Advertisement
rhuntington

Untitled

Apr 5th, 2020
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // my code
  2. $(document).ready(() => {
  3.  
  4.     // Data
  5.     let SkillData = [
  6.         {
  7.             "Profession": "Blacksmith",
  8.             "Items": [
  9.                 ["ingot_iron", { "Level": 1, "Difficulty": 16, "Durability": 40, "Name": "Iron Ingot" }],
  10.                 ["ingot_iron", { "Level": 1, "Difficulty": 20, "Durability": 40, "Name": "Iron Ingot" }],
  11.                 ["ingot_iron", { "Level": 1, "Difficulty": 36, "Durability": 40, "Name": "Iron Ingot" }],
  12.                 ["ingot_iron", { "Level": 1, "Difficulty": 50, "Durability": 40, "Name": "Iron Ingot" }],
  13.                 ["ingot_iron", { "Level": 1, "Difficulty": 16, "Durability": 40, "Name": "Iron Ingot" }]
  14.             ],
  15.             "Image": "img/blacksmith.png"
  16.         }
  17.     ];
  18.  
  19.     let LoadItems = (id) => {
  20.         str = '';
  21.         let i = 0;
  22.         SkillData[id].Items.forEach(job => {
  23.            
  24.             str +=
  25.                 `<div id="crafting-itemlist-item">
  26.                     <div id = "crafting-itemlist-item-container">
  27.                         <div id = "crafting-itemlist-item-container-box">
  28.                         </div>
  29.                     </div>
  30.                     <p class="itemName" id = "${i}">${job[1].Name}</p>
  31.                     <p class="itemLvl" id ="crafting-itemlist-item-text-level">Lv. ${job[1].Level}</p>
  32.                 </div>`;
  33.             i++;
  34.         });
  35.         $('#crafting-itemlist').html(str);
  36.  
  37.         $('.itemName').click((d) => {
  38.             console.log(`Checking item click for item: ${d.target.id}`);
  39.             let num = d.target.id;
  40.             let difficulty = (SkillData[id].Items[num][1].Difficulty);
  41.             let durability = (SkillData[id].Items[num][1].Durability);
  42.             let name = (SkillData[id].Items[num][1].Name);
  43.             // let itempic = SkillData[id].Items[num][0];
  44.             console.dir(`Difficulty: ${difficulty}`);
  45.             console.dir(`Durability: ${durability}`);
  46.             console.dir(`Name: ${name}`);
  47.         });
  48.     };
  49.     LoadItems(0);
  50. });
  51.  
  52. // Yam's code
  53.  
  54. function LoadItems(id) {
  55.     Craft.CurrentSelection = id;
  56.  
  57.     let i = 0;
  58.     $('#crafting-itemlist').html('')
  59.     SkillData[id].Items.forEach(job => {
  60.         var $thing = $('#crafting-itemlist-item').clone();
  61.         $thing.html('<div id = "crafting-itemlist-item-container"> <div id = "crafting-itemlist-item-container-box"> <img src = "nui://geo-inventory/html/img/'+job[0]+'.png" id = "crafting-itemlist-item-container-box-pic"> </div> </div> <p id = "crafting-itemlist-item-text">'+job[1].Name+' </p> <p id = "crafting-itemlist-item-text-level">Lv. '+job[1].Level+' </p>')
  62.         $thing.attr('ident', i)
  63.         $('#crafting-itemlist').append($thing)
  64.         $($thing).click(function() {
  65.             let num = $(this).attr('ident')
  66.             let difficulty = (SkillData[id].Items[num][1].Difficulty)
  67.             let durability = (SkillData[id].Items[num][1].Durability)
  68.             let name = (SkillData[id].Items[num][1].Name)
  69.             let itempic = SkillData[id].Items[num][0]
  70.             console.log(num)
  71.         })
  72.         i++
  73.     })
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement