mirror of
https://github.com/2009scape/2009scape.github.io.git
synced 2024-08-18 07:09:42 +02:00
Started modularizing + push old CSS
This commit is contained in:
parent
5b56ef81d6
commit
5866a14ca1
37
services/m=hiscore/helpers.js
Normal file
37
services/m=hiscore/helpers.js
Normal file
@ -0,0 +1,37 @@
|
||||
var REQUIRE = REQUIRE || {};
|
||||
REQUIRE.sName = [
|
||||
"Attack",
|
||||
"Defence",
|
||||
"Strength",
|
||||
"Constitution",
|
||||
"Ranged",
|
||||
"Prayer",
|
||||
"Magic",
|
||||
"Cooking",
|
||||
"Woodcutting",
|
||||
"Fletching",
|
||||
"Fishing",
|
||||
"Firemaking",
|
||||
"Crafting",
|
||||
"Smithing",
|
||||
"Mining",
|
||||
"Herblore",
|
||||
"Agility",
|
||||
"Thieving",
|
||||
"Slayer",
|
||||
"Farming",
|
||||
"Runecrafting",
|
||||
"Hunter",
|
||||
"Construction",
|
||||
"Summoning"
|
||||
]
|
||||
|
||||
REQUIRE.linkLeftTabSkillNames = () => {
|
||||
REQUIRE.sName.forEach((skill, index) => {
|
||||
row = document.getElementsByClassName(` ${skill} ico`)[0].addEventListener("click", function (e) {
|
||||
e.preventDefault();
|
||||
console.log(skill, index);
|
||||
loadSkillTable(index);
|
||||
});
|
||||
});
|
||||
}
|
@ -622,7 +622,7 @@ English
|
||||
<input id="search_rank" class="textinput text" maxlength="12" type="text" name="rank" value="">
|
||||
<input type="hidden" name="table" value="0">
|
||||
<input type="hidden" name="category_type" value="0">
|
||||
<input type="submit" name="submit" class="buttonmedium" value="Search">
|
||||
<input id="search_rank_submit" type="submit" name="submit" class="buttonmedium" value="Search">
|
||||
</form>
|
||||
</div>
|
||||
<div class="subsectionHeader search_title">Compare Users</div>
|
||||
@ -698,6 +698,7 @@ English
|
||||
<!-- Mirrored from services/m=hiscore/hiscores.ws by HTTrack Website Copier/3.x [XR&CO'2010], Sun, 18 Jul 2010 08:59:40 GMT -->
|
||||
<!-- Added by HTTrack -->
|
||||
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1"><!-- /Added by HTTrack -->
|
||||
<script type="text/javascript" src="./helpers.js"></script>
|
||||
<script type="text/javascript" src="./hiscores.js"></script>
|
||||
|
||||
</html>
|
@ -1,35 +1,12 @@
|
||||
var REQUIRE = REQUIRE || {};
|
||||
|
||||
let page = 0;
|
||||
let currentSkillId = "";
|
||||
|
||||
const apiURL = "http://localhost:3000";
|
||||
const sName = [
|
||||
"Attack",
|
||||
"Defence",
|
||||
"Strength",
|
||||
"Constitution",
|
||||
"Ranged",
|
||||
"Prayer",
|
||||
"Magic",
|
||||
"Cooking",
|
||||
"Woodcutting",
|
||||
"Fletching",
|
||||
"Fishing",
|
||||
"Firemaking",
|
||||
"Crafting",
|
||||
"Smithing",
|
||||
"Mining",
|
||||
"Herblore",
|
||||
"Agility",
|
||||
"Thieving",
|
||||
"Slayer",
|
||||
"Farming",
|
||||
"Runecrafting",
|
||||
"Hunter",
|
||||
"Construction",
|
||||
"Summoning"
|
||||
]
|
||||
|
||||
let tableData = [];
|
||||
let defaultTableData = [];
|
||||
|
||||
function loadDefaultHSTable() {
|
||||
fetch(`${apiURL}/highscores/getPlayersByTotal`)
|
||||
@ -37,6 +14,7 @@ function loadDefaultHSTable() {
|
||||
.then(result => {
|
||||
console.log(result[0]);
|
||||
tableData = result;
|
||||
defaultTableData = result;
|
||||
populateDefaultHSTable();
|
||||
})
|
||||
.catch(error => console.log('error', error));
|
||||
@ -77,6 +55,7 @@ function loadUserTable(username) {
|
||||
console.log(result[0]);
|
||||
tableData = result;
|
||||
populatePlayerHSTable();
|
||||
document.getElementById("scores_head_skill").innerText = username + "'s ";
|
||||
})
|
||||
.catch(error => {
|
||||
document.getElementById('search_name').style.color = 'red';
|
||||
@ -94,7 +73,7 @@ function populatePlayerHSTable() {
|
||||
|
||||
row.childNodes[3].replaceWith(document.createElement("td"));
|
||||
row.childNodes[3].className = "alL";
|
||||
row.childNodes[3].innerHTML = `<a href="./hiscores.html">${sName[i - 1]}</a>`;
|
||||
row.childNodes[3].innerHTML = `<a href="./hiscores.html">${REQUIRE.sName[i - 1]}</a>`;
|
||||
row.childNodes[3].addEventListener("click", e => {
|
||||
e.preventDefault();
|
||||
loadSkillTable(i - 1);
|
||||
@ -123,8 +102,8 @@ function loadSkillTable(skillId) {
|
||||
}
|
||||
|
||||
function populateSkillHSTable() {
|
||||
document.getElementById("scores_head_skill").innerText = sName[currentSkillId];
|
||||
document.getElementById("scores_head_icon").src = `../../site/img/hiscores/skill_icon_${sName[currentSkillId].toLowerCase()}1eccb.gif`;
|
||||
document.getElementById("scores_head_skill").innerText = REQUIRE.sName[currentSkillId];
|
||||
document.getElementById("scores_head_icon").src = `../../site/img/hiscores/skill_icon_${REQUIRE.sName[currentSkillId].toLowerCase()}1eccb.gif`;
|
||||
|
||||
for (let i = 1; i <= 24; i++) {
|
||||
row = document.getElementsByClassName(`row row${i}`)[0];
|
||||
@ -177,14 +156,20 @@ document.getElementById("search_button").addEventListener("click", function (e)
|
||||
}
|
||||
});
|
||||
|
||||
// Handle Skill Names
|
||||
sName.forEach((skill, index) => {
|
||||
row = document.getElementsByClassName(` ${skill} ico`)[0].addEventListener("click", function (e) {
|
||||
e.preventDefault();
|
||||
console.log(skill, index);
|
||||
loadSkillTable(index);
|
||||
});
|
||||
document.getElementById("search_rank_submit").addEventListener("click", function (e) {
|
||||
e.preventDefault();
|
||||
if (document.getElementById('search_rank').value) {
|
||||
loadUserTable(defaultTableData[document.getElementById('search_rank').value - 1].username)
|
||||
document.getElementById("scores_head_skill").innerText = defaultTableData[document.getElementById('search_rank').value - 1].username + "'s ";
|
||||
}
|
||||
else {
|
||||
loadDefaultHSTable();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Handle Skill Names
|
||||
REQUIRE.linkLeftTabSkillNames();
|
||||
|
||||
|
||||
loadDefaultHSTable();
|
||||
|
@ -223,6 +223,12 @@
|
||||
.row22 {
|
||||
background-color: #423419;
|
||||
}
|
||||
.row23 {
|
||||
background-color: #534221;
|
||||
}
|
||||
.row24 {
|
||||
background-color: #423419;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -396,10 +402,10 @@
|
||||
height: 27px;
|
||||
}
|
||||
#button-up {
|
||||
top: 165px;
|
||||
top: 180px;
|
||||
}
|
||||
#button-down {
|
||||
top: 170px;
|
||||
top: 185px;
|
||||
}
|
||||
#button-up span.lev1_arrow {
|
||||
background-image: url('../img/hiscores/arrow_upeccb.gif?3');
|
||||
@ -486,7 +492,7 @@
|
||||
#playerList_back {
|
||||
float: left;
|
||||
width: 371px;
|
||||
height: 466px;
|
||||
height: 505px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
#table_friend {
|
||||
@ -536,7 +542,7 @@
|
||||
.arrow_back {
|
||||
width: 25px;
|
||||
background-color: #3B2B0F;
|
||||
height: 419px;
|
||||
height: 457px;
|
||||
float: right;
|
||||
}
|
||||
#arrow_up {
|
||||
@ -583,7 +589,7 @@
|
||||
#search_back {
|
||||
float: left;
|
||||
width: 156px;
|
||||
height: 466px;
|
||||
height: 505px;
|
||||
}
|
||||
.search_small, .search_large {
|
||||
margin-bottom: 2px;
|
||||
|
Loading…
Reference in New Issue
Block a user