Removed debug, small fixes

This commit is contained in:
Stijn Bannink 2023-01-20 19:55:28 +01:00
parent b48938f8dd
commit 05ef0e5e3c
4 changed files with 4 additions and 10 deletions

View file

@ -33,7 +33,7 @@ function buildJSON(item, models) {
for (let i = 0; i < models.length; i++) {
const model = models[i];
const damage = i + 1 / itemDamages[item];
const damage = (i + 1) / itemDamages[item];
json['overrides'][i + 1] = {
'predicate': {

View file

@ -1 +1 @@
function buildJSON(e,t){const a={parent:"item/handheld"};a.textures={layer0:"item/"+e},a.overrides=[],a.overrides[0]={predicate:{damaged:0,damage:0},model:"item/"+e};for(let d=0;d<t.length;d++){const r=t[d],i=d+1/itemDamages[e];a.overrides[d+1]={predicate:{damaged:0,damage:i},model:r}}return a.overrides[t.length+1]={predicate:{damaged:1,damage:0},model:"item/"+e},JSON.stringify(a,null,2)}const itemDamages={leather_boots:64,netherite_hoe:2030};
function buildJSON(e,t){const a={parent:"item/handheld"};a.textures={layer0:"item/"+e},a.overrides=[],a.overrides[0]={predicate:{damaged:0,damage:0},model:"item/"+e};for(let d=0;d<t.length;d++){const r=t[d],i=(d+1)/itemDamages[e];a.overrides[d+1]={predicate:{damaged:0,damage:i},model:r}}return a.overrides[t.length+1]={predicate:{damaged:1,damage:0},model:"item/"+e},JSON.stringify(a,null,2)}const itemDamages={leather_boots:64,netherite_hoe:2030};

8
dist/js/scripts.js vendored
View file

@ -19,8 +19,6 @@ $(document).ready(function () {
const currentVal = parseInt(input.attr('value'));
if (!isNaN(currentVal)) {
console.log("#iteminput" + currentVal);
if (currentVal > input.attr('min')) {
input.attr('value', (currentVal - 1).toString());
}
@ -77,12 +75,8 @@ $(document).ready(function () {
form.on("submit", function (e) {
e.preventDefault();
//Get selected item
//Get selected item and amount of models
const selectedItem = item.val();
//Get amount of items
const fieldName = $('.btn-number').attr('data-field');
const input = $("input[name='" + fieldName + "']");
const currentVal = parseInt(input.attr('value'));
//Build models array

View file

@ -1 +1 @@
$(document).ready(function(){function t(){const t=["red_car","blue_car","green_car","orange_car","blue_bicycle","red_bicycle","green_bicycle","orange_bicycle"];return t[Math.floor(Math.random()*t.length)]}const e=$("#calculatorForm"),a=$("#formItems"),n=$("#item"),r=$("#itemcount"),i=$("#items"),o=$("#content"),l=$("#copyButton"),c=$("#downloadButton"),u=$("#minus"),s=$("#plus"),d=$("input[name='quant']");u.click(function(t){const e=parseInt(d.attr("value"));isNaN(e)?d.attr("value","0"):(console.log("#iteminput"+e),e>d.attr("min")&&d.attr("value",(e-1).toString()),e-1==d.attr("min")&&$(this).attr("disabled",!0),$("#iteminput"+e).remove())}),s.click(function(e){const a=parseInt(d.attr("value"));if(isNaN(a))d.attr("value","0");else{if(a<d.attr("max")&&d.attr("value",(a+1).toString()),a==d.attr("max"))return void $(this).attr("disabled",!0);parseInt(d.attr("value"))>1?u.prop("disabled",!1):u.prop("disabled",!0),i.append('<div id="iteminput'+(a+1)+'" class="mb-3 w-50"><label for="item'+(a+1)+'">Model for damage '+(a+1)+':</label><input type="text" class="form-control" id="item'+(a+1)+'" name="item'+(a+1)+'" placeholder="cars/'+t()+'" required></div>')}}),n.change(function(){if(""!==this.value){a.show();const t=itemDamages[this.value];r.prop("max",t),s.prop("disabled",!1)}else a.hide()}),e.on("submit",function(t){t.preventDefault();const e=n.val(),a=$(".btn-number").attr("data-field"),r=$("input[name='"+a+"']"),i=parseInt(r.attr("value")),l=[];for(let t=0;t<i;t++)l[t]=$("#item"+(t+1)).val();const u=buildJSON(e,l);o.html(syntaxHighlight(u));const s="data:text/json;charset=utf-8,"+encodeURIComponent(u);return c.attr("href",s),c.attr("download",e+".json"),!1}),l.click(function(t){t.preventDefault(),navigator.clipboard.writeText(o.text())})});
$(document).ready(function(){function t(){const t=["red_car","blue_car","green_car","orange_car","blue_bicycle","red_bicycle","green_bicycle","orange_bicycle"];return t[Math.floor(Math.random()*t.length)]}const e=$("#calculatorForm"),a=$("#formItems"),n=$("#item"),r=$("#itemcount"),i=$("#items"),o=$("#content"),l=$("#copyButton"),c=$("#downloadButton"),s=$("#minus"),u=$("#plus"),d=$("input[name='quant']");s.click(function(t){const e=parseInt(d.attr("value"));isNaN(e)?d.attr("value","0"):(e>d.attr("min")&&d.attr("value",(e-1).toString()),e-1==d.attr("min")&&$(this).attr("disabled",!0),$("#iteminput"+e).remove())}),u.click(function(e){const a=parseInt(d.attr("value"));if(isNaN(a))d.attr("value","0");else{if(a<d.attr("max")&&d.attr("value",(a+1).toString()),a==d.attr("max"))return void $(this).attr("disabled",!0);parseInt(d.attr("value"))>1?s.prop("disabled",!1):s.prop("disabled",!0),i.append('<div id="iteminput'+(a+1)+'" class="mb-3 w-50"><label for="item'+(a+1)+'">Model for damage '+(a+1)+':</label><input type="text" class="form-control" id="item'+(a+1)+'" name="item'+(a+1)+'" placeholder="cars/'+t()+'" required></div>')}}),n.change(function(){if(""!==this.value){a.show();const t=itemDamages[this.value];r.prop("max",t),u.prop("disabled",!1)}else a.hide()}),e.on("submit",function(t){t.preventDefault();const e=n.val(),a=parseInt(d.attr("value")),r=[];for(let t=0;t<a;t++)r[t]=$("#item"+(t+1)).val();const i=buildJSON(e,r);o.html(syntaxHighlight(i));const l="data:text/json;charset=utf-8,"+encodeURIComponent(i);return c.attr("href",l),c.attr("download",e+".json"),!1}),l.click(function(t){t.preventDefault(),navigator.clipboard.writeText(o.text())})});