var g = {} contents = { "iron-plate":100, "copper-plate":7312, } // nice functions // hash a string to a hash 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; } // hash a string to a color 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); } // exactly what you would expect it to, returns String function capitalizeFirstLetter(string) { return string.charAt(0).toUpperCase() + string.slice(1); } // hide the HTML object passed as argument #1 function hideThis(object) { object.style.visibility = "hidden"; } // function to sort arrays of objects after a keys value 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 to draw data we recieve from ajax requests function drawcontents(data) { var data = sortByKey(data, "count"); result = "
| " + data[i].name + " | " + data[i].count + " |
Last seen: "+seenDate+"
Port: "+slaveData[key].serverPort+"
Host: "+slaveData[key].mac+"
" } } document.querySelector("#slaves > #display").innerHTML = HTML } } xmlhttp.open("GET", "slaves", true); xmlhttp.send(); }, 500) // image data // key is the name of the item in the database, value is the name of the image on wiki.factorio.com/images/* // this list has to include all entities that doesn't just follow the simple capitalize first letter convention var imagedata = { ["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", ["accumulator"]: "Basic-accumulator", ["beacon"]: "Basic-beacon", }