small-package/luci-theme-design/dev/design.js

43 lines
1.9 KiB
JavaScript
Raw Normal View History

2023-03-19 16:21:12 +08:00
(function ($) {
2023-03-20 23:39:24 +08:00
const global = $('head #global-scroll');
const isMobile = /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);
2023-03-20 16:24:43 +08:00
function settingGlobalScroll() {
2023-03-20 23:39:24 +08:00
if (!isMobile && global.length === 0) {
const style = document.createElement('style');
style.id = 'global-scroll';
style.textContent = `::-webkit-scrollbar { width: 4px; } ::-webkit-scrollbar-thumb { background: var(--scrollbarColor); border-radius: 2px; }`;
$('head').append(style);
} else if (isMobile && global.length > 0) {
global.remove();
}
2023-03-20 16:24:43 +08:00
}
2023-03-20 23:39:24 +08:00
const nodeStatusRealtime = $('.node-status-realtime');
2023-03-20 16:24:43 +08:00
$(document).ready(() => {
// Fixed scrollbar styles for browsers on different platforms
settingGlobalScroll();
2023-03-20 23:39:24 +08:00
2023-03-20 16:24:43 +08:00
// .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
2023-03-20 23:39:24 +08:00
const selectorValues = ['bandwidth', 'wifirate', 'wireless'];
selectorValues.forEach(value => {
const target = nodeStatusRealtime.find(`embed[src="/luci-static/resources/${value}.svg"] + div + br + table`);
if (target.length) {
const div = document.createElement('div');
div.style.overflowX = 'auto';
target.before(div);
const newTarget = target.clone();
target.remove();
div.appendChild(newTarget[0]);
}
});
});
// Fixed scrollbar styles for browsers on different platforms
$(window).resize(() => {
2023-03-20 16:24:43 +08:00
settingGlobalScroll();
2023-03-20 23:39:24 +08:00
});
})(jQuery);