diff options
Diffstat (limited to 'js')
| -rwxr-xr-x[-rw-r--r--] | js/app.js | 33 | ||||
| -rwxr-xr-x[-rw-r--r--] | js/course.js | 2 | ||||
| -rwxr-xr-x[-rw-r--r--] | js/flatfile.js | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | js/jquery-2.0.3.min.js | 0 | ||||
| -rwxr-xr-x[-rw-r--r--] | js/loader.js | 3 | ||||
| -rwxr-xr-x[-rw-r--r--] | js/util.js | 0 |
6 files changed, 33 insertions, 5 deletions
diff --git a/js/app.js b/js/app.js index 6b60d3b..fa2711e 100644..100755 --- a/js/app.js +++ b/js/app.js @@ -1,5 +1,6 @@ var config = {}; config.images = []; +window.mode = 'omnivore' function app(){}; app.init = function(){ @@ -15,9 +16,15 @@ app.load = function(){ , new Flatfile ("esoteric", "products.esoteric.txt") , new Flatfile ("meat", "products.meat.txt") , new Flatfile ("seafood", "products.seafood.txt") - , new Flatfile ("weird", "products.esoteric.txt") , new Flatfile ("techniques", "techniques.txt") , new Flatfile ("preparations", "preparations.txt") + , new Flatfile ("cereal", "cereal.txt") + , new Flatfile ("diseases", "diseases.txt") + , new Flatfile ("drugs", "drugs.txt") + , new Flatfile ("elements", "elements.txt") + , new Flatfile ("insects", "insects.txt") + , new Flatfile ("sf", "sf.txt") + , new Flatfile ("religions", "religions.txt") ]; app.loader.ready("loading"); @@ -31,20 +38,38 @@ app.ready = function(){ app.bind = function(){ $("#generate").click(app.generate); + $(".switch").click(app.switch_mode); +} + +app.switch_mode = function(){ + window.mode = $(this).html() + $('.active').removeClass('active') + $(this).addClass('active') + app.generate() } app.generate = function(){ - window.products = [].concat(vegan,meat,dairy,seafood); + if (mode == 'omnivore') { + window.products = [].concat(vegan,meat,dairy,seafood); + } else if (mode == 'vegan') { + window.products = [].concat(vegan); + } else if (mode == 'weirdo') { + window.products = [].concat(vegan,meat,dairy,seafood,esoteric); + } else { + window.products = [].concat(window[mode]) + } +console.log(window.products) var texts = []; for (var i = 0; i < courses.length; i++) { var courseName = courses[i][0]; var text = "<h2>" + courseName + "</h2>"; + var course = [] for (var j = 1; j < courses[i].length; j++) { - text += "<p>" + dish(courses[i][j]) + "</p>"; + course.push( dish(courses[i][j]) ) } + text += "<p>" + course.join(", ") + "</p>" texts.push(text); } - console.log(texts) $("#result").html(texts.join("")); } diff --git a/js/course.js b/js/course.js index d147a9f..2a35719 100644..100755 --- a/js/course.js +++ b/js/course.js @@ -28,7 +28,7 @@ function dish(n){ } function product(){ var result; - if (rand(100) > 80) { + if (rand(100) > 1) { var technique = choice(techniques); if (technique[0] == '-') { result = choice(products) + technique + " " + choice(products); diff --git a/js/flatfile.js b/js/flatfile.js index 89a6b17..89a6b17 100644..100755 --- a/js/flatfile.js +++ b/js/flatfile.js diff --git a/js/jquery-2.0.3.min.js b/js/jquery-2.0.3.min.js index 2be209d..2be209d 100644..100755 --- a/js/jquery-2.0.3.min.js +++ b/js/jquery-2.0.3.min.js diff --git a/js/loader.js b/js/loader.js index ddf4b7e..90f04c7 100644..100755 --- a/js/loader.js +++ b/js/loader.js @@ -21,6 +21,9 @@ app.load = function(){ } app.ready = function(){ } +// so basically he also puts a bunch of variables in the global namespace. Does that seem +// contradictory to an OOP approach? in global namespace where will be only app variable. no there are also +// ******************************************************/ function Loader (readyCallback){ diff --git a/js/util.js b/js/util.js index 5828a91..5828a91 100644..100755 --- a/js/util.js +++ b/js/util.js |
