Socket
Socket
Sign inDemoInstall

nodebb-theme-oxide

Package Overview
Dependencies
2
Maintainers
1
Versions
147
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 5.0.35 to 5.0.36

45

lib/modules/toggleTheme.js

@@ -6,37 +6,34 @@ /* globals ajaxify */

const setTheme = (isDark) => {
const safeBool = Boolean(isDark);
const _updateTheme = (state) => {
const safeState = Boolean(state);
document.documentElement.setAttribute("dark", safeBool);
localStorage.setItem("user:dark", safeBool);
document.documentElement.setAttribute("dark", safeState);
localStorage.setItem("user:dark", safeState);
};
const toggleTheme = (e) => {
e.stopPropagation();
const _setTheme = (e, btn) => {
e.preventDefault();
const { target } = e;
window.darkmode = !window.darkmode;
if (target.className === "off" && target.id === "toggle-theme") {
setTheme(true);
target.className = "on";
} else {
setTheme(false);
target.className = "off";
}
const btnState = window.darkmode ? "on" : "off";
btn.className = btnState;
_updateTheme(window.darkmode);
};
const addButton = () => {
if (!ajaxify.data.loggedIn) return null;
const isDefault = document.documentElement.dataset.initialDark ? true : false;
if (isDefault) return;
const toggleBtn = document.querySelector("#toggle-theme");
isDark ? toggleBtn.classList.add("on") : toggleBtn.classList.add("off");
window.darkmode = localStorage.getItem("user:dark") ? true : false;
_updateTheme(window.darkmode);
toggleBtn.addEventListener("click", toggleTheme, false);
};
$(window).on("action:ajaxify.end", () => {
if (!ajaxify.data.loggedIn) return null;
const isDark = JSON.parse(localStorage.getItem("user:dark"));
const btn = document.querySelector("#toggle-theme");
window.darkmode ? (btn.className = "on") : (btn.className = "off");
localStorage.getItem("user:dark") === null ? setTheme(false) : setTheme(isDark);
$(window).on("action:ajaxify.end", addButton);
btn.addEventListener("click", (e) => _setTheme(e, btn), false);
});
})();

@@ -112,3 +112,3 @@ "use strict";

config.enableShowIpInUserProfile = enableShowIpInUserProfile === "on";
config.enableDarkmodeIsDefault = enableDarkmodeIsDefault === "on";
config.enableDarkmodeIsDefault = enableDarkmodeIsDefault === "off";
});

@@ -115,0 +115,0 @@

{
"name": "nodebb-theme-oxide",
"description": "A theme that is based on the GitHub design.",
"version": "5.0.35",
"version": "5.0.36",
"homepage": "https://github.com/youhosi/nodebb-theme-oxide",

@@ -6,0 +6,0 @@ "license": "MIT",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc