Make use of unique element IDs for img consistent

This commit is contained in:
df 2021-03-04 15:08:15 +00:00 committed by HummyPkg
parent 029b115628
commit 346ed469c8
2 changed files with 21 additions and 23 deletions

View File

@ -1,7 +1,7 @@
Package: webif
Priority: optional
Section: web
Version: 1.4.9-2
Version: 1.4.9-3
Architecture: mipsel
Maintainer: af123@hpkg.tv
Depends: tcpfix,webif-channelicons(>=1.1.27),lighttpd(>=1.4.39-1),jim(>=0.79),jim-pack(>=0.79),jim-oo(>=0.77),jim-sqlite3(>=0.77),jim-cgi(>=0.7-2),jim-binary(>=0.76),service-control(>=2.3),busybox(>=1.20.2-1),lsof(>=4.87),epg(>=1.2.8),hmt(>=2.0.10),ssmtp,cron-daemon(>=1.18.3-3),at(>=3.1.18),anacron,trm(>=1.1),openssl-command,nicesplice,id3v2,file,rsvsync(>=1.1.13),webif-charts(>=1.2-1),stripts(>=1.4.2),tmenu(>=1.21-2),ffmpeg(>=2.8),id3v2,multienv(>=1.6),tcpping(>=1.1),e2fsprogs,wireless-tools(>=29-1),dbupdate,recmon(>=2.0.7),hwctl,nugget(>=0.98),sqlite3(>=3.15.1),jim-xconv,zip(>=3.0-1),wget

View File

@ -10,6 +10,18 @@ var plugins = {
dmenu_prepare: {}
};
// pattern matches directory path prefix
var pathre = /.*\/|\.[^.]*$/g;
// IDs of size, img elements for folders use RFC4648 s5 encoding of name
function folderID(folder)
{
return btoa(escape(folder))
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
}
function blockpage(msg)
{
if (!msg)
@ -115,21 +127,11 @@ function epginfo_callback(data, status, xhr)
function insert_folder_size(folder, size)
{
// folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
// ID of size element is ID + RFC4648 s5 encoding of folder name
folder = "ID" +
btoa(escape(folder))
.replace(/\+/g, '-')
.replace(/\//g, '_')
.replace(/=/g, '');
size += (size.search(/\d$/) == -1 ? 'iB' : ' bytes');
folder = folderID(folder);
//console.log("Folder: (%s) = (%s)", folder, size);
if (size.search(/\d$/) == -1)
size += 'iB';
else
size += ' bytes';
if (folder == "")
$('#dirsize').text(' (' + size + ')');
else
$('#' + folder).text(' (' + size + ')');
$(folder == "" ? '#dirsize' : '#ID' + folder)
.text(' (' + size + ')');
}
function folder_size_callback(data, status, xhr)
@ -141,11 +143,9 @@ function folder_size_callback(data, status, xhr)
function set_folder_new(folder, cnt)
{
folder = folder.replace(/ /g, '');
folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
//console.log("Folder: (%s) = (%s)", folder, cnt);
left = cnt > 99 ? 11 : (cnt > 9 ? 14 : 17);
$('#img' + folder)
$('#img' + folderID(folder))
.attr('src', '/img/Folder_New.png')
.next('span.foldernum')
.css('left', left + 'px')
@ -164,10 +164,8 @@ function new_folder_callback(data, status, xhr)
function set_folder__(folder)
{
folder = folder.replace(/ /g, '');
folder = folder.replace(/([ #;&,.+*~\':"!^$[\]()=>|\/@])/g, '\\$1');
//console.log("Folder: (%s)", folder);
$('#img' + folder + ' ~ span.folderu').show();
$('#img' + folderID(folder) + ' ~ span.folderu').show();
}
function __folder_callback(data, status, xhr)
@ -264,7 +262,7 @@ var $confirm; // Populated after DOM is loaded.
function confirm_action(action, callback, file, type, id)
{
var bfile = file.replace(/.*\/|\.[^.]*$/g, '');
var bfile = file.replace(pathre, '');
$confirm.dialog('option', 'buttons', {
'Yes': function() { $(this).dialog('close');
callback(file, type, id); },
@ -437,7 +435,7 @@ var menuclick = function(action, el, pos)
{
var file = $(el).parent().prevAll('a.bf').last().attr('file');
var efile = encodeURIComponent(file);
var bfile = file.replace(/.*\/|\.[^.]*$/g, '');
var bfile = file.replace(pathre, '');
bfile = bfile.replace(/[\x00-\x1f]+/g, '');
var type = $(el).attr('type');
var id = $(el).attr('did');