From d6f1c08cc86865732cff89299639403b8f22d8b0 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 21:44:28 -0400
Subject: [PATCH 01/61] retain open/closed status of the modal window across
page loads
---
src/favorite-setups.js | 24 ++++++++++++++++++++----
1 file changed, 20 insertions(+), 4 deletions(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 55d79ac..4e0e5ea 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -268,6 +268,7 @@
closeButton.textContent = "x";
closeButton.onclick = function () {
document.body.removeChild(mainDiv);
+ localStorage.setItem('showSetups', "N");
};
topDiv.appendChild(closeButton);
@@ -779,8 +780,14 @@
button.innerText = "Favorite Setups";
button.addEventListener("click", function () {
const existing = document.querySelector("#tsitu-fave-setups");
- if (existing) existing.remove();
- else render();
+ if (existing) {
+ localStorage.setItem('showSetups', "N");
+ existing.remove();
+ }
+ else {
+ localStorage.setItem('showSetups', "Y");
+ render()
+ };
});
button.addEventListener("contextmenu", function () {
if (confirm("Toggle 'Favorite Setups' placement?")) {
@@ -802,8 +809,14 @@
link.innerText = "[Favorite Setups]";
link.addEventListener("click", function () {
const existing = document.querySelector("#tsitu-fave-setups");
- if (existing) existing.remove();
- else render();
+ {
+ localStorage.setItem('showSetups', "N"); // retain previous open/close behaviour
+ existing.remove();
+ }
+ else {
+ render();
+ localStorage.setItem('showSetups', "Y"); // retain previous open/close behaviour
+ };
return false; // Prevent default link clicked behavior
});
link.addEventListener("contextmenu", function () {
@@ -818,6 +831,9 @@
}
}
}
+ // retain previous open/close behaviour
+ var openedSettings = localStorage.getItem('showSetups');
+ if(openedSettings == "Y") render();
injectUI();
/**
From a038bfd4d0fe5fa34fc746b8851711b8691c64ff Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 21:51:44 -0400
Subject: [PATCH 02/61] added location to data object and import/save/reset
functions
---
src/favorite-setups.js | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 4e0e5ea..863e7fb 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -50,7 +50,8 @@
cheese: 3,
trinket: 4,
charm: 4,
- skin: 5
+ skin: 5,
+ location: 6
};
const originalOpen = XMLHttpRequest.prototype.open;
@@ -71,7 +72,8 @@
base: {},
weapon: {},
trinket: {},
- skin: {}
+ skin: {},
+ location: {}
};
data.forEach(el => {
@@ -142,6 +144,7 @@
const rawData = localStorage.getItem("tsitu-owned-components");
if (rawData) {
const data = JSON.parse(rawData);
+ data.location = [];
const dataKeys = Object.keys(data).sort((a, b) => {
return displayOrder[a] - displayOrder[b];
});
@@ -353,6 +356,7 @@
.value;
// const skin = document.querySelector("#favorite-setup-input-skin").value;
const name = document.querySelector("#favorite-setup-name").value;
+ const location = document.querySelector("#favorite-setup-input-location").value;
if (name.length >= 1 && name.length <= 20) {
const obj = {};
@@ -361,7 +365,8 @@
base: "N/A",
weapon: "N/A",
trinket: "N/A",
- skin: "N/A"
+ skin: "N/A",
+ location: "N/A"
};
if (data.bait[bait] !== undefined) obj[name].bait = bait;
@@ -369,6 +374,7 @@
if (data.weapon[weapon] !== undefined) obj[name].weapon = weapon;
if (data.trinket[charm] !== undefined) obj[name].trinket = charm;
// if (data.skin[skin] !== undefined) obj[name].skin = skin;
+ if (data.location[location] !== undefined) obj[name].location = location;
obj[name].sort = -1;
const storedRaw = localStorage.getItem("favorite-setups-saved");
@@ -409,6 +415,8 @@
user.weapon_name || "";
document.querySelector("#favorite-setup-input-charm").value =
user.trinket_name || "";
+ document.querySelector("#favorite-setup-input-location").value =
+ user.environment_name || "";
// if (user.skin_name) {
// document.querySelector("#favorite-setup-input-skin").value =
// user.skin_name; // not really a thing, gotta use a qS probably or parse from LS ID-name map
@@ -425,6 +433,7 @@
document.querySelector("#favorite-setup-input-charm").value = "";
// document.querySelector("#favorite-setup-input-skin").value = "";
document.querySelector("#favorite-setup-name").value = "";
+ document.querySelector("#favorite-setup-input-location").value = "";
};
const buttonSpan = document.createElement("span");
From 6389e80e1e510e319398c8853128d60d71b37a96 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 21:56:15 -0400
Subject: [PATCH 03/61] added location loading to edit button
---
src/favorite-setups.js | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 863e7fb..63e42ef 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -638,6 +638,8 @@
el.weapon === "N/A" ? "" : el.weapon;
document.querySelector("#favorite-setup-input-charm").value =
el.trinket === "N/A" ? "" : el.trinket;
+ document.querySelector("#favorite-setup-input-location").value =
+ el.location === "N/A" ? "" : el.location;
// document.querySelector("#favorite-setup-input-skin").value =
// el.skin === "N/A" ? "" : el.skin;
document.querySelector("#favorite-setup-name").value = name || "";
From 3d3d95b0364e1216df52478a6c6ef9542bb05ce4 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 21:56:44 -0400
Subject: [PATCH 04/61] added travel button to setups using saved location
---
src/favorite-setups.js | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 63e42ef..e41cd45 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -566,6 +566,7 @@
for (let type of elKeys) {
if (type === "sort") continue;
if (type === "skin") continue;
+ if (type === "location") continue;
const img = document.createElement("img");
img.style.height = "40px";
@@ -663,6 +664,18 @@
}
};
+ const travelButton = document.createElement("button"); //ast location mod
+ travelButton.setAttribute("class","travelButton");
+ travelButton.title = "Left click to travel, Right click to update setup location to current location"
+ if (el.location) {
+ travelButton.textContent = el.location;
+ } else {
+ travelButton.textContent = 'N/A'
+ };
+ travelButton.onclick = function () {
+ app.pages.TravelPage.travel (locMap[el.location].type);
+ };
+
const buttonCol = document.createElement("td");
buttonCol.style.textAlign = "center";
buttonCol.style.verticalAlign = "middle";
@@ -672,6 +685,7 @@
buttonCol.appendChild(deleteButton);
buttonCol.appendChild(document.createElement("br"));
buttonCol.appendChild(armButton);
+ buttonCol.appendChild(travelButton);
const setupRow = document.createElement("tr");
setupRow.className = "tsitu-fave-setup-row";
From b4ff35dcd97012d1f95e1966e96807032198fc47 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 22:06:09 -0400
Subject: [PATCH 05/61] bug fix: missed if statement
---
src/favorite-setups.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 4e0e5ea..06c7ef2 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -809,7 +809,7 @@
link.innerText = "[Favorite Setups]";
link.addEventListener("click", function () {
const existing = document.querySelector("#tsitu-fave-setups");
- {
+ if (existing) {
localStorage.setItem('showSetups', "N"); // retain previous open/close behaviour
existing.remove();
}
From 398a0be0896c9200249ea67d07a3c01674ebe13b Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 22:08:59 -0400
Subject: [PATCH 06/61] bug fix
---
src/favorite-setups.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 06c7ef2..88908c9 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -557,6 +557,7 @@
for (let type of elKeys) {
if (type === "sort") continue;
if (type === "skin") continue;
+ if (type === "location") continue;
const img = document.createElement("img");
img.style.height = "40px";
From ec3ea16c2e065473d531818a18c39f238fe8ad2a Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 22:22:24 -0400
Subject: [PATCH 07/61] adding location datalist for dropdown
---
src/favorite-setups.js | 40 ++++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index e41cd45..e715d7f 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -54,6 +54,33 @@
location: 6
};
+ // Pull and save location list
+ const xhr = new XMLHttpRequest();
+ xhr.open(
+ "POST",
+ `https://www.mousehuntgame.com/managers/ajax/pages/page.php?page_class=HunterProfile&page_arguments%5Btab%5D=mice&page_arguments%5Bsub_tab%5D=location&uh=${user.unique_hash}`
+ );
+ xhr.onload = function () {
+ const response = JSON.parse(xhr.responseText);
+ const locations =
+ response.page.tabs.mice.subtabs[1].mouse_list.categories;
+ if (locations) {
+ const masterObj = {};
+
+ locations.forEach(el => {
+ const obj = {};
+ obj["type"] = el.type;
+ masterObj[el.name] = obj;
+ });
+
+ localStorage.setItem(
+ "ast-location-mapping",
+ JSON.stringify(masterObj)
+ );
+ };
+ };
+ xhr.send();
+
const originalOpen = XMLHttpRequest.prototype.open;
XMLHttpRequest.prototype.open = function () {
this.addEventListener("load", function () {
@@ -142,9 +169,22 @@
if (existing) existing.remove();
const rawData = localStorage.getItem("tsitu-owned-components");
+ const locMap = JSON.parse(localStorage.getItem("ast-location-mapping")); // ast location mod
+ // aliases for locations with multiple environment_names for the same environment_type
+ locMap["Cursed City"] = {"type": "lost_city"};
+ locMap["Sand Crypts"] = {"type": "sand_dunes"};
+ locMap["Twisted Garden"] = {"type": "desert_oasis"};
+
if (rawData) {
const data = JSON.parse(rawData);
+<<<<<<< Updated upstream
data.location = [];
+=======
+<<<<<<< Updated upstream
+=======
+ data.location = locMap;
+>>>>>>> Stashed changes
+>>>>>>> Stashed changes
const dataKeys = Object.keys(data).sort((a, b) => {
return displayOrder[a] - displayOrder[b];
});
From 0293f96a236ec178e677198a35ea755ce0de60c1 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 22:23:11 -0400
Subject: [PATCH 08/61] stashed changes
---
src/favorite-setups.js | 7 -------
1 file changed, 7 deletions(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index e715d7f..b2faaf2 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -177,14 +177,7 @@
if (rawData) {
const data = JSON.parse(rawData);
-<<<<<<< Updated upstream
- data.location = [];
-=======
-<<<<<<< Updated upstream
-=======
data.location = locMap;
->>>>>>> Stashed changes
->>>>>>> Stashed changes
const dataKeys = Object.keys(data).sort((a, b) => {
return displayOrder[a] - displayOrder[b];
});
From 693d86c6d4341e4595b27cb1e493c29a42665904 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 22:57:15 -0400
Subject: [PATCH 09/61] sort edited setups with a name change adjacent to
originating setup
---
src/favorite-setups.js | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 88908c9..dde6836 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -140,6 +140,8 @@
if (existing) existing.remove();
const rawData = localStorage.getItem("tsitu-owned-components");
+ var editSort = -1; // ast location mod. change to -2 if you want new setups to appear above location sorted setups until they are manually sorted.
+
if (rawData) {
const data = JSON.parse(rawData);
const dataKeys = Object.keys(data).sort((a, b) => {
@@ -369,7 +371,9 @@
if (data.weapon[weapon] !== undefined) obj[name].weapon = weapon;
if (data.trinket[charm] !== undefined) obj[name].trinket = charm;
// if (data.skin[skin] !== undefined) obj[name].skin = skin;
- obj[name].sort = -1;
+ obj[name].sort = editSort; // ast location mod
+ console.log("saved setup '"+name+"': "+JSON.stringify(obj[name])); // ast location mod
+
const storedRaw = localStorage.getItem("favorite-setups-saved");
if (storedRaw) {
@@ -633,6 +637,7 @@
// document.querySelector("#favorite-setup-input-skin").value =
// el.skin === "N/A" ? "" : el.skin;
document.querySelector("#favorite-setup-name").value = name || "";
+ editSort = el.sort; // for sorting name-edited setups after the originating setup this button was clicked on
};
const deleteButton = document.createElement("button");
From 214e57c07365482889c9af26d0ff8b804169ac04 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 22:57:24 -0400
Subject: [PATCH 10/61] 30 char limit on name
---
src/favorite-setups.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index dde6836..25a367e 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -356,7 +356,7 @@
// const skin = document.querySelector("#favorite-setup-input-skin").value;
const name = document.querySelector("#favorite-setup-name").value;
- if (name.length >= 1 && name.length <= 20) {
+ if (name.length >= 1 && name.length <= 30) {
const obj = {};
obj[name] = {
bait: "N/A",
From eb8264d6316c699f8ff699b5a257889dcfa8400f Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 22:57:59 -0400
Subject: [PATCH 11/61] console log when editing setup
---
src/favorite-setups.js | 1 +
1 file changed, 1 insertion(+)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 25a367e..0738763 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -638,6 +638,7 @@
// el.skin === "N/A" ? "" : el.skin;
document.querySelector("#favorite-setup-name").value = name || "";
editSort = el.sort; // for sorting name-edited setups after the originating setup this button was clicked on
+ console.log("editing setup: "+name+" from sort position "+editSort);
};
const deleteButton = document.createElement("button");
From b3c5e62749330320d71ec28d54179bd29fd111db Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 23:01:02 -0400
Subject: [PATCH 12/61] bug fix: 30 char limit on name
---
src/favorite-setups.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 0738763..819320b 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -329,7 +329,7 @@
nameInput.id = "favorite-setup-name";
nameInput.required = true;
nameInput.minLength = 1;
- nameInput.maxLength = 20;
+ nameInput.maxLength = 30;
const nameInputCol = document.createElement("td");
nameInputCol.appendChild(nameInput);
From fa30a26080413a4087b780e60954219b364fe9c9 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 23:01:53 -0400
Subject: [PATCH 13/61] load/edit buttons focus the name input, and "enter" key
saves the setup
---
src/favorite-setups.js | 13 +++++++++++++
1 file changed, 13 insertions(+)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 819320b..eb0bf93 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -330,6 +330,16 @@
nameInput.required = true;
nameInput.minLength = 1;
nameInput.maxLength = 30;
+ nameInput.addEventListener("keyup", function(event) {
+ // Number 13 is the "Enter" key on the keyboard
+ if (event.keyCode === 13) {
+ // Cancel the default action, if needed
+ event.preventDefault();
+ // Trigger the button element with a click
+ document.getElementById("saveButton").click();
+ }
+ });
+
const nameInputCol = document.createElement("td");
nameInputCol.appendChild(nameInput);
@@ -417,6 +427,8 @@
// document.querySelector("#favorite-setup-input-skin").value =
// user.skin_name; // not really a thing, gotta use a qS probably or parse from LS ID-name map
// }
+ document.getElementById("favorite-setup-name").focus();
+ console.log("loaded items: ",user.bait_name, user.base_name, user.weapon_name, user.trinket_name, user.environment_name);
};
const resetButton = document.createElement("button");
@@ -639,6 +651,7 @@
document.querySelector("#favorite-setup-name").value = name || "";
editSort = el.sort; // for sorting name-edited setups after the originating setup this button was clicked on
console.log("editing setup: "+name+" from sort position "+editSort);
+ document.getElementById("favorite-setup-name").focus(); // ast location mod
};
const deleteButton = document.createElement("button");
From cf71a5e3490efa6422b5c10a7d5fe7a0df4299dd Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 23:12:42 -0400
Subject: [PATCH 14/61] save and load scroll position when re-rendering after
saving a setup
---
src/favorite-setups.js | 3 +++
1 file changed, 3 insertions(+)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index eb0bf93..de0f26d 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -403,7 +403,10 @@
} else {
localStorage.setItem("favorite-setups-saved", JSON.stringify(obj));
}
+ var saveScroll = document.getElementById("scroller").scrollTop; // ast location mod
render();
+ document.getElementById("scroller").scrollTop = saveScroll;
+ console.log("scroll position before/after: "+saveScroll+" / "+document.getElementById("scroller").scrollTop);
} else {
alert(
"Please enter a name for your setup that is between 1-20 characters"
From a121553a6a49f5b19c9117dd7d2a03a446bb494d Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 23:14:20 -0400
Subject: [PATCH 15/61] delete button no long rerenders, deleting setup right
from the DOM
---
src/favorite-setups.js | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index de0f26d..a1a0a4d 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -670,7 +670,10 @@
"favorite-setups-saved",
JSON.stringify(storedData)
);
- render();
+ // to delete from DOM without a re-render
+ var i = this.parentNode.rowIndex;
+ console.log("deleted '"+name+"' from rowIndex: "+i);
+ document.getElementById("setupTbody").deleteRow(i);
}
}
};
From 7c6fd2ac0b57372901b302157214b51939e31f74 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 23:16:26 -0400
Subject: [PATCH 16/61] auto save on sort
---
src/favorite-setups.js | 23 ++++++++++++++++++++++-
1 file changed, 22 insertions(+), 1 deletion(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index a1a0a4d..c4527f9 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -743,7 +743,28 @@
placeholder: "ui-state-highlight-tsitu",
scroll: true,
scrollSensitivity: 20,
- scrollSpeed: 20
+ scrollSpeed: 20,
+ update: function() {
+ const storedRaw = localStorage.getItem("favorite-setups-saved");
+ if (storedRaw) {
+ const storedData = JSON.parse(storedRaw);
+ const nameSpans = document.querySelectorAll(
+ ".tsitu-fave-setup-namespan"
+ );
+ if (nameSpans.length === Object.keys(storedData).length) {
+ for (let i = 0; i < nameSpans.length; i++) {
+ const name = nameSpans[i].textContent;
+ if (storedData[name] !== undefined) {
+ storedData[name].sort = i;
+ }
+ }
+ localStorage.setItem(
+ "favorite-setups-saved",
+ JSON.stringify(storedData)
+ );
+ }
+ }
+ }
});
setupTable.appendChild(setupTbody);
setupTableDiv.appendChild(setupTable);
From f881936f32f42ee692c3815c8f5706fa1b4e25ce Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 23:19:40 -0400
Subject: [PATCH 17/61] replaced save/reset sort buttons with a toggle sort
lock
---
src/favorite-setups.js | 58 +++++++++++++++---------------------------
1 file changed, 21 insertions(+), 37 deletions(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index c4527f9..ae1b98d 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -695,43 +695,27 @@
setupTbody.appendChild(setupRow);
}
- // Save and reset sort buttons
- const saveSort = document.createElement("button");
- saveSort.innerText = "Save Sort Order";
- saveSort.onclick = function () {
- if (confirm("Are you sure you'd like to save this sort order?")) {
- const storedRaw = localStorage.getItem("favorite-setups-saved");
- if (storedRaw) {
- const storedData = JSON.parse(storedRaw);
- const nameSpans = document.querySelectorAll(
- ".tsitu-fave-setup-namespan"
- );
- if (nameSpans.length === Object.keys(storedData).length) {
- for (let i = 0; i < nameSpans.length; i++) {
- const name = nameSpans[i].textContent;
- if (storedData[name] !== undefined) {
- storedData[name].sort = i;
- }
- }
- localStorage.setItem(
- "favorite-setups-saved",
- JSON.stringify(storedData)
+ // Toggle sort lock/unlock
+ const toggleSort = document.createElement("button"); // ast location mod
+ toggleSort.id = "toggleSort";
+ toggleSort.innerText = "Click to unlock drag and drop sort";// "Reset Sort Order";
+ toggleSort.onclick = function () {
+ var disabled = $(setupTbody).sortable("option", "disabled");
+ if (disabled) {
+ $(setupTbody).sortable("enable");
+ toggleSort.innerText = "Drag to sort";
+ GM_addStyle( //disable setup name selection when dragging
+ " .tsitu-fave-setup-namespan { grid-area: a; font-size: inherit; text-align: left; text-overflow: ellipsis; user-select: none;}"
+ );
+ } else {
+ $(setupTbody).sortable("disable");
+ toggleSort.innerText = "Click to unlock sort";
+ GM_addStyle(
+ " .tsitu-fave-setup-namespan { grid-area: a; font-size: inherit; text-align: left; text-overflow: ellipsis; user-select: text;}"
);
- render();
- }
}
- }
};
- const resetSort = document.createElement("button");
- resetSort.innerText = "Reset Sort Order";
- resetSort.onclick = function () {
- if (
- confirm("Are you sure you'd like to reset to last saved sort order?")
- ) {
- render();
- }
- };
const sortSpan = document.createElement("span");
sortSpan.innerText = "Drag & drop to rearrange setup rows (PC only)";
@@ -742,8 +726,10 @@
$(setupTbody).sortable({
placeholder: "ui-state-highlight-tsitu",
scroll: true,
- scrollSensitivity: 20,
+ scrollSensitivity: 80,
scrollSpeed: 20,
+ cursor: "move",
+ disabled: true,
update: function() {
const storedRaw = localStorage.getItem("favorite-setups-saved");
if (storedRaw) {
@@ -783,9 +769,7 @@
mainDiv.appendChild(document.createElement("br"));
mainDiv.appendChild(setupTableDiv);
mainDiv.appendChild(document.createElement("br"));
- mainDiv.appendChild(saveSort);
- mainDiv.appendChild(document.createTextNode("\u00A0\u00A0"));
- mainDiv.appendChild(resetSort);
+ mainDiv.appendChild(toggleSort);
mainDiv.appendChild(document.createElement("br"));
mainDiv.appendChild(sortSpan);
document.body.appendChild(mainDiv);
From dfe369bd57dc1ff7649ada7ad8fe2b5d23eaaf39 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 23:21:39 -0400
Subject: [PATCH 18/61] enabling drag for the entire top div
---
src/favorite-setups.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index ae1b98d..19f8ff5 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -773,7 +773,7 @@
mainDiv.appendChild(document.createElement("br"));
mainDiv.appendChild(sortSpan);
document.body.appendChild(mainDiv);
- dragElement(mainDiv, titleSpan);
+ dragElement(mainDiv, topDiv);
// Reposition popup based on previous dragged location
const posTop = localStorage.getItem("favorite-setup-pos-top");
From 6531f54cc20dcd7c46d11d5143a1a4e1bd2ee877 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Mon, 3 Aug 2020 00:05:16 -0400
Subject: [PATCH 19/61] removed elements and updated id/class to prepare for
switch to CSS grid
---
src/favorite-setups.js | 49 ++++++++++++------------------------------
1 file changed, 14 insertions(+), 35 deletions(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index eec028d..0abf04a 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -613,15 +613,15 @@
});
const imgSpan = document.createElement("span");
- imgSpan.style.paddingRight = "10px";
+ imgSpan.className = "button";
+ imgSpan.id = "imgSpan";
+
for (let type of elKeys) {
if (type === "sort") continue;
if (type === "skin") continue;
if (type === "location") continue;
const img = document.createElement("img");
- img.style.height = "40px";
- img.style.width = "40px";
let item = el[type];
if (data.weapon["Golem Guardian Trap"] !== undefined) {
if (type === "weapon") {
@@ -661,25 +661,11 @@
const nameSpan = document.createElement("span");
nameSpan.className = "tsitu-fave-setup-namespan";
- nameSpan.style.fontSize = "14px";
nameSpan.textContent = name;
- const nameImgCol = document.createElement("td");
- nameImgCol.style.padding = "5px 0px 5px 8px";
- nameImgCol.appendChild(nameSpan);
- nameImgCol.appendChild(document.createElement("br"));
- nameImgCol.appendChild(imgSpan);
-
- const armButton = document.createElement("button");
- armButton.style.fontSize = "16px";
- armButton.style.fontWeight = "bold";
- armButton.textContent = "Arm!";
- armButton.onclick = function () {
- batchLoad(el.bait, el.base, el.weapon, el.trinket, el.skin);
- };
-
const editButton = document.createElement("button");
- editButton.style.fontSize = "10px";
+ editButton.id = "editButton";
+ editButton.className = "button";
editButton.textContent = "✏️";
editButton.onclick = function () {
document.querySelector("#favorite-setup-input-cheese").value =
@@ -701,8 +687,9 @@
};
const deleteButton = document.createElement("button");
- deleteButton.style.fontSize = "12px";
- deleteButton.textContent = "x";
+ deleteButton.id = "deleteButton";
+ deleteButton.className = "button";
+ deleteButton.textContent = "🗑️";
deleteButton.onclick = function () {
if (confirm(`Delete setup '${name}'?`)) {
const storedRaw = localStorage.getItem("favorite-setups-saved");
@@ -722,7 +709,7 @@
};
const travelButton = document.createElement("button"); //ast location mod
- travelButton.setAttribute("class","travelButton");
+ travelButton.className = "travelButton";
travelButton.title = "Left click to travel, Right click to update setup location to current location"
if (el.location) {
travelButton.textContent = el.location;
@@ -733,21 +720,13 @@
app.pages.TravelPage.travel (locMap[el.location].type);
};
- const buttonCol = document.createElement("td");
- buttonCol.style.textAlign = "center";
- buttonCol.style.verticalAlign = "middle";
- buttonCol.style.paddingRight = "10px";
- buttonCol.appendChild(editButton);
- buttonCol.appendChild(document.createTextNode("\u00A0"));
- buttonCol.appendChild(deleteButton);
- buttonCol.appendChild(document.createElement("br"));
- buttonCol.appendChild(armButton);
- buttonCol.appendChild(travelButton);
-
const setupRow = document.createElement("tr");
setupRow.className = "tsitu-fave-setup-row";
- setupRow.appendChild(nameImgCol);
- setupRow.appendChild(buttonCol);
+ setupRow.appendChild(nameSpan);
+ setupRow.appendChild(travelButton);
+ setupRow.appendChild(imgSpan);
+ setupRow.appendChild(editButton);
+ setupRow.appendChild(deleteButton);
setupTbody.appendChild(setupRow);
}
From 4318d0a3bcf03e77b2a5477c5b116f57232d41e9 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Sun, 2 Aug 2020 23:44:51 -0400
Subject: [PATCH 20/61] moved arm button functionality to setup img span and
removed html table elements
---
src/favorite-setups.js | 22 +++++++++++++++++++++-
1 file changed, 21 insertions(+), 1 deletion(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 0abf04a..0844dec 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -657,12 +657,22 @@
"https://www.mousehuntgame.com/images/items/stats/ee8f12ab8e042415063ef4140cefab7b.gif?cv=243";
if (data[type][item]) img.src = data[type][item][1];
imgSpan.appendChild(img);
- }
+ };
+ imgSpan.onclick = function () { //ast location mod
+ batchLoad(el.bait, el.base, el.weapon, el.trinket, el.skin);
+ console.log("armed '"+name+"': ", el.bait, el.base, el.weapon, el.trinket, el.skin, el.location);
+ };
const nameSpan = document.createElement("span");
nameSpan.className = "tsitu-fave-setup-namespan";
nameSpan.textContent = name;
+ const nameImgCol = document.createElement("td");
+ nameImgCol.style.padding = "5px 0px 5px 8px";
+ nameImgCol.appendChild(nameSpan);
+ nameImgCol.appendChild(document.createElement("br"));
+ nameImgCol.appendChild(imgSpan);
+
const editButton = document.createElement("button");
editButton.id = "editButton";
editButton.className = "button";
@@ -720,6 +730,16 @@
app.pages.TravelPage.travel (locMap[el.location].type);
};
+ const buttonCol = document.createElement("td");
+ buttonCol.style.textAlign = "center";
+ buttonCol.style.verticalAlign = "middle";
+ buttonCol.style.paddingRight = "10px";
+ buttonCol.appendChild(editButton);
+ buttonCol.appendChild(document.createTextNode("\u00A0"));
+ buttonCol.appendChild(deleteButton);
+ buttonCol.appendChild(document.createElement("br"));
+ buttonCol.appendChild(travelButton);
+
const setupRow = document.createElement("tr");
setupRow.className = "tsitu-fave-setup-row";
setupRow.appendChild(nameSpan);
From eb4709dc3513b89f8b5d3d7804b7bb67143374c1 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Mon, 3 Aug 2020 00:14:37 -0400
Subject: [PATCH 21/61] removing excess elements to clean up UI
---
src/favorite-setups.js | 21 +--------------------
1 file changed, 1 insertion(+), 20 deletions(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 0844dec..afae865 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -496,15 +496,6 @@
buttonSpan.appendChild(document.createTextNode("\u00A0\u00A0"));
buttonSpan.appendChild(resetButton);
- // Items last updated span
- const timeUpdated = document.createElement("span");
- let tsLatestStr = "N/A";
- const tsLatestRaw = localStorage.getItem("favorite-setup-timestamp");
- if (tsLatestRaw) {
- tsLatestStr = new Date(parseInt(tsLatestRaw)).toLocaleString();
- }
- timeUpdated.textContent = `[Owned items last updated: ${tsLatestStr}]`;
-
// Setup table styling
const setupTableDiv = document.createElement("div");
setupTableDiv.style.overflowY = "scroll";
@@ -812,21 +803,11 @@
// Append everything to main popup UI
mainDiv.appendChild(topDiv);
- mainDiv.appendChild(document.createElement("br"));
- mainDiv.appendChild(dataListDiv);
- mainDiv.appendChild(timeUpdated);
- mainDiv.appendChild(document.createElement("br"));
- mainDiv.appendChild(document.createElement("br"));
mainDiv.appendChild(buttonSpan);
- mainDiv.appendChild(document.createElement("br"));
- mainDiv.appendChild(document.createElement("br"));
+ mainDiv.appendChild(dataListDiv);
mainDiv.appendChild(setupSelectorDiv);
- mainDiv.appendChild(document.createElement("br"));
mainDiv.appendChild(setupTableDiv);
- mainDiv.appendChild(document.createElement("br"));
mainDiv.appendChild(toggleSort);
- mainDiv.appendChild(document.createElement("br"));
- mainDiv.appendChild(sortSpan);
document.body.appendChild(mainDiv);
dragElement(mainDiv, topDiv);
From ca57288d1d9d26237e8bdda7b272c6905e82a2b4 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Mon, 3 Aug 2020 00:15:17 -0400
Subject: [PATCH 22/61] removing html table elements to prepare for CSS grid
---
src/favorite-setups.js | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index afae865..e4e0753 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -658,12 +658,6 @@
nameSpan.className = "tsitu-fave-setup-namespan";
nameSpan.textContent = name;
- const nameImgCol = document.createElement("td");
- nameImgCol.style.padding = "5px 0px 5px 8px";
- nameImgCol.appendChild(nameSpan);
- nameImgCol.appendChild(document.createElement("br"));
- nameImgCol.appendChild(imgSpan);
-
const editButton = document.createElement("button");
editButton.id = "editButton";
editButton.className = "button";
@@ -721,16 +715,6 @@
app.pages.TravelPage.travel (locMap[el.location].type);
};
- const buttonCol = document.createElement("td");
- buttonCol.style.textAlign = "center";
- buttonCol.style.verticalAlign = "middle";
- buttonCol.style.paddingRight = "10px";
- buttonCol.appendChild(editButton);
- buttonCol.appendChild(document.createTextNode("\u00A0"));
- buttonCol.appendChild(deleteButton);
- buttonCol.appendChild(document.createElement("br"));
- buttonCol.appendChild(travelButton);
-
const setupRow = document.createElement("tr");
setupRow.className = "tsitu-fave-setup-row";
setupRow.appendChild(nameSpan);
From 682ae8620c424dac1970202ff99cd1cddd159204 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Mon, 3 Aug 2020 00:24:25 -0400
Subject: [PATCH 23/61] deleting space
---
src/favorite-setups.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index e4e0753..9ff0870 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -170,7 +170,6 @@
const rawData = localStorage.getItem("tsitu-owned-components");
var editSort = -1; // ast location mod. change to -2 if you want new setups to appear above location sorted setups until they are manually sorted.
-
const locMap = JSON.parse(localStorage.getItem("ast-location-mapping")); // ast location mod
// aliases for locations with multiple environment_names for the same environment_type
locMap["Cursed City"] = {"type": "lost_city"};
From c4c13dc44762297b4228ac670b4a496bedd680d5 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Mon, 3 Aug 2020 00:29:37 -0400
Subject: [PATCH 24/61] added CSS style sheets, implementing table grid
---
src/favorite-setups.js | 232 ++++++++++++++++++++++++++++++++++++++++-
1 file changed, 231 insertions(+), 1 deletion(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 9ff0870..ab16317 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -8,7 +8,237 @@
// @match http://www.mousehuntgame.com/*
// @match https://www.mousehuntgame.com/*
// ==/UserScript==
-
+GM_addStyle ( `
+#tsitu-fave-setups {
+ background-color: #F5F5F5;
+ position: fixed;
+ z-index: 42;
+ left: 5px;
+ top: 5px;
+ border: solid 3px #696969;
+ padding: 10px;
+ text-align: center;
+ border-radius: 10px;
+ height: 95vh;
+ overflow: hidden;
+ display: flex;
+ flex-direction: column;
+ font-size: inherit;
+ resize: both;
+ min-width: min-content;
+ min-height: 25vh;
+}
+}
+#tsitu-fave-setups button {
+ cursor: pointer;
+}
+#tsitu-fave-setups .title {
+ font-weight: bold;
+ font-size: 160%;
+ text-decoration: underline;
+}
+#tsitu-fave-setups #close-button {
+ float: right;
+ font-size: 15px;
+ color: rgba(690,0,0,0.69);
+ padding: 1px 5px;
+ margin: -11px;
+ //background-color: rgba(420,0,0,0.420);
+ //border-radius: 0px 5px;
+ //border: none;
+}
+
+.btn-group {
+ display: inline-flex;
+ justify-content: center;
+ padding: 8px 0px;
+}
+.btn-group .button {
+ margin: -1px;
+ flex-grow: 1;
+ font-size: 100%;
+}
+#saveButton {
+ font-weight: bold;
+ font-size: 120%;
+}
+
+.favInput {
+ //display: flex;
+ //flex-grow: 1;
+ width: calc(100% - 5px*2 - 2px);
+ padding: 1px 5px;
+ //justify-content: center;
+ margin: -1px -1px;
+ font-size: 110%;
+}
+
+#collapsible {
+ display: none;
+}
+
+#dataListDiv {
+ max-height: 0px;
+ overflow-y: hidden;
+ opacity: 1;
+ transition: max-height 250ms ease-in-out, opacity 500ms;
+}
+
+#collapsible:checked + #dataListDiv {
+ max-height: 100%;
+ overflow-y: visible;
+ opacity: 1;
+}
+
+#dataListTable {
+ width: 100%;
+}
+
+.setupSelectorDiv {
+ padding-bottom: 5px;
+}
+
+#scroller {
+ /* fill parent */
+ display: block;
+ width: 100%;
+ height: 100%;
+ /* set to some transparent color */
+ border-color: rgba(0, 0, 0, 0.0);
+ transition: border-color 300ms ease-in-out;
+ overflow: auto;
+ padding-right: 2px;
+ margin-bottom: 5px;
+}
+
+#scroller:hover {
+ /* the color we want the scrollbar on hover */
+ border-color: rgba(0, 0, 0, 0.3);
+}
+
+#scroller::-webkit-scrollbar,
+#scroller::-webkit-scrollbar-thumb,
+#scroller::-webkit-scrollbar-corner {
+ /* add border to act as background-color */
+ border-right-style: outset;
+ border-right-width: 3px;
+ /* inherit border-color to inherit transitions */
+ border-color: inherit;
+}
+#scroller::-webkit-scrollbar {
+ width: 3px;
+ height: 3px;
+ border-color: rgba(0,0,0,0);
+}
+#scroller::-webkit-scrollbar-thumb {
+ border-color: inherit;
+ border-radius: 50px;
+}
+
+#scroller::-webkit-scrollbar-thumb:active {
+ border-color: rgba(0, 0, 0, 0.5);
+}
+
+// #setupTableDiv {
+// overflow-y: scroll;
+// max-height: 100%;
+// }
+// #setupTableDiv::-webkit-scrollbar
+// {
+// width: 5px;
+// background-color: #F5F5F5;
+// }
+// #setupTableDiv::-webkit-scrollbar-thumb
+// {
+// background-color: #696969;
+// border-radius: 420px;
+// }
+#setupTbody tr:nth-child(odd){
+ background-color: rgba(0, 0, 0, 0.25);
+}
+#setupTbody tr:nth-child(even){
+ background-color: rgba(0, 0, 0, 0.069);
+}
+.tsitu-fave-setup-row {
+ display: grid;
+ align-items: stretch;
+ grid-template-columns: 1fr auto 2em;
+ grid-template-rows: 50% 50%;
+ grid-template-areas:
+ "a c d"
+ "b c e";
+ padding: 3px;
+ border-radius: 3px;
+ white-space: nowrap;
+ overflow: hidden;
+ text-overflow: ellipsis;
+}
+.tsitu-fave-setup-namespan {
+ grid-area: a;
+ font-size: inherit;
+ text-align: left;
+ text-overflow: ellipsis;
+ padding-top: 3px;
+ padding-left: 3px;
+ margin-right: -3px;
+}
+.travelButton {
+ grid-area: b;
+ overflow: hidden;
+ padding: 0px 2px;
+ font-size: inherit;
+ display: flex;
+ align-items: center;
+ justify-content: center;
+ width: auto;
+}
+#imgSpan {
+ grid-area: c;
+ //align-items: center;
+ max-height: 100%;
+ max-width: max-content;
+ min-width: max-content;
+ padding: 0px 0px 0px 0px;
+ margin-left: 3px;
+ margin-right: -1px;
+ //justify-items: center;
+ overflow: hidden;
+}
+#imgSpan img {
+ max-height: 100%;
+ max-width: 100%;
+ height: 3.2vh; /* change this to change the overall size which should scale with this */
+// width: auto;
+// object-fit: scale-down;
+ margin-bottom: -3px;
+}
+#editButton {
+ grid-area: d;
+ text-align: center;
+ font-size: inherit;
+ padding: 0;
+ margin-bottom: -1px;
+}
+#deleteButton {
+ grid-area: e;
+ text-align: center;
+ font-size: inherit;
+ padding: 0;
+ margin-top: -1px;
+}
+#resizeButton {
+ display: flex;
+ flex-direction: right;
+ float: right;
+ font-size: 15px;
+ color: rgba(690,0,0,0.69);
+ padding: 1px 5px;
+ margin: -11px;
+ background-color: rgba(420,0,0,0.420);
+ border-radius: 5px 0px;
+ border: none;
+}
+`);
(function () {
// Observe Camp page for mutations (to re-inject button)
const observerTarget = document.querySelector(".mousehuntPage-content");
From 00f70fb25c00571d874dfd06c0b545dbba5015c1 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Mon, 3 Aug 2020 00:32:20 -0400
Subject: [PATCH 25/61] added scroller wrapper to setup table
---
src/favorite-setups.js | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index ab16317..6555f38 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -821,6 +821,12 @@ GM_addStyle ( `
// TODO: [med] Mobile UX for drag & drop as well as scrollable div (jquery-ui-touch-punch did not work for simulating touch events)
// TODO: [low] Skin implementation/checks (in-progress, but either save for later or scrap entirely since use case is minimal)
+ const scroller = document.createElement("div");
+ scroller.id = "scroller";
+
+ const setupTableDiv = document.createElement("div");
+ setupTableDiv.id = "setupTableDiv";
+
// Generate and append each saved setup as a new
savedSetupSortKeys.forEach(name => {
generateRow(name);
@@ -1019,7 +1025,8 @@ GM_addStyle ( `
mainDiv.appendChild(buttonSpan);
mainDiv.appendChild(dataListDiv);
mainDiv.appendChild(setupSelectorDiv);
- mainDiv.appendChild(setupTableDiv);
+ scroller.appendChild(setupTableDiv);
+ mainDiv.appendChild(scroller);
mainDiv.appendChild(toggleSort);
document.body.appendChild(mainDiv);
dragElement(mainDiv, topDiv);
From dcdc27d23fc57f6439cf6f541f4d004b79edecab Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Mon, 3 Aug 2020 00:33:21 -0400
Subject: [PATCH 26/61] bug fix: removed old setupTableDiv
---
src/favorite-setups.js | 3 ---
1 file changed, 3 deletions(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 6555f38..6de5fff 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -726,9 +726,6 @@ GM_addStyle ( `
buttonSpan.appendChild(resetButton);
// Setup table styling
- const setupTableDiv = document.createElement("div");
- setupTableDiv.style.overflowY = "scroll";
- setupTableDiv.style.height = "50vh";
const setupTable = document.createElement("table");
const setupTbody = document.createElement("tbody");
From 82b9e6487e722ca4489b1195ed5e79e8ee7bf102 Mon Sep 17 00:00:00 2001
From: Joshua Cheng <22689840+PersonalPalimpsest@users.noreply.github.com>
Date: Mon, 3 Aug 2020 00:44:41 -0400
Subject: [PATCH 27/61] removing in-line styles, assigning ids and classes to
format in the CSS
---
src/favorite-setups.js | 66 ++++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 35 deletions(-)
diff --git a/src/favorite-setups.js b/src/favorite-setups.js
index 6de5fff..6449c00 100644
--- a/src/favorite-setups.js
+++ b/src/favorite-setups.js
@@ -507,32 +507,19 @@ GM_addStyle ( `
// Main popup styling
const mainDiv = document.createElement("div");
mainDiv.id = "tsitu-fave-setups";
- mainDiv.style.backgroundColor = "#F5F5F5";
- mainDiv.style.position = "fixed";
- mainDiv.style.zIndex = "42";
- mainDiv.style.left = "5px";
- mainDiv.style.top = "5px";
- mainDiv.style.border = "solid 3px #696969";
- mainDiv.style.borderRadius = "20px";
- mainDiv.style.padding = "10px";
- mainDiv.style.textAlign = "center";
// Top div styling (close button, title, drag instructions)
const topDiv = document.createElement("div");
+ topDiv.id = "header"
+ topDiv.title = "Drag header to reposition this popup";
const titleSpan = document.createElement("span");
- titleSpan.style.fontWeight = "bold";
- titleSpan.style.fontSize = "18px";
- titleSpan.style.textDecoration = "underline";
- titleSpan.style.paddingLeft = "20px";
+ titleSpan.className = "title";
titleSpan.innerText = "Favorite Setups";
- const dragSpan = document.createElement("span");
- dragSpan.innerText = "(Drag title to reposition this popup)";
const closeButton = document.createElement("button");
- closeButton.style.float = "right";
- closeButton.style.fontSize = "8px";
- closeButton.textContent = "x";
+ closeButton.id = "close-button";
+ closeButton.textContent = "×";
closeButton.onclick = function () {
document.body.removeChild(mainDiv);
localStorage.setItem('showSetups', "N");
@@ -540,12 +527,11 @@ GM_addStyle ( `
topDiv.appendChild(closeButton);
topDiv.appendChild(titleSpan);
- topDiv.appendChild(document.createElement("br"));
- topDiv.appendChild(dragSpan);
// Build