Skip to content

Commit

Permalink
bug fix Sty-Lists.js
Browse files Browse the repository at this point in the history
  • Loading branch information
SharkPool-SP authored Sep 7, 2024
1 parent 6718ac2 commit 353dc79
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions extensions/SharkPool/Sty-Lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
// Description: Customize and Organize Lists Monitors.
// By: SharkPool

// Version 2.0.0
// Version 2.0.1

(function (Scratch) {
"use strict";
if (!Scratch.extensions.unsandboxed) throw new Error("Sty-Lists must run unsandboxed!");

const menuIconURI =
"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI2Mi4xNDMiIGhlaWdodD0iNjIuMTQzIiB2aWV3Qm94PSIwIDAgNjIuMTQzIDYyLjE0MyI+PGcgc3Ryb2tlLW1pdGVybGltaXQ9IjEwIiBzdHlsZT0ibWl4LWJsZW5kLW1vZGU6bm9ybWFsIj48cGF0aCBkPSJNMCAzMS4wNzFDMCAxMy45MTEgMTMuOTEgMCAzMS4wNzEgMGMxNy4xNiAwIDMxLjA3MSAxMy45MSAzMS4wNzEgMzEuMDcxIDAgMTcuMTYtMTMuOTEgMzEuMDcxLTMxLjA3MSAzMS4wNzFDMTMuOTExIDYyLjE0MiAwIDQ4LjIzMiAwIDMxLjA3MSIgZmlsbD0iI2NjNDYwMiIvPjxwYXRoIGQ9Ik0zLjU2NCAzMS4wNzFjMC0xNS4xOTIgMTIuMzE1LTI3LjUwNyAyNy41MDctMjcuNTA3czI3LjUwNyAxMi4zMTUgMjcuNTA3IDI3LjUwNy0xMi4zMTUgMjcuNTA3LTI3LjUwNyAyNy41MDdTMy41NjQgNDYuMjYzIDMuNTY0IDMxLjA3MSIgZmlsbD0iI2ZmNjYxYSIvPjxwYXRoIGQ9Im00NC4yMzkgMzguNjQ1LS4wMDUuMDQ3djQuNzY0YzAgLjU3My0uNDYzIDEuMDQ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Q0IDEuMDQ0aC00LjgxYTEuMDQ0IDEuMDQ0IDAgMCAxLTEuMDQ0LTEuMDQ0di00LjgxYzAtLjU3Ni40NjgtMS4wNDQgMS4wNDQtMS4wNDRoNC44MTFjLjI3NyAwIC41NDIuMTEuNzM4LjMwNiIgZmlsbD0iI2ZmZiIvPjxwYXRoIGQ9Ik00Ni43NjEgMzMuMDYyYy41MjEgMCAuOTQ0LjQyMy45NDQuOTQ0djEwLjQ3NkgzNy4yMjZjLS41Mi0uMDAyLS45NC0uMzM0LS45NC0uODU0bC4wMDMtNC40MzZjMC0uNTE5LjQ2NC0uOTg1Ljk4Mi0uOTg4bDQuMi4wNDR2LTQuMjM5YS45NDMuOTQzIDAgMCAxIC45NDMtLjkzN3oiIGZpbGw9IiNmZmYiIHN0cm9rZT0iI2ZmNjYxYSIgc3Ryb2tlLXdpZHRoPSI2Ii8+PHBhdGggZD0iTTQ2Ljc2MSAzMy4wNjJjLjUyMSAwIC45NDQuNDIzLjk0NC45NDR2NC4yNDJoNC4yMzlhLjk0My45NDMgMCAwIDEgLjkzNy45NDRsLjAxIDQuMzQ2YS45NDQuOTQ0IDAgMCAxLS45NDQuOTQ0aC00LjI0MnY0LjI0NWMtLjAwMi41Mi0uNDY5Ljk0LS45ODkuOTRsLTQuMjU2LS4wMDNjLS41MTkgMC0uOTg1LS40MTktLjk4OC0uOTM3di00LjI0NWgtNC4yNDZjLS41Mi0uMDAyLS45NC0uMzM0LS45NC0uODU0bC4wMDMtNC40MzZjMC0uNTE5LjQ2NC0uOTg1Ljk4Mi0uOTg4bDQuMi4wNDR2LTQuMjM5YS45NDMuOTQzIDAgMCAxIC45NDMtLjkzN3oiIGZpbGw9IiNmZmYiLz48L3N2Zz4=";

const vm = Scratch.vm;
const runtime = vm.runtime;
Expand Down Expand Up @@ -336,16 +336,16 @@
if (list.listenerApplied === undefined) {
list.listenerApplied = true;
const container = listMon.querySelector(listDocs.grid);
container.addEventListener("scroll", () => { this.applyChanges(listMon, id) });
container.addEventListener("scroll", () => this.applyChanges(listMon, id));
}
const allItems = listMon.querySelectorAll(`div[class^="${listDocs.body}"] [class^="${listDocs.value}"]`);
const changedLabels = list.labels, changedColors = list.colors;
const isPackaged = typeof scaffolding !== "undefined";
allItems.forEach((item, i) => {
if (isPackaged ? item.parentNode.getAttribute("data-index") == i : item.getAttribute("dataindex") == i) {
if (changedLabels && changedLabels[i]) item.previousSibling.textContent = changedLabels[i];
if (changedColors && changedColors[i]) item.style.background = changedColors[i];
}
const allItems = listMon.querySelectorAll(`div[class^="${listDocs.body}"] [class^="${listDocs.value}"]`);
const newLabels = list.labels || {}, newColors = list.colors || {};
allItems.forEach((item) => {
const i = isPackaged ? item.parentNode.getAttribute("data-index") : item.getAttribute("dataindex");
if (newLabels[i]) item.previousSibling.textContent = newLabels[i];
if (isPackaged) item.style.background = newColors[i] || ""; // Labels auto reset, colors do not
else if (newColors[i]) item.style.background = newColors[i];
});
}

Expand All @@ -367,7 +367,7 @@
workspace.toolboxRefreshEnabled_ = true;
workspace.refreshToolboxSelection_();
workspace.toolboxRefreshEnabled_ = false;
setTimeout(function() { runtime.requestBlocksUpdate() }, 10);
setTimeout(() => { runtime.requestBlocksUpdate() }, 10);
}
}

Expand Down Expand Up @@ -421,7 +421,7 @@
container.style.overflowX = "hidden";
container.style.height = "100%";
container.style.position = "relative";
container.addEventListener("scroll", () => { this.applyChanges(listMon, id) });
container.addEventListener("scroll", () => this.applyChanges(listMon, id));
for (let i = 0; i < Math.ceil(items.length / columnCnt); i++) {
const row = document.createElement("div");
row.className = itemClasses[0];
Expand Down Expand Up @@ -619,8 +619,9 @@
const { id, listMon } = this.getMonitor(args.LIST, util, true);
if (!listMon) return;
const index = Math.max(0, Scratch.Cast.toNumber(args.NUM) - 1);
const val = args.VALUE.replaceAll(" ", " ");
const currentList = visualLists[id] || {};
visualLists[id] = { ...currentList, util, labels: { ...currentList.labels, [index]: args.VALUE } };
visualLists[id] = { ...currentList, util, labels: { ...currentList.labels, [index]: val } };
this.applyChanges(listMon, id);
}

Expand Down

0 comments on commit 353dc79

Please sign in to comment.