0) {
- this.preferences.put(keys[i], p);
- } else {
- this.preferences.put(keys[i], defs[i]);
- }
- }
- } else {
- // We're not inside Dashboard. Use defaults.
- for (var i in keys) {
- this.preferences.put(keys[i], defs[i]);
- }
- }
- },
-
-
- getPreference: function (key) {
- return (this.preferences.containsKey(key) ? this.preferences.get(key) : null);
- },
-
-
- setPreference: function (key, value) {
- if (this.preferences.containsKey(key) && typeof value == 'string') {
- Base.Log.write("Setting preference " + key + " to '" + value + "'");
- this.preferences.put(key, value);
- if (window.widget) {
- widget.setPreferenceForKey(key, value);
- }
- }
- },
-
- showDebug: function () {
- if (!this.debugPanel) {
- this.debugPanel = new LWWidget.Debug();
- }
- this.debugPanel.show();
- }
-
-
-}, {
-
- // Base URL for the LegacyWorlds website.
- base: 'http://www.legacyworlds.com',
-
- // Enable/disable debugging
- debug: true,
-
- // This widget's version number
- version: 1,
-
- // Main widget instance
- main: null,
-
- // Password storage
- password: '',
-
- // When the widget page is loaded, initialise the component
- onLoad: function () {
- new LWWidget();
- }
-
-}, "LWWidget");
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5.js
deleted file mode 100644
index 2a4e2f0..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5.js
+++ /dev/null
@@ -1,77 +0,0 @@
-LWWidget.Beta5 = LWWidget.Game.inherits({
-
- constructor: function (path) {
- this.base(path);
- this.pageElement = 'b5Display';
-
- this.pages[0] = new LWWidget.Beta5.Player(this);
- this.pages[1] = new LWWidget.Beta5.Planets(this);
- this.pages[2] = new LWWidget.Beta5.Fleets(this);
- this.pages[3] = new LWWidget.Beta5.Cash(this);
- this.pages[4] = new LWWidget.Beta5.Techs(this);
- this.pages[5] = new LWWidget.Beta5.Msg(this);
- this.pages[6] = new LWWidget.Beta5.Forums(this);
- this.pages[7] = new LWWidget.Beta5.Ticks(this);
-
- this.setPage('player');
-
- this.addSlot('updateServerTime');
- this.stUpdate = new Base.Timer(1000, true);
- this.stUpdate.bindEvent('Tick', 'updateServerTime', this);
- this.stUpdate.start();
- },
-
- destroy: function () {
- this.stUpdate.destroy();
- this.base();
- },
-
-
- setData: function (data) {
- this.base(data);
- this.serverTime = parseInt(data.getAttribute('serverTime'), 10);
- this.drawServerTime();
- },
-
-
- draw: function () {
- var _e = document.getElementById('gDisplay');
- if (!_e) {
- return;
- }
-
- var _e2 = document.getElementById('b5Display');
- if (!_e2) {
- _e.style.overflow = 'visible';
- _e.innerHTML = '';
- }
- this.drawServerTime();
-
- this.base();
- },
-
-
- updateServerTime: function () {
- if (!this.serverTime) {
- return;
- }
- this.serverTime ++;
- this.drawServerTime();
- },
-
- drawServerTime: function (u) {
- var _e = document.getElementById('serverTime');
- if (!_e || !this.serverTime) {
- return;
- }
-
- _e.innerHTML = LWWidget.Game.formatTime(this.serverTime);
- }
-
-});
-
-// Register the version
-LWWidget.Game.versions().put('beta5', LWWidget.Beta5);
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Cash.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Cash.js
deleted file mode 100644
index bcde32d..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Cash.js
+++ /dev/null
@@ -1,17 +0,0 @@
-LWWidget.Beta5.Cash = LWWidget.Game.Page.inherits({
-
- setData: function (data) {
- var _d = data.getChildren('Empire')[0].getChildren('Budget')[0];
-
- this.income = parseInt(_d.getAttribute('income'), 10);
- this.upkeep = parseInt(_d.getAttribute('upkeep'), 10);
- this.profit = parseInt(_d.getAttribute('profit'), 10);
- },
-
- draw: function (_e) {
- _e.innerHTML = '
Planetary income: €' + Base.Util.formatNumber(this.income)
- + '
Fleet upkeep: €' + Base.Util.formatNumber(this.upkeep)
- + '
Daily profit: €' + Base.Util.formatNumber(this.profit) + '
';
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Fleets.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Fleets.js
deleted file mode 100644
index a405286..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Fleets.js
+++ /dev/null
@@ -1,55 +0,0 @@
-LWWidget.Beta5.Fleets = LWWidget.Game.Page.inherits({
-
- setData: function (data) {
- var _d = data.getChildren('Empire')[0].getChildren('Fleets')[0];
-
- this.fleets = parseInt(_d.getAttribute('count'), 10);
- if (this.fleets) {
- // Fleets in battle
- this.inBattle = parseInt(_d.getAttribute('inBattle'), 10);
- // Total fleet power
- this.power = parseInt(_d.getAttribute('power'), 10);
- // Ships types
- this.gaships = parseInt(_d.getAttribute('gaships'), 10);
- this.fighters = parseInt(_d.getAttribute('fighters'), 10);
- this.cruisers = parseInt(_d.getAttribute('cruisers'), 10);
- this.bcruisers = parseInt(_d.getAttribute('bcruisers'), 10);
- // Upkeep
- _d = data.getChildren('Empire')[0].getChildren('Budget')[0];
- this.upkeep = parseInt(_d.getAttribute('upkeep'), 10);
- }
- },
-
- draw: function (_e) {
- if (this.fleets == 0) {
- _e.innerHTML = 'No fleets
';
- return;
- }
-
- var _s = '' + Base.Util.formatNumber(this.fleets)
- + ' fleet' + (this.fleets > 1 ? 's' : '');
- if (this.inBattle) {
- _s += ' (' + Base.Util.formatNumber(this.inBattle) + ' engaged in battle!)';
- }
- _s += '
Total fleet power: ' + Base.Util.formatNumber(this.power)
- + '
Upkeep: €' + Base.Util.formatNumber(this.upkeep)
- + '
Ship types
';
-
- if (this.gaships) {
- _s += 'G.A. ships: ' + Base.Util.formatNumber(this.gaships) + '
';
- }
- if (this.fighters) {
- _s += 'Fighters: ' + Base.Util.formatNumber(this.fighters) + '
';
- }
- if (this.cruisers) {
- _s += 'Cruisers: ' + Base.Util.formatNumber(this.cruisers) + '
';
- }
- if (this.bcruisers) {
- _s += 'Battle Cruisers: ' + Base.Util.formatNumber(this.bcruisers) + '
';
- }
- _s += '
';
-
- _e.innerHTML = _s;
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Forums.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Forums.js
deleted file mode 100644
index 4e4d3e2..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Forums.js
+++ /dev/null
@@ -1,125 +0,0 @@
-LWWidget.Beta5.Forums = LWWidget.Game.Page.inherits({
-
- switchMode: function () {
- this.details = !this.details;
- this.game.draw();
- },
-
- setData: function (data) {
- var _f = data.getChildren('Communications')[0].getChildren('Forums')[0];
-
- // Read general forums
- var gf = _f.getChildren('GeneralForums'), gcats = new Base.Util.Hashtable();
- for (var i in gf) {
- var c = gf[i], desc = c.getChildren('Description')[0].getText(),
- cf = c.getChildren('Forum'), forums = new Array();
- for (var j in cf) {
- forums.push([cf[j].getText(), parseInt(cf[j].getAttribute('topics'), 10), parseInt(cf[j].getAttribute('unread'), 10)]);
- }
- gcats.put(desc, forums);
- }
-
- // Read alliance forums
- var af = _f.getChildren('AllianceForums'), aForums = new Array();
- if (af.length) {
- af = af[0].getChildren('Forum');
- for (var i in af) {
- aForums.push([af[i].getText(), parseInt(af[i].getAttribute('topics'), 10), parseInt(af[i].getAttribute('unread'), 10)]);
- }
- }
-
- // Store data
- this.general = gcats;
- this.alliance = aForums;
- },
-
-
- show: function () {
- this.details = false;
- },
-
- draw: function (_e) {
- if (this.details) {
- _e.innerHTML = this.getDetailedHTML();
- } else {
- _e.innerHTML = this.getShortHTML();
- }
- },
-
-
- getShortHTML: function () {
- var text = new Array(), gk = this.general.keys();
- for (var i in gk) {
- text.push(this.catSummary(gk[i], this.general.get(gk[i])));
- }
-
- if (this.alliance.length) {
- text.push(this.catSummary('Alliance forums', this.alliance));
- }
-
- return '' + text.join('
') + '
Show details';
- },
-
- catSummary: function (name, list) {
- var s = '' + name + ': ';
-
- var unread = this.countUnread(list);
- if (unread > 0) {
- s += '' + Base.Util.formatNumber(unread) + ' unread topic' + (unread > 1 ? 's' : '');
- } else {
- s += 'no unread topics';
- }
- return s;
- },
-
- countUnread: function (forums) {
- var s = 0;
- for (var i in forums) {
- s += forums[i][2];
- }
- return s;
- },
-
-
- getDetailedHTML: function () {
- var text = new Array(), gk = this.general.keys();
-
- for (var i in gk) {
- text.push(this.catDetailed(gk[i], this.general.get(gk[i])));
- }
-
- if (this.alliance.length) {
- text.push(this.catDetailed('Alliance forums', this.alliance));
- }
-
- return '
Hide details
' + text.join('
');
- },
-
- catDetailed: function (name, forums) {
- if (!forums.length) {
- return "";
- }
-
- var text = new Array();
-
- text.push('' + name + '');
- for (var i in forums) {
- var f = forums[i], s = '' + f[0] + ': ';
-
- if (f[1]) {
- s += '' + Base.Util.formatNumber(f[1]) + ' topic' + (f[1] > 1 ? 's' : '');
- if (f[2]) {
- s += ' (' + Base.Util.formatNumber(f[2]) + ' unread)';
- }
- } else {
- s += 'empty forum';
- }
- text.push(s);
- }
-
- return text.join('
');
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Msg.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Msg.js
deleted file mode 100644
index 682b04f..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Msg.js
+++ /dev/null
@@ -1,71 +0,0 @@
-LWWidget.Beta5.Msg = LWWidget.Game.Page.inherits({
-
- setData: function (data) {
- var _d = data.getChildren('Communications')[0].getChildren('Messages')[0];
-
- // Get default folders
- var _f = _d.getChildren('DefaultFolder');
- for (var i in _f) {
- var _a = [parseInt(_f[i].getAttribute('all'), 10), parseInt(_f[i].getAttribute('new'), 10)];
- switch (_f[i].getAttribute('id')) {
- case 'IN': this.inbox = _a; break;
- case 'INT': this.internal = _a; break;
- case 'OUT': this.outbox = _a; break;
- }
- }
-
- // Get custom folders
- this.custom = new Base.Util.Hashtable();
- _f = _d.getChildren('CustomFolder');
- for (var i in _f) {
- this.custom.put(_f[i].getAttribute('id'), [parseInt(_f[i].getAttribute('all'), 10), parseInt(_f[i].getAttribute('new'), 10), _f[i].getText()]);
- }
- },
-
- show: function () {
- this.dCustom = false;
- },
-
- draw: function (_e) {
- var _s = '
';
- _s += this.folderCode('Inbox', this.inbox[0], this.inbox[1]) + '
';
- _s += this.folderCode('Transmissions', this.internal[0], this.internal[1]) + '
'
- _s += this.folderCode('Sent messages', this.outbox[0], this.outbox[1]) + '
';
-
- if (this.custom.isEmpty()) {
- _s += 'No custom folders';
- } else if (this.dCustom) {
- _s += 'Hide custom folders
';
- var cf = this.custom.values();
- for (var i in cf) {
- _s += this.folderCode(cf[i][2], cf[i][0], cf[i][1]) + '
';
- }
- } else {
- _s += 'Display custom folders';
- }
-
- _s += '
';
- _e.innerHTML = _s;
- },
-
- folderCode: function (name, a, n) {
- var _s = '' + name + ': ';
- if (a) {
- if (n) {
- _s += '' + Base.Util.formatNumber(n) + ' new message' + (n > 1 ? 's' : '');
- } else {
- _s += 'no new messages';
- }
- _s += ' (' + Base.Util.formatNumber(a) + ' total)';
- } else {
- _s += 'no messages';
- }
- return _s;
- },
-
- switchCustom: function () {
- this.dCustom = !this.dCustom;
- this.game.draw();
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Planets.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Planets.js
deleted file mode 100644
index 1cdaaa3..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Planets.js
+++ /dev/null
@@ -1,86 +0,0 @@
-LWWidget.Beta5.Planets = LWWidget.Game.Page.inherits({
-
- setData: function (data) {
- var _d = data.getChildren('Empire')[0].getChildren('Planets')[0];
-
- this.planets = parseInt(_d.getAttribute('count'), 10);
- this.pList = new Array();
- if (this.planets) {
- // Planets under attack
- this.underAttack = parseInt(_d.getAttribute('siege'), 10);
- // Happiness / Corruption
- this.avgHappiness = parseInt(_d.getAttribute('avgHap'), 10);
- this.avgCorruption = parseInt(_d.getAttribute('avgCor'), 10);
- // Population
- this.totPopulation = parseInt(_d.getAttribute('totPop'), 10);
- this.avgPopulation = parseInt(_d.getAttribute('avgPop'), 10);
- // Factories
- this.totFactories = parseInt(_d.getAttribute('totFac'), 10);
- this.avgFactories = parseInt(_d.getAttribute('avgFac'), 10);
- // Factories
- this.totTurrets = parseInt(_d.getAttribute('totTur'), 10);
- this.avgTurrets = parseInt(_d.getAttribute('avgTur'), 10);
-
- // Planet list
- var _l = _d.getChildren('List')[0].getChildren('Planet');
- for (var i in _l) {
- this.pList.push(_l[i].getText());
- }
- }
- },
-
- show: function () {
- this.mode = 0;
- },
-
- draw: function (_e) {
- _e.innerHTML = (this.mode == 0 || !this.planets) ? this.getStats() : this.getList();
- },
-
- setMode: function (m) {
- this.mode = m;
- if (this.game) {
- this.game.draw();
- }
- },
-
-
- getStats: function () {
- if (this.planets == 0) {
- return 'No planets.
';
- }
-
- var _s = '' + Base.Util.formatNumber(this.planets) + ' planet'
- + (this.planets > 1 ? 's' : '') + '
';
- if (this.underAttack) {
- _s += '' + Base.Util.formatNumber(this.underAttack) + ' planet'
- + (this.underAttack > 1 ? 's' : '') + ' under attack!';
- } else {
- _s += 'No planets under attack';
- }
-
- _s += '
Average happiness: ' + this.avgHappiness + '%
Average corruption: '
- + this.avgCorruption + '%
Population: ' + Base.Util.formatNumber(this.totPopulation) + '';
- if (this.planets > 1) {
- _s += ' (' + Base.Util.formatNumber(this.avgPopulation) + ' on average)';
- }
- _s += '
Factories: ' + Base.Util.formatNumber(this.totFactories) + '';
- if (this.planets > 1) {
- _s += ' (' + Base.Util.formatNumber(this.avgFactories) + ' on average)';
- }
- _s += '
Turrets: ' + Base.Util.formatNumber(this.totTurrets) + '';
- if (this.planets > 1) {
- _s += ' (' + Base.Util.formatNumber(this.avgTurrets) + ' on average)';
- }
- _s += '
View list
';
-
- return _s;
- },
-
- getList: function () {
- return '<<- Back
'
- + this.pList.join('
') + '
';
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Player.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Player.js
deleted file mode 100644
index cec2b9d..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Player.js
+++ /dev/null
@@ -1,82 +0,0 @@
-LWWidget.Beta5.Player = LWWidget.Game.Page.inherits({
-
- setData: function (data) {
- var _d = data.getChildren('Player')[0];
-
- // Player name and cash
- this.playerName = _d.getAttribute('name');
- this.cash = _d.getAttribute('cash');
-
- // Alliance status
- var _a = _d.getChildren('Alliance');
- if (_a.length) {
- _a = _a[0];
- this.alliance = { joined: (_a.getAttribute('inalliance') == '1'), tag: _a.getAttribute('tag') };
- } else {
- this.alliance = null;
- }
-
- // General rankings
- _a = _d.getChildren('Rankings')[0];
- var _r = _a.getChildren('Ranking');
- for (var i in _r) {
- if (_r[i].getText() != 'General Ranking') {
- continue;
- }
- this.points = _r[i].getAttribute('points');
- this.rank = _r[i].getAttribute('rank');
- break;
- }
-
- // Planets / planets under attack
- _d = data.getChildren('Empire')[0].getChildren('Planets')[0];
- this.planets = parseInt(_d.getAttribute('count'), 10);
- this.underAttack = parseInt(_d.getAttribute('siege'), 10);
-
- // Fleets / fleets in battle
- _d = data.getChildren('Empire')[0].getChildren('Fleets')[0];
- this.fleets = parseInt(_d.getAttribute('count'), 10);
- this.inBattle = parseInt(_d.getAttribute('inBattle'), 10);
- },
-
- draw: function (_e) {
- if (!this.playerName) {
- return;
- }
-
- var str = 'Player ' + this.playerName + '';
- if (this.alliance && this.alliance.joined) {
- str += ' [' + this.alliance.tag + ']';
- } else if (this.alliance && !this.alliance.joined) {
- str += '
Requesting to join alliance [' + this.alliance.tag + ']';
- }
-
- str += '
Cash: €' + Base.Util.formatNumber(this.cash) + ''
- + '
General ranking: #' + Base.Util.formatNumber(this.rank) + ' ('
- + Base.Util.formatNumber(this.points) + ' points)
';
-
- if (this.planets == 0) {
- str += "No planets";
- } else {
- str += '' + Base.Util.formatNumber(this.planets) + ' planet' + (this.planets > 1 ? 's' : '');
- if (this.underAttack > 0) {
- str += ' (' + Base.Util.formatNumber(this.underAttack) + ' under attack!)';
- }
- }
- str += '
';
-
- if (this.fleets == 0) {
- str += "No fleets";
- } else {
- str += '' + Base.Util.formatNumber(this.fleets) + ' fleet' + (this.fleets > 1 ? 's' : '');
- if (this.inBattle > 0) {
- str += ' (' + Base.Util.formatNumber(this.inBattle) + ' in battle)';
- }
- }
-
- str += '
';
-
- _e.innerHTML = str;
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Techs.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Techs.js
deleted file mode 100644
index 03a12ea..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Techs.js
+++ /dev/null
@@ -1,37 +0,0 @@
-LWWidget.Beta5.Techs = LWWidget.Game.Page.inherits({
-
- setData: function (data) {
- var _d = data.getChildren('Empire')[0].getChildren('Research')[0];
-
- this.points = parseInt(_d.getAttribute('points'), 10);
- this.newTechs = parseInt(_d.getAttribute('new'), 10);
- this.foreseen = parseInt(_d.getAttribute('foreseen'), 10);
-
- _d = _d.getChildren('RBudget')[0];
- this.fundamental = parseInt(_d.getAttribute('fundamental'), 10);
- this.military = parseInt(_d.getAttribute('military'), 10);
- this.civilian = parseInt(_d.getAttribute('civilian'), 10);
- },
-
- draw: function (_e) {
- var _s = '';
- if (this.newTechs == 0) {
- _s += 'No new technologies discovered.';
- } else {
- _s += '' + this.newTechs + ' new technolog' + (this.newTechs > 1 ? 'ies' : 'y') + ' discovered.';
- }
- _s += '
';
- if (this.foreseen == 0) {
- _s += 'No breakthroughs foreseen.';
- } else {
- _s += '' + this.foreseen + ' breakthrough' + (this.foreseen > 1 ? 's' : '') + ' foreseen.';
- }
- _s += '
Research budget
' + Base.Util.formatNumber(this.points) + ' research points per day
'
- + this.fundamental + '% allocated to Fundamental research
'
- + this.military + '% allocated to Military research
'
- + this.civilian + '% allocated to Civilian research
';
-
- _e.innerHTML = _s;
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Ticks.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Ticks.js
deleted file mode 100644
index 30a0626..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Beta5/Ticks.js
+++ /dev/null
@@ -1,121 +0,0 @@
-LWWidget.Beta5.Ticks = LWWidget.Game.Page.inherits({
-
- constructor: function (game) {
- this.base(game);
-
- this.addSlot('update');
- this.timer = new Base.Timer(1000, true);
- this.timer.bindEvent('Tick', 'update', this);
- },
-
- destroy: function () {
- this.timer.destroy();
- this.base();
- },
-
-
- setData: function (data) {
- var tList = data.getChildren('Ticks')[0].getChildren('Tick'), ticks = new Array();
-
- for (var i in tList) {
- var tick = new Array();
- tick[0] = tList[i].getText();
- tick[1] = parseInt(tList[i].getAttribute('first'), 10);
- tick[2] = parseInt(tList[i].getAttribute('interval'), 10);
-
- var l = tList[i].getAttribute('last');
- if (typeof l == 'string') {
- tick[3] = parseInt(l, 10);
- } else {
- tick[3] = null;
- }
-
- ticks.push(tick);
- }
-
- this.tDiff = (new Date()).getTime() - (parseInt(data.getAttribute('serverTime'), 10) * 1000);
- this.ticks = ticks;
- },
-
-
- show: function () {
- this.timer.start();
- },
-
- hide: function () {
- this.timer.stop();
- },
-
-
- draw: function (_e) {
- var text = new Array();
-
- for (var i in this.ticks) {
- text.push('Next ' + this.ticks[i][0] + ': ');
- }
-
- _e.innerHTML = '' + text.join('
') + '
';
- this.update();
- },
-
-
- update: function () {
- this.computeNextTicks();
-
- for (var i in this.ticks) {
- var t;
-
- if (typeof this.ticks[i][5] == 'number') {
- var d, h, m, s;
-
- h = this.ticks[i][5] % 86400; d = (this.ticks[i][5] - h) / 86400;
- m = h % 3600; h = (h - m) / 3600;
- s = m % 60; m = (m - s) / 60;
-
- if (h < 10) { h = '0' + h; }
- if (m < 10) { m = '0' + m; }
- if (s < 10) { s = '0' + s; }
-
- t = '' + h + ':' + m + ':' + s + '';
- if (d > 0) {
- t = '' + d + ' day' + (d > 1 ? 's' : '') + ', ' + t;
- }
- } else {
- t = 'never';
- }
-
- var e = document.getElementById('dtick' + i);
- if (!e) {
- break;
- }
- e.innerHTML = t;
- }
- },
-
- computeNextTicks: function () {
- var now = Math.round(((new Date()).getTime() - this.tDiff) / 1000);
- for (var i in this.ticks) {
- if (this.ticks[i][3] && now > this.ticks[i][3]) {
- this.ticks[i][4] = null;
- continue;
- }
-
- if (now <= this.ticks[i][1]) {
- this.ticks[i][4] = this.ticks[i][1];
- continue;
- }
-
- var d = now - this.ticks[i][1], m = (d - (d % this.ticks[i][2])) / this.ticks[i][2];
- this.ticks[i][4] = this.ticks[i][1] + (m + 1) * this.ticks[i][2];
- }
-
- for (var i in this.ticks) {
- if (typeof this.ticks[i][4] != 'number') {
- this.ticks[i][5] = null;
- } else {
- this.ticks[i][5] = this.ticks[i][4] - now;
- }
- }
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Data.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Data.js
deleted file mode 100644
index 44cc265..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Data.js
+++ /dev/null
@@ -1,25 +0,0 @@
-LWWidget.Data = Base.inherits({
-
- constructor: function (name) {
- this.base();
- this.name = name;
- this.attributes = new Base.Util.Hashtable();
- },
-
- setAttribute: function (name, value) {
- this.attributes.put(name, value);
- },
-
- getAttribute: function (name) {
- return (this.attributes.containsKey(name) ? this.attributes.get(name) : null);
- },
-
- getChildren: function (name) {
- return new Array();
- },
-
- getText: function () {
- return "";
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Data/Leaf.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Data/Leaf.js
deleted file mode 100644
index 217326a..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Data/Leaf.js
+++ /dev/null
@@ -1,12 +0,0 @@
-LWWidget.Data.Leaf = LWWidget.Data.inherits({
-
- constructor: function (name, text) {
- this.base(name);
- this.text = text;
- },
-
- getText: function () {
- return this.text;
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Data/Loader.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Data/Loader.js
deleted file mode 100644
index fccddc8..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Data/Loader.js
+++ /dev/null
@@ -1,130 +0,0 @@
-LWWidget.Data.Loader = Base.Comp.inherits({
-
- constructor: function (login, password) {
- this.base();
-
- this.addEvent('CommError');
- this.addEvent('FatalError');
- this.addEvent('Kick');
- this.addEvent('Load');
- this.addEvent('LoginFailure');
- this.addEvent('Maintenance');
-
- this.addSlot('loaderDestroyed');
- this.addSlot('dataReceived');
-
- this.loader = new Base.XMLLoader('', true);
- this.loader.bindEvent('Destroy', 'loaderDestroyed', this);
- this.loader.bindEvent('NetworkError', 'onCommError', this);
- this.loader.bindEvent('ServerError', 'onCommError', this);
- this.loader.bindEvent('Timeout', 'onCommError', this);
- this.loader.bindEvent('Unsupported', 'onCommError', this);
- this.loader.bindEvent('Aborted', 'onCommError', this);
- this.loader.bindEvent('Loaded', 'dataReceived', this);
-
- this.params = new Base.Util.Hashtable();
- this.params.put('__s', '1');
- this.params.put('__l', login);
- this.params.put('__p', password);
- },
-
- destroy: function () {
- if (this.loader) {
- this.loader.destroy();
- }
- this.base();
- },
-
-
- load: function (from) {
- if (this.loader.isLoading) {
- return false;
- }
- this.loader.changeParameters(LWWidget.base + '/index.php/' + from + '.xml');
- this.loader.load(this.params);
- },
-
-
- loaderDestroyed: function () {
- this.loader = null;
- },
-
-
- dataReceived: function (data) {
- var _xml = Base.Util.parseXML(data);
- if (!_xml) {
- this.onCommError();
- return;
- }
-
- var _doc = _xml.documentElement;
- if (_doc.nodeName == 'Maintenance') {
- var _r, _u, _c;
- _r = LWWidget.Data.Loader.getXMLText(_doc, 'Reason');
- _u = LWWidget.Data.Loader.getXMLText(_doc, 'Until');
- _c = LWWidget.Data.Loader.getXMLText(_doc, 'Current');
- this.onMaintenance(_r, _u, _c);
- } else if (_doc.nodeName == 'FatalError') {
- this.onFatalError(_doc.getAttribute('code'), LWWidget.Data.Loader.getXMLText(_doc, 'Text'));
- } else if (_doc.nodeName == 'Kicked') {
- this.onKick(LWWidget.Data.Loader.getXMLText(_doc, 'Reason'));
- } else if (_doc.nodeName == 'Failed') {
- this.onLoginFailure(_doc.getAttribute('code'));
- } else {
- var _data = LWWidget.Data.Loader.parse(_doc);
- if (_data) {
- this.onLoad(_data);
- } else {
- this.onCommError();
- }
- }
- }
-
-}, {
-
- getXMLText: function (node, name) {
- var _t = '';
- for (var i=0;iFlush log - Hide'
- + ' |
';
- document.getElementById('debugDiv').innerHTML = _str;
- this.drawLog();
- },
-
- clear: function () {
- Base.Log.flush();
- this.drawLog();
- },
-
- drawLog: function () {
- var _e = document.getElementById('dbgContents');
- if (!_e) {
- return;
- }
-
- var _l = Base.Log.get();
- if (_l.length == this.lastLength) {
- return;
- }
- this.lastLength = _l.length;
-
- var _s;
- if (_l.length == 0) {
- _s = 'The log is empty
';
- } else {
- _s = '';
- for (var i=_l.length;i>0;i--) {
- _s += '[' + i + '] ' + _l[i-1] + '
';
- }
- _s += '
';
- }
- _e.innerHTML = _s;
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Game.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Game.js
deleted file mode 100644
index 289e4c7..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Game.js
+++ /dev/null
@@ -1,168 +0,0 @@
-LWWidget.Game = Base.Comp.inherits({
-
- constructor: function (path) {
- this.base();
- this.path = path;
-
- this.addEvent('RequestUpdate');
- this.addSlot('startDataUpdate');
-
- this.pageElement = 'gDisplay';
-
- this.autoUpdate = new Base.Timer(30000, true);
- this.autoUpdate.bindEvent('Tick', 'startDataUpdate', this);
- this.autoUpdate.start();
-
- this.pages = [null, null, null, null, null, null, null, null];
- this.page = null;
- this.data = null;
- },
-
- destroy: function () {
- this.autoUpdate.destroy();
- if (this.page) {
- this.page.hide();
- this.page = null;
- }
- for (var i in this.pages) {
- if (this.pages[i]) {
- var _p = this.pages[i];
- this.pages[i] = null;
- _p.destroy();
- }
- }
- this.base();
- },
-
-
- startDataUpdate: function () {
- this.onRequestUpdate(this.path);
- },
-
- setData: function (data) {
- this.data = data;
- for (var i in this.pages) {
- if (this.pages[i]) {
- this.pages[i].setData(data);
- }
- }
- this.draw();
- },
-
-
- setPage: function (pName) {
- // Check for a valid page name
- if (!LWWidget.Game.pageMap().containsKey(pName)) {
- return;
- }
-
- // Check if something was changed
- var _p = this.pages[LWWidget.Game.pageMap().get(pName)];
- if (_p && this.page && _p._cid == this.page._cid || !(_p || this.page)) {
- return;
- }
-
- // Hide current page and show new page
- if (this.page) {
- this.page.hide();
- }
- this.page = _p;
- if (_p) {
- this.page.show();
- }
- this.draw();
- },
-
- draw: function () {
- var _e = document.getElementById(this.pageElement);
- if (_e) {
- if (this.page) {
- this.page.draw(_e);
- } else {
- _e.innerHTML = 'Page not implemented
';
- }
- }
- },
-
- show: function () {
- this.startDataUpdate();
- this.autoUpdate.start();
- if (this.page) {
- this.page.show();
- }
- },
-
- hide: function () {
- this.autoUpdate.stop();
- if (this.page) {
- this.page.hide();
- }
- }
-
-}, {
-
- pageMapInst: null,
-
- versionsInst: null,
-
- pageMap: function () {
- if (!LWWidget.Game.pageMapInst) {
- var _h = new Base.Util.Hashtable();
- _h.put('player', 0);
- _h.put('planets', 1);
- _h.put('fleets', 2);
- _h.put('budget', 3);
- _h.put('tech', 4);
- _h.put('msg', 5);
- _h.put('forums', 6);
- _h.put('ticks', 7);
- LWWidget.Game.pageMapInst = _h;
- }
- return LWWidget.Game.pageMapInst;
- },
-
- versions: function () {
- if (!LWWidget.Game.versionsInst) {
- LWWidget.Game.versionsInst = new Base.Util.Hashtable();
- }
- return LWWidget.Game.versionsInst;
- },
-
- formatTime: function (ts) {
- var d = new Date(ts * 1000);
- var str, s2;
-
- s2 = d.getUTCHours().toString();
- if (s2.length == 1) {
- s2 = "0" + s2;
- }
- str = s2 + ':';
-
- s2 = d.getUTCMinutes().toString();
- if (s2.length == 1) {
- s2 = "0" + s2;
- }
- str += s2 + ':';
-
- s2 = d.getUTCSeconds().toString();
- if (s2.length == 1) {
- s2 = "0" + s2;
- }
- str += s2 + ' on ';
-
- s2 = d.getUTCDate().toString();
- if (s2.length == 1) {
- s2 = "0" + s2;
- }
- str += s2 + '/';
-
- s2 = (d.getUTCMonth() + 1).toString();
- if (s2.length == 1) {
- s2 = "0" + s2;
- }
- str += s2 + '/' + d.getUTCFullYear();
-
- return str;
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Game/Page.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Game/Page.js
deleted file mode 100644
index 18c1a0d..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Game/Page.js
+++ /dev/null
@@ -1,34 +0,0 @@
-LWWidget.Game.Page = Base.Comp.inherits({
-
- constructor: function (game) {
- this.base();
-
- this.addSlot('gameDestroyed');
- this.game = game;
- this.game.bindEvent('Destroy', 'gameDestroyed', this);
- },
-
- writeContents: function (contents) {
- var e = document.getElementById('gDisplay');
- if (e) {
- e.innerHTML = contents;
- }
- },
-
- gameDestroyed: function () {
- this.game = null;
- },
-
- setData: function (data) {
- },
-
- draw: function (_e) {
- },
-
- show: function () {
- },
-
- hide: function () {
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/GameDisplay.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/GameDisplay.js
deleted file mode 100644
index 10fe24e..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/GameDisplay.js
+++ /dev/null
@@ -1,73 +0,0 @@
-LWWidget.GameDisplay = LWWidget.Page.inherits({
-
- constructor: function () {
- this.base();
-
- this.addSlot('gameDestroyed');
- this.addEvent('Refresh');
-
- this.gPath = '';
- this.game = null;
- },
-
- destroy: function () {
- if (this.game) {
- this.game.destroy();
- }
- this.base();
- },
-
-
- setGame: function (gClass, gPath) {
- if (this.game) {
- this.game.destroy();
- }
- this.game = new gClass(gPath);
- this.game.bindEvent('Destroy', 'gameDestroyed', this);
- this.game.bindEvent('RequestUpdate', 'onRefresh', this);
- },
-
- gameDestroyed: function () {
- this.game = null;
- },
-
-
- handleData: function (data) {
- if (this.game) {
- this.game.setData(data);
- }
- },
-
-
- hide: function () {
- if (this.game) {
- this.game.hide();
- }
- },
-
-
- show: function () {
- if (this.game) {
- this.game.show();
- }
- this.draw();
- },
-
-
- setPage: function (pName) {
- if (this.game) {
- this.game.setPage(pName);
- }
- },
-
-
- draw: function () {
- if (!document.getElementById('gDisplay')) {
- this.writeContents('
');
- }
- if (this.game) {
- this.game.draw();
- }
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/GameSelector.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/GameSelector.js
deleted file mode 100644
index 8c4ce54..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/GameSelector.js
+++ /dev/null
@@ -1,65 +0,0 @@
-LWWidget.GameSelector = LWWidget.Page.inherits({
-
- constructor: function () {
- this.base();
- this.games = [];
-
- this.addEvent('Select');
- },
-
-
- setGames: function (games) {
- if (games instanceof Array) {
- this.games = games;
- this.draw();
- }
- },
-
-
- draw: function () {
- var cc = '"return Base.Comp.get(' + this._cid + ').select()"',
- st = ' style="color:white;font-size:13px;background-color:#3f7fff;width:100%" ',
- st2 = ' style="color:white;font-size:13px;background-color:#3f7fff" ',
- str = '';
- this.writeContents(str);
-
- var _cb = document.getElementById('grem');
- if (_cb) {
- _cb.checked = (LWWidget.main.getPreference('lwRemGame') == '1');
- }
- },
-
- select: function () {
- var _s = document.getElementById('gsel');
- if (!_s) {
- return false;
- }
-
- var sv = parseInt(_s.options[_s.selectedIndex].value, 10), rem = document.getElementById('grem').checked;
- LWWidget.main.setPreference('lwRemGame', rem ? '1' : '0');
- if (rem) {
- LWWidget.main.setPreference('lwGame', this.games[sv].path);
- }
-
- this.onSelect(this.games[sv]);
-
- return false;
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Login.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Login.js
deleted file mode 100644
index 5355abb..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Login.js
+++ /dev/null
@@ -1,77 +0,0 @@
-LWWidget.Login = LWWidget.Page.inherits({
-
- constructor: function () {
- this.base();
- this.addEvent('Login');
- this.error = "";
- },
-
- draw: function () {
- var cc = '"return Base.Comp.get(' + this._cid + ').login()"',
- st = ' style="color:white;font-size:13px;background-color:#3f7fff;width:100%" ',
- st2 = ' style="color:white;font-size:13px;background-color:#3f7fff" ',
- str = '';
- this.writeContents(str);
- this.fillForm();
- },
-
- fillForm: function () {
- var l = LWWidget.main.getPreference('lwLogin'), p = LWWidget.main.getPreference('lwPassword'), r = LWWidget.main.getPreference('lwRemAuth');
- if (!document.getElementById('lname')) {
- return;
- }
- document.getElementById('lname').value = l;
- document.getElementById('lpass').value = p;
- document.getElementById('lrem').checked = (r == '1');
- document.getElementById("lerror").innerHTML = (this.error == "") ? ' ' : this.error;
- },
-
-
- setError: function (error) {
- this.error = error;
- var e = document.getElementById("lerror");
- if (e) {
- e.innerHTML = (error == "") ? ' ' : error;
- }
- },
-
-
- login: function () {
- if (!document.getElementById('lname')) {
- return false;
- }
-
- var l = document.getElementById('lname').value, p = document.getElementById('lpass').value,
- r = document.getElementById('lrem').checked ? '1' : '0';
-
- if (l == '') {
- this.setError("Please type in your username");
- } else if (p == '') {
- this.setError("Please type in your password");
- } else {
- // Save the login as a preference and store the rest until we're sure
- LWWidget.main.setPreference('lwLogin', l);
- LWWidget.main.setPreference('lwRemAuth', r);
- LWWidget.main.password = p;
-
- this.onLogin();
- }
-
- return false;
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Main.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Main.js
deleted file mode 100644
index c7eda09..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Main.js
+++ /dev/null
@@ -1,392 +0,0 @@
-LWWidget.Main = Base.Comp.inherits({
-
- constructor: function () {
- this.base();
-
- this.addEvent('Show');
- this.addEvent('Hide');
- this.addSlot('draw');
- this.bindEvent('Show', 'draw');
-
- // Game-related slots
- this.addSlot('login');
- this.addSlot('loadGame');
- this.addSlot('loadData');
-
- // Version management slots
- this.addSlot('versionError');
- this.addSlot('versionNewAvailable');
- this.addSlot('versionNewRequired');
- this.addSlot('versionOk');
-
- // Generate the menu
- this.makeMenu();
-
- // Version checker
- this.versionCheck = new LWWidget.VersionCheck();
- this.versionPage = new LWWidget.NewVersion();
- this.versionCheck.bindEvent('CommError', 'versionError', this);
- this.versionCheck.bindEvent('NewVersion', 'versionNewAvailable', this);
- this.versionCheck.bindEvent('RequiredVersion', 'versionNewRequired', this);
- this.versionCheck.bindEvent('VersionOk', 'versionOk', this);
- this.versionChecked = false;
-
- // Login page
- this.loginPage = new LWWidget.Login();
- this.loginPage.bindEvent('Login', 'login', this);
-
- // Game selection page
- this.gameSelector = new LWWidget.GameSelector();
- this.gameSelector.bindEvent('Select', 'loadGame', this);
-
- // Game display
- this.gameDisplay = new LWWidget.GameDisplay(this);
- this.gameDisplay.bindEvent('Refresh', 'loadData', this);
-
- // Generic text display
- this.textPage = new LWWidget.TextPage();
-
- // FIXME: Set Dashboard-specific event handlers
- // this.initDashboard();
-
- // FIXME: should use saved password if possible
- this.page = this.loginPage;
- this.menu.setMode('out');
- this.state = 0;
-
- this.onShow(); // FIXME: use Dashboard events if possible
- },
-
-
- initDashboard: function () {
- if (window.widget) {
- var _cid = this._cid;
- widget.onshow = function () {
- if (Base) {
- Base.Comp.get(_cid).onShow();
- }
- };
- widget.onhide = function () {
- if (Base) {
- Base.Comp.get(_cid).onHide();
- }
- };
- }
- },
-
-
- makeMenu: function () {
- var _m;
- this.menu = new LWWidget.Menu();
- this.addSlot('menuCommand');
- this.menu.bindEvent('Click', 'menuCommand', this);
-
- // Waiting
- _m = this.menu.newMode('wait');
- _m.addItem(new LWWidget.Menu.Text('Loading ... Please wait ...'));
-
- // New version available
- _m = this.menu.newMode('nvAvail');
- _m.addItem(new LWWidget.Menu.Text('New version! '));
- _m.addItem(new LWWidget.Menu.Command('continue', 'Continue'));
- _m.addItem(new LWWidget.Menu.Command('logout', 'Log out'));
-
- // New version required
- _m = this.menu.newMode('nvReq');
- _m.addItem(new LWWidget.Menu.Text('Update required '));
- _m.addItem(new LWWidget.Menu.Command('logout', 'Log out'));
-
- // Logged out user
- _m = this.menu.newMode('out');
- _m.addItem(new LWWidget.Menu.Text('Please log in'));
-
- // Game selection
- _m = this.menu.newMode('game');
- _m.addItem(new LWWidget.Menu.Entry('gamesel', 'Game selection'));
- _m.addItem(new LWWidget.Menu.Command('logout', 'Log out'));
-
- // Error
- _m = this.menu.newMode('error');
- _m.addItem(new LWWidget.Menu.Text('Error! - '));
- _m.addItem(new LWWidget.Menu.Command('logout', 'Log out'));
-
- // Standard
- _m = this.menu.newMode('std');
- _m.addItem(new LWWidget.Menu.Command('gamesel', 'Game selection'));
- _m.addItem(new LWWidget.Menu.Entry('player', 'Player'));
- _m.addItem(new LWWidget.Menu.Entry('planets', 'Planets'));
- _m.addItem(new LWWidget.Menu.Entry('fleets', 'Fleets'));
- _m.addItem(new LWWidget.Menu.Entry('budget', 'Budget'));
- _m.addItem(new LWWidget.Menu.Entry('tech', 'Research'));
- _m.addItem(new LWWidget.Menu.Entry('msg', 'Messages'));
- _m.addItem(new LWWidget.Menu.Entry('forums', 'Forums'));
- _m.addItem(new LWWidget.Menu.Entry('ticks', 'Ticks'));
- _m.addItem(new LWWidget.Menu.Command('logout', 'Log out'));
- },
-
-
- initLoader: function (login, password) {
- this.loader = new LWWidget.Data.Loader(LWWidget.main.getPreference('lwLogin'), LWWidget.main.password);
-
- var events = ['CommError', 'FatalError', 'Kick', 'Load', 'LoginFailure', 'Maintenance', 'Destroy'];
- var slots = ['commError', 'serverError', 'playerKicked', 'dataLoaded', 'loginFailed', 'serverMaintenance', 'loaderDestroyed'];
- for (var i=0;i'
- + ''
- + 'Legacy Worlds |
'
- + '
'
- + ' |
'
- + '
';
- if (LWWidget.debug) {
- str += '
';
- }
- Base.Browser.get().docBody.innerHTML = str;
-
- this.menu.draw();
- this.page.draw();
- },
-
-
- setTextPage: function (mMode, text) {
- this.menu.setMode(mMode);
- this.page = this.textPage;
- this.page.setText(text);
- },
-
- menuCommand: function (command) {
- if (command == 'logout') {
- if (this.loader) {
- this.loader.destroy();
- }
- if (this.versionCheck) {
- this.versionCheck.stop();
- }
- if (this.state == 3) {
- this.gameDisplay.hide();
- }
- this.state = 0;
- this.versionChecked = false;
- this.loginPage.setError('');
- this.page = this.loginPage;
- this.menu.setMode('out');
- this.page.draw();
- } else if (command == 'continue') {
- this.login();
- } else if (command == 'gamesel') {
- if (this.state == 3) {
- this.page.hide();
- }
- this.state = 1;
- this.setTextPage('wait', 'Connecting to the Legacy Worlds server
Please wait');
- this.loader.load('main/index');
- } else if (this.state == 3) {
- this.gameDisplay.setPage(command);
- }
- },
-
-
- versionError: function () {
- // Ignore the error if the version has already been checked
- if (!this.versionChecked) {
- this.commError();
- }
- },
-
- versionNewAvailable: function (url) {
- // Ignore the new version unless it is the first time we check
- if (this.versionChecked) {
- return;
- }
- this.versionChecked = true;
-
- this.versionPage.setData(url, false);
- this.page = this.versionPage;
- this.menu.setMode('nvAvail');
- this.page.draw();
- },
-
- versionNewRequired: function (url) {
- if (this.state == 3) {
- this.gameDisplay.hide();
- }
- this.versionCheck.stop();
- this.versionPage.setData(url, true);
- this.page = this.versionPage;
- this.menu.setMode('nvReq');
- this.page.draw();
- },
-
- versionOk: function () {
- if (!this.versionChecked) {
- // Continue login
- this.versionChecked = true;
- this.login();
- }
- },
-
-
- login: function () {
- this.setTextPage('wait', 'Connecting to the Legacy Worlds server
Please wait');
-
- // If the version hasn't been checked, well, check it
- if (!this.versionChecked) {
- this.versionCheck.start();
- return;
- }
-
- // Initialise the loader and get the game list
- this.initLoader();
- this.loader.load('main/index');
- },
-
-
- handleGameList: function (data, force) {
- this.state = 1;
-
- var games = new Array(), auto = null;
-
- if (!force && LWWidget.main.getPreference('lwRemGame') == '1') {
- auto = LWWidget.main.getPreference('lwGame');
- }
-
- for (var i in data.contents) {
- // Check if version is supported
- var _v = data.contents[i].getAttribute('version');
- if (!LWWidget.Game.versions().containsKey(_v)) {
- continue;
- }
-
- var _g = {
- name: data.contents[i].getText(),
- path: data.contents[i].getAttribute('path'),
- version: LWWidget.Game.versions().get(_v)
- };
- if (auto && auto == _g.path) {
- this.loadGame(_g);
- return;
- }
- games.push(_g);
- }
-
- if (games.length == 0) {
- this.setTextPage('error', 'It appears that you are not registered to any Legacy Worlds game.');
- } else if (!force && games.length == 1) {
- this.loadGame(games[0]);
- } else {
- this.page = this.gameSelector;
- this.menu.setMode('game');
- this.gameSelector.setGames(games);
- }
- },
-
-
- loadGame: function (game) {
- this.state = 2;
- this.currentGame = game;
- this.loader.load(game.path + '/play');
- },
-
- loadData: function (path) {
- if (this.state == 3 && this.loader) {
- this.loader.load(path + '/play');
- }
- },
-
-
-
- commError: function () {
- this.setTextPage('error', 'Communications error
The server could not be reached or it sent an invalid reply.');
- },
-
- serverError: function (code, text) {
- var str = 'Server error
The server encountered an internal error:
'
- + text + '
(code: ' + code + ')';
- this.setTextPage('error', str);
- },
-
- playerKicked: function (reason) {
- var str = (reason == '' ? 'No reason was specified' : ('Reason: ' + reason));
- if (this.state == 3) {
- this.gameDisplay.hide();
- }
- this.setTextPage('error', 'You have been kicked from the game!
' + str);
- },
-
- loginFailed: function (code) {
- switch (code) {
- case '0':
- if (this.state == 0) {
- this.loader.destroy();
- LWWidget.main.password = '';
- this.loginPage.setError('Invalid username or password');
- this.page = this.loginPage;
- this.page.draw();
- } else {
- this.setTextPage('error', 'Your password has been changed.');
- }
- break;
- case '1':
- this.setTextPage('error', 'The server encountered an internal error while authenticating your account.');
- break;
- case '2':
- this.setTextPage('error', 'Your account has been closed!');
- break;
- case '3':
- this.setTextPage('error', 'Your account has not been validated yet, please check your e-mail.');
- break;
- case '4':
- if (this.state < 2) {
- this.setTextPage('error', 'The server just did something it\'s not supposed to do. Ever.');
- } else {
- this.gameDisplay.hide();
- this.setTextPage('errsel', 'You are no longer registered to this game!');
- }
- break;
- }
- },
-
- serverMaintenance: function (reason, until, now) {
- var str = 'The server is undergoing maintenance.
Reason: ' + reason
- + '
It will be down until ' + until + '.
Current server time: ' + now;
- this.setTextPage('error', str);
- },
-
- loaderDestroyed: function () {
- this.loader = null;
- },
-
- dataLoaded: function (data) {
- if (this.state == 0) {
- // We were not loging in, save password if needed
- if (LWWidget.main.getPreference('lwRemAuth') == '1') {
- LWWidget.main.setPreference('lwPassword', LWWidget.main.password);
- }
-
- this.handleGameList(data);
- } else if (this.state == 1) {
- // We were logged in but asked to select a game
- this.handleGameList(data, true);
- } else if (this.state == 2) {
- // We just received game data for the first time
- this.gameDisplay.setGame(this.currentGame.version, this.currentGame.path);
- this.gameDisplay.handleData(data);
- this.page = this.gameDisplay;
- this.menu.setMode('std');
- this.menu.setSelected('player');
- this.page.draw();
- this.state = 3;
- } else {
- // Update game contents
- this.gameDisplay.handleData(data);
- }
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu.js
deleted file mode 100644
index 23abe8c..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu.js
+++ /dev/null
@@ -1,81 +0,0 @@
-LWWidget.Menu = Base.Comp.inherits({
-
- constructor: function () {
- this.base();
-
- this.currentMode = null;
- this.modes = new Base.Util.Hashtable();
-
- this.addSlot('modeDestroyed');
- this.addSlot('draw');
- this.addEvent('Click');
- this.bindEvent('Click', 'draw');
- },
-
- destroy: function () {
- var modes = this.modes.values();
- for (var i in modes) {
- modes[i].destroy();
- }
- this.base();
- },
-
-
- newMode: function (name) {
- if (this.modes.containsKey(name)) {
- return null;
- }
-
- var mode = new LWWidget.Menu.Mode(name);
- this.modes.put(name, mode);
- if (!this.currentMode) {
- this.currentMode = mode;
- }
-
- mode.bindEvent('Destroy', 'modeDestroyed', this);
- mode.bindEvent('Click', 'onClick', this);
-
- return mode;
- },
-
- setMode: function (name) {
- if (!this.modes.containsKey(name) || this.currentMode && this.currentMode.name == name) {
- return;
- }
- this.currentMode = this.modes.get(name);
- this.draw();
- },
-
- setSelected: function (name) {
- if (this.currentMode) {
- this.currentMode.setSelected(name);
- this.draw();
- }
- },
-
- modeDestroyed: function (mode) {
- if (!(mode && mode._cid && mode.name && this.modes.containsKey(mode.name))) {
- return;
- }
-
- this.modes.remove(mode.name);
- if (this.currentMode && this.currentMode._cid == mode._cid) {
- var _v = this.modes.values();
- if (_v.length) {
- this.currentMode = _v[0];
- } else {
- this.currentMode = null;
- }
- }
- },
-
-
- draw: function () {
- var e = document.getElementById('mtMenu');
- if (!(e && this.currentMode)) {
- return;
- }
- e.innerHTML = this.currentMode.draw();
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Command.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Command.js
deleted file mode 100644
index d4af539..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Command.js
+++ /dev/null
@@ -1,7 +0,0 @@
-LWWidget.Menu.Command = LWWidget.Menu.Item.inherits({
-
- constructor: function (name, text) {
- this.base(name, text, true, false, ' - ');
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Entry.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Entry.js
deleted file mode 100644
index aad8595..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Entry.js
+++ /dev/null
@@ -1,7 +0,0 @@
-LWWidget.Menu.Entry = LWWidget.Menu.Item.inherits({
-
- constructor: function (name, text) {
- this.base(name, text, true, true, ' - ');
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Item.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Item.js
deleted file mode 100644
index 03e3526..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Item.js
+++ /dev/null
@@ -1,38 +0,0 @@
-LWWidget.Menu.Item = Base.Comp.inherits({
-
- constructor: function (name, text, clickable, selectable, separator) {
- this.base();
-
- this.name = name;
- this.text = text;
- this.clickable = !!clickable;
- this.selectable = this.clickable && !!selectable;
- this.separator = (typeof separator == 'string') ? separator : '';
- this.selected = false;
-
- this.addEvent('Click');
- },
-
- draw: function () {
- var pfx, sfx;
- if (this.clickable && !this.selected) {
- pfx = '';
- sfx = '';
- } else if (this.selectable && this.selected) {
- pfx = '';
- sfx = '';
- } else {
- pfx = sfx = '';
- }
-
- return pfx + this.text + sfx;
- },
-
- click: function () {
- if (this.selectable) {
- this.selected = true;
- }
- this.onClick(this);
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Mode.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Mode.js
deleted file mode 100644
index 8d92b0a..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Menu/Mode.js
+++ /dev/null
@@ -1,109 +0,0 @@
-LWWidget.Menu.Mode = Base.Comp.inherits({
-
- constructor: function (name) {
- this.base();
-
- this.name = name;
- this.items = new Base.Util.Hashtable();
- this.selected = null;
-
- this.addSlot('itemDestroyed');
- this.addSlot('itemClicked');
- this.addEvent('Click');
- },
-
- destroy: function () {
- var items = this.items.values();
- for (var i in items) {
- var _i = items[i];
- this.items.remove(items[i]._cid);
- items[i].destroy();
- }
-
- this.base();
- },
-
- draw: function () {
- var str = '', items = this.items.values();
-
- for (var i=0;i
Download the new version';
-
- this.writeContents(_s);
- },
-
-
- startDownload: function () {
- if (window.widget) {
- widget.openURL(this.url);
- } else {
- window.open(this.url);
- }
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Page.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Page.js
deleted file mode 100644
index 9f993a8..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Page.js
+++ /dev/null
@@ -1,17 +0,0 @@
-LWWidget.Page = Base.Comp.inherits({
-
- constructor: function () {
- this.base();
-
- this.addEvent('Show');
- this.addEvent('Hide');
- },
-
- writeContents: function (contents) {
- var e = document.getElementById('mtContents');
- if (e) {
- e.innerHTML = contents;
- }
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/TextPage.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/TextPage.js
deleted file mode 100644
index 152482b..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/TextPage.js
+++ /dev/null
@@ -1,18 +0,0 @@
-LWWidget.TextPage = LWWidget.Page.inherits({
-
- constructor: function () {
- this.text = "";
- },
-
- setText: function (text) {
- if (this.text != text) {
- this.text = text;
- }
- this.draw();
- },
-
- draw: function () {
- this.writeContents(this.text == "" ? ' ' : this.text);
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/VersionCheck.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/VersionCheck.js
deleted file mode 100644
index 7918974..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/VersionCheck.js
+++ /dev/null
@@ -1,101 +0,0 @@
-LWWidget.VersionCheck = Base.Comp.inherits({
-
- constructor: function () {
- this.base();
-
- this.addEvent('CommError');
- this.addEvent('NewVersion');
- this.addEvent('RequiredVersion');
- this.addEvent('VersionOk');
-
- this.addSlot('dataReceived');
- this.addSlot('loaderDestroyed');
- this.addSlot('timerDestroyed');
-
- this.loader = new Base.XMLLoader(LWWidget.base + '/index.php/main/macwidget.xml', false);
- this.loader.bindEvent('Destroy', 'loaderDestroyed', this);
- this.loader.bindEvent('NetworkError', 'onCommError', this);
- this.loader.bindEvent('ServerError', 'onCommError', this);
- this.loader.bindEvent('Timeout', 'onCommError', this);
- this.loader.bindEvent('Unsupported', 'onCommError', this);
- this.loader.bindEvent('Aborted', 'onCommError', this);
- this.loader.bindEvent('Loaded', 'dataReceived', this);
-
- this.timer = new Base.Timer(300000, true);
- this.timer.bindEvent('Tick', 'load', this.loader);
- this.timer.bindEvent('Destroy', 'timerDestroyed', this);
-
- this.knownVersion = LWWidget.version;
- },
-
-
- destroy: function () {
- if (this.loader) {
- this.loader.destroy();
- }
- if (this.timer) {
- this.timer.destroy();
- }
- this.base();
- },
-
-
- timerDestroyed: function () {
- this.timer = null;
- },
-
- loaderDestroyed: function () {
- this.loader = null;
- },
-
-
- start: function () {
- if (typeof this.requiredVersion != 'undefined' && LWWidget.version < this.requiredVersion) {
- return;
- }
- this.timer.start();
- this.loader.load();
- },
-
- stop: function () {
- this.timer.stop();
- this.knownVersion = LWWidget.version;
- delete this.latestVersion;
- delete this.requiredVersion;
- },
-
-
- dataReceived: function (data) {
- var _xml = Base.Util.parseXML(data);
- if (!_xml) {
- this.onCommError();
- return;
- }
-
- var _doc = _xml.documentElement;
- this.latestVersion = parseInt(_doc.getAttribute('latest'), 10);
- this.requiredVersion = parseInt(_doc.getAttribute('oldestOk'), 10);
- this.url = _doc.childNodes[0].nodeValue;
-
- if (this.knownVersion == this.latestVersion && this.requiredVersion <= LWWidget.version) {
- this.onVersionOk();
- return;
- }
-
- Base.Log.write('Version check: current version = ' + LWWidget.version);
- Base.Log.write('Version check: latest received version = ' + this.knownVersion);
- Base.Log.write('Version check: latest version = ' + this.latestVersion);
- Base.Log.write('Version check: oldest accepted version = ' + this.requiredVersion);
-
- this.knownVersion = this.latestVersion;
- if (LWWidget.version < this.requiredVersion) {
- this.onRequiredVersion(this.url);
- this.timer.stop();
- } else if (LWWidget.version < this.latestVersion) {
- this.onNewVersion(this.url);
- } else {
- this.onVersionOk();
- }
- }
-
-});
diff --git a/misc/Legacy Worlds.wdgt/lib/LWWidget/Versions.js b/misc/Legacy Worlds.wdgt/lib/LWWidget/Versions.js
deleted file mode 100644
index ae403de..0000000
--- a/misc/Legacy Worlds.wdgt/lib/LWWidget/Versions.js
+++ /dev/null
@@ -1,2 +0,0 @@
-LWWidget.Versions = new Base.Util.Hashtable();
-LWWidget.Versions.put('beta5', LWWidget.Beta5);
diff --git a/scripts/config.inc b/scripts/config.inc
index ae11713..8ab50cb 100644
--- a/scripts/config.inc
+++ b/scripts/config.inc
@@ -4,18 +4,12 @@
// engine instance
$config = array(
- // Database connection parameters
- "dbhost" => "localhost",
- "dbuser" => "legacy",
- "dbpass" => "",
- "dbname" => "legacy",
-
// Path and URL to static contents
- "staticdir" => dirname(__FILE__) . "/../site/static",
- "staticurl" => "http://www.legacyworlds.com/static",
+ "staticdir" => __DIR__ . "/../site/static",
+ "staticurl" => "http://localhost/static",
// Path to game scripts
- "scriptdir" => dirname(__FILE__),
+ "scriptdir" => __DIR__,
// Path to the cache
"cachedir" => "/tmp/lwcache",
@@ -33,11 +27,6 @@ $config = array(
),
*/
- // Mac widget version numbers and location
- "latestWidget" => 1,
- "oldestWidget" => 1,
- "widgetURL" => "http://www.legacyworlds.com/downloads/LegacyWorlds-Dashboard-latest.zip",
-
// Version numbers to make us feel good
"v_engine" => "0.85a",
"v_game" => "Beta 5",
diff --git a/scripts/game/main/ticks/deathofrats/library.inc b/scripts/game/main/ticks/deathofrats/library.inc
index a7f2d37..6172c51 100644
--- a/scripts/game/main/ticks/deathofrats/library.inc
+++ b/scripts/game/main/ticks/deathofrats/library.inc
@@ -150,14 +150,6 @@ class main_ticks_deathofrats_library {
l::debug("Analysing " . count($this->connections) . " new record(s)");
$this->makePerAccountRecords();
- // Start with open proxies
- l::debug("Checking for open proxies ...");
- $this->checkOpenProxies();
- if ($this->proxiedAccounts) {
- l::info("Logging " . count($this->proxiedAccounts) . " account(s) using open proxies");
- $this->db->safeTransaction(array($this, 'logOpenProxies'));
- }
-
// Now examine per-account entries to find different types of rats
l::debug("Checking single player badness");
foreach ($this->perAccount as $records) {
@@ -660,111 +652,6 @@ class main_ticks_deathofrats_library {
}
- /***********************************************************************
- * OPEN PROXIES *
- ***********************************************************************/
-
- /** This method checks for open proxies in the latest log entries.
- */
- private function checkOpenProxies() {
- $IPs = array();
-
- // Make lists of accounts for each IP
- foreach ($this->connections as $record) {
- if ($record['ip_addr'] == 'AUTO' || $record['action'] == 'OUT') {
- continue;
- }
- $ip = $record['ip_addr'];
- $account = $record['account'];
- if (!is_array($IPs[$ip])) {
- $IPs[$ip] = array($account);
- } elseif (!in_array($account, $IPs[$ip])) {
- array_push($IPs[$ip], $account);
- }
- }
-
- // Check for proxies on the IPs
- $requests = array();
- $proxies = array();
- foreach (array_keys($IPs) as $ip) {
- if (count($requests) < 20) {
- array_push($requests, $ip);
- continue;
- }
-
- try {
- $results = pcheck::check($requests);
- } catch (Exception $e) {
- l::error("Failed to check some addresses for open proxies");
- l::info($e->getMessage());
- return;
- }
-
- foreach ($results as $host => $status) {
- if ($status == 1) {
- array_push($proxies, $host);
- }
- }
-
- $requests = array();
- }
-
- // If there are some requests we didn't execute, do it
- if (count($requests)) {
- try {
- $results = pcheck::check($requests);
- } catch (Exception $e) {
- l::error("Failed to check some addresses for open proxies");
- l::info($e->getMessage());
- return;
- }
-
- foreach ($results as $host => $status) {
- if ($status == 1) {
- array_push($proxies, $host);
- }
- }
- }
-
- // Check for proxied accounts
- $proxyAccounts = array();
- foreach ($proxies as $ip) {
- foreach ($IPs[$ip] as $account) {
- if (in_array($account, $proxyAccounts)) {
- continue;
- }
- array_push($proxyAccounts, $account);
- }
- }
-
- $this->proxiedAccounts = $proxyAccounts;
- }
-
-
- /** This method logs access to accounts using open proxies. A log
- * entry is only added every 24h.
- */
- public function logOpenProxies() {
- // Get all recent open proxy logs
- $this->db->query(
- "SELECT account FROM dor_single "
- . "WHERE message = 'PROXY' AND {$this->now} - ts < 86400"
- );
- $recent = array();
- while ($r = dbFetchArray($q)) {
- $recent[] = $r[0];
- }
-
- // Insert proxy logs
- foreach ($this->proxiedAccounts as $account) {
- if (in_array($account, $recent)) {
- continue;
- }
- $this->singlePlayerLog("PROXY", $account);
- }
- }
-
-
/***********************************************************************
* SINGLE PLAYER SUSPICIOUS BEHAVIOUR *
***********************************************************************/
diff --git a/scripts/legacyworlds.xml b/scripts/legacyworlds.xml
index bc03fdb..4718129 100644
--- a/scripts/legacyworlds.xml
+++ b/scripts/legacyworlds.xml
@@ -15,17 +15,6 @@
-
-
-
-
-
-
-
-
-
-
-