let itemData
let duplicates = []
let filteredKeys = ["durability", "remove_head", "absorb", "bonuses", "archery_ticket_price",
"attack_anims", "attack_audios", "weapon_interface",
"walk_anim", "turn90cw_anim", "turn90ccw_anim", "run_anim", "stand_turn_anim", "turn180_anim",
"stand_anim", "stand_turn_anim", "render_anim","defence_anim"]
function newDisplayItem(itemObj) {
let debugState = (debugClass == "debug-show") ? true : false;
let row = $("
").append($(""))
.append($("").append($("").attr('src', iconURL(1207))))
.append($(" | ").append($("").attr('src', iconURL(1325))))
.append($(" | ").append($("").attr('src', iconURL(1339))))
.append($(" | ").append($("").attr('src', ".././img/alt/magic.png")))
.append($(" | ").append($("").attr('src', ".././img/alt/ranged.png")))
.append($(" | ").append($("").attr('src', ".././img/alt/summoning.png")))
let otherBonusIcons = $(" |
").append($(""))
.append($("").append($("").attr('src', ".././img/alt/Strength_icon.png")))
.append($(" | ").append($("").attr('src', ".././img/alt/RangedStrength.png")))
.append($(" | ").append($("").attr('src', ".././img/alt/MagicStrength.png")))
.append($(" | ").append($("").attr('src', ".././img/alt/Prayer_icon.png")))
let attackBonus = $(" |
")
.append($("").append(aStab))
.append($(" | ").append(aSlash))
.append($(" | ").append(aCrush))
.append($(" | ").append(aMagic))
.append($(" | ").append(aRanged))
let defenseBonus = $(" |
")
.append($("").append(dStab))
.append($(" | ").append(dSlash))
.append($(" | ").append(dCrush))
.append($(" | ").append(dMagic))
.append($(" | ").append(dRanged))
.append($(" | ").append(dSummoning))
let otherBonus = $(" |
")
.append($("").append(strength))
.append($(" | ").append(rangedStr))
.append($(" | ").append(magicStr))
.append($(" | ").append(prayer))
row.append($("").text("Attack bonuses").attr('class', 'stat-data'))
row.append(attackBonusIcons.append(attackBonus))
row.append($(" ").text("Defense bonuses").attr('class', 'stat-data'))
row.append(defenseBonusIcons.append(defenseBonus))
row.append($(" ").text("Other bonuses").attr('class', 'stat-data'))
row.append(otherBonusIcons.append(otherBonus))
}
return row.append(itemName).append(about)[0]
}
function spaceToUnder(str) {
return str.replaceAll(' ', '_').toLowerCase()
}
function search(e) {
let input = spaceToUnder(e.value)
let table = document.getElementById("dcontent")
table.innerHTML = ""
console.log(input)
for (const item of itemData) {
let itemDisplay = $(" ")
if (input.length > 3 && spaceToUnder(item.name).includes(input)) {
console.log(input + " is like " + item.name)
if (duplicates.indexOf(item.id) == -1)
itemDisplay.append(newDisplayItem(item))
let h1 = $("").addClass("hover-link").append($("").text(prettyName(item.name)))
.on('mouseenter', function () {
$(this).text(prettyName(item.name)).append($(" ").attr('src', ".././img/items/link.png"))
})
.on('click', function () {
window.location = window.location.toString().split('?')[0] + "?" + this.innerText
})
.on('mouseleave', function () {
$(this).find($("img")).remove()
})
if (itemDisplay[0].innerHTML != "") {
table.appendChild($(" ").append(h1)[0])
table.append(itemDisplay[0])
}
}
}
}
window.addEventListener('load', () => {
let timeout = 0;
async function getItems() {
// Mirror fetches changes every 15 minutes from Gitlab
const response = await fetch('https://downthecrop.github.io/2009scape-mirror/Server/data/configs/item_configs.json');
itemData = await response.json();
}
getItems();
let checkExist = setInterval(function () {
if (itemData != undefined) {
let checked = []
for (item of itemData) {
if (checked.indexOf(item.name) != -1) {
duplicates.push(item.id)
}
checked.push(item.name)
}
clearInterval(checkExist);
searchURLString()
}
checkTimeout(timeout++)
}, 100);
}); |