mirror of
https://github.com/ntop/ntopng.git
synced 2026-04-29 07:29:32 +00:00
Localize preferences and implement preference search box (#1119)
This commit is contained in:
parent
886df5e319
commit
e5e4949901
5 changed files with 688 additions and 209 deletions
|
|
@ -243,8 +243,8 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
function shortenString(name)
|
||||
max_len = 24
|
||||
function shortenString(name, max_len)
|
||||
max_len = max_len or 24
|
||||
if(string.len(name) < max_len) then
|
||||
return(name)
|
||||
else
|
||||
|
|
@ -254,6 +254,31 @@ end
|
|||
|
||||
-- ##############################################
|
||||
|
||||
--
|
||||
-- Returns indexes to be used for string shortening. The portion of to_shorten between
|
||||
-- middle_start and middle_end will be inside the bounds.
|
||||
--
|
||||
-- to_shorten: string to be shorten
|
||||
-- middle_start: middle part begin index
|
||||
-- middle_end: middle part begin index
|
||||
-- maxlen: maximum length
|
||||
--
|
||||
function shortenInTheMiddle(to_shorten, middle_start, middle_end, maxlen)
|
||||
local maxlen = maxlen - (middle_end - middle_start)
|
||||
|
||||
if maxlen <= 0 then
|
||||
return 0, string.len(to_shorten)
|
||||
end
|
||||
|
||||
local left_slice = math.max(middle_start - math.floor(maxlen / 2), 1)
|
||||
maxlen = maxlen - (middle_start - left_slice - 1)
|
||||
local right_slice = math.min(middle_end + maxlen, string.len(to_shorten))
|
||||
|
||||
return left_slice, right_slice
|
||||
end
|
||||
|
||||
-- ##############################################
|
||||
|
||||
function shortHostName(name)
|
||||
local chunks = {name:match("(%d+)%.(%d+)%.(%d+)%.(%d+)")}
|
||||
if(#chunks == 4) then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue