Added full source code

This commit is contained in:
Emmanuel BENOîT 2016-01-10 11:01:49 +01:00
commit 33f8586698
1377 changed files with 123808 additions and 0 deletions

View file

@ -0,0 +1,37 @@
function formatDate(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;
}
Component.Listing.notFoundText = 'No elements found';
Component.Listing.loadingText = 'Loading ...';
Component.Listing.errorText = 'Error: the list couldn\'t be loaded';

1399
site/static/beta5/js/main.js Normal file

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,129 @@
var listTitle = 'Allies List';
var emptyList = 'You are not a trusting person, it would seem.';
var notTrusted = 'Apparently, no one trusts you.';
var addBanText = 'Blacklist a player';
var addBanLabel = 'Name of the player to ban:';
var addBanButton = 'Ban player';
var blackListTitle = 'Blacklist contents';
var emptyBlackList = 'Everyone can add you to their Trusted Allies lists.';
var raHeaders = ['Player', 'Trust Level'];
function makeAlliesTooltips()
{
tratt = new Array();
if (ttDelay == 0)
{
var i;
for (i=0;i<30;i++)
tratt[i] = "";
return;
}
tratt[0] = tt_Dynamic("Use this text field to type in the name of the new allie to add to your trusted allies list");
tratt[1] = tt_Dynamic("Click here to add this player to your trusted allies list");
tratt[10] = tt_Dynamic("Click here to remove the selected player(s) from your trusted allies list");
tratt[11] = tt_Dynamic("Click here to move the selected player up in the list");
tratt[12] = tt_Dynamic("Click here to move the selected player down in the list");
tratt[15] = tt_Dynamic("Click here to remove yourself to this player's trusted allies list");
tratt[16] = tt_Dynamic("Click here to remove yourself to this player's trusted allies list and prevent him from adding you again");
tratt[20] = tt_Dynamic("Use this checkbox to select the corresponding trusted ally");
tratt[21] = tt_Dynamic("Use this checkbox to select this player");
}
function drawAddAlly(value)
{
var str = '<h1>Add Ally</h1>';
str += '<p>Name of the new ally: <input type="text" ' + tratt[0] + 'name="newally" id="newally" value="';
str += value.replace(/"/g, '&quot;') + '" maxlength="15" size="16" /> <input type="button" ';
str += 'name="add" ' + tratt[1] + ' value="Add" onClick="addAlly();return false" /></p>';
return str;
}
function drawButtons(cr,cmu,cmd)
{
var str = '';
if (cr)
str += '<input type="button" ' + tratt[10] + ' name="del" value="Remove" onClick="removeAllies();return false" />';
if (cmu)
str += '<input type="button" ' + tratt[11] + ' name="mup" value="Up" onClick="moveUp();return false" />';
if (cmd)
str += '<input type="button" ' + tratt[12] + ' name="mdown" value="Down" onClick="moveDown();return false" />';
if (str == "")
str = "&nbsp;";
return str;
}
function drawRButtons()
{
var str;
str = '<input type="button" ' + tratt[15] + ' name="rdel" value="Remove" onClick="removeRAllies();return false" />'
+ '<input type="button" ' + tratt[16] + ' name="rban" value="Remove and Ban" onClick="removeBanRAllies();return false" />';
return str;
}
function drawBLButtons()
{
var str;
str = '<input type="button" ' + tratt[31] + ' name="bldel" value="Remove" onClick="removeBans();return false" />';
return str;
}
function addAllyConfirm(name)
{
var str = 'You are about to add the player named ' + name + ' to your trusted allies list.\n';
str += 'It will give this player partial control over your fleets when you are not online.\n';
str += 'Please confirm.';
return confirm(str);
}
function confirmRemoveRAllies(ids)
{
var i, n = new Array();
var str = 'You are about to remove yourself from the folowing player' + (ids.length > 1 ? "s' " : "'s")
+ " Trusted Allies list" + (ids.length > 1 ? "s" : "") + ':\n';
for (i=0;i<ids.length;i++)
n.push(idRAllies[ids[i]].name);
str += n.join(', ') + '\n You will no longer be able to handle ' + (ids.length > 1 ? "these players'" : "this player's")
+ ' fleets.\nPlease confirm.';
return confirm(str);
}
function confirmBanRAllies(ids)
{
var i, n = new Array();
var str = 'You are about to remove yourself from the folowing player' + (ids.length > 1 ? "s' " : "'s")
+ " Trusted Allies list" + (ids.length > 1 ? "s" : "") + ' and add ' + (ids.length > 1 ? 'them' : 'him')
+ ' to your T.A. blacklist:\n';
for (i=0;i<ids.length;i++)
n.push(idRAllies[ids[i]].name);
str += n.join(', ') + '\n You will no longer be able to handle ' + (ids.length > 1 ? "these players'" : "this player's")
+ ' fleets and ' + (ids.length > 1 ? 'they' : 'he') + ' won\'t be able to add you to ' + (ids.length > 1 ? 'their' : 'his')
+ ' Trusted Allies list again.\nPlease confirm.';
return confirm(str);
}
function commandAlert(ei)
{
var str = 'Error\n';
switch (ei)
{
case 0: str += 'Player not found.'; break;
case 1: str += 'Please specify the name of the player to add to the list.'; break;
case 2: str += 'Player not found.'; break;
case 3: str += 'You can\'t add yourself to your allies list.'; break;
case 4: str += 'This player is already in your allies list.'; break;
case 5: str += 'This player is already on 5 other players\' allies list.'; break;
case 6: str += 'This player is on your enemy list.'; break;
case 7: str += 'One of the selected players no longer trusts you anyway.'; break;
case 8: str += 'One of the selected players is already in your T.A. blacklist (this is a bug).'; break;
case 9: str += 'This player has blacklisted you and can\'t be set as a trusted ally anymore.'; break;
case 10: str += 'This player has already been removed from the blacklist.'; break;
case 11: str += 'Please type the name of the player to add to the blacklist.'; break;
case 12: str += 'This player is already in your blacklist.'; break;
case 13: str += 'You can\'t add yourself to your blacklist.'; break;
case 14: str += 'You already have 5 trusted allies.'; break;
case 200: str += 'You are not allowed to edit your trusted allies list while in vacation mode.'; break;
default: str += 'An unknown error has occured.'; break;
}
alert(str);
}

View file

@ -0,0 +1,408 @@
var lsAllies = new Array(), idAllies = new Array();
var lsRAllies = new Array(), idRAllies = new Array();
var lsBans = new Array(), idBans = new Array();
var tratt;
function TrustedAlly(id,name)
{
this.id = id;
this.name = name;
this.selected = false;
}
function ReverseAlly(id,level,name)
{
this.id = id;
this.name = name;
this.level = parseInt(level,10);
this.selected = false;
}
function BannedPlayer(id,name)
{
this.id = id;
this.name = name;
this.selected = false;
}
function parseData(data)
{
var list = new Array();
var byId = new Array();
var l = data.split('\n');
var na, nr, nb;
var i, a, t, id;
a = l.shift().split('#');
na = parseInt(a[0], 10);
nr = parseInt(a[1], 10);
nb = parseInt(a[2], 10);
for (i=0;i<na;i++)
{
a = l.shift().split('#');
id = a.shift();
if (idAllies[id])
t = idAllies[id];
else
t = new TrustedAlly(id, a.join('#'));
byId[id] = t;
list.push(t);
}
lsAllies = list; idAllies = byId;
list = new Array(); byId = new Array();
for (i=0;i<nr;i++)
{
a = l.shift().split('#');
id = a.shift();
if (idRAllies[id])
t = idRAllies[id];
else
t = new ReverseAlly(id, a.shift(), a.join('#'));
byId[id] = t;
list.push(t);
}
lsRAllies = list; idRAllies = byId;
list = new Array(); byId = new Array();
for (i=0;i<nb;i++)
{
a = l.shift().split('#');
id = a.shift();
if (idBans[id])
t = idBans[id];
else
t = new BannedPlayer(id, a.join('#'));
byId[id] = t;
list.push(t);
}
lsBans = list; idBans = byId;
}
function initPage()
{
var data = document.getElementById('alinit').innerHTML;
if (data.split('\n').length == 1 && data.split('#').length > 3)
x_getTrusted(listReceived);
else
listReceived(data);
}
function listReceived(data)
{
parseData(data);
displayPage();
update = setTimeout('x_getTrusted(listReceived)', 600000);
}
function displayPage()
{
var str = "";
var e = document.getElementById('newally');
if (lsAllies.length < 5)
str += drawAddAlly(e ? e.value : "");
str += drawAllyList();
document.getElementById('allies').innerHTML = str;
document.getElementById('rallies').innerHTML = drawReverseList();
document.getElementById('bans').innerHTML = drawBlackList();
updateButtons(); updateRButtons(); updateBLButtons();
}
function handleCommand(data) {
if (data.indexOf('ERR#') == 0) {
var ei = parseInt(data.replace(/ERR#/, ''), 10);
commandAlert(ei);
update = setTimeout('x_getTrusted(listReceived)', 600000);
} else {
var e = document.getElementById('newally');
if (e) {
e.value = '';
}
listReceived(data);
}
}
function drawAllyList()
{
var i, str = '<h1>' + listTitle + '</h1>';
if (lsAllies.length == 0)
return str + '<p>' + emptyList + '</p>';
str += '<table cellspacing="0" cellpadding="0" class="lsallies">';
for (i=0;i<lsAllies.length;i++)
{
str += '<tr>';
if (i==0)
str += '<td class="spacer" rowspan="' + (lsAllies.length+2) + '">&nbsp;</td>';
str += '<td class="al'+i+'"><input type="checkbox" ' + tratt[20] + ' name="ally" id="al'+i+'" value="'+i+'"';
str += ' onClick="lsAllies['+i+'].selected=!lsAllies['+i+'].selected;updateButtons()" ';
if (lsAllies[i].selected)
str += ' checked="checked"';
str += '/> <label for="al'+i+'">' + lsAllies[i].name + '</label></td></tr>';
}
str += '<tr><td>&nbsp;</td></tr><tr><td id="buttons">&nbsp;</td></tr></table>';
return str;
}
function updateButtons()
{
if (!document.getElementById('buttons'))
return;
var i, cr = false, cmu = true, cmd = true;
for (i=0;i<lsAllies.length;i++)
{
cr = cr || lsAllies[i].selected;
cmu = cmu && (!lsAllies[i].selected || i != 0);
cmd = cmd && (!lsAllies[i].selected || i != lsAllies.length - 1);
}
cmu = cmu && cr;
cmd = cmd && cr;
document.getElementById('buttons').innerHTML = drawButtons(cr,cmu,cmd);
}
function moveUp()
{
clearTimeout(update);
var i, sl = new Array();
for (i=0;i<lsAllies.length;i++)
if (lsAllies[i].selected)
sl.push(lsAllies[i].id);
x_moveAllies(sl.join('#'), 1, handleCommand);
}
function moveDown()
{
clearTimeout(update);
var i, sl = new Array();
for (i=0;i<lsAllies.length;i++)
if (lsAllies[i].selected)
sl.push(lsAllies[i].id);
x_moveAllies(sl.join('#'), 0, handleCommand);
}
function removeAllies()
{
clearTimeout(update);
var i, sl = new Array();
for (i=0;i<lsAllies.length;i++)
if (lsAllies[i].selected)
sl.push(lsAllies[i].id);
x_removeAllies(sl.join('#'), handleCommand);
}
function addAlly()
{
var n = document.getElementById('newally').value;
if (!addAllyConfirm(n))
return;
clearTimeout(update);
x_addAlly(n, handleCommand);
}
function drawReverseList()
{
if (lsRAllies.length == 0)
return "<p>" + notTrusted + "</p>";
var str = '<table cellspacing="0" cellpadding="0" class="list" id="ralist"><tr>';
str += '<td class="spacer" rowspan="' + (3+lsRAllies.length) + '">&nbsp;</td><td class="rasel">&nbsp;</td>';
str += '<th class="raname">'+raHeaders[0]+'</th><th class="ralevel">' + raHeaders[1] + '</th></tr>';
var i;
lsRAllies.sort(new Function('a','b','return a.name.toLowerCase()>b.name.toLowerCase()?1:-1'));
for (i=0;i<lsRAllies.length;i++)
{
str += '<tr><td class="rasel"><input type="checkbox" ' + tratt[21] + ' name="ally" id="ral'+i+'" value="'+i+'"'
+ ' onClick="lsRAllies['+i+'].selected=!lsRAllies['+i+'].selected;updateRButtons()" ';
if (lsRAllies[i].selected)
str += ' checked="checked"';
str += '/></td><td class="raname"><a href="message?a=c&ct=0&id=' + lsRAllies[i].id + '">' + lsRAllies[i].name + '</a></td>'
+ '<td class="ralevel">' + (lsRAllies[i].level + 1) + '</td></tr>';
}
str += '<tr><td colspan="3">&nbsp;</td></tr><tr><td colspan="3" id="rbuttons">&nbsp;</td></tr></table>';
return str;
}
function updateRButtons()
{
if (!document.getElementById('rbuttons'))
return;
var i;
for (i=0;i<lsRAllies.length;i++)
if (lsRAllies[i].selected)
break;
document.getElementById('rbuttons').innerHTML = (i==lsRAllies.length) ? "&nbsp;" : drawRButtons();
}
function removeRAllies()
{
clearTimeout(update);
var i, sl = new Array();
for (i=0;i<lsRAllies.length;i++)
if (lsRAllies[i].selected)
sl.push(lsRAllies[i].id);
if (!confirmRemoveRAllies(sl))
{
update = setTimeout('x_getTrusted(listReceived)', 600000);
return;
}
x_removeRAllies(sl.join('#'), handleCommand);
}
function removeBanRAllies()
{
clearTimeout(update);
var i, sl = new Array();
for (i=0;i<lsRAllies.length;i++)
if (lsRAllies[i].selected)
sl.push(lsRAllies[i].id);
if (!confirmBanRAllies(sl))
{
update = setTimeout('x_getTrusted(listReceived)', 600000);
return;
}
x_removeBanRAllies(sl.join('#'), handleCommand);
}
function drawBlackList()
{
var i, str;
str = '<h2>' + addBanText + '</h2><p>' + addBanLabel + ' <input type="text" name="addban" id="addban" value="" '
+ 'size="16" maxlength="15" /> <input type="button" name="baddban" value="' + addBanButton
+ '" onClick="addBan();return false" /></p><h2>' + blackListTitle + '</h2>';
if (lsBans.length == 0)
return str + '<p>' + emptyBlackList + '</p>';
str += '<table cellspacing="0" cellpadding="0" class="lsbans">';
for (i=0;i<lsBans.length;i++)
{
str += '<tr>';
if (i==0)
str += '<td class="spacer" rowspan="' + (lsBans.length+1) + '">&nbsp;</td>';
str += '<td class="rasel"><input type="checkbox" ' + tratt[30] + ' name="banned" id="bl'+i+'" value="'+i+'"'
+ ' onClick="lsBans['+i+'].selected=!lsBans['+i+'].selected;updateBLButtons()" ';
if (lsBans[i].selected)
str += ' checked="checked"';
str += '/></td><td><a href="message?a=c&ct=0&id=' + lsBans[i].id + '">' + lsBans[i].name + '</a></td></tr>';
}
str += '<tr><td>&nbsp;</td></tr><tr><td>&nbsp;</td><td id="blbuttons" colspan="2">&nbsp;</td></tr></table>';
return str;
}
function updateBLButtons()
{
if (!document.getElementById('blbuttons'))
return;
var i;
for (i=0;i<lsBans.length;i++)
if (lsBans[i].selected)
break;
document.getElementById('blbuttons').innerHTML = (i==lsBans.length) ? "&nbsp;" : drawBLButtons();
}
function removeBans()
{
clearTimeout(update);
var i, sl = new Array();
for (i=0;i<lsBans.length;i++)
if (lsBans[i].selected)
sl.push(lsBans[i].id);
x_removeBans(sl.join('#'), handleCommand);
}
function addBan()
{
clearTimeout(update);
var pname = document.getElementById('addban').value;
var i = 0, pws = true;
while (i < pname.length)
{
if (pname.charAt(i) == " ")
{
if (pws)
{
var s1 = (i>0) ? pname.substr(0, i) : "";
var s2 = (i<pname.length-1) ? pname.substr(i+1) : "";
pname = s1 + s2;
}
else
i++;
pws = true;
}
else
{
pws = false;
i++;
}
}
if (pws)
pname = pname.substr(0, pname.length - 1);
if (pname == "")
{
commandAlert(11);
update = setTimeout('x_getTrusted(listReceived)', 600000);
return;
}
var found = null;
for (i=0;i<lsRAllies.length;i++)
{
if (lsRAllies[i].name.toLowerCase() == pname.toLowerCase())
{
found = lsRAllies[i];
break;
}
}
if (found && !confirmBanRAllies([found.id]))
{
update = setTimeout('x_getTrusted(listReceived)', 600000);
return;
}
found = null;
for (i=0;i<lsBans.length;i++)
{
if (lsBans[i].name.toLowerCase() == pname.toLowerCase())
{
found = lsBans[i];
break;
}
}
if (found)
{
commandAlert(12);
update = setTimeout('x_getTrusted(listReceived)', 600000);
return;
}
x_addBan(pname, handleCommand);
}

View file

@ -0,0 +1,40 @@
var noCustomFolders = 'You do not have custom folders.';
var allianceForums = 'Alliance Forums';
function makeCommsTooltips()
{
comtt = new Array();
if (ttDelay == 0)
{
var i;
for (i=0;i<5;i++)
comtt[i] = "";
return;
}
comtt[0] = tt_Dynamic("Click here to go to the page of this custom folder");
comtt[1] = tt_Dynamic("Click here to go to the page of this general forums category");
comtt[2] = tt_Dynamic("Click here to go to the page of this general forum");
comtt[3] = tt_Dynamic("Click here to go to the page of this alliance forum");
}
function makeMessagesText(tot, n)
{
if (tot == 0)
return "no messages";
var str = '<b>' + formatNumber(tot) + '</b> message' + (tot > 1 ? 's' : '');
if (n == 0)
return str;
str += ' (<b>' + formatNumber(n) + '</b> unread message'+(n>1?'s':'')+')';
return str;
}
function makeTopicsText(tot, n)
{
if (tot == 0)
return "empty forum";
var str = '<b>' + formatNumber(tot) + '</b> topic' + (tot > 1 ? 's' : '');
if (n == 0)
return str;
str += ' (<b>' + formatNumber(n) + '</b> unread)';
return str;
}

View file

@ -0,0 +1,144 @@
var dFolders, cFolders;
var genForums, aForums;
var comtt;
function Folder(id, tMsg, nMsg, name)
{
this.id = id;
this.tMsg = tMsg;
this.nMsg = nMsg;
this.name = name;
}
function Category(id, type, name)
{
this.id = id;
this.type = type;
this.name = name;
this.forums = new Array();
}
function Forum(id, nTopics, nUnread, name)
{
this.id = id;
this.nTopics = nTopics;
this.nUnread = nUnread;
this.name = name;
}
function initPage() {
commsDataReceived(document.getElementById('init-data').value);
}
function commsDataReceived(data)
{
var i, l = data.split('\n');
var a = l.shift().split('#');
var nCustom = parseInt(a[0],10), nGenCats = parseInt(a[1],10), nAForums = parseInt(a[2],10);
// Default folders
dFolders = new Array();
for (i=0;i<3;i++)
{
a = l.shift().split('#');
dFolders.push(new Folder('', a[0], a[1], ''));
}
// Custom folders
cFolders = new Array();
for (i=0;i<nCustom;i++)
{
a = l.shift().split('#');
cFolders.push(new Folder(a.shift(), a.shift(), a.shift(), a.join('#')));
}
// General categories & forums
genForums = new Array();
for (i=0;i<nGenCats;i++)
{
a = l.shift().split('#');
var j,c,id,tp,nForums;
id = a.shift(); tp = a.shift();
nForums = parseInt(a.shift(), 10);
c = new Category(id, tp, a.join('#'));
for (j=0;j<nForums;j++)
{
a = l.shift().split('#');
c.forums.push(new Forum(a.shift(),a.shift(),a.shift(),a.join('#')));
}
genForums.push(c);
}
// Alliance forums
aForums = new Array();
for (i=0;i<nAForums;i++)
{
a = l.shift().split('#');
aForums.push(new Forum(a.shift(),a.shift(),a.shift(),a.join('#')));
}
drawCommsPage();
setTimeout('x_getCommsData(commsDataReceived)', 30000);
}
function drawCommsPage()
{
var i, j, a;
// Default folders
for (i=0;i<3;i++)
document.getElementById('msg' + i).innerHTML = makeMessagesText(dFolders[i].tMsg, dFolders[i].nMsg);
// Custom folders
if (cFolders.length == 0)
document.getElementById('cflist').innerHTML = noCustomFolders;
else
{
a = new Array();
for (i=0;i<cFolders.length;i++)
{
var s = '<a href="message?a=f&f=C&cf=' + cFolders[i].id;
s += '" ' + comtt[0] + ' >' + cFolders[i].name + '</a>: ' + makeMessagesText(cFolders[i].tMsg, cFolders[i].nMsg);
a.push(s);
}
document.getElementById('cflist').innerHTML = a.join('<br/>') + '<br/>';
}
// General forums
a = new Array();
for (i=0;i<genForums.length;i++)
{with(genForums[i]){
var s = '<a href="forums?cmd=C%23G%23' + id + '" ' + comtt[1] + ' >' + name + '</a>';
for (j=0;j<forums.length;j++)
{
s += '<br/>&nbsp;&nbsp;-&nbsp;<a href="forums?cmd=F%23' + type + '%23' + forums[j].id + '" ' + comtt[2] + ' >' + forums[j].name + '</a>: ';
s += makeTopicsText(forums[j].nTopics, forums[j].nUnread);
}
a.push(s);
}}
document.getElementById('gforums').innerHTML = a.join('<br/><br/>');
// Alliance forums
if (aForums.length == 0)
document.getElementById('aforums').innerHTML = '&nbsp;';
else
{
a = new Array();
for (j=0;j<aForums.length;j++)
{
s = '&nbsp;&nbsp;-&nbsp;<a href="forums?cmd=F%23A%23' + aForums[j].id + '" ' + comtt[3] + ' >' + aForums[j].name + '</a>: ';
s += makeTopicsText(aForums[j].nTopics, aForums[j].nUnread);
a.push(s);
}
document.getElementById('aforums').innerHTML = '<h2>' + allianceForums + '</h2><p>' + a.join('<br/>') + '</p>';
}
}

View file

@ -0,0 +1,157 @@
function makeDiplomacyTooltips()
{
diptt = new Array();
if (ttDelay == 0)
{
var i;
for (i=0;i<5;i++)
diptt[i] = "";
return;
}
diptt[0] = tt_Dynamic("Click here to go to the alliance page and create or join one");
diptt[1] = tt_Dynamic("Click here to go to the alliance page and manage your joining request");
diptt[2] = tt_Dynamic("Click here to go to alliance page and access your alliance specific information");
diptt[3] = tt_Dynamic("Click here to go to the main page of this specific alliance forum");
diptt[4] = tt_Dynamic("Click here to go to the scientific assistance page and manage scientific diplomatic exchange");
}
function drawNoRelations()
{
document.getElementById('allies').innerHTML = 'You do not have enemies nor allies.';
}
function drawRelations(nenp, nena, nall, nrall)
{
var str = "";
if (nall == 0)
str += "You have no allies.";
else
str += "You have <b>" + nall + "</b> trusted all" + (nall > 1 ? "ies" : "y") + ".";
str += '<br/>';
if (nrall == 0)
str += "Noone trusts you.";
else
str += "<b>" + nrall + "</b> player"+(nrall>1?"s trust":" trusts")+" you.";
str += '<br/>';
if (nenp + nena == 0)
str += "You have no enemies.";
else if (nenp == 0)
str += "Enemies: <b>" + nena + "</b> alliance" + (nena>1?"s":"");
else if (nena == 0)
str += "Enemies: <b>" + nenp + "</b> player" + (nenp>1?"s":"");
else
str += "Enemies: <b>" + nenp + "</b> player" + (nenp>1?"s":"") + " and <b>" + nena + "</b> alliance" + (nena>1?"s":"")
str += "<br/>";
document.getElementById('allies').innerHTML = str;
}
function drawNoAlliance()
{
document.getElementById('alliance').innerHTML = '<p>You are not a member of any alliance.<br/><a href="alliance" ' + diptt[0] + ' >Alliance page</a></p>';
}
function drawPending(npl,ax,ay,rk,pts,tag,name,ln)
{
var str = '<p>You are requesting to join this alliance:<br/>';
str += 'Alliance tag: <b>['+tag+']</b><br/>Alliance name: <b>' + name + '</b><br/>';
str += 'Leader: <b>' + ln + '</b><br/>';
if (npl == 0)
str += 'No controlled planets.';
else if (npl == 1)
str += '<b>1</b> planet at coordinates (<b>'+ax+','+ay+'</b>)';
else
str += '<b>'+npl+'</b> planets at average coordinates (<b>'+ax+','+ay+'</b>)';
str += '<br/>';
if (rk != "")
str += 'The alliance is ranked <b>#'+rk+'</b> with <b>' + formatNumber(pts) + '</b> points.<br/>';
str += '<br/><a href="alliance" ' + diptt[1] + '>Alliance page</a></p>';
document.getElementById('alliance').innerHTML = str;
}
function drawAlliance(npl,ax,ay,rk,pts,il,tag,name,ln,prk,fl)
{
var str = '<h2>Overview</h2>';
str += '<p>Alliance tag: <b>['+tag+']</b><br/>Alliance name: <b>' + name + '</b><br/>';
if (il != 1)
str += 'Leader: <b>' + ln + '</b><br/>';
if (npl == 0)
str += 'No controlled planets.';
else if (npl == 1)
str += '<b>1</b> planet at coordinates (<b>'+ax+','+ay+'</b>)';
else
str += '<b>'+npl+'</b> planets at average coordinates (<b>'+ax+','+ay+'</b>)';
str += '<br/>';
if (rk != "")
str += 'The alliance is ranked <b>#'+rk+'</b> with <b>' + formatNumber(pts) + '</b> points.<br/>';
str += 'You are ';
if (il == 1)
str += 'the leader';
else
str += 'a member';
str += ' of this alliance';
if (il == 0 && prk != "-")
str += ' with the rank of <b>' + prk + '</b>';
str += '.<br/><a href="alliance" ' + diptt[2] + ' >Alliance page</a></p>';
if (fl.length > 0)
{
str += '<h2>Forums</h2><p>';
var i;
for (i=0;i<fl.length;i++)
{
var a = fl[i].split('#');
var id = a.shift(), ntot = a.shift(), nunr = a.shift();
str += '<a href="forums?cmd=F%23A%23'+id+'" ' + diptt[3] + '>' + a.join('#') + '</a>: ';
if (ntot>0)
{
str += '<b>' + ntot + '</b> topic' + (ntot>1?"s":"");
if (nunr > 0)
str += ', <b>' + nunr + '</b> unread';
}
else
str += 'empty forum';
str += '<br/>';
}
str += '</p>';
}
document.getElementById('alliance').innerHTML = str;
}
function drawNoAssistance()
{
document.getElementById('rsass').innerHTML = 'You cannot yet give or receive scientific assistance.';
}
function drawAssistance(pend,sto)
{
var str = 'You have ';
if (pend == 0)
str += 'no pending assistance offers.';
else if (pend == 1)
str += '<b>1</b> pending offer.';
else
str += '<b>'+pend+'</b> pending offers.';
str += '<br/>';
if (sto == "")
str += 'You haven\'t sent any offer in the last 24 hours.';
else
str += 'You have sent an offer to <b>'+sto+'</b> in the last 24 hours.';
str += '<br/><a href="research?p=d" ' + diptt[4] + ' >Scientific Assistance page</a>';
document.getElementById('rsass').innerHTML = str;
}

View file

@ -0,0 +1,62 @@
var diptt;
function initPage()
{
var data = document.getElementById('dinit').innerHTML;
if (data.indexOf('\n') != -1)
drawDiplomacyPage(data);
else // IE sucks.
x_getInformation(drawDiplomacyPage);
}
function drawDiplomacyPage(data)
{
var l = data.split('\n');
// Alliance status
var a = l.shift().split('#');
if (a[0] == 0)
drawNoAlliance();
else if (a[0] == 1)
drawPending(a[1],a[2],a[3],a[4],a[5],l.shift(),l.shift(),l.shift());
else
{
var i, fl = new Array();
var tag = l.shift(), name = l.shift();
var leader = (a[6] == 1) ? "" : l.shift();
var rank = (a[6] == 1) ? "-" : l.shift();
for (i=0;i<a[7];i++)
fl.push(l.shift());
drawAlliance(a[1],a[2],a[3],a[4],a[5],a[6],tag,name,leader,rank,fl);
}
// Allies and enemies
a = l.shift().split('#');
var nenp = parseInt(a[0], 10);
var nena = parseInt(a[1], 10);
var nall = parseInt(a[2], 10);
var nrall = parseInt(a[3], 10);
if (nenp+nena+nall+nrall == 0)
drawNoRelations();
else
drawRelations(nenp, nena, nall, nrall);
// Messages
a = l.shift().split('#');
document.getElementById('pm').innerHTML = formatNumber(a[0]);
document.getElementById('pmn').innerHTML = formatNumber(a[1]);
document.getElementById('it').innerHTML = formatNumber(a[2]);
document.getElementById('itn').innerHTML = formatNumber(a[3]);
// Scientific assistance
a = l.shift().split('#');
if (a[0] == 0)
drawNoAssistance();
else
{
a.shift();
drawAssistance(a.shift(), a.join('#'));
}
setTimeout('x_getInformation(drawDiplomacyPage)', 120000);
}

View file

@ -0,0 +1,62 @@
function makeEmpireTooltips()
{
emptt = new Array();
if (ttDelay == 0)
{
var i;
for (i=0;i<2;i++)
emptt[i] = "";
return;
}
emptt[0] = tt_Dynamic("Click here to go to this planet's individual page");
emptt[1] = tt_Dynamic("Click here to get a new planet when you've lost all of yours");
}
function empire_planets(d)
{
var str;
if (d[3] != 'N/A')
str = '<b>' + formatNumber(d[3]) + '</b> per planet';
else
str = 'N/A';
document.getElementById('plapop').innerHTML = str;
if (d[5] != 'N/A')
str = '<b>' + formatNumber(d[5]) + '</b> per planet';
else
str = 'N/A';
document.getElementById('plafct').innerHTML = str;
if (d[7] != 'N/A')
str = '<b>' + formatNumber(d[7]) + '</b> per planet';
else
str = 'N/A';
document.getElementById('platrt').innerHTML = str;
if (d[8] != '0')
{
str = '<b class="phapbad">' + d[8] + ' planet';
if (d[8] > 1)
str += 's';
str += ' under attack!</b><br/>';
}
else
str = '';
document.getElementById('platt').innerHTML = str;
}
function displayResearchStatus(na, nb)
{
var str;
if (na == 0 && nb == 0)
return;
str = '<h2>Status</h2><p>';
if (na > 0)
str += 'Available technologies: <b>' + na + '</b>';
if (nb > 0)
str += (na > 0 ? '<br/>' : '') + 'Foreseen breakthroughs: <b>' + nb + '</b>';
document.getElementById('rsst').innerHTML = str;
}

View file

@ -0,0 +1,118 @@
var emptt;
function empire_write(data)
{
var a, plo, flo, plst, i, mi, str, pid, pname;
a = data.split("\n");
// Planets overview
plo = a[0].split('#');
document.getElementById('plcnt').innerHTML = plo[0];
if (plo[1] != 'N/A')
{
str = '<b class="phap';
if (plo[1] >= 70)
str += 'ok';
else if (plo[1] >= 40)
str += 'med';
else if (plo[1] >= 20)
str += 'dgr';
else
str += 'bad';
str += '">' + plo[1] + '%</b>';
}
else
str = plo[1];
document.getElementById('plahap').innerHTML = str;
if (plo[9] != 'N/A')
{
str = '<b class="phap';
if (plo[9] >= 41)
str += 'bad';
else if (plo[9] >= 41)
str += 'dgr';
else if (plo[9] >= 11)
str += 'med';
else
str += 'ok';
str += '">' + plo[9] + '%</b>';
}
else
str = plo[9];
document.getElementById('placor').innerHTML = str;
document.getElementById('plpop').innerHTML = formatNumber(plo[2]);
document.getElementById('plfct').innerHTML = formatNumber(plo[4]);
document.getElementById('pltrt').innerHTML = formatNumber(plo[6]);
empire_planets(plo);
// Planets list
plst = a[1].split('#');
mi = plst.length / 2;
str = '';
for (i=0;i<mi;i++)
{
pid = plst[i*2];
pname = plst[i*2 + 1];
str += '<a href="planet?id=' + pid + '" ' + emptt[0] + ' >' + pname + '</a>';
if (i < mi - 1)
{
if ((i-2)%3)
str += ' - ';
else
str += '<br/>';
}
}
if (str == '')
str = '<a href="getplanet" ' + emptt[1] + ' >Get a new planet</a>';
document.getElementById('pllst').innerHTML = str;
// Fleets
flo = a[2].split('#');
document.getElementById('fltot').innerHTML = formatNumber(flo[2]);
document.getElementById('flupk').innerHTML = formatNumber(flo[3]);
document.getElementById('flcnt').innerHTML = formatNumber(flo[0]);
document.getElementById('flbat').innerHTML = formatNumber(flo[1]);
document.getElementById('flhcnt').innerHTML = formatNumber(flo[4]);
document.getElementById('flhbat').innerHTML = formatNumber(flo[5]);
document.getElementById('flocnt').innerHTML = formatNumber(flo[6]);
document.getElementById('flobat').innerHTML = formatNumber(flo[7]);
document.getElementById('flomv').innerHTML = formatNumber(flo[8]);
document.getElementById('flowt').innerHTML = formatNumber(flo[9]);
document.getElementById('flgas').innerHTML = formatNumber(flo[10]);
document.getElementById('flfgt').innerHTML = formatNumber(flo[11]);
document.getElementById('flcru').innerHTML = formatNumber(flo[12]);
document.getElementById('flbcr').innerHTML = formatNumber(flo[13]);
tot = parseInt(flo[10], 10) + parseInt(flo[11], 10) + parseInt(flo[12], 10) + parseInt(flo[13], 10);
document.getElementById('flsht').innerHTML = formatNumber(tot.toString());
// Research
var rd = a[3].split('#');
var rbPoints = rd[0], rbPercentage = new Array();
for (i=0;i<3;i++)
rbPercentage[i] = parseInt(rd[i+1], 10);
var rbCatPoints = new Array(), s = 0;
for (i=0;i<3;i++)
{
rbCatPoints[i] = Math.floor(rbPercentage[i] * rbPoints / 100);
s += rbCatPoints[i];
}
for (i=0;s<rbPoints;i=(i+1)%3)
{
rbCatPoints[i] ++;
s ++;
}
document.getElementById('rsbf').innerHTML = rbPercentage[0];
document.getElementById('rspf').innerHTML = formatNumber(rbCatPoints[0].toString());
document.getElementById('rsbm').innerHTML = rbPercentage[1];
document.getElementById('rspm').innerHTML = formatNumber(rbCatPoints[1].toString());
document.getElementById('rsbc').innerHTML = rbPercentage[2];
document.getElementById('rspc').innerHTML = formatNumber(rbCatPoints[2].toString());
displayResearchStatus(rd[4], rd[5]);
// Money
var md = a[4].split('#');
document.getElementById('minc').innerHTML = formatNumber(md[0]);
document.getElementById('mprof').innerHTML = formatNumber(md[1]);
setTimeout('x_getEmpireData(empire_write)', 60000);
}

View file

@ -0,0 +1,40 @@
var emptyListText = 'This list is empty.';
var removeText = 'Remove selected enemies';
function makeEnemyListTooltips()
{
enltt = new Array();
if (ttDelay == 0)
{
var i;
for (i=0;i<11;i++)
enltt[i] = "";
return;
}
enltt[0] = tt_Dynamic("Use this checkbox to select / unselect this enemy");
enltt[10] = tt_Dynamic("Click here to remove the selected enemies from your enemy list");
}
function addAlert(ei) {
var str = 'Error\n';
switch(ei) {
case 0: str += 'Possible cheating detected.'; break;
case 1: str += 'You must specify the name of the enemy to add.'; break;
case 2: str += 'This player does not exist.'; break;
case 3: str += 'This alliance does not exist.'; break;
case 4: str += 'This player is already in your enemy list.'; break;
case 5: str += 'This alliance is already in your enemy list.'; break;
case 6: str += 'You can\'t add yourself to your enemy list.'; break;
case 7: str += 'You can\'t add your own alliance to your enemy list.'; break;
case 8: str += 'This player is in your trusted allies list.'; break;
case 9: str += 'You can\'t add the Peacekeepers to your enemy list.'; break;
case 200: str += 'You are not allowed to edit the enemy list\nwhile in vacation mode.'; break;
default: str += 'An unknown error has occured.'; break;
}
alert(str);
}
function alertRemoveVacation () {
alert('Error\nYou are not allowed to edit the enemy list\nwhile in vacation mode.');
}

View file

@ -0,0 +1,167 @@
var enPlayers = new Array();
var enAlliances = new Array();
var lsPlayers = new Array();
var lsAlliances = new Array();
var update;
var enltt;
function Enemy(id,name)
{
this.id = id;
this.name = name;
this.selected = false;
}
function parseData(data) {
if (data == "ERR#200") {
alertRemoveVacation();
return;
}
var l = data.split('\n');
var pl, al, t;
pl = enPlayers; al = enAlliances;
enPlayers = new Array(); lsPlayers = new Array();
enAlliances = new Array(); lsAlliances = new Array();
while (l.length > 0) {
var a = l.shift().split('#');
var tp = a.shift(), id = a.shift();
if (tp == 0)
{
if (pl[id])
t = pl[id];
else
t = new Enemy(id, a.join('#'));
enPlayers[id] = t;
lsPlayers.push(t);
}
else
{
if (al[id])
t = al[id];
else
t = new Enemy(id, a.join('#'));
enAlliances[id] = t;
lsAlliances.push(t);
}
}
}
function initList()
{
var data = document.getElementById('elinit').innerHTML;
if (data != "")
{
if (data.split('#').length > 3 && data.indexOf('\n') == -1)
{
// IE really sucks.
x_getEnemies(updatePage);
return;
}
parseData(data);
}
displayPage();
}
function updatePage(data) {
if (data == "") {
enPlayers = new Array(); lsPlayers = new Array();
enAlliances = new Array(); lsAlliances = new Array();
} else {
parseData(data);
}
displayPage();
}
function displayPage()
{
drawList('eal', lsAlliances, "lsAlliances");
drawList('epl', lsPlayers, "lsPlayers");
update = setTimeout('x_getEnemies(updatePage)', 60000);
}
function drawList(lid, lst, lsn)
{
if (lst.length == 0)
{
document.getElementById(lid + 'div').innerHTML = '<p>' + emptyListText + '</p>';
return;
}
lst.sort(new Function('a','b','return (a.name.toLowerCase()>b.name.toLowerCase())?1:-1'));
var i, str = '<table cellspacing="0" cellpadding="0" class="enlist">';
var nr = (lst.length % 2) + (lst.length - (lst.length % 2)) / 2;
for (i=0;i<lst.length;i++)
{
if (i%2 == 0)
{
str += '<tr>';
if (i==0)
str += '<td rowspan="' + (nr+1) + '" class="spacer">&nbsp;</td>';
}
str += '<td><input type="checkbox" ' + enltt[0] + ' name="'+lid+'sel" id="'+lid+'s'+i+'" value="'+i+'" onClick="';
str += lsn+'['+i+'].selected=!'+lsn+'['+i+'].selected;updateButton(\''+lid+'\','+lsn+',\''+lsn+'\')"';
if (lst[i].selected)
str += ' checked="checked"';
str += '/> <label for="'+lid+'s'+i+'">'+lst[i].name+'</label></td>';
if (i%2 == 1)
str += '</tr>';
}
if (i%2 == 1)
str += '<td>&nbsp;</td></tr>';
str += '<tr><td colspan="2" class="lsbutton" id="del'+lid+'">&nbsp;</td></tr></table>';
document.getElementById(lid + 'div').innerHTML = str;
updateButton(lid, lst, lsn);
}
function updateButton(lid, lst, lsn)
{
var i;
for (i=0;i<lst.length&&!lst[i].selected;i++) ;
document.getElementById('del'+lid).innerHTML=(i==lst.length) ? '&nbsp;'
: ('<input type="button" ' + enltt[10] + ' name="bd'+lid+'" value="'+removeText+'" onClick="listRemove('+lsn+',\''+lsn+'\');return false" />');
}
function listRemove(lst, lsn)
{
var i, lids = new Array();
for (i=0;i<lst.length;i++)
if (lst[i].selected)
lids.push(lst[i].id);
clearTimeout(update);
x_removeEnemies(lsn == 'lsPlayers' ? 0 : 1, lids.join('#'), updatePage);
}
function addPlayer()
{
clearTimeout(update);
x_addEnemy(0, document.getElementById('nepl').value, addDataReceived);
}
function addAlliance()
{
clearTimeout(update);
x_addEnemy(1, document.getElementById('neal').value, addDataReceived);
}
function addDataReceived(data) {
if (data.indexOf('ERR#') == 0) {
var ei = parseInt(data.replace(/ERR#/, ''), 10);
addAlert(ei);
update = setTimeout('x_getEnemies(updatePage)', 60000);
} else {
document.getElementById('neal').value = '';
document.getElementById('nepl').value = '';
updatePage(data);
}
}

View file

@ -0,0 +1,992 @@
var actionText = ['Please select at least one fleet.', 'Rename', 'Change orders', 'Switch status', 'Split', 'Merge', 'Sell', 'Disband', 'View trajectory', 'Clear selection', 'Cancel sale', 'Sale details'];
var statusText = ['Attack', 'Defense', 'Avail.', 'Unavail.', 'On sale', 'Sold', ' (bundled)'];
var sectionTitles = ['Own planets', 'Allied planets', 'Other planets', 'Moving fleets', 'Fleets standing by'];
var noFleetsFound = 'No fleets were found.';
var foSelHeader = '<th class="fown">Owner</th><th class="fname">Name</th><th class="fhs">Haul</th><th class="fshp">Ships (G/F/C/B)</th><th class="fpwr">Power</th><th class="ftraj">Trajectory</th>';
var foAvaHeader = '<th class="fown">Owner</th><th class="fname">Name</th><th class="fhs">Haul</th><th class="fshp">Ships (G/F/C/B)</th><th class="fpwr">Power</th><th class="fco">Current Orders</th>';
var curOrdersTxt = ['Defending ', 'Attacking ', '', '', 'Moving to ', 'Moving to ', ' for defense', ' for attack', 'Standing by in Hyperspace to defend ', 'Standing by in Hyperspace to attack ', '', ''];
var noSelection = 'no destination selected';
var smapCoordTxt = "System at coordinates ";
var dirTxt = ['Up', 'Left', 'Right', 'Down'];
var unchartedTxt = "(uncharted)";
var orbitTypes = ['Planet', 'Planetary remains', 'Class 1 nebula', 'Class 2 nebula', 'Class 3 nebula', 'Class 4 nebula'];
var salesText = ['Target player:', 'Price:', 'Minimum bid:'];
function drawMainLayout()
{
var i, str = '<form action="?" onSubmit="return false"><table class="fctrl" cellspacing="0" cellpadding="0">';
// Locations
str += '<tr><td>Locations:</td><td><select name="lLoc" id="lLoc" onChange="changeFilters(\'listLocations\', this.options[this.selectedIndex].value)">';
var locs = ['All planets', 'Own planets', 'Allied planets', 'Other planets'];
for (i=0;i<locs.length;i++)
str += '<option value="'+i+'"'+(listLocations == i ? ' selected="selected"' : '')+'>'+locs[i]+'</option>';
str += '</select></td>';
// Modes
str += '<td>Fleet mode:</td><td><select name="lMode" id="lMode" onChange="changeFilters(\'listMode\', this.options[this.selectedIndex].value)">';
var fmd = ['Any', 'Defending', 'Attacking'];
for (i=0;i<fmd.length;i++)
str += '<option value="'+i+'"'+(listMode == i ? ' selected="selected"' : '')+'>'+fmd[i]+'</option>';
str += '</select></td></tr>';
// Current status
str += '<tr><td>Fleet status:</td><td><select name="fMode" id="fMode" onChange="changeFilters(\'fDispMode\', this.options[this.selectedIndex].value)">';
var fst = ['Any', 'Idle', 'Unavailable', 'Moving', 'H.S. Stand-by', 'On sale', 'Sold'];
for (i=0;i<fst.length;i++)
str += '<option value="'+i+'"'+(fDispMode == i ? ' selected="selected"' : '')+'>'+fst[i]+'</option>';
str += '</select></td>';
// Allies mode
str += '<td>Fleet owner:</td><td><select name="aMode" id="aMode" onChange="changeFilters(\'alliesMode\', this.options[this.selectedIndex].value)">';
var alm = ['Any', 'Myself', 'Trusted Allies', 'Others'];
for (i=0;i<alm.length;i++)
str += '<option value="'+i+'"'+(alliesMode == i ? ' selected="selected"' : '')+'>'+alm[i]+'</option>';
str += '</select></td></tr></table>';
// Search engine
str += '<table class="fsearch"><tr><td>';
str += 'Search for <select name="sType" id="sType" onChange="changeFilters(\'sType\', this.options[this.selectedIndex].value)">';
var stp = ['fleet', 'location', 'player'];
for (i=0;i<stp.length;i++)
str += '<option value="'+i+'"'+(sType == i ? ' selected="selected"' : '')+'>'+stp[i]+'</option>';
var c = "changeFilters('sText', this.value)";
str += '</select> <input type="text" name="sText" id="sText" value="" onKeyUp="'+c+'" onClick="'+c+'" />';
str += '</td></tr></table>';
// Main display
str += '<hr/><div id="fmain">&nbsp;</div>';
// Commands
str += '<div class="factions" id="faframe"><table class="factions" cellpadding="0" cellspacing="0"><tr><th>Actions:</th>';
str += '<td id="factions">&nbsp;</td><td style="width:5%"><a href="manual?p=fleets_page">Help</a></tr></table></div>';
str += '</form>';
document.getElementById('fpage').innerHTML = str;
document.getElementById('sText').value = sText;
}
function drawMovingHeader(hasSel) {
var str;
str = '<table class="mfltl"><tr>';
if (hasSel) {
str += '<th class="fsel" id="f-move-sel" rowspan="2">&nbsp;</th>';
}
str += '<th class="fown" rowspan="2">Owner</th><th class="fname" rowspan="2">Name</th>';
str += '<th class="fhs">Haul</th><th class="fshp">GA Ships</th>';
str += '<th class="fshp">Fighters</th><th class="fshp">Cruisers</th><th class="fshp">Battle Cruisers</th>';
str += '<th class="fpwr">Power</th><th class="fstat">Status</th></tr>';
str += '<tr><th class="floc" colspan="2">Current Location</th><th class="fdest" colspan="2">Destination</th>';
str += '<th class="feta">E.T.A.</th><th class="fstd" colspan="2">H.S. Standby</th></tr></table>';
return str;
}
function drawWaitingHeader(hasSel) {
var str;
str = '<table class="wfltl"><tr>';
if (hasSel) {
str += '<th class="fsel" id="f-hssb-sel" rowspan="2">&nbsp;</th>';
}
str += '<th class="fown" rowspan="2">Owner</th><th class="fname" rowspan="2">Name</th>';
str += '<th class="fhs">Haul</th><th class="fshp">GA Ships</th>';
str += '<th class="fshp">Fighters</th><th class="fshp">Cruisers</th><th class="fshp">Battle Cruisers</th>';
str += '<th class="fpwr">Power</th><th class="fstat">Status</th></tr>';
str += '<tr><th class="floc" colspan="2">Location</th><th class="ftime" colspan="2">Time Spent</th>';
str += '<th class="ftime" colspan="2">Time Left</th><th class="floss">Loss Prob.</th></tr></table>';
return str;
}
function drawPlanetBox(planet) {
var str = '<table class="planet"><tr class="phdr">';
var so = (planet.fleetLocation.details && planet.fleetLocation.details.owner != '' && planet.fleetLocation.details.owner != myself.id);
var apow = 0, dpow = 0;
str += "<td class='pimg'><img src='" + staticurl + '/beta5/pics/';
if (planet.fleetLocation.opacity == 0) {
str += 'pl/s/'+planet.id;
} else if (planet.fleetLocation.opacity == 1) {
str += 'prem_s';
} else {
str += 'nebula' + (planet.fleetLocation.opacity-1);
}
str += ".png' class='pimg' alt='[P]' /></td><td class='name'><a href='planet?id=";
str += planet.id + "'>" + planet.fleetLocation.name + '</a>';
str += " (<b>" + planet.fleetLocation.x + ',' + planet.fleetLocation.y + '</b>,' + planet.fleetLocation.orbit + ')';
if (planet.fleetLocation.details && planet.fleetLocation.details.tag != '') {
str += ' [<b>' + planet.fleetLocation.details.tag + '</b>]';
}
str += '</td>';
if (so) {
str += '<td class="pinf"><a href="message?a=c&ct=0&id='+planet.fleetLocation.details.owner+'">';
str += players.get(planet.fleetLocation.details.owner) + '</a></td>';
}
str += "<td class='pinf'";
if (planet.fleetLocation.details) {
with(planet.fleetLocation.details) {
str += '>Population: <b>' + formatNumber(pop) + 'M</b></td><td class="pinf">';
if (turrets != 0) {
str += '<b>' + formatNumber(turrets) + '</b> turret' + (turrets > 1 ? 's' : '');
str += '; power: <b>' + formatNumber(tPower) + '</b>';
dpow += parseInt(tPower, 10);
} else {
str += 'No turrets';
}
}
} else {
str += ' colspan="2">' + (planet.fleetLocation.opacity == 1 ? 'Planetary remains' : ('Class ' + (planet.fleetLocation.opacity - 1) + ' nebula'));
}
str += '</td></tr><tr><td colspan="'+(so?'5':'4')+'" class="';
if (planet.fleets.length) {
planet.fleetLocation.selectableFleets = planet.fleetLocation.selectedFleets = 0;
var j, f, om = -1;
str += 'flt"><table class="fltl"><tr><th class="fsel" id="fsel-p-' + planet.id + '">&nbsp;</th>';
str += '<th class="fown">Owner</th><th class="fname">Name</th><th class="fhs">Haul</th><th class="fshp">GA Ships</th>';
str += '<th class="fshp">Fighters</th><th class="fshp">Cruisers</th><th class="fshp">Battle Cruisers</th>';
str += '<th class="fpwr">Power</th><th class="fstat">Status</th></tr>';
planet.fleets.sort(sortPlanetFleets);
for (j=0;j<planet.fleets.length;j++) {
f = fleets.get(planet.fleets[j]);
if (f.owner == myself.id) {
om = f.mode;
}
}
if (om == -1) {
for (j=0;j<planet.fleets.length;j++) {
f = fleets.get(planet.fleets[j]);
if (allies.containsKey(f.owner))
om = f.mode;
}
}
if (om == -1) {
om = 0;
}
for (j=0;j<planet.fleets.length;j++) {
f = fleets.get(planet.fleets[j]);
if (f.mode == 0) {
dpow += parseInt(f.power,10);
} else {
apow += parseInt(f.power,10);
}
str += drawFleetLine(f, f.owner == myself.id ? 'own' : (f.mode == om ? 'ally': 'enemy'),true);
}
str += '</table>';
if (planet.fleetLocation.details) {
var act = new Array(), ang = new Array();
f = allies.keys();
if (!planet.fleetLocation.details.vacation) {
for (j=0;j<f.length;j++) {
var a = allies.get(f[j]), og;
if (!a.gasAt.containsKey(planet.id)) {
continue;
}
og = a.gasAt.get(planet.id);
if (og * a.gaPop >= planet.fleetLocation.details.pop) {
act.push(a);
} else if (og > 0) {
var ep = parseInt(planet.fleetLocation.details.pop, 10) - og * a.gaPop;
ep = Math.ceil(ep / a.gaPop);
ang.push([a,ep.toString()]);
}
}
}
if (act.length || ang.length || apow != 0 || planet.fleetLocation.details.vacation
|| planet.fleetLocation.details.protection) {
str += '</td></tr><tr><td colspan="'+(so?'5':'4')+'" class="takers">';
if (act.length) {
for (j=0;j<act.length;j++) {
if (j != 0) {
str += (j == act.length - 1) ? ' or ' : ', ';
}
str += act[j].getName();
}
str += ' could take the planet.';
if (ang.length || apow != 0) {
str += '<br/>';
}
}
if (ang.length) {
for (j=0;j<ang.length;j++) {
str += ang[j][0].getName() + ' would need <b>' + formatNumber(ang[j][1]) + '</b> more GA Ship'
+ (ang[j][1] > 1 ? 's' : '') + ' to take this planet.';
if (j != ang.length - 1) {
str += '<br/>';
}
}
if (apow != 0) {
str += '<br/>';
}
}
if (apow != 0) {
str += 'Battle status: <b class="own">' + formatNumber((om == 0 ? dpow : apow).toString())
+ '</b> vs. <b class="enemy">' + formatNumber((om == 1 ? dpow : apow).toString()) + '</b>';
if (planet.fleetLocation.details.vacation || planet.fleetLocation.details.protection) {
str += '<br/>';
}
}
if (planet.fleetLocation.details.protection) {
str += '<b class="enemy">Planet is under protection!</b>';
} else if (planet.fleetLocation.details.vacation) {
str += '<b class="enemy">Planet is on vacation!</b>';
}
}
}
str += '</table>';
} else {
str += 'noflt">No fleets found';
}
str += '</td></tr></table>';
return str;
}
function getNewFleetName(p)
{
return prompt("Please type the new name for th"+(p?"ese fleets":"is fleet")+".", "");
}
function alertFleetName(e) {
var str = 'Error: ';
switch (e)
{
case 0:
str += 'please specify a name';
break;
case 1:
str += 'this name is too long';
break;
case 2:
str += 'this name is too short';
break;
case 3:
str += 'a fleet was not found';
break;
case 200:
str += 'you can\'t rename a fleet while in vacation mode';
break;
default:
str += 'an unknown error has occured';
break;
}
alert(str + '.');
}
function getMergedFleetName()
{
return prompt("Please type the name of the merged fleet. Leave blank to keep\nits former name.\n", '');
}
function alertFleetMerge(e) {
var str = 'Error: ';
switch (e)
{
case 0:
str += 'this name is too long';
break;
case 1:
str += 'this name is too short';
break;
case 2:
str += 'a fleet was not found';
break;
case 200:
str += 'you can\'t merge fleets while in vacation mode';
break;
default:
str += 'an unknown error has occured';
break;
}
alert(str + '.');
}
function alertFleetSwitch(e) {
var str = 'Error: ';
switch (e) {
case 0:
str += 'you no longer have control over this fleet';
break;
case 1:
str += 'you can\'t switch to attack mode on a planet you own';
break;
case 2:
str += 'you (or your alliance) are in the planet owner\'s enemy list';
break;
case 3:
str += 'the Peacekeepers will not let you get away with that so easily';
break;
case 200:
str += 'you can\'t switch a fleet\'s status while in vacation mode';
break;
default:
str += 'an unknown error has occured';
break;
}
alert(str + '.');
}
function alertFleetDisband(e) {
var str = 'Error: ';
switch (e) {
case 0:
str += 'you don\'t have control over this fleet';
break;
case 1:
str += 'the selected fleet(s) no longer exist';
break;
case 2:
str += 'not enough cash to cancel the fleet\'s sale';
break;
case 200:
str += 'you can\'t disband fleets while in vacation mode';
break;
default:
str += 'an unknown error has occured';
break;
}
alert(str + '.');
}
function alertFleetSplit(e) {
var str = 'Error: ';
switch (e) {
case 0:
str += 'you no longer have control over this fleet';
break;
case 1:
str += 'you are trying to cheat, aren\'t you? If not, contact us';
break;
case 2: case 5:
str += 'the fleet you tried to split is no longer available';
break;
case 3: case 4: case 7:
str += 'the fleet\'s size has changed in the meantime';
break;
case 10:
str += 'the new fleets\' name is too short';
break;
case 11:
str += 'the new fleets\' name is too long';
break;
case 200:
str += 'you can\'t split a fleet while in vacation mode';
break;
default:
str += 'an unknown error has occured';
break;
}
alert(str + '.');
}
function alertFleetOrders(e) {
var str = 'Error: ';
switch (e) {
case 0:
str += 'you no longer have control over these fleets';
break;
case 1:
str += 'the destination planet wasn\'t found';
break;
case 2:
str += 'an internal error occured.\nPlease report this to the staff as "setOrders/2"';
break;
case 3:
str += 'the fleets you selected are for sale';
break;
case 4:
str += 'the fleets you selected are no longer available';
break;
case 200:
str += 'you can\'t change fleet orders while in vacation mode';
break;
default:
str += 'an unknown error has occured';
break;
}
alert(str + '.');
}
function alertServerError() {
alert('Error: an error has occured on the server.\nPlease contact the staff.');
}
function alertViewSale() {
alert('Error: this sale is no longer available');
}
function drawSplitPage()
{
var i, str = '<form action="?" onSubmit="return false"><h2>';
var f = splitParam[0];
switch (f.orders.oType)
{
case 0:
str += 'Split fleet orbitting ' + f.orders.loc.name + '</h2><br/>';
str += '<table class="planet"><tr><td class="flt"><table class="fltl"><tr>';
str += '<th class="fown">Owner</th><th class="fname">Name</th><th class="fhs">Haul</th><th class="fshp">GA Ships</th>';
str += '<th class="fshp">Fighters</th><th class="fshp">Cruisers</th><th class="fshp">Battle Cruisers</th>';
str += '<th class="fpwr">Power</th><th class="fstat">Status</th></tr>';
str += drawFleetLine(f, (f.owner == myself.id ? 'own' : 'ally'), false);
str += '</table></td></tr></table>';
break;
case 1:
str += 'Split moving fleet</h2><br/><table class="planet"><tr><td class="flt">' + drawMovingHeader(false) + '</td></tr>';
str += drawMovingFleetLine(f, false);
str += '</table>';
break;
case 2:
str += 'Split waiting fleet</h2><br/><table class="planet"><tr><td class="flt">' + drawWaitingHeader() + '</td></tr>';
str += drawWaitingFleetLine(f, false);
str += '</table>';
break;
}
str += '<h2>New fleet(s)</h2>';
str += '<table class="scmd"><tr><th>Split type:</th><td><label><input type="radio" name="stype" value="0" id="stype0" checked="checked" onClick="setSplitType(0)" />';
str += 'Manual</label></td></tr><tr><th>&nbsp;</th><td><label><input type="radio" name="stype" value="1" onClick="setSplitType(1)" /> Automatic</label></td></tr>';
str += '<tr><th>Amount of fleets:</th><td><select name="nfleets" onChange="setSplitCount(parseInt(this.options[this.selectedIndex].value, 10))">';
for (i=1;i<11;i++)
str += '<option value="'+i+'">'+(i+1)+'</option>';
str += '</select></td></tr><tr><th>New name:</th><td><input type="text" value="" name="nfn" id="nfn" onChange="splitParam[9]=this.value" /></td></tr>';
str += '<tr><td colspan="2">&nbsp;</td></tr>';
if (f.ships[0] > 0)
{
var c = 'setSplitShips(0,parseInt(this.value, 10))';
c = "onKeyUp='"+c+"' onClick='"+c+"'";
str += '<tr><th>GA Ships:</th><td><input type="text" value="0" id="sgas" name="sgas" size="10"'+c+' /> / ' + formatNumber(f.ships[0]) + '</td></tr>';
}
if (f.ships[1] > 0)
{
var c = 'setSplitShips(1,parseInt(this.value, 10))';
c = " onKeyUp='"+c+"' onClick='"+c+"'";
str += '<tr><th>Fighters:</th><td><input type="text" value="0" id="sfgt" name="sfgt" size="10"'+c+' /> / ' + formatNumber(f.ships[1]) + '</td></tr>';
}
if (f.ships[2] > 0)
{
var c = 'setSplitShips(2,parseInt(this.value, 10))';
c = " onKeyUp='"+c+"' onClick='"+c+"'";
str += '<tr><th>Cruisers:</th><td><input type="text" value="0" id="scru" name="scru" size="10"'+c+' /> / ' + formatNumber(f.ships[2]) + '</td></tr>';
}
if (f.ships[3] > 0)
{
var c = 'setSplitShips(3,parseInt(this.value, 10))';
c = " onKeyUp='"+c+"' onClick='"+c+"'";
str += '<tr><th>Battle Cruisers:</th><td><input type="text" value="0" id="sbcr" name="sbcr" size="10"'+c+' /> / ' + formatNumber(f.ships[3]) + '</td></tr>';
}
if (f.ships[2] > 0 || f.ships[3] > 0)
str += '<tr><th>Haul used:</th><td id="hused">0</td></tr><tr><th>Haul available:</th><td id="havail">0</td></tr>';
str += '<tr><td colspan="2">&nbsp;</td></tr><tr><td colspan="2" class="sbut">';
str += '<input type="submit" onClick="doFleetSplit(); return false" value="Split fleet" id="bsplit" disabled="disabled" />';
str += '<input type="submit" onClick="cancelSplit(); return false" value="Cancel" /></td></tr>';
str += '</table>';
str += '</form>';
document.getElementById('fpage').innerHTML = str;
}
function confirmDisband(p)
{
return confirm('Are you sure you want to disband ' + (p ? 'these fleets' : 'this fleet') + '?');
}
function drawOrdersPage()
{
var str = '<form action="?" onSubmit="return false">'
+ '<table><tr><td id="chord"><h1>Change Orders</h1><td id="chordc">&nbsp;</td></tr></table>'
+ '<h2>New orders</h2><p><span id="moveto">&nbsp;</span><br/><span id="standby">&nbsp;</span><br/>'
+ '<span id="odmode">&nbsp;</span></p><h2>Selected fleets</h2><div id="oself">&nbsp;</div>'
+ '<h2>Available fleets</h2><div id="oavaf">&nbsp;</div></form>';
document.getElementById('fpage').innerHTML = str;
}
function getMoveToLine()
{
if (moveTo == -1)
return "No destination selected - <a href='#' onClick='setOrdersDestination();return false'>Set destination</a>";
return "Move to <b>" + moveToLoc.name + "</b> (<b>" + moveToLoc.x + ',' + moveToLoc.y + '</b>,' + moveToLoc.orbit
+ ") - <a href='#' onClick='setOrdersDestination();return false'>Change destination</a> - "
+ "<a href='#' onClick='removeOrdersDestination();return false'>Remove destination</a>";
}
function getStandByLine()
{
if (!selCanHS)
{
waitTime = -1;
return "Selection is not capable of Hyperspace travel";
}
if (waitTime == -1)
return "No Hyperspace stand-by orders - <a href='#' onClick='setOrdersTime();return false'>Set delay</a>";
return "Selection is scheduled to stand by in Hyperspace for <b>" + waitTime + "</b>h "
+ " - <a href='#' onClick='setOrdersTime();return false'>Change delay</a>"
+ " - <a href='#' onClick='cancelOrdersDelay();return false'>Remove delay</a>";
}
function getModeLine()
{
var fd = false;
if (orderFleets.length)
{
var i;
for (i=0;i<orderFleets.length;i++)
{
var f = fleets.get(orderFleets[i]);
if ( moveTo != -1 && moveToLoc.details && f.owner == moveToLoc.details.owner
|| moveTo == -1 && (f.orders.oType == 1 && f.orders.cur.details && f.orders.cur.details.owner == f.owner)
|| moveTo == -1 && (f.orders.oType != 1 && f.orders.loc.details && f.orders.loc.details.owner == f.owner)
)
return "Destination is owned by one of the fleets' owners - forcing to defense.";
}
}
return "Fleet mode: <select onclick='orderMode = parseInt(this.options[this.selectedIndex].value, 10)' "
+ "name='flmode' id='flmode'><option value='0'>Defense</option>"
+ "<option value='1' " + (orderMode ? " selected='selected'" : "") + ">Attack</option></select>";
}
function getOrderLinks()
{
var str = "";
if (orderFleets.length > 0)
str += '<a href="#" onClick="setNewOrders();return false">Confirm</a> - ';
str += '<a href="#" onClick="cancelOrders();return false">Cancel</a>';
return str;
}
function getFleetDelay(current)
{
return prompt("Please enter the duration of the fleet's Hyperspace stand by,\nin hours.", current);
}
function fleetDelayError(e)
{
var str = "Error: ";
switch (e)
{
case 0:
str += "please type a valid number";
break;
case 1:
str += "the delay must be at least 1 hour";
break;
case 2:
str += "the delay must be at most 48 hours";
break;
}
alert(str);
}
function drawDestinationSelection()
{
var str = '<form onSubmit="return false" action="?">';
str += '<table class="fseldest"><tr><td><h1>Set Destination</h1>';
str += '<p>Current selection: <span id="cursel">&nbsp;</span></p><p>';
str += 'Please use the map on the right to select a new destination.</p>';
str += '<p class="sdbut"><input type="button" name="sdok" value="Confirm" onClick="confirmSetDestination()" id="sdok" disabled="disabled" />';
str += ' <input type="button" name="sdcancel" value="Cancel" onClick="cancelSetDestination()" /></p>';
str += '</td><td id="sdmap">&nbsp;</td></tr></table></form>';
document.getElementById('fpage').innerHTML = str;
}
function drawMapControls() {
var str;
// Centre map on coords...
str = '<p>&nbsp;</p><table id="mapctr"><tr>';
str += '<td><input type="checkbox" name="mrem" id="mcrem" ' + (mapRemember ? 'checked="checked" ':'')
+ ' onclick="mapRemember = this.checked" /></td><td><label for="mcrem">Remember map location'
+ '</label></td></tr>';
str += '<td onClick="document.getElementById(\'mct0\').checked=true">';
str += '<input type="radio" name="mct" id="mct0" ' + (mapCType==0?'checked="checked" ':'') + ' /></td>';
str += '<td onClick="document.getElementById(\'mct0\').checked=true"><label for="mct0">Centre on coordinates</label></td></tr>';
str += '<tr><td>&nbsp;</td><td onClick="document.getElementById(\'mct0\').checked=true">';
str += '(<input type="text" name="cx" id="cx" value="'+dMapX+'" size="4" />,<input type="text" name="cy" id="cy"';
str += ' value="'+dMapY+'" size="4" />)</td></tr>';
// Centre map on own planet...
str += '<td onClick="document.getElementById(\'mct1\').checked=true">';
str += '<input type="radio" name="mct" id="mct1" ' + (mapCType==1?'checked="checked" ':'') + ' /></td>';
str += '<td onClick="document.getElementById(\'mct1\').checked=true"><label for="mct1">Centre on own/allied planet</label></td></tr>';
str += '<tr><td>&nbsp;</td><td onClick="document.getElementById(\'mct1\').checked=true">';
str += '<select name="mcpo" style="width:100%" id="mcpo"><option value="0">-----</option>';
var i, l = locations.keys(), mapList = [];
for (i = 0; i < l.length; i ++) {
var p = locations.get(l[i]);
if (!p.details || !p.details.owner) {
continue;
}
mapList.push(l[i]);
}
mapList.sort(sortMapPList);
for (i in mapList) {
var p = locations.get(mapList[i]);
str += '<option value="' + p.id + '"'
+ (mapCType == 1 && p.id == mapParm ? ' selected="selected"' : '') + '>' + p.name
+ (allies.get(p.details.owner).isMe ? '' : (' (' + players.get(p.details.owner) + ')'))
+ '</option>';
}
str += '</select></td></tr>';
// Centre map on planet...
str += '<td onClick="document.getElementById(\'mct2\').checked=true">';
str += '<input type="radio" name="mct" id="mct2" ' + (mapCType==2?'checked="checked" ':'') + ' /></td>';
str += '<td onClick="document.getElementById(\'mct2\').checked=true"><label for="mct2">Centre on planet</label></td></tr>';
str += '<tr><td>&nbsp;</td><td onClick="document.getElementById(\'mct2\').checked=true">';
str += '<input type="text" style="width:100%" name="pn" id="mcpn" value="' + (mapCType==2?mapParm:'') + '" /></td></tr>';
str += '</table><p class="mapbt"><input type="button" name="mcup" value="Move" onClick="updateGalacticMap()" /></p>';
return str;
}
function alertMap()
{
alert('Error: this planet was not found on the map');
}
function getTrajectoryText(id, t)
{
if (!t)
return "(loading)";
var f = fleets.get(id);
if (t.length == 0 && f.orders.oType != 1)
return "N/A";
var r, i, str = '<select name="tr' + id + '">';
if (f.orders.oType == 1)
{
r = f.orders.reroute + 10;
if (r > 61)
r = 61;
str += '<option>Rerouting: ' + r + ' minutes</option>';
}
else
r = 0;
for (i=0;i<t.length;i++)
{
var w = t[i];
str += '<option';
if (i == t.length - 1)
str += ' selected="selected">Arriving at';
else
str += '>Leaving';
var e = parseInt(w.eta,10) + r;
str += ' ' + w.name + ' ' + w.coords + ': ' + e + ' minutes</option>';
}
str += '</select>';
return str;
}
function drawFleetTrajectory()
{
var str, f = fleetTrajectory.fleet, o = allies.get(f.owner);
var used = f.ships[0] * o.gSpace + f.ships[1] * o.fSpace;
var haul = f.ships[2] * o.cHaul + f.ships[3] * o.bHaul;
var m = parseInt(f.mode, 10);
str = '<table><tr><td id="chord"><h1>View Fleet Trajectory ...</h1></td><td id="chordc">'
+ '<a href="#" onClick="prepareUpdate();x_getFleetsList(parseMainData);return false">'
+ 'Close</a></td></tr></table><h2>Selected Fleet</h2><table class="oavaf"><tr>' + foAvaHeader
+ '</tr><tr class="' + (f.owner == myself.id ? 'flown' : 'flally') + '"><td class="fown">'
+ players.get(f.owner) + '</td><td class="fname">' + f.name + '</td><td class="fhs">';
if (haul == 0)
str += 'N/A';
else
{
var hp = Math.round(used * 100 / haul);
str += (hp > 200) ? '&gt;200%' : (hp + '%');
}
var op = locations.get(fleetTrajectory.from);
str += '</td><td class="fshp">' + formatNumber(f.ships[0]) + ' / ' + formatNumber(f.ships[1]) + ' / '
+ formatNumber(f.ships[2]) + ' / ' + formatNumber(f.ships[3]) + '</td><td class="fpwr">'
+ formatNumber(f.power) + '</td><td class="fco">' + curOrdersTxt[m+4] + f.orders.to.name
+ curOrdersTxt[m+6] + '</td></tr></table><h2>Trajectory</h2><p>Fleet moving in '
+ (fleetTrajectory.hyperspace ? 'Hyperspace' : 'normal space') + '; original point of origin: '
+ '<a href="planet?id=' + op.id + '">' + op.name + '</a> (<b>' + op.x + ',' + op.y + '</b>,'
+ op.orbit + ')</p><table class="ftraj"><tr>'
+ '<th class="tname">Location</th><th class="ttype">Type</th><th class="tstat">'
+ 'Status</th></tr>';
var hc = false;
if (fleetTrajectory.changed > 0)
{
str += '<tr class="tcur"><td class="tname"><a href="planet?id=' + fleetTrajectory.waypoints[0].id
+ '">' + fleetTrajectory.waypoints[0].name + '</a> (<b>' + fleetTrajectory.waypoints[0].system
+ '</b>,' + fleetTrajectory.waypoints[0].orbit + ')</td><td class="ttype"><span class="ot'
+ fleetTrajectory.waypoints[0].opacity + '">'+ orbitTypes[fleetTrajectory.waypoints[0].opacity]
+ '</td><td class="tstat">Rerouting (' + fleetTrajectory.changed + ' minute'
+ (fleetTrajectory.changed > 1 ? 's' : '') + ')</td></tr>';
hc = true;
}
var i;
for (i=0;i<fleetTrajectory.waypoints.length;i++)
{
var wp = fleetTrajectory.waypoints[i];
str += '<tr';
if (!hc && wp.eta < fleetTrajectory.left)
{
str += ' class="tcur"';
hc = true;
}
str += '><td class="tname"><a href="planet?id=' + wp.id + '">' + wp.name + '</a> (<b>' + wp.system
+ '</b>,' + wp.orbit + ')</td><td class="ttype"><span class="ot' + wp.opacity + '">'
+ orbitTypes[wp.opacity] + '</td><td class="tstat">';
if (!hc)
{
var n = wp.eta - fleetTrajectory.left;
if (n > 0)
str += 'Left orbit ' + n + ' minute' + (n>1?'s':'') + ' ago';
else
str += 'Just left orbit';
}
else if (i < fleetTrajectory.waypoints.length - 1)
{
var n = fleetTrajectory.left + fleetTrajectory.changed - wp.eta;
str += 'Leaving orbit in ' + n + ' minute' + (n>1?'s':'');
}
else
{
var n = fleetTrajectory.left + fleetTrajectory.changed - wp.eta;
str += 'Reaching destination in ' + n + ' minute' + (n>1?'s':'');
}
str += '</td></tr>';
}
if (fleetTrajectory.wait != 0)
{
var wp = fleetTrajectory.waypoints[fleetTrajectory.waypoints.length - 1];
str += '<tr><td class="tname"><a href="planet?id=' + wp.id + '">' + wp.name + '</a> (<b>' + wp.system
+ '</b>,' + wp.orbit + ')</td><td class="ttype"><span class="ot' + wp.opacity + '">'
+ orbitTypes[wp.opacity] + '</td><td class="tstat">Standing by in Hyperspace for '
+ fleetTrajectory.wait + ' hour' + (fleetTrajectory.wait>1?'s':'') + '</td></tr>';
}
str += '</table>';
document.getElementById('fpage').innerHTML = str;
}
function drawSellLayout()
{
var str;
str = '<form onSubmit="return false" action="?"><table><tr><td id="chord">'
+ '<h1>Sell Fleets ...</h1></td><td id="chordc">&nbsp;</td></tr></table>'
+ '<div id="sflist">&nbsp;</div></form>';
document.getElementById('fpage').innerHTML = str;
}
function FleetSale_drawForm()
{with(this){
var str;
str = '<p>&nbsp;</p><h2>Orbitting ' + fleetLocation.name + ' (' + fleetLocation.x + ',' + fleetLocation.y + ',' + fleetLocation.orbit
+ ')</h2><h3>Selected Fleets</h3><table class="fslist"><tr><th class="fname">Fleet Name</th>'
+ '<th class="fshp">G.A. Ships</th><th class="fshp">Fighters</th><th class="fshp">Cruisers'
+ '</th><th class="fshp">Battle Cruisers</th><th class="fpwr">Power</th></tr>';
var tot = [0,0,0,0,0];
for (var i=0;i<fleets.length;i++)
{
str += '<tr><td class="fname">' + fleets[i].name + '</td>';
for (var j=0;j<4;j++)
{
str += '<td class="fshp">' + formatNumber(fleets[i].ships[j]) + '</td>';
tot[j] += parseInt(fleets[i].ships[j], 10);
}
str += '<td class="fpwr">' + formatNumber(fleets[i].power) + '</td></tr>';
tot[4] += parseInt(fleets[i].power, 10);
}
str += '<tr><th class="ftot">Total</th>';
for (i=0;i<5;i++)
str += '<td class="f' + (i==4 ? 'pwr' : 'shp') + '">' + formatNumber(tot[i].toString()) + '</td>';
var smc = ['','','',''];
smc[mode] = ' checked="checked"';
str += '</tr></table><h3>Sale details</h3><table cellspacing="0" cellpadding="0"><tr>'
+ '<td class="div20" rowspan="4">&nbsp;</td><td class="pc45"><input type="radio" name="s'
+ id + 'mode" id="s' + id + 'm0" value="0" onClick="sales.get(' + id + ').setMode(0);'
+ 'return true"'+smc[0]+' /> <label for="s' + id + 'm0">Gift</label></td><td class="pc15"><label for="s'
+ id + 'exp">Offer expires:</label></td><td class="pc30"><select name="s' + id + 'exp" id="s'
+ id + 'exp" onChange="sales.get(' + id + ').setExpire(this.options[this.selectedIndex].value)">';
var expTime = [0, 6, 12, 24, 48, 72, 96, 120],
expLabel = ['Never', '6 hours', '12 hours', '1 day', '2 days', '3 days', '4 days', '5 days'];
for (i=0;i<expTime.length;i++)
str += '<option value="'+expTime[i]+'">'+expLabel[i]+'</option>';
str += '</select></td><td class="div20" rowspan="4">&nbsp;</td></tr><tr><td class="pc45"><input type="radio" '
+ 'name="s'+ id + 'mode" id="s' + id + 'm1" value="1" onClick="sales.get(' + id + ').setMode(1);'
+ 'return true"'+smc[1]+' /> <label for="s' + id + 'm1">Direct Sale</label></td><td id="s' + id
+ 'tarl">&nbsp;</td><td id="s' + id + 'tar">&nbsp;</td></tr><tr><td class="pc45"><input type="radio" '
+ 'name="s'+ id + 'mode" id="s' + id + 'm2" value="2" onClick="sales.get(' + id + ').setMode(2);'
+ 'return true"'+smc[2]+' /> <label for="s' + id + 'm2">Public Sale</label></td><td id="s' + id
+ 'pril">&nbsp;</td><td id="s' + id + 'pri">&nbsp;</td></tr><tr><td class="pc45"><input type="radio" '
+ 'name="s'+ id + 'mode" id="s' + id + 'm3" value="3" onClick="sales.get(' + id + ').setMode(3);'
+ 'return true"'+smc[3]+' /> <label for="s' + id + 'm3">Auction Sale</label></td><td colspan="2">&nbsp;</td>'
+ '</tr></table>';
return str;
}}
function drawSellLinks(valid)
{
var str;
if (valid)
str = '<a href="#" onClick="confirmSale();return false">Confirm</a> - ';
else
str = '';
str += '<a href="#" onClick="cancelSale();return false">Cancel</a>';
document.getElementById('chordc').innerHTML = str;
}
function saleAlert(ec, id) {
var str;
if (ec == -1)
str = "Go away, kiddie.";
else if (ec == 4)
str = 'Error: some fleets were no longer available for sale; they have been\nremoved from the '
+ 'list. Please verify the updated fleet sale form.';
else if (ec == 5) {
str = 'Error: none of the previously selected fleets are available for sale.';
} else if (ec == 200) {
str = 'Error: you are not allowed to sell fleets while in vacation mode.';
} else if (ec == 201) {
str = 'Error: you are not allowed to sell fleets while under Peacekeeper protection.';
} else {
str = 'An error occured while handling the sale at ' + locations.get(id).name + ':\n';
switch (ec)
{
case 0:
str += 'The target player could not be found.';
break;
case 1:
str += 'The target player is in a different protection level.';
break;
case 2:
str += 'The price is invalid.';
break;
case 3:
str += 'Auction sales require an expiration date.';
break;
case 6:
str += 'You are trying to sell or give a fleet to yourself.';
break;
case 7:
str += 'The target player has not been in the game long enough to\naccept the offer.';
break;
}
}
alert(str);
}
function confirmCancelSale(pl)
{
return confirm('Are you sure you want to cancel the sale of th' + (pl?'ese fleets':'is fleet') + '?');
}
function drawSaleDetails(l, name)
{
var str, f = fleets.get(l[1]), o = allies.get(f.owner);
var used = f.ships[0] * o.gSpace + f.ships[1] * o.fSpace;
var haul = f.ships[2] * o.cHaul + f.ships[3] * o.bHaul;
var m = parseInt(f.mode, 10);
str = '<table><tr><td id="chord"><h1>Fleet Sale Details</h1></td><td id="chordc">'
+ '<a href="#" onClick="prepareUpdate();x_getFleetsList(parseMainData);return false">'
+ 'Close</a></td></tr></table><h2>Fleet</h2><table class="oavaf"><tr>' + foAvaHeader
+ '</tr><tr class="flown"><td class="fown">' + o.getName()
+ '</td><td class="fname">' + f.name + '</td><td class="fhs">'
if (haul == 0)
str += 'N/A';
else
{
var hp = Math.round(used * 100 / haul);
str += (hp > 200) ? '&gt;200%' : (hp + '%');
}
str += '</td><td class="fshp">' + formatNumber(f.ships[0]) + ' / ' + formatNumber(f.ships[1]) + ' / '
+ formatNumber(f.ships[2]) + ' / ' + formatNumber(f.ships[3]) + '</td><td class="fpwr">'
+ formatNumber(f.power) + '</td><td class="fco">'
+ (f.orders.oType == 3 ? 'On sale at ' : 'Waiting for transfer at ') + f.orders.loc.name
+ '</td></tr></table><h2>Sale details</h2><table class="sdet"><tr><th>Sale type:</th><td>';
var st;
switch (l[6])
{
case '0':
if (l[7] == '0')
{
str += 'Gift';
st = 0;
}
else
{
str += 'Direct offer';
st = 1;
}
str += '</td></tr><tr><th>To player:</th><td><a href="message?a=c&ct=0&id=' + l[4] + '">'
+ name + '</a></td></tr>';
if (st == 1)
str += '<tr><th>Price:</th><td>&euro;' + formatNumber(l[7]) + '</td></tr>';
str += '<tr><th>Expires:</th><td>' + (l[2] == "" ? 'Never' : formatDate(l[2])) + '</td></tr>';
break;
case '1':
str += 'Public offer</td></tr><tr><th>Price:</th><td>' + formatNumber(l[7]) + '</td></tr>'
+ '<tr><th>Expires:</th><td>' + (l[2] == "" ? 'Never' : formatDate(l[2])) + '</td></tr>';
st = 2;
break;
case '2':
str += 'Auction sale</td></tr><tr><th>Minimum bid:</th><td>' + formatNumber(l[7]) + '</td></tr>'
+ '<tr><th>Expires:</th><td>' + formatDate(l[2]) + '</td></tr>';
if (l[8] != '')
{
str += '<tr><th>Latest bid at:</th><td>' + formatDate(l[10]) + '</td></tr><tr><th>'
+ 'Bid:</th><td>&euro;' + formatNumber(l[8]) + '</td></tr>';
if (l[3] == "")
str += '<tr><th>Bid by:</th><td><a href="message?a=c&ct=0&id=' + l[9] + '">'
+ name + '</a></td></tr>';
}
st = 3;
break;
}
if (l[3] != "")
{
var tx = parseInt(l[5],10) + 1;
str += '<tr><th>Finalized:</th><td>' + formatDate(l[3]) + '</td></tr>';
if (st > 1)
str += '<tr><th>Sold to:</th><td><a href="message?a=c&ct=0&id=' + l[4] + '">'
+ name + '</a></td></tr>';
str += '<tr><th>Transfer time:</th><td>' + tx + ' hour' + (tx > 1 ? 's' : '') + '</td></tr>';
}
str += '</table>';
document.getElementById('fpage').innerHTML = str;
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,53 @@
function confirmDelete()
{
var i = countSelected();
if (i == 0)
{
alert('Please select the topic(s) you want to delete.');
return false;
}
return confirm('Please confirm you want to delete ' + (i > 1 ? ('these ' + i + ' topics') : 'this topic') + '.');
}
function confirmSticky()
{
var i = countSelected();
if (i == 0)
{
alert('Please select the topic(s) you want to switch to/from sticky.');
return false;
}
return confirm('Please confirm you want to switch ' + (i > 1 ? ('these ' + i + ' topics') : 'this topic') + ' to/from sticky.');
}
function confirmMove()
{
var i = countSelected();
if (i == 0)
{
alert('Please select the topic(s) you want to move.');
return false;
}
var e = document.getElementById('mdest');
if (e.options[e.selectedIndex].value == '')
{
alert('Please select the forum to which the topic'+(i>1?'s':'')+' must be moved.');
return false;
}
return confirm(
'Please confirm you want to move the selected topic' + (i>1?'s':'') + '\nto the "'
+ e.options[e.selectedIndex].text + '" forum.'
);
}
function confirmDTopic()
{
return confirm('Deleting this post will delete the whole topic. Please confirm.');
}
function confirmDPost()
{
return confirm('Please confirm you want to delete this post.');
}

View file

@ -0,0 +1,10 @@
function countSelected()
{
var n = 0, i = 0, e;
while (e = document.getElementById('msel' + i))
{
n += e.checked ? 1 : 0;
i++;
}
return n;
}

View file

@ -0,0 +1,79 @@
var uncharted = '(uncharted)';
var dirs = ['Up', 'Down', 'Left', 'Right'];
var hdNames = ['Coordinates', 'Planet', 'Tag', 'Opacity'];
var lcHeader = ['Protected', null, 'Target'];
var yesNo = ['Yes', 'No'];
function makeMapTooltips()
{
maptt = new Array();
if (ttDelay == 0)
{
for (i=0;i<31;i++)
maptt[i] = "";
return;
}
maptt[0] = tt_Dynamic("Use this drop down list to change the information displayed on the map");
maptt[1] = tt_Dynamic("Use this radio button to center the map on the typed in coordinates");
maptt[2] = tt_Dynamic("Use this text field to enter the horizontal coordinate you want the map to be centered on.");
maptt[3] = tt_Dynamic("use this text field to enter the vertical coordinate you want the map to be centered on.");
maptt[4] = tt_Dynamic("Use this drop down list to select the size of the grid in which the map is displayed.");
maptt[5] = tt_Dynamic("Use this radio button to center the map on chosen own planet");
maptt[6] = tt_Dynamic("Use this drop down list to select the planet you own to use to center the map");
maptt[7] = tt_Dynamic("Click here to update the display according to the provided parameters");
maptt[8] = tt_Dynamic("Use this radio button to center the map on chosen planet");
maptt[9] = tt_Dynamic("Use this text field to enter the name of a planet to search for; if it exists the map will be centered on the system in which it is located.");
maptt[10] = tt_Dynamic("Click this button to move the display towards positive vertical coordinates.");
maptt[11] = tt_Dynamic("Click this button to move the display towards negative horizontal coordinates.");
maptt[12] = tt_Dynamic("Click this button to move the display towards positive horizontal coordinates.");
maptt[13] = tt_Dynamic("Click this button to move the display towards negative vertical coordinates.");
maptt[20] = tt_Dynamic("Click here to order the list according to this field and switch between descending and ascending order");
maptt[30] = tt_Dynamic("Click here to go to the individual page of this planet");
}
function drawMapControls()
{
var str = '<form action="?" onSubmit="return false"><table class="mapctrl">';
var i;
str += '<tr><th>Display:</th><td><select name="mtype" ' + maptt[0] + 'onChange="setMode(options[selectedIndex].value)">';
var modes = ['planet map', 'alliance map', 'listing'];
for (i=0;i<modes.length;i++)
str += '<option value="'+i+'"'+(map.mode == i ? ' selected="selected"' : '')+'>'+modes[i]+'</option>';
str += '</td><th>Centre on</th><td onClick="centreMode=0;document.getElementById(\'cm0\').checked=true">';
str += '<input type="radio" ' + maptt[1] + ' name="cm" id="cm0" value="0" onClick="centreMode=0" /> ';
str += 'coordinates (<input type="text" ' + maptt[2] + 'name="cx" id="cx" value="'+map.cx+'" size="4" />,<input type="text" ' + maptt[3] + ' name="cy" id="cy"';
str += ' value="'+map.cy+'" size="4" />)</td><th colspan="4" id="mcttl">Map colors</th></tr>';
str += '<tr><th>Grid size:</th><td><select ' + maptt[4] + ' name="gsize" onChange="setSize(options[selectedIndex].value)">';
for (i=1;i<=7;i++)
str += '<option value="'+i+'"'+(map.size==i?' selected="selected"':'')+'>'+i+'x'+i+'</option>';
str += '</select></td><th>or</th><td onClick="centreMode=1;document.getElementById(\'cm1\').checked=true">';
str += '<input type="radio" ' + maptt[5] + ' name="cm" id="cm1" value="1" onClick="centreMode=1" '+(centreOnOwn!=0?' checked="checked"':'')+'/> ';
str += 'own planet <span id="plpl"><select name="plpl" ' + maptt[6] + ' onChange="centreOnOwn=options[selectedIndex].value">';
str += '<option value="0">-----</option>';
for (i=0;i<plPlanets.length;i++)
{
str += '<option value="'+plPlanets[i].id+'"'+(plPlanets[i].id==centreOnOwn?' selected="selected"':'')+'>';
str += plPlanets[i].name.replace(/&/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;') + '</option>';
}
str += '<td class="mcolors" id="neb1">Nebula 1</td><td class="mcolors" id="neb2">Nebula 2</td>';
str += '<td class="mcolors" id="neb3">Nebula 3</td><td class="mcolors" id="neb4">Nebula 4</td></tr>';
str += '<tr><td>&nbsp;</td><td><input ' + maptt[7] + ' type="button" onClick="manualUpdate();return false" name="mupd" value="Update Display" /></td>';
str += '<th>or</th><td onClick="centreMode=2;document.getElementById(\'cm2\').checked=true">';
str += '<input type="radio" ' + maptt[8] + ' name="cm" id="cm2" value="2" onClick="centreMode=2" '+(centreOnOwn==0?' checked="checked"':'')+'/> ';
str += 'planet <input type="text" ' + maptt[9] + ' name="cp" id="cp" value="'+centreOn.replace(/"/g, '&quot;')+'" size="16" maxlength="15" /></td>';
str += '</select></span></td><td class="mcolors" id="mcown">Own</td><td class="mcolors" id="mcally">Allied</td>';
str += '<td class="mcolors" id="mcother">Other</td>'
switch (gameType) {
case '0': str += '<td class="mcolors" style="background-color:#00274f">Protected</td>'; break;
case '1': str += '<td>&nbsp;</td>'; break;
case '2': str += '<td class="mcolors" style="background-color:#00274f">Target</td>'; break;
}
str += '</tr>';
str += '</table></form>';
document.getElementById('jsctrls').innerHTML = str;
}

View file

@ -0,0 +1,824 @@
var gameType;
var map;
var maptt;
var centreMode = 1;
var centreOnTxt;
var centreOnOwn;
var plPlanets;
var inUpdate = true;
//--------------------------------------------------------------------------------------
// PLANETS AND NEBULAS
//--------------------------------------------------------------------------------------
function Planet(system,id,name,status,relation,tag)
{
this.id = id;
this.name = name.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;');
this.status = status;
this.opacity = (status == "1") ? 1 : 0;
this.relation = relation;
this.tag = tag;
this.system = system;
this.drawName = Planet_drawName;
this.drawTag = Planet_drawTag;
}
function Planet_drawName()
{
var str = '<tr class="srow">';
if (this.opacity) {
str += '<td class="pimg"' + (this.system.protection ? ' style="background-color:#00274f"' : '')
+ '><img src="' + staticurl + '/beta5/pics/prem_s.png" alt="[P]" /></td><td class="prem"'
+ (this.system.protection ? ' style="background-color:#00274f"' : '') + '>';
} else {
str += '<td class="pimg"' + (this.system.protection ? ' style="background-color:#00274f"' : '')
+ '><img src="' + staticurl + '/beta5/pics/pl/s/' + this.id
+ '.png" alt="[P]" /></td><td class="planet'
+ (this.relation == 0 ? 'n' : (this.relation == 1 ? 'a' : 'o')) + '"'
+ (this.system.protection ? ' style="background-color:#00274f"' : '') + '>';
}
str += '<a href="planet?id='+this.id+'">' + this.name + '</a></td></tr>';
return str;
}
function Planet_drawTag()
{
var str = '<tr class="srow">';
if (this.opacity) {
str += '<td class="pimg"><img src="' + staticurl
+ '/beta5/pics/prem_s.png" alt="[P]" /></td><td class="prem">N/A</td></tr>';
} else {
str += '<td class="pimg"' + (this.system.protection ? ' style="background-color:#00274f"' : '')
+ '><img src="' + staticurl + '/beta5/pics/pl/s/' + this.id
+ '.png" alt="[P]" /></td><td class="planet'
+ (this.relation == 0 ? 'n' : (this.relation == 1 ? 'a' : 'o')) + '"'
+ (this.system.protection ? ' style="background-color:#00274f"' : '') + '>'
+ '[' + this.tag + ']</td></tr>';
}
return str;
}
function Nebula(id,opacity,name)
{
this.id = id;
this.name = name;
this.opacity = opacity;
this.drawName = Nebula_drawName;
this.drawTag = Nebula_drawTag;
}
function Nebula_drawName()
{
var str = '<tr class="srow"><td class="nebzone';
str += this.opacity + '"><a href="planet?id='+this.id+'">' + this.name + '</a></td></tr>';
return str;
}
function Nebula_drawTag()
{
var str = '<tr class="srow"><td class="nebzone';
str += this.opacity + '">N/A</td></tr>';
return str;
}
//--------------------------------------------------------------------------------------
// SYSTEMS AND UNCHARTED SPACE
//--------------------------------------------------------------------------------------
function System(id,x,y,md5,nebula,prot)
{
this.id = id;
this.x = parseInt(x, 10);
this.y = parseInt(y, 10);
this.md5 = md5;
this.nebula = nebula;
this.protection = (prot != '0');
this.planets = new Array();
this.update = Math.round((new Date().getTime()) / 1000);
this.drawPlanets = System_drawPlanets;
this.drawAlliances = System_drawAlliances;
}
function System_drawPlanets()
{
var str = '<table class="sys';
if (this.nebula > 0)
str += 'neb' + this.nebula;
else if (this.prot > 0)
str += 'prot';
str += '" cellspacing="0" cellpadding="0">';
var i;
for (i=0;i<this.planets.length;i++)
str += this.planets[i].drawName();
return str + '</table>';
}
function System_drawAlliances()
{
var str = '<table class="sys';
if (this.nebula > 0)
str += 'neb' + this.nebula;
else if (this.prot > 0)
str += 'prot';
str += '" cellspacing="0" cellpadding="0">';
var i;
for (i=0;i<this.planets.length;i++)
str += this.planets[i].drawTag();
return str + '</table>';
}
function Uncharted()
{
this.md5 = '-';
this.update = Math.round((new Date().getTime()) / 1000);
this.drawPlanets = Uncharted_getCode;
this.drawAlliances = Uncharted_getCode;
}
function Uncharted_getCode()
{
var i, str = '<table class="sysunch" cellspacing="0" cellpadding="0">';
for (i=0;i<6;i++)
str += '<tr class="srow"><td>'+uncharted+'</td></tr>';
return str + '</table>';
}
//--------------------------------------------------------------------------------------
// THE MAP
//--------------------------------------------------------------------------------------
function MapListItem(s,p,o)
{
this.system = s;
this.planet = p;
this.orbit = o;
}
function Map(mode)
{
this.systems = new Hashtable();
this.cx = false;
this.cy = false;
this.size = false;
this.refresh = '';
this.mode = mode;
this.list = new Array();
this.sortType = 1;
this.sortDir = false;
this.setParm = Map_setParm;
this.checkUpdates = Map_checkUpdates;
this.parse = Map_parse;
this.clearCache = Map_clearCache;
this.draw = Map_draw;
this.mapGridBegin = Map_gridBegin;
this.mapGridEnd = Map_gridEnd;
this.mapListBegin = Map_listBegin;
this.mapListEnd = Map_listEnd;
this.mapList = Map_list;
this.mapPlanets = Map_planets;
this.mapAlliances = Map_alliances;
}
function Map_setParm(cx,cy,size)
{
if (cx == this.cx && cy == this.cy && size == this.size)
return;
this.cx = cx;
this.cy = cy;
this.size = size;
var mod;
mod = this.size % 2;
this.minX = this.cx + (mod - this.size) / 2;
this.maxX = this.cx + (this.size + mod - 2) / 2;
this.minY = this.cy + (mod - this.size) / 2;
this.maxY = this.cy + (this.size + mod - 2) / 2;
this.checkUpdates();
}
function Map_checkUpdates()
{
var i,j,as = new Array(), str;
var now = Math.round((new Date().getTime()) / 1000);
for (i=this.minX;i<=this.maxX;i++) for (j=this.minY;j<=this.maxY;j++)
{
var str = i + ',' + j, s = this.systems.get(str);
if (!s)
as.push(str + ',');
else if (now - s.update > 60)
{
as.push(str + ',' + s.md5);
s.update = now;
}
}
this.refresh = as.join('#');
}
function Map_clearCache()
{
var i, s, lk = this.systems.keys(), nk = 0;
var now = Math.round((new Date().getTime()) / 1000);
var Mx=this.maxX+4,mx=this.minX-4, My=this.maxY+4,my=this.minY-4;
for (i=0;i<lk.length;i++)
{
s = this.systems.get(lk[i]);
if (!s || (s.x<=Mx&&s.x>=mx&&s.y<=My&&s.y>=my) || nk > 50 || now-s.update<300)
{
nk ++;
continue;
}
this.systems.remove(lk[i]);
}
}
function Map_parse(data)
{
var l = data.split('\n');
var st = 0, s, pdat, i;
var mod = '#';
while (l.length)
{
i = l.shift();
if (st == 0)
{
var a = i.split('#');
if (a[0] == '') {
s = new Uncharted();
} else {
s = new System(a[0], a[1], a[2], a[3], a[4], a[5]);
st = (a[4] > 0) ? 3 : 1;
}
this.systems.put(a[1] + "," + a[2], s);
mod += a[1] + "," + a[2] + '#';
} else if (st == 1) {
pdat = i.split('#');
st ++;
}
else if (st == 2)
{
s.planets.push(new Planet(s, pdat.shift(), i, pdat.shift(), pdat.shift(), pdat.join('#')));
st = (s.planets.length == 6) ? 0 : 1;
}
else if (st == 3)
{
pdat = i.split('#');
s.planets.push(new Nebula(pdat.shift(), pdat.shift(), pdat.join('#')));
if (s.planets.length == 6)
st = 0;
}
}
this.refresh = "";
}
function Map_draw()
{
var str;
switch (this.mode)
{
case 0: str = this.mapGridBegin() + this.mapPlanets() + this.mapGridEnd(); break;
case 1: str = this.mapGridBegin() + this.mapAlliances() + this.mapGridEnd(); break;
case 2: str = this.mapListBegin() + this.mapList() + this.mapListEnd(); break;
}
document.getElementById('jsmapint').innerHTML = str;
}
function Map_gridBegin()
{
var i, tmp = "<table class='map' id='msz" + this.size + "' cellspacing='0'>";
tmp += "<tr class='hd'><td class='idx'>&nbsp;</td><td class='idx'>-X</td>";
tmp += "<td colspan='"+this.size+"' class='arrow' onClick='moveUp()' " + maptt[10] + ">";
tmp += "<img src='"+staticurl+"/beta5/pics/up_"+color+".gif' alt='"+dirs[0]+"' /></a></td>";
tmp += "<td class='idx'>X</td><td class='idx'>&nbsp;</td></tr>";
tmp += "<tr class='hd'><td class='idx'>Y</td><td class='idx'></td>";
for (i=this.minX;i<=this.maxX;i++)
tmp += "<td class='mgrcol'>"+i+"</td>";
tmp += "<td class='idx'></td><td class='idx'>Y</td></tr>";
return tmp;
}
function Map_gridEnd()
{
var i, tmp = "<tr class='hd'><td class='idx'>-Y</td><td class='idx'>&nbsp;</td>";
for (i=this.minX;i<=this.maxX;i++)
tmp += "<td class='mgrcol'>"+i+"</td>";
tmp += "<td class='idx'>&nbsp;</td><td class='idx'>-Y</td></tr>";
tmp += "<tr class='hd'><td class='idx'>&nbsp;</td><td class='idx'>-X</td>";
tmp += "<td colspan='"+this.size+"' class='arrow' onClick='moveDown()' " + maptt[13] + ">";
tmp += "<img src='"+staticurl+"/beta5/pics/down_"+color+".gif' alt='"+dirs[1]+"' /></a></td><td class='idx'>X</td>";
tmp += "<td class='idx'>&nbsp;</td></tr>";
tmp += "</table>";
return tmp;
}
function Map_planets()
{
var j, i, str = '';
for (j=this.maxY;j>=this.minY;j--)
{
str += '<tr>';
if (j == this.maxY)
{
str += "<td rowspan='"+this.size+"' class='arrow' onClick='moveLeft()' " + maptt[11] + ">";
str += "<img src='"+staticurl+"/beta5/pics/left_"+color+".gif' alt='"+dirs[2]+"' /></td>";
}
str += "<td class='hd'>"+j+"</td>";
for (i=this.minX;i<=this.maxX;i++)
str += '<td class="system">' + this.systems.get(i+','+j).drawPlanets() + '</td>';
str += "<td class='hd'>"+j+"</td>";
if (j == this.maxY)
{
str += "<td rowspan='"+this.size+"' class='arrow' onClick='moveRight()' " + maptt[12] + ">";
str += "<img src='"+staticurl+"/beta5/pics/right_"+color+".gif' alt='"+dirs[3]+"' /></td>";
}
str += '</tr>';
}
return str;
}
function Map_alliances()
{
var j, i, str = '';
for (j=this.maxY;j>=this.minY;j--)
{
str += '<tr>';
if (j == this.maxY)
{
str += "<td rowspan='"+this.size+"' class='arrow' onClick='moveLeft()' " + maptt[11] + ">";
str += "<img src='"+staticurl+"/beta5/pics/left_"+color+".gif' alt='"+dirs[2]+"' /></td>";
}
str += "<td class='hd'>"+j+"</td>";
for (i=this.minX;i<=this.maxX;i++)
str += '<td class="system">' + this.systems.get(i+','+j).drawAlliances() + '</td>';
str += "<td class='hd'>"+j+"</td>";
if (j == this.maxY)
{
str += "<td rowspan='"+this.size+"' class='arrow' onClick='moveRight()' " + maptt[12] + ">";
str += "<img src='"+staticurl+"/beta5/pics/right_"+color+".gif' alt='"+dirs[3]+"' /></td>";
}
str += '</tr>';
}
return str;
}
function Map_listBegin()
{
var hdTypes = ['Coord','Name','Alliance','Opacity','Protected'];
var hdCols = ['', ' class="pname" colspan="2"', '', '', ''];
var i,j,o;
this.list = new Array();
for (i=this.minX;i<=this.maxX;i++) for (j=this.minY;j<=this.maxY;j++)
{
var s = this.systems.get(i+','+j);
if (!s || !s.planets)
continue;
for (k=0;k<6;k++)
this.list.push(new MapListItem(s,s.planets[k],k+1));
}
var smet = 'this.list.sort(spl_' + hdTypes[this.sortType] + '_' + (this.sortDir ? "desc" : "asc") + ')';
eval(smet);
var str = '<table class="list" cellspacing="0" cellpadding="0" id="plist"><tr>';
if (hdNames.length == 4 && gameType != 1) {
hdNames.push(lcHeader[gameType]);
}
for (i = 0; i < hdNames.length; i ++) {
str += '<th' + hdCols[i] + ' ' + maptt[20] + ' onClick="map.sortType=' + i
+ ';map.sortDir=!map.sortDir;map.draw()">';
if (this.sortType == i) {
str += '<b>';
}
str += hdNames[i];
if (this.sortType == i) {
str += '</b><img src="'+staticurl+'/beta5/pics/';
str += this.sortDir ? "up" : "down";
str += '_' + color + '.gif" alt="' + (this.sortDir ? dirs[0] : dirs[1]) + '" />';
}
str += '</th>';
}
str += '</tr>';
return str;
}
function Map_listEnd()
{
return '</table>';
}
function Map_list() {
var i, str = '';
for (i = 0; i < this.list.length; i ++) {
str += '<tr class="';
if (this.list[i].system.nebula != 0) {
str += 'nebzone' + this.list[i].planet.opacity + '"';
} else if (this.list[i].planet.opacity == 0) {
str += 'planet' + (this.list[i].planet.relation == 0 ? 'n'
: (this.list[i].planet.relation == 1 ? 'a' : 'o')) + '"';
} else {
str += 'prem"';
}
str += '><td>(<b>' + this.list[i].system.x + ',' + this.list[i].system.y + '</b>,';
str += this.list[i].orbit + ')</td>';
str += '<td';
if (this.list[i].system.nebula == 0) {
if (this.list[i].planet.opacity == 0) {
str += ' class="pimg"><img src="' + staticurl + '/beta5/pics/pl/s/'
+ this.list[i].planet.id + '.png" alt="[P]" /></td><td class="pname">';
} else {
str += ' class="pimg"><img src="' + staticurl
+ '/beta5/pics/prem_s.png" alt="[P]" /></td><td class="pname">';
}
} else {
str += ' class="pname" colspan="2">';
}
str += '<a href="planet?id=' + this.list[i].planet.id + '" ' + maptt[30] + ' >'
+ this.list[i].planet.name + '</a></td><td>';
if (this.list[i].system.nebula == 0) {
str += '[' + this.list[i].planet.tag + ']';
} else {
str += '-';
}
str += '</td><td>' + this.list[i].planet.opacity;
if (gameType != 1) {
str += '</td><td>' + (this.list[i].system.protection == 0 ? yesNo[1] : yesNo[0]);
}
str += '</td></tr>';
}
return str;
}
//--------------------------------------------------------------------------------------
// INITIALISATION AND GENERIC FUNCTIONS
//--------------------------------------------------------------------------------------
function PlayerPlanet(id, name)
{
this.id = id;
this.name = name;
}
function mapInit(data)
{
gameType = document.getElementById('gametype').innerHTML;
// Receiving: mode followed by x#y#is_id#id_or_name followed by (id#name)*
var l = data.split('\n');
var m = parseInt(l.shift(), 10);
var a = l.shift().split('#');
plPlanets = new Array();
while (l.length > 0)
{
var p = l.shift().split('#');
plPlanets.push(new PlayerPlanet(p.shift(), p.join('#')));
}
centreOn = (a[2] == 1) ? a[3] : "";
centreOnOwn = (a[2] == 0) ? a[3] : 0;
map = new Map(m);
map.setParm(parseInt(a[0],10),parseInt(a[1],10),5);
drawMapLayout();
x_updateData(map.refresh, mapDataReceived);
setTimeout('maintainMap()', 11000);
}
function drawMapLayout()
{
var str = "<tr><td style='width:95%' id='jsctrls'>&nbsp;</td><td style='width:5%;vertical-align:top'><a href='manual?p=maps'>Help</a></td></tr>"
+ "<tr><td colspan='2'><hr/></td></tr><tr><td colspan='2' id='jsmapint'>&nbsp;</td></tr>";
document.getElementById('jsmap').innerHTML = "<table cellspacing='0' cellpadding='0'>" + str + "</table>";
drawMapControls();
setTimeout('x_getPlayerPlanets(playerPlanetsReceived)', 300000);
}
function playerPlanetsReceived(data)
{
plPlanets = new Array();
if (data != "")
{
var l = data.split('\n');
while (l.length > 0)
{
var p = l.shift().split('#');
plPlanets.push(new PlayerPlanet(p.shift(), p.join('#')));
}
}
drawPlayerList();
setTimeout('x_getPlayerPlanets(playerPlanetsReceived)', 300000);
}
function mapDataReceived(data)
{
if (data != "")
map.parse(data);
map.draw();
inUpdate = false;
}
function maintainMap()
{
if (inUpdate)
{
setTimeout('maintainMap()', 500);
return;
}
inUpdate = true;
map.clearCache();
map.checkUpdates();
refreshMap();
setTimeout('maintainMap()', 11000);
}
function refreshMap()
{
if (map.refresh == '')
{
map.draw();
inUpdate = false;
}
else
x_updateData(map.refresh, mapDataReceived);
}
function resultReceived(data)
{
if (data == "ERR")
{
inUpdate = false;
return;
}
var a = data.split('#');
if (a[2] == 1)
{
centreOn = a[3];
centreMode = 2;
document.getElementById('cm2').checked = true;
document.getElementById('cp').value = centreOn;
}
else
{
centreOnOwn = a[3];
centreMode = 1;
document.getElementById('cm1').checked = true;
drawPlayerList();
}
document.getElementById('cx').value = a[0];
document.getElementById('cy').value = a[1];
map.setParm(parseInt(a[0],10),parseInt(a[1],10),map.size);
refreshMap();
}
function drawPlayerList()
{
var i, str = '<select name="plpl" onChange="centreOnOwn=options[selectedIndex].value">';
str += '<option value="0">-----</option>';
for (i=0;i<plPlanets.length;i++)
{
str += '<option value="'+plPlanets[i].id+'"'+(plPlanets[i].id==centreOnOwn?' selected="selected"':'')+'>';
str += plPlanets[i].name.replace(/&/g,'&amp;').replace(/>/g,'&gt;').replace(/</g,'&lt;') + '</option>';
}
str += '</select>';
document.getElementById('plpl').innerHTML = str;
}
//--------------------------------------------------------------------------------------
// CONTROLS
//--------------------------------------------------------------------------------------
function setSize(s)
{
if (inUpdate)
{
setTimeout('setSize('+s+')', 500);
return;
}
inUpdate = true;
map.setParm(map.cx,map.cy,parseInt(s,10));
refreshMap();
}
function setMode(m)
{
if (inUpdate)
{
setTimeout('setMode("'+m+'")', 500);
return;
}
inUpdate = true;
map.mode = parseInt(m,10);
map.draw();
inUpdate = false;
}
function moveUp()
{
if (inUpdate)
{
setTimeout('moveUp()', 50);
return;
}
inUpdate = true;
document.getElementById('cy').value = map.cy + 1;
document.getElementById('cm0').checked = true;
centreMode = 0;
map.setParm(map.cx, map.cy+1, map.size);
refreshMap();
}
function moveDown()
{
if (inUpdate)
{
setTimeout('moveDown()', 50);
return;
}
inUpdate = true;
document.getElementById('cy').value = map.cy - 1;
document.getElementById('cm0').checked = true;
centreMode = 0;
map.setParm(map.cx, map.cy-1, map.size);
refreshMap();
}
function moveLeft()
{
if (inUpdate)
{
setTimeout('moveLeft()', 50);
return;
}
inUpdate = true;
document.getElementById('cx').value = map.cx - 1;
document.getElementById('cm0').checked = true;
centreMode = 0;
map.setParm(map.cx-1, map.cy, map.size);
refreshMap();
}
function moveRight()
{
if (inUpdate)
{
setTimeout('moveRight()', 50);
return;
}
inUpdate = true;
document.getElementById('cx').value = map.cx + 1;
document.getElementById('cm0').checked = true;
centreMode = 0;
map.setParm(map.cx+1, map.cy, map.size);
refreshMap();
}
function manualUpdate()
{
if (inUpdate)
{
setTimeout('manualUpdate()', 500);
return;
}
inUpdate = true;
if (centreMode == 0)
{
var tx, nx, ty, ny;
tx = document.getElementById('cx').value; ty = document.getElementById('cy').value;
if (tx == '-0') tx = '0';
if (ty == '-0') ty = '0';
nx = parseInt(tx,10); ny = parseInt(ty,10);
if (tx != nx.toString() || ty != ny.toString())
{
inUpdate = false;
return;
}
map.setParm(nx, ny, map.size);
refreshMap();
}
else if (centreMode == 1)
{
var i;
for (i=0;i<plPlanets.length&&plPlanets[i].id!=centreOnOwn;i++) ;
if (i==plPlanets.length)
{
inUpdate = false;
return;
}
x_findName(plPlanets[i].name, resultReceived);
}
else if (centreMode == 2)
x_findName(document.getElementById('cp').value, resultReceived);
}
//--------------------------------------------------
// LIST SORTING
//--------------------------------------------------
function spl_Coord_asc(a,b)
{
var sup;
if (a.system.x!=b.system.x)
sup = (a.system.x>b.system.x);
else if (a.system.y!=b.system.y)
sup = (a.system.y>b.system.y);
else
sup = (a.orbit>b.orbit);
return sup?1:-1;
}
function spl_Coord_desc(a,b)
{
var sup;
if (a.system.x!=b.system.x)
sup = (a.system.x>b.system.x);
else if (a.system.y!=b.system.y)
sup = (a.system.y>b.system.y);
else
sup = (a.orbit>b.orbit);
return sup?-1:1;
}
function spl_Name_asc(a,b)
{
var ra = a.planet.name.toLowerCase(); var rb = b.planet.name.toLowerCase();
return (ra < rb) ? -1 : 1;
}
function spl_Name_desc(a,b)
{
var ra = a.planet.name.toLowerCase(); var rb = b.planet.name.toLowerCase();
return (ra > rb) ? -1 : 1;
}
function spl_Alliance_asc(a,b)
{
var ra, rb;
ra = (a.system.nebula == 0) ? a.planet.tag.toLowerCase() : "";
rb = (b.system.nebula == 0) ? b.planet.tag.toLowerCase() : "";
return (ra < rb) ? -1 : (ra > rb ? 1 : spl_Name_asc(a,b));
}
function spl_Alliance_desc(a,b)
{
var ra, rb;
ra = (a.system.nebula == 0) ? a.planet.tag.toLowerCase() : "";
rb = (b.system.nebula == 0) ? b.planet.tag.toLowerCase() : "";
return (ra < rb) ? 1 : (ra > rb ? -1 : spl_Name_desc(a,b));
}
function spl_Opacity_asc(a,b)
{
var ra = parseInt(a.planet.opacity, 10); var rb = parseInt(b.planet.opacity, 10);
return (ra < rb) ? -1 : ((ra > rb) ? 1 : spl_Coord_asc(a,b));
}
function spl_Opacity_desc(a,b)
{
var ra = parseInt(a.planet.opacity, 10); var rb = parseInt(b.planet.opacity, 10);
return (ra < rb) ? 1 : ((ra > rb) ? -1 : spl_Coord_desc(a,b));
}
function spl_Protected_asc(a,b) {
var ra = a.system.protection, rb = b.system.protection;
return (ra && !rb) ? -1 : ((rb && ! ra) ? 1 : spl_Coord_asc(a, b));
}
function spl_Protected_desc(a,b) {
var ra = a.system.protection, rb = b.system.protection;
return (ra && !rb) ? 1 : ((rb && ! ra) ? -1 : spl_Coord_desc(a, b));
}

View file

@ -0,0 +1,411 @@
var menuText = ['Public Offers','Direct Offers','Sent Offers'];
var searchText = ['Search for planet: ', 'Search for location: '];
var prhStatus = ['Cancelled', 'Transfer Cancelled', 'Accepted', 'Expired', 'Rejected'];
var soModes = ['Gift', 'Private Sale', 'Public Sale', 'Auction Sale'];
// Listing texts, defaults
var notFound = 'No items found.';
var listingText = ['Display %1% items / page', 'Page %1% / %2%'];
// Planet sales
var noPSales = '<p>There are no planets for sale in this area.</p>';
var noPSalesFound = 'No matching planets were found.';
var psListingText = ['Display %1% planets / page', 'Page %1% / %2%'];
var psHeaders = ['Planet', 'Coords.', 'Pop.', 'Turrets', 'Fact.', 'Fleets', 'Owner', 'Expiration', 'Price', 'Action'];
// Fleet sales
var noFSales = '<p>There are no fleets for sale in this area.</p>';
var noFSalesFound = 'No matching locations were found.';
var fsListingText = ['Display %1% planets / page', 'Page %1% / %2%'];
var fsHeaders = ['Location', 'Coords.', 'G.A.S.', 'Fgt.', 'Cru.', 'B.Cru.', 'Owner', 'Expiration', 'Price', 'Action']
// Pending private offers
var noPOffers = '<p>There are no offers pending our approval.</p>';
var noPOffersFound = '<b>No offers matching this location.</p>';
var proHeaders = ['Received', 'Sender', 'Price', 'Expiration', 'Details'];
// Private offers history
var noPHist = '<p>The history is empty.</p>';
var noPHistFound = '<b>No archived offers matching this location.</p>';
var prhHeaders = ['Received', 'Sender', 'Price', 'Last Change', 'Status', 'Details'];
// Pending sent offers
var noSOffers = '<p>We have not offered to sell or give anything recently.</p>';
var noSOffersFound = '<b>No offers matching this location.</p>';
var sopHeaders = ['Date', 'Offer Type', 'Price', 'Expiration', 'To Player', 'Details'];
// Private offers history
var noSHist = '<p>The history is empty.</p>';
var noSHistFound = '<b>No archived offers matching this location.</p>';
var sohHeaders = ['Last Change', 'Status', 'Sent', 'Offer Type', 'Price', 'To Player', 'Details'];
function drawPublicLayout()
{
var str = '<table cellspacing="0" cellpadding="0" id="pubmain"><tr>';
str += '<td><h1>Planets For Sale</h1><div id="plsale">&nbsp;</div>';
str += '<p>&nbsp;</p><h1>Fleets For Sale</h1><div id="flsale">&nbsp;</div></td>';
// Map table
str += '<td rowspan="5" class="pubmap"><table cellspacing="0" cellpadding="0" id="sysmap">';
str += '<tr><td>&nbsp;</td><td onClick="moveMapUp()" class="horz"><img src="'+staticurl;
str += '/beta5/pics/up_'+color+'.gif" alt="Up" /></td><td>&nbsp;</td></tr><tr>';
str += '<td onClick="moveMapLeft()" class="vert"><img src="'+staticurl+'/beta5/pics/left_';
str += color+'.gif" alt="Left" /></td><td id="mapcnt">&nbsp;</td><td onClick="moveMapRight()" class="vert">';
str += '<img src="'+staticurl+'/beta5/pics/right_'+color+'.gif" alt="Right" /></td></tr>';
str += '<tr><td>&nbsp;</td><td onClick="moveMapDown()" class="horz"><img src="'+staticurl;
str += '/beta5/pics/down_'+color+'.gif" alt="Down" /></td><td>&nbsp;</td></tr></table>';
// Centre map on coords...
str += '<p>&nbsp;</p><table id="mapctr"><tr>';
str += '<td onClick="document.getElementById(\'mct0\').checked=true">';
str += '<input type="radio" name="mct" id="mct0" ' + (mapCType==0?'checked="checked" ':'') + ' /></td>';
str += '<td onClick="document.getElementById(\'mct0\').checked=true"><label for="mct0">Centre on coordinates</label></td></tr>';
str += '<tr><td>&nbsp;</td><td onClick="document.getElementById(\'mct0\').checked=true">';
str += '(<input type="text" name="cx" id="cx" value="'+mapX+'" size="4" />,<input type="text" name="cy" id="cy"';
str += ' value="'+mapY+'" size="4" />)</td></tr>';
// Centre map on own planet...
str += '<td onClick="document.getElementById(\'mct1\').checked=true">';
str += '<input type="radio" name="mct" id="mct1" ' + (mapCType==1?'checked="checked" ':'') + ' /></td>';
str += '<td onClick="document.getElementById(\'mct1\').checked=true"><label for="mct1">Centre on own planet</label></td></tr>';
str += '<tr><td>&nbsp;</td><td onClick="document.getElementById(\'mct1\').checked=true">';
str += '<select name="mcpo" id="mcpo"><option value="0">-----</option>';
var i, l = myPlanets.keys();
for (i=0;i<l.length;i++)
{
str += '<option value="'+l[i]+'"'+(mapCType==1&&l[i]==mapParm?' selected="selected"':'')+'>';
str += myPlanets.get(l[i]) + '</option>';
}
str += '</select></td></tr>';
// Centre map on planet...
str += '<td onClick="document.getElementById(\'mct2\').checked=true">';
str += '<input type="radio" name="mct" id="mct2" ' + (mapCType==2?'checked="checked" ':'') + ' /></td>';
str += '<td onClick="document.getElementById(\'mct2\').checked=true"><label for="mct2">Centre on planet</label></td></tr>';
str += '<tr><td>&nbsp;</td><td onClick="document.getElementById(\'mct2\').checked=true">';
str += '<input type="text" name="pn" id="mcpn" value="' + (mapCType==2?mapParm:'') + '" /></td></tr>';
// Distance
str += '</table><center><br/>Distance: <select name="mcds" id="mcds">';
for (i=1;i<8;i++)
str += '<option value="'+i+'"'+(i==mapDist?' selected="selected"':'')+'>' + i + '</option>';
str += '</select><br/><br/><input type="button" name="mcup" value="Update Display" onClick="updatePublicDisplay()" /></center>';
str += '</td></tr></table>';
document.getElementById('mkppage').innerHTML = str;
// Draw listings
pfsListing.draw();
ffsListing.draw();
}
function drawPSFleets(v)
{
if (!v.fleet)
return "No fleet";
return "G: <b>" + v.fleet[1] + "</b>; F: <b>" + v.fleet[2] + "</b>; C: <b>" + v.fleet[3] + "</b>; B: <b>" + v.fleet[4] + "</b>";
}
function drawPSAction(v)
{
var s = sellers.get(v.seller);
if (s.isMe)
return '<a href="#" onClick="cancelPSale('+v.offer+');return false">Cancel Sale</a>';
else if (v.auction)
return '<a href="#" onClick="placePBid('+v.offer+');return false">Place Bid</a>';
return '<a href="#" onClick="buyPlanet('+v.offer+');return false">Buy</a>';
}
function drawFSAction(v)
{
var s = sellers.get(v.seller);
if (s.isMe)
return '<a href="#" onClick="cancelFSale('+v.offer+');return false">Cancel Sale</a>';
else if (v.auction)
return '<a href="#" onClick="placeFBid('+v.offer+');return false">Place Bid</a>';
return '<a href="#" onClick="buyFleet('+v.offer+');return false">Buy</a>';
}
function drawExpire(v)
{
if (v.expires == '')
return 'Never';
return formatDate(v.expires);
}
// Messages for planet sales
function confirmPCancel(p)
{
return confirm('You are about to cancel the public sale of planet ' + p.name + '.\nPlease confirm.');
}
function confirmBuyPlanet(p)
{
return confirm('Are you sure you want to buy planet ' + p.name + ' for\n' + formatNumber(p.price) + ' euros?');
}
function planetBought()
{
alert('Planet has been bought. Control will be transfered to you in 4h, unless\nthe transfer is canceled by the current owner or he loses the planet.');
}
function postPBuyError(err) {
if (err == '0') {
alert('Unable to buy the planet: the offer has expired.');
} else if (err == '1') {
alert('Unable to buy the planet: not enough cash.');
} else if (err == '200') {
alert('You can\'t use the marketplace while on vacation.');
} else if (err == '201') {
alert('You can\'t use the marketplace while under Peacekeeper protection.');
} else{
alert('Unable to buy the planet: unknown error.');
}
}
function confirmBidPlanet(p) {
return prompt('Please place your bid for planet ' + p.name + '.\nMinimum bid: ' + formatNumber(p.price) + ' euros.', (parseInt(p.price)+1).toString());
}
function pBidError(p) {
alert('Minimum bid for planet ' + p.name + ' is ' + formatNumber(p.price) + ' euros.\nYour bid must be higher than this.');
}
function postPBidError(d) {
if (d=='0') {
alert('Unable to place the bid: the offer has expired.');
startUpdate();
} else if (d=='1') {
alert('Unable to place the bid: not enough cash.');
startUpdate();
} else if (d == '200') {
alert('You can\'t use the marketplace while on vacation.');
startUpdate();
} else if (err == '201') {
alert('You can\'t use the marketplace while under Peacekeeper protection.');
startUpdate();
} else {
var a = d.split('#');
var p = getPlanetOffer(a[1]);
if (!p) {
alert('An unknown error has occured.');
startUpdate();
return;
}
alert('Unable to place the bid on planet ' + p.name + '\nSomeone has placed a new bid in the meantime.\nThe minimum price is now ' + formatNumber(a[2]));
p.price = a[2];
pfsListing.updateDisplay();
doPlacePBid(p.offer);
}
}
// Messages for fleet sales
function getFleetComposition(f)
{
var a = new Array();
if (f.fleet[0] > 0) a.push(f.fleet[0] + ' GA Ship' + (f.fleet[0] > 1 ? 's' : ''));
if (f.fleet[1] > 0) a.push(f.fleet[1] + ' Fighter' + (f.fleet[1] > 1 ? 's' : ''));
if (f.fleet[2] > 0) a.push(f.fleet[2] + ' Cruiser' + (f.fleet[2] > 1 ? 's' : ''));
if (f.fleet[3] > 0) a.push(f.fleet[3] + ' Battle Cruiser' + (f.fleet[3] > 1 ? 's' : ''));
return a.join(', ');
}
function confirmFCancel(f)
{
return confirm(
'You are about to cancel the public sale of the fleet located at ' + f.plName + '.\n'
+ 'Fleet composition: ' + getFleetComposition(f) + '.\nPlease confirm.'
);
}
function confirmBuyFleet(f)
{
return confirm(
'Are you sure you want to buy the fleet located at ' + f.plName + ' for\n' + formatNumber(f.price) + ' euros?\n'
+ 'Fleet composition: ' + getFleetComposition(f) + '.\n');
}
function fleetBought()
{
alert('The fleet has been bought. Control will be transfered to you in 4h, unless\nthe transfer is canceled by the current owner or the fleet is destroyed.');
}
function postFBuyError(err) {
if (err == '0') {
alert('Unable to buy the fleet: the offer has expired.');
} else if (err == '1') {
alert('Unable to buy the fleet: not enough cash.');
} else if (err == '200') {
alert('You can\'t use the marketplace while on vacation.');
} else if (err == '201') {
alert('You can\'t use the marketplace while under Peacekeeper protection.');
} else {
alert('Unable to buy the fleet: unknown error.');
}
}
function confirmBidFleet(f) {
return prompt(
'Please place your bid for the fleet located at ' + f.plName + '.\n'
+ 'Fleet composition: ' + getFleetComposition(f) + '.\n'
+ 'Minimum bid: ' + formatNumber(f.price) + ' euros.',
(parseInt(f.price,10) + 1).toString());
}
function fBidError(f) {
alert('Minimum bid for fleet at ' + f.plName + ' is ' + formatNumber(f.price) + ' euros.\nYour bid must be higher than this.');
}
function postFBidError(d) {
if (d=='0') {
alert('Unable to place the bid: the offer has expired.');
startUpdate();
} else if (d=='1') {
alert('Unable to place the bid: not enough cash.');
startUpdate();
} else if (d == '200') {
alert('You can\'t use the marketplace while on vacation.');
startUpdate();
} else if (err == '201') {
alert('You can\'t use the marketplace while under Peacekeeper protection.');
startUpdate();
} else {
var a = d.split('#');
var p = getFleetOffer(a[1]);
if (!p) {
alert('An unknown error has occured.');
startUpdate();
return;
}
alert('Unable to place the bid on fleet at ' + f.plName + '\nSomeone has placed a new bid in the meantime.\nThe minimum price is now ' + formatNumber(a[2]));
p.price = a[2];
ffsListing.updateDisplay();
doPlaceFBid(p.offer);
}
}
// Private offers
function drawPrivateLayout()
{
var str = '<h1>Pending Offers</h1><div id="prpending">&nbsp;</div><p>&nbsp;</p>';
str += '<h1>History</h1><div id="prhistory">&nbsp;</div>';
document.getElementById('mkppage').innerHTML = str;
// Draw listings
proListing.draw();
prhListing.draw();
}
function drawPRPrice(i)
{ return i.price != 0 ? ('&euro;' + formatNumber(i.price)) : 'Free'; }
function drawPRDetails(i)
{
var str = '';
var s, j, ts = ['G.A. Ship', 'Fighter', 'Cruiser', 'Battle Cruiser'], r = new Array();
if (i.planet[0] != '')
{
str = 'The planet <b>'+i.pName+'</b> at coordinates (<b>' + i.x + ',' + i.y + '</b>,' + i.orbit + '): ';
str += '<b>' + formatNumber(i.planet[1]) + 'M</b> inhabitants, <b>' + formatNumber(i.planet[2]) + '</b> turrets and <b>';
str += formatNumber(i.planet[3]) + '</b> factories';
if (i.fleet[0] != '')
{
str += ' along with a fleet of ';
for (j=0;j<4;j++)
{
if (i.fleet[1+j] == 0)
continue;
s = '<b>' + formatNumber(i.fleet[1+j]) + '</b> ' + ts[j];
if (i.fleet[1+j] > 1)
s += 's';
r.push(s);
}
s = r.pop();
str += r.join(', ') + (r.length > 0 ? ' and ' : '') + s;
}
str += '.';
}
else
{
str += 'A fleet of ';
for (j=0;j<4;j++)
{
if (i.fleet[1+j] == 0)
continue;
s = '<b>' + formatNumber(i.fleet[1+j]) + '</b> ' + ts[j];
if (i.fleet[1+j] > 1)
s += 's';
r.push(s);
}
s = r.pop();
str += r.join(', ') + (r.length > 0 ? ' and ' : '') + s;
str += ' located in orbit around <b>' + i.pName + '</b> (<b>' + i.x + ',' + i.y + '</b>,' + i.orbit + ').';
}
if (!i.aDate && i.buyer == null)
{
str += '<br/>[ <a href="#" onClick="acceptPrivate('+i.id+');return false">Accept offer</a> - ';
str += '<a href="#" onClick="declinePrivate('+i.id+');return false">Decline offer</a> ]';
}
else if (!i.aDate && i.buyer != null)
str += '<br/>[ <a href="#" onClick="cancelSale('+i.id+');return false">Cancel</a> ]';
return str;
}
function confirmBuyPrivate(p)
{
var str = 'Are you sure you want to accept this private offer?';
if (p.price > 0)
str += '\nIt will cost you ' + formatNumber(p.price) + ' euros.';
return confirm(str);
}
function confirmDeclinePrivate()
{
return confirm('Please confirm that you want to decline this offer.');
}
function privateError(err) {
if (err == '0') {
alert('Unable to accept the offer: it has expired.');
} else if (err == '1') {
alert('Unable to accept the offer: not enough cash.');
} else if (err == '200') {
alert('You can\'t use the marketplace while on vacation.');
} else if (err == '201') {
alert('You can\'t use the marketplace while under Peacekeeper protection.');
} else {
alert('Unable to accept the offer: unknown error.');
}
}
// Sent offers
function drawSentLayout()
{
var str = '<h1>Pending Offers</h1><div id="sopending">&nbsp;</div><p>&nbsp;</p>';
str += '<h1>History</h1><div id="sohistory">&nbsp;</div>';
document.getElementById('mkppage').innerHTML = str;
// Draw listings
sopListing.draw();
sohListing.draw();
}
function drawSentBuyer(v)
{
if (v.buyer == '')
return "None";
var s = sellers.get(v.buyer);
return (s.isMe||s.quit ? '' : ('<a href="message?a=c&ct=0&id='+v.buyer+'">')) + s.name + (s.isMe||s.quit ? '' : '</a>');
}
function confirmCancelSale()
{
return confirm('You are about to cancel an offer. Please confirm.');
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,377 @@
var colTitles = new Array('(S)', 'Subject', 'Date', 'From', 'To');
var msgNotFound = "Message body could not be found.";
var replyText = "Reply";
function makeMessagesTooltips()
{
msgtt = new Array();
if (ttDelay == 0)
{
var i;
for (i=0;i<86;i++)
msgtt[i] = "";
return;
}
msgtt[0] = tt_Dynamic("Click here to write a new message");
msgtt[1] = tt_Dynamic("Click here to go to the folder management page");
msgtt[2] = tt_Dynamic("Click here to view the contents of this folder");
msgtt[3] = tt_Dynamic("Click here to go to the forums' page");
msgtt[10] = tt_Dynamic("Select the type of recipient for this message");
msgtt[11] = tt_Dynamic("Specify here the name of the recipient of this message");
msgtt[12] = tt_Dynamic("Specify here the subject of this message");
msgtt[13] = tt_Dynamic("Specify here the body of this message");
msgtt[14] = tt_Dynamic("Click here to send this message");
msgtt[20] = tt_Dynamic("Select the number of messages to display on each page");
msgtt[21] = tt_Dynamic("Use this check box to switch between threaded / linear view");
msgtt[30] = tt_Dynamic("Select the page of messages to display");
msgtt[40] = tt_Dynamic("Click here to delete the selected message(s)");
msgtt[41] = tt_Dynamic("Click here to move the selected message(s) to the chosen folder");
msgtt[42] = tt_Dynamic("Select the folder to which you want to move the selected message(s)");
msgtt[50] = tt_Dynamic("Use this check box to select / unselect this folder");
msgtt[51] = tt_Dynamic("Click here to rename the selected folder");
msgtt[60] = tt_Dynamic("Click here to create a new folder");
msgtt[70] = tt_Dynamic("Click here to flush the contents of the selected folder(s)");
msgtt[71] = tt_Dynamic("Click here to delete the selected folder(s)");
msgtt[80] = tt_Dynamic("Use this check box to select / unselect all messages in this folder");
msgtt[81] = tt_Dynamic("Click here to sort the messages according to this field");
msgtt[82] = tt_Dynamic("Use this check box to select / unselect this message");
msgtt[83] = tt_Dynamic("Click here to display / hide the body of this message");
msgtt[84] = tt_Dynamic("Click here to send a message to this recipient");
msgtt[85] = tt_Dynamic("Click here to reply to this message");
}
function drawMainMenu()
{
var str = '<table cellspacing="0" cellpadding="0">';
str += '<tr><td colspan="2">&nbsp;</td></tr>';
str += '<tr><th colspan="2">Messages</th></tr>';
str += '<tr><td colspan="2">&nbsp;</td></tr>';
str += '<tr><td colspan="2">';
if (page == "Compose")
str += '<i>Compose a message</i>';
else
str += '<a href="#" onClick="composeNew(); return false"' + msgtt[0] + '>Compose a message</a>';
str += '</td></tr>';
str += '<tr><td colspan="2">';
if (page == "Folders")
str += '<i>Folders</i>';
else
str += '<a href="#" onClick="manageFolders(); return false"' + msgtt[1] + '>Folders</a>';
str += '</td></tr>';
var i, ic;
for (i=0;i<folders.length;i++)
{
ic = (page == "Browse" && vFolder == i);
str += '<tr>';
if (i==0)
str += '<td class="mmspc" rowspan="' + folders.length + '">&nbsp;</td>';
str += '<td>';
str += ic ? '<i>' : ('<a href="#" onClick="browseFolder(' + i + '); return false"' + msgtt[2] + ' >');
if (folders[i].nCount > 0)
str += "<b>"
if (folders[i].type == 'CUS')
str += folders[i].name;
else if (folders[i].type == 'IN')
str += 'Inbox';
else if (folders[i].type == 'INT')
str += 'Internal transmissions';
else
str += 'Sent messages';
if (folders[i].nCount > 0)
str += " (" + folders[i].nCount + ")</b>";
str += ic ? '</i>' : '</a>';
str += '</td></tr>';
}
str += '<tr><td colspan="2">&nbsp;</td></tr>';
str += '<tr><th colspan="2"><a href="forums"' + msgtt[3] + '>Forums</a></th></tr>';
str += '</table>';
document.getElementById('mmenu').innerHTML = str;
}
function drawComposePage()
{
var i, a = new Array('player', 'planet', 'alliance');
var str = '<h1>Compose a message</h1><form action="?">';
str += '<table cellspacing="1" cellpadding="1" class="mcomp">';
if (pCompose.sent)
str += '<tr><td colspan="2"><p><b>Your message has been sent</b></p></td></tr>';
else if (pCompose.errors[0] != 0)
{
str += '<tr><td>&nbsp;</td><td><b class="err">';
switch (pCompose.errors[0])
{
case 1: str += 'Please specify message recipient.'; break;
case 2: str += 'Recipient not found.'; break;
}
str += '</b></td></tr>';
}
str += '<tr><th>Message to:</th><td><select name="mt" id="mcmtype"' + msgtt[10] +' >';
for (i=0;i<a.length;i++)
{
str += '<option value="' + i + '"';
if (i == pCompose.tType)
str += ' selected="selected"';
str += '>' + a[i] + '</option>';
}
str += '</select><input type="text" name="tn" id="mcmto" size="45" value="'+pCompose.tText+'"' + msgtt[11] + ' /></td></tr>';
if (pCompose.errors[1] != 0)
{
str += '<tr><td>&nbsp;</td><td><b class="err">';
switch (pCompose.errors[1])
{
case 1: str += 'Please specify message subject.'; break;
case 2: str += 'Subject is too long (max. 64 characters).'; break;
}
str += '</b></td></tr>';
}
str += '<tr><th>Subject:</th><td><input type="text" name="ms" id="mcmsub" size="58" maxlength="64" value="'+pCompose.sText+'"' + msgtt[12] + ' /></td></tr>';
if (pCompose.errors[2] != 0)
{
str += '<tr><td>&nbsp;</td><td><b class="err">';
switch (pCompose.errors[2])
{
case 1: str += 'You are not allowed to send empty messages.'; break;
}
str += '</b></td></tr>';
}
str += '<tr><th>Message:</th><td><textarea name="mc" id="mcmsg" cols="56" rows="15" wrap="word"' + msgtt[13] + '></textarea></td></tr>';
str += '<tr><td>&nbsp;</td><td class="mbut"><input type="button" id="mcmsend" ';
str += 'value="Send message" onClick="sendMessage(); return false;"' + msgtt[14] + ' /></td></tr>';
str += '</table>';
if (pCompose.rId != -1)
str += '<h2>Replying to...</h2><p>' + pCompose.rText + '</p>';
str += '</form>';
document.getElementById('mbody').innerHTML = str;
}
function drawPageNotFound()
{
document.getElementById('mbody').innerHTML = '<h1>Folder not found</h1><p>The folder you are trying to browse cannot be found.</p>';
}
function drawFolderLayout()
{
var str = '<h1>"';
switch (folders[vFolder].type)
{
case "IN": str += "Inbox"; break;
case "INT": str += "Internal Transmissions"; break;
case "OUT": str += "Sent Messages"; break;
case "CUS": str += folders[vFolder].name; break;
}
str += '" Folder</h1><div id="fbrowser"><p>Loading browser...</p></div>';
document.getElementById('mbody').innerHTML = str;
}
function drawFolderControls(s)
{
var i, str = '<form action="?"><table cellspacing="0" cellpadding="0" class="fctrl">';
str += '<tr class="topctrl"><td id="mppcell">';
str += 'Messages per page: <select name="mpp" id="fcmpp" onChange="setMsgPerPage();"' + msgtt[20] + ' >';
for (i=1;i<6;i++)
{
str += '<option value="'+i+'"';
if (i*10 == s[0])
str += ' selected="selected"';
str += '>'+(i*10)+'</option>';
}
str += '</select></td>';
str += '<td><label><input type="checkbox" name="thr" id="fcthr" ' + msgtt[21] + ' onClick="switchThreaded();"';
if (s[3])
str += ' checked="checked"';
str += '/>Threaded view</label></td><td id="fcpage">&nbsp;</td></tr>';
str += '<tr><td id="msglist" colspan="3"><b class="msgmsg">Loading message list ...</b></td></tr>';
str += '<tr><td id="msgctrl" colspan="3">&nbsp;</td></tr>';
str += '</table></form>';
document.getElementById('fbrowser').innerHTML = str;
}
function drawEmptyFolder()
{
document.getElementById('fcpage').innerHTML = '&nbsp;';
document.getElementById('msgctrl').innerHTML = '&nbsp;';
document.getElementById('msglist').innerHTML = '<b class="msgmsg">There are no messages in this folder.</b>';
}
function drawPageSelector(npg, np)
{
var str, i;
if (npg == 1)
str = 'Page 1 / 1';
else
{
str = 'Page <select name="pgs" id="pgs" onChange="changePage();"' + msgtt[30] + '>';
for (i=0;i<npg;i++)
{
str += '<option value="' + i + '"';
if (np == i)
str += ' selected="selected"';
str += '>' + (i+1) + '</option>';
}
str += '</select> / ' + npg;
}
document.getElementById('fcpage').innerHTML = str;
}
function genMsgControls(cfolder)
{
var i, t, str = '<table cellspacing="0" cellpadding="0" class="msgctrl"><tr>';
str += '<th>With selected messages:</th>';
str += '<td><input type="button" id="msgdel" value="Delete"' + msgtt[40] + ' onClick="deleteSelected(); return false"/>';
str += ' or <input type="button" id="msgmv" value="move"' + msgtt[41] + ' onClick="moveSelected(); return false"/> to ';
str += '<select name="msgmvt" id="msgmvt"' + msgtt[42] + '><option value="">- select destination folder -</option>';
for (i=0;i<folders.length;i++)
{
if (i == vFolder)
continue;
t = folders[i].type + '#' + folders[i].id;
str += '<option value="' + t + '"';
if (cfolder == t)
str += ' selected="selected"';
str += '>';
if (folders[i].type == 'CUS')
str += folders[i].name;
else if (folders[i].type == 'IN')
str += 'Inbox';
else if (folders[i].type == 'INT')
str += 'Internal transmissions';
else
str += 'Sent messages';
str += '</option>';
}
str += '</select></td></tr></table>';
return str;
}
function moveError()
{
alert('Please select a destination folder');
}
function confirmDelete(nm)
{
var str = 'You are about to delete ' + nm + ' message' + (nm > 1 ? 's' : '') + '.\nAre you sure?';
return confirm(str);
}
function drawFoldersList()
{
var i, str = '<h1>Folders management</h1>';
str += '<form action="?"><table cellspacing="0" cellpadding="0">';
str += '<tr class="fldhdr"><td class="fldspc">&nbsp;</td><td class="fldspc">&nbsp;</td>';
str += '<th class="fldname">Folder name</th><th class="msgcnt">Messages</th>';
str += '<th class="msgcnt">(New)</th><td class="fldspc">&nbsp;</td></tr>';
str += '<tr class="fldlst"><td>&nbsp;</td><td colspan="4"><table cellspacing="0" cellpadding="0" class="list">';
for (i=0;i<folders.length;i++)
{
var fid = folders[i].type + '#' + folders[i].id;
str += '<tr><td class="fldspc"><input type="checkbox"' + msgtt[50] + 'name="selfld" value="'+i;
str += '" id="sfld'+i+'" onClick="switchFSel(\''+fid+'\');return true"';
if (folders[i].selected)
str += ' checked="checked"';
str += ' /></td><td class="fldname">';
switch (folders[i].type)
{
case "IN": str += "Inbox"; break;
case "INT": str += "Internal Transmissions"; break;
case "OUT": str += "Sent Messages"; break;
case "CUS": str += '<a href="#"' + msgtt[51] + ' onClick="renameFolder('+folders[i].id+'); return false">' + folders[i].name + '</a>'; break;
}
str += '</td><td class="msgcnt">' + folders[i].mCount;
str += '</td><td class="msgcnt">' + folders[i].nCount;
str += '</td></tr>';
}
str += '</table></td><td class="fldspc">&nbsp;</td></tr>';
str += '<tr><td>&nbsp;</td><td colspan="4"><table cellspacing="0" cellpadding="0"><tr>';
str += '<td id="addfld">&nbsp;</td>';
str += '<td id="chgfld">&nbsp;</td>';
str += '</tr></table></td><td>&nbsp;</td></tr>';
str += '</table></form>';
document.getElementById('mbody').innerHTML = str;
}
function drawAddFolder()
{
var e, str2, str = '<input type="button" name="adfldb" id="adfldb" value="Create"' + msgtt[60] + ' onClick="addFolder(); return false" />';
str += ' a new folder: <input type="text" name="adfldn" id="adfldn" value="" />';
e = document.getElementById('adfldn');
str2 = e ? e.value : "";
document.getElementById('addfld').innerHTML = str;
document.getElementById('adfldn').value = str2;
}
function drawSFControls(cnt, cd)
{
var str = '<input type="button" name="flfldb" id="flfldb" value="Flush"' + msgtt[70] + ' onClick="flushFolders(); return false" />';
if (cd)
str += ' or <input type="button" name="rmfldb" id="rmfldb" value="delete"' + msgtt[71] + ' onClick="deleteFolders(); return false" />';
str += ' selected folder' + (cnt > 1 ? 's' : '') + '.';
document.getElementById('chgfld').innerHTML = str;
}
function promptRename(an)
{
return prompt("Please enter the new name for this folder.\nOriginal name: " + an, an);
}
function alertFolderName(mid)
{
var str = 'Error\n';
switch (mid)
{
case 0: str += "Empty folder names are not allowed"; break;
case 1: str += "Folder name is too long (max. 32 characters)"; break;
}
alert(str);
}
function confirmFDelete(nf, nm)
{
var str = 'You are about to delete ' + nf + ' folder' + (nf > 1 ? 's' : '');
str += '.\nThis will result in the loss of ' + nm + ' message' + (nm > 1 ? 's' : '');
str += '.\nAre you sure ?';
return confirm(str);
}
function confirmFFlush(nf, nm)
{
var str = 'You are about to flush ' + nf + ' folder' + (nf > 1 ? 's' : '');
str += '.\nThis will result in the loss of ' + nm + ' message' + (nm > 1 ? 's' : '');
str += '.\nAre you sure ?';
return confirm(str);
}

View file

@ -0,0 +1,943 @@
var colTypes = new Array('st', 'sub', 'date', 'from', 'to');
var msgSortGetData = [
'(x.status == "N") ? 2 : ((x.status == "r") ? 1 : 0)',
'x.subject.toLowerCase()', 'x.moment',
'x.from.toLowerCase()', 'x.to.toLowerCase()'
];
var folders = new Array();
var fpBuilding = false;
var flUpdate;
var page;
var vFolder;
var pCompose;
var udFolder;
var udFList;
var msgtt;
function emptyCB(data) { }
function Folder(t, i, n, nc, mc)
{
this.type = t;
this.id = i;
this.name = n;
this.nCount = nc;
this.mCount = mc;
this.messages = new Array();
this.settings = new Array();
this.threadOrder = new Array();
this.selAll = false;
this.selected = false;
this.deleteMessage = Folder_deleteMessage;
this.prepareThreading = Folder_prepareThreading;
}
function Folder_deleteMessage(idm)
{with(this) {
var i;
for (i=0;i<messages.length&&messages[i].id!=idm;i++) ;
if (i==messages.length)
return;
if (messages[i].status == 'N')
nCount --;
messages.splice(i, 1);
}}
function Folder_prepareThreading()
{with(this){
var i, j, ir = new Array();
for (i=0;i<messages.length;i++)
{
messages[i].replies = new Array();
for (j=0;j<messages.length;j++)
if (j!=i && messages[j].replyTo == messages[i].id)
{
messages[i].replies.push(j);
ir[j] = i;
}
}
threadOrder = new Array();
for (i=0;i<messages.length;i++)
{
if (typeof ir[i] != "undefined")
continue;
threadedMessage(this, i, 0);
}
}}
function threadedMessage(fld, m, d)
{with(fld){
var i;
threadOrder.push(m);
messages[m].depth = d;
for (i=0;i<messages[m].replies.length;i++)
threadedMessage(fld, messages[m].replies[i], d+1);
}}
function Message(id, moment, status, sl, rl, repl, from, to, sub, rtid)
{
this.id = id;
this.moment = parseInt(moment, 10);
this.status = status;
this.slink = sl;
this.rlink = rl;
this.replink = repl;
this.from = from;
this.to = to;
this.subject = sub;
this.replyTo = rtid;
this.replies = new Array();
this.depth = 0;
this.message = "";
this.isopen = false;
this.selected = false;
}
function ComposeParameters(tt, tid, rid)
{
this.tType = tt; // Player/Planet/Alliance
this.tId = tid; // Target identifier
this.tText = ""; // Target text
this.sText = ""; // Subject
this.cText = ""; // Contents
this.rId = rid; // Reply to
this.rText = ""; // Reply text
this.errors = new Array(0, 0, 0);
this.sent = false;
this.ready = false;
this.check = checkComposeMessage;
}
function checkComposeMessage()
{with(this){
sent = false;
if (tText == "")
errors[0] = 1;
else
errors[0] = 0;
if (sText == "")
errors[1] = 1;
else if (sText.length > 64)
errors[1] = 2;
else
errors[1] = 0;
if (cText == "")
errors[2] = 1;
else
errors[2] = 0;
return (errors[0] == 0 && errors[1] == 0 && errors[2] == 0);
}}
function makeSortFunction(type,dir)
{
var str = 'function(a,b){var x,s1,s2,i,rv=0,l=msgSortGetData.length;'
+ 'for(i=0;i<l&&rv==0;i++){x=a;eval(\'' + (dir ? 's1' : 's2')
+ '=(\'+msgSortGetData[(i+'+type+')%l]+\')\');x=b;eval(\''
+ (dir ? 's2' : 's1')+'=(\'+msgSortGetData[(i+'+type+')%l]+\')\');'
+ 'rv=((s1<s2)?-1:((s1>s2)?1:0));}return rv;}';
return str;
}
function initMessages()
{
// Initialise sort functions
var i,j;
for (i=0;i<colTypes.length;i++)
{
eval('ms_' + colTypes[i] + '_asc = ' + makeSortFunction(i,true));
eval('ms_' + colTypes[i] + '_desc = ' + makeSortFunction(i,false));
}
var data = document.getElementById('jsmsgflist').innerHTML;
if (data.split('\n').length == 1)
{
// IE really sucks.
x_updateFolders(initializeFoldersIE);
return;
}
parseFolderList(data);
initializeLayout();
data = document.getElementById('jsmsginit').innerHTML.split('#');
page = data.shift();
eval('setParameters' + page + '(data)');
drawMainMenu();
}
function initializeFoldersIE(d1)
{
parseFolderList(d1);
initializeLayout();
var data = document.getElementById('jsmsginit').innerHTML.split('#');
page = data.shift();
eval('setParameters' + page + '(data)');
drawMainMenu();
}
function parseFolderList(data)
{
var lst = data.split('\n');
var l = lst.length, i, j;
var nFolders = new Array();
var init = (folders.length == 0);
var cft, cfi;
var afc = new Array();
if (!init && page == 'Browse')
{
cft = folders[vFolder].type;
cfi = folders[vFolder].id;
}
for (i=j=0;i<l;i+=2,j++)
{
var of, a;
a = lst[i].split('#');
nFolders[j] = new Folder(a[0], a[1], lst[i+1], a[2], a[3]);
of = findFolder(a[0], a[1]);
if (of == -1)
continue;
afc[j] = folders[of].nCount;
nFolders[j].settings = folders[of].settings;
nFolders[j].messages = folders[of].messages;
nFolders[j].selAll = folders[of].selAll;
nFolders[j].selected = folders[of].selected;
nFolders[j].threadOrder = folders[of].threadOrder;
}
folders = nFolders;
if (!init)
{
if (page == 'Browse')
{
idx = findFolder(cft, cfi);
if (idx == -1)
{
page = 'NotFound';
drawPageNotFound();
}
else
{
i = vFolder;
vFolder = idx;
if (afc[i] < folders[idx].nCount)
browseFolder(idx);
}
}
else if (page == "Folders")
buildFoldersList();
drawMainMenu();
}
flUpdate = (new Date()).getTime();
udFList = setTimeout('x_updateFolders(parseFolderList)', 15000);
}
function findFolder(t, id)
{
var i;
for (i=0;i<folders.length;i++)
if (folders[i].type == t && (t != 'CUS' || (t == 'CUS' && folders[i].id == id)))
return i;
return -1;
}
function initializeLayout() {
document.getElementById('jsmsg').innerHTML = '<table cellspacing="0" cellpadding="0"><tr><td class="mmenu" id="mmenu">&nbsp;</td><td id="mbody">&nbsp;</td>'
+ '<td style="width:5%"><a href="manual?p=messages">Help</a></td></tr></table>';
}
//--------------------
// COMPOSE MESSAGE
//--------------------
function composeNew()
{
page = "Compose";
setParametersCompose(new Array("","",""));
drawMainMenu();
}
function messageTo(t,n)
{
page = "Compose";
setParametersCompose(new Array(t.toString(),n.toString(),""));
drawMainMenu();
}
function composeReply(t,n,r)
{
page = "Compose";
setParametersCompose(new Array(t.toString(),n.toString(),r));
drawMainMenu();
}
function setParametersCompose(p)
{
var tt, tid, trp;
tt = p[0] ? p[0] : "p";
tid = p[1] ? p[1] : -1;
trp = p[2] ? p[2] : -1;
pCompose = new ComposeParameters(tt, tid, trp);
if (tid != -1)
{
x_getTargetName(tt, tid, targetNameReceived);
setTimeout('checkComposeReady()', 500);
}
else
{
pCompose.ready = true;
buildComposePage();
}
}
function targetNameReceived(data)
{
pCompose.tText = data;
if (pCompose.rId != -1)
x_getMessageText(pCompose.rId, gotOriginalMessage);
else
pCompose.ready = true;
}
function gotOriginalMessage(data)
{
var a = data.split('\n');
a.shift();
if (a[0].indexOf('Re:') == 0)
pCompose.sText = a.shift();
else
pCompose.sText = 'Re: ' + a.shift();
if (a.length > 0)
pCompose.rText = a.join('\n');
pCompose.ready = true;
}
function checkComposeReady()
{
if (pCompose.ready)
buildComposePage();
else
setTimeout('checkComposeReady()', 500);
}
function buildComposePage()
{
drawComposePage();
document.getElementById('mcmsg').value = pCompose.cText;
}
function composePageStatus(s)
{
var allids = new Array('mcmtype', 'mcmto', 'mcmsub', 'mcmsg', 'mcmsend');
var i;
for (i=0;i<allids.length;i++)
document.getElementById(allids[i]).disabled = !s;
}
function sendMessage()
{
composePageStatus(false);
pCompose.tType = document.getElementById('mcmtype').value;
pCompose.tText = document.getElementById('mcmto').value;
pCompose.sText = document.getElementById('mcmsub').value;
pCompose.cText = document.getElementById('mcmsg').value;
if (!pCompose.check())
{
buildComposePage();
composePageStatus(true);
}
else
x_sendMessage(pCompose.tType, pCompose.tText, pCompose.sText, pCompose.cText, pCompose.rId, messageSent);
}
function messageSent(data)
{
if (data == "OK")
{
pCompose.tType = 0;
pCompose.tText = pCompose.sText = pCompose.cText = "";
pCompose.tId = pCompose.rId = -1;
pCompose.sent = true;
}
else
{
var i, d = data.split('#');
for (i=0;i<d.length;i++)
pCompose.errors[i] = parseInt(d[i], 10);
}
buildComposePage();
composePageStatus(true);
}
//--------------------
// BROWSE FOLDER
//--------------------
function browseFolder(i)
{
clearTimeout(udFolder);
page = 'Browse';
vFolder = i;
buildFolderPage();
drawMainMenu();
}
function setParametersBrowse(p)
{
var idx;
if (p.length == 1 && p[0] != "-1")
idx = findFolder(p[0], 0);
else if (p.length == 1)
idx = -1;
else
idx = findFolder(p[0], p[1]);
if (idx == -1)
page = 'NotFound';
else
vFolder = idx;
buildFolderPage();
}
function setParametersNotFound(p)
{
drawPageNotFound();
}
function buildFolderPage()
{
fpBuilding = true;
if (page == 'NotFound')
{
drawPageNotFound();
return;
}
drawFolderLayout();
if (folders[vFolder].settings.length == 0)
{
folders[vFolder].settings[4] = 0;
x_getFolderSettings(folders[vFolder].type, folders[vFolder].id, settingsReceived);
}
else
{
drawFolderControls(folders[vFolder].settings);
getMessageList();
}
}
function settingsReceived(data)
{
if (data != "")
{
var a = data.split('\n');
var b = a[0].split('#');
folders[vFolder].settings[0] = parseInt(b[0], 10);
folders[vFolder].settings[1] = b[1];
folders[vFolder].settings[2] = (b[2] == "1");
folders[vFolder].settings[3] = (b[3] == "1");
drawFolderControls(folders[vFolder].settings);
getMessageList();
}
else
{
page = "NotFound";
drawPageNotFound();
}
}
function getMessageList()
{
if (page != 'Browse')
return;
with(folders[vFolder]){
var a = new Array(), i, l = messages.length;
for (i=0;i<l;i++)
a.push(messages[i].id);
x_getMessageList(type, id, a.join('#'), messageListReceived);
}
}
function messageListReceived(data)
{
var ml = data.split('\n');
var i = 0, l = ml.length;
while (data != "" && i<l)
{
var dl = ml[i].split('#');
if (dl[0] == '-')
folders[vFolder].deleteMessage(dl[1]);
else
{
dl.shift();
var m = new Message(dl[0], dl[1], dl[2], dl[3], dl[4], dl[5], ml[i+1], ml[i+2], ml[i+3], dl[6]);
m.selected = folders[vFolder].selAll;
folders[vFolder].messages.push(m);
i+=3;
}
i++;
}
if (i>0)
{
if (udFList)
clearTimeout(udFList);
x_updateFolders(parseFolderList);
}
if (i>0||fpBuilding)
{
fpBuilding = false;
buildMessageDisplay();
}
}
function buildMessageDisplay()
{with(folders[vFolder]){
var mcl = messages.length, mcm = mcl % settings[0];
if (mcl == 0)
{
drawEmptyFolder();
return;
}
var smet = 'messages.sort(ms_' + settings[1] + '_' + (settings[2] ? "asc" : "desc") + ')';
eval(smet);
if (settings[3])
prepareThreading();
var npg = (mcl - mcm) / settings[0] + (mcm > 0 ? 1 : 0);
if (settings[4] >= npg)
settings[4] = npg - 1;
drawPageSelector(npg, settings[4]);
drawListHeader();
drawList();
updateControls();
udFolder = setTimeout('getMessageList()', 30000);
}}
function drawListHeader()
{with(folders[vFolder]){
var i, str = '<table class="msghdr" cellspacing="0" cellpadding="0">';
str += '<tr><td class="msgview">&nbsp;</td>';
str += '<td class="msgview"><input type="checkbox"' + msgtt[80] + 'name="selall" id="mlsa" onClick="switchSelAll();return true"';
str += (selAll ? ' checked="checked"':'') + '/></td>';
for (i=0;i<colTypes.length;i++)
{
var t = colTypes[i];
str += '<th class="mct'+t+'" onClick="switchSort(\''+t+'\');"' + msgtt[81] + '>';
if (settings[1] == t)
str += '<b>';
str += colTitles[i];
if (settings[1] == t)
{
str += '</b><img src="'+staticurl+'/beta5/pics/';
str += settings[2] ? "down" : "up";
str += '_' + color + '.gif" alt="' + (settings[2] ? "down" : "up");
str += '" />';
}
str += '</th>';
}
str += '<td class="msgview">&nbsp;</td></tr><tr><td id="msglist2" colspan="' + (colTypes.length+3);
str += '">&nbsp;</td></tr></table>';
document.getElementById('msglist').innerHTML = str;
}}
function drawList()
{with(folders[vFolder]){
var i, j, m, str = '<table class="list" cellspacing="0" cellpadding="0">';
var crc = false;
m = settings[4]*settings[0];
for (j=m;j<m+settings[0]&&j<messages.length;j++)
{
i = settings[3] ? threadOrder[j] : j;
var oct = ' onClick="switchOpen('+i+')"';
str += '<tr><td><table cellspacing="0" cellpadding="0">';
str += '<tr><td class="msgview">&nbsp;</td>';
str += '<td class="msgview"><input type="checkbox" name="msg" ' + msgtt[82] + 'id="msgck'+i+'" value="';
str += messages[i].id + '" onClick="switchSelection('+i+');"';
str += (messages[i].selected ? ' checked="checked"' : '');
str += '/></td><td class="mctst"'+oct+'><img src="'+staticurl+'/beta5/pics/msg';
str += (messages[i].status == 'N' ? 'u' : (messages[i].status == 'r' ? 'r' : 'rep'));
str += '.gif" alt="' + messages[i].status + '" /></td>';
str += '<td class="mctsub"'+oct+'>';
if (settings[3])
{
var k;
for (k=0;k<messages[i].depth;k++)
str += '-&nbsp;';
}
if (messages[i].status == 'N')
str += '<b>';
str += '<u' + msgtt[83] + '>'+messages[i].subject+'</u>';
if (messages[i].status == 'N')
str += '</b>';
str += '</td>';
str += '<td class="mctdate"'+oct+'>' + formatDate(messages[i].moment) + '</td>';
str += '<td class="mctfrom">';
if (messages[i].slink != "")
str += '<a href="#"' + msgtt[84] + ' onClick="messageTo('+messages[i].slink+');return false">';
str += messages[i].from;
if (messages[i].slink != "")
str += '</a>';
str += '</td>';
str += '<td class="mctto">';
if (messages[i].rlink != "")
str += '<a href="#"' + msgtt[84] + 'onClick="messageTo(' + messages[i].rlink + ');return false">';
str += messages[i].to;
if (messages[i].rlink != "")
str += '</a>';
str += '</td>';
str += '<td class="msgview">&nbsp;</td></tr>';
if (messages[i].isopen && messages[i].message != "")
{
if (messages[i].status == 'N')
{
messages[i].status = 'r';
nCount--;
crc = true;
}
str += '<tr><td colspan="3">&nbsp;</td><td class="mbody" colspan="4"><p>';
str += messages[i].message + '</p>';
if (messages[i].replink)
{
str += '<a class="rlink" href="#"' + msgtt[85] + 'onClick="composeReply(' + messages[i].replink + ');return false">[ ';
str += replyText + ' ]</a>';
}
str += '</td><td>&nbsp;</td></tr>';
}
str += '</table></td></tr>';
}
str += '</table>';
document.getElementById('msglist2').innerHTML = str;
if (crc)
{
drawMainMenu();
updateHeader();
}
}}
function switchSort(t)
{with(folders[vFolder]){
if (settings[1] != t)
settings[1] = t;
settings[2] = !settings[2];
x_setSortParameters(type, id, settings[1], settings[2] ? "1" : "0", emptyCB);
buildMessageDisplay();
}}
function setMsgPerPage()
{with(folders[vFolder]){
var sel = document.getElementById('fcmpp'), si = sel.selectedIndex;
settings[0] = parseInt(sel.options[si].value, 10) * 10;
x_setMessagesPerPage(type, id, sel.options[si].value, emptyCB);
buildMessageDisplay();
}}
function switchThreaded()
{with(folders[vFolder]){
settings[3] = !settings[3];
x_switchThreaded(type, id, emptyCB);
buildMessageDisplay();
}}
function changePage()
{with(folders[vFolder]){
var sel = document.getElementById('pgs'), si = sel.selectedIndex;
settings[4] = parseInt(sel.options[si].value, 10);
buildMessageDisplay();
}}
function switchOpen(i)
{with(folders[vFolder]){
messages[i].isopen = !messages[i].isopen;
if (messages[i].isopen && messages[i].message == "")
x_getMessageText(messages[i].id, gotMessageText);
else
drawList();
}}
function gotMessageText(data)
{
var i, a = data.split('\n');
var mId = a[0].split('#');
if (mId.length == 1)
return;
idx = findFolder(mId[0], mId[1]);
if (idx == -1)
return;
with (folders[idx])
{
for (i=0;i<messages.length&&messages[i].id!=mId[2];i++)
;
if (i == messages.length)
return;
if (a.length > 2)
{
a.shift();
a.shift();
messages[i].message = a.join('\n');
}
else
messages[i].message = msgNotFound;
}
drawList();
}
function switchSelection(idx)
{with(folders[vFolder]){
messages[idx].selected = !messages[idx].selected;
if (!messages[idx].selected && selAll)
{
selAll = false;
document.getElementById('mlsa').checked = false;
}
updateControls();
}}
function switchSelAll()
{with(folders[vFolder]){
var i,j=settings[0]*settings[4];
selAll = !selAll;
for (i=0;i<messages.length;i++)
messages[i].selected = selAll;
for (i=j;i<j+settings[0];i++)
{
var idx = settings[3] ? threadOrder[i] : i;
var e = document.getElementById('msgck' + idx);
if (!e)
break;
e.checked = selAll;
}
updateControls();
}}
function getPageSelection()
{with(folders[vFolder]){
var a = new Array();
var i, j = settings[0], k = j*settings[4];
for (i=k;i<j+k&&i<messages.length;i++)
if (messages[i].selected)
a.push(messages[i].id);
return a;
}}
function updateControls()
{
var str;
var s = getPageSelection();
if (s.length == 0)
str = '&nbsp;';
else
{
var i = document.getElementById('msgmvt');
if (i)
str = genMsgControls(i.options[i.selectedIndex].value);
else
str = genMsgControls('');
}
document.getElementById('msgctrl').innerHTML = str;
}
function deleteSelected()
{with(folders[vFolder]){
var a = getPageSelection(), b = new Array();
var i;
if (!confirmDelete(a.length))
return;
for (i=0;i<messages.length;i++)
b.push(messages[i].id);
clearTimeout(udFolder);
x_deleteMessages(type, id, a.join('#'), b.join('#'), messageListReceived);
}}
function moveSelected()
{with(folders[vFolder]){
var a = getPageSelection(), b = new Array();
var i, j, k;
i = document.getElementById('msgmvt');
j = i.selectedIndex;
k = i.options[j].value;
if (k == "")
{
moveError();
return;
}
c = k.split('#');
if (!c[1])
c[1] = 0;
for (i=0;i<messages.length;i++)
b.push(messages[i].id);
clearTimeout(udFolder);
x_moveMessages(type, id, c[0], c[1], a.join('#'), b.join('#'), messageListReceived);
}}
//--------------------
// FOLDER MANAGER
//--------------------
function manageFolders()
{
page = "Folders";
buildFoldersList();
drawMainMenu();
}
function setParametersFolders(p)
{
buildFoldersList();
}
function buildFoldersList()
{
drawFoldersList();
updateFControls();
updateHeader();
}
function switchFSel(fid)
{
var a = fid.split('#');
if (a[0] != "CUS")
a[1] = 0;
var i = findFolder(a[0], a[1]);
if (i == -1)
return;
folders[i].selected = !folders[i].selected;
updateFControls();
}
function updateFControls()
{
var str, fs, cd, i;
if (folders.length < 18)
drawAddFolder();
else
document.getElementById('addfld').innerHTML = '&nbsp;';
fs = 0;
cd = true;
for (i=0;i<folders.length;i++)
{
if (!folders[i].selected)
continue;
fs++;
cd = cd && (folders[i].type == 'CUS');
}
if (fs > 0)
drawSFControls(fs, cd);
else
document.getElementById('chgfld').innerHTML = '&nbsp;';
}
function renameFolder(fid)
{
var i = findFolder("CUS", fid);
if (i == -1)
return;
var nn = "";
while (nn == "")
{
nn = promptRename(folders[i].name);
if (typeof nn == 'object' && !nn)
return;
if (nn == "")
alertFolderName(0);
else if (nn.length > 32)
{
alertFolderName(1);
nn = "";
}
}
if (udFList)
clearTimeout(udFList);
x_renameFolder(fid, nn, parseFolderList);
}
function addFolder()
{
var n = document.getElementById('adfldn').value;
if (n == "")
{
alertFolderName(0);
return;
}
else if (n.length > 32)
{
alertFolderName(1);
return;
}
if (udFList)
clearTimeout(udFList);
x_addFolder(n, parseFolderList);
}
function deleteFolders()
{
var i, a = new Array(), tm = 0;
for (i=0;i<folders.length;i++)
{
if (folders[i].selected)
{
a.push(folders[i].id);
tm += parseInt(folders[i].mCount, 10);
}
}
if (tm > 0 && !confirmFDelete(a.length, tm))
return;
x_deleteFolders(a.join('#'), parseFolderList);
}
function flushFolders()
{
var i, a = new Array(), tm = 0;
for (i=0;i<folders.length;i++)
{
if (folders[i].selected)
{
a.push(folders[i].type + '!' + folders[i].id);
tm += parseInt(folders[i].mCount, 10);
}
}
if (tm == 0 || !confirmFFlush(a.length, tm))
return;
x_flushFolders(a.join('#'), parseFolderList);
}

View file

@ -0,0 +1,161 @@
function makeMoneyTooltips()
{
montt = new Array();
if (ttDelay == 0)
{
var i;
for (i=0;i<5;i++)
montt[i] = "";
return;
}
montt[0] = tt_Dynamic("Use this text field to type in the amount of cash you want to transfer");
montt[1] = tt_Dynamic("Use this text field to type in the name of the player you want to transfer cash to");
montt[2] = tt_Dynamic("Click here to perform the cash tranfer");
montt[3] = tt_Dynamic("Click here to go to this planet's individual page");
montt[4] = tt_Dynamic("Click here to go to this fleet's individual page");
}
function drawTransferVacation()
{
return '<p>It is impossible to transfer funds while on vacation mode.</p>';
}
function drawTransferWait(days)
{
return '<p>You need to wait another <b>' + days + ' day' + (days > 1 ? 's' : '')
+ '</b> before being able to transfer funds.</p>';
}
function drawTransferForm()
{
var str = '<form action="?"><p>';
str += 'Transfer &euro;<input type="text" name="tamt" id="tamt" value="" size="9" ' + montt[0] + ' /> ';
str += 'to player <input type="text" name="tdst" id="tdst" value="" size="16" maxlength="15" ' + montt[1] + ' />';
str += '<input type="button" name="tgo" id="tgo" value="Ok" onClick="transferFunds(); return false;" ' + montt[2] + ' /> ';
str += '</p></form>';
return str;
}
function drawPlanetTableHdr()
{
var str = '<table id="lstpl" class="list" cellspacing="0" cellpadding="0">';
str += '<tr>';
str += '<th class="picon"></th>';
str += '<th class="pname">Planet</th>';
str += '<th>Base income</th>';
str += '<th>Industrial Factories</th>';
str += '<th>Factory Income</th>';
str += '<th>Factory Upkeep</th>';
str += '<th>Turret Upkeep</th>';
str += '<th>Expense</th>';
str += '<th>Corruption Cost</th>';
str += '<th>Profit</th>';
str += '</tr>';
return str;
}
function drawPlanetTableFtr(n)
{
var str = '<tr>';
str += '<th colspan="9" class="tdi">Total Daily Income:</th>';
str += '<th class="tdi">&euro;' + formatNumber(n) + '</th>';
str += '</tr></table>';
return str;
}
function drawFleetTableHdr()
{
var str = '<table id="lstfl" class="list" cellspacing="0" cellpadding="0">';
str += '<tr>';
str += '<th>Name</th>';
str += '<th>Location</th>';
str += '<th class="dist">Distance</th>';
str += '<th class="dist">Delay</th>';
str += '<th class="upkp">Upkeep</th>';
str += '</tr>';
return str;
}
function drawFleetTableFtr(n)
{
var str = '<tr>';
str += '<th colspan="4" class="tfu">Total Fleet Upkeep:</th>';
str += '<th class="tfu">&euro;' + formatNumber(n) + '</th>';
str += '</tr></table>';
return str;
}
function drawNoPlanets()
{
return "<p>You do not own any planet.</p>";
}
function drawNoFleets()
{
return "<p>You do not own any fleet.</p>";
}
function tfError(en)
{
var str;
switch (en)
{
case 1:
str = 'You must indicate the amount to transfer.';
break;
case 2:
str = 'You must indicate a player to transfer funds to.';
break;
case 3:
str = 'The target player wasn\'t found. Please check the name.';
break;
case 4:
str = 'You cannot transfer funds to yourself.';
break;
case 5:
str = 'The target player cannot receive money yet.';
break;
case 6:
str = 'You cheat! We already told you you can\'t transfer funds!';
break;
case 7:
str = 'You can\'t transfer funds while under Peacekeeper protection.';
break;
case 8:
str = 'This player is under Peacekeeper protection.';
break;
case 9:
str = 'You don\'t have that much money.';
break;
case 10:
str = 'This player is on vacation.';
break;
default:
str = 'An unkown error has occured: ' + en;
break;
}
alert('Funds Transfer: error\n\n' + str);
}
function confirmTransfer(am, pl)
{
return confirm('Funds Transfer: please confirm\n\nYou are about to transfer '+formatNumber(am.toString())+' euro'+(am>1?'s':'')+'\nto player ' + pl);
}
function showTransferOk()
{
alert('Funds have been transfered.');
}

View file

@ -0,0 +1,133 @@
var cfUpdate;
var montt;
function displayCash(data)
{
document.getElementById("cfunds").innerHTML = '&euro;' + formatNumber(data);
cfUpdate = setTimeout('x_getCash(displayCash);', 15000);
}
function displayPage(data) {
var a = data.split("\n");
var b = a[0].split('#');
var str, i, c = '', d = '';
if (b[0] == "0" && b[1] == "0") {
if (document.getElementById('tgo')) {
c = document.getElementById('tamt').value;
d = document.getElementById('tdst').value;
}
str = drawTransferForm();
} else if (b[0] != "0") {
str = drawTransferWait(b[0]);
} else if (b[1] != "0") {
str = drawTransferVacation();
}
document.getElementById('transfer').innerHTML = str;
if (b[0] == "0" && b[1] == "0") {
document.getElementById('tamt').value = c;
document.getElementById('tdst').value = d;
}
var pcnt = parseInt(b[2],10), fcnt = parseInt(b[3], 10);
document.getElementById('pinc').innerHTML = '&euro;' + formatNumber(b[4]);
document.getElementById('fupk').innerHTML = '&euro;' + formatNumber(b[5]);
document.getElementById('dprof').innerHTML = formatNumber(b[6]);
if (pcnt > 0)
{
str = drawPlanetTableHdr();
for (i=0;i<pcnt;i++)
{
var name = a[1+i*2];
var pdat = a[(i+1)*2].split('#');
var tmp = parseInt(pdat[4], 10) + parseInt(pdat[5], 10);
str += '<tr><td class="picon"><img class="picon" src="'+staticurl
+ '/beta5/pics/pl/s/' + pdat[0] + '.png" alt="[P-' + pdat[0] + '" border="0" />'
+ '</td><td class="pname"><a ' + montt[3] + ' href="planet?id=' + pdat[0] + '">' + name
+ '</a></td><td>&euro;' + formatNumber(pdat[2]) + '</td><td>' + formatNumber(pdat[7])
+ '</td><td>&euro;' + formatNumber(pdat[3]) + '</td><td>&euro;' + formatNumber(pdat[4])
+ '</td><td>&euro;' + formatNumber(pdat[5]) + '</td><td>&euro;'
+ formatNumber(tmp.toString()) + '</td><td>&euro;' + formatNumber(pdat[6])
+ '</td><td>&euro;' + formatNumber(pdat[1]) + '</td></tr>';
}
str += drawPlanetTableFtr(b[4]);
}
else
str = drawNoPlanets();
document.getElementById('planets').innerHTML = str;
if (fcnt > 0)
{
str = drawFleetTableHdr();
var nb = 1 + pcnt*2;
for (i=0;i<fcnt;i++)
{
var fname = a[nb+i*3];
var lname = a[nb+i*3+1];
var fdat = a[nb+i*3+2].split('#');
var tmp;
str += '<tr><td><a ' + montt[4] + ' href="fleets#fid' + fdat[0] + '">' + fname;
str += '</td><td>' + lname + '</td><td class="dist">' + fdat[1];
str += '</td><td class="dist">' + fdat[2] + '</td><td class="upkp">';
str += '&euro;' + formatNumber(fdat[3]) + '</td></tr>';
}
str += drawFleetTableFtr(b[5]);
}
else
str = drawNoFleets();
document.getElementById('fleets').innerHTML = str;
setTimeout('x_getCashDetails(displayPage)', 300000);
}
function transferOk(data)
{
if (data == '0')
{
if (cfUpdate)
clearTimeout(cfUpdate);
x_getCash(displayCash);
updateHeader();
document.getElementById('tamt').value = '';
document.getElementById('tdst').value = '';
showTransferOk();
}
else
tfError(parseInt(data, 10));
document.getElementById('tgo').disabled = false;
}
function transferFunds()
{
var a, b;
document.getElementById('tgo').disabled = true;
a = parseInt(document.getElementById('tamt').value, 10);
if (isNaN(a) || a <= 0)
{
tfError(1);
document.getElementById('tgo').disabled = false;
return;
}
b = document.getElementById('tdst').value;
if (b == '')
{
tfError(2);
document.getElementById('tgo').disabled = false;
return;
}
if (!confirmTransfer(a, b))
{
document.getElementById('tgo').disabled = false;
return;
}
x_transferFunds(b, a, transferOk);
}

View file

@ -0,0 +1,247 @@
function makeOverviewTooltips()
{
ovett = new Array();
if (ttDelay == 0)
{
var i;
for (i=0;i<23;i++)
ovett[i] = "";
return;
}
ovett[0] = tt_Dynamic("Click here to switch to Complete Overview mode");
ovett[1] = tt_Dynamic("Click here to go to your inbox and read your new external message(s)");
ovett[2] = tt_Dynamic("Click here to go to your internal transmissin folder and read your new internal message(s)");
ovett[3] = tt_Dynamic("Click here to go to the compose page and prepare a new message to be sent");
ovett[4] = tt_Dynamic("Click here to go to this general forum main page");
ovett[5] = tt_Dynamic("Click here to go to your alliance forum main page");
ovett[10] = tt_Dynamic("Click here to switch to Short Overview mode");
ovett[11] = tt_Dynamic("Click here to go directly to this folder");
ovett[12] = tt_Dynamic("Click here to go directly to the planets overview page");
ovett[13] = tt_Dynamic("Click here to go directly to the fleets overview page");
ovett[14] = tt_Dynamic("Click here to go directly to the research management page");
ovett[15] = tt_Dynamic("Click here to go directly to the money page");
ovett[16] = tt_Dynamic("Click here to go to the main page for this forum category");
ovett[17] = tt_Dynamic("Click here to go to this forum main page");
ovett[18] = tt_Dynamic("Click here to go to you alliance forums main page");
ovett[19] = tt_Dynamic("Click here to go to the maps page");
ovett[20] = tt_Dynamic("Click here to go to the universe overview page");
ovett[21] = tt_Dynamic("Click here to go to the ticks page");
ovett[22] = tt_Dynamic("Click here to go to the rankings page");
}
function makeNextText(name)
{
return "Next " + name + ": ";
}
function makeTopicsText(tot, n)
{
if (tot == 0)
return "empty forum";
var str = '<b>' + formatNumber(tot) + '</b> topic' + (tot > 1 ? 's' : '');
if (n == 0)
return str;
str += ' (<b>' + formatNumber(n) + '</b> unread)';
return str;
}
function drawShortOverview() {
var str = '<table><tr><td class="pc50"><h1>Empire</h1></td><td class="pc30"><h1>Universe</h1></td><td class="flink"><a href="#" '
+ ovett[0] + ' onClick="switchMode();return false">Complete overview</a> - <a href="manual?p=overview_page">Help</a></td></tr>';
str += '<tr><td><h2>Messages</h2><p>You have ';
if (dFolders[0].nMsg > 0 && dFolders[1].nMsg > 0)
{
str += '<a href="message?a=f&f=I" ' + ovett[1] + ' >'+formatNumber(dFolders[0].nMsg)+' external</a>';
str += ' and <a href="message?a=f&f=T" ' + ovett[2] + ' >'+formatNumber(dFolders[1].nMsg)+' internal</a> messages';
}
else if (dFolders[0].nMsg > 0)
{
str += '<a href="message?a=f&f=I" ' + ovett[1] + ' >'+formatNumber(dFolders[0].nMsg)+' external</a> message';
if (dFolders[0].nMsg > 1)
str += 's';
}
else if (dFolders[1].nMsg > 0)
{
str += '<a href="message?a=f&f=T" ' + ovett[2] + ' >'+formatNumber(dFolders[1].nMsg)+' internal</a> message';
if (dFolders[1].nMsg > 1)
str += 's';
}
else
str += 'no new messages';
str += '.<br/><a href="message?a=c" ' + ovett[3] + ' >Compose</a> a message.</p>';
str += '<h2>Planets</h2><p>'
+ (protection == 0 ? '' : (
'<b>Under protection</b> - <b>' + protection + '</b> day'
+ (protection > 1 ? 's' : '') + ' left (<a href="#" onclick="breakProtection(); return false">'
+ 'Break protection</a>)<br/>'))
+ 'Planets owned: <b>' + plOverview[0] + '</b><br/>'
+ 'Total population: <b>' + formatNumber(plOverview[2]) + '</b><br/>'
+ 'Total factories: <b>' + formatNumber(plOverview[4]) + '</b>'
+ '</p>'
str += '<h2>Fleets</h2><p>Total fleet power: <b>'+formatNumber(flOverview[0])+'</b></p>';
str += '<h2>Money</h2><p>Daily Profit: <b>&euro;'+formatNumber(moOverview[2])+'</b></p></td>';
str += '<td colspan="2"><h2>Forums</h2><p>';
var i,j,k,a=new Array();
for (i=0;i<genForums.length;i++)
{with(genForums[i]){
k = 0;
for (j=0;j<forums.length;j++)
k += parseInt(forums[j].nUnread,10);
j = (k==0? "no unread topics" : (k + ' unread topic' + (k>1 ? 's' : '')));
a.push('<a href="forums?cmd=C%23G%23'+id+'" ' + ovett[4] + ' >'+name+'</a>: ' + j);
}}
if (aForums.length)
{
k = 0;
for (j=0;j<aForums.length;j++)
k += parseInt(aForums[j].nUnread,10);
j = (k==0? "no unread topics" : (k + ' unread topic' + (k>1 ? 's' : '')));
a.push('<a href="forums?cmd=C%23A%23'+allianceId+'" ' + ovett[5] + ' >Alliance forums</a>: ' + j);
}
str += a.join('<br/>') + '</p>';
str += '<h2>Planets</h2><p><b>'+formatNumber(unOverview[0])+'</b> planets</p>';
str += '<h2>Next ticks</h2><p id="ticks"> </p>';
str += '<h2>Rankings</h2><p>General ranking: <b>#'+formatNumber(rankings[2])+'</b><br/>';
str += 'Round ranking: <b>' + (rankings[10] == '' ? 'N/A' : ('#' + formatNumber(rankings[10]))) + '</b></p></td>';
str += '</tr></table>';
document.getElementById('overview').innerHTML = str;
}
function drawCompleteOverview() {
var str = '<table><tr><td class="pc50"><h1>Empire</h1></td><td class="pc30"><h1>Universe</h1></td><td class="flink"><a href="#" '
+ ovett[10] + ' onClick="switchMode();return false">Short overview</a> - <a href="manual?p=overview_page">Help</a></td></tr>';
str += '<tr><td><h2>Messages</h2><p>';
var i,dfld = ['Inbox','Internal Transmissions','Outbox'],dcmd=['I','T','O'];
for (i=0;i<3;i++)
{
str += '<a href="message?a=f&f='+dcmd[i]+'" ' + ovett[11] + ' >'+dfld[i]+'</a>: <b>' + formatNumber(dFolders[i].tMsg);
str += '</b> message' + (dFolders[i].tMsg > 1 ? 's' : '');
if (dFolders[i].nMsg > 0)
str += ' (<b>' + formatNumber(dFolders[i].nMsg) + '</b> unread)';
str += '<br/>';
}
str += '<a href="message?a=c" ' + ovett[3] + ' >Compose</a> a message.</p>';
str += '<h2>Planets</h2><p>'
+ (protection == 0 ? '' : (
'<b>Under protection</b> - <b>' + protection + '</b> day'
+ (protection > 1 ? 's' : '') + ' left (<a href="#" onclick="breakProtection(); return false">'
+ 'Break protection</a>)<br/>'))
+ 'Planets owned: <b>'+plOverview[0]+'</b>';
if (plOverview[0] > 0)
{
str += '<br/>Average happiness: <b class="phap';
if (plOverview[1] >= 70)
str += 'ok';
else if (plOverview[1] >= 40)
str += 'med';
else if (plOverview[1] >= 20)
str += 'dgr';
else
str += 'bad';
str += '">' + plOverview[1] + '%</b><br/>';
str += 'Average corruption: <b class="phap';
if (plOverview[9] >= 71)
str += 'bad';
else if (plOverview[9] >= 41)
str += 'dgr';
else if (plOverview[9] >= 11)
str += 'med';
else
str += 'ok';
str += '">'+formatNumber(plOverview[9])+'%</b><br/>';
str += 'Total population: <b>'+formatNumber(plOverview[2])+'</b> (avg. <b>'
str += formatNumber(plOverview[3]) + '</b>)<br/>';
str += 'Total factories: <b>'+formatNumber(plOverview[4])+'</b> (avg. <b>'
str += formatNumber(plOverview[5]) + '</b>)<br/>';
str += 'Total turrets: <b>'+formatNumber(plOverview[6])+'</b> (avg. <b>'
str += formatNumber(plOverview[7]) + '</b>)';
}
str += '<br/><a href="planets" ' + ovett[12] + ' >More details...</a></p>';
str += '<h2>Fleets</h2><p>Total fleet power: <b>'+formatNumber(flOverview[0])+'</b>'
if (flOverview[1] > 0)
{
str += '<br/><b>' + formatNumber(flOverview[1]) + '</b> fleet' + (flOverview[1]>1?'s':'');
if (flOverview[2] > 0)
str += ' (<b>' + formatNumber(flOverview[2]) + '</b> engaged in battle)';
}
str += '<br/><a href="fleets" ' + ovett[13] + ' >More details...</a></p>';
str += '<h2>Research</h2><p>';
if (nResearch == 0)
str += 'Sorry, no new technology has been discovered at this time.';
else
str += '<b>' + nResearch + '</b> new technolog' + (nResearch > 1 ? 'ies have' : 'y has') + ' been discovered.';
str += '<br/><a href="research" ' + ovett[14] + ' >More details...</a></p>';
str += '<h2>Money</h2><p>';
str += 'Income: <b>&euro;'+formatNumber(moOverview[0])+'</b><br/>';
str += 'Fleet Upkeep: <b>&euro;'+formatNumber(moOverview[1])+'</b><br/>';
str += 'Daily Profit: <b>&euro;'+formatNumber(moOverview[2])+'</b><br/>';
str += '<a href="money" ' + ovett[15] + ' >More details...</a></p></td>';
str += '<td colspan="2"><h2>Forums</h2><p>';
var j,a=new Array(),s;
for (i=0;i<genForums.length;i++)
{with(genForums[i]){
s = '<b>' + name + '</b> (<a href="forums?cmd=C%23G%23'+id+'" ' + ovett[16] + '>view</a>)';
for (j=0;j<forums.length;j++)
{
s += '<br/>&nbsp;&nbsp;-&nbsp;<a href="forums?cmd=F%23' + type + '%23' + forums[j].id + '" ' + ovett[17] + '>' + forums[j].name + '</a>: ';
s += makeTopicsText(forums[j].nTopics, forums[j].nUnread);
}
a.push(s);
}}
if (aForums.length)
{
s = '<b>Alliance Forums</b> (<a href="forums?cmd=C%23A%23'+allianceId+'" ' + ovett[18] + ' >view</a>)';
for (j=0;j<aForums.length;j++)
{
s += '<br/>&nbsp;&nbsp;-&nbsp;<a href="forums?cmd=F%23A%23' + aForums[j].id + '" ' + ovett[17] + ' >' + aForums[j].name + '</a>: ';
s += makeTopicsText(aForums[j].nTopics, aForums[j].nUnread);
}
a.push(s);
}
str += a.join('<br/><br/>') + '</p>';
str += '<h2>Universe</h2><p><b>'+formatNumber(unOverview[0])+'</b> planets';// (<b>';
str += /*formatNumber(unOverview[2]) + '</b> at the same prot. level)*/'<br/><b>';
str += formatNumber(unOverview[1]) + '</b> systems occupied by nebulas<br/>';
str += '<a href="map" ' + ovett[19] + ' >Maps</a> - <a href="universe" ' + ovett[20] + '>More details...</a></p>';
str += '<h2>Next ticks</h2><p><span id="ticks"> </span><a href="ticks" ' + ovett[21] + ' >More details...</a></p>';
str += '<h2>Rankings</h2><p>General ranking: <b>#'+formatNumber(rankings[2])+'</b> (<b>'+formatNumber(rankings[1])+'</b> points)<br/>';
str += 'Civilisation ranking: <b>#'+formatNumber(rankings[4])+'</b> (<b>'+formatNumber(rankings[3])+'</b> points)<br/>';
str += 'Military ranking: <b>#'+formatNumber(rankings[8])+'</b> (<b>'+formatNumber(rankings[7])+'</b> points)<br/>';
str += 'Financial ranking: <b>#'+formatNumber(rankings[6])+'</b> (<b>'+formatNumber(rankings[5])+'</b> points)<br/>';
str += 'Inflicted damage ranking: <b>#'+formatNumber(rankings[12])+'</b> (<b>'+formatNumber(rankings[11])+'</b> points)<br/>';
if (rankings[10] == '')
str += 'You are too weak to be in the round rankings.';
else
str += 'Round ranking: <b>#' + formatNumber(rankings[10]) + '</b> (<b>'+formatNumber(rankings[9])+'</b> points)'
str += '<br/><a href="rank" ' + ovett[22] + ' >More details...</a></p></td>';
str += '</tr></table>';
document.getElementById('overview').innerHTML = str;
}
function getDaysText(p)
{
return "day" + (p?'s':'');
}
function confirmBreakProtection() {
return confirm('You are about to break away from Peacekeeper protection.\n'
+ 'Anyone will be able to attack your planets afterwards.\n'
+ 'Please confirm.');
}

View file

@ -0,0 +1,267 @@
var dFolders, cFolders;
var genForums, aForums, allianceId;
var plOverview, flOverview, moOverview, nResearch;
var unOverview,stDiff,ticks,tUpdate,rankings;
var complete, protection, updateTimer;
var ovett;
function emptyCB(data) { }
function Tick(id,first,interval,last,name)
{
this.id = id;
this.first = parseInt(first, 10);
this.interval = parseInt(interval, 10);
this.stopTime = (last != "") ? parseInt(last, 10) : -1;
this.name = name;
this.started = true;
this.stDays = 0;
this.previous = 0;
this.next = 0;
this.last = 0;
this.remaining = 0;
this.compute = Tick_compute;
this.draw = Tick_draw;
}
function Tick_compute(st)
{
this.started = (st >= this.first);
if (!this.started)
{
var tl = this.first - st;
this.stDays = Math.floor((tl - (tl % 86400)) / 86400);
this.next = this.first;
this.remaining = this.next - (st + this.stDays * 86400);
this.last = -1;
return;
}
else
this.stDays = 0;
var f = this.first % 86400;
var n = (st % 86400);
var tm = n + ((n<f) ? 86400 : 0) - f;
var nx = this.interval - tm % this.interval;
if (this.stopTime > -1)
{
var s = (this.stopTime - this.first);
var m = s % this.interval;
this.last = this.first + s - m
}
else
this.last = -1;
if (this.last != -1 && nx + st > this.last)
{
this.next = -1;
this.previous = this.last;
}
else
{
this.next = nx + st;
this.previous = this.next - this.interval;
this.remaining = nx;
}
}
function Tick_draw()
{
var str = makeNextText(this.name);
if (this.next != -1)
{
if (!this.started)
str += '<b>' + this.stDays + '</b> ' + getDaysText(this.stDays > 1) + ', ';
str += '<b>'
var rh = (this.remaining - (this.remaining % 3600)) / 3600,
rm = (this.remaining - rh*3600 - (this.remaining % 60)) / 60,
rs = this.remaining - (rh*60+rm)*60;
var s = rh.toString();
if (s.length == 1)
s = '0' + s;
str += s + ':';
s = rm.toString();
if (s.length == 1)
s = '0' + s;
str += s + ':';
s = rs.toString();
if (s.length == 1)
s = '0' + s;
str += s;
}
else
str += '<b>N/A';
str += '</b>';
return str;
}
function Folder(id, tMsg, nMsg, name)
{
this.id = id;
this.tMsg = tMsg;
this.nMsg = nMsg;
this.name = name;
}
function Category(id, type, name)
{
this.id = id;
this.type = type;
this.name = name;
this.forums = new Array();
}
function Forum(id, nTopics, nUnread, name)
{
this.id = id;
this.nTopics = nTopics;
this.nUnread = nUnread;
this.name = name;
}
function initPage() {
overviewReceived(document.getElementById('init-data').value);
}
function updatePage()
{
clearTimeout(tUpdate);
x_getOverview(overviewReceived);
}
function parseComms(l)
{
var i, a = l.shift().split('#');
var nCustom = parseInt(a[0],10), nGenCats = parseInt(a[1],10), nAForums = parseInt(a[2],10);
allianceId = a[3];
// Default folders
dFolders = new Array();
for (i=0;i<3;i++)
{
a = l.shift().split('#');
dFolders.push(new Folder('', a[0], a[1], ''));
}
// Custom folders
cFolders = new Array();
for (i=0;i<nCustom;i++)
{
a = l.shift().split('#');
cFolders.push(new Folder(a.shift(), a.shift(), a.shift(), a.join('#')));
}
// General categories & forums
genForums = new Array();
for (i=0;i<nGenCats;i++)
{
a = l.shift().split('#');
var j,c,id,tp,nForums;
id = a.shift(); tp = a.shift();
nForums = parseInt(a.shift(), 10);
c = new Category(id, tp, a.join('#'));
for (j=0;j<nForums;j++)
{
a = l.shift().split('#');
c.forums.push(new Forum(a.shift(),a.shift(),a.shift(),a.join('#')));
}
genForums.push(c);
}
// Alliance forums
aForums = new Array();
for (i=0;i<nAForums;i++)
{
a = l.shift().split('#');
aForums.push(new Forum(a.shift(),a.shift(),a.shift(),a.join('#')));
}
}
function parseTicks(l)
{
var a = l.shift();
var now = Math.round((new Date().getTime()) / 1000);
stDiff = now - parseInt(a,10);
ticks = new Array();
while (l.length > 0)
{
a = l.shift().split('#');
var t = new Tick(a.shift(), a.shift(), a.shift(), a.shift(), a.join('#'));
ticks.push(t);
}
}
function overviewReceived(data) {
var l = data.split('\n');
complete = (l.shift() == 1);
protection = parseInt(l.shift(), 10);
parseComms(l);
plOverview = l.shift().split('#');
flOverview = l.shift().split('#');
moOverview = l.shift().split('#');
moOverview[2] = (parseInt(moOverview[0],10) - parseInt(moOverview[1],10)).toString();
nResearch = l.shift();
unOverview = l.shift().split('#');
rankings = l.shift().split('#');
parseTicks(l);
drawOverviewPage();
updateTimer = setTimeout('updatePage()', 60000);
}
function drawOverviewPage()
{
if (complete)
drawCompleteOverview();
else
drawShortOverview();
drawTicks();
}
function drawTicks()
{
var now = Math.round((new Date().getTime()) / 1000) - stDiff;
var i, str = '';
for (i=0;i<ticks.length;i++)
{
ticks[i].compute(now);
str += ticks[i].draw() + "<br/>";
}
document.getElementById('ticks').innerHTML = str;
tUpdate = setTimeout('drawTicks()', 1000);
}
function switchMode()
{
complete = !complete;
clearTimeout(tUpdate);
drawOverviewPage();
x_switchOvMode(emptyCB);
}
function breakProtection() {
if (!confirmBreakProtection()) {
return;
}
clearTimeout(updateTimer);
clearTimeout(tUpdate);
x_breakProtection(overviewReceived);
}

View file

@ -0,0 +1,658 @@
// Orbit
function Orbit_drawFleetSummary()
{with(this){
var f = new Array(document.getElementById('fsum1'), document.getElementById('fsum2'),
document.getElementById('fsum3'), document.getElementById('fsum4'));
var i = 1;
if ( fleets[1] == '0' && fleets[2] == '0' && fleets[3] == '0'
|| fleets[1] == '' && fleets[2] == '' && fleets[3] == '')
{
f[0].innerHTML = f[1].innerHTML = f[2].innerHTML = f[3].innerHTML = '&nbsp;';
return;
}
var ff, ef, ffs, efs;
if (fleets[0] == '0')
{
f[0].innerHTML = '<b>Local fleets</b>';
ff = 'Defending'; ef = 'Attacking';
ffs = fleets[2]; efs = fleets[3];
}
else
{
ff = 'Friendly'; ef = 'Enemy';
if (fleets[0] == '1')
{
if (fleets[3] == '0')
f[0].innerHTML = '<b>Fleets standing by</b>';
else
f[0].innerHTML = '<b>Defending the planet</b>';
ffs = fleets[2]; efs = fleets[3];
}
else
{
f[0].innerHTML = '<b>Attacking the planet</b>';
ffs = fleets[3]; efs = fleets[2];
}
}
if (fleets[1] != '0')
{
f[i].innerHTML = '<em class="phapok">Own fleet power: <b>' + formatNumber(fleets[1]) + '</b></em>';
i++;
}
if (efs != '0')
{
f[i].innerHTML = '<em class="phapmed">' + ff + ' fleet power: <b>' + formatNumber(efs) + '</b></em>';
i++;
}
if (ffs != '0')
f[i].innerHTML = '<em class="phapbad">'+ef+' fleet power: <b>' + formatNumber(ffs) + '</b></em>';
}}
// Nebula
function Nebula_drawLayout()
{
var str;
document.getElementById('plactions').innerHTML = '<a href="fleets?sto='+this.orbit.id+'">Send Fleets</a> - <a href="map?menu=p&ctr='+this.orbit.id+'">Centre Map</a>';
document.getElementById('pimg').innerHTML = '<img src="'+staticurl+'/beta5/pics/nebula'+this.opacity+'.png" alt="Nebula - Opacity '+this.opacity+'" />';
document.getElementById('plname').innerHTML = 'Nebula ' + this.orbit.name;
str = '<h2>Details</h2><table cellspacing="0" cellpadding="0"><tr>';
str += '<td class="div20">&nbsp;</td><td class="pc70">Coordinates: ('+this.orbit.drawCoords()+')</td>';
str += '<td class="pc20" id="fsum1">&nbsp;</td><td class="div20">&nbsp;</td></tr>';
str += '<tr><td class="div20">&nbsp;</td><td class="pc70">Opacity: <b>'+this.opacity+'</b></td>';
str += '<td class="pc20" id="fsum2">&nbsp;</td><td class="div20">&nbsp;</td></tr>';
str += '<tr><td class="pc75" colspan="2">&nbsp;</td><td class="pc20" id="fsum3">&nbsp;</td><td class="div20">&nbsp;</td></tr>';
str += '<tr><td class="pc75" colspan="2">&nbsp;</td><td class="pc20" id="fsum4">&nbsp;</td><td class="div20">&nbsp;</td></tr>';
str += '</table>';
document.getElementById("pldesc").innerHTML = str;
}
// Remains
function Remains_drawLayout()
{
var str;
document.getElementById('plactions').innerHTML = '<a href="fleets?sto='+this.orbit.id+'">Send Fleets</a> - <a href="map?menu=p&ctr='+this.orbit.id+'"">Centre Map</a>';
document.getElementById('pimg').innerHTML = '<img src="'+staticurl+'/beta5/pics/prem_l.png" alt="Planetary Remains" />';
document.getElementById('plname').innerHTML = 'Planetary Remains ' + this.orbit.name;
str = '<h2>Details</h2><table cellspacing="0" cellpadding="0"><tr>';
str += '<td class="div20">&nbsp;</td><td class="pc70">Coordinates: ('+this.orbit.drawCoords()+')</td>';
str += '<td class="pc20" id="fsum1">&nbsp;</td><td class="div20">&nbsp;</td></tr>';
str += '<tr><td class="div20">&nbsp;</td><td class="pc70">Opacity: <b>1</b></td>';
str += '<td class="pc20" id="fsum2">&nbsp;</td><td class="div20">&nbsp;</td></tr>';
str += '<tr><td class="pc75" colspan="2">&nbsp;</td><td class="pc20" id="fsum3">&nbsp;</td><td class="div20">&nbsp;</td></tr>';
str += '<tr><td class="pc75" colspan="2">&nbsp;</td><td class="pc20" id="fsum4">&nbsp;</td><td class="div20">&nbsp;</td></tr>';
str += '</table>';
document.getElementById("pldesc").innerHTML = str;
}
// Planet
function Planet_drawLayout()
{
document.getElementById('pimg').innerHTML = '<img src="'+staticurl+'/beta5/pics/pl/l/'+this.orbit.id+'.png" alt="Planet" />';
var str = '<h2>Planet Overview</h2><table cellspacing="0" cellpadding="0"><tr>';
str += '<td class="div20">&nbsp;</td>';
str += '<td class="pc40">Coordinates: ('+this.orbit.drawCoords()+')</td>';
str += '<td class="pc30" id="pprof">&nbsp;</td>';
str += '<td class="fsum" id="fsum1">&nbsp;</td>';
str += '<td class="div20">&nbsp;</td>';
str += '</tr>';
str += '<tr>';
str += '<td>&nbsp;</td>';
str += '<td>Alliance: <span id="ptag"></span></td>';
str += '<td id="phap">&nbsp;</td>';
str += '<td class="fsum" id="fsum2">&nbsp;</td>';
str += '<td>&nbsp;</td>';
str += '</tr>';
str += '<tr>';
str += '<td>&nbsp;</td>';
str += '<td>Population: <b id="ppop"></b></td>';
str += '<td id="pcor">&nbsp;</td>';
str += '<td class="fsum" id="fsum3">&nbsp;</td>';
str += '<td>&nbsp;</td>';
str += '</tr>';
str += '<tr>';
str += '<td>&nbsp;</td>';
str += '<td>Turrets: <b id="ptur"></b><span id="dtur">&nbsp;</span></td>';
str += '<td id="pfact1">&nbsp;</td>';
str += '<td class="fsum" id="fsum4">&nbsp;</td>';
str += '<td>&nbsp;</td></tr><tr><td>&nbsp;</td><td>Status: <b id="pstat">&nbsp;</b></td>';
str += '<td id="pfact2">&nbsp;</td><td>&nbsp;</td>';
str += '</tr></table><br/>';
str += '<div id="pcontrol" style="display:none"><form action="?" method="post" onSubmit="return false">';
str += '<table cellspacing="0" cellpadding="0">';
str += '<tr>';
str += '<td colspan="2"><h2>Industrial factories</h2></td>';
str += '<td colspan="2"><h2>Military factories</h2></td>';
str += '</tr>';
str += '<tr>';
str += '<td class="div20">&nbsp;</td>';
str += '<td class="pc35">Quantity: <b id="ifc2"></b> (Cost: <b id="ifcc"></b>)</td>';
str += '<td class="div20">&nbsp;</td>';
str += '<td class="pc55">Quantity: <b id="mfc2"></b> (Cost: <b id="mfcc"></b>)</td>';
str += '</tr>';
str += '<tr>';
str += '<td>&nbsp;</td>';
str += '<td>';
str += '<input type="text" name="ifc" id="ifc" value="" size="5" />';
str += '<input type="button" name="ifi" id="ifi" value="Increase" onClick="factAction(0, 0); return false;" />';
str += '<input type="button" name="ifd" id="ifd" value="Decrease" onClick="factAction(1, 0); return false;" />';
str += '</td>';
str += '<td>&nbsp;</td>';
str += '<td>';
str += '<input type="text" name="mfc" id="mfc" value="" size="5" />';
str += '<input type="button" name="mfi" id="mfi" value="Increase" onClick="factAction(0, 1); return false;" />';
str += '<input type="button" name="mfd" id="mfd" value="Decrease" onClick="factAction(1, 1); return false;" />';
str += '</td>';
str += '</tr>';
str += '</table>';
str += '<br/><p>&nbsp;</p>';
str += '<h2>Build Warfare</h2>';
str += '<table cellspacing="0" cellpadding="0">';
str += '<tr>';
str += '<td class="div20" rowspan="2">&nbsp;</td>';
str += '<td class="pbwlst" rowspan="2">';
str += '<span id="bqstuff"></span><br/>';
str += 'Quantity: <input type="text" size="6" value="" name="bwfq" id="bwfq" /><br/><br/>';
str += '<input type="button" name="bwfa" id="bwfa" value="Add" onClick="addToQueue(); return false;" />';
str += '<input type="button" name="bwfr" id="bwfr" value="Replace selected" onClick="replaceItems(); return false;" />';
str += '</td>';
str += '<td class="bqt" id="bqueue"></td>';
str += '<td class="div20" rowspan="2">&nbsp;</td>';
str += '</tr>';
str += '<tr>';
str += '<td class="bqct" id="bqbut"></td>';
str += '</tr>';
str += '</table></form></div>';
str += '<div id="psale" style="display:none"><form action="?" method="post" onSubmit="return false">';
str += '<h2>Give / Sale Planet</h2><table cellspacing="0" cellpadding="0">';
str += '<tr><td class="div20" rowspan="4">&nbsp;</td>';
str += '<td class="pc45"><input type="radio" name="smode" id="sm0" value="0" onClick="setSaleMode(0)" /> <label for="sm0">Gift</label></td>';
str += '<td class="pc15"><label for="psexp">Offer expires:</label></td><td class="pc30"><select name="psexp" id="psexp" onChange="orbit.spec.sellForm.expires=';
str += 'this.options[this.selectedIndex].value">';
var i, expTime = [0, 6, 12, 24, 48, 72, 96, 120];
var expLabel = ['Never', '6 hours', '12 hours', '1 day', '2 days', '3 days', '4 days', '5 days'];
for (i=0;i<expTime.length;i++)
str += '<option value="'+expTime[i]+'">'+expLabel[i]+'</option>';
str += '</select></td><td class="div20" rowspan="4">&nbsp;</td></tr>';
str += '<tr><td class="pc45"><input type="radio" name="smode" id="sm1" value="1" onClick="setSaleMode(1)" /> <label for="sm1">Direct Sale</label></td>';
str += '<td id="pstarl">&nbsp;</td><td id="pstar">&nbsp;</td></tr>';
str += '<tr><td class="pc45"><input type="radio" name="smode" id="sm2" value="2" onClick="setSaleMode(2)" /> <label for="sm2">Public Sale</label></td>';
str += '<td id="pspril">&nbsp;</td><td id="pspri">&nbsp;</td></tr>';
str += '<tr><td class="pc45"><input type="radio" name="smode" id="sm3" value="3" onClick="setSaleMode(3)" /> <label for="sm3">Auction Sale</label></td>';
str += '<td colspan="2">&nbsp;</td></tr>';
str += '</table><br/>';
str += '<h2>Bundled Fleets</h2>';
str += '<div id="bndflt">&nbsp;</div>';
str += '</form></div>';
document.getElementById("pldesc").innerHTML = str;
}
function Planet_draw()
{
var e, str;
document.getElementById('plname').innerHTML = 'Planet ' + this.orbit.name;
str = '<a href="fleets?sto='+this.orbit.id+'">Send Fleets</a> - <a href="map?menu=p&ctr='+this.orbit.id+'"">Centre Map</a>';
if (this.isOwn)
{
if (this.sellForm)
{
str = '<a href="#" onClick="confirmSale();return false">Confirm Sale</a> - ';
str += '<a href="#" onClick="closeSaleForm();return false">Cancel</a>';
}
else if (this.cAction == '0')
{
if (this.canRename)
str += ' - <a href="#" onClick="renamePlanet();return false">Rename</a>';
if (this.canAbandon)
str += ' - <a href="#" onClick="abandonPlanet();return false">Abandon</a>';
if (this.canSell)
str += ' - <a href="#" onClick="sellPlanet();return false">Sell/Give</a>';
if (this.canDestroy)
str += ' - <a href="#" onClick="destroyPlanet();return false">Blow it up!</a>';
}
else if (this.cAction == '1')
{
if (this.time == 0)
{
if (this.sellId == '')
str += ' - Planet is for sale (<a href="#" onClick="removeSaleOffer();return false">Cancel</a>)';
else
{
str += ' - Planet offered to <a href="message?a=c&ct=0&id='+this.sellId+'">' + this.sellName + '</a> ';
str += '(<a href="#" onClick="removeSaleOffer();return false">Cancel</a>)';
}
}
else
{
str += ' - <a href="message?a=c&ct=0&id='+this.sellId+'">' + this.sellName + '</a> taking control in <b>';
str += this.time + '</b>h (<a href="#" onClick="removeSaleOffer();return false">Cancel</a>)';
}
}
else if (this.cAction == '2')
{
str += ' - Wormhole Super Nova in <b>' + this.time + '</b> hour' + (this.time > 1 ? 's' : '') + ' (<a href="#" onClick="';
str += 'cancelDestruction();return false">Cancel</a>)';
}
else if (this.cAction == '3')
{
str += ' - Abandoning the planet in ' + this.time + ' hour tick' + (this.time > 1 ? 's' : '') + ' (<a href="#" onClick="';
str += 'cancelAbandon();return false">Cancel</a>)';
}
}
else
str += ' - <a href="message?a=c&ct=1&id=' + this.orbit.id + '">Message</a>';
document.getElementById('plactions').innerHTML = str;
// Planet overview
document.getElementById('ptag').innerHTML = (this.tag == '') ? '-' : ('<b>['+this.tag+']</b>');
document.getElementById('ptur').innerHTML = (this.turrets == '') ? '?' : ('<b>'+formatNumber(this.turrets)+'</b>');
document.getElementById('pstat').innerHTML = this.protection ? "protected" : (
this.vacation ? "on vacation" : "normal"
);
document.getElementById('ppop').innerHTML = (this.population == '') ? '?' : ('<b>'+formatNumber(this.population)+'</b>');
if (this.isOwn)
{
str = 'Happiness: <b class="phap';
if (this.happiness >= 70)
str += 'ok';
else if (this.happiness >= 40)
str += 'med';
else if (this.happiness >= 20)
str += 'dgr';
else
str += 'bad';
str += '">' + this.happiness + '%</b>';
document.getElementById('phap').innerHTML = str;
str = 'Corruption: <b class="phap';
if (this.corruption >= 71)
str += 'bad';
else if (this.corruption >= 41)
str += 'dgr';
else if (this.corruption >= 11)
str += 'med';
else
str += 'ok';
str += '">' + this.corruption + '%</b>';
document.getElementById('pcor').innerHTML = str;
document.getElementById('pprof').innerHTML = 'Planet Income: <b>&euro;' + formatNumber(this.profit) + '</b>';
}
else
document.getElementById('pcor').innerHTML = document.getElementById('phap').innerHTML = document.getElementById('pprof').innerHTML = '&nbsp;';
if (this.tFactories != '')
{
document.getElementById('pfact1').innerHTML = 'Total factories: <b>' + formatNumber(this.tFactories) + '</b>';
document.getElementById('pfact2').innerHTML = '&nbsp;'
}
else if (this.iFactories != '')
{
document.getElementById('pfact1').innerHTML = 'Industrial factories: <b>' + formatNumber(this.iFactories) + '</b>';
document.getElementById('pfact2').innerHTML = 'Military factories: <b>' + formatNumber(this.mFactories) + '</b>';
}
if (!this.isOwn || this.sellForm)
{
e = document.getElementById('pcontrol');
if (e.style)
e = e.style;
e.display = 'none';
if (!this.isOwn)
return;
}
// "Sell" form
e = document.getElementById('psale');
if (e.style)
e = e.style;
if (this.sellForm)
{
e.display = 'block';
document.getElementById('sm'+this.sellForm.mode).checked = true;
drawSaleForm(this.sellForm);
return;
}
else
e.display = 'none';
e = document.getElementById('pcontrol');
if (e.style)
e = e.style;
e.display = 'block';
document.getElementById('ifc2').innerHTML = formatNumber(this.iFactories);
document.getElementById('ifcc').innerHTML = '&euro;' + formatNumber(this.caps[1]);
document.getElementById('mfc2').innerHTML = formatNumber(this.mFactories);
document.getElementById('mfcc').innerHTML = '&euro;' + formatNumber(this.caps[2]);
var i, ml = parseInt(this.caps[0], 10);
str = '';
for (i=0;i<ml+2;i++)
{
str += '<input type="radio" name="bwft" value="';
str += i + '" id="bwft'+i+'" onClick="mlSel=' + i + '"';
if (i == mlSel)
str += ' checked="checked"';
str += '/> <label for="bwft'+i+'">' + getBQItemName(i, true) + ' (&euro;';
str += formatNumber(this.caps[i+4]) + ')</label><br/>';
}
document.getElementById('bqstuff').innerHTML = str;
document.getElementById('bqueue').innerHTML = this.drawBuildQueue();
document.getElementById('bqbut').innerHTML = drawBQButtons(this);
document.getElementById('dtur').innerHTML = ' (<a href="#" onClick="destroyTurrets();return false">Destroy</a>)';
}
function drawSaleForm()
{
var i,e = document.getElementById('psexp');
for (i=0;i<e.options.length;i++)
if (e.options[i].value == orbit.spec.sellForm.expires)
{
e.selectedIndex = i;
break;
}
e = document.getElementById('pstarget');
if (e && orbit.spec.sellForm.mode > 1)
{
orbit.spec.sellForm.player = e.value;
document.getElementById('pstarl').innerHTML = document.getElementById('pstar').innerHTML = '&nbsp;';
}
else if (!e && orbit.spec.sellForm.mode <= 1)
{
document.getElementById('pstar').innerHTML = '<input type="text" name="pstarget" id="pstarget" />';
document.getElementById('pstarl').innerHTML = '<label for="pstarget">Target player:</label>';
document.getElementById('pstarget').value = orbit.spec.sellForm.player;
}
e = document.getElementById('psprice');
if (e && orbit.spec.sellForm.mode < 1)
{
orbit.spec.sellForm.player = e.value;
document.getElementById('pspril').innerHTML = document.getElementById('pspri').innerHTML = '&nbsp;';
}
else if (!e && orbit.spec.sellForm.mode >= 1)
{
document.getElementById('pspri').innerHTML = '<input type="text" name="psprice" id="psprice" />';
document.getElementById('psprice').value = orbit.spec.sellForm.player;
}
if (orbit.spec.sellForm.mode == 0)
document.getElementById('pspril').innerHTML = '&nbsp;';
else if (orbit.spec.sellForm.mode == 3)
document.getElementById('pspril').innerHTML = '<label for="psprice">Minimum bid:</label>';
else
document.getElementById('pspril').innerHTML = '<label for="psprice">Price:</label>';
if (orbit.spec.sellForm.fleets.length == 0)
document.getElementById('bndflt').innerHTML = '<p>No fleets are available.</p>';
else
{with(orbit.spec.sellForm){
var str;
str = '<table class="fbundle"><tr><th class="fbsel">&nbsp;</th><th class="fbnam">Name</th><th class="fshp">G.A. Ships</th>'
+ '<th class="fshp">Fighters</th><th class="fshp">Cruisers</th><th class="fshp">Battle Cruisers</th>'
+ '<th class="fpwr">Power</th></tr>';
for (i=0;i<fleets.length;i++)
str += '<tr><td class="fbsel"><input type="checkbox" name="fbsel" onClick="orbit.spec.sellForm.fleets[' + i
+ '][7] = !orbit.spec.sellForm.fleets[' + i + '][7]" ' + (fleets[i][7] ? 'checked="checked"' : '')
+ '/></td><td class="fbnam">' + fleets[i][6] + '</td><td class="fshp">' + formatNumber(fleets[i][1])
+ '</td><td class="fshp">' + formatNumber(fleets[i][2]) + '</td><td class="fshp">' + formatNumber(fleets[i][3])
+ '</td><td class="fshp">' + formatNumber(fleets[i][4]) + '</td><td class="fpwr">' + formatNumber(fleets[i][5])
+ '</td></tr>';
str += '</table>';
document.getElementById('bndflt').innerHTML = str;
}}
}
function getBQItemName(id, pl)
{
var names = ['Turret', 'GA Ship', 'Fighter', 'Cruiser', 'Battle Cruiser'];
return names[id] + (pl ? 's' : '');
}
function drawBQHeader()
{
var str;
str = '<tr class="bqlf">';
str += '<td class="bqsel">&nbsp;</td>';
str += '<td colspan="2">&nbsp;</td>';
str += '<th colspan="2">Time to build</th>';
str += '</tr>';
str += '<tr class="bql">';
str += '<td class="bqsel">&nbsp;</td>';
str += '<th class="bqqt">Qty</th>';
str += '<th class="bqt">Type</th>';
str += '<th>Ind.</th>';
str += '<th>Cum.</th>';
str += '</tr>';
return str;
}
function getEmptyBQ()
{
return '<h2>The Build Queue is empty</h2>';
}
function drawBQButtons(planet)
{
var str;
if (!planet.bq.length)
return "&nbsp;";
str = '<input type="button" name="bqmu" id="bqmu" value="Up" onClick="moveItems(1); return false;" />';
str += '<input type="button" name="bqmd" id="bqmd" value="Down" onClick="moveItems(0); return false;" />';
str += '<input type="button" name="bqdl" id="bqdl" value="Cancel" onClick="deleteItems(); return false;" />';
str += '<input type="button" name="bqfl" id="bqfl" value="Flush" onClick="flushQueue(); return false;" />';
return str;
}
function alertFlush()
{
return confirm('Are you sure you want to flush the build queue?');
}
function plError(en)
{
var str;
switch (en)
{
case -1:
str = 'You are no longer the owner of this planet.';
break;
case 0:
case 24:
str = 'You don\'t have enough money for this operation.';
break;
case 1:
str = 'You must select the type of items to build.';
break;
case 2:
str = 'Please specify the quantity of items to add to the build queues.';
break;
case 3:
str = 'Please specify the quantity of factories to build or destroy.';
break;
case 4:
str = 'Please specify the quantity of replacement items.';
break;
case 5:
str = 'You must select at least one item in the queue.';
break;
case 6:
str = 'You can\'t move up the first item of the build queue.';
break;
case 7:
str = 'You can\'t move down the last item of the build queue.';
break;
case 8:
str = 'The number of factories to destroy exceed the planet\'s quantity of factories.';
break;
case 9:
str = 'Your planet must keep a minimum of 1 military factory.';
break;
case 10:
str = 'You can\'t destroy more than 10% of a planet\'s factories in 24h.';
break;
case 11:
str = 'Control over this planet is being transfered.';
break;
case 12:
str = 'This planet is under siege.';
break;
case 13:
str = 'This planet name is too long (maximum 15 characters).';
break;
case 14:
str = 'This planet name is incorrect (letters, numbers, spaces and _.@-+\'/ only).';
break;
case 15:
str = 'Multiple spaces are not allowed.';
break;
case 16:
str = 'This planet name is too short (minimum 2 characters).';
break;
case 17:
str = 'Planet names must contain at least one letter';
break;
case 18:
str = 'Impossible to cancel the transfer, you do not have enough cash for a refund.';
break;
case 19:
str = 'Please specify a valid amount of turrets to destroy.';
break;
case 20:
str = 'Please specify a number of turrets that\'s actually inferior to the amount\nof turrets on the planet ...';
break;
case 21:
str = 'You can\'t destroy more than 20% of a planet\'s turrets in 24h.';
break;
case 22:
str = 'You can\'t destroy turrets while the planet is being transferred\nto another player.';
break;
case 23:
str = 'You can\'t destroy turrets while the planet is under siege.';
break;
case 25:
str = 'You can\'t build factories while the planet is being transferred\nto another player.';
break;
case 26:
str = 'Your population is too low, you can\'t build that many factories.';
break;
case 37:
str = 'You can\'t destroy factories so soon after building them.\nYou have to wait for two hours after you last built factories.';
break;
case 38:
str = 'This planet name is unavailable.';
break;
case 200:
str = 'You can\'t do anything while in vacation mode.';
break;
default:
str = 'An unkown error has occured: ' + en;
break;
}
alert('Planet Manager: error\n\n' + str);
}
function factoryConfirm(act, ft, qt)
{
var str;
if (act == 0)
{
var c = qt;
str = 'You are about to build ';
str += formatNumber(qt.toString()) + ' ' + (ft == '1' ? 'military' : 'industrial') + ' factor' + (qt > 1 ? 'ies' : 'y');
str += '.\nThis operation will cost you ';
c *= parseInt(orbit.spec.caps[ft == '1' ? 2 : 1], 10);
str += formatNumber(c.toString()) + ' euros.\nPlease confirm.';
}
else
{
str = 'You are about to destroy ' + qt + ' ';
str += (ft == '1' ? 'military' : 'industrial') + ' factor' + (qt > 1 ? 'ies' : 'y');
str += '.\nPlease note that your factories will not be refunded.\nPlease confirm this operation.';
}
return confirm(str);
}
function promptNewName() {
return prompt('Please type in the new name for this planet:', '');
}
function promptDestroyTurrets() {
return prompt('How many turrets do you wish to destroy?', '1');
}
function saleError(e) {
var str;
switch (e) {
case 1: str = 'You must indicate a player to give / sale the planet to.'; break;
case 2: str = 'Please specify a price.'; break;
case 3: str = 'Auction sales must have an expiration date. Please select one.'; break;
case 4: str = 'Target player not found.'; break;
case 5: str = 'Target player is under Peacekeeper protection.'; break;
case 6: str = 'Unable to sell something to yourself.'; break;
case 7: str = 'Fleet not found.'; break;
case 200: str = 'You can\'t do anything while in vacation mode.'; break;
case 201: str = 'You can\'t sell planets while under Peacekeeper protection.'; break;
default: str = 'An unknown error has occured.'; break;
}
alert('Planet Sale - Error\n' + str);
}
function userConfirmSale()
{
return confirm("Please confirm that you really want to give / sell this planet.");
}
function confirmAbandon()
{
return confirm('You are about the abandon this planet.\nPlease confirm.');
}
function confirmCancelAbandon()
{
return confirm('You were about the abandon this planet.\nPlease confirm you want to cancel this action.');
}
function confirmCancelSale()
{
return confirm('You are about to cancel the sale of this planet.\nPlease confirm.');
}
function confirmDestroy()
{
return confirm(
'You are about to make this planet\'s wormhole go supernova.\n'
+ 'The planet will be destroyed, and the people under your rule will be scared to\n'
+ 'death because of it.\n'
+ 'It will take the wormhole 4 hours to reach the point where it actually explodes.\n'
+ 'Please confirm.'
);
}
function confirmCancelDestruction()
{
return confirm('You are about to cancel the planet\'s destruction\nPlease confirm.');
}

View file

@ -0,0 +1,672 @@
var pdUpdate;
var orbit;
var planet;
var plId;
var pdIsOwn;
var miSel;
var miDir = -1;
var mlSel = -1;
//---------------------------------------------------------------------------
// PLANET LIST
//---------------------------------------------------------------------------
var plUpdate;
function drawPlanetList(data)
{
var cs = document.getElementById('oid').value;
var str, i, a, n, f;
a = data.split('\n');
n = parseInt(a.shift(),10);
if (n > 0)
{
str = '';
f = false;
for (i=0;i<n;i++)
{
var d = a.shift().split('#');
str += '<option value="' + d[0] + '"';
if (cs == d[0])
{
str += ' selected="selected"';
f = true;
}
str += '>' + d[1] + '</option>';
}
str = '<select name="id" onChange="submit();">' + (f ? '' : '<option>------</option>') + str + '</select>';
}
else
str = '---';
document.getElementById('psel').innerHTML = str;
plUpdate = setTimeout('x_getPlanetList(drawPlanetList)', 600000);
}
//---------------------------------------------------------------------------
// GENERIC ORBIT OBJECT
//---------------------------------------------------------------------------
function Orbit(type,id,x,y,orbit,name)
{
this.type = type;
this.id = id;
this.x = x;
this.y = y;
this.orbit = orbit;
this.name = name;
this.fleets = null;
this.spec = null;
this.drawAll = Orbit_drawAll;
this.draw = Orbit_draw;
this.drawCoords = Orbit_drawCoords;
this.drawFleets = Orbit_drawFleetSummary;
}
function Orbit_drawAll()
{
if (!this.spec)
return
this.spec.drawLayout();
this.draw();
}
function Orbit_draw()
{
this.drawFleets();
if (!this.spec.draw)
return
this.spec.draw();
}
function Orbit_drawCoords()
{
return '<b>'+this.x+','+this.y+'</b>,'+this.orbit;
}
//---------------------------------------------------------------------------
// NEBULA OBJECT
//---------------------------------------------------------------------------
function Nebula(orbit,opacity)
{
this.orbit = orbit;
this.opacity = opacity;
this.drawLayout = Nebula_drawLayout;
}
//---------------------------------------------------------------------------
// REMAINS OBJECT
//---------------------------------------------------------------------------
function Remains(orbit)
{
this.orbit = orbit;
this.drawLayout = Remains_drawLayout;
}
//---------------------------------------------------------------------------
// PLANET OBJECT
//---------------------------------------------------------------------------
function Planet(orbit)
{
this.orbit = orbit;
this.bq = new Array();
this.sellForm = null;
this.drawLayout = Planet_drawLayout;
this.draw = Planet_draw;
this.drawBuildQueue = Planet_drawQueue;
}
function BQItem()
{
this.selected = false;
}
function parsePlanetData(planet, l)
{
var a = l.shift().split('#');
planet.isOwn = (a.shift() == '1');
planet.vacation = (a.shift() == '1');
planet.protection = (a.shift() == '1');
planet.turrets = a.shift();
planet.population = a.shift();
planet.tFactories = a.shift();
planet.iFactories = a.shift();
planet.mFactories = a.shift();
planet.happiness = a.shift();
planet.corruption = a.shift();
planet.profit = a.shift();
planet.tag = a.join('#');
if (!planet.isOwn)
return;
// Actions and capabilities
a = l.shift().split('#');
planet.cAction = a.shift();
if (planet.cAction == '0')
{
planet.canRename = (a.shift() == '1');
planet.canSell = (a.shift() == '1');
planet.canDestroy = (a.shift() == '1');
planet.canAbandon = (a.shift() == '1');
}
else if (planet.cAction == '1')
{
planet.time = a.shift();
planet.sellId = a.shift();
planet.sellName = a.shift();
}
else
planet.time = a.shift();
planet.caps = l.shift().split('#');
// Build queue
var i = 0, obq = planet.bq;
planet.bq = new Array();
while (l.length)
{
var bqi = (i<obq.length) ? obq[i] : new BQItem();
a = l.shift().split('#');
bqi.type = a.shift();
bqi.qt = a.shift();
bqi.ttb = a.shift();
bqi.cttb = a.shift();
planet.bq.push(bqi);
i ++;
}
}
function Planet_drawQueue()
{
var i, str;
if (!this.bq.length)
return getEmptyBQ();
str = '<table cellspacing="0" cellpadding="0" class="bqueue">';
str += drawBQHeader();
for (i=0;i<this.bq.length;i++)
{
str += '<tr class="bql">';
str += '<td><input type="checkbox" name="qbsel" value="';
str += i + '" onClick="orbit.spec.bq['+i+'].selected=!orbit.spec.bq['+i+'].selected; return true;"';
if (this.bq[i].selected)
str += ' checked="checked"';
str += '/></td>';
str += '<td class="bqqt"><b>' + this.bq[i].qt + '</b></td>';
str += '<td>' + getBQItemName(this.bq[i].type, (this.bq[i].qt > 1)) + '</td>';
str += '<td class="bqqt"><b>' + this.bq[i].ttb + '</b>h</td>';
str += '<td class="bqqt"><b>' + this.bq[i].cttb + '</b>h</td>';
str += '</tr>';
}
str += '</table>';
return str;
}
//---------------------------------------------------------------------------
// PLANET SALE
//---------------------------------------------------------------------------
function SellForm()
{
this.mode = 0;
this.player = '';
this.price = 0;
this.expires = 0;
this.fleets = new Array();
this.validate = SellForm_validate;
}
function SellForm_validate()
{
if (this.mode < 2)
{
this.player = document.getElementById('pstarget').value;
if (this.player == '')
return 1;
}
if (this.mode != 0)
{
this.price = parseInt(document.getElementById('psprice').value, 10);
if (isNaN(this.price) || this.price <= 0)
return 2;
}
if (this.mode == 3 && this.expires == 0)
return 3;
return 0;
}
function sellPlanet()
{
x_getSellableFleets(orbit.id, gotFleetsList);
}
function gotFleetsList(data)
{
if (data != "ERR#-1")
{
orbit.spec.sellForm = new SellForm();
if (data != "")
{
var l = data.split('\n');
while (l.length)
{
var a = l.shift().split('#');
var b = new Array();
b.push(a.shift()); b.push(a.shift()); b.push(a.shift());
b.push(a.shift()); b.push(a.shift()); b.push(a.shift());
b.push(a.join('#')); b.push(false);
orbit.spec.sellForm.fleets.push(b);
}
}
}
orbit.draw();
}
function closeSaleForm()
{
orbit.spec.sellForm = null;
orbit.draw();
}
function confirmSale()
{with(orbit.spec.sellForm){
var e = validate();
if (e)
{
saleError(e);
return;
}
var a = new Array();
for (e=0;e<fleets.length;e++)
if (fleets[e][7])
a.push(fleets[e][0]);
if (!lockUpdate())
return;
if (!userConfirmSale())
{
startUpdate();
return;
}
x_planetSale(plId, mode, player, price, expires, a.join('#'), saleRequestSent);
}}
function saleRequestSent(data)
{
if (data.indexOf('ERR#') == 0)
{
saleError(parseInt(data.substr(4), 10));
startUpdate();
}
else
{
orbit.spec.sellForm = null;
parseOrbitData(data);
}
}
function setSaleMode(m)
{
orbit.spec.sellForm.mode = m;
drawSaleForm();
}
function removeSaleOffer()
{
if (!lockUpdate())
return;
if (!confirmCancelSale())
{
startUpdate();
return;
}
x_cancelSale(plId, plExecuteOk);
}
//---------------------------------------------------------------------------
// PAGE MANAGEMENT & DATA PARSING
//---------------------------------------------------------------------------
function lockUpdate()
{
if (!pdUpdate)
return false;
var p = pdUpdate;
pdUpdate = null;
clearTimeout(p);
return true;
}
function startUpdate()
{
if (pdUpdate)
return;
pdUpdate = setTimeout('x_getPlanetData(plId, parseOrbitData)', 60000);
}
function initPlanetPage() {
plId = document.getElementById('oid').value;
x_getPlanetList(drawPlanetList);
x_getPlanetData(plId, parseOrbitData);
}
function parseOrbitData(data)
{
var l = data.split('\n');
var a = l.shift().split('#');
var t = parseInt(a.shift());
if (orbit && orbit.type == t)
{
orbit.fleets = l.shift().split('#');
if (t == 0)
{
a.splice(0,4);
orbit.name = a.join('#');
parsePlanetData(orbit.spec, l);
}
orbit.draw();
}
else
{
orbit = new Orbit(t, a.shift(), a.shift(), a.shift(), a.shift(), a.join('#'));
orbit.fleets = l.shift().split('#');
if (t >= 2)
orbit.spec = new Nebula(orbit, t - 1);
else if (t == 1)
orbit.spec = new Remains(orbit);
else
{
orbit.spec = new Planet(orbit);
parsePlanetData(orbit.spec, l);
}
orbit.drawAll();
}
startUpdate();
}
//---------------------------------------------------------------------------
// ACTIONS
//---------------------------------------------------------------------------
function renamePlanet()
{
if (!lockUpdate())
return;
var nn = promptNewName();
if (typeof nn == 'object' && !nn)
{
startUpdate();
return;
}
x_rename(plId, nn, plExecuteOk);
}
function factAction(ta, tf)
{
var n, str;
if (!lockUpdate())
return;
str = (tf == 1) ? 'mfc' : 'ifc';
n = parseInt(document.getElementById(str).value, 10);
if (isNaN(n) || n <= 0)
{
plError(3);
startUpdate();
return;
}
if (!factoryConfirm(ta, tf, n))
{
startUpdate();
return;
}
x_factoryAction(plId, ta, n, tf, plExecuteOk);
}
function addToQueue()
{
if (!lockUpdate())
return;
if (mlSel == -1)
{
plError(1);
startUpdate();
return;
}
var n = parseInt(document.getElementById('bwfq').value, 10);
if (isNaN(n) || n <= 0)
{
plError(2);
startUpdate();
return;
}
x_addToQueue(plId, n, mlSel, plExecuteOk);
}
function getSelectedItems()
{
var j, s = new Array();
for (j=0;j<orbit.spec.bq.length;j++)
{
if (orbit.spec.bq[j].selected)
s.push(j);
}
return s;
}
function replaceItems()
{
if (!lockUpdate())
return;
if (mlSel == -1)
{
plError(1);
startUpdate();
return;
}
var n = parseInt(document.getElementById('bwfq').value, 10);
if (isNaN(n) || n <= 0)
{
plError(4);
startUpdate();
return;
}
var sel = getSelectedItems();
if (sel.length == 0)
{
plError(5);
startUpdate();
return;
}
x_replaceItems(plId, sel.join('#'), n, mlSel, plExecuteOk);
}
function moveItems(dir)
{
if (!lockUpdate())
return;
var sel = getSelectedItems();
if (!sel.length)
{
plError(5);
startUpdate();
return;
}
var n, ts = '!' + sel.join('!') + '!';
if (dir == 1)
{
if (ts.indexOf('!0!') != -1)
{
plError(6);
startUpdate();
return;
}
}
else
{
n = orbit.spec.bq.length - 1;
if (ts.indexOf('!' + n + '!') != -1)
{
plError(7);
startUpdate();
return;
}
}
miSel = sel;
miDir = dir;
x_moveItems(plId, sel.join('#'), dir, plExecuteOk);
}
function deleteItems()
{
if (!lockUpdate())
return;
var sel = getSelectedItems();
if (sel.length == 0)
{
plError(5);
startUpdate();
return;
}
x_deleteItems(plId, sel.join('#'), plExecuteOk);
}
function flushQueue()
{
if (!lockUpdate())
return;
var c = alertFlush();
if (!c)
{
startUpdate();
return;
}
x_flushQueue(plId, plExecuteOk);
}
function moveSelection()
{
var i, j, s, ni;
s = '';
for (i=0;i<miSel.length;i++)
{
j = parseInt(miSel[i], 10);
ni = j + (miDir ? -1 : 1);
if (s.indexOf('!'+j+'!') == -1)
orbit.spec.bq[j].selected = false;
orbit.spec.bq[ni].selected = true;
s += '!'+ni+'!';
}
}
function plExecuteOk(data)
{
if (data.indexOf('ERR#') == 0)
{
plError(parseInt(data.substr(4), 10));
if (data.substr(4) == "-1")
{
history.go(0);
return;
}
startUpdate();
}
else
{
if (miDir != -1)
{
moveSelection();
miDir = -1;
}
updateHeader();
parseOrbitData(data);
}
}
function abandonPlanet()
{
if (!lockUpdate())
return;
if (!confirmAbandon())
{
startUpdate();
return;
}
x_abandon(plId, plExecuteOk);
}
function cancelAbandon()
{
if (!lockUpdate())
return;
if (!confirmCancelAbandon())
{
startUpdate();
return;
}
x_cancelAbandon(plId, plExecuteOk);
}
function destroyPlanet()
{
if (!lockUpdate())
return;
if (!confirmDestroy())
{
startUpdate();
return;
}
x_blowItUp(plId, plExecuteOk);
}
function cancelDestruction()
{
if (!lockUpdate())
return;
if (!confirmCancelDestruction())
{
startUpdate();
return;
}
x_cancelDestruction(plId, plExecuteOk);
}
function destroyTurrets()
{
if (!lockUpdate())
return;
var nn = promptDestroyTurrets();
if (typeof nn == 'object' && !nn)
{
startUpdate();
return;
}
x_destroyTurrets(plId, nn, plExecuteOk);
}

View file

@ -0,0 +1,315 @@
function makePlanetsTooltips()
{
plstt = new Array();
if (ttDelay == 0)
{
var i;
for (i=0;i<40;i++)
plstt[i] = "";
return;
}
plstt[0] = tt_Dynamic("Click here to swtich between individual and cumulative build times for the planets' build queues");
plstt[1] = tt_Dynamic("Click here to switch between list and quick builder modes");
plstt[2] = tt_Dynamic("Click here to get a new planet if you have lost all those you had");
plstt[10] = tt_Dynamic("Check this checkbox to select this planet and build what you'll define in the quick builder on it");
plstt[11] = tt_Dynamic("Click here to go to this planet's individual page");
plstt[12] = tt_Dynamic("Check this checkbox to select this item in this planet's build queue and perform some queue operation on it with the quick builder");
plstt[20] = tt_Dynamic("Use this radio button to perform operations on factories on the selected planets");
plstt[21] = tt_Dynamic("Use drop down list to select what operation to perform with factories on the selected planets");
plstt[22] = tt_Dynamic("Use this text field to type in the number of factories to build or destroy on the selected planets");
plstt[23] = tt_Dynamic("Use this drop down list to select the type of factories with which to perform the defined operation on the selected planets");
plstt[24] = tt_Dynamic("Use this radio button to add items to the build queues on the selected planets");
plstt[25] = tt_Dynamic("Use this text field to type in the number of items to add to the build queue on the selected planets");
plstt[26] = tt_Dynamic("Use this drop down list to select the kind of items to add to the build queue on the selected planets");
plstt[27] = tt_Dynamic("Use this radio button to flush the build queue on the selected planets");
plstt[28] = tt_Dynamic("Use this radio button to delete the selected itesm from the build queues");
plstt[29] = tt_Dynamic("Use this radio button move the selected items in the build queues");
plstt[30] = tt_Dynamic("Use this drop down list to select in what direction to move the selected items in the build queues");
plstt[31] = tt_Dynamic("Use this radio button to replace the selected items in the build queues with the defined new items");
plstt[32] = tt_Dynamic("Use this text field to type in the number of items to build to replace the selected items");
plstt[33] = tt_Dynamic("Use this drop down list to select the type of items to build to replace the selected items");
plstt[34] = tt_Dynamic("Click here to execute the action you've defined with the quick builder and keep the quick builder open");
plstt[35] = tt_Dynamic("Click here to execute the action you've defined with the quick builder and go back to list mode");
plstt[36] = tt_Dynamic("Click here to select all planets for quick builder operations");
plstt[37] = tt_Dynamic("Click here to unselect all planets for quick builder operations");
plstt[38] = tt_Dynamic("Click here to invert the planets selection for quick builder operations");
}
function drawMainDisplay() {
var str, i;
var cs = ';text-align:center;vertical-align:bottom';
var csb = ';border-color:white;border-style:solid;border-width: 0px 0px 1px 0px';
str = '<table cellspacing="0" cellpadding="0" style="margin: 0px 0px 10px 0px">'
+ '<tr><td class="div2"><h1>Controlled planets</h1></td><td class="flink">'
+ (vacation ? '' : ('<a ' + plstt[1]
+ ' href="#" onClick="enableQuickBuilder(); return false;">Quick builder mode</a> - '))
+ '<a ' + plstt[1] + ' href="manual?p=planets#pop_cp">Help</a></td>'
+ '</tr><tr><td colspan="2">'
+ '<table cellspacing="0" cellpadding="0" style="width:100%;border-collapse:true;border-style:solid'
+ ';border-color:white;border-width:0px 0px 2px 0px">'
+ '<tr>'
+ '<th style="width:32px;height:32px' + csb + '" rowspan="2">&nbsp;</th>'
+ '<th colspan="2" rowspan="2" style="text-align:left;vertical-align:bottom' + csb +'">Planet</th>'
+ '<th rowspan="2" style="width:10%;max-width:80px' + cs + csb + '">Coord.</th>'
+ '<th rowspan="2" style="width:8%;max-width:60px' + cs + csb + '">Pop.</th>'
+ '<th style="width:6%;max-width:50px' + cs + '">Happ.</th>'
+ '<th style="width:6%;max-width:50px' + cs + '">Ind.</th>'
+ '<th rowspan="2" style="width:8%;max-width:70px' + cs + csb + '">Turrets</th>'
+ '<th rowspan="2" style="width:8%;max-width:80px' + cs + csb + '">Profit</th>'
+ '</tr><tr>'
+ '<th style="width:6%;max-width:50px' + cs + csb + '">Corr.</th>'
+ '<th style="width:6%;max-width:50px' + cs + csb + '">Mil.</th>'
+ '</tr>'
if (planets.length > 0) {
for (i = 0; i < planets.length; i ++) {
str += buildPlanetLine(i);
}
} else {
str += '<tr><td>&nbsp;</td></tr>';
str += '<tr><th>You do not control any planet.</th></tr>';
str += '<tr><td><a ' + plstt[2] + ' href="nplanet">Get a new planet</a></td></tr>';
str += '<tr><td>&nbsp;</td></tr>';
}
str += '</table></td></tr></table>';
return str;
}
function drawBQSummary(bq) {
var i, str;
var types = new Array('Turret', 'GA Ship', 'Fighter', 'Cruiser', 'Battle Cruiser');
var csb = ';padding: 4px 0px 0px 0px;border-style:solid;border-color:white;border-width: 1px 0px 0px 0px';
if (bq.length == 0) {
return '<td>&nbsp;</td>';
}
return '<td class="bq">Build queue loaded for <b>' + bq[bq.length - 1].cttb + '</b>h</td>';
}
function buildBuilderLine(ipl) {
var str, j;
var types = new Array('Turret', 'GA&nbsp;Ship', 'Fighter', 'Cruiser', 'Battle&nbsp;Cruiser');
str = '<tr><td><table cellspacing="0" cellpadding="0">';
str += '<td class="pimg" rowspan="2"><input ' + plstt[10] + ' type="checkbox" name="qb_pl' + planets[ipl].id
+ '" value="1"';
if (planets[ipl].selected) {
str += ' checked="checked"';
}
str += ' id="qb_pl' + planets[ipl].id + '" onClick="return selPlanet('+ipl+');" />';
str += '</td><td class="pname"><label for="qb_pl' + planets[ipl].id + '"><b>' + planets[ipl].name
+ '</b></label>';
if (planets[ipl].bq.length > 0) {
var as = ' href="#" style="color: white;text-decoration:underline;font-weight:normal" ';
str += ' (select items: <a' + as + 'onclick="selAllAt(' + planets[ipl].id + ');return false">'
+ 'all</a> - <a' + as + 'onclick="selNoneAt(' + planets[ipl].id + ');return false">'
+ 'none</a> - <a' + as + 'onclick="invertSelAt(' + planets[ipl].id + ');return false">'
+ 'invert</a>)';
}
str += '</td><td rowspan="2">' + formatNumber(planets[ipl].pop) + '</td><td>'
+ drawHappiness(planets[ipl].hap) + '</td><td>' + formatNumber(planets[ipl].ind)
+ '</td><td rowspan="2">' + formatNumber(planets[ipl].tur) + '</td></tr><tr><td class="pname">';
if (planets[ipl].bq.length == 0) {
str += 'Build Queue is empty';
} else {
for (j=0;j<planets[ipl].bq.length;j++) {
var name = 'qb_pl' + planets[ipl].id + '_i' + j;
str += '<input ' + plstt[12] + ' type="checkbox" name="' + name + '" id="' + name
+ '" value="1" onClick="return selItem(' + ipl + ',' + j + ');"';
if (planets[ipl].bq[j].selected) {
str += ' checked="checked"';
}
str += '/><label for="'+name+'"><b>' + formatNumber(planets[ipl].bq[j].qt)
+ '</b>&nbsp;' + types[planets[ipl].bq[j].type];
if (planets[ipl].bq[j].qt > 1) {
str += 's';
}
var v = (useCTTB ? planets[ipl].bq[j].cttb : planets[ipl].bq[j].ttb);
str += '&nbsp;(<b>' + v + '</b>h)</label> ';
}
}
str += '</td><td>' + drawCorruption(planets[ipl].corruption) + '</td><td>' + formatNumber(planets[ipl].mil)
+ '</td></tr></table></td></tr>';
return str;
}
function drawQuickBuilder()
{
var str;
// Header
str = '<form action="?"><table cellspacing="0" cellpadding="0">';
str += '<tr><td class="div2"><h1>Quick builder</h1</td><td class="flink">';
str += '<a ' + plstt[0] + ' href="#" onClick="switchTTB(); return false;">Display ' + (useCTTB ? 'individual' : 'cumulative') + ' time</a> - ';
str += '<a ' + plstt[1] + ' href="#" onClick="enableQuickBuilder(); return false;">List mode</a> - ';
str += '<a href="manual?p=planets#pop_qb">Help</a></td>';
str += '</tr>';
// Planet operations header
str += '<tr><td><table id="qbuild" cellspacing="0" cellpadding="0">';
str += '<tr><td colspan="3"><h3>Planet operations</h3></td></tr>';
// Factories
str += '<tr><td class="dv"></td><td class="dv"><input ' + plstt[20] + ' type="radio" name="qb_ac" value="fac" id="qb_ac1" ';
if (action == 1)
str += 'checked="checked" ';
str += 'onClick="selAction(1); return true;" /></td>';
str += '<td class="pc90" onClick="selAction(1)"><select ' + plstt[21] + ' name="qb_fdestr" id="qb_fdestr"><option value="0">Build</option>';
str += '<option value="1">Destroy</option></select><input ' + plstt[22] + ' type="text" name="qb_fcount" value="" size="6" maxlength="8" id="qb_fcount" />';
str += '<select ' + plstt[23] + ' name="qb_ftype" id="qb_ftype"><option value="0">industrial</option><option value="1">military</option>';
str += '</select> factories</td></tr>';
// Add to queue(s)
str += '<tr><td></td><td class="dv"><input ' + plstt[24] + ' type="radio" name="qb_ac" id="qb_ac2" ';
if (action == 2)
str += 'checked="checked" ';
str += 'value="adq" onClick="selAction(2); return true;" /></td>';
str += '<td onClick="selAction(2)">Add <input ' + plstt[25] + ' type="text" name="qb_adc" id="qb_adc" value="" size="5" maxlength="8" />';
str += '<select ' + plstt[26] + ' name="qb_adt" id="qb_adt">'+bqItems()+'</select> to the queues</td></tr>';
// Flush queue(s)
str += '<tr><td></td><td class="dv"><input ' + plstt[27] + ' type="radio" name="qb_ac" value="fls" id="qb_ac3" ';
if (action == 3)
str += 'checked="checked" ';
str += 'onClick="selAction(3); return true;" /></td>';
str += '<td onClick="selAction(3)">Flush build queues</td></tr>';
str += '</table></td>';
// Queue operations header
str += '<td><table id="qbuild" cellspacing="0" cellpadding="0">';
str += '<tr><td colspan="3"><h3>Queue operations</h3></td></tr>';
// Delete items
str += '<tr><td class="dv"></td><td class="dv"><input ' + plstt[28] + ' type="radio" name="qb_ac" value="dsi" id="qb_ac4" ';
if (action == 4)
str += 'checked="checked" ';
str += 'onClick="selAction(4); return true;" /></td>';
str += '<td onClick="selAction(4)">Delete selected items</td></tr>';
// Move items
str += '<tr><td class="dv"></td><td class="dv"><input ' + plstt[29] + ' type="radio" name="qb_ac" value="dsi" id="qb_ac5" ';
if (action == 5)
str += 'checked="checked" ';
str += 'onClick="selAction(5); return true;" /></td>';
str += '<td onClick="selAction(5)">Move selected items <select ' + plstt[30] + ' name="qb_mid" id="qb_mid">';
str += '<option value="0">down</option><option value="1">up</option></select> in the queue</td></tr>';
// Replace items
str += '<tr><td></td><td class="dv"><input ' + plstt[31] + ' type="radio" name="qb_ac" value="adq" id="qb_ac6" ';
if (action == 6)
str += 'checked="checked" ';
str += 'onClick="selAction(6); return true;" /></td>';
str += '<td onClick="selAction(6)">Replace items with <input ' + plstt[32] + ' type="text" name="qb_ric" id="qb_ric" value="" size="5" maxlength="8" />';
str += '<select ' + plstt[33] + ' name="qb_rit" id="qb_rit">'+bqItems()+'</select></td></tr>';
str += '</table></td></tr>';
// Buttons
str += '<tr><td colspan="2" class="fbutton"><input ' + plstt[34] + ' type="button" id="qbex1" value="Execute action" onClick="qbExecute(false); return false;" />';
str += '<input ' + plstt[35] + ' type="button" value="Execute and hide" id="qbex2" onClick="qbExecute(true); return false;" />';
str += '</td></tr>';
// Planet list header
str += '<tr><td colspan="2"><hr/></td></tr>';
str += '<tr>';
str += '<td><h1>Controlled planets</h1></td>';
str += '<td class="flink">';
str += 'Planets: <a ' + plstt[36] + ' href="#" onclick="selAllPlanets(); return false;">select all</a> -';
str += '<a ' + plstt[37] + ' href="#" onclick="selNoPlanets(); return false;">unselect all</a> -';
str += '<a ' + plstt[38] + ' href="#" onclick="invertPlanets(); return false">invert</a>';
str += '</td></tr>';
str += '<tr><td colspan="2" id="qb_planets">';
// End
str += '</td></tr></table></form>';
return str;
}
function drawQBList() {
var str, i;
str = '<table class="list" id="planets" cellspacing="0" cellpadding="0"><tr><td><table cellspacing="0" cellpadding="0"><tr>';
str += '<th class="pimg" rowspan="2"></th><th class="pname">Planet</th><th rowspan="2">Population</th>'
+ '<th>Happiness</th><th>Industrial</th><th rowspan="2">Turrets</th></tr>'
+ '<tr><th class="pname">Build queue</th><th>Corruption</th><th>Military</th></tr>'
+ '</table></td></tr>';
// Planet list
if (planets.length > 0) {
for (i=0;i<planets.length;i++) {
str += buildBuilderLine(i);
}
} else {
str += '<tr><td>&nbsp;</td></tr>';
str += '<tr><th>You do not control any planet.</th></tr>';
str += '<tr><td><a ' + plstt[2] + ' href="nplanet">Get a new planet</a></td></tr>';
str += '<tr><td>&nbsp;</td></tr>';
}
str += '</table>';
return str;
}
function bqItems()
{
var i,str;
var types = new Array('turret', 'GA ship', 'fighter', 'cruiser', 'battle cruiser');
str = '';
for (i=0;i<milLevel;i++)
str += '<option value="'+i+'">' + types[i] + '</option>';
return str;
}
function qbError(en)
{
var str;
switch (en)
{
case 0:
str = 'You must select an action.';
break;
case 1:
str = 'You must select at least one planet.';
break;
case 2:
str = 'Please specify the quantity of items to add to the build queues.';
break;
case 3:
str = 'Please specify the quantity of factories to build or destroy.';
break;
case 14:
case 4:
str = 'You don\'t have enough money for this operation.';
break;
case 5:
str = 'The number of factories to destroy exceed one of the planet\'s\nquantity of factories.';
break;
case 6:
str = 'Your planets must keep a minimum of 1 military factory.';
break;
case 7:
str = 'You can\'t destroy more than 10% of a planet\'s factories in 24h.';
break;
case 8:
str = 'At least one of the selected planets is under siege.';
break;
case 9:
str = 'You must select at least one item in the queue.';
break;
case 10:
str = 'Please specify the quantity of replacement items.';
break;
case 11:
str = 'You can\'t move up the first item of a build queue.';
break;
case 12:
str = 'You can\'t move down the last item of a build queue.';
break;
case 13:
str = 'You can\'t use the quick builder while in vacation mode.';
break;
case 15:
str = 'You can\'t build factories while the planet is being transferred\nto another player.';
break;
case 16:
str = 'Your population is too low, you can\'t build that many factories.';
break;
case 34:
str = 'You can\'t destroy factories so soon after building them.\nYou have to wait for two hours after you last built factories.';
break;
default:
str = 'An unkown error has occured: ' + en;
break;
}
alert('Quick Builder: error\n\n' + str);
}

View file

@ -0,0 +1,530 @@
var vacation = true;
var qbMode = false;
var useCTTB = false;
var action = 0;
var milLevel;
var planets;
var updTimer;
var mustHide;
var miSel, miDir;
var plstt;
function BQItem(type, qt, ttb, cttb)
{
this.type = type;
this.qt = qt;
this.ttb = ttb;
this.cttb = cttb;
this.selected = false;
}
function Planet(id,name,x,y,orbit,pop,hap,ind,tur,mil,prof,cor,bqstr)
{
this.id = id;
this.name = name;
this.x = x;
this.y = y;
this.orbit = orbit;
this.pop = pop;
this.hap = hap;
this.corruption = cor;
this.ind = ind;
this.tur = tur;
this.mil = mil;
this.prof = prof;
this.selected = false;
var i,j;
this.bq = new Array();
bqd = bqstr.split('#');
if (bqd.length == 1)
return;
ni = bqd.length / 4;
for (i=0;i<ni;i++)
{
j=i*4;
this.bq[i] = new BQItem(bqd[j], bqd[j+1], bqd[j+2], bqd[j+3]);
}
}
function buildPlanetLine(ipl) {
var id = planets[ipl].id;
var csb = ';border-style:solid;border-color:white;border-width: 1px 0px 0px 0px';
var cs1 = ';text-align:center;vertical-align:top;padding: 4px 0px 0px 0px';
var cs0 = cs1 + csb;
var str = '<tr>'
+ '<td style="width:32px;height:32px' + csb + '" rowspan="2"><img src="' + staticurl
+ '/beta5/pics/pl/s/' + id + '.png" alt="[P]" style="border-width:0px' + csb + '" /></td>'
+ '<td colspan="2" style="text-align:left;vertical-align:top' + csb + '">'
+ '<a href="planet?id=' + id + '">' + planets[ipl].name + '</a></td>'
+ '<td rowspan="2" style="width:10%;max-width:80px' + cs0 + '">(' + planets[ipl].x
+ ',' + planets[ipl].y + ',' + planets[ipl].orbit + ')</td>'
+ '<td rowspan="2" style="width:8%;max-width:60px' + cs0 + '">'
+ formatNumber(planets[ipl].pop) + '</td>'
+ '<td style="width:6%;max-width:50px' + cs0 + '">' + drawHappiness(planets[ipl].hap) + '</td>'
+ '<td style="width:6%;max-width:50px' + cs0 + '">' + formatNumber(planets[ipl].ind) + '</td>'
+ '<td rowspan="2" style="width:8%;max-width:70px' + cs0 + '">' + formatNumber(planets[ipl].tur) + '</td>'
+ '<td rowspan="2" style="width:8%;max-width:80px' + cs0 + '">&euro;' + formatNumber(planets[ipl].prof)
+ '</td>'
+ '</tr><tr>'
+ '<td style="width:20px">&nbsp;</td>' + drawBQSummary(planets[ipl].bq)
+ '<td style="width:6%;max-width:50px' + cs1 + '">' + drawCorruption(planets[ipl].corruption) + '</td>'
+ '<td style="width:6%;max-width:50px' + cs1 + '">' + formatNumber(planets[ipl].mil) + '</td>'
+ '</tr>'
return str;
}
function getMilitaryLevel(data)
{
milLevel = parseInt(data, 10) + 2;
document.getElementById('jsplanets').innerHTML = drawQuickBuilder();
}
function buildQuickBuilder()
{
if (!milLevel)
x_getMilitaryLevel(getMilitaryLevel);
else
document.getElementById('jsplanets').innerHTML = drawQuickBuilder();
}
function buildQBList()
{
var e = document.getElementById('qb_ftype'), e2 = document.getElementById('qb_planets');
if (!(e && e2))
setTimeout('buildQBList()', 500);
else
e2.innerHTML = drawQBList();
}
function buildPlanetList()
{
document.getElementById('jsplanets').innerHTML = drawMainDisplay();
}
function planetListReceived(data)
{
var i, j, lines, np, pdat, nbp, sel, sstr, bqsel, bqstr, bqlen, bqlstr;
// Store selections and build queue lengths as strings
sel = new Array();
bqlen = new Array();
bqsel = new Array();
if (planets)
{
np = 0;
for (i=0;i<planets.length;i++)
{
var id = planets[i].id;
if (planets[i].selected)
sel.push(id);
bqlen.push(id + '-' + planets[i].bq.length);
for (j=0;j<planets[i].bq.length;j++)
{
if (planets[i].bq[j].selected)
bqsel.push(id + '-' + j);
}
}
}
sstr = '!' + sel.join('!!') + '!';
bqlstr = '!' + bqlen.join('!!') + '!';
bqstr = '!' + bqsel.join('!!') + '!';
// Regenerate planets array
planets = new Array();
lines = data.split('\n');
np = (lines.length - 1) / 3;
for (i=0;i<np;i++)
{
pdat = lines[i*3].split('#');
planets[i] = new Planet(pdat[0], lines[i*3+1], pdat[1], pdat[2], pdat[3], pdat[4], pdat[5], pdat[6], pdat[7], pdat[8], pdat[9], pdat[10], lines[i*3+2]);
// Restore selections
if (sstr.indexOf('!' + pdat[0] + '!') != -1)
planets[i].selected = true;
if (bqlstr.indexOf('!' + pdat[0] + '-' + planets[i].bq.length + '!') != -1)
{
for (j=0;j<planets[i].bq.length;j++)
planets[i].bq[j].selected = (bqstr.indexOf('!' + pdat[0] + '-' + j + '!') != -1);
}
}
if (qbMode)
buildQBList();
else
buildPlanetList();
updTimer = setTimeout('x_getPlanetList(planetListReceived)', 60000);
}
function initGetMode(data)
{
var a = data.split('#');
qbMode = (a[0] == '1');
useCTTB = (a[1] == '1');
vacation = (a[2] == '1');
if (qbMode) {
buildQuickBuilder();
}
x_getPlanetList(planetListReceived);
}
function modeChange(data)
{
if (qbMode)
{
buildQuickBuilder();
buildQBList();
}
else
buildPlanetList();
}
function switchTTB()
{
useCTTB = !useCTTB;
x_setCumulative(useCTTB ? 1 : 0, modeChange);
}
function enableQuickBuilder()
{
qbMode = !qbMode;
x_setMode(qbMode ? 1 : 0, modeChange);
}
function qbExecuteOk(data)
{
if (data == 'OK')
{
if (action == 5)
moveItems();
action = 0;
if (updTimer)
clearTimeout(updTimer);
if (qbMode)
{
if (mustHide)
{
qbMode = !qbMode;
x_setMode(qbMode ? 1 : 0, modeChange);
}
else
buildQuickBuilder();
}
x_getPlanetList(planetListReceived);
updateHeader();
}
else
qbError(parseInt(data, 10));
var b1 = document.getElementById('qbex1'), b2 = document.getElementById('qbex2');
b1.disabled = false; b2.disabled = false;
}
function qbExecute(hide)
{
mustHide = hide;
var b1 = document.getElementById('qbex1'), b2 = document.getElementById('qbex2');
b1.disabled = true; b2.disabled = true;
if (action == 0)
{
qbError(0);
b1.disabled = false; b2.disabled = false;
return;
}
var sel;
if (action < 4)
{
sel = getSelectedPlanets();
if (sel.length == 0)
{
qbError(1);
b1.disabled = false; b2.disabled = false;
return;
}
}
else
{
sel = getSelectedItems();
if (sel.length == 0)
{
qbError(9);
b1.disabled = false; b2.disabled = false;
return;
}
}
if (action == 1)
{
var n, b, t, ts, to;
n = parseInt(document.getElementById('qb_fcount').value, 10);
if (isNaN(n) || n <= 0)
{
qbError(3);
b1.disabled = false; b2.disabled = false;
return;
}
ts = document.getElementById('qb_fdestr');
to = ts.selectedIndex;
b = parseInt(ts.options[to].value, 10);
ts = document.getElementById('qb_ftype');
to = ts.selectedIndex;
t = parseInt(ts.options[to].value, 10);
x_factoryAction(sel.join('#'), b, n, t, qbExecuteOk);
}
else if (action == 2)
{
var n, t, ts, to;
n = parseInt(document.getElementById('qb_adc').value, 10);
if (isNaN(n) || n <= 0)
{
qbError(2);
b1.disabled = false; b2.disabled = false;
return;
}
ts = document.getElementById('qb_adt');
to = ts.selectedIndex;
t = parseInt(ts.options[to].value, 10);
x_addToQueues(sel.join('#'), n, t, qbExecuteOk);
}
else if (action == 3)
x_flushQueues(sel.join('#'), qbExecuteOk);
else if (action == 4)
x_deleteItems(sel.join('#'), qbExecuteOk);
else if (action == 5)
{
var n, t, ts, to;
ts = document.getElementById('qb_mid');
to = ts.selectedIndex;
t = parseInt(ts.options[to].value, 10);
ts = '!' + sel.join('!') + '!';
if (t == 1)
{
if (ts.indexOf('-0!') != -1)
{
qbError(11);
b1.disabled = false; b2.disabled = false;
return;
}
}
else
{
for (n=0;n<planets.length;n++)
{
to = planets[n].bq.length - 1;
if (ts.indexOf('!' + planets[n].id + '-' + to + '!') != -1)
{
qbError(12);
b1.disabled = false; b2.disabled = false;
return;
}
}
}
miSel = sel;
miDir = t;
x_moveItems(sel.join('#'), t, qbExecuteOk);
}
else if (action == 6)
{
var n, t, ts, to;
n = parseInt(document.getElementById('qb_ric').value, 10);
if (isNaN(n) || n <= 0)
{
qbError(2);
b1.disabled = false; b2.disabled = false;
return;
}
ts = document.getElementById('qb_rit');
to = ts.selectedIndex;
t = parseInt(ts.options[to].value, 10);
x_replaceItems(sel.join('#'), n, t, qbExecuteOk);
}
else
{
qbError(-1);
b1.disabled = false; b2.disabled = false;
}
}
function selAllPlanets()
{
var i;
for (i=0;i<planets.length;i++)
{
var name = 'qb_pl' + planets[i].id;
document.getElementById(name).checked = true;
planets[i].selected = true;
}
}
function selNoPlanets()
{
var i;
for (i=0;i<planets.length;i++)
{
var name = 'qb_pl' + planets[i].id;
document.getElementById(name).checked = false;
planets[i].selected = false;
}
}
function invertPlanets()
{
var i;
for (i=0;i<planets.length;i++)
{
var name = 'qb_pl' + planets[i].id;
v = !planets[i].selected;
document.getElementById(name).checked = v;
planets[i].selected = v;
}
}
function selPlanet(i)
{
planets[i].selected = !planets[i].selected;
return true;
}
function getSelectedPlanets()
{
var i, s = new Array();
for (i=0;i<planets.length;i++)
{
if (planets[i].selected)
s.push(planets[i].id);
}
return s;
}
function selAllAt(planet) {
var i;
for (i = 0; i < planets.length; i ++) {
if (planets[i].id != planet) {
continue;
}
for (var j = 0; j < planets[i].bq.length; j ++) {
planets[i].bq[j].selected = true;
document.getElementById('qb_pl' + planets[i].id + '_i' + j).checked = true;
}
break;
}
}
function selNoneAt(planet) {
var i;
for (i = 0; i < planets.length; i ++) {
if (planets[i].id != planet) {
continue;
}
for (var j = 0; j < planets[i].bq.length; j ++) {
planets[i].bq[j].selected = false;
document.getElementById('qb_pl' + planets[i].id + '_i' + j).checked = false;
}
break;
}
}
function invertSelAt(planet) {
var i;
for (i = 0; i < planets.length; i ++) {
if (planets[i].id != planet) {
continue;
}
for (var j = 0; j < planets[i].bq.length; j ++) {
planets[i].bq[j].selected = ! planets[i].bq[j].selected;
document.getElementById('qb_pl' + planets[i].id + '_i' + j).checked = planets[i].bq[j].selected;
}
break;
}
}
function selItem(i,j)
{
planets[i].bq[j].selected = !planets[i].bq[j].selected;
return true;
}
function getSelectedItems()
{
var i, j, s = new Array();
for (i=0;i<planets.length;i++)
{
id = planets[i].id;
for (j=0;j<planets[i].bq.length;j++)
{
if (planets[i].bq[j].selected)
s.push(id+'-'+j);
}
}
return s;
}
function moveItems()
{
var i, j, s, a, ni;
s = '';
for (i=0;i<miSel.length;i++)
{
a = miSel[i].split('-');
for (j=0;j<planets.length&&planets[j].id!=a[0];j++)
;
a[1] = parseInt(a[1], 10);
ni = a[1] + (miDir ? -1 : 1);
if (s.indexOf('!'+j+'-'+a[1]+'!') == -1)
planets[j].bq[a[1]].selected = false;
planets[j].bq[ni].selected = true;
s += '!'+j+'-'+ni+'!';
}
}
function selAction(i)
{
action = i;
document.getElementById('qb_ac' + i).checked = true;
}
function drawHappiness(value) {
var str = '<span class="phap';
if (value >= 70) {
str += 'ok';
} else if (value >= 40) {
str += 'med';
} else if (value >= 20) {
str += 'dgr';
} else {
str += 'bad';
}
str += '">' + value + '%</span>';
return str;
}
function drawCorruption(value) {
var str = '<span class="phap';
if (value >= 71) {
str += 'bad';
} else if (value >= 41) {
str += 'dgr';
} else if (value >= 11) {
str += 'med';
} else {
str += 'ok';
}
str += '">' + value + '%</span>';
return str;
}

View file

@ -0,0 +1,53 @@
var pgTitles = ['Policy', 'Beacons'];
var empPolTitle = "General Policy";
var plaPolTitle = "Planet-specific Policy";
var polTexts = ['probes from trusted allies', 'probes from alliance members', 'probes from other players', 'probes from enemies'];
var polValue = ['Destroy', 'Jam', 'Allow'];
var noPlanets = 'No planets were found.';
var planetTxt = 'Planet';
var polUse = 'Use a planet-specific policy instead of the general policy';
var polUseEmpire = 'This planet follows the empire\'s general policy';
var bcnCurrent = ['No beacon', 'Hyperspace Beacon', 'Probing Beacon', 'Advanced Warning Beacon'];
var bcnNoUpgrade = 'There is no available upgrade for this planet\'s beacon.';
var bcnAlreadyBuilt = 'A beacon or probe has been built on this planet recently; you must wait for the next Day Tick.';
var bcnUpgrade = "You can upgrade this planet\'s beacon to the level of <b>__B__</b> (cost: <b>&euro;__C__</b>)";
var bcnUpgradeBtn = "Upgrade Beacon";
var bcnInfoLevel = ['Minimal', 'Very rough estimate', 'Rough estimate', 'Fleet size', 'Positive identification'];
var bcnUnknown = 'Unknown';
function PolicyPage_error(a)
{
var ec = parseInt(a.shift(), 10), str = 'Probes policy manager: error\n\n';
switch (ec)
{
case 0: str += 'Database error.'; break
case 1: str += 'Invalid parameters.'; break;
case 2: str += 'You no longer have control over this planet.'; break;
default: str += 'Something weird has happened (unknown error).'; break;
}
alert(str);
}
function BeaconsPage_error(a)
{
var ec = parseInt(a.shift(), 10), str = 'Beacons manager: error\n\n';
switch (ec)
{
case 0: str += 'Invalid parameters.'; break;
case 1: str += 'You no longer have control over this planet.'; break;
case 2: str += 'You don\'t have enough cash to pay for this upgrade.'; break;
case 200: str += 'You can\'t upgrade beacons while in vacation mode'; break;
default: str += 'Something weird has happened (unknown error).'; break;
}
alert(str);
}
function BeaconsPage_confirmUpgrade(p)
{
var str = 'Are you sure you want to upgrade the beacon on planet\n' + p.name
+ ' to the level of ' + bcnCurrent[p.cLevel + 1] + '\nfor ' + p.upgrade + ' euros?';
return confirm(str);
}

View file

@ -0,0 +1,520 @@
//--------------------------------------------------------------------
// Initialisation code
var page;
function initPage()
{
var e = document.getElementById('pinit');
if (!e)
return;
page = new Page(e.innerHTML);
page.action(['update']);
}
//--------------------------------------------------------------------
// Page management
function Page(cPage)
{
this.action = Page_action;
this.init = Page_init;
this.update = Page_update;
this.updated = Page_updated;
this.drawLayout = Page_drawLayout;
this.startTimer = Page_startTimer;
this.setPage = Page_setPage;
this.lockLock = false;
this.timerLock = false;
this.timer = null;
this.menu = new Menu(cPage);
this.page = null;
this.init();
this.drawLayout();
}
function Page_action(args)
{
var tl = true;
while (tl)
{
while (this.lockLock) ;
this.lockLock = true;
tl = this.timerLock;
if (!tl)
{
clearTimeout(this.timer);
this.timerLock = true;
}
this.lockLock = false;
}
var x = 'this.' + args.shift() + '(', i;
for (i=0;i<args.length;i++)
x += (i>0?',':'') + 'args[' + i + ']';
eval(x + ')');
}
function Page_setPage(nPage)
{
this.menu.cPage = nPage;
this.init();
// this.menu.draw();
this.drawLayout();
this.update();
}
function Page_init()
{
var classes = [/*'PolicyPage',*/ 'BeaconsPage'];
var i;
for (i=0;i<classes.length&&this.menu.ids[i]!=this.menu.cPage;i++) ;
if (i == classes.length)
return;
eval('this.page = new ' + classes[i] + '(this)');
}
function Page_update()
{
x_getPageData(this.menu.cPage, function(d) { page.updated(d); });
}
function Page_updated(data)
{
if (this.updateHeader)
{
this.updateHeader = false;
updateHeader();
}
this.page.parse(data);
this.startTimer();
}
function Page_drawLayout()
{
// this.menu.draw();
document.getElementById('prpage').innerHTML = this.page.drawLayout();
}
function Page_startTimer()
{
while (this.lockLock) ;
this.lockLock = true;
this.timer = setTimeout("page.action(['update'])", 60000);
this.timerLock = false;
this.lockLock = false;
}
function ajaxCallback(data)
{
if (data.indexOf('ERR#') == 0)
{
var a = data.split('#');
a.shift();
page.updateHeader = false;
page.page.error(a);
page.startTimer();
}
else
page.updated(data);
}
//--------------------------------------------------------------------
// Menu
function Menu(cPage)
{
this.cPage = cPage;
this.ids = [/*'policy',*/'beacons'];
this.titles = pgTitles;
this.draw = Menu_draw;
}
function Menu_draw()
{
var str = '', i;
for (i=0;i<this.ids.length;i++)
{
if (i > 0)
str += ' - ';
if (this.cPage == this.ids[i])
str += '<b>';
else
str += '<a href="#" onclick="page.action([\'setPage\', \'' + this.ids[i] + '\']);return false">';
str += this.titles[i] + (this.cPage == this.ids[i] ? "</b>" : "</a>");
}
document.getElementById('prmenu').innerHTML = str;
}
//--------------------------------------------------------------------
// Policy page
function PolicyPage(main)
{
this.error = PolicyPage_error;
this.drawLayout = PolicyPage_drawLayout;
this.updateEmpire = PolicyPage_updateEmpire;
this.updatePlanetList = PolicyPage_updatePlanetList;
this.updatePlanet = PolicyPage_updatePlanet;
this.parsePolicy = function(s) { var p=new Array(),i; for(i=0;i<4;i++) p[i]=s.charAt(i); return p; };
this.parse = PolicyPage_parse;
this.parseMain = PolicyPage_parseMain;
this.setEmpPolicy = PolicyPage_setEmpPolicy;
this.setPlPolicy = PolicyPage_setPlPolicy;
this.togglePlanet = PolicyPage_togglePlanet;
this.main = main;
this.policy = null;
this.planets = null;
this.updateHeader = false;
this.pLines = ['ta', 'am', 'ot', 'en'];
}
function PolicyPage_parse(data)
{
var l = data.split('\n');
var t = l.shift();
if (t == "0")
this.parseMain(l);
else if (t == "1")
{
this.policy = this.parsePolicy(l[0]);
this.updateEmpire();
}
else if (t == "2")
{
var i;
t = l[0].split('#');
for (i=0;i<this.planets.length && this.planets[i][0] != t[0];i++) ;
if (i<this.planets.length)
{
if (t[1] == "")
this.planets[i][3] = null;
else
this.planets[i][3] = this.parsePolicy(t[1]);
this.updatePlanet(i);
}
}
}
function PolicyPage_parseMain(l)
{
var a = l.shift().split('#');
var nPlanets = parseInt(a[0],10);
this.policy = this.parsePolicy(a[1]);
this.planets = new Array();
while (nPlanets > 0)
{
a = l.shift().split('#');
var p = new Array();
p[0] = a.shift();
p[1] = '<b>' + a.shift() + ',' + a.shift() + '</b>,' + a.shift();
if (a[0] == "")
a.shift();
else
p[3] = this.parsePolicy(a.shift());
p[2] = a.join('#');
this.planets.push(p);
nPlanets --;
}
this.updateEmpire();
this.updatePlanetList();
for (a=0;a<this.planets.length;a++)
this.updatePlanet(a);
}
function PolicyPage_drawLayout()
{
var str, i;
str = '<h1>' + empPolTitle + '</h1><p>';
for (i=0;i<this.pLines.length;i++)
{
if (i>0)
str += '<br/>';
var j, idpfx = "ep" + this.pLines[i];
for (j=3;j>0;j--)
str += '<input type="radio" name="'+idpfx+'" id="'+idpfx+(j-1)+'" value="' + (j-1)
+ '" onclick="page.action([\'page.setEmpPolicy\','+i+','+(j-1)+']);return true" '
+' /><label for="'+idpfx+(j-1)+'">' + polValue[j-1] + '</label> ';
str += polTexts[i]
}
str += '</p><h1>' + plaPolTitle + '</h1><div id="plapol">&nbsp;</div>';
return str;
}
function PolicyPage_updateEmpire()
{
var i;
for (i=0;i<this.pLines.length;i++)
{
var j, idpfx = "ep" + this.pLines[i];
for (j=0;j<3;j++)
document.getElementById(idpfx+j).checked = (this.policy[i] == j);
}
}
function PolicyPage_updatePlanetList()
{
var str = '';
if (this.planets.length == 0)
str = '<p>'+noPlanets+'</p>';
else
{
for (i=0;i<this.planets.length;i++)
{
var p = this.planets[i];
var pfx = "pl"+p[0];
str += '<table class="polpl"><tr><th>' + planetTxt + ' <a href="planet?id=' + p[0] + '">'
+ p[2] + '</a> (' + p[1] + ')</th><td><input type="checkbox" name="' + pfx + 'up" value="1"'
+ (p[3] ? ' checked="checked"' : '') + ' onclick="page.action([\'page.togglePlanet\','
+ p[0] +'])" id="' + pfx + 'up" /><label for="' + pfx + 'up">' + polUse + '</label></td></tr>'
+ '<tr><td colspan="2" id="'+pfx+'t">&nbsp;</td></tr></table>';
}
}
document.getElementById('plapol').innerHTML = str;
}
function PolicyPage_updatePlanet(index)
{
var i, j, p = this.planets[index], pfx = "pl" + p[0], up = (typeof p[3] == "object" && p[3]), e, ht;
document.getElementById(pfx + 'up').checked = up;
ht = (document.getElementById(pfx+'t').innerHTML != '&nbsp;');
e = document.getElementById(pfx+'ta0');
if (up && !(e && ht))
{
var str = '<p>';
for (i=0;i<this.pLines.length;i++)
{
var idpfx = pfx + this.pLines[i];
if (i>0)
str += '<br/>';
for (j=3;j>0;j--)
str += '<input type="radio" name="'+idpfx+'" id="'+idpfx+(j-1)+'" value="' + (j-1)
+ '" onclick="page.action([\'page.setPlPolicy\','+p[0]+','+i+','+(j-1)+']);return true"'
+' /><label for="'+idpfx+(j-1)+'">' + polValue[j-1] + '</label> ';
str += polTexts[i];
}
document.getElementById(pfx+'t').innerHTML = str + '</p>';
}
else if (!up && (e || !ht))
document.getElementById(pfx+'t').innerHTML = '<p>' + polUseEmpire + '</p>';
if (!up)
return;
for (i=0;i<this.pLines.length;i++)
{
var idpfx = pfx + this.pLines[i];
for (j=0;j<3;j++)
document.getElementById(idpfx + j).checked = (j == p[3][i]);
}
}
function PolicyPage_setEmpPolicy(elem, val)
{
if (this.policy[elem] == val)
{
this.main.startTimer();
return;
}
x_setEmpirePolicy(elem, val, ajaxCallback);
}
function PolicyPage_togglePlanet(id)
{
x_togglePlanetPolicy(id, ajaxCallback);
}
function PolicyPage_setPlPolicy(id, elem, val)
{
x_setPlanetPolicy(id, elem, val, ajaxCallback);
}
//--------------------------------------------------------------------
// Beacons page data
function BP_Planet(id,x,y,orbit,current,upgrade,built,nHs,nMv,name)
{
this.id = id;
this.name = name;
this.coords = "<b>"+x+","+y+"</b>,"+orbit;
this.cLevel = parseInt(current,10);
this.upgrade = (upgrade == "" ? "" : formatNumber(upgrade));
this.built = (built == 1);
this.nHS = parseInt(nHs,10);
this.nMv = parseInt(nMv,10);
this.hsFleets = new Array();
this.hsMove = new Array();
}
//--------------------------------------------------------------------
// Beacons page
function BeaconsPage(main)
{
this.error = BeaconsPage_error;
this.drawLayout = function() { return ""; };
this.parse = BeaconsPage_parse;
this.parsePlanet = BeaconsPage_parsePlanet;
this.drawAll = BeaconsPage_drawAll;
this.drawPlanet = BeaconsPage_drawPlanet;
this.upgrade = BeaconsPage_upgrade;
this.confirmUpgrade = BeaconsPage_confirmUpgrade;
this.main = main;
this.planets = new Hashtable();
this.techLevel = 0;
}
function BeaconsPage_parse(data)
{
var l = data.split("\n");
var mode = l.shift();
if (mode == "0")
{
var a = l.shift().split('#');
this.techLevel = parseInt(a.shift(), 10);
a = parseInt(a.shift(), 10);
while (a > 0)
{
this.parsePlanet(l);
a --;
}
this.drawAll();
}
else if (mode == "1")
{
var id = this.parsePlanet(l);
this.drawPlanet(id);
}
}
function BeaconsPage_parsePlanet(data)
{
var a = data.shift().split('#');
var p = new BP_Planet(a.shift(),a.shift(),a.shift(),a.shift(),a.shift(),a.shift(),a.shift(),a.shift(),a.shift(),a.join('#'));
this.planets.put(p.id, p);
if (p.nHS > 0) {
for (var i = 0; i < p.nHS; i ++) {
var f = {};
a = data.shift().split('#');
f.level = parseInt(a.shift(), 10);
f.size = a.shift();
f.ownerID = a.shift();
f.ownerName = a.shift();
p.hsFleets.push(f);
}
}
return p.id;
}
function BeaconsPage_drawAll()
{
var i, keys = this.planets.keys();
var str = '';
for (i=0;i<keys.length;i++)
str += '<div id="bppl'+keys[i]+'">&nbsp;</div>';
document.getElementById('prpage').innerHTML = str;
for (i=0;i<keys.length;i++)
this.drawPlanet(keys[i]);
}
function BeaconsPage_drawPlanet(id)
{
var e = document.getElementById('bppl' + id), p = this.planets.get(id);
if (!p)
return;
if (!e)
{
this.drawAll();
return;
}
var str;
str = '<table class="plbcn"><tr><th class="bcnpl">Planet <a href="planet?id=' + id + '">'
+ p.name + '</a> (' + p.coords + ')</th><td colspan="2">' + bcnCurrent[p.cLevel] + '</td></tr>';
if (p.nHS > 0) {
str += '<tr><th colspan="3" style="font-size:115%">Fleets detected!</th></tr>'
+ '<tr><th>Information level</th><th>Fleet size</th><th>Fleet owner</th></tr>';
for (var i = 0; i < p.nHS; i ++) {
var f = p.hsFleets[i];
str += '<tr><td style="text-align:center">' + bcnInfoLevel[f.level]
+ '</td><td style="text-align:center">'
+ (f.size == '' ? bcnUnknown : formatNumber(f.size))
+ '</td><td style="text-align:center">'
+ (f.ownerID == '' ? bcnUnknown : (
'<a href="message?a=c&ct=0&id=' + f.ownerID + '">' + f.ownerName + '</a>'))
+ '</td></tr>';
}
}
str += '<tr><td colspan="3">';
if (p.upgrade == "")
str += bcnNoUpgrade;
else if (p.built)
str += bcnAlreadyBuilt;
else
{
var u = bcnUpgrade;
u = u.replace(/__B__/, bcnCurrent[p.cLevel+1]);
u = u.replace(/__C__/, p.upgrade);
str += u + ' <input type="button" onclick="page.action([\'page.upgrade\',' + id + '])" name="bcnup' + id
+ '" value="' + bcnUpgradeBtn + '" />';
}
str += '</table>';
e.innerHTML = str;
}
function BeaconsPage_upgrade(id)
{
var p = this.planets.get(id);
if (!(p && this.confirmUpgrade(p)))
{
this.main.startTimer();
return;
}
this.main.updateHeader = true;
x_upgradeBeacon(id, ajaxCallback);
}

View file

@ -0,0 +1,81 @@
Rankings.pointsText = 'points';
Rankings.noPlayersFound = 'No players were found.';
Rankings.noAlliancesFound = 'No alliances were found.';
Rankings.pageText = 'Page __CP__ / __MP__';
Rankings.playersPerPageText = 'Display __PS__ players / page';
Rankings.alliancesPerPageText = 'Display __PS__ alliances / page';
Rankings.searchPlayerText = 'Search for player : __TF__';
Rankings.searchAllianceText = 'Search for alliance : __TF__';
Rankings.Summary.loadingText = 'Please wait; loading ...';
Rankings.Headers.player = 'Player name';
Rankings.Headers.alliance = 'Alliance tag';
Rankings.Headers.ranking = 'Ranking / Points';
Rankings.Headers.civRanking = 'Civilization<br/>Ranking / Points';
Rankings.Headers.milRanking = 'Military<br/>Ranking / Points';
Rankings.Headers.finRanking = 'Financial<br/>Ranking / Points';
var menuText = ['Summary', 'General Rankings', 'Detailed Rankings', 'Alliance Rankings', 'Overall Round Rankings', 'Inflicted Damage Ranking'];
function makeRanksTooltips()
{
rantt = new Array();
if (ttDelay == 0)
{
var i;
for (i=30;i<31;i++)
rantt[i] = "";
return;
}
// rantt[0] = tt_Dynamic("Use this drop down list to select the number of items to display on each page");
// rantt[1] = tt_Dynamic("Use this text field to search a particular string in this ranking listing");
// rantt[10] = tt_Dynamic("Use this drop down list to go to the selected page of this rankings");
// rantt[20] = tt_Dynamic("Click here to sort the list according to this field and switch between ascending / descending order");
rantt[30] = tt_Dynamic("Click here to go to this particular rankings listing");
}
Rankings.Summary.prototype.getText = function() {
var str = '<table cellspacing="0" cellpadding="0"><tr>';
str += '<td class="div2"><h1>General ranking</h1><p>';
str += 'This ranking corresponds to a combination of your civilisation, military and financial rankings. It represents your current overall advancement and strength in the game.</b>';
str += '</p><p>Your general ranking: <b>#' + formatNumber(this.rkGen) + '</b> (<b>' + formatNumber(this.ptGen) + '</b> points)';
str += '</p></td>';
str += '<td><h1>Civilization Ranking</h1><p>';
str += 'This ranking represents the advancement level of the society in your empire. It takes into account technology level, population and happiness.';
str += '</p><p>Your civilization ranking: <b>#' + formatNumber(this.rkCiv) + '</b> (<b>' + formatNumber(this.ptCiv) + '</b> points)';
str += '</p></td>';
str += '</tr><tr></tr><tr>';
str += '<td><h1>Overall Round Ranking</h1><p>';
str += 'This ranking is calculated based on your previous general rankings. It allows for a long term estimate of your strength and advancement.';
str += '</p><p>';
if (this.rkRnd == "")
str += 'You are too weak to have an overall round ranking.';
else
str += 'Your overall ranking: <b>#' + formatNumber(this.rkRnd) + '</b> (<b>' + formatNumber(this.ptRnd) + '</b> points)';
str += '</p></td>';
str += '<td><h1>Military Ranking</h1><p>';
str += 'This ranking allows to assess the military strength of your empire. Its calculation is based on the number of turrets and military factories you own along with your fleet fire power.';
str += '</p><p>Your military ranking: <b>#' + formatNumber(this.rkMil) + '</b> (<b>' + formatNumber(this.ptMil) + '</b> points)';
str += '</p></td>';
str += '</tr><tr>';
str += '<td><h1>Inflicted Damage Ranking</h1><p>';
str += 'This ranking represents the amount of damage you have inflicted on other players\' fleets since you started playing.';
str += '</p><p>Your inflicted damage ranking: <b>#' + formatNumber(this.rkDam) + '</b> (<b>' + formatNumber(this.ptDam) + '</b> points)';
str += '</p></td>';
str += '<td><h1>Financial Ranking</h1><p>';
str += 'This ranking corresponds to the economic health of your empire. It takes into account your banked cash, your income and the number of industrial factories you own.';
str += '</p><p>Your financial ranking: <b>#' + formatNumber(this.rkFin) + '</b> (<b>' + formatNumber(this.ptFin) + '</b> points)';
str += '</p></td>';
str += '</tr></table>';
return str;
}

View file

@ -0,0 +1,237 @@
var pages = ['Summary','General','Details','Alliance','Round','Damage'];
var comps = ['summary','genListing','detListing','allListing','rndListing','idrListing'];
var rkPage = null;
var summary, genListing, detListing, allListing, rndListing, idrListing;
var currentPage = null;
var rantt;
Rankings = {};
Rankings.Headers = {};
Rankings.makeListing = function(rpc, dataType, nfText, ppText, sText, sMode) {
var ls = new Component.Listing(rpc, 3600, dataType, 'list', 'row', 'hdr');
ls.notFoundText = nfText;
ls.getDocID = function() { return 'rkpage'; }
ls.getElement = function() { return document.getElementById('rkpage'); };
ls.setPageController(new Component.Listing.PageController(Rankings.pageText), true);
var c = new Component.Listing.PageSizeController(ppText, 5, 25, 5);
c.select.select('15');
ls.setPageSizeController(c, true);
c = new Component.Listing.SearchController(sText);
c.addMode(0, sMode);
c.textField.setMaxLength(15); c.textField.setSize(16);
ls.setSearchController(c, true);
return ls;
}
Rankings.setPage = function (page) { Rankings.setPage.ajax.call(page); }
Rankings.setPage.ajax = new Component.Ajax('setPage');
Rankings.GeneralRankings = function (cache) { Component.Listing.Data.apply(this, [cache]); }
Rankings.GeneralRankings.prototype = new Component.Listing.Data;
Rankings.GeneralRankings.prototype.parse = function (data) {
var a = data.shift().split('#');
var isMe = (a.shift() == '1');
var bb = isMe ? "<b>" : "";
var be = isMe ? "</b>" : "";
this.rank = bb + '#' + formatNumber(a.shift()) + ' / '
+ formatNumber(a.shift()) + " " + Rankings.pointsText + be;
this.player = bb + a.join('#') + be;
}
Rankings.DetailedRankings = function (cache) { Component.Listing.Data.apply(this, [cache]); }
Rankings.DetailedRankings.prototype = new Component.Listing.Data;
Rankings.DetailedRankings.prototype.parse = function (data) {
var a = data.shift().split('#');
var isMe = (a.shift() == '1');
var bb = isMe ? "<b>" : "";
var be = isMe ? "</b>" : "";
this.civRank = bb + '#' + formatNumber(a.shift()) + ' / '
+ formatNumber(a.shift()) + " " + Rankings.pointsText + be;
this.milRank = bb + '#' + formatNumber(a.shift()) + ' / '
+ formatNumber(a.shift()) + " " + Rankings.pointsText + be;
this.finRank = bb + '#' + formatNumber(a.shift()) + ' / '
+ formatNumber(a.shift()) + " " + Rankings.pointsText + be;
this.player = bb + a.join('#') + be;
}
Rankings.AllianceRankings = function (cache) { Component.Listing.Data.apply(this, [cache]); }
Rankings.AllianceRankings.prototype = new Component.Listing.Data;
Rankings.AllianceRankings.prototype.parse = function (data) {
var a = data.shift().split('#');
this.rank = '#' + formatNumber(a.shift()) + ' / '
+ formatNumber(a.shift()) + " " + Rankings.pointsText;
this.alliance = a.join('#');
}
Rankings.Summary = function () {
Component.apply(this, [false]);
this.newSlot('dataReceived');
this.newSlot('startUpdate');
this.newSlot('stopUpdate');
this.newSlot('updateData');
this.timer = new Component.Timer(3600*1000, true);
this.ajax = new Component.Ajax('getPlayerData');
this.md5 = '';
this.loading = true;
this.bindEvent('Hide', 'stopUpdate');
this.ajax.bindEvent('Returned', 'dataReceived', this);
this.bindEvent('Show', 'startUpdate');
this.timer.bindEvent('Tick', 'updateData', this);
}
Rankings.Summary.prototype = new Component;
Rankings.Summary.prototype.getDocID = function() { return 'rkpage'; }
Rankings.Summary.prototype.getElement = function() { return document.getElementById('rkpage'); };
Rankings.Summary.prototype.dataReceived = function (data) {
this.loading = false;
if (data != 'KEEP') {
var a = data.split('#');
this.md5 = a.shift();
this.ptGen = a.shift();
this.rkGen = a.shift();
this.ptCiv = a.shift();
this.rkCiv = a.shift();
this.ptMil = a.shift();
this.rkMil = a.shift();
this.ptFin = a.shift();
this.rkFin = a.shift();
this.ptRnd = a.shift();
this.rkRnd = a.shift();
this.ptDam = a.shift();
this.rkDam = a.shift();
}
this.drawAll();
}
Rankings.Summary.prototype.startUpdate = function () {
this.loading = true;
this.timer.start();
this.drawAll();
this.ajax.call(this.md5);
}
Rankings.Summary.prototype.stopUpdate = function () { this.timer.stop(); }
Rankings.Summary.prototype.updateData = function () { this.ajax.call(this.md5); }
Rankings.Summary.prototype.draw = function () {
var e = this.getElement();
if (!e)
return;
var str;
if (this.loading)
str = '<div style="text-align:center;">'
+ Rankings.Summary.loadingText + '</span>';
else
str = this.getText();
e.innerHTML = str;
}
//----------------------------------------------------------------------------------------------
// GENERAL
//----------------------------------------------------------------------------------------------
function initPage() {
var c;
summary = new Rankings.Summary();
// General rankings
genListing = Rankings.makeListing('getGeneralRankings', Rankings.GeneralRankings,
Rankings.noPlayersFound, Rankings.playersPerPageText, Rankings.searchPlayerText,
"player");
genListing.addField(new Component.Listing.Field(Rankings.Headers.player, true, 'player', 0, 0, 1, 1, 'gname'));
genListing.addField(c = new Component.Listing.Field(Rankings.Headers.ranking, true, 'rank', 1, 0, 1, 1, 'grank'));
genListing.dataCache.sortField = c;
genListing.finalizeLayout();
// Detailed rankings
detListing = Rankings.makeListing('getDetailedRankings', Rankings.DetailedRankings,
Rankings.noPlayersFound, Rankings.playersPerPageText, Rankings.searchPlayerText,
"player");
detListing.addField(new Component.Listing.Field(Rankings.Headers.player, true, 'player', 0, 0, 1, 1, 'dname'));
detListing.addField(new Component.Listing.Field(Rankings.Headers.civRanking, true, 'civRank', 1, 0, 1, 1, 'drank'));
detListing.addField(new Component.Listing.Field(Rankings.Headers.milRanking, true, 'milRank', 2, 0, 1, 1, 'drank'));
detListing.addField(new Component.Listing.Field(Rankings.Headers.finRanking, true, 'finRank', 3, 0, 1, 1, 'drank'));
detListing.finalizeLayout();
// Alliance rankings
allListing = Rankings.makeListing('getAllianceRankings', Rankings.AllianceRankings,
Rankings.noAlliancesFound, Rankings.alliancesPerPageText, Rankings.searchAllianceText,
"alliance");
allListing.addField(new Component.Listing.Field(Rankings.Headers.alliance, true, 'alliance', 0, 0, 1, 1, 'dname'));
allListing.addField(c = new Component.Listing.Field(Rankings.Headers.ranking, true, 'rank', 1, 0, 1, 1, 'drank'));
allListing.dataCache.sortField = c;
allListing.finalizeLayout();
// Round rankings
rndListing = Rankings.makeListing('getRoundRankings', Rankings.GeneralRankings,
Rankings.noPlayersFound, Rankings.playersPerPageText, Rankings.searchPlayerText,
"player");
rndListing.addField(new Component.Listing.Field(Rankings.Headers.player, true, 'player', 0, 0, 1, 1, 'gname'));
rndListing.addField(c = new Component.Listing.Field(Rankings.Headers.ranking, true, 'rank', 1, 0, 1, 1, 'grank'));
rndListing.dataCache.sortField = c;
rndListing.finalizeLayout();
// Damage rankings
idrListing = Rankings.makeListing('getDamageRankings', Rankings.GeneralRankings,
Rankings.noPlayersFound, Rankings.playersPerPageText, Rankings.searchPlayerText,
"player");
idrListing.addField(new Component.Listing.Field(Rankings.Headers.player, true, 'player', 0, 0, 1, 1, 'gname'));
idrListing.addField(c = new Component.Listing.Field(Rankings.Headers.ranking, true, 'rank', 1, 0, 1, 1, 'grank'));
idrListing.dataCache.sortField = c;
idrListing.finalizeLayout();
switchToPage(document.getElementById('rkinit').innerHTML);
}
function switchToPage(page)
{
if (rkPage == page)
return;
if (currentPage)
currentPage.hide();
rkPage = page;
drawRankingsMenu();
var i;
for (i=0;i<pages.length;i++) {
if (pages[i] == rkPage) {
eval('currentPage='+comps[i]);
break;
}
}
currentPage.show();
Rankings.setPage(page);
}
function drawRankingsMenu()
{
var i, rkm = new Array();
for (i=0;i<pages.length;i++)
{
var s = (pages[i] == rkPage) ? '<b>' : ('<a href="#" ' + rantt[30] + ' onClick="switchToPage(\''+pages[i]+'\');return false">');
s += menuText[i] + ((pages[i] == rkPage) ? '</b>' : '</a>');
rkm.push(s);
}
document.getElementById('rkpsel').innerHTML = rkm.join(' - ');
}

View file

@ -0,0 +1,654 @@
var pageTitles = new Array('Research topics', 'Laws', 'Research budget', 'Diplomacy');
var rTypes = new Array('Fundamental', 'Military', 'Civilian');
function makeResearchTooltips()
{
rett = new Array();
if (ttDelay == 0)
{
var i;
for (i=0;i<82;i++)
rett[i] = "";
return;
}
rett[0] = tt_Dynamic("Click here to hide / show this research topic");
rett[1] = tt_Dynamic("Click here to implement this technology");
rett[10] = tt_Dynamic("Click here to hide / show this law");
rett[11] = tt_Dynamic("Click here to revoke this law");
rett[12] = tt_Dynamic("Click here to enact this law");
rett[20] = tt_Dynamic("Click here to decrease the percentage of research points attributed to this category by 10 points");
rett[21] = tt_Dynamic("Click here to decrease the percentage of research points attributed to this category by 1 point");
rett[22] = tt_Dynamic("Click here to increase the percentage of research points attributed to this category by 1 point");
rett[23] = tt_Dynamic("Click here to increase the percentage of research points attributed to this category by 10 points");
rett[30] = tt_Dynamic("Click here to validate the new budget attributions");
rett[31] = tt_Dynamic("Click here to reset the budget attributions");
rett[40] = tt_Dynamic("Check this radio button to offer scientific assistance");
rett[41] = tt_Dynamic("Type here the name of the player to send the offer to");
rett[42] = tt_Dynamic("Type here the amount of cash you want to receive in exchange for the offer");
rett[43] = tt_Dynamic("Click here to send the offer");
rett[44] = tt_Dynamic("Check this radio button to offer the selected technology");
rett[45] = tt_Dynamic("Choose here the technology you want to offer");
rett[50] = tt_Dynamic("Select here the page of pending technology exchange offers you want to display");
rett[51] = tt_Dynamic("Click here to accept this technology exchange");
rett[52] = tt_Dynamic("Click here to decline this technology exchange");
rett[60] = tt_Dynamic("Selected here the page of the history of technology exchanges to display");
rett[70] = tt_Dynamic("Click here to implement new technologies, view foreseen breakthroughs and already implemented technologies");
rett[71] = tt_Dynamic("Click here to enact and revoke laws");
rett[72] = tt_Dynamic("Click here to balance your research budget between fundamental, military and civilian research");
rett[73] = tt_Dynamic("Click here to give or sell technologies and scientific knowledge with other empires, and examine offers made to you");
rett[80] = tt_Dynamic("Click here to unlock the category");
rett[81] = tt_Dynamic("Click here to prevent this category from being changed along with the other two");
}
function getLoadingText()
{
return "Loading page data ...";
}
function getTopicsPage()
{
var str = '<h1>New technologies</h1>';
var tl = '!' + rtExpanded.join('!!') + '!';
var i, d, id;
if (rtCompleted.length == 0)
str += '<p>No new technology has been discovered.</p>';
else
{
str += '<table cellspacing="0" cellpadding="0" class="list">';
str += '<tr><td class="sdesc">&nbsp;</td><th class="tname">Technology</th><th class="itype">Type</th><th class="icost">Cost</th><td class="impl">&nbsp;</td></tr>';
for (i=0;i<rtCompleted.length;i++)
{
id = rtCompleted[i];
d = (tl.indexOf('!' + id + '!') != -1);
str += '<tr><td class="sdesc"><a href="#" ' + rett[0] + ' onClick="' + (d ? 'hide' : 'show') + 'Description('+id+'); return false;">';
str += '[&nbsp;' + (d ? '-' : '+') + '&nbsp;]</a>&nbsp;</td>';
if (d) {
str += '<td rowspan="2"><span onClick="' + (d ? 'hide' : 'show') + 'Description('+id+')">' + rtTitles[id] + '</span><br/>';
str += rtDescriptions[id] + '<br/><a href="manual?p=tech_' + id
+ '" style="color:white;text-decoration:underline;font-weight:normal" target="_blank">More information ...</a></td>';
}
else
str += '<td onClick="' + (d ? 'hide' : 'show') + 'Description('+id+')">' + rtTitles[id] + '</td>';
str += '<td class="itype">' + rTypes[rtTypes[id]] + '</td>';
str += '<td class="icost">&euro;' + formatNumber(rtCosts[id]) + '</td><td><a href="#" ' + rett[1] + ' onClick="';
str += 'implementTechnology(' + id + '); return false;">Implement technology</a></td>';
if (d)
str += '</tr><tr><td>&nbsp;</td><td colspan="3">&nbsp;</td>';
str += '</tr>';
}
str += '</table><br/>';
}
str += '<h1>Foreseen breakthroughs</h1>';
if (rtForeseen.length == 0)
str += '<p>No breakthrough is currently in sight.</p>';
else
{
str += '<table cellspacing="0" cellpadding="0" class="list">';
str += '<tr><td class="sdesc">&nbsp;</td><th class="tname">Technology</th><th class="itype">Type</th><th class="icost">Estimated cost</th><th class="compl">Completion</th></tr>';
for (i=0;i<rtForeseen.length;i++)
{
id = rtForeseen[i];
d = (tl.indexOf('!' + id + '!') != -1);
str += '<tr><td class="sdesc"><a href="#" ' + rett[0] + ' onClick="' + (d ? 'hide' : 'show') + 'Description('+id+'); return false;">';
str += '[&nbsp;' + (d ? '-' : '+') + '&nbsp;]</a>&nbsp;</td>';
if (d)
{
str += '<td rowspan="2"><span onClick="' + (d ? 'hide' : 'show') + 'Description('+id+')">' + rtTitles[id] + '</span><br/>';
str += rtDescriptions[id] + '<br/><a href="manual?p=tech_' + id
+ '" style="color:white;text-decoration:underline;font-weight:normal" target="_blank">More information ...</a></td>';
}
else
str += '<td onClick="' + (d ? 'hide' : 'show') + 'Description('+id+')">' + rtTitles[id] + '</td>';
str += '<td class="itype">' + rTypes[rtTypes[id]] + '</td>';
str += '<td class="icost">&euro;' + formatNumber(rtCosts[id]) + '</td><td class="compl">' + rtForeseenP[id] + '%</td>';
if (d)
str += '</tr><tr><td>&nbsp;</td><td colspan="2">&nbsp;</td>';
str += '</tr>';
}
str += '</table><br/>';
}
str += '<h1>Implemented technologies</h1><table cellspacing="0" cellpadding="0"><tr>'
+ drawImplementedList(tl, 0) + drawImplementedList(tl, 1) + drawImplementedList(tl, 2)
+ '</tr></table>';
return str;
}
function drawImplementedList(tl, type)
{
var str = '<td class="div3"><h3>' + rTypes[type] + ' research</h3>';
if (rtImplemented.length == 0)
return str + '<p>No such technology has been implemented at the moment.</p></td>';
var n = 0;
for (i=0;i<rtImplemented.length;i++)
{
id = rtImplemented[i];
if (rtTypes[id] != type)
continue;
if (n == 0)
str += '<table class="list">';
n ++;
d = (tl.indexOf('!' + id + '!') != -1);
str += '<tr><td class="sdesc"><a href="#" ' + rett[0] + ' onClick="' + (d ? 'hide' : 'show') + 'Description('+id+'); return false;">';
str += '[&nbsp;' + (d ? '-' : '+') + '&nbsp;]</a>&nbsp;</td>';
if (d)
{
str += '<td rowspan="2"><span onClick="' + (d ? 'hide' : 'show') + 'Description('+id+')">' + rtTitles[id] + '</span><br/>';
str += rtDescriptions[id] + '<br/><a href="manual?p=tech_' + id
+ '" style="color:white;text-decoration:underline;font-weight:normal" target="_blank">More information ...</a></td></tr><tr><td>&nbsp;</td></tr>';
}
else
str += '<td onClick="' + (d ? 'hide' : 'show') + 'Description('+id+')">' + rtTitles[id] + '</td></tr>';
}
if (n>0)
str += '</table></td>';
else
str += '<p>No such technology has been implemented at the moment.</p></td>';
return str;
}
function confirmTech(id)
{
var str;
str = 'Implementing ' + rtTitles[id] + '\nThis will cost ' + formatNumber(rtCosts[id]) + ' euros.\n';
str += 'Are you sure you want to do this?';
return confirm(str);
}
function implError(code) {
var str = 'Error: ';
switch (code) {
case 0:
str += 'you do not have enough cash to implement this technology';
break;
case 1:
str += 'trying to cheat by hacking the server _is_ evil';
break;
case 200:
str += 'you can\'t implement technologies while in vacation mode';
break;
default:
str += 'an unknown error has occured';
break;
}
alert(str + '.');
}
function getLawsPage()
{
var str = '<h1>Enacted laws</h1>';
var tl = '!' + rtExpanded.join('!!') + '!';
var i, d, id;
if (lEnacted.length == 0)
str += '<p>No laws have been enacted yet.</p>';
else
{
str += '<table cellspacing="0" cellpadding="0" class="list">';
str += '<tr><td class="sdesc">&nbsp;</td><th class="tname">Law</th><th class="icost">Cost</th><td class="impl">&nbsp;</td></tr>';
for (i=0;i<lEnacted.length;i++)
{
id = lEnacted[i];
d = (tl.indexOf('!' + id + '!') != -1);
str += '<tr><td class="sdesc"><a href="#" ' + rett[10] + 'onClick="' + (d ? 'hide' : 'show') + 'Description('+id+'); return false;">';
str += '[&nbsp;' + (d ? '-' : '+') + '&nbsp;]</a>&nbsp;</td>';
if (d)
str += '<td rowspan="2">' + rtTitles[id] + '<br/>' + rtDescriptions[id] + '<br/><a href="manual?p=tech_' + id + '" style="color:white;text-decoration:underline;font-weight:normal" target="_blank">More information ...</a></td>';
else
str += '<td>' + rtTitles[id] + '</td>';
if (lTimeRevoke[id] == 0)
{
str += '<td class="icost">&euro;' + formatNumber(rtCosts[id]) + '</td><td><a href="#" ' + rett[11] + ' onClick="';
str += 'revokeLaw(' + id + '); return false;">Revoke</a></td>';
}
else
{
str += '<td colspan="2">' + lTimeRevoke[id] + ' day' + (lTimeRevoke[id] > 1 ? 's' : '');
str += ' left before the law can be revoked.</td>';
}
if (d)
str += '</tr><tr><td>&nbsp;</td><td colspan="2">&nbsp;</td>';
str += '</tr>';
}
str += '</table><br/>';
}
str += '<h1>Available laws</h1>';
if (lAvailable.length == 0)
str += '<p>No laws are available.</p>';
else
{
str += '<table cellspacing="0" cellpadding="0" class="list">';
str += '<tr><td class="sdesc">&nbsp;</td><th class="tname">Law</th><th class="icost">Cost</th><td class="impl">&nbsp;</td></tr>';
for (i=0;i<lAvailable.length;i++)
{
id = lAvailable[i];
d = (tl.indexOf('!' + id + '!') != -1);
str += '<tr><td class="sdesc"><a href="#" ' + rett[10] + ' onClick="' + (d ? 'hide' : 'show') + 'Description('+id+'); return false;">';
str += '[&nbsp;' + (d ? '-' : '+') + '&nbsp;]</a>&nbsp;</td>';
if (d)
str += '<td rowspan="2">' + rtTitles[id] + '<br/>' + rtDescriptions[id] + '<br/><a href="manual?p=tech_' + id + '" style="color:white;text-decoration:underline;font-weight:normal" target="_blank">More information ...</a></td>';
else
str += '<td>' + rtTitles[id] + '</td>';
if (lTimeEnact[id] == 0)
{
str += '<td class="icost">&euro;' + formatNumber(rtCosts[id]) + '</td><td><a href="#" ' + rett[12] + ' onClick="';
str += 'enactLaw(' + id + '); return false;">Enact</a></td>';
}
else
{
str += '<td colspan="2">' + lTimeEnact[id] + ' day' + (lTimeEnact[id] > 1 ? 's' : '');
str += ' left before the law can be enacted.</td>';
}
if (d)
str += '</tr><tr><td>&nbsp;</td><td colspan="2">&nbsp;</td>';
str += '</tr>';
}
str += '</table><br/>';
}
return str;
}
function confirmEnact(id)
{
var str;
str = 'Enacting ' + rtTitles[id] + ' will cost ' + formatNumber(rtCosts[id]) + ' euros.\n';
str += 'You will not be able to revoke the law before 5 days have passed.\n';
str += 'Are you sure you want to do this?';
return confirm(str);
}
function confirmRevoke(id)
{
var str;
str = 'Revoking ' + rtTitles[id] + ' will cost ' + formatNumber(rtCosts[id]) + ' euros.\n';
str += 'You will not be able to enact the law again before 5 days have passed.\n';
str += 'Are you sure you want to do this?';
return confirm(str);
}
function slawError(code) {
var str = 'Error: ';
switch (code) {
case 0:
str += 'you do not have enough cash to switch this law\'s status';
break;
case 1:
str += 'trying to cheat by hacking the server _is_ evil';
break;
case 200:
str += 'you can\'t enact or revoke laws while in vacation mode';
break;
default:
str += 'an unknown error has occured';
break;
}
alert(str + '.');
}
function budgetError(code) {
var str = 'Error: ';
switch (code) {
case 0:
str += 'trying to cheat by hacking the server _is_ evil';
break;
case 200:
str += 'you can\'t modify your research budget while in vacation mode';
break;
default:
str += 'an unknown error has occured';
break;
}
alert(str + '.');
}
function drawAttributionsDisplay()
{
var i, str = '<h1>Research budget</h1>';
str += '<p>Research points: <b id="totRPoints"></b> per day</p>';
str += '<form action="?"><table class="rbudget" cellspacing="0" cellpadding="0">';
for (i=0;i<rTypes.length;i++)
{
str += '<tr>';
if (i==0)
str += '<td class="rbico" rowspan="' + rTypes.length + '">&nbsp;</td>';
str += '<td class="rbttl">' + rTypes[i] + ' research:</td>';
if (i==0)
str += '<td class="rbico" rowspan="' + rTypes.length + '">&nbsp;</td>';
str += '<td class="rbico" ' + rett[20] + ' onClick="changeAttr(' + i + ', -10);"><img src="'+staticurl+'/beta5/pics/dec2_'+color+'.gif" alt="<<" /></td>';
str += '<td class="rbico" ' + rett[21] + ' onClick="changeAttr(' + i + ', -1);"><img src="'+staticurl+'/beta5/pics/dec1_'+color+'.gif" alt="<" /></td>';
str += '<td class="rbval"><b id="rbval' + i + '"> </b>%</td>';
str += '<td class="rbico" ' + rett[22] + ' onClick="changeAttr(' + i + ', 1);"><img src="'+staticurl+'/beta5/pics/add1_'+color+'.gif" alt=">" /></td>';
str += '<td class="rbico" ' + rett[23] + ' onClick="changeAttr(' + i + ', 10);"><img src="'+staticurl+'/beta5/pics/add2_'+color+'.gif" alt=">>" /></td>';
if (i==0)
str += '<td class="rbico" rowspan="' + rTypes.length + '">&nbsp;</td>';
str += '<td class="rbico" id="rblock'+i+'">&nbsp;</td>';
if (i==0)
str += '<td class="rbico" rowspan="' + rTypes.length + '">&nbsp;</td>';
str += '<td><b id="rbpts'+i+'"> </b> point(s)</td></tr>';
}
str += '<tr><td colspan="12">&nbsp;</td></tr>';
str += '<tr id="rbctrl"><td class="rbcl" colspan="5" id="rbcl">&nbsp;</td><td>&nbsp;</td>';
str += '<td class="rbcr" colspan="6" id="rbcr">&nbsp;</td></tr>';
str += '</table></form>';
document.getElementById('respage').innerHTML = str;
}
function drawBudgetControls()
{
document.getElementById('rbcl').innerHTML = '<input ' + rett[30] + ' type="button" name="ok" value="Modify research budget" onClick="validateBudget(); return false;" />';
document.getElementById('rbcr').innerHTML = '<input ' + rett[31] + ' type="button" name="cancel" value="Reset to previous values" onClick="resetBudget(); return false;" />';
}
function drawDiplomacyRestrained(d)
{
var str = '<h1>Give / receive scientific assistance</h1>';
str += '<p>Your account is too young to use this feature. You must wait for ' + d + ' more day' + (d > 1 ? 's' : '') + '.</p>';
document.getElementById('respage').innerHTML = str;
}
function drawRDSentAlready()
{
var str = '<h1>Send scientific assistance</h1>';
str += '<p>We already sent an assistance offer in the last 22 hours (<b>' + formatDate(rdSentOffer.time) + '</b>).<br/>';
str += 'We offered to give <b>' + rdSentOffer.player + '</b> ';
if (rdSentOffer.tech == "")
str += 'research assistance';
else
str += 'the "<b>' + rtTitles[rdSentOffer.tech] + '</b>" technology';
if (rdSentOffer.price > 0)
str += ' in exchange for <b>&euro;' + formatNumber(rdSentOffer.price) + '</b>';
str += '; the offer ';
if (rdSentOffer.status == "P")
str += 'is <b>still pending</b>.';
else if (rdSentOffer.status == "A")
str += 'has been <b>accepted</b>.';
else
str += 'has been <b>declined</b>.';
str += '</p>';
document.getElementById('rdgive').innerHTML = str;
}
function drawRDSendForm()
{
var i, str = '<h1>Send scientific assistance</h1>';
str += '<table cellspacing="0" cellpadding="0"><tr><td class="div20">&nbsp;</td>';
str += '<td>Offer&nbsp;</td><td';
if (rdAvailTech.length > 0)
{
str += ' onClick="rdfType=0;document.getElementById(\'rdstype0\').checked=true" >';
str += '<input type="radio" ' + rett[40] + ' name="rdstype" id="rdstype0" value="0"';
if (rdfType == 0)
str += ' checked="checked"';
str += ' onClick="rdfType = 0;" /';
}
str += '> research assistance</td><td>to player <input ' + rett[41] + ' type="text" name="rdsto" id="rdsto" value="';
str += '" onChange="rdfTarget=this.value" /> in exchange for &euro;<input ' + rett[42] + ' type="text" name="rdsprice" id="rdsprice" value="';
str += '" onChange="rdfPrice=this.value" /></td><td class="div10"><input ' + rett[43] + ' type="button" value="Send offer" ';
str += 'onClick="sendOffer();return false" /></td></tr>';
if (rdAvailTech.length > 0)
{
str += '<tr><td colspan="2">&nbsp;</td><td onClick="rdfType=1;document.getElementById(\'rdstype1\').checked=true"';
str += '><input type="radio" ' + rett[44] + ' name="rdstype" id="rdstype1" value="1"';
if (rdfType == 1)
str += ' checked="checked"';
str += ' onClick="rdfType = 1;" /> the <select ' + rett[45] + ' name="rdstech" id="rdstech"';
str += ' onChange="rdfTech=parseInt(this.options[this.selectedIndex].value, 10)">';
str += '<option value="0">-- select --</option>';
for (i=0;i<rdAvailTech.length;i++)
{
str += '<option value="'+rdAvailTech[i]+'"';
if (rdAvailTech[i] == rdfTech)
str += ' selected="selected"';
str += '>' + rtTitles[rdAvailTech[i]] + '</option>';
}
str += '</select> technology</td><td colspan="2">&nbsp;</td></tr>';
}
str += '</table>';
document.getElementById('rdgive').innerHTML = str;
document.getElementById('rdsto').value = rdfTarget;
document.getElementById('rdsprice').value = rdfPrice;
}
function drawRDPending()
{
var str = '<h1>Received assistance offers</h1>';
if (rdRecOffers.length == 0)
str += '<p>No assistance offers have been received.</p>';
else
{
var n, m, i;
n = rdRecOffers.length;
m = n % 5;
n = (n-m)/5 + (m>0?1:0);
if (rdRecPage >= n)
rdRecPage = n-1;
str += '<table cellspacing="0" cellpadding="0"><tr><td class="div20" rowspan="3">&nbsp;</td><td>Page ';
if (n == 1)
str += "1 / 1";
else
{
str += '<select ' + rett[50] + ' name="rdrpage" id="rdrpage" onChange="rdRecToPage(this.options[this.selectedIndex].value)">';
for (i=0;i<n;i++)
{
str += '<option value="' + i + '"';
if (rdRecPage == i)
str += ' selected="selected"';
str += '>' + (i+1) + '</option>';
}
str += '</select> / ' + n;
}
str += '</td></tr><tr><td>&nbsp;</td></tr><tr><td><table class="list" cellspacing="0" cellpadding="0">';
var r = new Array(
'Unfortunately, we do not have enough cash to accept this offer.',
'Since we have already accepted another offer in the past 22 hours, we cannot accept this offer.',
'However, we have already discovered or are about to discover this technology.',
'However, we do not have the scientific knowledge required to accept this offer.'
);
for (i=5*rdRecPage;i<rdRecOffers.length&&i<5*(rdRecPage+1);i++)
{
str += '<tr><td>Player <b>' + rdRecOffers[i].player + '</b> has offered to give us ';
if (rdRecOffers[i].tech == "")
str += '<b>scientific assistance</b>';
else
str += 'the "<b>' + rtTitles[rdRecOffers[i].tech] + '</b>" technology';
if (rdRecOffers[i].price > 0)
str += ' in exchange for <b>&euro;' + formatNumber(rdRecOffers[i].price) + '</b>';
str += '. The offer was received at ' + formatDate(rdRecOffers[i].time) + '.<br/>';
if (rdRecOffers[i].status2 == 0)
{
str += '<input ' + rett[51] + ' type="button" value="Accept" onClick="acceptOffer(' + rdRecOffers[i].id + ');return false" />';
str += ' <input ' + rett[52] + ' type="button" value="Decline" onClick="rejectOffer(' + rdRecOffers[i].id + ');return false" />';
}
else
{
str += r[rdRecOffers[i].status2 - 1] + ' You may either decline the offer or let it expire.<br/>';
str += '<input type="button" ' + rett[52] + ' value="Decline" onClick="rejectOffer(' + rdRecOffers[i].id + ');return false" />';
}
str += '<hr/></td></tr>';
}
str += '</table></td></tr></table>';
}
document.getElementById('rdrec').innerHTML = str;
}
function drawRDHistory()
{
var str = '<h1>History</h1>';
if (rdHistory.length == 0)
str += '<p>The history is empty.</p>';
else
{
var n, m, i;
n = rdHistory.length;
m = n % 5;
n = (n-m)/5 + (m>0?1:0);
if (rdHistPage >= n)
rdHistPage = n-1;
str += '<table cellspacing="0" cellpadding="0"><tr><td class="div20" rowspan="3">&nbsp;</td><td>Page ';
if (n == 1)
str += "1 / 1";
else
{
str += '<select ' + rett[60] + ' name="rdhpage" id="rdhpage" onChange="rdHistToPage(this.options[this.selectedIndex].value)">';
for (i=0;i<n;i++)
{
str += '<option value="' + i + '"';
if (rdHistPage == i)
str += ' selected="selected"';
str += '>' + (i+1) + '</option>';
}
str += '</select> / ' + n;
}
str += '</td></tr><tr><td>&nbsp;</td></tr><tr><td><table class="list" cellspacing="0" cellpadding="0">';
for (i = 5 * rdHistPage; i < rdHistory.length && i < 5 * (rdHistPage + 1); i ++) {
str += '<tr><td>';
if (rdHistory[i].type == "R")
str +='Player <b>' + rdHistory[i].player + '</b> offered to give us ';
else
str +='We offered to give player <b>' + rdHistory[i].player + '</b> ';
if (rdHistory[i].tech == "")
str += '<b>scientific assistance</b>';
else
str += 'the "<b>' + rtTitles[rdHistory[i].tech] + '</b>" technology';
if (rdHistory[i].price > 0)
str += ' in exchange for <b>&euro;' + formatNumber(rdHistory[i].price) + '</b>';
str += '. The offer was ' + (rdHistory[i].type == "R" ? 'received' : 'sent') + ' at ' + formatDate(rdHistory[i].time);
str += ' and ';
if (rdHistory[i].status == "E")
str += "<b>expired</b> one day later.";
else if (rdHistory[i].status == "A")
str += "was <b>accepted</b>.";
else
str += "was <b>declined</b>.";
str += '<hr/></td></tr>';
}
str += '</table></td></tr></table>';
}
document.getElementById('rdhist').innerHTML = str;
}
function confirmSendOffer(tp, tc, pl, pr)
{
var str = "You are about to offer ";
if (tp == 0)
str += "scientific assistance";
else
str += 'data on the "' + rtTitles[tc] + '" technology';
str += '\nto ' + pl;
if (pr > 0)
str += ' in exchange for ' + formatNumber(pr.toString()) + ' euros.';
str += '\nYou will not be able to make another offer for 24 hours.';
return confirm(str);
}
function rdOfferError(ec)
{
var str = "Error :\n";
switch (ec)
{
case 1: str += "You have not selected a technology to offer."; break
case 2: str += "You have not specified a player to send the offer to."; break;
case 3: str += "The price you specified is invalid."; break;
case 4: str += "This player does not exist."; break;
case 5: str += "You do not seem to have this technology."; break;
case 6: str += "You can't send a diplomatic offer to yourself."; break;
case 7: str += "This player is on vacation."; break;
case 8: str += "Invalid data received."; break;
case 9: str += "It seems you have already sent an offer in the past 24h."; break;
case 10: str += "This player is under Peacekeeper protection."; break;
case 200: str += "You can't send diplomatic offers while in vacation mode."; break;
case 201: str += "You can't send diplomatic offers while under Peacekeeper protection."; break;
default: str += "An unknown error has happened ("+ec+")."; break;
}
alert(str);
}
function rdAcceptError(ec) {
var str = "Error :\n";
switch (ec) {
case 1: str += "You do not have enough cash to accept this offer."; break
case 2: str += "You have already accepted this offer."; break;
case 3: str += "You have already declined this offer."; break;
case 4: str += "Unknown offer identifier."; break;
case 5: str += "You don't have the dependencies for this technology."; break;
case 200: str += "You can't accept or reject diplomatic offers while in vacation mode."; break;
case 201: str += "You can't accept diplomatic offers while under Peacekeeper protection."; break;
default: str += "An unknown error has happened ("+ec+")."; break;
}
alert(str);
}
function confirmAcceptOffer(i)
{
var str = "Are you sure you want to accept " + rdRecOffers[i].player + "'s offer to\ngive us ";
if (rdRecOffers[i].type == "R")
str += "scientific assistance";
else
str += "the \"" + rtTitles[rdRecOffers[i].tech] + "\" technology";
if (rdRecOffers[i].price > 0)
str += " in exchange for\n" + formatNumber(rdRecOffers[i].price) + " euros";
str += "?";
return confirm(str);
}
function confirmRejectOffer(i)
{
var str = "Are you sure you want to decline " + rdRecOffers[i].player + "'s offer to\ngive us ";
if (rdRecOffers[i].type == "R")
str += "scientific assistance";
else
str += "the \"" + rtTitles[rdRecOffers[i].tech] + "\" technology";
if (rdRecOffers[i].price > 0)
str += " in exchange for\n" + formatNumber(rdRecOffers[i].price) + " euros";
str += "?";
return confirm(str);
}

View file

@ -0,0 +1,655 @@
var pageMode;
var pageModes = new Array('Topics', 'Laws', 'Attributions', 'Diplomacy');
var puTimer;
var onGetComplete;
var rtGetData = new Array(); // Research topics for which data must be requested
var rtTitles = new Array(); // Research topics titles
var rtDescriptions = new Array(); // Research topics descriptions
var rtCosts = new Array(); // Research topics implementation cost
var rtTypes = new Array(); // Research topics types
var rtExpanded = new Array(); // Topics for which the description is being displayed
var rtAll; // All research topics or laws
var rtCompleted; // Completed researches
var rtImplemented; // Implemted technologies
var rtForeseen; // Foreseen breakthroughs
var rtForeseenP; // Foreseen breakthroughs completion percentages
var lEnacted; // Enacted laws
var lTimeRevoke; // Time left before a law can be revoked
var lAvailable; // Available laws
var lTimeEnact; // Time left before a law can be enacted again
var rbPoints; // Research points / day
var rbPercentage; // Percentage going to each research type
var rbOriPercentage; // Percentage going to each research type before player modification
var rbCatPoints; // Points going to each category
var rbLocks; // Locked categories
var rdDiplomacyDelay;
var rdSentOffer; // Offer sent by the player, false if none
var rdRecOffers; // List of received offers
var rdHistory; // List of past offers
var rdAvailTech; // List of available technologies
var rdRecPage = 0; // Current page for the received offers list
var rdHistPage = 0; // Current page for the history
var rdfType = 0;
var rdfTech = 0;
var rdfTarget = "";
var rdfPrice = "";
var rett;
function initResearchPage(data)
{
setPage(data);
}
function showDescription(id)
{
rtExpanded.push(id);
if (pageMode == 'Topics')
topicsDisplayOk();
else if (pageMode == 'Laws')
lawsDisplayOk();
}
function hideDescription(id)
{
var t = rtExpanded, i;
rtExpanded = new Array();
for (i=0;i<t.length;i++)
if (t[i] != id)
rtExpanded.push(t[i]);
if (pageMode == 'Topics')
topicsDisplayOk();
else if (pageMode == 'Laws')
lawsDisplayOk();
}
function sortResearch(a,b)
{
var ta=rtTitles[a],tb=rtTitles[b];
return (ta > tb ? 1 : -1);
}
function descriptionsReceived(data)
{
if (data != "")
{
var i, l, a = data.split("\n");
l = a.length / 4;
for (i=0;i<l;i++)
{
var tmp = a[i*4+2].split('#');
rtTitles[a[i*4]] = a[i*4+1];
rtCosts[a[i*4]] = tmp[0];
rtTypes[a[i*4]] = tmp[1];
rtDescriptions[a[i*4]] = a[i*4+3];
}
}
rtGetData = new Array();
eval(onGetComplete);
}
function setPage(mode)
{
pageMode = mode;
if (puTimer)
clearTimeout(puTimer);
writeLinks();
document.getElementById('respage').innerHTML = getLoadingText();
var str = 'x_get'+mode+'Data(build'+mode+'Display);'
eval(str);
}
function writeLinks()
{
var str = '', i;
for (i=0;i<pageModes.length;i++)
{
if (str != '')
str += ' - ';
if (pageModes[i] != pageMode)
str += '<a href="#" ' + rett[70+i] + ' onClick="x_setMode(\'' + pageModes[i] + '\', setPage); return false;">';
else
str += '<b><u>';
str += pageTitles[i];
if (pageModes[i] != pageMode)
str += '</a>';
else
str += '</u></b>';
}
document.getElementById('respsel').innerHTML = str;
}
function buildTopicsDisplay(data)
{
var all = data.split('!');
var t, i;
rtCompleted = (all[1] == "" ? new Array() : all[1].split('#'));
rtAll = rtCompleted;
rtImplemented = (all[0] == "" ? new Array() : all[0].split('#'));
rtAll = rtAll.concat(rtImplemented);
t = all[2].split('#');
rtForeseen = new Array();
rtForeseenP = new Array();
for (i=0;all[2] != "" && i<t.length/2;i++)
{
rtForeseen[i] = t[i*2];
rtForeseenP[t[i*2]] = t[i*2+1];
}
rtAll = rtAll.concat(rtForeseen);
for (i=0;i<rtAll.length;i++)
{
if (!rtTitles[rtAll[i]])
rtGetData.push(rtAll[i]);
}
if (rtGetData.length > 0)
{
onGetComplete = 'topicsDisplayOk();';
x_getDescriptions(rtGetData.join('#'), descriptionsReceived);
}
else
topicsDisplayOk();
puTimer = setTimeout('x_getTopicsData(buildTopicsDisplay)', 900000);
}
function topicsDisplayOk()
{
rtCompleted.sort(sortResearch);
rtImplemented.sort(sortResearch);
rtForeseen.sort(sortResearch);
document.getElementById('respage').innerHTML = getTopicsPage();
}
function implementResult(data) {
if (data == "OK") {
updateHeader();
setPage('Topics');
} else {
var a = data.split('#');
implError(parseInt(a[1], 10));
}
}
function implementTechnology(id)
{
if (!confirmTech(id))
return;
x_implementTechnology(id, implementResult);
}
function buildLawsDisplay(data)
{
var t, i;
t = data.split('#');
lEnacted = new Array();
lTimeRevoke = new Array();
lAvailable = new Array();
lTimeEnact = new Array();
for (i=0;data != "" && i<t.length/2;i++)
{
var j = parseInt(t[i*2+1], 10);
if (j <= 0)
{
lAvailable.push(t[i*2]);
lTimeEnact[t[i*2]] = -j;
}
else
{
lEnacted.push(t[i*2]);
lTimeRevoke[t[i*2]] = (j-1);
}
}
rtAll = lEnacted.concat(lAvailable);
for (i=0;i<rtAll.length;i++)
{
if (!rtTitles[rtAll[i]])
rtGetData.push(rtAll[i]);
}
if (rtGetData.length > 0)
{
onGetComplete = 'lawsDisplayOk();';
x_getDescriptions(rtGetData.join('#'), descriptionsReceived);
}
else
lawsDisplayOk();
puTimer = setTimeout('x_getLawsData(buildLawsDisplay)', 900000);
}
function lawsDisplayOk()
{
lEnacted.sort(sortResearch);
lAvailable.sort(sortResearch);
document.getElementById('respage').innerHTML = getLawsPage();
}
function switchLawResult(data) {
if (data == "OK") {
updateHeader();
setPage('Laws');
} else {
var a = data.split('#');
slawError(parseInt(a[1], 10));
}
}
function revokeLaw(id)
{
if (!confirmRevoke(id))
return;
x_switchLaw(id, switchLawResult);
}
function enactLaw(id)
{
if (!confirmEnact(id))
return;
x_switchLaw(id, switchLawResult);
}
function buildAttributionsDisplay(data)
{
var a = data.split('#'), i;
rbPoints = a[0];
rbOriPercentage = new Array();
for (i=0;i<rTypes.length;i++)
rbOriPercentage[i] = parseInt(a[i+1], 10);
if (!rbPercentage)
{
rbPercentage = (new Array()).concat(rbOriPercentage);
rbLocks = new Array();
}
computeCatPoints();
if (!document.getElementById('totRPoints'))
drawAttributionsDisplay();
updateAttributionsValues();
puTimer = setTimeout('x_getAttributionsData(buildAttributionsDisplay)', 900000);
}
function computeCatPoints()
{
var i, s;
s = 0;
rbCatPoints = new Array();
for (i=0;i<rTypes.length;i++)
{
rbCatPoints[i] = Math.floor(rbPercentage[i] * rbPoints / 100);
s += rbCatPoints[i];
}
for (i=0;s<rbPoints;i=(i+1)%rTypes.length)
{
rbCatPoints[i] ++;
s++;
}
}
function updateAttributionsValues()
{
var i, l, s, t, d;
document.getElementById('totRPoints').innerHTML = formatNumber(rbPoints);
l = (rbLocks.length == rTypes.length - 2);
s = '!' + rbLocks.join('!') + '!';
d = false;
for (i=0;i<rTypes.length;i++)
{
document.getElementById('rbval' + i).innerHTML = rbPercentage[i];
document.getElementById('rbpts' + i).innerHTML = formatNumber(rbCatPoints[i].toString());
if (s.indexOf('!' + i + '!') != -1)
t = '<img ' + rett[80] + ' src="'+staticurl+'/beta5/pics/lock_'+color+'.gif" alt="[L]" onClick="switchLock('+i+');" />';
else if (l)
t = '&nbsp;';
else
t = '<img ' + rett[81] + ' src="'+staticurl+'/beta5/pics/unlock_'+color+'.gif" alt="[U]" onClick="switchLock('+i+');" />';
document.getElementById('rblock'+i).innerHTML = t;
d = d || (rbPercentage[i] != rbOriPercentage[i]);
}
if (d)
drawBudgetControls();
else
{
document.getElementById('rbcl').innerHTML = '&nbsp;';
document.getElementById('rbcr').innerHTML = '&nbsp;';
}
}
function switchLock(l)
{
var i, a, s = '!' + rbLocks.join('!') + '!';
if (s.indexOf('!' + l + '!') == -1)
rbLocks.push(l);
else
{
a = new Array();
for (i=0;i<rbLocks.length;i++)
if (rbLocks[i] != l)
a.push(rbLocks[i]);
rbLocks = a;
}
updateAttributionsValues();
}
function changeAttr(a, v)
{
var i, j, k;
var rv, orv;
var ls = '!' + rbLocks.join('!') + '!', lv;
var mv = new Array(), mi = new Array(), m;
if (rbPercentage[a] + v < 0)
rv = -rbPercentage[a];
else if (rbPercentage[a] + v > 100)
rv = 100 - rbPercentage[a];
else
rv = v;
if (rv == 0)
return;
mv = mv.concat(rbPercentage);
mv.sort(new Function('a', 'b', 'return a - b'));
m = '';
for (i=0;i<mv.length;i++)
{
k = (rv < 0) ? i : (mv.length - (i+1));
for (j=0;j<mv.length;j++)
if ( mv[k] == rbPercentage[j]
&& m.indexOf('!' + j + '!') == -1
&& ls.indexOf('!' + j + '!') == -1
&& j != a
)
{
mi.push(j);
break;
}
m = '!' + mi.join('!') + '!';
}
rs = Math.abs(rv)/rv;
orv = 0;
for (i=0;rv!=0&&orv!=mi.length;i=(i+1)%mi.length)
{
orv ++;
j = mi[i];
if (rbPercentage[j] - rs < 0 || rbPercentage[j] - rs > 100)
continue;
rbPercentage[a] += rs;
rbPercentage[j] -= rs;
rv -= rs;
orv = 0;
}
computeCatPoints();
updateAttributionsValues();
}
function resetBudget()
{
rbPercentage = (new Array()).concat(rbOriPercentage);
rbLocks = new Array();
computeCatPoints();
updateAttributionsValues();
}
function validateBudget()
{
var s = rbPercentage.join('#');
x_validateBudget(s, budgetValidated);
}
function budgetValidated(data) {
if (data == "OK") {
rbOriPercentage = (new Array()).concat(rbPercentage);
computeCatPoints();
updateAttributionsValues();
} else {
var a = data.split('#');
budgetError(parseInt(a[1], 10));
}
}
function ResearchOffer(id,type,status,status2,price,tech,time,player)
{
this.id = id;
this.type = type;
this.status = status;
this.status2 = status2;
this.price = price;
this.tech = tech;
this.time = parseInt(time, 10);
this.player = player;
var d = new Date();
var t = d.getTime();
t = (t - (t % 1000)) / 1000;
this.today = (t - this.time <= rdDiplomacyDelay);
}
function buildDiplomacyDisplay(data)
{
if (data.indexOf('\n') == -1)
drawDiplomacyRestrained(data);
else
{
var i, o, a = data.split('\n'), tl;
rdDiplomacyDelay = parseInt(a.shift(), 10);
tl = a.shift().split('#');
rdAvailTech = new Array();
rtGetData = new Array();
for (i=0;i<tl.length;i++)
{
if (tl[i] == "")
continue;
rdAvailTech.push(tl[i]);
if (!rtTitles[tl[i]])
rtGetData.push(tl[i]);
}
tl = '!' + rtGetData.join('!!') + '!';
rdSentOffer = false;
rdRecOffers = new Array();
rdHistory = new Array();
if (a.length > 1)
{
for (i=0;i<a.length;i+=2)
{
var l = a[i].split('#');
o = new ResearchOffer(l[0],l[1],l[2],l[6],l[3],l[4],l[5],a[i+1]);
if (o.type == "S" && o.today)
rdSentOffer = o;
else if (o.type == "R" && o.status == "P")
rdRecOffers.push(o);
else
rdHistory.push(o);
if (o.tech != "" && !rtTitles[o.tech] && tl.indexOf('!' + o.tech + '!') == -1)
{
rtGetData.push(o.tech);
tl += '!' + o.tech + '!';
}
}
}
drawDiplomacyLayout();
if (rtGetData.length > 0)
{
onGetComplete = 'drawDiplomacyPage();';
x_getDescriptions(rtGetData.join('#'), descriptionsReceived);
}
else
drawDiplomacyPage();
}
puTimer = setTimeout('x_getDiplomacyData(buildDiplomacyDisplay)', 900000);
}
function drawDiplomacyLayout()
{
var str = '<form action="?"><table cellspacing="0" cellpadding="0"><tr><td colspan="2" id="rdgive">&nbsp;</td></tr>';
str += '<tr><td colspan="2">&nbsp;</td></tr>';
str += '<tr><td class="div2" id="rdrec">&nbsp;</td><td class="div2" id="rdhist">&nbsp;</td></tr></table></form>';
document.getElementById('respage').innerHTML = str;
}
function drawDiplomacyPage()
{
if (typeof rdSentOffer == "object")
drawRDSentAlready();
else
{
rdAvailTech.sort(sortResearch);
drawRDSendForm();
}
drawRDPending();
drawRDHistory();
}
function sendOffer()
{
if (rdfType == 1 && rdfTech == 0)
{
rdOfferError(1);
return;
}
if (rdfTarget == "")
{
rdOfferError(2);
return;
}
var p;
if (rdfPrice != "")
{
p = parseInt(rdfPrice, 10);
if (rdfPrice != p.toString() || p < 0)
{
rdOfferError(3);
return;
}
}
else
p = 0;
if (!confirmSendOffer(rdfType, rdfTech, rdfTarget, p))
return;
x_sendOffer(rdfType, rdfTech, rdfTarget, p, offerSent);
}
function offerSent(data)
{
if (data.indexOf('ERR#') == 0)
{
var a = data.split("#");
a[1] = parseInt(a[1], 10);
rdOfferError(a[1]);
}
else
buildDiplomacyDisplay(data);
}
function acceptOffer(oid)
{
var i;
for (i=0;i<rdRecOffers.length&&rdRecOffers[i].id!=oid;i++) ;
if (i == rdRecOffers.length)
return;
if (!confirmAcceptOffer(i))
return;
x_acceptOffer(oid, offerAccepted);
}
function rejectOffer(oid)
{
var i;
for (i=0;i<rdRecOffers.length&&rdRecOffers[i].id!=oid;i++) ;
if (i == rdRecOffers.length)
return;
if (!confirmRejectOffer(i))
return;
x_declineOffer(oid, offerAccepted);
}
function offerAccepted(data)
{
if (data.indexOf('ERR#') == 0)
{
var a = data.split("#");
a[1] = parseInt(a[1], 10);
rdAcceptError(a[1]);
}
else
{
buildDiplomacyDisplay(data);
updateHeader();
}
}
function rdHistToPage(p)
{
rdHistPage = parseInt(p, 10);
drawRDHistory();
}

View file

@ -0,0 +1,78 @@
// Text for AccessDenied
TechTrade.AccessDenied.title = 'Access denied';
TechTrade.AccessDenied.mainText = 'You are not authorized to use the alliance technology trading tool.';
TechTrade.AccessDenied.allianceTxt = 'Your current rank in your alliance does not have this privilege.';
TechTrade.AccessDenied.noAllianceTxt = 'You are not a member of any alliance.';
// Loading texts
TechTrade.Page.loadingText = "Loading technology list, please wait...";
TechTrade.Page.subLoadingText = "Loading page, please wait...";
// Text for the menu
TechTrade.Menu.text = [ 'Main page', 'Requests', 'Alliance list', 'Change orders', 'View orders' ];
// Main page text
TechTrade.Page.Main.submitTitle = "Technology list submission";
TechTrade.Page.Main.ordersTitle = "Technology trading orders";
TechTrade.Page.Main.lastSubText = "You last submitted your technology list at <b>__LS__</b>.";
TechTrade.Page.Main.nextSubText = "You will be able to submit your technology list again after <b>__NS__</b>.";
TechTrade.Page.Main.noLastSubText = "You have never submitted your technology list.";
TechTrade.Page.Main.submitButtonText = "Submit technology list";
TechTrade.Page.Main.noOrdersText = "No technology trading orders.";
TechTrade.Page.Main.sendOrderTitle = "Technology to send";
TechTrade.Page.Main.sendOrder = "We've been order to send the <a href='manual?p=tech___TI__'>__TN__</a> technology to player <a href='message?a=c&ct=0&id=__PI__'>__PN__</a>. The order was received at __OR__.";
TechTrade.Page.Main.sendOrderObeyed = "We obeyed this order at __OE__.";
TechTrade.Page.Main.sendButtonText = "Send technology";
TechTrade.Page.Main.recOrderTitle = "Technology to receive";
TechTrade.Page.Main.recOrder = "Player <a href='message?a=c&ct=0&id=__PI__'>__PN__</a> has been order to send us the <a href='manual?p=tech___TI__'>__TN__</a> technology. The order was issued at __OR__";
TechTrade.Page.Main.recOrderObeyed = " and obeyed at __OE__.";
// Requests page text
TechTrade.Page.Request.title = "Technology requests";
TechTrade.Page.Request.noReqText = "No requests at this time"
TechTrade.Page.Request.fiveRequests = "You already have 5 requests, unable to add more.";
TechTrade.Page.Request.noAvailableTechs = "There are no technologies you can request at this time.";
TechTrade.Page.Request.addRequest = "Add request for the following technology: ";
TechTrade.Page.Request.addRequestManual = "View manual page";
TechTrade.Page.Request.addRequestAdd = "Add";
TechTrade.Page.Request.noSelection = "-- Select technology --";
TechTrade.Page.Request.delRequest = "delete";
TechTrade.Page.Request.increasePriority = "up";
TechTrade.Page.Request.decreasePriority = "down";
TechTrade.Page.Request.submitText = "Submit requests";
// List page text
TechTrade.Page.List.playerHdr = 'Player';
TechTrade.Page.List.lastSubHdr = 'Last submission';
TechTrade.Page.List.vacationHdr = 'On vacation';
TechTrade.Page.List.restrainedHdr = 'Restrained';
TechTrade.Page.List.boolText = ['No', 'Yes'];
TechTrade.Page.List.techStatus = ['New', 'Foreseen', 'Implemented', 'Law'];
TechTrade.Page.List.requested = "Requested";
TechTrade.Page.List.playersPerPage = 'Players / page:';
TechTrade.Page.List.techsPerPage = 'Technologies / page:';
// Orders viewing page
TechTrade.Page.ViewOrders.title = 'Current technology trading orders';
TechTrade.Page.ViewOrders.noOrders = 'No technology trading orders have been issued yet.';
TechTrade.Page.ViewOrders.playerHdr = 'Player';
TechTrade.Page.ViewOrders.sendHdr = 'Send technology';
TechTrade.Page.ViewOrders.recvHdr = 'Receive technology';
TechTrade.Page.ViewOrders.noOrders = 'No orders';
TechTrade.Page.ViewOrders.sendTech = '<a href="manual?p=tech___TI__" target="_blank">__TN__</a> to <b>__PN__</b><br/>Order issued at __OI__.';
TechTrade.Page.ViewOrders.techSent = 'Sent at __OE__.';
TechTrade.Page.ViewOrders.receiveTech = '<a href="manual?p=tech___TI__" target="_blank">__TN__</a> from <b>__PN__</b><br/>Order issued at __OI__.';
TechTrade.Page.ViewOrders.techReceived = 'Received at __OE__.';
// Orders edition page
TechTrade.Page.SetOrders.title = 'Set alliance technology trading orders';
TechTrade.Page.SetOrders.alreadySubmitted = 'Technology trading orders were last submitted at __LS__.<br/>It will be possible to set new trading orders at __NS__.';
TechTrade.OrdersEditor.cantTrade = 'This player can\'t trade technologies';
TechTrade.OrdersEditor.sendTech = '<a href="manual?p=tech___TI__" target="_blank">__TN__</a> to <b>__PN__</b>.';
TechTrade.OrdersEditor.recvTech = '<a href="manual?p=tech___TI__" target="_blank">__TN__</a> from <b>__PN__</b>.';
TechTrade.OrdersEditor.addOrder = 'Set order';
TechTrade.OrdersEditor.delOrder = 'Remove order';
TechTrade.OrdersEditor.editOrder = 'Change order';
TechTrade.OrdersEditor.willReceive = '<b>__PN__</b> will receive __SP1__ from __SP2__';
TechTrade.OrdersEditor.willSend = '<b>__PN__</b> will send __SP1__ to __SP2__';
TechTrade.OrdersEditor.ok = 'Confirm';
TechTrade.OrdersEditor.cancel = 'Cancel';
TechTrade.OrdersEditor.selectPlayer = '--- select player ---';
TechTrade.OrdersEditor.selectTech = '--- select technology ---';
TechTrade.OrdersEditor.submitOrders = 'Submit orders';
TechTrade.OrdersEditor.confirmSubmit = 'You are about to submit new orders for the alliance\'s tech trading.\nYou will not be able to change these orders for the following 24h.\nPlease confirm.';
TechTrade.OrdersEditor.submitting = 'The orders are being sent, please wait ...';
TechTrade.OrdersEditor.submitError = 'An error occured while sending the technology trading orders.\nThis error can have different reasons:\n- someone else submitted orders,\n- a tech list has been updated and is no longer compatible with your orders.\n';

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,6 @@
var tText = ['Previous tick', 'Next tick', 'Last tick', 'Time remaining', 'These ticks have stopped.'];
function getDaysText(p)
{
return "day" + (p?'s':'');
}

View file

@ -0,0 +1,177 @@
var ticks;
var tList;
var updateTimer;
var stDifference;
var nUpdates;
function Tick(id, first, interval, last)
{
this.id = id;
this.first = parseInt(first, 10);
this.interval = parseInt(interval, 10);
this.stopTime = (last != "") ? parseInt(last, 10) : -1;
this.started = true;
this.stDays = 0;
this.previous = 0;
this.next = 0;
this.last = 0;
this.remaining = 0;
this.compute = Tick_compute;
this.draw = Tick_draw;
this.setEnd = Tick_setEnd;
}
function Tick_setEnd(last)
{
this.stopTime = (last != "") ? parseInt(last, 10) : -1;
}
function Tick_compute(st)
{
var f = this.first % 86400;
var n = (st % 86400);
var tm = n + ((n<f) ? 86400 : 0) - f;
var nx = this.interval - tm % this.interval;
this.started = (st >= this.first);
if (!this.started)
{
var tl = this.first - st;
this.stDays = Math.floor((tl - (tl % 86400)) / 86400);
this.next = this.first;
this.remaining = this.next - (st + this.stDays * 86400);
this.last = -1;
return;
}
else
this.stDays = 0;
if (this.stopTime > -1)
{
var s = (this.stopTime - this.first);
var m = s % this.interval;
this.last = this.first + s - m
}
else
this.last = -1;
if (this.last != -1 && nx + st > this.last)
{
this.next = -1;
this.previous = this.last;
}
else
{
this.next = nx + st;
this.previous = this.next - this.interval;
this.remaining = nx;
}
}
function Tick_draw()
{
var str = '<p>' + tText[0]+ ': ';
if (this.started && this.previous >= this.first)
str += '<b>' + formatDate(this.previous) + '</b>';
else
str += '<b>N/A</b>';
str += '<br/>';
if (this.next != -1)
{
str += tText[1] + ': <b>' + formatDate(this.next + this.stDays * 86400) + '</b> (' + tText[3] + ': ';
if (!this.started)
str += '<b>' + this.stDays + '</b> ' + getDaysText(this.stDays > 1) + ', ';
str += '<b>';
var rh = (this.remaining - (this.remaining % 3600)) / 3600,
rm = (this.remaining - rh*3600 - (this.remaining % 60)) / 60,
rs = this.remaining - (rh*60+rm)*60;
var s = rh.toString();
if (s.length == 1)
s = '0' + s;
str += s + ':';
s = rm.toString();
if (s.length == 1)
s = '0' + s;
str += s + ':';
s = rs.toString();
if (s.length == 1)
s = '0' + s;
str += s + '</b>)';
if (this.last != -1)
{
str += '<br/>' + tText[2] + ': <b>' + formatDate(this.last) + '</b>';
}
}
else
str += '<b>' + tText[4] + '</b>';
str += '</p>';
document.getElementById('tick' + this.id).innerHTML = str;
}
function readInitString()
{
var l = document.getElementById('tickinit').innerHTML.split('#');
var now = Math.round((new Date().getTime()) / 1000);
var st = parseInt(l.shift(), 10);
stDifference = now - st;
ticks = new Array();
tList = new Array();
while (l.length > 0)
{
var t = new Tick(l.shift(), l.shift(), l.shift(), l.shift());
ticks[t.id] = t;
tList.push(t);
t.compute(st);
t.draw();
}
nUpdates = 0;
setTimeout('updateTicks()', 1000);
}
function updateTicks()
{
var i;
var now = Math.round((new Date().getTime()) / 1000) - stDifference;
var as = true;
for (i=0;i<tList.length;i++)
{
tList[i].compute(now);
tList[i].draw();
as = as && (tList[i].last != -1) && (tList[i].last < now);
}
if (as)
return;
nUpdates ++;
if (nUpdates < 300)
setTimeout('updateTicks()', 1000);
else
x_updateTicks(updateReceived);
}
function updateReceived(data)
{
var l = data.split('#');
var now = Math.round((new Date().getTime()) / 1000);
var st = parseInt(l.shift(), 10);
stDifference = now - st;
while (l.length > 0)
{
var id = l.shift();
ticks[id].setEnd(l.shift());
}
nUpdates = 0;
setTimeout('updateTicks()', 1000);
}

View file

@ -0,0 +1,20 @@
function makeNextText(name)
{
return "Next " + name + ": ";
}
function drawRoundRankings(points,rank)
{
var str;
if (points == "")
str = 'You are too weak to be in the overall round rankings.';
else
str = 'Your overall round ranking is <b>#' + formatNumber(rank) + '</b> (<b>' + formatNumber(points) + '</b> points)';
document.getElementById('rndrank').innerHTML = str;
}
function getDaysText(p)
{
return "day" + (p?'s':'');
}

View file

@ -0,0 +1,172 @@
var stDiff;
var ticks;
var nUpdates;
function Tick(id,first,interval,last,name)
{
this.id = id;
this.first = parseInt(first, 10);
this.interval = parseInt(interval, 10);
this.stopTime = (last != "") ? parseInt(last, 10) : -1;
this.name = name;
this.started = true;
this.stDays = 0;
this.previous = 0;
this.next = 0;
this.last = 0;
this.remaining = 0;
this.compute = Tick_compute;
this.draw = Tick_draw;
}
function Tick_compute(st)
{
var f = this.first % 86400;
var n = (st % 86400);
var tm = n + ((n<f) ? 86400 : 0) - f;
var nx = this.interval - tm % this.interval;
this.started = (st >= this.first);
if (!this.started)
{
var tl = this.first - st;
this.stDays = Math.floor((tl - (tl % 86400)) / 86400);
this.next = this.first;
this.remaining = this.next - (st + this.stDays * 86400);
this.last = -1;
return;
}
if (this.stopTime > -1)
{
var s = (this.stopTime - this.first);
var m = s % this.interval;
this.last = this.first + s - m
}
else
this.last = -1;
if (this.last != -1 && nx + st > this.last)
{
this.next = -1;
this.previous = this.last;
}
else
{
this.next = nx + st;
this.previous = this.next - this.interval;
this.remaining = nx;
}
}
function Tick_draw()
{
var str = makeNextText(this.name);
if (this.next != -1)
{
if (!this.started)
str += '<b>' + this.stDays + '</b> ' + getDaysText(this.stDays > 1) + ', ';
str += '<b>'
var rh = (this.remaining - (this.remaining % 3600)) / 3600,
rm = (this.remaining - rh*3600 - (this.remaining % 60)) / 60,
rs = this.remaining - (rh*60+rm)*60;
var s = rh.toString();
if (s.length == 1)
s = '0' + s;
str += s + ':';
s = rm.toString();
if (s.length == 1)
s = '0' + s;
str += s + ':';
s = rs.toString();
if (s.length == 1)
s = '0' + s;
str += s;
}
else
str = '<b>N/A';
str += '</b>';
return str;
}
function initPage() {
drawUniversePage(document.getElementById('init-data').value);
}
function drawUniversePage(data)
{
var l = data.split('\n');
// Get universe information
var a = l.shift().split('#');
document.getElementById('npl').innerHTML = formatNumber(a[0]);
document.getElementById('nnpl').innerHTML = formatNumber(a[1]);
document.getElementById('nnsys').innerHTML = formatNumber(a[2]);
document.getElementById('avgf').innerHTML = formatNumber(a[3]);
document.getElementById('avgt').innerHTML = formatNumber(a[4]);
// Get protection zone information
// a = l.shift().split('#');
/* document.getElementById('sznpl').innerHTML = formatNumber(a[0]);
document.getElementById('sznnpl').innerHTML = formatNumber(a[1]);
document.getElementById('sznnsys').innerHTML = formatNumber(a[2]);
document.getElementById('szavgf').innerHTML = formatNumber(a[3]);
document.getElementById('szavgt').innerHTML = formatNumber(a[4]);
// Time left in protection should be drawn in the LD file */
// Rankings
a = l.shift().split('#');
document.getElementById('rknplayers').innerHTML = formatNumber(a[0]);
document.getElementById('genpts').innerHTML = formatNumber(a[1]);
document.getElementById('genrank').innerHTML = '#' + formatNumber(a[2]);
document.getElementById('civpts').innerHTML = formatNumber(a[3]);
document.getElementById('civrank').innerHTML = '#' + formatNumber(a[4]);
document.getElementById('finpts').innerHTML = formatNumber(a[5]);
document.getElementById('finrank').innerHTML = '#' + formatNumber(a[6]);
document.getElementById('milpts').innerHTML = formatNumber(a[7]);
document.getElementById('milrank').innerHTML = '#' + formatNumber(a[8]);
drawRoundRankings(a[9],a[10]);
document.getElementById('idpts').innerHTML = formatNumber(a[11]);
document.getElementById('idrank').innerHTML = '#' + formatNumber(a[12]);
// Time to ticks
a = l.shift().split('#');
var now = Math.round((new Date().getTime()) / 1000);
var str = '';
stDiff = now - parseInt(a.shift(),10);
ticks = new Array();
while (l.length > 0)
{
a = l.shift().split('#');
var t = new Tick(a.shift(), a.shift(), a.shift(), a.shift(), a.join('#'));
ticks.push(t);
t.compute(now - stDiff);
str += t.draw() + "<br/>";
}
document.getElementById('ticks').innerHTML = str;
nUpdates = 0;
setTimeout('updateDisplay()', 1000);
}
function updateDisplay()
{
var now = Math.round((new Date().getTime()) / 1000) - stDiff;
var i, str = '';
for (i=0;i<ticks.length;i++)
{
ticks[i].compute(now);
str += ticks[i].draw() + "<br/>";
}
document.getElementById('ticks').innerHTML = str;
nUpdates ++;
if (nUpdates == 12)
setTimeout('x_getInformation(drawUniversePage)', 1000);
else
setTimeout('updateDisplay()', 1000);
}

View file

@ -0,0 +1,57 @@
function rpc_alertSupport()
{
alert("LegacyWorlds fatal error\nIt seems your browser has no support for asynchronous JavaScript.\nYou must upgrade your browser.");
}
function rpc_alertFunction(name)
{
alert("LegacyWorlds bug\nAn undefined RPC function has been called ('" + name + "')\nThis is a bug, please report it to webmaster@legacyworlds.com.");
}
function rpc_alertCallback(name, aType, nArgs)
{
var str = 'Dumping args[]:\n' + nArgs.join('\n');
alert("LegacyWorlds bug\nThe '"+name+"' RPC function was called without a callback function.\nThe last argument's type was: '"+aType
+ "'.\nThis is a bug, please report it to webmaster@legacyworlds.com.\n\n" + str);
}
function rpc_alertCallID(id)
{
alert("LegacyWorlds bug\nThe server returned data for call ID '"+id+"' which can't be found in the queue.\nThis is a bug, please report it to webmaster@legacyworlds.com.");
}
function rpc_showErrorPage() {
var str = '<h1>LegacyWorlds</h1><p>A connection error occured when the page tried to contact the server. This means that you were disconnected from the internet '
+ 'or that the server is currently unavailable.<br/><br/>You may try <a href="#" onclick="window.location.href=window.location.href">reloading the '
+ 'page</a> shortly if you wish to do so. Alternatively you can hang around and enjoy this cute error page.</p>';
var t = document.getElementsByTagName("body");
if (!t || !t[0])
return; // FIXME
t[0].innerHTML = str;
}
function rpc_alertFatalError(code) {
var codes = [
"Could not open configuration file", "Could not connect to database", "Failed to set up tracking data",
"Failed to set up tracking data", "Failed to set up tracking data", "Failed to set up tracking data",
'Invalid request', 'Invalid request', 'Page not found', 'Page not found', 'Internal error', 'Internal error',
"Failed to set up session data", "Failed to set up session data", "Failed to set up session data",
"Failed to set up session data", 'Internal error', 'Internal error', "Internal error", 'Internal error',
'Internal error', 'Internal error', 'Internal error', 'Internal error', 'Internal error', 'Internal error',
'Invalid extension', 'Unhandled extension', 'Internal error', 'Internal error', 'Resource not found',
];
alert("A fatal error occured on the server.\nError " + code + ": " + codes[code] + "\nSorry for the inconvenience.");
}
function rpc_alertKicked(reason) {
alert("You have been kicked from the game!\n" + (reason != "" ? ("Reason: " + reason) : "No reason was given"));
}
function rpc_alertUnkownError(data) {
alert("LegacyWorlds bug\nThe server sent an unknown error code: " + data + "\nThis is a bug, please report it to webmaster@legacyworlds.com.");
}
function rpc_alertUnknownStatus(text) {
alert("LegacyWorlds bug\nThe server sent an invalid RPC reply.\nThis is a bug, please report it to webmaster@legacyworlds.com."
+ ("\n" + text));
}

369
site/static/beta5/js/rpc.js Normal file
View file

@ -0,0 +1,369 @@
var rpc_objCode = '';
var rpc_defaultMethod = "GET";
var rpc_queueLock = false;
var rpc_lockLock = false;
var rpc_currentCalls = new Array();
var rpc_functions = new Array();
var rpc_failed = false;
// Calls a remote function on the server
function rpc_doCall(name, pArguments)
{
if (rpc_failed)
return;
var func = rpc_functions[name];
if (!func)
{
rpc_alertFunction(name);
return;
}
var args = new Array();
var callback, i;
for (i=0;i<pArguments.length-1;i++)
args[i] = encodeURIComponent(pArguments[i]);
callback = pArguments[i];
if (typeof callback != 'function')
{
rpc_alertCallback(name, typeof callback, args);
return;
}
rpc_setLock();
var nCall = new rpc_Call(func, args, callback);
rpc_currentCalls.push(nCall);
rpc_resetLock();
nCall.call();
}
// Locks the main RPC lock
function rpc_setLock()
{
while (rpc_queueLock)
{
while (rpc_lockLock) ;
rpc_lockLock = true;
if (!rpc_queueLock)
{
rpc_queueLock = true;
rpc_lockLock = false;
break;
}
rpc_lockLock = false;
}
}
// Unlocks the main RPC lock
function rpc_resetLock()
{
while (rpc_lockLock) ;
rpc_lockLock = true;
rpc_queueLock = false;
rpc_lockLock = false;
}
// Checks the queue of current calls for a specific identifier
function rpc_isCalling(id)
{
var i = rpc_currentCalls.length;
while (i>0)
{
i--;
if (rpc_currentCalls[i].id == id)
return true;
}
return false;
}
// Reads the queue and returns the RPC call identified by the ID passed by the
// caller. Returns null if the RPC call cannot be found.
function rpc_getCall(id)
{
for (i=0;i<rpc_currentCalls.length;i++)
if (rpc_currentCalls[i].id == id)
return rpc_currentCalls[i];
return null;
}
// Removes a call object from the list of calls in progress.
function rpc_removeCall(id)
{
var n = new Array();
for (i=0;i<rpc_currentCalls.length;i++)
if (rpc_currentCalls[i].id != id)
n.push(rpc_currentCalls[i]);
rpc_currentCalls = n;
return;
}
// Initialises an object that will be able to handle RPC calls
function rpc_initObject()
{
var A;
if (rpc_objCode == "E")
return null;
else if (rpc_objCode != "")
eval('A='+rpc_objCode);
else
{
try
{
A = new ActiveXObject("Msxml2.XMLHTTP");
rpc_objCode = 'new ActiveXObject("Msxml2.XMLHTTP")';
}
catch (e)
{
try
{
A=new ActiveXObject("Microsoft.XMLHTTP");
rpc_objCode = 'new ActiveXObject("Microsoft.XMLHTTP")';
}
catch (oc)
{
A = null;
}
}
if (!A && typeof XMLHttpRequest != "undefined")
{
A = new XMLHttpRequest();
rpc_objCode = "new XMLHttpRequest()";
}
}
if (!A && typeof A == "object" && rpc_objCode != "E")
{
rpc_objCode = "E";
rpc_alertSupport();
}
return A;
}
//-----------------------------------------------------------------
// rpc_Function object
//-----------------------------------------------------------------
// Initialises the object by specifying the name of the function,
// and its calling method. Adds the object to the function list, and
// generate the stub.
function rpc_Function(name, method)
{
this.name = name;
this.method = method ? method : rpc_defaultMethod;
rpc_functions[name] = this;
eval('x_'+name+'=function(){rpc_doCall("'+name+'",arguments)}');
}
//-----------------------------------------------------------------
// rpc_Call object
//-----------------------------------------------------------------
// Initialises the object using the function object, arguments and
// callback passed by the main function.
function rpc_Call(func, args, callback)
{
this.funcObj = func;
this.arguments = args;
this.callback = callback;
var rts = new Date().getTime();
while (rpc_isCalling(rts) || rts == "")
rts++;
this.id = rts;
this.inCall = false;
this.retries = 0;
this.timeout = null;
this.timestamp = 0;
this.object = null;
this.call = rpc_Call_call;
this.retry = rpc_Call_retry;
this.send = rpc_Call_send;
}
// Prepares a RPC call using the data stored within the object
function rpc_Call_call()
{
if (this.inCall)
return;
this.inCall = true;
this.send();
}
// Tries re-executing a RPC call
function rpc_Call_retry()
{
if (!this.inCall)
return;
delete this.object;
clearTimeout(this.timeout);
if (this.retries == 3)
{
rpc_failed = true;
rpc_showErrorPage();
rpc_resetLock();
return;
}
this.retries ++;
rpc_resetLock();
this.send();
}
// Sends a request to the server
function rpc_Call_send()
{
var uri = rpc_pageURI;
var postData, mks;
var i, obj;
mks = 'rs=' + escape(this.funcObj.name);
if (this.arguments.length)
mks += '&rsargs[]=' + this.arguments.join('&rsargs[]=');
mks += '&rsId=' + this.id;
if (this.funcObj.method == "GET")
{
postData = null;
uri += '?' + mks;
}
else
postData = mks;
obj = rpc_initObject();
if (!obj)
{
rpc_setLock();
rpc_failed = true;
rpc_resetLock();
return;
}
obj.open(this.funcObj.method, uri, true);
if (this.funcObj.method == "POST")
{
obj.setRequestHeader("Method", "POST " + uri + " HTTP/1.1");
obj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
}
eval('obj.onreadystatechange=function(){rpc_Call_returned('+this.id+')}');
this.timeout = setTimeout('rpc_Call_timeout('+this.id+')', 25000);
this.object = obj;
obj.send(postData);
delete obj;
}
// This function is used as the callback for all RPC functions
function rpc_Call_returned(id)
{
rpc_setLock();
if (rpc_failed)
{
rpc_resetLock();
return;
}
var c = rpc_getCall(id);
if (!c || !c.inCall)
{
rpc_failed = true;
rpc_resetLock();
rpc_alertCallID(id);
return;
}
var obj = c.object;
if (obj.readyState != 4)
{
rpc_resetLock();
return;
}
try
{
if (obj.status != 200)
{
c.retry();
return;
}
}
catch (e)
{
c.retry();
return;
}
var stat = obj.responseText.charAt(0);
var data = obj.responseText.substring(2);
if (stat == "-") {
rpc_failed = true;
if (data == "m" || data == "a") {
window.location.href=window.location.href;
} else if (data.indexOf('f:') == 0) {
rpc_alertFatalError(data.substring(2));
} else if (data.indexOf('k:') == 0) {
rpc_alertKicked(data.substring(2));
window.location.href=window.location.href;
} else {
rpc_alertUnknownError(data);
rpc_showErrorPage();
}
return;
} else if (stat != '+') {
rpc_failed = true;
rpc_alertUnknownStatus(stat.charCodeAt(0) + " " + stat + "\n" + obj.responseText);
rpc_showErrorPage();
return;
}
c.inCall = false;
clearTimeout(c.timeout);
c.timestamp = new Date().getTime();
rpc_removeCall(c.id);
rpc_resetLock();
c.callback(data);
}
// Timeout function
function rpc_Call_timeout(id)
{
rpc_setLock();
if (rpc_failed)
{
rpc_resetLock();
return;
}
var c = rpc_getCall(id);
if (!c || !c.inCall || (new Date().getTime()) - c.timestamp < 23000)
{
rpc_resetLock();
return;
}
c.object.abort();
c.object = null;
c.retry();
}

View file

@ -0,0 +1,103 @@
var thmcls_hdTimer;
var thmcls_stTimer;
var thmcls_msgIcon = null, thmcls_milock = false, thmcls_dIcon;
var thm_sTime;
function thmcls_activateMsgBlink() {
if (thmcls_milock) {
setTimeout('thmcls_activateMsgBlink()', 500);
return;
}
thmcls_milock = true;
if (!thmcls_msgIcon) {
thmcls_dIcon = false;
thmcls_msgIcon = setTimeout('thmcls_blinkMsgBlink()', 200);
}
thmcls_milock = false;
}
function thmcls_disableMsgBlink() {
if (thmcls_milock) {
setTimeout('thmcls_disableMsgBlink()', 500);
return;
}
thmcls_milock = true;
clearTimeout(thmcls_msgIcon);
thmcls_msgIcon = null;
var e = document.getElementById('msgmenu');
if (typeof e.oldbgc != 'undefined') {
e.bgColor = e.oldbgc;
}
thmcls_milock = false;
}
function thmcls_blinkMsgBlink() {
if (thmcls_milock) {
setTimeout('thmcls_blinkMsgBlink()', 50);
return;
}
thmcls_milock = true;
var e = document.getElementById('msgmenu');
if (thmcls_dIcon) {
e.oldbgc = e.bgColor;
e.bgColor = '#3F3F3F';
} else {
e.bgColor = e.oldbgc;
}
thmcls_dIcon = !thmcls_dIcon;
thmcls_msgIcon = setTimeout('thmcls_blinkMsgBlink()', 1000);
thmcls_milock = false;
}
function thmcls_updateTime() {
thm_sTime ++;
document.getElementById('jsservtm').innerHTML = formatDate(thm_sTime);
thmcls_stTimer = setTimeout('thmcls_updateTime()', 1000);
}
function thmcls_writeHeader(data) {
if (thmcls_stTimer) {
clearTimeout(thmcls_stTimer);
}
var a = data.split("#");
thm_sTime = parseInt(a.shift(), 10);
document.getElementById('jsservtm').innerHTML = formatDate(thm_sTime);
document.getElementById('jspname').innerHTML = a.shift();
document.getElementById('jscash').innerHTML = "&euro;" + formatNumber(a.shift());
if (a[0] == "1") {
thmcls_activateMsgBlink();
} else {
thmcls_disableMsgBlink();
}
a.shift();
if (a[0] != "" || a.length > 1) {
document.getElementById('jsalliance').innerHTML = " [<b>" + a.join('#') + "</b>]";
} else {
document.getElementById('jsalliance').innerHTML = "";
}
thmcls_stTimer = setTimeout('thmcls_updateTime()', 1000);
thmcls_hdTimer = setTimeout('x_getHeaderData(thmcls_writeHeader)', 15000);
}
function updateHeader() {
if (thmcls_hdTimer) {
clearTimeout(thmcls_hdTimer);
}
if (thmcls_stTimer) {
clearTimeout(thmcls_stTimer);
}
x_getHeaderData(thmcls_writeHeader);
}

View file

@ -0,0 +1,107 @@
var thmcrp_hdTimer;
var thmcrp_stTimer;
var thmcrp_msgIcon = null, thmcrp_milock = false, thmcrp_dIcon;
var thm_sTime;
function thmcrp_activateMsgBlink() {
if (thmcrp_milock) {
setTimeout('thmcrp_activateMsgBlink()', 500);
return;
}
thmcrp_milock = true;
if (!thmcrp_msgIcon) {
thmcrp_dIcon = false;
thmcrp_msgIcon = setTimeout('thmcrp_blinkMsgBlink()', 200);
}
thmcrp_milock = false;
}
function thmcrp_disableMsgBlink() {
if (thmcrp_milock) {
setTimeout('thmcrp_disableMsgBlink()', 500);
return;
}
thmcrp_milock = true;
clearTimeout(thmcrp_msgIcon);
thmcrp_msgIcon = null;
var e = document.getElementById('msgmenu');
if (typeof e.oldbgc != 'undefined') {
e.bgColor = e.oldbgc;
}
thmcrp_milock = false;
}
function thmcrp_blinkMsgBlink() {
if (thmcrp_milock) {
setTimeout('thmcrp_blinkMsgBlink()', 50);
return;
}
thmcrp_milock = true;
var e = document.getElementById('msgmenu').getElementsByTagName('h1');
e = e[0];
if (thmcrp_dIcon) {
e.oldbgc = e.style.backgroundColor;
e.oldc = e.style.color;
e.style.backgroundColor = '#6fafcf';
e.style.color = '#000000';
} else {
e.style.backgroundColor = e.oldbgc;
e.style.color = e.oldc;
}
thmcrp_dIcon = !thmcrp_dIcon;
thmcrp_msgIcon = setTimeout('thmcrp_blinkMsgBlink()', 1000);
thmcrp_milock = false;
}
function thmcrp_updateTime() {
thm_sTime ++;
document.getElementById('jsservtm').innerHTML = formatDate(thm_sTime);
thmcrp_stTimer = setTimeout('thmcrp_updateTime()', 1000);
}
function thmcrp_writeHeader(data) {
if (thmcrp_stTimer) {
clearTimeout(thmcrp_stTimer);
}
var a = data.split("#");
thm_sTime = parseInt(a.shift(), 10);
document.getElementById('jsservtm').innerHTML = formatDate(thm_sTime);
document.getElementById('jspname').innerHTML = a.shift();
document.getElementById('jscash').innerHTML = "&euro;" + formatNumber(a.shift());
if (a[0] == "1") {
thmcrp_activateMsgBlink();
} else {
thmcrp_disableMsgBlink();
}
a.shift();
if (a[0] != "" || a.length > 1) {
document.getElementById('jsalliance').innerHTML = " [<b>" + a.join('#') + "</b>]";
} else {
document.getElementById('jsalliance').innerHTML = "";
}
thmcrp_stTimer = setTimeout('thmcrp_updateTime()', 1000);
thmcrp_hdTimer = setTimeout('x_getHeaderData(thmcrp_writeHeader)', 15000);
}
function updateHeader() {
if (thmcrp_hdTimer) {
clearTimeout(thmcrp_hdTimer);
}
if (thmcrp_stTimer) {
clearTimeout(thmcrp_stTimer);
}
x_getHeaderData(thmcrp_writeHeader);
}

View file

@ -0,0 +1 @@
var thmdef_getPlanet = 'Get New Planet';

View file

@ -0,0 +1,178 @@
var thmdef_hdTimer;
var thmdef_stTimer;
var thmdef_plTimer;
var thmdef_msgIcon = null, thmdef_milock = false, thmdef_dIcon;
var thmdef_mFolders, thmdef_fdTimer;
var thm_sTime;
function thmdef_activateMsgIcon()
{
if (thmdef_milock)
{
setTimeout('thmdef_activateMsgIcon()', 500);
return;
}
thmdef_milock = true;
if (!thmdef_msgIcon)
{
thmdef_dIcon = false;
thmdef_msgIcon = setTimeout('thmdef_blinkMsgIcon()', 200);
}
thmdef_milock = false;
}
function thmdef_disableMsgIcon()
{
if (thmdef_milock)
{
setTimeout('thmdef_disableMsgIcon()', 500);
return;
}
thmdef_milock = true;
clearTimeout(thmdef_msgIcon);
thmdef_msgIcon = null;
document.getElementById('msgicon').innerHTML = '&nbsp;';
document.getElementById('msgicon').onclick = null;
thmdef_milock = false;
}
function thmdef_viewMessage() {
document.location.href = 'message.redirect';
}
function thmdef_blinkMsgIcon()
{
if (thmdef_milock)
{
setTimeout('thmdef_blinkMsgIcon()', 50);
return;
}
thmdef_milock = true;
var e = document.getElementById('msgicon');
if (typeof e.onClick != 'function')
e.onclick = thmdef_viewMessage;
if (thmdef_dIcon)
e.innerHTML = '&nbsp;';
else
e.innerHTML = '<img src="'+staticurl+'/beta5/pics/icons/message.gif" alt="New message" />';
thmdef_dIcon = !thmdef_dIcon;
thmdef_msgIcon = setTimeout('thmdef_blinkMsgIcon()', 1000);
thmdef_milock = false;
}
function thmdef_updateTime()
{
thm_sTime ++;
document.getElementById('jsservtm').innerHTML = formatDate(thm_sTime);
thmdef_stTimer = setTimeout('thmdef_updateTime()', 1000);
}
function thmdef_writeHeader(data)
{
if (thmdef_stTimer)
clearTimeout(thmdef_stTimer);
var a = data.split("#");
thm_sTime = parseInt(a.shift(), 10);
document.getElementById('jsservtm').innerHTML = formatDate(thm_sTime);
document.getElementById('jspname').innerHTML = a.shift();
document.getElementById('jscash').innerHTML = "&euro;" + formatNumber(a.shift());
if (a[0] == "1")
thmdef_activateMsgIcon();
else
thmdef_disableMsgIcon();
a.shift();
if (a[0] != "" || a.length > 1)
document.getElementById('jsalliance').innerHTML = " [<b>" + a.join('#') + "</b>]";
else
document.getElementById('jsalliance').innerHTML = "";
thmdef_stTimer = setTimeout('thmdef_updateTime()', 1000);
thmdef_hdTimer = setTimeout('x_getHeaderData(thmdef_writeHeader)', 15000);
}
function thmdef_writePlanets(data)
{
if (!document.getElementById('jspmenu'))
return;
var ms = "";
if (data != '')
{
var i, a = data.split("\n");
for (i=0;i<a.length;i++)
{
p = a[i].split('#');
ms += "<li class='tmenu'><a class='tmenu' href='planet?id=" + p[0] + "'>";
ms += p[1].replace(' ', '&nbsp;') + "</a></li>";
}
}
else
ms = '<li class="tmenu"><a class="tmenu" href="nplanet">' + thmdef_getPlanet + '</a></li>';
document.getElementById('jspmenu').innerHTML = ms;
thmdef_plTimer = setTimeout('x_getHeaderPList(thmdef_writePlanets)', 180000);
}
function thmdef_ieDisplay(mid)
{
document.getElementById(mid).style.display = 'block';
}
function thmdef_ieHide(mid)
{
document.getElementById(mid).style.display = 'none';
}
function thmdef_writeFolders(data)
{
if (!document.getElementById('jsfmenu'))
return;
var ms = thmdef_mFolders;
if (data != '')
{
var i, a = data.split("\n");
for (i=0;i<a.length;i++)
{
var p = a[i].split('#');
ms += "<li class='tmenu'><a class='tmenu' href='message?a=f&f=C&cf=" + p.shift() + "'>";
ms += p.join('#').replace(' ', '&nbsp;') + "</a></li>";
}
}
document.getElementById('jsfmenu').innerHTML = ms;
thmdef_fdTimer = setTimeout('x_getHeaderFolders(thmdef_writeFolders)', 180000);
}
function thmdef_initFolders()
{
var e = document.getElementById('jsfmenu');
if (!e)
return;
thmdef_mFolders = e.innerHTML;
x_getHeaderFolders(thmdef_writeFolders);
}
function updateHeader()
{
if (thmdef_hdTimer)
clearTimeout(thmdef_hdTimer);
if (thmdef_stTimer)
clearTimeout(thmdef_stTimer);
if (thmdef_plTimer)
clearTimeout(thmdef_plTimer);
if (thmdef_fdTimer)
clearTimeout(thmdef_fdTimer);
x_getHeaderData(thmdef_writeHeader);
x_getHeaderPList(thmdef_writePlanets);
x_getHeaderFolders(thmdef_writeFolders);
}

View file

@ -0,0 +1 @@
var thminv_getPlanet = 'Get New Planet';

View file

@ -0,0 +1,179 @@
var thminv_hdTimer;
var thminv_stTimer;
var thminv_plTimer;
var thminv_msgIcon = null, thminv_milock = false, thminv_dIcon;
var thminv_mFolders, thminv_fdTimer;
var thm_sTime;
function thminv_activateMsgIcon()
{
if (thminv_milock)
{
setTimeout('thminv_activateMsgIcon()', 500);
return;
}
thminv_milock = true;
if (!thminv_msgIcon)
{
thminv_dIcon = false;
thminv_msgIcon = setTimeout('thminv_blinkMsgIcon()', 200);
}
thminv_milock = false;
}
function thminv_disableMsgIcon()
{
if (thminv_milock)
{
setTimeout('thminv_disableMsgIcon()', 500);
return;
}
thminv_milock = true;
clearTimeout(thminv_msgIcon);
thminv_msgIcon = null;
document.getElementById('msgicon').innerHTML = '&nbsp;';
document.getElementById('msgicon').onclick = null;
thminv_milock = false;
}
function thminv_viewMessage()
{
document.location.href = 'message.redirect';
}
function thminv_blinkMsgIcon()
{
if (thminv_milock)
{
setTimeout('thminv_blinkMsgIcon()', 50);
return;
}
thminv_milock = true;
var e = document.getElementById('msgicon');
if (typeof e.onClick != 'function')
e.onclick = thminv_viewMessage;
if (thminv_dIcon)
e.innerHTML = '&nbsp;';
else
e.innerHTML = '<img src="'+staticurl+'/beta5/pics/icons/message.gif" alt="New message" />';
thminv_dIcon = !thminv_dIcon;
thminv_msgIcon = setTimeout('thminv_blinkMsgIcon()', 1000);
thminv_milock = false;
}
function thminv_updateTime()
{
thm_sTime ++;
document.getElementById('jsservtm').innerHTML = formatDate(thm_sTime);
thminv_stTimer = setTimeout('thminv_updateTime()', 1000);
}
function thminv_writeHeader(data)
{
if (thminv_stTimer)
clearTimeout(thminv_stTimer);
var a = data.split("#");
thm_sTime = parseInt(a.shift(), 10);
document.getElementById('jsservtm').innerHTML = formatDate(thm_sTime);
document.getElementById('jspname').innerHTML = a.shift();
document.getElementById('jscash').innerHTML = "&euro;" + formatNumber(a.shift());
if (a[0] == "1")
thminv_activateMsgIcon();
else
thminv_disableMsgIcon();
a.shift();
if (a[0] != "" || a.length > 1)
document.getElementById('jsalliance').innerHTML = " [<b>" + a.join('#') + "</b>]";
else
document.getElementById('jsalliance').innerHTML = "";
thminv_stTimer = setTimeout('thminv_updateTime()', 1000);
thminv_hdTimer = setTimeout('x_getHeaderData(thminv_writeHeader)', 15000);
}
function thminv_writePlanets(data)
{
if (!document.getElementById('jspmenu'))
return;
var ms = "";
if (data != '')
{
var i, a = data.split("\n");
for (i=0;i<a.length;i++)
{
p = a[i].split('#');
ms += "<li class='tmenu'><a class='tmenu' href='planet?id=" + p[0] + "'>";
ms += p[1].replace(' ', '&nbsp;') + "</a></li>";
}
}
else
ms = '<li class="tmenu"><a class="tmenu" href="nplanet">' + thminv_getPlanet + '</a></li>';
document.getElementById('jspmenu').innerHTML = ms;
thminv_plTimer = setTimeout('x_getHeaderPList(thminv_writePlanets)', 180000);
}
function thminv_ieDisplay(mid)
{
document.getElementById(mid).style.display = 'block';
}
function thminv_ieHide(mid)
{
document.getElementById(mid).style.display = 'none';
}
function thminv_writeFolders(data)
{
if (!document.getElementById('jsfmenu'))
return;
var ms = thminv_mFolders;
if (data != '')
{
var i, a = data.split("\n");
for (i=0;i<a.length;i++)
{
var p = a[i].split('#');
ms += "<li class='tmenu'><a class='tmenu' href='message?a=f&f=C&cf=" + p.shift() + "'>";
ms += p.join('#').replace(' ', '&nbsp;') + "</a></li>";
}
}
document.getElementById('jsfmenu').innerHTML = ms;
thminv_fdTimer = setTimeout('x_getHeaderFolders(thminv_writeFolders)', 180000);
}
function thminv_initFolders()
{
var e = document.getElementById('jsfmenu');
if (!e)
return;
thminv_mFolders = e.innerHTML;
x_getHeaderFolders(thminv_writeFolders);
}
function updateHeader()
{
if (thminv_hdTimer)
clearTimeout(thminv_hdTimer);
if (thminv_stTimer)
clearTimeout(thminv_stTimer);
if (thminv_plTimer)
clearTimeout(thminv_plTimer);
if (thminv_fdTimer)
clearTimeout(thminv_fdTimer);
x_getHeaderData(thminv_writeHeader);
x_getHeaderPList(thminv_writePlanets);
x_getHeaderFolders(thminv_writeFolders);
}

View file

@ -0,0 +1,616 @@
/* This notice must be untouched at all times.
wz_tooltip.js v. 3.38
The latest version is available at
http://www.walterzorn.com
or http://www.devira.com
or http://www.walterzorn.de
Copyright (c) 2002-2005 Walter Zorn. All rights reserved.
Created 1. 12. 2002 by Walter Zorn (Web: http://www.walterzorn.com )
Last modified: 9. 12. 2005
Cross-browser tooltips working even in Opera 5 and 6,
as well as in NN 4, Gecko-Browsers, IE4+, Opera 7+ and Konqueror.
No onmouseouts required.
Appearance of tooltips can be individually configured
via commands within the onmouseovers.
LICENSE: LGPL
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License (LGPL) as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
For more details on the GNU Lesser General Public License,
see http://www.gnu.org/copyleft/lesser.html
*/
/* Lots of LegacyWorlds related changes in here ... */
//////////////// GLOBAL TOOPTIP CONFIGURATION /////////////////////
var ttAbove = false; // tooltip above mousepointer? Alternative: true
// Some definitions have been disabled for LW, the layout code should
// include code that does just that.
//var ttBgColor = "#e6ecff";
//var ttBgImg = ""; // path to background image;
//var ttBorderColor = "#003399";
var ttBorderWidth = 1;
//var ttDelay = 500; // time span until tooltip shows up [milliseconds]
//var ttFontColor = "#000066";
var ttFontFace = "arial,helvetica,sans-serif";
//var ttFontSize = "11px";
var ttFontWeight = "normal"; // alternative: "bold";
var ttLeft = false; // tooltip on the left of the mouse? Alternative: true
var ttOffsetX = 12; // horizontal offset of left-top corner from mousepointer
var ttOffsetY = 15; // vertical offset "
var ttOpacity = 100; // opacity of tooltip in percent (must be integer between 0 and 100)
var ttPadding = 3; // spacing between border and content
//var ttShadowColor = "";
//var ttShadowWidth = 0;
var ttStatic = false; // tooltip NOT move with the mouse? Alternative: true
var ttSticky = false; // do NOT hide tooltip on mouseout? Alternative: true
var ttTemp = 0; // time span after which the tooltip disappears; 0 (zero) means "infinite timespan"
var ttTextAlign = "left";
//var ttTitleColor = "#ffffff"; // color of caption text
var ttWidth = 300;
//////////////////// END OF TOOLTIP CONFIG ////////////////////////
////////////// TAGS WITH TOOLTIP FUNCTIONALITY ////////////////////
// List may be extended or shortened:
var tt_tags = new Array("a","area","b","big","caption","center","code","dd","div","dl","dt","em","h1","h2","h3","h4","h5","h6","i","img","input","li","map","ol","p","pre","s", "select", "small","span","strike","strong","sub","sup","table","td","th","tr","tt","u","var","ul","layer");
/////////////////////////////////////////////////////////////////////
///////// DON'T CHANGE ANYTHING BELOW THIS LINE /////////////////////
var tt_obj = null, // current tooltip
tt_ifrm = null, // iframe to cover windowed controls in IE
tt_objW = 0, tt_objH = 0, // width and height of tt_obj
tt_objX = 0, tt_objY = 0,
tt_offX = 0, tt_offY = 0,
xlim = 0, ylim = 0, // right and bottom borders of visible client area
tt_sup = false, // true if T_ABOVE cmd
tt_sticky = false, // tt_obj sticky?
tt_wait = false,
tt_act = false, // tooltip visibility flag
tt_sub = false, // true while tooltip below mousepointer
tt_u = "undefined",
tt_mf = null, // stores previous mousemove evthandler
tt_optag = null, // Opera: stores hovered dom node, and href and previous statusbar txt on <a> tags
tt_tag = null, // stores hovered dom node
tt_offsetLeft, // Backup the offsetLeft property to determine changes in location for the hovered node
tt_disable = false; // Disable tt_Show
var tt_total = 0; // LW: make sure we don't define a dynamic tooltip twice
var tt_dyncode = '';
var tt_db = (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body? document.body : null,
tt_n = navigator.userAgent.toLowerCase(),
tt_nv = navigator.appVersion;
// Browser flags
var tt_op = !!(window.opera && document.getElementById),
tt_op6 = tt_op && !document.defaultView,
tt_op7 = tt_op && !tt_op6,
tt_ie = tt_n.indexOf("msie") != -1 && document.all && tt_db && !tt_op,
tt_ie6 = tt_ie && parseFloat(tt_nv.substring(tt_nv.indexOf("MSIE")+5)) >= 5.5,
tt_n4 = (document.layers && typeof document.classes != tt_u),
tt_n6 = (!tt_op && document.defaultView && typeof document.defaultView.getComputedStyle != tt_u),
tt_w3c = !tt_ie && !tt_n6 && !tt_op && document.getElementById,
tt_konq = tt_n.indexOf('konqueror') != -1;
function tt_Int(t_x)
{
var t_y;
return isNaN(t_y = parseInt(t_x))? 0 : t_y;
}
function wzReplace(t_x, t_y)
{
var t_ret = "",
t_str = this,
t_xI;
while((t_xI = t_str.indexOf(t_x)) != -1)
{
t_ret += t_str.substring(0, t_xI) + t_y;
t_str = t_str.substring(t_xI + t_x.length);
}
return t_ret+t_str;
}
String.prototype.wzReplace = wzReplace;
function tt_N4Tags(tagtyp, t_d, t_y)
{
t_d = t_d || document;
t_y = t_y || new Array();
var t_x = (tagtyp=="a")? t_d.links : t_d.layers;
for(var z = t_x.length; z--;) t_y[t_y.length] = t_x[z];
for(z = t_d.layers.length; z--;) t_y = tt_N4Tags(tagtyp, t_d.layers[z].document, t_y);
return t_y;
}
function tt_Htm(tt, t_id, txt)
{
var t_bgc = (typeof tt.T_BGCOLOR != tt_u)? tt.T_BGCOLOR : ttBgColor,
t_bgimg = (typeof tt.T_BGIMG != tt_u)? tt.T_BGIMG : ttBgImg,
t_bc = (typeof tt.T_BORDERCOLOR != tt_u)? tt.T_BORDERCOLOR : ttBorderColor,
t_bw = (typeof tt.T_BORDERWIDTH != tt_u)? tt.T_BORDERWIDTH : ttBorderWidth,
t_ff = (typeof tt.T_FONTFACE != tt_u)? tt.T_FONTFACE : ttFontFace,
t_fc = (typeof tt.T_FONTCOLOR != tt_u)? tt.T_FONTCOLOR : ttFontColor,
t_fsz = (typeof tt.T_FONTSIZE != tt_u)? tt.T_FONTSIZE : ttFontSize,
t_fwght = (typeof tt.T_FONTWEIGHT != tt_u)? tt.T_FONTWEIGHT : ttFontWeight,
t_opa = (typeof tt.T_OPACITY != tt_u)? tt.T_OPACITY : ttOpacity,
t_padd = (typeof tt.T_PADDING != tt_u)? tt.T_PADDING : ttPadding,
t_shc = (typeof tt.T_SHADOWCOLOR != tt_u)? tt.T_SHADOWCOLOR : (ttShadowColor || 0),
t_shw = (typeof tt.T_SHADOWWIDTH != tt_u)? tt.T_SHADOWWIDTH : (ttShadowWidth || 0),
t_algn = (typeof tt.T_TEXTALIGN != tt_u)? tt.T_TEXTALIGN : ttTextAlign,
t_tit = (typeof tt.T_TITLE != tt_u)? tt.T_TITLE : "",
t_titc = (typeof tt.T_TITLECOLOR != tt_u)? tt.T_TITLECOLOR : ttTitleColor,
t_w = (typeof tt.T_WIDTH != tt_u)? tt.T_WIDTH : ttWidth;
if(t_shc || t_shw)
{
t_shc = t_shc || "#cccccc";
t_shw = t_shw || 5;
}
if(tt_n4 && (t_fsz == "10px" || t_fsz == "11px")) t_fsz = "12px";
var t_optx = (tt_n4? '' : tt_n6? ('-moz-opacity:'+(t_opa/100.0)) : tt_ie? ('filter:Alpha(opacity='+t_opa+')') : ('opacity:'+(t_opa/100.0))) + ';';
var t_y = '<div id="'+t_id+'" style="position:absolute;z-index:1010;';
t_y += 'left:0px;top:0px;width:'+(t_w+t_shw)+'px;visibility:'+(tt_n4? 'hide' : 'hidden')+';'+t_optx+'">' +
'<table border="0" cellpadding="0" cellspacing="0"'+(t_bc? (' bgcolor="'+t_bc+'" style="background:'+t_bc+';"') : '')+' width="'+t_w+'">';
if(t_tit)
{
t_y += '<tr><td style="padding-left:3px;padding-right:3px;" align="'+t_algn+'"><font color="'+t_titc+'" face="'+t_ff+'" ' +
'style="color:'+t_titc+';font-family:'+t_ff+';font-size:'+t_fsz+';"><b>' +
(tt_n4? '&nbsp;' : '')+t_tit+'</b></font></td></tr>';
}
t_y += '<tr><td><table border="0" cellpadding="'+t_padd+'" cellspacing="'+t_bw+'" width="100%">' +
'<tr><td'+(t_bgc? (' bgcolor="'+t_bgc+'"') : '')+(t_bgimg? ' background="'+t_bgimg+'"' : '')+' style="text-align:'+t_algn+';';
if(tt_n6) t_y += 'padding:'+t_padd+'px;';
t_y += '" align="'+t_algn+'"><font color="'+t_fc+'" face="'+t_ff+'"' +
' style="color:'+t_fc+';font-family:'+t_ff+';font-size:'+t_fsz+';font-weight:'+t_fwght+';">';
if(t_fwght == 'bold') t_y += '<b>';
t_y += txt;
if(t_fwght == 'bold') t_y += '</b>';
t_y += '</font></td></tr></table></td></tr></table>';
if(t_shw)
{
var t_spct = Math.round(t_shw*1.3);
if(tt_n4)
{
t_y += '<layer bgcolor="'+t_shc+'" left="'+t_w+'" top="'+t_spct+'" width="'+t_shw+'" height="0"></layer>' +
'<layer bgcolor="'+t_shc+'" left="'+t_spct+'" align="bottom" width="'+(t_w-t_spct)+'" height="'+t_shw+'"></layer>';
}
else
{
t_optx = tt_n6? '-moz-opacity:0.85;' : tt_ie? 'filter:Alpha(opacity=85);' : 'opacity:0.85;';
t_y += '<div id="'+t_id+'R" style="position:absolute;background:'+t_shc+';left:'+t_w+'px;top:'+t_spct+'px;width:'+t_shw+'px;height:1px;overflow:hidden;'+t_optx+'"></div>' +
'<div style="position:relative;background:'+t_shc+';left:'+t_spct+'px;top:0px;width:'+(t_w-t_spct)+'px;height:'+t_shw+'px;overflow:hidden;'+t_optx+'"></div>';
}
}
return(t_y+'</div>' +
(tt_ie6 ? '<iframe id="TTiEiFrM" src="javascript:false" scrolling="no" frameborder="0" style="filter:Alpha(opacity=0);position:absolute;top:0px;left:0px;display:none;"></iframe>' : ''));
}
function tt_EvX(t_e)
{
var t_y = tt_Int(t_e.pageX || t_e.clientX || 0) +
tt_Int(tt_ie? tt_db.scrollLeft : 0) +
tt_offX;
if(t_y > xlim) t_y = xlim;
var t_scr = tt_Int(window.pageXOffset || (tt_db? tt_db.scrollLeft : 0) || 0);
if(t_y < t_scr) t_y = t_scr;
return t_y;
}
function tt_EvY(t_e)
{
var t_y = tt_Int(t_e.pageY || t_e.clientY || 0) +
tt_Int(tt_ie? tt_db.scrollTop : 0);
if(tt_sup) t_y -= (tt_objH + tt_offY - 15);
else if(t_y > ylim || !tt_sub && t_y > ylim-24)
{
t_y -= (tt_objH + 5);
tt_sub = false;
}
else
{
t_y += tt_offY;
tt_sub = true;
}
return t_y;
}
function tt_ReleasMov()
{
if(document.onmousemove == tt_Move)
{
if(!tt_mf && document.releaseEvents) document.releaseEvents(Event.MOUSEMOVE);
document.onmousemove = tt_mf;
}
}
function tt_ShowIfrm(t_x)
{
if(!tt_obj || !tt_ifrm) return;
if(t_x)
{
tt_ifrm.style.width = tt_objW+'px';
tt_ifrm.style.height = tt_objH+'px';
tt_ifrm.style.display = "block";
}
else tt_ifrm.style.display = "none";
}
function tt_GetDiv(t_id)
{
return(
tt_n4? (document.layers[t_id] || null)
: tt_ie? (document.all[t_id] || null)
: (document.getElementById(t_id) || null)
);
}
function tt_GetDivW()
{
return tt_Int(
tt_n4? tt_obj.clip.width
: (tt_obj.style.pixelWidth || tt_obj.offsetWidth)
);
}
function tt_GetDivH()
{
return tt_Int(
tt_n4? tt_obj.clip.height
: (tt_obj.style.pixelHeight || tt_obj.offsetHeight)
);
}
// Compat with DragDrop Lib: Ensure that z-index of tooltip is lifted beyond toplevel dragdrop element
function tt_SetDivZ()
{
var t_i = tt_obj.style || tt_obj;
if(t_i)
{
if(window.dd && dd.z)
t_i.zIndex = Math.max(dd.z+1, t_i.zIndex);
if(tt_ifrm) tt_ifrm.style.zIndex = t_i.zIndex-1;
}
}
function tt_SetDivPos(t_x, t_y)
{
var t_i = tt_obj.style || tt_obj;
var t_px = (tt_op6 || tt_n4)? '' : 'px';
t_i.left = (tt_objX = t_x) + t_px;
t_i.top = (tt_objY = t_y) + t_px;
if(tt_ifrm)
{
tt_ifrm.style.left = t_i.left;
tt_ifrm.style.top = t_i.top;
}
}
function tt_ShowDiv(t_x)
{
tt_ShowIfrm(t_x);
if(tt_n4) tt_obj.visibility = t_x? 'show' : 'hide';
else tt_obj.style.visibility = t_x? 'visible' : 'hidden';
tt_act = t_x;
}
function tt_OpDeHref(t_e)
{
var t_tag;
if(t_e)
{
t_tag = t_e.target;
while(t_tag)
{
if(t_tag.hasAttribute("href"))
{
tt_optag = t_tag
tt_optag.t_href = tt_optag.getAttribute("href");
tt_optag.removeAttribute("href");
tt_optag.style.cursor = "hand";
tt_optag.onmousedown = tt_OpReHref;
tt_optag.stats = window.status;
window.status = tt_optag.t_href;
break;
}
t_tag = t_tag.parentElement;
}
}
}
function tt_OpReHref()
{
if(tt_optag)
{
tt_optag.setAttribute("href", tt_optag.t_href);
window.status = tt_optag.stats;
tt_optag = null;
}
}
function tt_whichElement(e)
{
var targ;
if (e.target) targ = e.target
else if (e.srcElement) targ = e.srcElement
if (targ.nodeType == 3) // defeat Safari bug
targ = targ.parentNode;
return targ;
}
function tt_Show(t_e, t_id, t_sup, t_delay, t_fix, t_left, t_offx, t_offy, t_static, t_sticky, t_temp)
{
if(tt_disable) return;
if(tt_obj) tt_Hide();
tt_mf = document.onmousemove || null;
if(window.dd && (window.DRAG && tt_mf == DRAG || window.RESIZE && tt_mf == RESIZE)) return;
var t_sh, t_h;
tt_obj = tt_GetDiv(t_id);
if(tt_obj)
{
t_e = t_e || window.event;
tt_sub = !(tt_sup = t_sup);
tt_sticky = t_sticky;
tt_objW = tt_GetDivW();
tt_objH = tt_GetDivH();
tt_offX = t_left? -(tt_objW+t_offx) : t_offx;
tt_offY = t_offy;
if(tt_op7) tt_OpDeHref(t_e);
tt_tag=tt_whichElement(t_e);
tt_offsetLeft = tt_tag.offsetLeft;
if(tt_n4)
{
if(tt_obj.document.layers.length)
{
t_sh = tt_obj.document.layers[0];
t_sh.clip.height = tt_objH - Math.round(t_sh.clip.width*1.3);
}
}
else
{
t_sh = tt_GetDiv(t_id+'R');
if(t_sh)
{
t_h = tt_objH - tt_Int(t_sh.style.pixelTop || t_sh.style.top || 0);
if(typeof t_sh.style.pixelHeight != tt_u) t_sh.style.pixelHeight = t_h;
else t_sh.style.height = t_h+'px';
}
}
xlim = tt_Int((tt_db && tt_db.clientWidth)? tt_db.clientWidth : window.innerWidth) +
tt_Int(window.pageXOffset || (tt_db? tt_db.scrollLeft : 0) || 0) -
tt_objW -
(tt_n4? 21 : 0);
ylim = tt_Int(window.innerHeight || tt_db.clientHeight) +
tt_Int(window.pageYOffset || (tt_db? tt_db.scrollTop : 0) || 0) -
tt_objH - tt_offY;
tt_SetDivZ();
if(t_fix) tt_SetDivPos(tt_Int((t_fix = t_fix.split(','))[0]), tt_Int(t_fix[1]));
else tt_SetDivPos(tt_EvX(t_e), tt_EvY(t_e));
var t_txt = 'tt_ShowDiv(\'true\');';
if(t_sticky) t_txt += '{'+
'tt_ReleasMov();'+
'window.tt_upFunc = document.onmouseup || null;'+
'if(document.captureEvents) document.captureEvents(Event.MOUSEUP);'+
'document.onmouseup = new Function("window.setTimeout(\'tt_Hide();\', 10);");'+
'}';
else if(t_static) t_txt += 'tt_ReleasMov();';
if(t_temp > 0) t_txt += 'window.tt_rtm = window.setTimeout(\'tt_sticky = false; tt_Hide();\','+t_temp+');';
window.tt_rdl = window.setTimeout(t_txt, t_delay);
if(!t_fix)
{
if(document.captureEvents) document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = tt_Move;
}
}
}
var tt_area = false;
function tt_Move(t_ev)
{
if(!tt_obj) return;
if(tt_n6 || tt_w3c)
{
if(tt_wait) return;
tt_wait = true;
setTimeout('tt_wait = false;', 5);
}
var t_e = t_ev || window.event;
tt_SetDivPos(tt_EvX(t_e), tt_EvY(t_e));
if(tt_op6)
{
if(tt_area && t_e.target.tagName != 'AREA') tt_Hide();
else if(t_e.target.tagName == 'AREA') tt_area = true;
}
if(tt_konq&&typeof tt_tag != 'undefined')
{
var t = tt_tag;
while (t.tagName != 'HTML')
{
if (typeof t.offsetLeft == 'undefined')
{
tt_Hide();
return;
}
t = t.parentElement;
}
}
else if(typeof tt_tag != 'undefined' && tt_tag.offsetLeft != tt_offsetLeft)
tt_Hide();
}
function tt_Hide()
{
if(window.tt_obj)
{
if(window.tt_rdl) window.clearTimeout(tt_rdl);
if(!tt_sticky || !tt_act)
{
if(window.tt_rtm) window.clearTimeout(tt_rtm);
tt_ShowDiv(false);
tt_SetDivPos(-tt_objW, -tt_objH);
tt_obj = null;
if(typeof window.tt_upFunc != tt_u) document.onmouseup = window.tt_upFunc;
}
tt_sticky = false;
if(tt_op6 && tt_area) tt_area = false;
tt_ReleasMov();
if(tt_op7) tt_OpReHref();
}
}
function tt_DynamicHtm(t_id, txt)
{
var t_bgc = ttBgColor,
t_bgimg = ttBgImg,
t_bc = ttBorderColor,
t_bw = ttBorderWidth,
t_ff = ttFontFace,
t_fc = ttFontColor,
t_fsz = ttFontSize,
t_fwght = ttFontWeight,
t_padd = ttPadding,
t_shc = (ttShadowColor || 0),
t_shw = (ttShadowWidth || 0),
t_tit = '',
t_titc = ttTitleColor,
t_w = ttWidth;
if (t_shc || t_shw)
{
t_shc = t_shc || '#cccccc';
t_shw = t_shw || 3;
}
if (tt_n4 && (t_fsz == '10px' || t_fsz == '11px')) t_fsz = '12px';
var t_y = '<div id="' + t_id + '" style="position:absolute;z-index:1010;';
t_y += 'left:0px;top:0px;width:' + (t_w+t_shw) + 'px;visibility:' + (tt_n4? 'hide' : 'hidden') + ';">';
t_y += '<table border="0" cellpadding="0" cellspacing="0"' + (t_bc? (' bgcolor="' + t_bc + '"') : '') + ' width="' + t_w + '">';
if (t_tit)
{
t_y += '<tr><td style="padding-left:3px;"><font color="' + t_titc + '" face="' + t_ff + '" ';
t_y += 'style="color:' + t_titc + ';font-family:' + t_ff + ';font-size:' + t_fsz + ';"><b>';
t_y += t_tit + '<\/b><\/font><\/td><\/tr>';
}
t_y += '<tr><td><table border="0" cellpadding="' + t_padd + '" cellspacing="' + t_bw + '" width="100%">';
t_y += '<tr><td' + (t_bgc? (' bgcolor="' + t_bgc + '"') : '') + (t_bgimg? ' background="' + t_bgimg + '"' : '');
if (tt_n6) t_y += ' style="padding:' + t_padd + 'px;"';
t_y += '><font color="' + t_fc + '" face="' + t_ff + '"';
t_y += ' style="color:' + t_fc + ';font-family:' + t_ff + ';font-size:' + t_fsz + ';font-weight:' + t_fwght + ';">';
if (t_fwght == 'bold') t_y += '<b>';
t_y += txt;
if (t_fwght == 'bold') t_y += '<\/b>';
t_y += '<\/font><\/td><\/tr><\/table><\/td><\/tr><\/table>';
if (t_shw)
{
var t_spct = Math.round(t_shw*1.3);
if (tt_n4)
{
t_y += '<layer bgcolor="' + t_shc + '" left="' + t_w + '" top="' + t_spct + '" width="' + t_shw + '" height="0"><\/layer>';
t_y += '<layer bgcolor="' + t_shc + '" left="' + t_spct + '" align="bottom" width="' + (t_w-t_spct) + '" height="' + t_shw + '"><\/layer>';
}
else
{
var t_opa = tt_n6? '-moz-opacity:0.85;' : tt_ie? 'filter:Alpha(opacity=85);' : '';
t_y += '<div id="' + t_id + 'R" style="position:absolute;background:' + t_shc + ';left:' + t_w + 'px;top:' + t_spct + 'px;width:' + t_shw + 'px;height:1px;overflow:hidden;' + t_opa + '"><\/div>';
t_y += '<div style="position:relative;background:' + t_shc + ';left:' + t_spct + 'px;top:0px;width:' + (t_w-t_spct) + 'px;height:' + t_shw + 'px;overflow:hidden;' + t_opa + '"><\/div>';
}
}
t_y += '<\/div>';
var ih = document.getElementById('ttPlaceHolderReserved').innerHTML;
if (ih == "")
tt_dyncode += t_y;
else
ih += t_y;
}
function tt_Init()
{
if(!(tt_op || tt_n4 || tt_n6 || tt_ie || tt_w3c)) return;
var htm = tt_n4? '<div style="position:absolute;"></div>' : '',
tags,
t_tj,
over,
esc = 'return escape(';
var i = tt_tags.length;
htm += tt_dyncode;
while (i--)
{
tags = tt_ie? (document.all.tags(tt_tags[i]) || 1)
: document.getElementsByTagName? (document.getElementsByTagName(tt_tags[i]) || 1)
: (!tt_n4 && tt_tags[i]=="a")? document.links
: 1;
if(tt_n4 && (tt_tags[i] == "a" || tt_tags[i] == "layer")) tags = tt_N4Tags(tt_tags[i]);
var j = tags.length; while(j--)
{
if(typeof (t_tj = tags[j]).onmouseover == "function" && t_tj.onmouseover.toString().indexOf(esc) != -1 && !tt_n6 || tt_n6 && (over = t_tj.getAttribute("onmouseover")) && over.indexOf(esc) != -1)
{
if(over) t_tj.onmouseover = new Function(over);
var txt = unescape(t_tj.onmouseover());
htm += tt_Htm(
t_tj,
"tOoLtIp"+i+""+j,
txt.wzReplace("& ","&")
);
t_tj.onmouseover = new Function('e',
'tt_Show(e,'+
'"tOoLtIp' +i+''+j+ '",'+
((typeof t_tj.T_ABOVE != tt_u)? t_tj.T_ABOVE : ttAbove)+','+
((typeof t_tj.T_DELAY != tt_u)? t_tj.T_DELAY : ttDelay)+','+
((typeof t_tj.T_FIX != tt_u)? '"'+t_tj.T_FIX+'"' : '""')+','+
((typeof t_tj.T_LEFT != tt_u)? t_tj.T_LEFT : ttLeft)+','+
((typeof t_tj.T_OFFSETX != tt_u)? t_tj.T_OFFSETX : ttOffsetX)+','+
((typeof t_tj.T_OFFSETY != tt_u)? t_tj.T_OFFSETY : ttOffsetY)+','+
((typeof t_tj.T_STATIC != tt_u)? t_tj.T_STATIC : ttStatic)+','+
((typeof t_tj.T_STICKY != tt_u)? t_tj.T_STICKY : ttSticky)+','+
((typeof t_tj.T_TEMP != tt_u)? t_tj.T_TEMP : ttTemp)+
');'
);
t_tj.onmouseout = tt_Hide;
if(t_tj.alt) t_tj.alt = "";
if(t_tj.title) t_tj.title = "";
}
}
}
document.getElementById('ttPlaceHolderReserved').innerHTML=htm;
if(document.getElementById) tt_ifrm = document.getElementById("TTiEiFrM");
}
function tt_Dynamic(txt)
{
tt_DynamicHtm('dyntOoLtIp'+tt_total, txt.wzReplace('& ','&'));
var code = ' onmouseover=\'tt_Show(event,"dyntOoLtIp'+tt_total+'",'+
'false,ttDelay,"",false,ttOffsetX,ttOffsetY,false,false);\'';
code += ' onmouseout=\'tt_Hide();\' ';
tt_total ++;
return code;
}
function tt_Disable()
{
var i = tt_tags.length;
while (i--)
{
var tags = tt_ie? (document.all.tags(tt_tags[i]) || 1)
: document.getElementsByTagName? (document.getElementsByTagName(tt_tags[i]) || 1)
: (!tt_n4 && tt_tags[i]=="a")? document.links
: 1;
if(tt_n4 && (tt_tags[i] == "a" || tt_tags[i] == "layer")) tags = tt_N4Tags(tt_tags[i]);
var j = tags.length; while(j--)
{
var t_tj;
if(typeof (t_tj = tags[j]).onmouseover == "function")
{
t_tj.onmouseover = undefined;
t_tj.onmouseout = undefined;
}
}
}
if(tt_obj) tt_Hide();
tt_disable = true;
}

View file

@ -0,0 +1,8 @@
var ttBgColor = '#e6ecff';
var ttBgImg = '';
var ttBorderColor = '#003399';
var ttFontColor = '#0033CC';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#dfffef';
var ttBgImg = '';
var ttBorderColor = '#1fcf1f';
var ttFontColor = '#1f7f1f';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#ffffff';
var ttBgImg = '';
var ttBorderColor = '#666666';
var ttFontColor = '#4f4f4f';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#000000';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#eeccff';
var ttBgImg = '';
var ttBorderColor = '#CC33FF';
var ttFontColor = '#660099';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#ffece6';
var ttBgImg = '';
var ttBorderColor = '#993300';
var ttFontColor = '#CC3300';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#996600';
var ttBgImg = '';
var ttBorderColor = '#ffff3f';
var ttFontColor = '#ffff3f';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#000000';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#e6ecff';
var ttBgImg = '';
var ttBorderColor = '#003399';
var ttFontColor = '#0033CC';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#dfffef';
var ttBgImg = '';
var ttBorderColor = '#1fcf1f';
var ttFontColor = '#1f7f1f';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#ffffff';
var ttBgImg = '';
var ttBorderColor = '#666666';
var ttFontColor = '#4f4f4f';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#000000';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#eeccff';
var ttBgImg = '';
var ttBorderColor = '#CC33FF';
var ttFontColor = '#660099';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#ffece6';
var ttBgImg = '';
var ttBorderColor = '#993300';
var ttFontColor = '#CC3300';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#996600';
var ttBgImg = '';
var ttBorderColor = '#ffff3f';
var ttFontColor = '#ffff3f';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#000000';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#e6ecff';
var ttBgImg = '';
var ttBorderColor = '#003399';
var ttFontColor = '#0033CC';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#dfffef';
var ttBgImg = '';
var ttBorderColor = '#1fcf1f';
var ttFontColor = '#1f7f1f';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#ffffff';
var ttBgImg = '';
var ttBorderColor = '#666666';
var ttFontColor = '#4f4f4f';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#000000';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#eeccff';
var ttBgImg = '';
var ttBorderColor = '#CC33FF';
var ttFontColor = '#660099';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#ffece6';
var ttBgImg = '';
var ttBorderColor = '#993300';
var ttFontColor = '#CC3300';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#ffffff';

View file

@ -0,0 +1,8 @@
var ttBgColor = '#996600';
var ttBgImg = '';
var ttBorderColor = '#ffff3f';
var ttFontColor = '#ffff3f';
var ttShadowColor = '';
var ttShadowWidth = 0;
var ttTitleColor = '#000000';