-
Notifications
You must be signed in to change notification settings - Fork 0
/
fightsim-ui.js
65 lines (59 loc) · 1.92 KB
/
fightsim-ui.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
var FightsimUi = {
// http://www.siedlertools.de/wiki/Einheiten%C3%BCbersicht
icons: {
R: "http://www.siedlertools.de/w/images/e/eb/Icon_recruit.png",
M: "http://www.siedlertools.de/w/images/9/98/Icon_militia.png",
S: "http://www.siedlertools.de/w/images/c/c3/Icon_soldier.png",
E: "http://www.siedlertools.de/w/images/2/28/Icon_elite_soldier.png",
C: "http://www.siedlertools.de/w/images/1/15/Cavalry.png",
B: "http://www.siedlertools.de/w/images/5/5b/Icon_bowman.png",
LB: "http://www.siedlertools.de/w/images/2/2f/Icon_longbowman.png",
A: "http://www.siedlertools.de/w/images/6/6e/Icon_crossbowman.png",
K: "http://www.siedlertools.de/w/images/4/49/Icon_cannonier.png",
G: "http://www.siedlertools.de/w/images/b/b8/Icon_general2.png"
},
labels: {
R: "Rekrut",
M: "Miliz",
S: "Soldat",
E: "Elitesoldat",
C: "Reiter",
B: "Bogenschütze",
LB: "Langbogenschütze",
A: "Armbrustschütze",
K: "Kanonier",
G: "General"
},
printUnit: function(unitLetter) {
var icon = this.icons[unitLetter];
var text = this.labels[unitLetter];
var html = "<span class='unit'>";
html += Html.tag("input", { class: "spinner", name: unitLetter, size: 3, value: 0 } );
html += Html.tag("img", { src: icon, alt: unitLetter });
html += " " + text;
html += "</span>";
return html;
},
printUnits: function(unitLetters) {
var html = "";
var _this = this;
$.each(unitLetters, function(key, value) {
html += _this.printUnit(value);
html += Html.tag("br");
});
return html;
},
parseUnits: function(selector) {
var units = {};
// body > table > tbody > tr:nth-child(2) > td.left > span:nth-child(20) > span > input
$(selector + " .unit input").each(function(i, e) {
var n = e.name;
var c = e.value;
units[n] = c;
});
return units;
},
init: function() {
$( ".unit .spinner" ).spinner({min: 0, max: 250});
}
}