diff --git a/grepolis.user.js b/grepolis.user.js
index de2bb7c..15c4b00 100644
--- a/grepolis.user.js
+++ b/grepolis.user.js
@@ -20,17 +20,9 @@
lastAmounts = "";
console.log("Initializing...");
windows = {};
+ durations = {};
//farm_ids = [1225, 1226, 1228, 1229, 1230, 1231];
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);
logWindow.createWindow();
@@ -49,6 +41,13 @@
});
logWindowElement.empty();
+ farm_ids.forEach(function(xFarmId) {
+ var tmout = 5000 + rand(5);
+ setTimeout(getWaresTick(xFarmId), tmout);
+ var tmoutId = 'farm-' + xFarmId
+ logWindowElement.append('
');
+ })
+
$("#ui-id-1").empty().append("");
var choose = $("#choosefarmduration")[0];
choose.onchange = function() {
@@ -138,6 +137,7 @@
getWaresFromFarm(wnd, mood, xFarmId);
} finally {
+ durations[xFarmId] = timeout / 1000;
setTimeout(getWaresTick(xFarmId), timeout);
}
}
@@ -156,4 +156,21 @@
function buttonIsInitialized() {
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;
+ }
})()
\ No newline at end of file