2022-03-25 11:25:27 +08:00
|
|
|
/**
|
|
|
|
* 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 ($) {
|
2023-02-28 22:22:45 +08:00
|
|
|
|
|
|
|
// 修复某些插件导致在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)
|
|
|
|
}
|
|
|
|
}
|
2022-03-25 11:25:27 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|
2023-02-28 22:22:45 +08:00
|
|
|
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;
|
2022-03-25 11:25:27 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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({
|
2023-02-28 22:22:45 +08:00
|
|
|
width: "17rem"
|
2022-03-25 11:25:27 +08:00
|
|
|
}, "fast");
|
|
|
|
$(".main-right").css("overflow-y", "hidden");
|
2023-02-28 22:22:45 +08:00
|
|
|
$(".showSide").css("display", "none");
|
|
|
|
$("header").css("box-shadow", "17rem 2px 4px rgb(0 0 0 / 8%)")
|
2022-03-25 11:25:27 +08:00
|
|
|
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");
|
2023-02-28 22:22:45 +08:00
|
|
|
$(".showSide").css("display", "");
|
|
|
|
$("header").css("box-shadow", "0 2px 4px rgb(0 0 0 / 8%)")
|
2022-03-25 11:25:27 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
$(window).resize(function () {
|
2023-02-28 22:22:45 +08:00
|
|
|
if ($(window).width() > 992) {
|
|
|
|
$(".showSide").css("display", "");
|
2022-03-25 11:25:27 +08:00
|
|
|
$(".main-left").css("width", "");
|
|
|
|
$(".darkMask").stop(true);
|
|
|
|
$(".darkMask").css("display", "none");
|
|
|
|
showSide = false;
|
2023-02-28 22:22:45 +08:00
|
|
|
$("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%)")
|
2022-03-25 11:25:27 +08:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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);
|