From 6b6ffe5904df318c704f7be84c84b2e5cb0604a6 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Thu, 20 Oct 2016 22:47:36 +0200 Subject: [PATCH 1/6] #8 Working on icons in masterGUI --- static/main.js | 64 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 62 insertions(+), 2 deletions(-) diff --git a/static/main.js b/static/main.js index ed6b580e..3139d400 100644 --- a/static/main.js +++ b/static/main.js @@ -20,12 +20,17 @@ function hashColor(str) { return "#" + ("0" + r.toString(16)).substr(-2) + ("0" + g.toString(16)).substr(-2) + ("0" + b.toString(16)).substr(-2); } + + // function to draw data we recieve from ajax requests function drawcontents(data) { - keys = Object.keys(data); result = ""; for(i = 0;i < data.length; i++) { - result = result + ""; + var img = ""; + if(imagedata[data[i].name]){ + img = "https://wiki.factorio.com/images/" + imagedata[data[i].name] + ".png" + } + result = result + ""; } result = result + "
" + data[i].name + "" + data[i].count + "
" + data[i].name + "" + data[i].count + "
" document.getElementById("contents").innerHTML = result; @@ -87,6 +92,7 @@ function drawcharts() { // this is where we generate new data var newDataA = piedata[0].value - piedataOld[0].value; var newDataB = piedata[1].value - piedataOld[1].value; + // not quite sure how this works, where is dataSetA placed in data/the graph? dataSetA.push(newDataA); dataSetB.push(newDataB); dataSetA.shift(); @@ -162,3 +168,57 @@ setInterval(function() { xmlhttp.send(); }, 500) +// image data +var imagedata = { + ["raw-wood"]: "Raw-wood", + ["alien-artifact"]: "Alien-artifact", + ["heavy-oil"]: "Heavy-oil", + ["engine-unit"]: "Engine-unit", + ["electric-engine-unit"]: "Electric-engine-unit", + ["flying-robot-frame"]: "Flying-robot-frame", + ["alien-science_pack"]: "Alien-science-pack", + ["empty-barrel"]: "Barrel-empty", + ["transport-belt"]: "Basic-transport-belt", + ["underground-belt"]: "Basic-transport-belt-to-ground", + ["fast-underground-belt"]: "Fast-transport-belt-to-ground", + ["express-underground-belt"]: "Express-transport-belt-to-ground", + ["splitter"]: "Basic-splitter", + ["inserter"]: "Inserter-icon", + ["stack-inserter"]: "Stack_inserter", + ["stack-filter-inserter"]: "Stack_filter_inserter", + ["efficiency-module"]: "Effectivity-module", + ["efficiency-module_2"]: "Effectivity-module-2", + ["efficiency-module_3"]: "Effectivity-module-3", + ["low-density-structure"]: "Rocket-structure", + ["electric-mining-drill"]: "Basic-mining-drill", + ["burner-mining-drill"]: "Burner-mining-drill", + ["active-provider-chest"]: "Logistic-chest-active-provider", + ["passive-provider-chest"]: "Logistic-chest-passive-provider", + ["storage-chest"]: "Logistic-chest-storage", + ["requester-chest"]: "Logistic-chest-requester", + ["wall"]: "Stone-wall", + ["medium-electric-pole"]: "Medium-electric-pole", + ["lamp"]: "Small-lamp", + ["regular-magazine"]: "Basic-bullet-magazine", + ["piercing-rounds_magazine"]: "Piercing-bullet-magazine", + ["flamethrower-ammo"]: "Flame-thrower-ammo", + ["cannon-shells"]: "Cannon-shell", + ["explosive-cannon-shells"]: "Explosive-cannon-shell", + ["land-mine"]: "Land-mine-research", + ["cluster-grenade"]: "Cluster_grenade", + ["shotgun-shells"]: "Shotgun-shell", + ["piercing-shotgun-shells"]: "Piercing-shotgun-shell", + ["coal"]: "Coal", + ["copper-ore"]: "Copper-ore", + ["iron-ore"]: "Iron-ore", + ["offshore-pump"]: "Offshore-pump", + ["boiler"]: "Boiler", + ["steam-engine"]: "Steam-engine", + ["chemical-plant"]: "Chemical-plant", + ["rocket-control-unit"]: "Rocket-control-unit", + ["stone-furnace"]: "Stone-furnace", + ["small-electric-pole"]: "Small-electric-pole", + ["burner-inserter"]: "Burner-inserter", + ["electronic-circuit"]: "Electronic-circuit", + ["advanced-circuit"]: "Advanced-circuit", +} From 59ddb289a8010467c7a8293d3e3f2a38bcd7691e Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Fri, 21 Oct 2016 09:22:35 +0200 Subject: [PATCH 2/6] Removed jumping related to icons --- static/style.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/static/style.css b/static/style.css index b67f4dbb..995fcd40 100644 --- a/static/style.css +++ b/static/style.css @@ -22,6 +22,11 @@ #contents table { border: 1px solid black; } + +#contents td img { + height:32px; + width:32px; +} #contentGraph { float:left; } From 3ea2530dab5114e486d7925341ce7432d5b6eb63 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Fri, 21 Oct 2016 11:04:48 +0200 Subject: [PATCH 3/6] Moar icons :D --- static/main.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/static/main.js b/static/main.js index 3139d400..f62b5481 100644 --- a/static/main.js +++ b/static/main.js @@ -20,7 +20,9 @@ function hashColor(str) { return "#" + ("0" + r.toString(16)).substr(-2) + ("0" + g.toString(16)).substr(-2) + ("0" + b.toString(16)).substr(-2); } - +function capitalizeFirstLetter(string) { + return string.charAt(0).toUpperCase() + string.slice(1); +} // function to draw data we recieve from ajax requests function drawcontents(data) { @@ -29,6 +31,8 @@ function drawcontents(data) { var img = ""; if(imagedata[data[i].name]){ img = "https://wiki.factorio.com/images/" + imagedata[data[i].name] + ".png" + } else { + img = "https://wiki.factorio.com/images/" + capitalizeFirstLetter(data[i].name) + ".png"; } result = result + "" + data[i].name + "" + data[i].count + ""; } From 8562bccd5f9d23fecce9ef78ea4e2ff9a2ec22d9 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Fri, 21 Oct 2016 11:14:04 +0200 Subject: [PATCH 4/6] Betterer icons --- static/main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/static/main.js b/static/main.js index f62b5481..07c65671 100644 --- a/static/main.js +++ b/static/main.js @@ -25,6 +25,9 @@ function capitalizeFirstLetter(string) { } // function to draw data we recieve from ajax requests +function hideThis(object) { + object.style.visibility = "hidden"; +} function drawcontents(data) { result = ""; for(i = 0;i < data.length; i++) { @@ -34,7 +37,7 @@ function drawcontents(data) { } else { img = "https://wiki.factorio.com/images/" + capitalizeFirstLetter(data[i].name) + ".png"; } - result = result + ""; + result = result + ""; } result = result + "
" + data[i].name + "" + data[i].count + "
" + data[i].name + "" + data[i].count + "
" document.getElementById("contents").innerHTML = result; From 82f52c6e21cc815b45a3228ed0b3239c64965067 Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Fri, 21 Oct 2016 15:39:39 +0200 Subject: [PATCH 5/6] Item list sort after amount --- static/main.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/static/main.js b/static/main.js index 07c65671..b6106566 100644 --- a/static/main.js +++ b/static/main.js @@ -28,7 +28,14 @@ function capitalizeFirstLetter(string) { function hideThis(object) { object.style.visibility = "hidden"; } +function sortByKey(array, key) { + return array.sort(function(a, b) { + var x = Number(a[key]); var y = Number(b[key]); + return ((x < y) ? 1 : ((x > y) ? -1 : 0)); + }); +} function drawcontents(data) { + var data = sortByKey(data, "count"); result = ""; for(i = 0;i < data.length; i++) { var img = ""; From 12ca57af6129f4b06a1aa7a21da6c4d8fcef081f Mon Sep 17 00:00:00 2001 From: Danielv123 Date: Fri, 21 Oct 2016 16:00:40 +0200 Subject: [PATCH 6/6] More icon exceptions --- static/main.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/static/main.js b/static/main.js index b6106566..319db5b2 100644 --- a/static/main.js +++ b/static/main.js @@ -222,17 +222,7 @@ var imagedata = { ["cluster-grenade"]: "Cluster_grenade", ["shotgun-shells"]: "Shotgun-shell", ["piercing-shotgun-shells"]: "Piercing-shotgun-shell", - ["coal"]: "Coal", - ["copper-ore"]: "Copper-ore", - ["iron-ore"]: "Iron-ore", - ["offshore-pump"]: "Offshore-pump", - ["boiler"]: "Boiler", - ["steam-engine"]: "Steam-engine", - ["chemical-plant"]: "Chemical-plant", - ["rocket-control-unit"]: "Rocket-control-unit", - ["stone-furnace"]: "Stone-furnace", - ["small-electric-pole"]: "Small-electric-pole", - ["burner-inserter"]: "Burner-inserter", - ["electronic-circuit"]: "Electronic-circuit", - ["advanced-circuit"]: "Advanced-circuit", + ["accumulator"]: "Basic-accumulator", + ["beacon"]: "Basic-beacon", + }