forked from plainblack/Lacuna-Web-Client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuildingCapitol.js
75 lines (67 loc) · 2.93 KB
/
buildingCapitol.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
YAHOO.namespace("lacuna.buildings");
if (typeof YAHOO.lacuna.buildings.Capitol == "undefined" || !YAHOO.lacuna.buildings.Capitol) {
(function(){
var Util = YAHOO.util,
Dom = Util.Dom,
Event = Util.Event,
Lacuna = YAHOO.lacuna,
Game = Lacuna.Game,
Lib = Lacuna.Library;
var Capitol = function(result){
Capitol.superclass.constructor.call(this, result);
this.service = Game.Services.Buildings.Capitol;
};
YAHOO.lang.extend(Capitol, Lacuna.buildings.Building, {
getChildTabs : function() {
return [this._getRenameTab()];
},
_getRenameTab : function() {
var div = document.createElement("div");
Dom.addClass(div, 'capitolEmpireRenameTab');
div.innerHTML = [
'<p>',
' Current empire name: <span id="capitolCurrentEmpireName">', Game.EmpireData.name, '</span>',
'</p>',
'<fieldset style="text-align: center">',
' <legend>Change Empire Name</legend>',
' <div><label>Cost to change:<span class="smallImg"><img src="',Lib.AssetUrl,'ui/s/essentia.png" class="smallEssentia" title="Essentia" /></span>',this.result.rename_empire_cost,'</label></div>',
' <div><label>New empire name: <input type="text" id="capitolNewEmpireName"></input></label></div>',
' <div><button id="capitolChangeEmpireName">Change Name</button></div>',
'</fieldset>'
].join('');
Event.on('capitolChangeEmpireName', "click", this.RenameEmpire, this, true);
var tab = new YAHOO.widget.Tab({ label: "Rename Empire", contentEl: div});
return tab;
},
RenameEmpire : function(e) {
Event.stopEvent(e);
var btn = Event.getTarget(e);
var newName = Dom.get('capitolNewEmpireName').value;
Lacuna.Pulser.Show();
btn.disabled = true;
this.service.rename_empire({
session_id:Game.GetSession(),
building_id:this.building.id,
name: newName
}, {
success : function(o){
YAHOO.log(o, "info", "Capitol.rename_empire.success");
btn.disabled = false;
Dom.get('capitolNewEmpireName').value = '';
Dom.get('capitolCurrentEmpireName').innerHTML = newName;
Lacuna.Pulser.Hide();
this.rpcSuccess(o);
alert('Your empire name has been changed!');
},
failure : function(o){
btn.disabled = false;
},
scope:this
});
}
});
Lacuna.buildings.Capitol = Capitol;
})();
YAHOO.register("Capitol", YAHOO.lacuna.buildings.Capitol, {version: "1", build: "0"});
}
// vim: noet:ts=4:sw=4