This commit is contained in:
GordonDaFreeman 2018-01-17 10:57:46 +01:00
parent e1a7c248b8
commit 3d021a9d13
14 changed files with 209 additions and 146 deletions

View File

@ -26,14 +26,8 @@
}
#bottom-right {
right: 0;
bottom: 0;
position: absolute;
}
#bottom-left {
left: 5px;
right: 5px;
bottom: 0;
position: absolute;
position: fixed;
}

View File

@ -58,6 +58,6 @@
</div>
</body>
<div id="container">
<div class="ui-widget" id="bottom-left">Inspiration Pyramidalist<br>© MasterGordon & Ph3nix</div>
<div class="ui-widget" id="bottom-left">Thanks to Pyramidalist and his community<br>© MasterGordon & Ph3nix</div>
</div>
</html>

View File

@ -21,40 +21,55 @@ itemsRequest.onload = function() {
}
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("<option value=\""+allItemsArray[i].id+"\">" + allItemsArray[i].name + "</option>")
$("#k_"+allItemsArray[i].type).append("<li><div class=\"additem\" id=\"add"+ allItemsArray[i].id +"\">" + allItemsArray[i].name + "</div></li>")
if (!('disabled' in allItemsArray[i])) {
// $("#itemtoadd").append("<option
// value=\""+allItemsArray[i].id+"\">" + allItemsArray[i].name +
// "</option>")
$("#k_" + allItemsArray[i].type).append(
"<li><div class=\"additem\" id=\"add" + allItemsArray[i].id
+ "\">" + allItemsArray[i].name + "</div></li>")
} 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))
$(".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!")
var tagid = 'item_' + id
if ($('#' + tagid).length) {
console.log(id + " allready exists!")
return
}
$("#tocraft").append('<input id="'+tagid+'" name="value"><label id="lable_'+tagid+'" style="margin-top: 3px;" class="ui-widget" for="'+tagid+'"> '+getItemFromId(id).name+'<br></label>')
$("#"+tagid).spinner({
min: 0,
numberFormat: "n",
change: function( event, ui ) {
if($("#"+tagid).spinner( "value" )==0){
$("#"+tagid).spinner( "destroy" )
$("#"+tagid).remove()
$("#lable_"+tagid).remove()
$("#tocraft")
.append(
'<input id="'
+ tagid
+ '" name="value"><label id="lable_'
+ tagid
+ '" style="margin-top: 3px;" class="ui-widget" for="'
+ tagid + '"> '
+ getItemFromId(id).name
+ '<br></label>')
$("#" + 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)
$("#" + tagid).val(1)
})
}
@ -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,21 +90,23 @@ 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<allItemsArray.length;i++){
if(allItemsArray[i].id == index)
function getItemFromId(index) {
for (var i = 0; i < allItemsArray.length; i++) {
if (allItemsArray[i].id == index)
return allItemsArray[i]
}
return null
}
$( document ).ready(function() {
$(document)
.ready(
function() {
// SEITE HAT GELADEN
$("#itemtoadd").selectmenu()
@ -97,43 +114,79 @@ $( document ).ready(function() {
$("#calc").button()
// BUTTONS
$(".additem").click(function() {
$(".additem")
.click(
function() {
var id = $("#itemtoadd").val()
console.log("Adding "+id+"...")
var tagid = 'item_'+id
if($('#'+tagid).length){
console.log(id+" allready exists!")
console.log("Adding " + id + "...")
var tagid = 'item_' + id
if ($('#' + tagid).length) {
console.log(id
+ " allready exists!")
return
}
$("#tocraft").append('<input id="'+tagid+'" name="value"><label id="lable_'+tagid+'" style="margin-top: 3px;" class="ui-widget" for="'+tagid+'"> '+getItemFromId(id).name+'<br></label>')
$("#"+tagid).spinner({
min: 0,
numberFormat: "n",
change: function( event, ui ) {
if($("#"+tagid).spinner( "value" )==0){
$("#"+tagid).spinner( "destroy" )
$("#"+tagid).remove()
$("#lable_"+tagid).remove()
$("#tocraft")
.append(
'<input id="'
+ tagid
+ '" name="value"><label id="lable_'
+ tagid
+ '" style="margin-top: 3px;" class="ui-widget" for="'
+ tagid
+ '"> '
+ getItemFromId(id).name
+ '<br></label>')
$("#" + 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)
$("#" + tagid).val(1)
})
$("#calc").click(function() {
$("#calc")
.click(
function() {
requieredCount = []
requieredItems = []
for(var i=0;i<newid;i++){
var tag = "#item_"+i;
if($(tag).length){
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){
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])]++
} else {
requieredCount[requieredItems
.indexOf(item.crafting[j])]++
}
}
}
@ -142,47 +195,63 @@ $( document ).ready(function() {
updateoutput()
})
})
})
function updateoutput() {
$("#output").empty()
for (var i = 0; i < requieredItems.length; i++) {
if(allItems[requieredItems[i]]){
$("#output").append("<span id=\""+i+"\" class=\"ui-widget outputitem splitable\">" +requieredCount[i]+"x "+allItems[requieredItems[i]].name+ "</span><br>")
}else{
$("#output").append("<span id=\""+i+"\" class=\"ui-widget outputitem notsplitable\">" +requieredCount[i]+"x "+requieredItems[i]+ "</span><br>")
if (allItems[requieredItems[i]]) {
$("#output").append(
"<span id=\"" + i
+ "\" class=\"ui-widget outputitem splitable\">"
+ requieredCount[i] + "x "
+ allItems[requieredItems[i]].name + "</span><br>")
} else {
$("#output").append(
"<span id=\"" + i
+ "\" class=\"ui-widget outputitem notsplitable\">"
+ requieredCount[i] + "x " + requieredItems[i]
+ "</span><br>")
}
}
$(".outputitem").click(function() {
$(".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]){
if (allItems[itemid]) {
var item = allItems[itemid]
requieredCount.splice(index,1)
requieredItems.splice(index,1)
for(var i=0;i<itemcount;i++){
for(var j=0;j<item.crafting.length;j++){
requieredCount.splice(index, 1)
requieredItems.splice(index, 1)
for (var i = 0; i < itemcount; i++) {
for (var j = 0; j < item.crafting.length; j++) {
var count = 1
if(item.count)
count = 1/item.count
if (item.count)
count = 1 / item.count
if(requieredItems.indexOf(item.crafting[j])==-1){
if (requieredItems
.indexOf(item.crafting[j]) == -1) {
requieredCount[requieredItems.length] = count
requieredItems[requieredItems.length] = item.crafting[j]
console.log("-1")
}else{
requieredCount[requieredItems.indexOf(item.crafting[j])] += count
} else {
requieredCount[requieredItems
.indexOf(item.crafting[j])] += count
}
}
}
for(var i=0;i<requieredCount.length;i++){
requieredCount[i]=Math.ceil(requieredCount[i])
}
for (var i = 0; i < requieredCount.length; i++) {
requieredCount[i] = Math
.ceil(requieredCount[i])
}
$('#' + index).fadeOut(300)
setTimeout(function() {
updateoutput()
}, 300)
}
})
}

View File

@ -2,5 +2,5 @@
"type":"tools",
"name": "Axe of the Wyvern",
"crafting": ["Diamond_axe", "Draconium Ingot", "Draconium Ingot", "wyvern_core", "wyvern_energy_core"]
"crafting": ["diamond_axe", "Draconium Ingot", "Draconium Ingot", "wyvern_core", "wyvern_energy_core"]
}

View File

@ -3,5 +3,5 @@
"type":"other",
"name": "Block of Emerald",
"disabled": true,
"crafting": ["emerald", "emerald", "emerald", "emerald", "emerald", "emerald", "emerald", "emerald", "emerald"]
"crafting": ["Emerald", "Emerald", "Emerald", "Emerald", "Emerald", "Emerald", "Emerald", "Emerald", "Emerald"]
}

View File

@ -2,5 +2,5 @@
"type":"tools",
"name": "Draconic Hoe",
"crafting": ["Diamond_hoe", "awakened_draconium_ingot", "awakened_draconium_ingot", "awakened_core", "draconic_energy_core"]
"crafting": ["diamond_hoe", "awakened_draconium_ingot", "awakened_draconium_ingot", "awakened_core", "draconic_energy_core"]
}

View File

@ -3,5 +3,5 @@
"type":"other",
"name": "Eye of Ender",
"disabled": true,
"crafting": ["ender_pearl", "blaze_powder"]
"crafting": ["Ender Pearl", "blaze_powder"]
}

View File

@ -3,5 +3,5 @@
"type":"other",
"name": "Golden Apple",
"disabled": true,
"crafting": ["apple", "Gold Ingot", "Gold Ingot", "Gold Ingot", "Gold Ingot", "Gold Ingot", "Gold Ingot", "Gold Ingot", "Gold Ingot"]
"crafting": ["Apple", "Gold Ingot", "Gold Ingot", "Gold Ingot", "Gold Ingot", "Gold Ingot", "Gold Ingot", "Gold Ingot", "Gold Ingot"]
}

View File

@ -2,5 +2,5 @@
"type":"tools",
"name": "Pickaxe of the Wyvern",
"crafting": ["Diamond_pickaxe", "Draconium Ingot", "Draconium Ingot", "wyvern_core", "wyvern_energy_core"]
"crafting": ["diamond_pickaxe", "Draconium Ingot", "Draconium Ingot", "wyvern_core", "wyvern_energy_core"]
}

View File

@ -2,5 +2,5 @@
"type":"tools",
"name": "Shovel of the Wyvern",
"crafting": ["Diamond_shovel", "Draconium Ingot", "Draconium Ingot", "wyvern_core", "wyvern_energy_core"]
"crafting": ["diamond_shovel", "Draconium Ingot", "Draconium Ingot", "wyvern_core", "wyvern_energy_core"]
}

View File

@ -2,5 +2,5 @@
"type":"tools",
"name": "Sword of the Wyvern",
"crafting": ["Diamond_sword", "Draconium Ingot", "Draconium Ingot", "wyvern_core", "wyvern_energy_core"]
"crafting": ["diamond_sword", "Draconium Ingot", "Draconium Ingot", "wyvern_core", "wyvern_energy_core"]
}

View File

@ -1,5 +1,5 @@
{
"type": "upgrades",
"name": "Upgrade Tier Basic",
"crafting": ["diamond", "diamond", "draconic_core", "golden_apple", "golden_apple", "eye_of_ender", "eye_of_ender"]
"crafting": ["Diamond", "Diamond", "draconic_core", "golden_apple", "golden_apple", "eye_of_ender", "eye_of_ender"]
}

View File

@ -1,5 +1,5 @@
{
"type": "upgrades",
"name": "Upgrade Tier Chaotic",
"crafting": ["wyvern_core", "wyvern_core", "awakened_core", "awakened_core", "dragon_egg", "dragon_egg", "chaotic_core"]
"crafting": ["wyvern_core", "wyvern_core", "awakened_core", "awakened_core", "Dragon Egg", "Dragon Egg", "chaotic_core"]
}

View File

@ -1,5 +1,5 @@
{
"type": "upgrades",
"name": "Upgrade Tier Wyvern",
"crafting": ["nether_star", "nether_star", "draconic_core", "draconic_core", "emerald", "emerald", "wyvern_core"]
"crafting": ["nether_star", "nether_star", "draconic_core", "draconic_core", "Emerald", "Emerald", "wyvern_core"]
}