From c1fac487c717899827b82473aff806a8b7c75e98 Mon Sep 17 00:00:00 2001 From: Ivan K Date: Tue, 18 Feb 2025 21:05:02 +0300 Subject: [PATCH] style: add tooltip functionality and adjust CSS for better UI --- .../resources/view/podkop/podkop.js | 77 ++++++++++++++++++- 1 file changed, 74 insertions(+), 3 deletions(-) diff --git a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js index 3c420e6..242cbd8 100644 --- a/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js +++ b/luci-app-podkop/htdocs/luci-static/resources/view/podkop/podkop.js @@ -19,8 +19,78 @@ return view.extend({ + `); + // Add tooltip functionality + setTimeout(() => { + document.querySelectorAll('.cbi-value-field').forEach(field => { + const description = field.querySelector('.cbi-value-description'); + if (description) { + const text = description.textContent; + let tooltip = null; + + // Find all input elements within the field + const inputElements = field.querySelectorAll('input, select, textarea'); + inputElements.forEach(inputElement => { + inputElement.addEventListener('mouseenter', (e) => { + tooltip = document.createElement('div'); + tooltip.className = 'tooltip'; + tooltip.textContent = text; + document.body.appendChild(tooltip); + + const updatePosition = (e) => { + const rect = inputElement.getBoundingClientRect(); + const scrollX = window.pageXOffset || document.documentElement.scrollLeft; + const scrollY = window.pageYOffset || document.documentElement.scrollTop; + tooltip.style.left = (e.pageX + 15) + 'px'; + tooltip.style.top = (e.pageY + 10) + 'px'; + }; + + updatePosition(e); + inputElement.addEventListener('mousemove', updatePosition); + }); + + inputElement.addEventListener('mouseleave', () => { + if (tooltip) { + tooltip.remove(); + tooltip = null; + } + }); + }); + } + }); + }, 1000); + var m, s, o; m = new form.Map('podkop', _('Podkop configuration'), null, ['main', 'second']); @@ -50,7 +120,7 @@ return view.extend({ o = s.taboption('basic', form.TextValue, 'proxy_string', _('Proxy Configuration URL'), _('Enter connection string starting with vless:// or ss:// for proxy configuration')); o.depends('proxy_config_type', 'url'); - o.rows = 5; + o.rows = 7; o.ucisection = 'main'; o.validate = function (section_id, value) { if (!value || value.length === 0) { @@ -193,7 +263,7 @@ return view.extend({ o = s.taboption('basic', form.TextValue, 'outbound_json', _('Outbound Configuration'), _('Enter complete outbound configuration in JSON format')); o.depends('proxy_config_type', 'outbound'); - o.rows = 10; + o.rows = 7; o.ucisection = 'main'; o.validate = function (section_id, value) { if (!value || value.length === 0) { @@ -358,7 +428,7 @@ return view.extend({ o = s.taboption('basic', form.TextValue, 'custom_domains_text', _('User Domains List'), _('Enter domain names separated by comma, space or newline (example: sub.example.com, example.com or one domain per line)')); o.placeholder = 'example.com, sub.example.com\ndomain.com test.com\nsubdomain.domain.com another.com, third.com'; o.depends('custom_domains_list_type', 'text'); - o.rows = 10; + o.rows = 8; o.rmempty = false; o.ucisection = 'main'; o.validate = function (section_id, value) { @@ -649,6 +719,7 @@ return view.extend({ // Service Status Section let createStatusSection = function (podkopStatus, singboxStatus, podkop, luci, singbox, system) { return E('div', { 'class': 'cbi-section' }, [ + E('h3', {}, _('Service Status')), E('div', { 'class': 'table', style: 'display: flex; gap: 20px;' }, [ // Podkop Column E('div', { 'style': 'flex: 1; padding: 15px; background: #f8f9fa; border-radius: 8px;' }, [