aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexichi <alexbankai96@gmail.com>2016-04-21 08:55:29 +0200
committeralexichi <alexbankai96@gmail.com>2016-04-21 08:55:29 +0200
commitcb613739dcfb693df277137d8f06d7f800f50145 (patch)
tree449b5cca2f49ae3347cdb8fb4a530ea20c6e578d
parent4b04983d7c9e6b6b09dd4bad707b954b7348bb54 (diff)
downloadcandybox-cb613739dcfb693df277137d8f06d7f800f50145.tar.gz
candybox-cb613739dcfb693df277137d8f06d7f800f50145.tar.bz2
candybox-cb613739dcfb693df277137d8f06d7f800f50145.tar.xz
candybox-cb613739dcfb693df277137d8f06d7f800f50145.zip
mise du parseInt et mise à jour mots anglais
-rw-r--r--js/craftmine.js51
-rw-r--r--js/craftmine.js~51
2 files changed, 102 insertions, 0 deletions
diff --git a/js/craftmine.js b/js/craftmine.js
index e69de29..50d3a47 100644
--- a/js/craftmine.js
+++ b/js/craftmine.js
@@ -0,0 +1,51 @@
+datas = {
+ gold: 0,
+ mine: 0,
+ miners: 1,
+ level: 1
+}
+
+function sendRequest(url, params, callback) {
+ var xhr = new XMLHttpRequest();
+ xhr.open("POST", url);
+ xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xhr.onreadystatechange = function() {
+ if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == "200") {
+ callback(xhr);
+ }
+ }
+ xhr.send(params);
+}
+
+
+function updateDatas(t) {
+ document.getElementById(t).innerHTML = datas[t];
+}
+
+function withdrawMine() {
+ sendRequest("craftmine.php", "op=withdrawMine", function() {
+ datas.gold += parseInt(datas.mine);
+ datas.mine = 0;
+ updateDatas("gold");
+ updateDatas("mine");
+ })
+}
+
+function initCraftMine() {
+ sendRequest("craftmine.php", "op=getCraftMine", function(xhr) {
+ var ret = xhr.responseText;
+ datas.gold = ret;
+ updateDatas("gold");
+ })
+}
+
+
+function updateMine() {
+ datas.mine += (datas.miners+1);
+ updateDatas("mine");
+}
+
+function init() {
+ initCraftMine();
+ window.setInterval(updateMine, 1000);
+}
diff --git a/js/craftmine.js~ b/js/craftmine.js~
new file mode 100644
index 0000000..bc03d6c
--- /dev/null
+++ b/js/craftmine.js~
@@ -0,0 +1,51 @@
+datas = {
+ gold: 0,
+ mine: 0,
+ miners: 1,
+ level: 1
+}
+
+function sendRequest(url, params, callback) {
+ var xhr = new XMLHttpRequest();
+ xhr.open("POST", url);
+ xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
+ xhr.onreadystatechange = function() {
+ if(xhr.readyState == XMLHttpRequest.DONE && xhr.status == "200") {
+ callback(xhr);
+ }
+ }
+ xhr.send(params);
+}
+
+
+function updateDatas(t) {
+ document.getElementById(t).innerHTML = datas[t];
+}
+
+function withdrawMine() {
+ sendRequest("craftmine.php", "op=withdrawMine", function() {
+ datas.gold += parseInt(datas.mine);
+ datas.mine = 0;
+ updateDatas("gold");
+ updateDatas("mine");
+ })
+}
+
+function initCraftMine() {
+ sendRequest("craftmine.php", "op=getCraftMine", function(xhr) {
+ var ret = xhr.responseText;
+ datas.gold = ret;
+ updateDatas("gold");
+ })
+}
+
+
+function updateMine() {
+ datas.mine += (datas.mineurs+1);
+ updateDatas("mine");
+}
+
+function init() {
+ initCraftMine();
+ window.setInterval(updateMine, 1000);
+}