summaryrefslogtreecommitdiff
path: root/js/app.js
blob: fa2711ed0682ad1d83db20ddc639438882619b59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
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 = "<h2>" + courseName + "</h2>";
		var course = []
		for (var j = 1; j < courses[i].length; j++) {
			course.push( dish(courses[i][j]) )
		}
                text += "<p>" + course.join(", ") + "</p>"
		texts.push(text);
	}
	$("#result").html(texts.join(""));
}