Difference between revisions of "Widget:EnemyMapDropdown"

From Dragalia Lost Wiki
Jump to navigation Jump to search
imported>Elaeagnifolia
>Eave
m (forgot to close string...)
 
(32 intermediate revisions by 3 users not shown)
Line 2: Line 2:
 
const maps = <!--{$maps}-->;
 
const maps = <!--{$maps}-->;
  
RLQ.push( function() {
+
RLQ.push(['jquery', function() {
 
$(document).ready(function() {
 
$(document).ready(function() {
 
initializeMapList();
 
initializeMapList();
 
});
 
});
});
+
}]);
  
 
function initializeMapList() {
 
function initializeMapList() {
Line 15: Line 15:
 
let mapSelect = document.getElementById("mapSelect");
 
let mapSelect = document.getElementById("mapSelect");
 
let mapList = [];
 
let mapList = [];
 +
mapList.push("Display All Quests");
 
 
 
for (const map of maps) {
 
for (const map of maps) {
Line 20: Line 21:
 
}
 
}
 
_populateSelectBox(mapSelect, mapList);
 
_populateSelectBox(mapSelect, mapList);
 +
mapSelect.value = checkURL();
 +
displayEnemyMapInfo(mapSelect);
 +
}
 +
 +
function checkURL() {
 +
var url = window.location.href;
 +
var hashIndex = url.indexOf("#");
 +
 +
if (hashIndex > -1) {
 +
var map = decodeURI(url.substring(hashIndex+1).replace(/_/g," "));
 +
if (maps.includes(map)) {
 +
return map;
 +
}
 +
}
 +
 +
return "Display All Quests";
 
}
 
}
  
Line 34: Line 51:
  
 
function displayEnemyMapInfo(obj) {
 
function displayEnemyMapInfo(obj) {
var enemyInfoboxes = document.getElementsByClassName('enemy-infobox');
+
var enemyTables = $(".enemy-info-table table");
  
for each (enemyInfobox in enemyInfoboxes) {
+
for (enemyTable of enemyTables) {
if (enemyInfobox.dataset.missionType == obj.value) {
+
for (let i = 1; i < enemyTable.rows.length; i++) {
enemyInfobox.style.display = "";
+
var row = enemyTable.rows[i];
} else {
+
if (obj.value == "Display All Quests") {
enemyInfobox.style.display = "none";
+
row.style.display = "";
 +
}
 +
else {
 +
if (row.cells[0].innerHTML == obj.value) {
 +
row.style.display = "";
 +
} else {
 +
row.style.display = "none";
 +
}
 +
}
 
}
 
}
 
}
 
}

Latest revision as of 06:34, 19 April 2020