Initial commit
This commit is contained in:
19 files changed
+1652
No files matched your search
@@ -0,0 +1,27 @@
|
||||
(function () {
|
||||
var root = document.documentElement, KEY = "ricehub-mode";
|
||||
try { var saved = localStorage.getItem(KEY); if (saved) root.dataset.theme = saved; } catch (e) {}
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
var mode = document.getElementById("mode");
|
||||
if (mode) mode.onclick = function () {
|
||||
var dark = root.dataset.theme
|
||||
? root.dataset.theme === "dark"
|
||||
: matchMedia("(prefers-color-scheme:dark)").matches;
|
||||
var next = dark ? "light" : "dark";
|
||||
root.dataset.theme = next;
|
||||
try { localStorage.setItem(KEY, next); } catch (e) {}
|
||||
};
|
||||
var toast = document.getElementById("toast");
|
||||
document.querySelectorAll(".sw button").forEach(function (b) {
|
||||
b.onclick = function () {
|
||||
var hex = b.dataset.hex;
|
||||
function done() {
|
||||
toast.textContent = "Copied " + hex;
|
||||
toast.classList.add("on");
|
||||
setTimeout(function () { toast.classList.remove("on"); }, 1400);
|
||||
}
|
||||
try { navigator.clipboard.writeText(hex).then(done, done); } catch (e) { done(); }
|
||||
};
|
||||
});
|
||||
});
|
||||
})();
|
||||
Reference in new issue
Block a user