This repository has been archived by the owner on Nov 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
engine.js
153 lines (143 loc) · 4.13 KB
/
engine.js
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
// Generated by CoffeeScript 1.6.3
var Map, render_hub_scene, render_hub_verb, render_page, states, __,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
__ = function() {
console.log.apply(console, arguments);
return arguments[0];
};
Map = window.Map;
states = {
scene: function(scene, node) {
render_page(node);
return render_hub_scene(scene, {
click_verb: function(verb) {
return states.verb(scene, verb);
}
});
},
verb: function(scene, verb) {
return render_hub_verb(scene, verb, {
click_back: function() {
return states.scene(scene);
},
click_word: function(word) {
var node, sk, sv, vk, vv, wk, wv, _base, _ref, _ref1;
node = Map[scene][verb][word];
_ref = node.set;
for (sk in _ref) {
sv = _ref[sk];
if (Map[sk] == null) {
Map[sk] = sv;
}
for (vk in sv) {
vv = sv[vk];
if ((_base = Map[sk])[vk] == null) {
_base[vk] = vv;
}
for (wk in vv) {
wv = vv[wk];
Map[sk][vk][wk] = wv;
}
}
}
if (node.del != null) {
for (sk in Map) {
sv = Map[sk];
for (vk in sv) {
vv = sv[vk];
for (wk in vv) {
wv = vv[wk];
if (__indexOf.call(node.del, wk) >= 0) {
delete vv[wk];
}
}
if (__indexOf.call(node.del, vk) >= 0 || _.isEmpty(sv[vk])) {
delete sv[vk];
}
}
}
}
try {
delete Map[scene][verb][word];
} catch (_error) {}
if (((node != null ? (_ref1 = node.del) != null ? _ref1.length : void 0 : void 0) === 0) || _.isEmpty(Map[scene][verb])) {
delete Map[scene][verb];
}
return states.scene(node.scene || scene, node);
}
});
}
};
render_hub_scene = function(scene, _arg) {
var click_verb, el, v, _i, _len, _ref, _results;
click_verb = _arg.click_verb;
$('#verbs').empty();
$('#words').empty();
_ref = _.keys(Map[scene]);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
v = _ref[_i];
el = $("<div class='left button'>" + v + "</div>");
el.on('mouseup', (function(v) {
return function() {
return click_verb(v);
};
})(v));
_results.push($('#verbs').append(el));
}
return _results;
};
render_hub_verb = function(scene, verb, _arg) {
var ce, click_back, click_word, el, node, w, _i, _len, _ref, _results;
click_word = _arg.click_word, click_back = _arg.click_back;
node = Map[scene][verb];
$('#verbs').empty();
$('#words').empty();
ce = $("<div class='selected left button'>" + verb + "</div>");
ce.on('mouseup', click_back);
$('#verbs').append(ce);
_ref = _.keys(Map[scene][verb]);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
w = _ref[_i];
el = $("<div class='right button'>" + w + "</div>");
el.on('mouseup', (function(w) {
return function() {
return click_word(w);
};
})(w));
el.on('mouseenter', (function(el) {
return function() {
return $('.selected.button').css({
top: (el.position().top) + 'px'
});
};
})(el));
_results.push($('#words').append(el));
}
return _results;
};
render_page = function(node) {
if (node == null) {
return;
}
if (node.scene != null) {
$('#page').append("<pre class='inter'>***");
}
if (node.img != null) {
$('#page').append("<pre class='inter'><img src='img/" + node.img + "'></pre>");
}
if (node.bg != null) {
$('body').css({
background: "url(img/" + node.bg + ")"
});
}
$('#page').append("<pre> " + (node.t || node));
return $('#page').scrollTop($('#page')[0].scrollHeight);
};
$('#page').append("<pre class='inter title'>" + Map.opening.title);
$('#page').append("<pre> " + Map.opening.t);
states.scene(Map.opening.sc);
/*
//@ sourceMappingURL=engine.map
*/