2020-12-09 16:52:03 +01:00
|
|
|
var hiscores = hiscores || {};
|
|
|
|
hiscores.sName = [
|
2020-12-09 16:40:53 +01:00
|
|
|
"Attack",
|
|
|
|
"Defence",
|
|
|
|
"Strength",
|
|
|
|
"Constitution",
|
|
|
|
"Ranged",
|
|
|
|
"Prayer",
|
|
|
|
"Magic",
|
|
|
|
"Cooking",
|
|
|
|
"Woodcutting",
|
|
|
|
"Fletching",
|
|
|
|
"Fishing",
|
|
|
|
"Firemaking",
|
|
|
|
"Crafting",
|
|
|
|
"Smithing",
|
|
|
|
"Mining",
|
|
|
|
"Herblore",
|
|
|
|
"Agility",
|
|
|
|
"Thieving",
|
|
|
|
"Slayer",
|
|
|
|
"Farming",
|
|
|
|
"Runecrafting",
|
|
|
|
"Hunter",
|
|
|
|
"Construction",
|
|
|
|
"Summoning"
|
|
|
|
]
|
|
|
|
|
2020-12-09 17:13:31 +01:00
|
|
|
|
|
|
|
hiscores.page = 0;
|
|
|
|
hiscores.currentSkillId = "";
|
|
|
|
|
|
|
|
hiscores.apiURL = "http://localhost:3000";
|
|
|
|
|
|
|
|
hiscores.tableData = [];
|
|
|
|
hiscores.defaultTableData = [];
|
|
|
|
|
2020-12-09 16:52:03 +01:00
|
|
|
hiscores.linkLeftTabSkillNames = () => {
|
|
|
|
hiscores.sName.forEach((skill, index) => {
|
2020-12-09 16:40:53 +01:00
|
|
|
row = document.getElementsByClassName(` ${skill} ico`)[0].addEventListener("click", function (e) {
|
|
|
|
e.preventDefault();
|
2020-12-09 16:52:03 +01:00
|
|
|
hiscores.loadSkillTable(index);
|
2020-12-09 16:40:53 +01:00
|
|
|
});
|
|
|
|
});
|
2020-12-09 16:52:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hiscores.initializePageArrows = () => {
|
|
|
|
document.getElementById("button-up").addEventListener("click", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (hiscores.page > 0) {
|
|
|
|
hiscores.page--;
|
|
|
|
}
|
|
|
|
hiscores.populateDefaultHSTable();
|
|
|
|
});
|
|
|
|
document.getElementById("button-down").addEventListener("click", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
hiscores.page++;
|
|
|
|
hiscores.populateDefaultHSTable();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
hiscores.initalizeRightsideButtons = () => {
|
|
|
|
document.getElementById("search_button").addEventListener("click", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (document.getElementById('search_name').value) {
|
|
|
|
hiscores.loadUserTable(document.getElementById('search_name').value)
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
hiscores.loadDefaultHSTable();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
document.getElementById("search_rank_submit").addEventListener("click", function (e) {
|
|
|
|
e.preventDefault();
|
|
|
|
if (document.getElementById('search_rank').value) {
|
|
|
|
hiscores.loadUserTable(defaultTableData[document.getElementById('search_rank').value - 1].username)
|
2020-12-09 17:13:31 +01:00
|
|
|
hiscores.setHeadSkillText(defaultTableData[document.getElementById('search_rank').value - 1].username + "'s ");
|
2020-12-09 16:52:03 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
hiscores.loadDefaultHSTable();
|
|
|
|
}
|
|
|
|
});
|
2020-12-09 17:13:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hiscores.formatName = (name, aposS = false) => {
|
|
|
|
name = name.replaceAll("_", " ");
|
|
|
|
name = name.replace(/(^\w|\s\w)/g, match => match.toUpperCase()); // Capitalize first letter of each word
|
|
|
|
if (aposS) {
|
|
|
|
if (!name.endsWith('s')) {
|
|
|
|
name += "'s";
|
|
|
|
} else {
|
|
|
|
name += "'";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2020-12-09 22:12:19 +01:00
|
|
|
hiscores.setHeadSkillIcon = (icon) => {
|
|
|
|
if (icon.includes(".")) {
|
|
|
|
document.getElementById("scores_head_icon").src = icon;
|
|
|
|
} else {
|
|
|
|
document.getElementById("scores_head_icon").src = `../../site/img/hiscores/skill_icon_${icon.toLowerCase()}1eccb.gif`;
|
|
|
|
}
|
2020-12-09 17:13:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
hiscores.setHeadSkillText = (text) => {
|
|
|
|
document.getElementById("scores_head_skill").innerText = text;
|
2020-12-09 16:40:53 +01:00
|
|
|
}
|