Merge pull request #1571 from bergware/master

Favorites: fixes and enhancements
This commit is contained in:
tom mortensen
2024-01-03 21:36:50 -08:00
committed by GitHub
7 changed files with 32 additions and 22 deletions
+7 -7
View File
@@ -1,6 +1,7 @@
Menu="Tasks:2"
Type="xmenu"
Code="e970"
Code="f08a"
Cond="@filesize('/boot/config/favorites.cfg')"
---
<script>
function delPage(page) {
@@ -8,12 +9,11 @@ function delPage(page) {
}
$(function(){
$('i.PanelIcon').each(function(){
var icon = $(this);
var page = icon.closest('a').prop('href').split('/').pop();
icon.after('<i class="fa fa-heartbeat favo" title="_(Remove from favorites)_" onclick="delPage(&quot;'+page+'&quot;);return false"></i>');
icon.parent().parent().parent().hover(function(){icon.next().show();},function(){icon.next().hide();});
$('div.Panel').each(function(){
var page = $(this).find('a').prop('href').split('/').pop();
$(this).find('span').append('<i class="fa fa-heartbeat favo" title="_(Remove from favorites)_" onclick="delPage(&quot;'+page+'&quot;);return false"></i>');
$(this).hover(function(){$(this).find('i.favo').show();},function(){$(this).find('i.favo').hide();});
});
if ($('i.PanelIcon').length==0) $('#nofavs').show();
$.post('/webGui/include/MyFavorites.php',{action:'clear'},function(){if ($('div.Panel').length==0) $('#nofavs').show();});
});
</script>
+1 -1
View File
@@ -1,6 +1,6 @@
Menu="Favorites"
Type="menu"
Title="My Favorites"
Tag="icon-u-star"
Tag="heart"
---
<div id="nofavs" style="display:none;width:100%"><center>_(No favorites available)_</center></div>
+5 -6
View File
@@ -6,16 +6,15 @@ Code="e924"
<script>
function addPage(page) {
$.post('/webGui/include/MyFavorites.php',{action:'add',page:page},function(){
swal({title:"_(Added to Favorites)_",text:"",type:"success",html:true,confirmButtonText:"_(Ok)_"});
swal({title:"_(Added to Favorites)_",text:"",type:"success",html:true,confirmButtonText:"_(Ok)_"},function(x){refresh();});
});
}
$(function(){
$('i.PanelIcon').each(function(){
var icon = $(this);
var page = icon.closest('a').prop('href').split('/').pop();
icon.after('<i class="fa fa-heart favo" title="_(Add to favorites)_" onclick="addPage(&quot;'+page+'&quot;);return false"></i>');
icon.parent().parent().parent().hover(function(){icon.next().show();},function(){icon.next().hide();});
$('div.Panel').each(function(){
var page = $(this).find('a').prop('href').split('/').pop();
$(this).find('span').append('<i class="fa fa-heart favo" title="_(Add to favorites)_" onclick="addPage(&quot;'+page+'&quot;);return false"></i>');
$(this).hover(function(){$(this).find('i.favo').show();},function(){$(this).find('i.favo').hide();});
});
});
</script>
+5 -6
View File
@@ -6,16 +6,15 @@ Code="e909"
<script>
function addPage(page) {
$.post('/webGui/include/MyFavorites.php',{action:'add',page:page},function(){
swal({title:"_(Added to Favorites)_",text:"",type:"success",html:true,confirmButtonText:"_(Ok)_"});
swal({title:"_(Added to Favorites)_",text:"",type:"success",html:true,confirmButtonText:"_(Ok)_"},function(x){refresh();});
});
}
$(function(){
$('i.PanelIcon').each(function(){
var icon = $(this);
var page = icon.closest('a').prop('href').split('/').pop();
icon.after('<i class="fa fa-heart favo" title="_(Add to favorites)_" onclick="addPage(&quot;'+page+'&quot;);return false"></i>');
icon.parent().parent().parent().hover(function(){icon.next().show();},function(){icon.next().hide();});
$('div.Panel').each(function(){
var page = $(this).find('a').prop('href').split('/').pop();
$(this).find('span').append('<i class="fa fa-heart favo" title="_(Add to favorites)_" onclick="addPage(&quot;'+page+'&quot;);return false"></i>');
$(this).hover(function(){$(this).find('i.favo').show();},function(){$(this).find('i.favo').hide();});
});
});
</script>
+12 -1
View File
@@ -14,10 +14,21 @@
$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
$permit = ['del','add'];
$action = $_POST['action']??'';
$page = glob("$docroot/plugins/*/{$_POST['page']}.page",GLOB_NOSORT)[0];
$cfg = '/boot/config/favorites.cfg';
// remove non-existing pages
if ($action=='clear') {
if (file_exists($cfg)) foreach (file($cfg,FILE_IGNORE_NEW_LINES) as $page) {
if (!file_exists($page)) {
$page = str_replace('/','\/',$page);
exec("sed -i '/$page/d' $cfg 2>/dev/null");
}
}
exit;
}
// validate input
$page = glob("$docroot/plugins/*/{$_POST['page']}.page",GLOB_NOSORT)[0];
if (!$page || !in_array($action,$permit)) exit;
$file = fopen($page,'r');
+1 -1
View File
@@ -54,7 +54,7 @@ i[class^="icon-u-"]{font-size:inherit}
i#mycase[class^="case-"]{font-size:128px}
i#mycase[class^="fa "]{font-size:96px}
a.cpu_close,span.hand{cursor:pointer;z-index:1001}
a.info{white-space:normal;word-spacing:92px;word-break:break-all}
a.info{white-space:normal;word-spacing:100px;word-break:break-word}
a.info span{word-spacing:normal}
tr#var0,tr#var1,tr#var2,tr#var3,tr#var4{cursor:alias}
tr#var1,tr#var4,tr#cpu_chart,.cpu_open{display:none}