/ ‘grepolis.user.js’

This commit is contained in:
Jan Bader 2014-06-15 00:28:25 +02:00
parent a14912143a
commit f5f5cdc4f6

View File

@ -20,17 +20,9 @@
lastAmounts = ""; lastAmounts = "";
console.log("Initializing..."); console.log("Initializing...");
windows = {}; windows = {};
durations = {};
//farm_ids = [1225, 1226, 1228, 1229, 1230, 1231]; //farm_ids = [1225, 1226, 1228, 1229, 1230, 1231];
farm_ids = [20466, 20472, 20471]; farm_ids = [20466, 20472, 20471];
farm_ids.forEach(function(xFarmId) {
console.log("Setting timer to 5s for Farm " + xFarmId);
setTimeout(getWaresTick(xFarmId), 5000 + rand(5));
});
window.onclose = function() {
alert("test");
};
var logWindow = new GPWindow(-1, null); var logWindow = new GPWindow(-1, null);
logWindow.createWindow(); logWindow.createWindow();
@ -49,6 +41,13 @@
}); });
logWindowElement.empty(); logWindowElement.empty();
farm_ids.forEach(function(xFarmId) {
var tmout = 5000 + rand(5);
setTimeout(getWaresTick(xFarmId), tmout);
var tmoutId = 'farm-' + xFarmId
logWindowElement.append('<span id="' + tmoutId + '"><script>countdown(' + Math.floor(tmout/10) + ', "' + tmoutId + '");</script></span><br />');
})
$("#ui-id-1").empty().append("<select id=choosefarmduration><option value=300>5min</option><option value=1200>20min</option><option value=5400>90min</option><option value=14400>4h</option></select>"); $("#ui-id-1").empty().append("<select id=choosefarmduration><option value=300>5min</option><option value=1200>20min</option><option value=5400>90min</option><option value=14400>4h</option></select>");
var choose = $("#choosefarmduration")[0]; var choose = $("#choosefarmduration")[0];
choose.onchange = function() { choose.onchange = function() {
@ -138,6 +137,7 @@
getWaresFromFarm(wnd, mood, xFarmId); getWaresFromFarm(wnd, mood, xFarmId);
} finally { } finally {
durations[xFarmId] = timeout / 1000;
setTimeout(getWaresTick(xFarmId), timeout); setTimeout(getWaresTick(xFarmId), timeout);
} }
} }
@ -156,4 +156,21 @@
function buttonIsInitialized() { function buttonIsInitialized() {
return typeof(btn) != "undefined" && btn != null && btn[0] != null; return typeof(btn) != "undefined" && btn != null && btn[0] != null;
} }
function countdown(time, id){
t = time;
h = Math.floor(t/(60*60)) % 24;
m = Math.floor(t/60) %60;
s = t %60;
h = (h < 10) ? "0"+h : h;
m = (m < 10) ? "0"+m : m;
s = (s < 10) ? "0"+s : s;
strZeit = h + ":" + m + ":" + s;
window.setTimeout('countdown('+ --time+',\''+id+'\')',1000);
document.getElementById(id).innerHTML = strZeit;
}
})() })()