var alPages = new Array('Main', 'Vote', 'MList', 'PList', 'MStat', 'Pending', 'FAdmin', 'RAdmin'); var alColours = new Array(null, null, null, null, null, null, null, null); var alCheckPriv = new Array( new Function('return true'), new Function('return lockedAlliances || isDemocracy'), new Function('return (alPrivileges[0] > 0)'), new Function('return (alPrivileges[0] > 1)'), new Function('return (alPrivileges[1] == 1)'), new Function('return (alPrivileges[4] == 1) && !lockedAlliances'), new Function('return (alPrivileges[5] == 1)'), new Function('return (alPrivileges[8] == 1)') ); var lockedAlliances; var plAlliance; var inAlliance; var alTag; var alName; var hasFocus = -1; var alPubInfo = false; var gdTimer; var puTimer; var amPage; var myPubInfo = false; var alPrivileges; var successor; var isDemocracy; var asSuccessor; var asDemocracy; var techTrade; var asTechTrade; var asButtons = false; var leCandidates; var leSelected; var leNewSel = false; var leCanSel; var leCanApply; var leCanCancel; var leCanTake; var leInAction = false; var leSort = 0; var leSortDir = false; var lsMode = false; var lsPlanets = new Array(); var lsPPerPage = 10; var lsPPage = 0; var lsPSearchType = 0; var lsPSearchText = ""; var lsPIndices; var lsPSort = 1; var lsPSortDir = false; var lsMembers = new Array(); var lsMPerPage = 10; var lsMPage = 0; var lsMRanks; var lsMChange; var lsMKick; var lsMSearchText = ""; var lsMIndices; var lsMSort = 0; var lsMSortDir = false; var lsMNewRank = false; var lsAttacks = new Array(); var lsAPerPage = 10; var lsAPage = 0; var lsAIndices; var lsASort = 1; var lsASortDir = false; var lsASearchText = ""; var lsASearchType = 0; var pRequests = new Array(); var faForums; var faEditing = false; var faOriginal; var faOriACL; var faNewPos; var faAccess; var raRanks = new Array(); var raForums; var raEditing = false; var raOriginal; var raDeleting = 0; var raDemote; var alltt; function emptyCB(data) {} function PubAlliance(id, tag, name, leader, rank, points, nplanets, cx, cy, vicCond) { this.id = id; this.tag = tag; this.name = name; this.leader = leader; this.points = points; this.rank = rank; this.points = points; this.nplanets = nplanets; this.cx = cx; this.cy = cy; this.victory = vicCond; } function initAlliancePage() { var data = document.getElementById('allinit').innerHTML; if (data.indexOf('\n') != -1) generalDataReceived(data); else // IE really sucks x_getGeneralData(generalDataReceived); } function generalDataReceived(data) { var a = data.split('\n'); var b = a[0].split('#'); plAlliance = b[0]; if (plAlliance == "") { inAlliance = false; drawPageNoAlliance(); } else if (a.length == 3) { inAlliance = false; alTag = a[1]; alName = a[2]; drawPageNoAlliance(); } else { if (!inAlliance) drawAllianceMemberLayout(); lockedAlliances = (b[2] == 1); b = a[3].split('#'); myPubInfo = new PubAlliance(b[0], a[1], a[2], a[4], b[5], b[6], b[1], b[2], b[3], b[8]); successor = a[5]; isDemocracy = (b[4] == "1"); techTrade = b[7]; alPrivileges = a[6].split('#'); alColours[4] = (alPrivileges[1] == 1 && a[8] != '0') ? "red" : null; alTag = a[1]; alName = a[2]; inAlliance = true; if (a[7] == 'List') { a[7] = 'Main'; } if (amPage != a[7]) eval('switchTo'+a[7]+'Page()'); else if (amPage == 'Main') { drawAllianceMenu(); drawMainPage(); } else drawAllianceMenu(); } gdTimer = setTimeout('x_getGeneralData(generalDataReceived)', 30000); } function clearUpdate() { if (puTimer) clearTimeout(puTimer); puTimer = false; } //-------------------------------------------------- // ALLIANCE INFORMATION //-------------------------------------------------- function getAllianceInfo() { var v = document.getElementById('alinfo').value; if (v == "") { alertAllianceInfo(0); return; } x_getTagInformation(v, tagInformationReceived); } function tagInformationReceived(data) { if (data.indexOf('ERR') == 0) { var a = data.split('#'); alPubInfo = false; alertAllianceInfo(parseInt(a[1], 10)); } else { var a = data.split('\n'); var b = a[0].split('#'); alPubInfo = new PubAlliance(b[0], a[1], a[2], a[3], b[4], b[5], b[1], b[2], b[3], b[6]); } drawPubAllianceInfo(); } //-------------------------------------------------- // ALLIANCE CREATION / REQUEST //-------------------------------------------------- function createAlliance() { var t, n; t = document.getElementById('actag').value; if (t == "") { alertCreate(2); return; } n = document.getElementById('acname').value; if (n == "") { alertCreate(3); return; } x_createAlliance(t, n, allianceCreated); } function allianceCreated(data) { if (data.indexOf('ERR') == 0) { var a = data.split('#'); alertCreate(parseInt(a[1], 10)); } else { updateHeader(); clearTimeout(gdTimer); generalDataReceived(data); } } function sendJoinRequest() { var t; t = document.getElementById('aljoin').value; if (t == "") { alertJoin(0); return; } x_sendRequest(t, requestSent); } function requestSent(data) { if (data.indexOf('ERR') == 0) { var a = data.split('#'); alertJoin(parseInt(a[1], 10)); } else { clearTimeout(gdTimer); generalDataReceived(data); } } //-------------------------------------------------- // ALLIANCE MEMBER PAGE //-------------------------------------------------- function drawAllianceMemberLayout() { document.getElementById('allpage').innerHTML = '
' + '' + '
 Help
 
 
'; } function drawAllianceMenu() { var i, j, str = ""; for (i = 0, j = 0; i < alPages.length; i ++) { if (!alCheckPriv[i]()) { continue; } if (j > 0) { str += (j == 5 ? "
" : " - "); } j ++; var colour = alColours[i] ? (" style='color: " + alColours[i] + "' ") : ""; var t = (amPage == alPages[i]); str += (t ? ('') : ('') ) + alPgTitles[i] + (t ? '' : ''); } document.getElementById('alpmenu').innerHTML = str; } // Main page (current alliance + alliance information) function switchToMainPage() { clearUpdate(); x_mainPage(emptyCB); amPage = "Main"; asButtons = (asDemocracy != isDemocracy) || (asSuccessor.toLowerCase() != successor.toLowerCase()) || (asTechTrade != techTrade); hasFocus = -1; drawAllianceMenu(); drawMainPage(); } function updateASControls() { var nst = (asDemocracy != isDemocracy) || (asSuccessor.toLowerCase() != successor.toLowerCase()) || (asTechTrade != techTrade); if (nst == asButtons) { return; } asButtons = nst; if (asButtons) { drawASButtons(); } else { document.getElementById('lasbut').innerHTML = ' '; } } function resetAllianceSettings() { asSuccessor = successor; asDemocracy = isDemocracy; asTechTrade = techTrade; drawMainPage(); } function modifyAllianceSettings() { document.getElementById('lasbut').innerHTML = ' '; x_modifySettings(asDemocracy ? 1 : 0, asTechTrade, asSuccessor, aSettingsModified); } function aSettingsModified(data) { if (data.indexOf('ERR') == 0) { var a = data.split('#'); alertASettings(parseInt(a[1], 10)); drawASButtons(); } else { asDemocracy = -1; clearTimeout(gdTimer); generalDataReceived(data); } } function asFocus() { if (hasFocus == 0 && alPrivileges[8] == 1) { document.getElementById('lassucc').focus(); } else if (hasFocus == 3) { document.getElementById('alinfo').focus(); } } function leaderStepDown() { if (!confirmLSD()) return; x_leaderStepDown(aSettingsModified); } function leaveAlliance() { var b; if (alPrivileges[8] == 0) b = confirmLeave(0); else if (successor != "") b = confirmLeave(1); else b = confirmLeave(isDemocracy ? 2 : 3); if (!b) return; x_leaveAlliance(aSettingsModified); } // Leader election function switchToVotePage() { clearUpdate(); if (!alCheckPriv[1]()) { switchToMainPage(); return; } amPage = 'Vote'; drawAllianceMenu(); drawLoadingText(); x_getCandidates(candidatesReceived); } function Candidate(id,nVotes,name) { this.id = id; this.nVotes = nVotes; this.name = name; } function candidatesReceived(data) { leInAction = false; if (amPage != "Vote") return; if (data == "") { switchToMainPage(); return; } else if (data.indexOf('ERR#') == 0) { var a = data.split('#'); alertElection(parseInt(a[1],10)); } else { var a = data.split('\n'); var ll = a.shift().split('#'); leCanSel = (ll[0] == '1'); leCanApply = (ll[1] == '1'); leCanCancel = (ll[2] == '1'); leCanTake = (ll[3] == '1'); leSelected = ll[4]; if (leNewSel == false && leCanSel) leNewSel = leSelected; var i; leCandidates = new Array(); for (i=0;i getRawRankText(y).toLowerCase() ? 1 : -1; }); } function getRank(m) { if (m.rankText == "") { m.rankText = getRankText(m.getRawRank()); } return m.rankText; } function getRawRankText(r) { for (var i = 0; i < lsMRanks.length && lsMRanks[i].id != r; i ++) { // Empty loop } return getRankText(i); } function getCookedRankText(r) { for (var i = 0; i < lsMRanks.length && lsMRanks[i].id != r; i ++) { // Empty loop } return getRankText((i == lsMRanks.length || lsMRanks[i].name == '-') ? '-' : i); } function removeMember(id) { var k; for (k=0;k' : '') + mbListHeaders[i]; if (lsMSort == i) { str += '' + (lsMSortDir ? '; } str += ''; } str += ''; // Contents for (i = firstMember; i < firstMember + mCount; i ++) { var idx = lsMIndices[i]; str += ''; if (canSelect) { str += ''; if ( ( kickRanks.indexOf('#' + lsMembers[idx].rank + '#') != -1 || changeRanks.indexOf('#' + lsMembers[idx].rank + '#') != -1 ) && !lsMembers[idx].current ) { str += ''; } str += ' '; str += ''; } str += ''; if (!lsMembers[idx].current) { str += ''; } str += lsMembers[idx].name + (lsMembers[idx].current ? '' : '') + '' + lastOnline(lsMembers[idx]) + '' + vacationMode[lsMembers[idx].onVacation ? 1 : 0] + ''; } str += ''; return str; } function lastOnline(member) { if (member.lastOnline) { var str = lastOnlinePrefix; var lo, loUnit; if (member.lastOnline > 60) { lo = (member.lastOnline - (member.lastOnline % 60)) / 60; loUnit = 1; } else { lo = member.lastOnline; loUnit = 0; } str += formatNumber(lo.toString()) + ' ' + lastOnlineUnits[loUnit * 2 + (lo > 1 ? 1 : 0)] + lastOnlineSuffix; return str; } return onlineText; } function updateMListPage() { if (!alCheckPriv[2]()) { switchToMainPage(); return; } hasFocus = 0; getPlayerList(); } // Planet list function Planet(id, owner, msOwner, name, cx, cy, orbit, fact, tur, ua) { this.id = id; this.owner = owner; this.msOwner = msOwner; this.name = name; this.coords = '(' + cx + ',' + cy + ',' + orbit + ')'; this.factories = fact; this.turrets = tur; this.underAttack = ua; } function switchToPListPage() { clearUpdate(); if (!alCheckPriv[3]()) { switchToMainPage(); return; } amPage = 'PList'; drawAllianceMenu(); drawLoadingText(); getPlanetList(); } function getPlanetList() { if (amPage != 'PList') { return; } var ids = new Array(), i; for (i = 0; i < lsPlanets.length; i ++) { ids.push(lsPlanets[i].id); } x_getPlanetList(ids.join('#'), planetListReceived); } function planetListReceived(data) { if (amPage != 'PList') { return; } if (data == "") { lsPlanets = new Array(); } else { parsePlanetList(data); } puTimer = setTimeout('updatePListPage()', 180000); preparePlanetList(); drawPlanetList(); } function updatePListPage() { if (!alCheckPriv[3]()) { switchToMainPage(); return; } hasFocus = 0; getPlanetList(); } function removePlanet(id) { var k; for (k=0;k 0) { var s = l.shift(); if (st == 0) { ca = s.split('#'); ca[4] = parseInt(ca[4], 10); ca[5] = parseInt(ca[5], 10); on = ''; att = new Array(); def = new Array(); st = 1; } else if (st == 1) { pn = s; if (ca[1] != "") st = 2; else if (ca[4] > 0) st = 3; else if (ca[5] > 0) st = 4; else { lsAttacks.push(new MilitarySituation(ca[0],pn,ca[6],'','',ca[3],ca[2],att,def)); st = 0; } } else if (st == 2) { on = s; if (ca[4] > 0) st = 3; else if (ca[5] > 0) st = 4; else { lsAttacks.push(new MilitarySituation(ca[0],pn,ca[6],ca[1],on,ca[3],ca[2],att,def)); st = 0; } } else if (st == 3) { def.push(s); ca[4] --; if (ca[4] == 0) { if (ca[5] > 0) st = 4; else { lsAttacks.push(new MilitarySituation(ca[0],pn,ca[6],ca[1],on,ca[3],ca[2],att,def)); st = 0; } } } else if (st == 4) { att.push(s); ca[5] --; if (ca[5] == 0) { lsAttacks.push(new MilitarySituation(ca[0],pn,ca[6],ca[1],on,ca[3],ca[2],att,def)); st = 0; } } } } function prepareMilitaryList() { var i; lsAIndices = new Array(); if (lsASearchText == "") { for (i=0;i 1)) return; if (puTimer && amPage == "Pending") { clearUpdate(); var ids = new Array(), i; for (i=0;i 1)) return; if (puTimer && amPage == "Pending") { clearUpdate(); var ids = new Array(), i; for (i=0;i= 30) { alertMaximumFCount(); forumEditCancel(); } else if (!faEditing.id) { if (faNewPos != -1 && !forumById(faNewPos)) faNewPos = -1; updateFPosSelector(); } else if (faEditing.id) { var f = forumById(faEditing.id); if (!f) { alertForumDeleted(); forumEditCancel(); } else if (faOriginal.name != f.name || faOriginal.userPost != f.userPost || faOriginal.description != f.description) { alertForumChanged(); updateFEditor(); } else { updateFEditor(); } } puTimer = setTimeout('x_getForums(forumsReceived)', 180000); } function parseForumList(data) { var dl = data.split('\n'); var st = 0, i = 0, cf = 0; var a; while (i b.order ? 1 : -1)')); } function moveForum(id,up) { x_moveForum(id, up ? 1 : 0, forumsReceived); } function forumById(id) { var i; for (i=0;i b.name.toLowerCase() ? 1 : -1')); } if (faEditing.id) faOriACL = makeForumACLString(); drawFAccessManager(); updateFEditor(); } function setFAccessLevel(level) { var i,cc=0; for (i=0;i 0) { drawFAccessManager(); updateFEditor(); } } function updateFEditor() { var ok, i; ok = (faEditing.name.length >= 4); if (faEditing.id) ok = ok && ( faEditing.name != faOriginal.name || faEditing.description != faOriginal.description || faEditing.userPost != faOriginal.userPost || faOriACL != makeForumACLString() ); document.getElementById('feok').disabled = !ok; } function makeForumACLString() { var a = new Array(), i; for (i=0;ib.name.toLowerCase()?1:-1')); var rr = new Array(); for (i = 0; i < nr; i ++) { var r, n, i; a = l.shift().split('#'); r = new Rank(a[0], l.shift(), a[1], a[2], a[3] == "1", a[4] == "1", a[5] == "1", a[6] == "1", a[7] == "1", a[8] == "1", a[9] == 1, a[10] == "1", a[11]); if (r.canKick) { if (l[0] != "") { r.ranksKick = l.shift().split('#'); } else { l.shift(); } } if (r.canSet) { if (l[0] != "") { r.ranksChange = l.shift().split('#'); } else { l.shift(); } } if (l[0] == "") { l.shift(); } else { r.fRead = l.shift().split('#'); } if (l[0] == "") { l.shift(); } else { r.fMod = l.shift().split('#'); } n = rankById(r.id); if (n) { r.open = n.open; } rr.push(r); } rr.sort(new Function('a','b','return a.name.toLowerCase()>b.name.toLowerCase()?1:-1')); raRanks = rr; if (!(raEditing || raDeleting)) { drawRanksList(); } puTimer = setTimeout('x_getRanks(ranksReceived)', 180000); } function rankById(id) { var i; for (i=0;i '; str += (raRanks[i].name == '-' ? (''+sm+'') : raRanks[i].name.replace(/&/g, '&').replace(//g, '>')) + ''; if (n%3 == 2) str += ''; n++; } if (n%3 != 0) { while (n%3 != 0) { str += ' '; n++; } str += ''; } str += ''; document.getElementById('re'+lstid+'list').innerHTML = str; } function updateREditor() { var ok; if (!raEditing.id || (raEditing.id && raOriginal.name != "-")) { ok = (raEditing.name.length > 3); } else { ok = true; } if (raEditing.id) { raEditing.ranksChange.sort(new Function('a','b','return a-b')); raEditing.ranksKick.sort(new Function('a','b','return a-b')); raEditing.fRead.sort(new Function('a','b','return a-b')); raEditing.fMod.sort(new Function('a','b','return a-b')); ok = ok && ( (raEditing.name != raOriginal.name) || (raEditing.list != raOriginal.list) || (raEditing.attacks != raOriginal.attacks) || (raEditing.canSet != raOriginal.canSet) || (raEditing.canKick != raOriginal.canKick) || (raEditing.accept != raOriginal.accept) || (raEditing.forumAdmin != raOriginal.forumAdmin) || (raEditing.canVote != raOriginal.canVote) || (raEditing.diplContact != raOriginal.diplContact) || (raEditing.candidate != raOriginal.candidate) || (raEditing.techTrade != raOriginal.techTrade) || (raEditing.ranksChange.join('#') != raOriginal.ranksChange.join('#')) || (raEditing.ranksKick.join('#') != raOriginal.ranksKick.join('#')) || (raEditing.fRead.join('#') != raOriginal.fRead.join('#')) || (raEditing.fMod.join('#') != raOriginal.fMod.join('#')) ); } document.getElementById('reok').disabled = !ok; } function rankEditCancel() { raEditing = false; drawRanksList(); } function rankEditOk() { var i, prs, rkick, rchange, fread, fmod; if (raEditing.canSet == 1 && raEditing.ranksChange.length == 0) raEditing.canSet = 0; if (raEditing.canKick == 1 && raEditing.ranksKick.length == 0) raEditing.canKick = 0; prs = raEditing.list + '#' + (raEditing.attacks ? '1' : '0') + '#'; prs += (raEditing.canSet != 0 ? '1' : '0') + '#' + (raEditing.canKick != 0 ? '1' : '0') + '#'; prs += (raEditing.accept ? '1' : '0') + '#' + (raEditing.forumAdmin ? '1' : '0') + '#'; prs += (raEditing.diplContact ? '1' : '0') + '#' + (raEditing.canVote ? '1' : '0') + '#'; prs += (raEditing.candidate ? '1' : '0') + '#' + raEditing.techTrade; if (raEditing.canSet == 1) rchange = raEditing.ranksChange.join('#'); else rchange = ""; if (raEditing.canKick == 1) rkick = raEditing.ranksKick.join('#'); else rkick = ""; if (raEditing.forumAdmin) fread = fmod = ""; else { fread = raEditing.fRead.join('#'); fmod = raEditing.fMod.join('#'); } if (raEditing.id) { x_changeRank(raEditing.id, raEditing.name, prs, rkick, rchange, fread, fmod, rankEdited); } else { x_newRank(raEditing.name, prs, rkick, rchange, fread, fmod, rankEdited); } } function rankEdited(data) { if (data.indexOf('ERR#') == 0) { alertRank(parseInt(data.replace(/ERR#/, ''), 10)); } else { raEditing = false; clearUpdate(); ranksReceived(data); } } function rankSwitchKick(idx) { var id = raRanks[idx].id; var ks = '!' + raEditing.ranksKick.join('!') + '!'; if (ks.indexOf('!' + id + '!') == -1) raEditing.ranksKick.push(id); else { var i; for (i=0;i 0) { raDeleting = raRanks[idx]; raDemote = raRanks[i].id; showRankDeletePage(); } } function rankDeleteOk() { x_delRank(raDeleting.id, raDemote, rankDeleted); } function rankDeleteCancel() { raDeleting = false; drawRanksList(); } function rankDeleted(data) { raDeleting = false; clearUpdate(); if (data.indexOf('ERR#') == 0) { alertRank(parseInt((data.split('#'))[1], 10)); } else { ranksReceived(data); } } //-------------------------------------------------- // LIST SORTING //-------------------------------------------------- function pls_Coord_asc(a,b) { var ra = lsPlanets[a].coords.toLowerCase(); var rb = lsPlanets[b].coords.toLowerCase(); return (ra < rb) ? -1 : 1; } function pls_Coord_desc(a,b) { var ra = lsPlanets[a].coords.toLowerCase(); var rb = lsPlanets[b].coords.toLowerCase(); return (ra < rb) ? 1 : -1; } function pls_Planet_asc(a,b) { var ra = lsPlanets[a].name.toLowerCase(); var rb = lsPlanets[b].name.toLowerCase(); return (ra < rb) ? -1 : 1; } function pls_Planet_desc(a,b) { var ra = lsPlanets[a].name.toLowerCase(); var rb = lsPlanets[b].name.toLowerCase(); return (ra < rb) ? 1 : -1; } function pls_Owner_asc(a,b) { var ra = lsPlanets[a].owner.toLowerCase(); var rb = lsPlanets[b].owner.toLowerCase(); return (ra < rb) ? -1 : ((ra > rb) ? 1 : pls_Planet_asc(a,b)); } function pls_Owner_desc(a,b) { var ra = lsPlanets[a].owner.toLowerCase(); var rb = lsPlanets[b].owner.toLowerCase(); return (ra < rb) ? 1 : ((ra > rb) ? -1 : pls_Planet_desc(a,b)); } function pls_Fact_asc(a,b) { var ra = parseInt(lsPlanets[a].factories, 10); var rb = parseInt(lsPlanets[b].factories, 10); return (ra < rb) ? -1 : ((ra > rb) ? 1 : pls_Planet_asc(a,b)); } function pls_Fact_desc(a,b) { var ra = parseInt(lsPlanets[a].factories, 10); var rb = parseInt(lsPlanets[b].factories, 10); return (ra < rb) ? 1 : ((ra > rb) ? -1 : pls_Planet_desc(a,b)); } function pls_Trt_asc(a,b) { var ra = parseInt(lsPlanets[a].turrets, 10); var rb = parseInt(lsPlanets[b].turrets, 10); return (ra < rb) ? -1 : ((ra > rb) ? 1 : pls_Planet_asc(a,b)); } function pls_Trt_desc(a,b) { var ra = parseInt(lsPlanets[a].turrets, 10); var rb = parseInt(lsPlanets[b].turrets, 10); return (ra < rb) ? 1 : ((ra > rb) ? -1 : pls_Planet_desc(a,b)); } function mls_Name_asc(a,b) { var ra = lsMembers[a].name.toLowerCase(); var rb = lsMembers[b].name.toLowerCase(); return (ra < rb) ? -1 : 1; } function mls_Name_desc(a,b) { var ra = lsMembers[a].name.toLowerCase(); var rb = lsMembers[b].name.toLowerCase(); return (ra > rb) ? -1 : 1; } function mls_LastOnline_asc(a,b) { var ra = lsMembers[a].lastOnline; var rb = lsMembers[b].lastOnline; return (ra < rb) ? 1 : ((ra > rb) ? -1 : mls_Name_desc(a,b)); } function mls_LastOnline_desc(a,b) { var ra = lsMembers[a].lastOnline; var rb = lsMembers[b].lastOnline; return (ra < rb) ? -1 : ((ra > rb) ? 1 : mls_Name_asc(a,b)); } function mls_Vacation_asc(a,b) { var ra = lsMembers[a].onVacation ? 1 : 0; var rb = lsMembers[b].onVacation ? 1 : 0; return (ra == rb ? mls_Name_asc(a,b) : (ra - rb)); } function mls_Vacation_desc(a,b) { var ra = lsMembers[a].onVacation ? 1 : 0; var rb = lsMembers[b].onVacation ? 1 : 0; return (ra == rb ? mls_Name_desc(a,b) : (rb - ra)); } function mls_Rank_asc(a,b) { var ra = lsMembers[a].getRawRank(), rb = lsMembers[b].getRawRank(); return (ra == rb) ? mls_Name_asc(a, b) : ((ra == '+' || rb == '-') ? -1 : ((ra == '-' || rb == '+') ? 1 : ((getRank(lsMembers[a]).toLowerCase() < getRank(lsMembers[b]).toLowerCase()) ? -1 : 1))); } function mls_Rank_desc(a,b) { var ra = lsMembers[a].getRawRank(), rb = lsMembers[b].getRawRank(); return (ra == rb) ? mls_Name_asc(a, b) : ((ra == '+' || rb == '-') ? 1 : ((ra == '-' || rb == '+') ? -1 : ((getRank(lsMembers[a]).toLowerCase() < getRank(lsMembers[b]).toLowerCase()) ? 1 : -1))); } function als_Coords_asc(a,b) { var ra = lsAttacks[a].coords.toLowerCase(); var rb = lsAttacks[b].coords.toLowerCase(); return (ra < rb) ? -1 : 1; } function als_Coords_desc(a,b) { var ra = lsAttacks[a].coords.toLowerCase(); var rb = lsAttacks[b].coords.toLowerCase(); return (ra < rb) ? 1 : -1; } function als_Name_asc(a,b) { var ra = lsAttacks[a].planetName.toLowerCase(); var rb = lsAttacks[b].planetName.toLowerCase(); return (ra < rb) ? -1 : 1; } function als_Name_desc(a,b) { var ra = lsAttacks[a].planetName.toLowerCase(); var rb = lsAttacks[b].planetName.toLowerCase(); return (ra < rb) ? 1 : -1; } function als_Owner_asc(a,b) { var ra = lsAttacks[a].ownerName.toLowerCase(); var rb = lsAttacks[b].ownerName.toLowerCase(); return (ra < rb) ? -1 : ((ra > rb) ? 1 : als_Planet_asc(a,b)); } function als_Owner_desc(a,b) { var ra = lsAttacks[a].ownerName.toLowerCase(); var rb = lsAttacks[b].ownerName.toLowerCase(); return (ra < rb) ? 1 : ((ra > rb) ? -1 : als_Planet_desc(a,b)); } function als_Def_asc(a,b) { var ra = parseInt(lsAttacks[a].defPower, 10); var rb = parseInt(lsAttacks[b].defPower, 10); return (ra < rb) ? -1 : ((ra > rb) ? 1 : als_Name_asc(a,b)); } function als_Def_desc(a,b) { var ra = parseInt(lsAttacks[a].defPower, 10); var rb = parseInt(lsAttacks[b].defPower, 10); return (ra < rb) ? 1 : ((ra > rb) ? -1 : als_Name_desc(a,b)); } function als_Att_asc(a,b) { var ra = parseInt(lsAttacks[a].attPower, 10); var rb = parseInt(lsAttacks[b].attPower, 10); return (ra < rb) ? -1 : ((ra > rb) ? 1 : als_Name_asc(a,b)); } function als_Att_desc(a,b) { var ra = parseInt(lsAttacks[a].attPower, 10); var rb = parseInt(lsAttacks[b].attPower, 10); return (ra < rb) ? 1 : ((ra > rb) ? -1 : als_Name_desc(a,b)); } function lec_Name_asc(a,b) { var ra = a.name.toLowerCase(), rb = b.name.toLowerCase(); return (ra > rb) ? 1 : -1; } function lec_Name_desc(a,b) { var ra = a.name.toLowerCase(), rb = b.name.toLowerCase(); return (ra < rb) ? 1 : -1; } function lec_Votes_asc(a,b) { var ra = parseInt(a.nVotes,10), rb = parseInt(b.nVotes,10); return (ra > rb) ? 1 : ((ra < rb) ? -1 : lec_Name_asc(a,b)); } function lec_Votes_desc(a,b) { var ra = parseInt(b.nVotes,10), rb = parseInt(a.nVotes,10); return (ra > rb) ? 1 : ((ra < rb) ? -1 : lec_Name_desc(a,b)); }