forked from plainblack/Lacuna-Web-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildingLibraryOfJith.js
151 lines (134 loc) · 5.9 KB
/
buildingLibraryOfJith.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
YAHOO.namespace("lacuna.buildings");
if (typeof YAHOO.lacuna.buildings.LibraryOfJith == "undefined" || !YAHOO.lacuna.buildings.LibraryOfJith) {
(function(){
var Lang = YAHOO.lang,
Util = YAHOO.util,
Dom = Util.Dom,
Event = Util.Event,
Pager = YAHOO.widget.Paginator,
Sel = Util.Selector,
Lacuna = YAHOO.lacuna,
Game = Lacuna.Game,
Lib = Lacuna.Library;
var LibraryOfJith = function(result){
LibraryOfJith.superclass.constructor.call(this, result);
this.service = Game.Services.Buildings.LibraryOfJith;
this.maps = {};
this.subscribe("onLoad", this.createFind, this, true);
};
Lang.extend(LibraryOfJith, Lacuna.buildings.Building, {
getChildTabs : function() {
return [this._getTab()];
},
_getTab : function() {
this.libraryTab = new YAHOO.widget.Tab({ label: "Species Library", content: [
'<div>',
' <div><label for="lojFindEmpire">Lookup by Empire Name:</label><div style="display:inline-block;width:300px;"><input type="text" id="lojFindEmpire" /></div></div>',
' <ul id="lojDetails" style="margin-top:5px;overflow-y:auto;">',
' </ul>',
'</div>'
].join('')});
return this.libraryTab;
},
createFind : function() {
this.species = Dom.get("lojDetails");
var dataSource = new Util.XHRDataSource("/empire");
dataSource.connMethodPost = "POST";
dataSource.maxCacheEntries = 2;
dataSource.responseType = YAHOO.util.XHRDataSource.TYPE_JSON;
dataSource.responseSchema = {
resultsList : "result.empires",
fields : ["name","id"]
};
var oTextboxList = new YAHOO.lacuna.TextboxList("lojFindEmpire", dataSource, { //config options
maxResultsDisplayed: 25,
minQueryLength:3,
multiSelect:false,
forceSelection:false,
useIndicator:true
});
oTextboxList.generateRequest = function(sQuery){
var s = Lang.JSON.stringify({
"id": YAHOO.rpc.Service._requestId++,
"method": "find",
"jsonrpc": "2.0",
"params": [
Game.GetSession(""),
decodeURIComponent(sQuery)
]
});
return s;
};
oTextboxList.dirtyEvent.subscribe(function(event, isDirty, oSelf){
var empire = this._oTblSingleSelection.Object;
oSelf.getSpecies(empire.id);
},this);
this.find = oTextboxList;
},
getSpecies : function(id) {
Lacuna.Pulser.Show();
this.service.research_species({session_id:Game.GetSession(),building_id:this.building.id, empire_id:id}, {
success : function(o){
Lacuna.Pulser.Hide();
this.rpcSuccess(o);
this.speciesDisplay(o.result.species);
},
scope:this
});
},
speciesDisplay : function(stat) {
this.species.innerHTML = [
'<li style="border-bottom:1px solid #52ACFF;font-size:120%;"><label>',stat.name,'</label></li>',
'<li style="padding-bottom:5px;">', stat.description, '</li>',
'<li>',
' <label>Habitable Orbits:</label><span>', stat.min_orbit, stat.max_orbit > stat.min_orbit ? ' to '+ stat.max_orbit : '','</span>',
'</li>',
'<li>',
' <label>Manufacturing:</label><span>', stat.manufacturing_affinity, '</span>',
'</li>',
'<li>',
' <label>Deception:</label><span>', stat.deception_affinity, '</span>',
'</li>',
'<li>',
' <label>Research:</label><span>', stat.research_affinity, '</span>',
'</li>',
'<li>',
' <label>Management:</label><span>', stat.management_affinity, '</span>',
'</li>',
'<li>',
' <label>Farming:</label><span>', stat.farming_affinity, '</span>',
'</li>',
'<li>',
' <label>Mining:</label><span>', stat.mining_affinity, '</span>',
'</li>',
'<li>',
' <label>Science:</label><span>', stat.science_affinity, '</span>',
'</li>',
'<li>',
' <label>Environmental:</label><span>', stat.environmental_affinity, '</span>',
'</li>',
'<li>',
' <label>Political:</label><span>', stat.political_affinity, '</span>',
'</li>',
'<li>',
' <label>Trade:</label><span>', stat.trade_affinity, '</span>',
'</li>',
'<li>',
' <label>Growth:</label><span>', stat.growth_affinity, '</span>',
'</li>'
].join('');
//wait for tab to display first
setTimeout(function() {
var Ht = Game.GetSize().h - 180;
if(Ht > 300) { Ht = 300; }
var tC = Dom.get('lojDetails');
Dom.setStyle(tC,"height",Ht + "px");
Dom.setStyle(tC,"overflow-y","auto");
},10);
}
});
YAHOO.lacuna.buildings.LibraryOfJith = LibraryOfJith;
})();
YAHOO.register("libraryofjith", YAHOO.lacuna.buildings.LibraryOfJith, {version: "1", build: "0"});
}
// vim: noet:ts=4:sw=4