From db473209515f792fc1f26f94ae47987cdf58d887 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Thu, 29 Sep 2016 09:15:42 +0200 Subject: [PATCH 1/5] Removed outdated script --- create_shortcut.bat | 31 ------------------------------- 1 file changed, 31 deletions(-) delete mode 100644 create_shortcut.bat diff --git a/create_shortcut.bat b/create_shortcut.bat deleted file mode 100644 index bc653533..00000000 --- a/create_shortcut.bat +++ /dev/null @@ -1,31 +0,0 @@ -@echo off -@cls - -@set /p host="Enter host (default: "127.0.0.1"): " -@if "%host%"=="" set host=127.0.0.1 - -@set /p port="Enter port (default: 25575): " -@if "%port%"=="" set port=25575 - -@set /p passwd="Enter password: " -@if "%passwd%"=="" set passwd= - -set name=connect_%host%-%port% - -@set /p name="Enter shortcut name (default: "%name%.bat"): " -@if "%name%"=="" set name=connect_%host%-%port% - -set command=@mcrcon.exe -t -H %host% -P %port% -p %passwd% - -@echo %command% >> %name%.bat -@echo. -@echo Command: "%command%" -@echo. -@echo Shortcut "%name%.bat" created! -@echo. - -@set "host=" -@set "port=" -@set "passwd=" - -@pause From aa93af6d066a72b213bbd5fd056dfd8d0676cc6b Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Thu, 29 Sep 2016 09:16:01 +0200 Subject: [PATCH 2/5] More cleanup --- launchEverything.bat | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/launchEverything.bat b/launchEverything.bat index 33516b3f..f08a766e 100644 --- a/launchEverything.bat +++ b/launchEverything.bat @@ -2,14 +2,4 @@ cd "Factorio_0.13.17" @RD /S /Q "temp" cd "bin/x64/" start factorio.exe --start-server testmap.zip --rcon-port 12345 --rcon-password 123 --server-settings server-settings.json -cd .. -cd .. -cd .. - -::start cmd /C node client.js -::start cmd /C node master.js - -::cd "Factorio 0.13.9 - Copy/bin/x64" -::@start factorio.exe - pause \ No newline at end of file From 181e570972079b1253eeaef7952689e373024365 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Fri, 30 Sep 2016 19:16:46 +0200 Subject: [PATCH 3/5] Master webpage syntax --- static/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/index.html b/static/index.html index 9d55d35e..084b2e68 100644 --- a/static/index.html +++ b/static/index.html @@ -1,4 +1,4 @@ - + Clusterio From e33109703d7c584655d3da5145d77fb57db25703 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Fri, 30 Sep 2016 19:16:46 +0200 Subject: [PATCH 4/5] Minor minor --- client.js | 2 +- static/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client.js b/client.js index ab6cf8e3..ed069883 100644 --- a/client.js +++ b/client.js @@ -96,7 +96,7 @@ setInterval(function() { // send our RCON command with whatever we got client.exec("/c remote.call('clusterio', 'importMany', '" + sadas + "')"); } -}, 10000) +}, 3000) /* fs.watch(config.factorioDirectory + "/script-output/orders.txt", "utf8", function(eventType, filename) { diff --git a/static/index.html b/static/index.html index 9d55d35e..084b2e68 100644 --- a/static/index.html +++ b/static/index.html @@ -1,4 +1,4 @@ - + Clusterio From 5670bdb77a2d582c8b284cc01c19169c86ee7929 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Fri, 30 Sep 2016 23:23:01 +0200 Subject: [PATCH 5/5] Working on adding charts to master GUI --- master.js | 7 +++++++ static/index.html | 8 ++++++++ static/main.js | 48 +++++++++++++++++++++++++++++++++++++++++++++-- static/style.css | 6 ++++++ 4 files changed, 67 insertions(+), 2 deletions(-) diff --git a/master.js b/master.js index 49b46cd7..6e1bdaf7 100644 --- a/master.js +++ b/master.js @@ -93,6 +93,13 @@ app.get("/inventory", function(req, res) { res.send(docs); }); }); +// endpoint for getting the chartjs library +app.get("/chart.js", function(req, res) { + res.header("Access-Control-Allow-Origin", "*"); + res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept"); + // Check it and send it + res.end(fs.readFileSync("node_modules/chartjs/chart.js")); +}); var server = app.listen(config.masterPort || 8080, function () { console.log("Listening on port %s...", server.address().port); diff --git a/static/index.html b/static/index.html index 084b2e68..ae504e47 100644 --- a/static/index.html +++ b/static/index.html @@ -2,6 +2,7 @@ Clusterio + @@ -25,6 +26,13 @@

Storage

+ + +
+

Production

+
+ +
\ No newline at end of file diff --git a/static/main.js b/static/main.js index d56bb0dc..21f4256c 100644 --- a/static/main.js +++ b/static/main.js @@ -1,10 +1,25 @@ - contents = { "iron-plate":100, "copper-plate":7312, } +function djb2(str){ + var hash = 5381; + for (var i = 0; i < str.length; i++) { + hash = ((hash << 5) + hash) + str.charCodeAt(i); /* hash * 33 + c */ + } + return hash; +} + +function hashColor(str) { + var hash = djb2(str); + var r = (hash & 0xFF0000) >> 16; + var g = (hash & 0x00FF00) >> 8; + var b = hash & 0x0000FF; + return "#" + ("0" + r.toString(16)).substr(-2) + ("0" + g.toString(16)).substr(-2) + ("0" + b.toString(16)).substr(-2); +} + function drawcontents(data) { keys = Object.keys(data); result = ""; @@ -14,14 +29,43 @@ function drawcontents(data) { result = result + "
" document.getElementById("contents").innerHTML = result; } + setInterval(function() { var xmlhttp = new XMLHttpRequest(); xmlhttp.onreadystatechange = function() { if(xmlhttp.readyState == 4 && xmlhttp.status == 200) { data = JSON.parse(xmlhttp.responseText); drawcontents(data); + // render our piechart with up to date information + piedata = []; + for(i=0;i