mirror of
https://github.com/SwingTheVine/Wplace-BlueMarble.git
synced 2026-04-21 19:31:56 +00:00
Added main overlay's UI related JS
This commit is contained in:
parent
9d8f4fc1ef
commit
341c14b10c
6 changed files with 48 additions and 20 deletions
|
|
@ -3,7 +3,7 @@
|
||||||
<header>
|
<header>
|
||||||
<div id="bm-bar-drag"></div>
|
<div id="bm-bar-drag"></div>
|
||||||
<h1>Create new template</h1>
|
<h1>Create new template</h1>
|
||||||
<button id="close"><!-- Add cross icon --></button>
|
<button id="close">✕</button>
|
||||||
</header>
|
</header>
|
||||||
<hr />
|
<hr />
|
||||||
<form>
|
<form>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<header>
|
<header>
|
||||||
<div id="bm-bar-drag"></div>
|
<div id="bm-bar-drag"></div>
|
||||||
<h1>Blue Marble</h1>
|
<h1>Blue Marble</h1>
|
||||||
<button id="close"><!-- Add cross icon --></button>
|
<button id="close">✕</button>
|
||||||
</header>
|
</header>
|
||||||
<hr />
|
<hr />
|
||||||
<table>
|
<table>
|
||||||
|
|
@ -16,8 +16,8 @@
|
||||||
<td id="droplets"></td>
|
<td id="droplets"></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>Next level in... </td>
|
<td>Level: </td>
|
||||||
<td id="next-level"></td>
|
<td id="level"></td>
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
<div>
|
<div>
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
<header>
|
<header>
|
||||||
<div id="bm-bar-drag"></div>
|
<div id="bm-bar-drag"></div>
|
||||||
<h1>Links manager</h1>
|
<h1>Links manager</h1>
|
||||||
<button id="close"><!-- Add cross icon --></button>
|
<button id="close">✕</button>
|
||||||
</header>
|
</header>
|
||||||
<hr />
|
<hr />
|
||||||
<label>
|
<label>
|
||||||
|
|
|
||||||
14
package-lock.json
generated
14
package-lock.json
generated
|
|
@ -8,7 +8,6 @@
|
||||||
"name": "wplace-bluemarble",
|
"name": "wplace-bluemarble",
|
||||||
"version": "0.81.0",
|
"version": "0.81.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@types/greasemonkey": "^4.0.7",
|
|
||||||
"zod": "^4.0.17"
|
"zod": "^4.0.17"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|
@ -18,7 +17,6 @@
|
||||||
"eslint": "^9.33.0",
|
"eslint": "^9.33.0",
|
||||||
"globals": "^16.3.0",
|
"globals": "^16.3.0",
|
||||||
"jsdoc": "^4.0.4",
|
"jsdoc": "^4.0.4",
|
||||||
"minami": "^1.2.3",
|
|
||||||
"prettier": "^3.6.2",
|
"prettier": "^3.6.2",
|
||||||
"terser": "^5.43.1",
|
"terser": "^5.43.1",
|
||||||
"typescript-eslint": "^8.39.1"
|
"typescript-eslint": "^8.39.1"
|
||||||
|
|
@ -980,12 +978,6 @@
|
||||||
"@types/geojson": "*"
|
"@types/geojson": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@types/greasemonkey": {
|
|
||||||
"version": "4.0.7",
|
|
||||||
"resolved": "https://registry.npmjs.org/@types/greasemonkey/-/greasemonkey-4.0.7.tgz",
|
|
||||||
"integrity": "sha512-DuYBRf/T4zixO/xhQ3eicZCBjjOgbSSXuHP5XkLNf/UBayrJpBniP9il/AQaPy0lffl4Bco48zgHL+pZmQ6Q0A==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/@types/json-schema": {
|
"node_modules/@types/json-schema": {
|
||||||
"version": "7.0.15",
|
"version": "7.0.15",
|
||||||
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
|
"resolved": "https://registry.npmjs.org/@types/json-schema/-/json-schema-7.0.15.tgz",
|
||||||
|
|
@ -2503,12 +2495,6 @@
|
||||||
"node": ">=8.6"
|
"node": ">=8.6"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/minami": {
|
|
||||||
"version": "1.2.3",
|
|
||||||
"resolved": "https://registry.npmjs.org/minami/-/minami-1.2.3.tgz",
|
|
||||||
"integrity": "sha512-3f2QqqbUC1usVux0FkQMFYB73yd9JIxmHSn1dWQacizL6hOUaNu6mA3KxZ9SfiCc4qgcgq+5XP59+hP7URa1Dw==",
|
|
||||||
"dev": true
|
|
||||||
},
|
|
||||||
"node_modules/minimatch": {
|
"node_modules/minimatch": {
|
||||||
"version": "3.1.2",
|
"version": "3.1.2",
|
||||||
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
|
||||||
|
|
|
||||||
|
|
@ -35,8 +35,8 @@ export const uiManager = new UIManager();
|
||||||
const mainOverlay = document.querySelector("#bm-main-overlay");
|
const mainOverlay = document.querySelector("#bm-main-overlay");
|
||||||
// If main overlay already exists that means another Blue Marble instance is already running
|
// If main overlay already exists that means another Blue Marble instance is already running
|
||||||
if(!mainOverlay){
|
if(!mainOverlay){
|
||||||
|
|
||||||
// Only run the code if this is the first Blue Marble instance
|
// Only run the code if this is the first Blue Marble instance
|
||||||
|
|
||||||
const params = new URLSearchParams(document.location.search); // Gets the url search query
|
const params = new URLSearchParams(document.location.search); // Gets the url search query
|
||||||
if (params.has("bmShare")) {
|
if (params.has("bmShare")) {
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
|
|
@ -23,9 +23,51 @@ function openManLinks(){
|
||||||
uiManager.open("bm-manage-links")
|
uiManager.open("bm-manage-links")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**Updates the values in this window's UI
|
||||||
|
* @since 0.2.0-overhaul
|
||||||
|
*/
|
||||||
|
function updateUI(){
|
||||||
|
|
||||||
|
if(!charity.game.user.data){ return }
|
||||||
|
|
||||||
|
// Try to get elements and set the appropriate text
|
||||||
|
const nameTD = document.querySelector("#bm-main-overlay td#name");
|
||||||
|
if(nameTD && nameTD.nodeName.toLocaleUpperCase() === "TD"){
|
||||||
|
nameTD.textContent = charity.game.user.data.name;
|
||||||
|
}
|
||||||
|
const dropletsTD = document.querySelector("#bm-main-overlay td#droplets")
|
||||||
|
if(dropletsTD && dropletsTD.nodeName.toLocaleUpperCase() === "TD"){
|
||||||
|
dropletsTD.textContent = charity.game.user.data.droplets.toString();
|
||||||
|
}
|
||||||
|
const levelTD = document.querySelector("#bm-main-overlay td#level");
|
||||||
|
if(levelTD && levelTD.nodeName.toLocaleUpperCase() === "TD"){
|
||||||
|
levelTD.textContent = charity.game.user.data.level.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**Initialises this window's UI-related javascript (addEventListener hooks, ect)
|
/**Initialises this window's UI-related javascript (addEventListener hooks, ect)
|
||||||
* @since 0.1.0-overhaul
|
* @since 0.1.0-overhaul
|
||||||
*/
|
*/
|
||||||
export function initMainOverlay(){
|
export function initMainOverlay(){
|
||||||
|
|
||||||
|
// Try to get the close button and connect the appropriate function to the onClick listener
|
||||||
|
const closeBtn = document.querySelector("#bm-main-overlay button#close");
|
||||||
|
if(closeBtn && closeBtn.nodeName.toLocaleUpperCase() === "BUTTON"){
|
||||||
|
closeBtn.addEventListener("click", ()=>close());
|
||||||
|
}
|
||||||
|
|
||||||
|
updateUI()
|
||||||
|
|
||||||
|
// Try to get elements and connect the appropriate function to the onClick listener
|
||||||
|
const manageTemplatesBtn = document.querySelector("#bm-main-overlay button#manage-templates");
|
||||||
|
if(manageTemplatesBtn && manageTemplatesBtn.nodeName.toLocaleUpperCase() === "BUTTON"){
|
||||||
|
manageTemplatesBtn.addEventListener("click", ()=>openManTemplates())
|
||||||
|
}
|
||||||
|
const manageLinksBtn = document.querySelector("#bm-main-overlay button#manage-links");
|
||||||
|
if(manageLinksBtn && manageLinksBtn.nodeName.toLocaleUpperCase() === "BUTTON"){
|
||||||
|
manageLinksBtn.addEventListener("click", ()=>openManLinks())
|
||||||
|
}
|
||||||
|
|
||||||
// Add event listener hooks
|
// Add event listener hooks
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue