From 04c8c55a37c9b073a33b0cf94dc15c72bcb9e5b0 Mon Sep 17 00:00:00 2001 From: AlterTobi Date: Thu, 12 Dec 2024 14:42:06 +0100 Subject: [PATCH] use material icons, not svg; use callback object --- _pages/images/white-arrow-right-up.png | Bin 1851 -> 0 bytes _pages/images/white_cross.png | Bin 1701 -> 0 bytes no_support/wfes-NominationNotify.js | 30 ++++++++++------- wfes-AutoHold.js | 4 +-- wfes-Base.js | 44 +++++++++++++++---------- 5 files changed, 48 insertions(+), 30 deletions(-) delete mode 100644 _pages/images/white-arrow-right-up.png delete mode 100644 _pages/images/white_cross.png diff --git a/_pages/images/white-arrow-right-up.png b/_pages/images/white-arrow-right-up.png deleted file mode 100644 index 29826b5cc9fa23cde9289139b6cd6d83b1a3635f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1851 zcmc&!drVVT7%vo%@qSJq2D@TJrfqL;-#0C#w+|>%D5c{O9PIY?7K*gD++Jx#ryGc4 zGdz@;@dz>&P&Uj!qL~?SM9B{oY=~6=;f|Cv|=GWnR9WH=oFyuFw>j@x9rSTF<&d60z17jyV9B9I}F zkhQ+pz#(O|AtsG(-5t0o*wr-cLU=rn$HVmqxFl7@B5JrV4IBIoLk%%u7@nL~Xt5Hit=!T7FVRZt56jo_8s0bDNu_~cdg$lK> zL@j_&NGjaG>YZ*HbK=B?Upw%-j#WPwi>N6Aqe;q4lC>L6V5}x-(p^ouSg@GOXYDAl zJFTS0o#C&~TDTg5vey$<9Ys1=s|iNz&mbU^5i&6!vvDv9B;wd`p^$?SGATzSw84D7 z4C2F5D|;PpeJXKlJqjcs2-gM|gfEoX1Y)a%1K}2kBe4mk92sGQIj|MD5#Tn9gs`!B zfFjS|Gf(xD2nFh=BiYxoSdAw zxw)jIq^_>6@$qrc^;@@YjgF2^NJz-e&OUzpcxPwlg$oy2T3QAM26}sY2L}g3Lqp|q zd3kyH*x1sFPM$pJa=CWz-kqA7nwFLZMzx}%LM#@WOs0^K zkdBTHu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5!EFIT~*-vf%k6-=M@PDZWa`m#+;2R zo;>TnvS-JgCCTQeKiNC|%o}g!-`Mx+nVm1Zb0Pgs@7=LR3Oed&+bu@{5n zsV&g#4<{lThwP`<*%+;4;q5CM+k;5k3H8;2;s>#c&YHJ|s|vO%7mXdQMaduHpX13% zQ_VM}m$Y4%XQpo~9e5yld4K)8y|L;quPcMc;G?(EX-RvWtD?F1@7vPX&yQ_?@Ay>R z;nbgYF#86Ec5dnWDl@U+l@Dg7>IUtSroO+b`(`uhzTWGRO$}I%1~>O#oJf2&sJY!T zcCc~XpR;lO#E(JE{ohBebKCac3`~;`Lk>5hGt!pyW&%>D+dH}>DpE4 sxTWH^-Mt_8bk8^4I5Xn@ In voting if ((historicalData.status !== "VOTING") && ("VOTING" === nom.status)) { - window.wfes.f.createNotification(`${notiTitle} went into voting!`, "green", searchSubmission, [nom.title]); + window.wfes.f.createNotification(`${notiTitle} went into voting!`, "green", callbackConfig); } else if ((historicalData.status !== "HELD") && ("HELD" === nom.status)) { // only if nomination is "old" if (getDateDiff(nom.day) > noHeldMsgDays) { - window.wfes.f.createNotification(`${notiTitle} put on HOLD!`, "red", searchSubmission, [nom.title]); + window.wfes.f.createNotification(`${notiTitle} put on HOLD!`, "red", callbackConfig); } } else if ((historicalData.status !== "APPEALED") && ("APPEALED" === nom.status)) { - window.wfes.f.createNotification(`${notiTitle} was appealed!`, "green", searchSubmission, [nom.title]); + window.wfes.f.createNotification(`${notiTitle} was appealed!`, "green", callbackConfig); } else if (historicalData.status !== "ACCEPTED" && historicalData.status !== "REJECTED" && historicalData.status !== "DUPLICATE") { if ("ACCEPTED" === nom.status) { - window.wfes.f.createNotification(`${notiTitle} was accepted!`, "green", searchSubmission, [nom.title]); + window.wfes.f.createNotification(`${notiTitle} was accepted!`, "green", callbackConfig); }else if("REJECTED" === nom.status) { - window.wfes.f.createNotification(`${notiTitle} was rejected!`, "red", searchSubmission, [nom.title]); + window.wfes.f.createNotification(`${notiTitle} was rejected!`, "red", callbackConfig); }else if("DUPLICATE" === nom.status) { - window.wfes.f.createNotification(`${notiTitle} was marked as a duplicate!`, "", searchSubmission, [nom.title]); + window.wfes.f.createNotification(`${notiTitle} was marked as a duplicate!`, "", callbackConfig); } } diff --git a/wfes-AutoHold.js b/wfes-AutoHold.js index 9a7f4025..3ba34977 100644 --- a/wfes-AutoHold.js +++ b/wfes-AutoHold.js @@ -1,5 +1,5 @@ // @name AutoHold -// @version 1.3.0 +// @version 1.3.1 // @description put nomination on HOLD when additional stament contains the text "#hold" // @author AlterTobi @@ -68,7 +68,7 @@ window.wfes.f.createNotification(`AutoHold: ${o.title}`, "orange"); _setHold(o.id); } else { - window.wfes.f.createNotification("AutoHold: all nominations processed, click arrow to reload page", "green", _reloadPage); + window.wfes.f.createNotification("AutoHold: all nominations processed, click arrow to reload page", "green", { callback: _reloadPage, icon: "renew"}); } } diff --git a/wfes-Base.js b/wfes-Base.js index 1f2da6ee..93c06999 100644 --- a/wfes-Base.js +++ b/wfes-Base.js @@ -1,5 +1,5 @@ // @name Base -// @version 2.3.0 +// @version 2.3.1 // @description basic functionality for WFES // @author AlterTobi // @run-at document-start @@ -22,9 +22,6 @@ const idbName = "wfes-data"; const idbLocalStorageCompat = "localStorage"; - const imgClose = "https://altertobi.github.io/Wayfarer-Extension-Scripts/dev/images/white_cross.png"; - const imgAction = "https://altertobi.github.io/Wayfarer-Extension-Scripts/dev/images/white-arrow-right-up.png"; - const myCssId = "notifyAreaCSS"; const myStyle = ` /* Container */ @@ -67,15 +64,12 @@ /* Buttons-Gruppe */ .wfesButtonGroup { display: flex; - gap: 10px; align-items: center; } /* notification Buttons */ .wfesNotiButton { - border: none; - width: 32px; - height: 32px; + font-size: 32px; cursor: pointer; } @@ -651,7 +645,7 @@ } }; - window.wfes.f.createNotification = function(message = "no message", color = "green", callback = null, callbackParams = []) { + window.wfes.f.createNotification = function(message = "no message", color = "green", callbackConfig = null) { const notification = document.createElement("div"); switch (color) { case "red": @@ -681,22 +675,38 @@ buttonGroup.setAttribute("class", "wfesButtonGroup"); // Schließen-Button - const closeButton = document.createElement("img"); - closeButton.setAttribute("class", "wfesNotiButton"); - closeButton.src = imgClose; + const closeButton = document.createElement("button"); + closeButton.setAttribute("class", "wfesNotiButton material-icons"); + closeButton.innerText = "close"; closeButton.onclick = function() { notification.remove(); }; // Optionaler Callback-Button - if (callback && "function" === typeof callback) { - const actionButton = document.createElement("img"); - actionButton.setAttribute("class", "wfesNotiButton"); - actionButton.src = imgAction; + if (callbackConfig && "function" === typeof callbackConfig.callback) { + const actionButton = document.createElement("button"); + actionButton.setAttribute("class", "wfesNotiButton material-icons"); + + let actionIcon; + switch (callbackConfig.icon) { + case "play": + actionIcon = "play_circle_outline"; + break; + case "search": + actionIcon = "search"; + break; + case "renew": + actionIcon="autorenew"; + break; + default: + actionIcon = "play_circle"; + } + + actionButton.innerText = actionIcon; actionButton.onclick = function(event) { event.stopPropagation(); // Verhindert, dass der Klick das notification-Element erreicht - callback(...callbackParams); // Ruft die Callback-Funktion mit den übergebenen Parametern auf + callbackConfig.callback(...(callbackConfig.params || [])); // Ruft die Callback-Funktion mit den übergebenen Parametern auf }; buttonGroup.appendChild(actionButton); }