From 3d021a9d135e1eced7d9904140d3338a0534a4cc Mon Sep 17 00:00:00 2001 From: GordonDaFreeman Date: Wed, 17 Jan 2018 10:57:46 +0100 Subject: [PATCH] bug fix --- css/main.css | 10 +- index.html | 2 +- js/main.js | 321 +++++++++++++--------- resources/items/axe_of_the_wyvern.txt | 2 +- resources/items/block_of_emerald.txt | 2 +- resources/items/draconic_hoe.txt | 2 +- resources/items/eye_of_ender.txt | 2 +- resources/items/golden_apple.txt | 2 +- resources/items/pickaxe_of_the_wyvern.txt | 2 +- resources/items/shovel_of_the_wyvern.txt | 2 +- resources/items/sword_of_the_wyvern.txt | 2 +- resources/upgrades/tier_basic.txt | 2 +- resources/upgrades/tier_chaotic.txt | 2 +- resources/upgrades/tier_wyvern.txt | 2 +- 14 files changed, 209 insertions(+), 146 deletions(-) diff --git a/css/main.css b/css/main.css index 94b0ddc..19f7981 100644 --- a/css/main.css +++ b/css/main.css @@ -26,14 +26,8 @@ } -#bottom-right { - right: 0; - bottom: 0; - position: absolute; -} - #bottom-left { - left: 5px; + right: 5px; bottom: 0; - position: absolute; + position: fixed; } \ No newline at end of file diff --git a/index.html b/index.html index 57d8ae2..b1abb17 100644 --- a/index.html +++ b/index.html @@ -58,6 +58,6 @@
-
Inspiration Pyramidalist
© MasterGordon & Ph3nix
+
Thanks to Pyramidalist and his community
© MasterGordon & Ph3nix
\ No newline at end of file diff --git a/js/main.js b/js/main.js index f6d789e..f96f629 100644 --- a/js/main.js +++ b/js/main.js @@ -17,45 +17,60 @@ itemsRequest.onload = function() { for (var i = 0; i < items.length && !(items[i] in window); i++) { loadJSON(items[i]) } - + } itemsRequest.send() - function loadHTML() { $("#menu li ul").empty() $("#k_other").empty() for (var i = 0; i < allItemsArray.length; i++) { - if (!('disabled' in allItemsArray[i])){ - //$("#itemtoadd").append("") - $("#k_"+allItemsArray[i].type).append("
  • " + allItemsArray[i].name + "
  • ") + if (!('disabled' in allItemsArray[i])) { + // $("#itemtoadd").append("") + $("#k_" + allItemsArray[i].type).append( + "
  • " + allItemsArray[i].name + "
  • ") } else { - //console.log(allItemsArray[i].name+" disabled. Not loading") + // console.log(allItemsArray[i].name+" disabled. Not loading") } } - - $(".additem").click(function() { - var id = parseInt($(this).attr("id").substring(3,99)) - console.log(id) - var tagid = 'item_'+id - if($('#'+tagid).length){ - console.log(id+" allready exists!") - return - } - $("#tocraft").append('') - $("#"+tagid).spinner({ - min: 0, - numberFormat: "n", - change: function( event, ui ) { - if($("#"+tagid).spinner( "value" )==0){ - $("#"+tagid).spinner( "destroy" ) - $("#"+tagid).remove() - $("#lable_"+tagid).remove() - } - } - }); - $("#"+tagid).val(1) - }) + + $(".additem") + .click( + function() { + var id = parseInt($(this).attr("id").substring(3, 99)) + console.log(id) + var tagid = 'item_' + id + if ($('#' + tagid).length) { + console.log(id + " allready exists!") + return + + } + $("#tocraft") + .append( + '') + $("#" + tagid).spinner({ + min : 0, + numberFormat : "n", + change : function(event, ui) { + if ($("#" + tagid).spinner("value") == 0) { + $("#" + tagid).spinner("destroy") + $("#" + tagid).remove() + $("#lable_" + tagid).remove() + } + } + }); + $("#" + tagid).val(1) + }) } function loadJSON(itemname) { @@ -65,9 +80,9 @@ function loadJSON(itemname) { itemRequest.onload = function() { itemname = itemname.replace(/\s/g, "") var item = JSON.parse(itemRequest.responseText) - if (!('name' in item)){ + if (!('name' in item)) { item.name = itemname - console.warn("missing key \"name\" in "+itemname) + console.warn("missing key \"name\" in " + itemname) } item.id = newid allItems[itemname] = item @@ -75,114 +90,168 @@ function loadJSON(itemname) { console.log(item) loadHTML() newid++ - if(newid==items.length) - $( "#menu" ).menu( "refresh" ); + if (newid == items.length) + $("#menu").menu("refresh"); } itemRequest.send() } -function getItemFromId(index){ - for(var i=0;i') - $("#"+tagid).spinner({ - min: 0, - numberFormat: "n", - change: function( event, ui ) { - if($("#"+tagid).spinner( "value" )==0){ - $("#"+tagid).spinner( "destroy" ) - $("#"+tagid).remove() - $("#lable_"+tagid).remove() - } - } - }); - $("#"+tagid).val(1) - }) - - $("#calc").click(function() { - requieredCount = [] - requieredItems = [] - for(var i=0;i') + $("#" + tagid) + .spinner( + { + min : 0, + numberFormat : "n", + change : function( + event, ui) { + if ($( + "#" + + tagid) + .spinner( + "value") == 0) { + $( + "#" + + tagid) + .spinner( + "destroy") + $( + "#" + + tagid) + .remove() + $( + "#lable_" + + tagid) + .remove() + } + } + }); + $("#" + tagid).val(1) + }) + + $("#calc") + .click( + function() { + requieredCount = [] + requieredItems = [] + for (var i = 0; i < newid; i++) { + var tag = "#item_" + i; + if ($(tag).length) { + var item = allItemsArray[i] + for (var n = 0; n < $(tag) + .spinner("value"); n++) { + for (var j = 0; j < item.crafting.length; j++) { + if (requieredItems + .indexOf(item.crafting[j]) == -1) { + requieredCount[requieredItems.length] = 1 + requieredItems[requieredItems.length] = item.crafting[j] + } else { + requieredCount[requieredItems + .indexOf(item.crafting[j])]++ + } + } + } + } + } + updateoutput() + }) + + }) function updateoutput() { $("#output").empty() for (var i = 0; i < requieredItems.length; i++) { - if(allItems[requieredItems[i]]){ - $("#output").append("" +requieredCount[i]+"x "+allItems[requieredItems[i]].name+ "
    ") - }else{ - $("#output").append("" +requieredCount[i]+"x "+requieredItems[i]+ "
    ") + if (allItems[requieredItems[i]]) { + $("#output").append( + "" + + requieredCount[i] + "x " + + allItems[requieredItems[i]].name + "
    ") + } else { + $("#output").append( + "" + + requieredCount[i] + "x " + requieredItems[i] + + "
    ") } } - - $(".outputitem").click(function() { - console.log($(this).attr('id')) - var index = parseInt($(this).attr('id')) - var itemid = requieredItems[index] - var itemcount = requieredCount[index] - if(allItems[itemid]){ - var item = allItems[itemid] - requieredCount.splice(index,1) - requieredItems.splice(index,1) - for(var i=0;i