mirror of
https://github.com/kenzok8/openwrt-packages
synced 2025-01-09 09:07:28 +08:00
update 2023-03-05 14:19:59
This commit is contained in:
parent
384e7c24b2
commit
fa7bd0c4a8
19
luci-app-design-config/Makefile
Normal file
19
luci-app-design-config/Makefile
Normal file
@ -0,0 +1,19 @@
|
||||
include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=luci-app-design-config
|
||||
PKG_VERSION:=1.2
|
||||
PKG_RELEASE:=20230302
|
||||
|
||||
PKG_MAINTAINER:=gngpp <gngppz@gmail.com>
|
||||
|
||||
LUCI_TITLE:=LuCI page for Design Config
|
||||
LUCI_PKGARCH:=all
|
||||
LUCI_DEPENDS:=+luci-compat
|
||||
|
||||
define Package/$(PKG_NAME)/conffiles
|
||||
/etc/config/design
|
||||
endef
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
# call BuildPackage - OpenWrt buildroot signature
|
14
luci-app-design-config/README.md
Normal file
14
luci-app-design-config/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
# luci-app-design-config
|
||||
Design Theme Config Plugin
|
||||
|
||||
### Features
|
||||
- Support changing theme dark/light mode
|
||||
- Support for replacing commonly used proxy icons
|
||||
|
||||
### Compile
|
||||
|
||||
```
|
||||
git clone https://github.com/gngpp/luci-app-design-config.git package/luci-app-design-config
|
||||
make menuconfig # choose LUCI->Applications->luci-app-design-config
|
||||
make V=s
|
||||
```
|
10
luci-app-design-config/luasrc/controller/design-config.lua
Normal file
10
luci-app-design-config/luasrc/controller/design-config.lua
Normal file
@ -0,0 +1,10 @@
|
||||
module("luci.controller.design-config", package.seeall)
|
||||
|
||||
function index()
|
||||
if not nixio.fs.access('/www/luci-static/design/css/style.css') then
|
||||
return
|
||||
end
|
||||
|
||||
local page = entry({"admin", "system", "design-config"}, form("design-config"), _("Design Config"), 90)
|
||||
page.acl_depends = { "luci-app-design-config" }
|
||||
end
|
50
luci-app-design-config/luasrc/model/cbi/design-config.lua
Normal file
50
luci-app-design-config/luasrc/model/cbi/design-config.lua
Normal file
@ -0,0 +1,50 @@
|
||||
local nxfs = require 'nixio.fs'
|
||||
local nutil = require 'nixio.util'
|
||||
local name = 'design'
|
||||
local uci = require 'luci.model.uci'.cursor()
|
||||
|
||||
local mode, navbar_proxy
|
||||
if nxfs.access('/etc/config/design') then
|
||||
mode = uci:get_first('design', 'global', 'mode')
|
||||
navbar_proxy = uci:get_first('design', 'global', 'navbar_proxy')
|
||||
end
|
||||
|
||||
-- [[ 设置 ]]--
|
||||
br = SimpleForm('config', translate('Design Config'), translate('Here you can set the mode of the theme and change the proxy tool icon in the navigation bar. [Recommend Chrome]'))
|
||||
br.reset = false
|
||||
br.submit = false
|
||||
s = br:section(SimpleSection)
|
||||
|
||||
o = s:option(ListValue, 'mode', translate('Theme mode'))
|
||||
o:value('normal', translate('Follow System'))
|
||||
o:value('light', translate('Force Light'))
|
||||
o:value('dark', translate('Force Dark'))
|
||||
o.default = mode
|
||||
o.rmempty = false
|
||||
o.description = translate('You can choose Theme color mode here')
|
||||
|
||||
o = s:option(ListValue, 'navbar_proxy', translate('Navigation bar proxy'))
|
||||
o:value('openclash', 'openclash')
|
||||
o:value('shadowsocksr', 'shadowsocksr')
|
||||
o:value('vssr', 'vssr')
|
||||
o:value('passwall', 'passwall')
|
||||
o:value('passwall2', 'passwall2')
|
||||
o.default = navbar_proxy
|
||||
o.rmempty = false
|
||||
o.description = translate('OpenClash by default')
|
||||
|
||||
o = s:option(Button, 'save', translate('Save Changes'))
|
||||
o.inputstyle = 'reload'
|
||||
|
||||
function br.handle(self, state, data)
|
||||
if (state == FORM_VALID and data.mode ~= nil and data.navbar_proxy ~= nil) then
|
||||
nxfs.writefile('/tmp/aaa', data)
|
||||
for key, value in pairs(data) do
|
||||
uci:set('design','@global[0]',key,value)
|
||||
end
|
||||
uci:commit('design')
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return br
|
@ -0,0 +1,7 @@
|
||||
<%+cbi/valueheader%>
|
||||
<% if self:cfgvalue(section) ~= false then %>
|
||||
<input class="cbi-button cbi-input-<%=self.inputstyle or "button" %>" style="display: <%= display %>" type="submit"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self.inputtitle or self.title)%> />
|
||||
<% else %>
|
||||
-
|
||||
<% end %>
|
||||
<%+cbi/valuefooter%>
|
@ -0,0 +1,8 @@
|
||||
<%+cbi/valueheader%>
|
||||
<span style="color: red">
|
||||
<%
|
||||
local val = self:cfgvalue(section) or self.default or ""
|
||||
write(pcdata(val))
|
||||
%>
|
||||
</span>
|
||||
<%+cbi/valuefooter%>
|
32
luci-app-design-config/po/zh-cn/design-config.po
Normal file
32
luci-app-design-config/po/zh-cn/design-config.po
Normal file
@ -0,0 +1,32 @@
|
||||
msgid ""
|
||||
msgstr "Content-Type: text/plain; charset=UTF-8\n"
|
||||
|
||||
msgid "Design Config"
|
||||
msgstr "Design 主题设置"
|
||||
|
||||
msgid "Here you can set the mode of the theme and change the proxy tool icon in the navigation bar. [Recommend Chrome]"
|
||||
msgstr "这里可以设置主题的模式和更换导航栏的代理工具图标。[建议使用 Chrome]"
|
||||
|
||||
msgid "Theme mode"
|
||||
msgstr "主题模式"
|
||||
|
||||
msgid "Follow System"
|
||||
msgstr "跟随系统"
|
||||
|
||||
msgid "Force Light"
|
||||
msgstr "强制亮色"
|
||||
|
||||
msgid "Force Dark"
|
||||
msgstr "强制暗色"
|
||||
|
||||
msgid "You can choose Theme color mode here"
|
||||
msgstr "你可以选择喜欢的主题模式"
|
||||
|
||||
msgid "Navigation bar proxy"
|
||||
msgstr "导航栏代理"
|
||||
|
||||
msgid "OpenClash by default"
|
||||
msgstr "默认 OpenClash"
|
||||
|
||||
msgid "Save Changes"
|
||||
msgstr "保存更改"
|
1
luci-app-design-config/po/zh_Hans
Symbolic link
1
luci-app-design-config/po/zh_Hans
Symbolic link
@ -0,0 +1 @@
|
||||
zh-cn
|
3
luci-app-design-config/root/etc/config/design
Normal file
3
luci-app-design-config/root/etc/config/design
Normal file
@ -0,0 +1,3 @@
|
||||
config global
|
||||
option mode 'dark'
|
||||
option navbar_proxy 'openclash'
|
@ -0,0 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
sed -i 's/cbi.submit\"] = true/cbi.submit\"] = \"1\"/g' /usr/lib/lua/luci/dispatcher.lua
|
||||
|
||||
rm -f /tmp/luci-indexcache
|
||||
exit 0
|
@ -0,0 +1,11 @@
|
||||
{
|
||||
"luci-app-design-config": {
|
||||
"description": "Grant UCI access for luci-app-design-config",
|
||||
"read": {
|
||||
"uci": [ "design" ]
|
||||
},
|
||||
"write": {
|
||||
"uci": [ "design" ]
|
||||
}
|
||||
}
|
||||
}
|
@ -7,8 +7,8 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
LUCI_TITLE:=Design Theme
|
||||
LUCI_DEPENDS:=
|
||||
PKG_VERSION:=5.3.3
|
||||
PKG_RELEASE:=20230303
|
||||
PKG_VERSION:=5.3.6
|
||||
PKG_RELEASE:=20230305
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
292
luci-theme-design/dev/script.js
Normal file
292
luci-theme-design/dev/script.js
Normal file
@ -0,0 +1,292 @@
|
||||
/**
|
||||
* Material is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI
|
||||
*
|
||||
* luci-theme-material
|
||||
* Copyright 2015 Lutty Yang <lutty@wcan.in>
|
||||
*
|
||||
* Have a bug? Please create an issue here on GitHub!
|
||||
* https://github.com/LuttyYang/luci-theme-material/issues
|
||||
*
|
||||
* luci-theme-bootstrap:
|
||||
* Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
* Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
|
||||
* Copyright 2012 David Menting <david@nut-bolt.nl>
|
||||
*
|
||||
* MUI:
|
||||
* https://github.com/muicss/mui
|
||||
*
|
||||
* Licensed to the public under the Apache License 2.0
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
// 修复某些插件导致在https下env(safe-area-inset-bottom)为0的情况
|
||||
var url = self.location.href;
|
||||
if ((/(iPhone|iPad|iPod|iOS|Mac|Macintosh)/i.test(navigator.userAgent)) && url.indexOf("openclash") != -1 ) {
|
||||
var oMeta = document.createElement('meta');
|
||||
oMeta.content = 'width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover';
|
||||
oMeta.name = 'viewport';
|
||||
document.getElementsByTagName('head')[0].appendChild(oMeta);
|
||||
}
|
||||
|
||||
// .node-status-realtime embed[src="/luci-static/resources/bandwidth.svg"] + div + br + table
|
||||
// .node-status-realtime embed[src="/luci-static/resources/wifirate.svg"] + div + br + table
|
||||
// .node-status-realtime embed[src="/luci-static/resources/wireless.svg"] + div + br + table
|
||||
$(document).ready(function(){
|
||||
["bandwidth", "wifirate", "wireless"].forEach(function (value) {
|
||||
let target = $(".node-status-realtime embed[src=\"\/luci-static\/resources\/" + value + ".svg\"] + div + br + table");
|
||||
if (target.length != 0) {
|
||||
let div = document.createElement("div");
|
||||
div.style = "overflow-x: auto;"
|
||||
target.before(div);
|
||||
newTarget = target.clone();
|
||||
target.remove();
|
||||
div.append(newTarget.get(0))
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// Fixed scrollbar styles for browsers on different platforms
|
||||
settingGlobalScroll();
|
||||
|
||||
$(document).ready(function() {
|
||||
settingGlobalScroll();
|
||||
})
|
||||
|
||||
$(window).resize(function () {
|
||||
settingGlobalScroll();
|
||||
});
|
||||
|
||||
function settingGlobalScroll() {
|
||||
let global = $('head #global-scroll')
|
||||
if ((/(phone|pad|pod|iPhone|iPod|ios|iOS|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent))) {
|
||||
if (global.length > 0) {
|
||||
global.remove();
|
||||
}
|
||||
} else if (global.length == 0 ) {
|
||||
var style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
style.id = "global-scroll"
|
||||
style.innerHTML="::-webkit-scrollbar { width: 4px; } ::-webkit-scrollbar-thumb { background: var(--scrollbarColor); border-radius: 2px;}"
|
||||
$("head").append(style)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* trim text, Remove spaces, wrap
|
||||
* @param text
|
||||
* @returns {string}
|
||||
*/
|
||||
function trimText(text) {
|
||||
return text.replace(/[ \t\n\r]+/g, " ");
|
||||
}
|
||||
|
||||
|
||||
var lastNode = undefined;
|
||||
var mainNodeName = undefined;
|
||||
|
||||
var nodeUrl = "";
|
||||
(function(node){
|
||||
if (node[0] == "admin"){
|
||||
luciLocation = [node[1], node[2]];
|
||||
}else{
|
||||
luciLocation = node;
|
||||
}
|
||||
|
||||
for(var i in luciLocation){
|
||||
nodeUrl += luciLocation[i];
|
||||
if (i != luciLocation.length - 1){
|
||||
nodeUrl += "/";
|
||||
}
|
||||
}
|
||||
})(luciLocation);
|
||||
|
||||
/**
|
||||
* get the current node by Burl (primary)
|
||||
* @returns {boolean} success?
|
||||
*/
|
||||
function getCurrentNodeByUrl() {
|
||||
var ret = false;
|
||||
if (!$('body').hasClass('logged-in')) {
|
||||
luciLocation = ["Main", "Login"];
|
||||
return true;
|
||||
}
|
||||
|
||||
$(".main > .main-left > .nav > .slide > .menu").each(function () {
|
||||
var ulNode = $(this);
|
||||
ulNode.next().find("a").each(function () {
|
||||
var that = $(this);
|
||||
var href = that.attr("href");
|
||||
|
||||
if (href.indexOf(nodeUrl) != -1) {
|
||||
ulNode.click();
|
||||
ulNode.next(".slide-menu").stop(true, true);
|
||||
lastNode = that.parent();
|
||||
lastNode.addClass("active");
|
||||
ret = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* menu click
|
||||
*/
|
||||
$(".main > .main-left > .nav > .slide > .menu").click(function () {
|
||||
var ul = $(this).next(".slide-menu");
|
||||
var menu = $(this);
|
||||
if (!menu.hasClass("exit")) {
|
||||
$(".main > .main-left > .nav > .slide > .active").next(".slide-menu").stop(true).slideUp("fast");
|
||||
$(".main > .main-left > .nav > .slide > .menu").removeClass("active");
|
||||
if (!ul.is(":visible")) {
|
||||
menu.addClass("active");
|
||||
ul.addClass("active");
|
||||
ul.stop(true).slideDown("fast");
|
||||
} else {
|
||||
ul.stop(true).slideUp("fast", function () {
|
||||
menu.removeClass("active");
|
||||
ul.removeClass("active");
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* hook menu click and add the hash
|
||||
*/
|
||||
$(".main > .main-left > .nav > .slide > .slide-menu > li > a").click(function () {
|
||||
if (lastNode != undefined) lastNode.removeClass("active");
|
||||
$(this).parent().addClass("active");
|
||||
$(".main > .loading").fadeIn("fast");
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
* fix menu click
|
||||
*/
|
||||
$(".main > .main-left > .nav > .slide > .slide-menu > li").click(function () {
|
||||
if (lastNode != undefined) lastNode.removeClass("active");
|
||||
$(this).addClass("active");
|
||||
$(".main > .loading").fadeIn("fast");
|
||||
window.location = $($(this).find("a")[0]).attr("href");
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* get current node and open it
|
||||
*/
|
||||
if (getCurrentNodeByUrl()) {
|
||||
mainNodeName = "node-" + luciLocation[0] + "-" + luciLocation[1];
|
||||
mainNodeName = mainNodeName.replace(/[ \t\n\r\/]+/g, "_").toLowerCase();
|
||||
$("body").addClass(mainNodeName);
|
||||
}
|
||||
$(".cbi-button-up").val("");
|
||||
$(".cbi-button-down").val("");
|
||||
|
||||
|
||||
/**
|
||||
* hook other "A Label" and add hash to it.
|
||||
*/
|
||||
$("#maincontent > .container").find("a").each(function () {
|
||||
var that = $(this);
|
||||
var onclick = that.attr("onclick");
|
||||
if (onclick == undefined || onclick == "") {
|
||||
that.click(function () {
|
||||
var href = that.attr("href");
|
||||
if (href.indexOf("#") == -1) {
|
||||
$(".main > .loading").fadeIn("fast");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Sidebar expand
|
||||
*/
|
||||
var showSide = false;
|
||||
$(".showSide").click(function () {
|
||||
if (showSide) {
|
||||
$(".darkMask").stop(true).fadeOut("fast");
|
||||
$(".main-left").stop(true).animate({
|
||||
width: "0"
|
||||
}, "fast");
|
||||
$(".main-right").css("overflow-y", "auto");
|
||||
showSide = false;
|
||||
} else {
|
||||
$(".darkMask").stop(true).fadeIn("fast");
|
||||
$(".main-left").stop(true).animate({
|
||||
width: "17rem"
|
||||
}, "fast");
|
||||
$(".main-right").css("overflow-y", "hidden");
|
||||
$(".showSide").css("display", "none");
|
||||
$("header").css("box-shadow", "17rem 2px 4px rgb(0 0 0 / 8%)")
|
||||
showSide = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(".darkMask").click(function () {
|
||||
if (showSide) {
|
||||
showSide = false;
|
||||
$(".darkMask").stop(true).fadeOut("fast");
|
||||
$(".main-left").stop(true).animate({
|
||||
width: "0"
|
||||
}, "fast");
|
||||
$(".main-right").css("overflow-y", "auto");
|
||||
$(".showSide").css("display", "");
|
||||
$("header").css("box-shadow", "0 2px 4px rgb(0 0 0 / 8%)")
|
||||
}
|
||||
});
|
||||
|
||||
$(window).resize(function () {
|
||||
if ($(window).width() > 992) {
|
||||
$(".showSide").css("display", "");
|
||||
$(".main-left").css("width", "");
|
||||
$(".darkMask").stop(true);
|
||||
$(".darkMask").css("display", "none");
|
||||
showSide = false;
|
||||
$("header").css("box-shadow", "17rem 2px 4px rgb(0 0 0 / 8%)")
|
||||
} else {
|
||||
$("header").css("box-shadow", "0 2px 4px rgb(0 0 0 / 8%)")
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* fix legend position
|
||||
*/
|
||||
$("legend").each(function () {
|
||||
var that = $(this);
|
||||
that.after("<span class='panel-title'>" + that.text() + "</span>");
|
||||
});
|
||||
|
||||
$(".main-right").focus();
|
||||
$(".main-right").blur();
|
||||
$("input").attr("size", "0");
|
||||
|
||||
if (mainNodeName != undefined) {
|
||||
console.log(mainNodeName);
|
||||
switch (mainNodeName) {
|
||||
case "node-status-system_log":
|
||||
case "node-status-kernel_log":
|
||||
$("#syslog").focus(function () {
|
||||
$("#syslog").blur();
|
||||
$(".main-right").focus();
|
||||
$(".main-right").blur();
|
||||
});
|
||||
break;
|
||||
case "node-status-firewall":
|
||||
var button = $(".node-status-firewall > .main fieldset li > a");
|
||||
button.addClass("cbi-button cbi-button-reset a-to-btn");
|
||||
break;
|
||||
case "node-system-reboot":
|
||||
var button = $(".node-system-reboot > .main > .main-right p > a");
|
||||
button.addClass("cbi-button cbi-input-reset a-to-btn");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
3301
luci-theme-design/dev/style.css
Normal file
3301
luci-theme-design/dev/style.css
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,292 +1,15 @@
|
||||
/**
|
||||
* Material is a clean HTML5 theme for LuCI. It is based on luci-theme-bootstrap and MUI
|
||||
*
|
||||
* luci-theme-material
|
||||
* Copyright 2015 Lutty Yang <lutty@wcan.in>
|
||||
*
|
||||
* Have a bug? Please create an issue here on GitHub!
|
||||
* https://github.com/LuttyYang/luci-theme-material/issues
|
||||
*
|
||||
* luci-theme-bootstrap:
|
||||
* Copyright 2008 Steven Barth <steven@midlink.org>
|
||||
* Copyright 2008 Jo-Philipp Wich <jow@openwrt.org>
|
||||
* Copyright 2012 David Menting <david@nut-bolt.nl>
|
||||
*
|
||||
* MUI:
|
||||
* https://github.com/muicss/mui
|
||||
*
|
||||
* Licensed to the public under the Apache License 2.0
|
||||
*/
|
||||
(function ($) {
|
||||
|
||||
// 修复某些插件导致在https下env(safe-area-inset-bottom)为0的情况
|
||||
var url = self.location.href;
|
||||
if ((/(iPhone|iPad|iPod|iOS|Mac|Macintosh)/i.test(navigator.userAgent)) && url.indexOf("openclash") != -1 ) {
|
||||
var oMeta = document.createElement('meta');
|
||||
oMeta.content = 'width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover';
|
||||
oMeta.name = 'viewport';
|
||||
document.getElementsByTagName('head')[0].appendChild(oMeta);
|
||||
}
|
||||
|
||||
// .node-status-realtime embed[src="/luci-static/resources/bandwidth.svg"] + div + br + table
|
||||
// .node-status-realtime embed[src="/luci-static/resources/wifirate.svg"] + div + br + table
|
||||
// .node-status-realtime embed[src="/luci-static/resources/wireless.svg"] + div + br + table
|
||||
$(document).ready(function(){
|
||||
["bandwidth", "wifirate", "wireless"].forEach(function (value) {
|
||||
let target = $(".node-status-realtime embed[src=\"\/luci-static\/resources\/" + value + ".svg\"] + div + br + table");
|
||||
if (target.length != 0) {
|
||||
let div = document.createElement("div");
|
||||
div.style = "overflow-x: auto;"
|
||||
target.before(div);
|
||||
newTarget = target.clone();
|
||||
target.remove();
|
||||
div.append(newTarget.get(0))
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
// Fixed scrollbar styles for browsers on different platforms
|
||||
settingGlobalScroll();
|
||||
|
||||
$(document).ready(function() {
|
||||
settingGlobalScroll();
|
||||
})
|
||||
|
||||
$(window).resize(function () {
|
||||
settingGlobalScroll();
|
||||
});
|
||||
|
||||
function settingGlobalScroll() {
|
||||
let global = $('head #global-scroll')
|
||||
if ((/(phone|pad|pod|iPhone|iPod|ios|iOS|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent))) {
|
||||
if (global.length > 0) {
|
||||
global.remove();
|
||||
}
|
||||
} else if (global.length == 0 ) {
|
||||
var style = document.createElement('style');
|
||||
style.type = 'text/css';
|
||||
style.id = "global-scroll"
|
||||
style.innerHTML="::-webkit-scrollbar { width: 4px; } ::-webkit-scrollbar-thumb { background: var(--scrollbarColor); border-radius: 2px;}"
|
||||
$("head").append(style)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* trim text, Remove spaces, wrap
|
||||
* @param text
|
||||
* @returns {string}
|
||||
*/
|
||||
function trimText(text) {
|
||||
return text.replace(/[ \t\n\r]+/g, " ");
|
||||
}
|
||||
|
||||
|
||||
var lastNode = undefined;
|
||||
var mainNodeName = undefined;
|
||||
|
||||
var nodeUrl = "";
|
||||
(function(node){
|
||||
if (node[0] == "admin"){
|
||||
luciLocation = [node[1], node[2]];
|
||||
}else{
|
||||
luciLocation = node;
|
||||
}
|
||||
|
||||
for(var i in luciLocation){
|
||||
nodeUrl += luciLocation[i];
|
||||
if (i != luciLocation.length - 1){
|
||||
nodeUrl += "/";
|
||||
}
|
||||
}
|
||||
})(luciLocation);
|
||||
|
||||
/**
|
||||
* get the current node by Burl (primary)
|
||||
* @returns {boolean} success?
|
||||
*/
|
||||
function getCurrentNodeByUrl() {
|
||||
var ret = false;
|
||||
if (!$('body').hasClass('logged-in')) {
|
||||
luciLocation = ["Main", "Login"];
|
||||
return true;
|
||||
}
|
||||
|
||||
$(".main > .main-left > .nav > .slide > .menu").each(function () {
|
||||
var ulNode = $(this);
|
||||
ulNode.next().find("a").each(function () {
|
||||
var that = $(this);
|
||||
var href = that.attr("href");
|
||||
|
||||
if (href.indexOf(nodeUrl) != -1) {
|
||||
ulNode.click();
|
||||
ulNode.next(".slide-menu").stop(true, true);
|
||||
lastNode = that.parent();
|
||||
lastNode.addClass("active");
|
||||
ret = true;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
});
|
||||
return ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* menu click
|
||||
*/
|
||||
$(".main > .main-left > .nav > .slide > .menu").click(function () {
|
||||
var ul = $(this).next(".slide-menu");
|
||||
var menu = $(this);
|
||||
if (!menu.hasClass("exit")) {
|
||||
$(".main > .main-left > .nav > .slide > .active").next(".slide-menu").stop(true).slideUp("fast");
|
||||
$(".main > .main-left > .nav > .slide > .menu").removeClass("active");
|
||||
if (!ul.is(":visible")) {
|
||||
menu.addClass("active");
|
||||
ul.addClass("active");
|
||||
ul.stop(true).slideDown("fast");
|
||||
} else {
|
||||
ul.stop(true).slideUp("fast", function () {
|
||||
menu.removeClass("active");
|
||||
ul.removeClass("active");
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* hook menu click and add the hash
|
||||
*/
|
||||
$(".main > .main-left > .nav > .slide > .slide-menu > li > a").click(function () {
|
||||
if (lastNode != undefined) lastNode.removeClass("active");
|
||||
$(this).parent().addClass("active");
|
||||
$(".main > .loading").fadeIn("fast");
|
||||
return true;
|
||||
});
|
||||
|
||||
/**
|
||||
* fix menu click
|
||||
*/
|
||||
$(".main > .main-left > .nav > .slide > .slide-menu > li").click(function () {
|
||||
if (lastNode != undefined) lastNode.removeClass("active");
|
||||
$(this).addClass("active");
|
||||
$(".main > .loading").fadeIn("fast");
|
||||
window.location = $($(this).find("a")[0]).attr("href");
|
||||
return false;
|
||||
});
|
||||
|
||||
/**
|
||||
* get current node and open it
|
||||
*/
|
||||
if (getCurrentNodeByUrl()) {
|
||||
mainNodeName = "node-" + luciLocation[0] + "-" + luciLocation[1];
|
||||
mainNodeName = mainNodeName.replace(/[ \t\n\r\/]+/g, "_").toLowerCase();
|
||||
$("body").addClass(mainNodeName);
|
||||
}
|
||||
$(".cbi-button-up").val("");
|
||||
$(".cbi-button-down").val("");
|
||||
|
||||
|
||||
/**
|
||||
* hook other "A Label" and add hash to it.
|
||||
*/
|
||||
$("#maincontent > .container").find("a").each(function () {
|
||||
var that = $(this);
|
||||
var onclick = that.attr("onclick");
|
||||
if (onclick == undefined || onclick == "") {
|
||||
that.click(function () {
|
||||
var href = that.attr("href");
|
||||
if (href.indexOf("#") == -1) {
|
||||
$(".main > .loading").fadeIn("fast");
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Sidebar expand
|
||||
*/
|
||||
var showSide = false;
|
||||
$(".showSide").click(function () {
|
||||
if (showSide) {
|
||||
$(".darkMask").stop(true).fadeOut("fast");
|
||||
$(".main-left").stop(true).animate({
|
||||
width: "0"
|
||||
}, "fast");
|
||||
$(".main-right").css("overflow-y", "auto");
|
||||
showSide = false;
|
||||
} else {
|
||||
$(".darkMask").stop(true).fadeIn("fast");
|
||||
$(".main-left").stop(true).animate({
|
||||
width: "17rem"
|
||||
}, "fast");
|
||||
$(".main-right").css("overflow-y", "hidden");
|
||||
$(".showSide").css("display", "none");
|
||||
$("header").css("box-shadow", "17rem 2px 4px rgb(0 0 0 / 8%)")
|
||||
showSide = true;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(".darkMask").click(function () {
|
||||
if (showSide) {
|
||||
showSide = false;
|
||||
$(".darkMask").stop(true).fadeOut("fast");
|
||||
$(".main-left").stop(true).animate({
|
||||
width: "0"
|
||||
}, "fast");
|
||||
$(".main-right").css("overflow-y", "auto");
|
||||
$(".showSide").css("display", "");
|
||||
$("header").css("box-shadow", "0 2px 4px rgb(0 0 0 / 8%)")
|
||||
}
|
||||
});
|
||||
|
||||
$(window).resize(function () {
|
||||
if ($(window).width() > 992) {
|
||||
$(".showSide").css("display", "");
|
||||
$(".main-left").css("width", "");
|
||||
$(".darkMask").stop(true);
|
||||
$(".darkMask").css("display", "none");
|
||||
showSide = false;
|
||||
$("header").css("box-shadow", "17rem 2px 4px rgb(0 0 0 / 8%)")
|
||||
} else {
|
||||
$("header").css("box-shadow", "0 2px 4px rgb(0 0 0 / 8%)")
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* fix legend position
|
||||
*/
|
||||
$("legend").each(function () {
|
||||
var that = $(this);
|
||||
that.after("<span class='panel-title'>" + that.text() + "</span>");
|
||||
});
|
||||
|
||||
$(".main-right").focus();
|
||||
$(".main-right").blur();
|
||||
$("input").attr("size", "0");
|
||||
|
||||
if (mainNodeName != undefined) {
|
||||
console.log(mainNodeName);
|
||||
switch (mainNodeName) {
|
||||
case "node-status-system_log":
|
||||
case "node-status-kernel_log":
|
||||
$("#syslog").focus(function () {
|
||||
$("#syslog").blur();
|
||||
$(".main-right").focus();
|
||||
$(".main-right").blur();
|
||||
});
|
||||
break;
|
||||
case "node-status-firewall":
|
||||
var button = $(".node-status-firewall > .main fieldset li > a");
|
||||
button.addClass("cbi-button cbi-button-reset a-to-btn");
|
||||
break;
|
||||
case "node-system-reboot":
|
||||
var button = $(".node-system-reboot > .main > .main-right p > a");
|
||||
button.addClass("cbi-button cbi-input-reset a-to-btn");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
})(jQuery);
|
||||
(function($){var url=self.location.href;if((/(iPhone|iPad|iPod|iOS|Mac|Macintosh)/i.test(navigator.userAgent))&&url.indexOf("openclash")!=-1){var oMeta=document.createElement('meta');oMeta.content='width=device-width,initial-scale=1,maximum-scale=1,user-scalable=0,viewport-fit=cover';oMeta.name='viewport';document.getElementsByTagName('head')[0].appendChild(oMeta);}
|
||||
$(document).ready(function(){["bandwidth","wifirate","wireless"].forEach(function(value){let target=$(".node-status-realtime embed[src=\"\/luci-static\/resources\/"+value+".svg\"] + div + br + table");if(target.length!=0){let div=document.createElement("div");div.style="overflow-x: auto;"
|
||||
target.before(div);newTarget=target.clone();target.remove();div.append(newTarget.get(0))}})});settingGlobalScroll();$(document).ready(function(){settingGlobalScroll();})
|
||||
$(window).resize(function(){settingGlobalScroll();});function settingGlobalScroll(){let global=$('head #global-scroll')
|
||||
if((/(phone|pad|pod|iPhone|iPod|ios|iOS|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i.test(navigator.userAgent))){if(global.length>0){global.remove();}}else if(global.length==0){var style=document.createElement('style');style.type='text/css';style.id="global-scroll"
|
||||
style.innerHTML="::-webkit-scrollbar { width: 4px; } ::-webkit-scrollbar-thumb { background: var(--scrollbarColor); border-radius: 2px;}"
|
||||
$("head").append(style)}}
|
||||
function trimText(text){return text.replace(/[ \t\n\r]+/g," ");}
|
||||
var lastNode=undefined;var mainNodeName=undefined;var nodeUrl="";(function(node){if(node[0]=="admin"){luciLocation=[node[1],node[2]];}else{luciLocation=node;}
|
||||
for(var i in luciLocation){nodeUrl+=luciLocation[i];if(i!=luciLocation.length-1){nodeUrl+="/";}}})(luciLocation);function getCurrentNodeByUrl(){var ret=false;if(!$('body').hasClass('logged-in')){luciLocation=["Main","Login"];return true;}
|
||||
$(".main > .main-left > .nav > .slide > .menu").each(function(){var ulNode=$(this);ulNode.next().find("a").each(function(){var that=$(this);var href=that.attr("href");if(href.indexOf(nodeUrl)!=-1){ulNode.click();ulNode.next(".slide-menu").stop(true,true);lastNode=that.parent();lastNode.addClass("active");ret=true;return true;}});});return ret;}
|
||||
$(".main > .main-left > .nav > .slide > .menu").click(function(){var ul=$(this).next(".slide-menu");var menu=$(this);if(!menu.hasClass("exit")){$(".main > .main-left > .nav > .slide > .active").next(".slide-menu").stop(true).slideUp("fast");$(".main > .main-left > .nav > .slide > .menu").removeClass("active");if(!ul.is(":visible")){menu.addClass("active");ul.addClass("active");ul.stop(true).slideDown("fast");}else{ul.stop(true).slideUp("fast",function(){menu.removeClass("active");ul.removeClass("active");});}
|
||||
return false;}});$(".main > .main-left > .nav > .slide > .slide-menu > li > a").click(function(){if(lastNode!=undefined)lastNode.removeClass("active");$(this).parent().addClass("active");$(".main > .loading").fadeIn("fast");return true;});$(".main > .main-left > .nav > .slide > .slide-menu > li").click(function(){if(lastNode!=undefined)lastNode.removeClass("active");$(this).addClass("active");$(".main > .loading").fadeIn("fast");window.location=$($(this).find("a")[0]).attr("href");return false;});if(getCurrentNodeByUrl()){mainNodeName="node-"+luciLocation[0]+"-"+luciLocation[1];mainNodeName=mainNodeName.replace(/[ \t\n\r\/]+/g,"_").toLowerCase();$("body").addClass(mainNodeName);}
|
||||
$(".cbi-button-up").val("");$(".cbi-button-down").val("");$("#maincontent > .container").find("a").each(function(){var that=$(this);var onclick=that.attr("onclick");if(onclick==undefined||onclick==""){that.click(function(){var href=that.attr("href");if(href.indexOf("#")==-1){$(".main > .loading").fadeIn("fast");return true;}});}});var showSide=false;$(".showSide").click(function(){if(showSide){$(".darkMask").stop(true).fadeOut("fast");$(".main-left").stop(true).animate({width:"0"},"fast");$(".main-right").css("overflow-y","auto");showSide=false;}else{$(".darkMask").stop(true).fadeIn("fast");$(".main-left").stop(true).animate({width:"17rem"},"fast");$(".main-right").css("overflow-y","hidden");$(".showSide").css("display","none");$("header").css("box-shadow","17rem 2px 4px rgb(0 0 0 / 8%)")
|
||||
showSide=true;}});$(".darkMask").click(function(){if(showSide){showSide=false;$(".darkMask").stop(true).fadeOut("fast");$(".main-left").stop(true).animate({width:"0"},"fast");$(".main-right").css("overflow-y","auto");$(".showSide").css("display","");$("header").css("box-shadow","0 2px 4px rgb(0 0 0 / 8%)")}});$(window).resize(function(){if($(window).width()>992){$(".showSide").css("display","");$(".main-left").css("width","");$(".darkMask").stop(true);$(".darkMask").css("display","none");showSide=false;$("header").css("box-shadow","17rem 2px 4px rgb(0 0 0 / 8%)")}else{$("header").css("box-shadow","0 2px 4px rgb(0 0 0 / 8%)")}});$("legend").each(function(){var that=$(this);that.after("<span class='panel-title'>"+that.text()+"</span>");});$(".main-right").focus();$(".main-right").blur();$("input").attr("size","0");if(mainNodeName!=undefined){console.log(mainNodeName);switch(mainNodeName){case "node-status-system_log":case "node-status-kernel_log":$("#syslog").focus(function(){$("#syslog").blur();$(".main-right").focus();$(".main-right").blur();});break;case "node-status-firewall":var button=$(".node-status-firewall > .main fieldset li > a");button.addClass("cbi-button cbi-button-reset a-to-btn");break;case "node-system-reboot":var button=$(".node-system-reboot > .main > .main-right p > a");button.addClass("cbi-button cbi-input-reset a-to-btn");break;}}})(jQuery);
|
||||
|
Loading…
Reference in New Issue
Block a user