var config = {}; config.images = []; window.mode = 'omnivore' function app(){}; app.init = function(){ app.load(); } app.load = function(){ app.loader = new Loader (); app.loader.register("loading"); app.flatfiles = [ new Flatfile ("vegan", "products.default.txt") , new Flatfile ("dairy", "products.dairy.txt") , new Flatfile ("esoteric", "products.esoteric.txt") , new Flatfile ("meat", "products.meat.txt") , new Flatfile ("seafood", "products.seafood.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"); } app.ready = function(){ console.log("READY"); app.bind(); app.generate(); } 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(){ 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 = "
" + course.join(", ") + "
" texts.push(text); } $("#result").html(texts.join("")); }