refactor: streamline favorites functionality in MyFavorites.page

- Moved the favorites deletion script from Favorites.page to MyFavorites.page for better organization.
- Updated the no favorites message to use a header element for improved semantics.
- Removed unnecessary script from Favorites.page to clean up the code.

[COMPLETE] Should I continue to the next item?
This commit is contained in:
Zack Spear
2025-05-27 16:20:43 -07:00
parent 9e7c27bc6a
commit 8e2d4e434d
2 changed files with 35 additions and 15 deletions

View File

@@ -1,19 +1,6 @@
Menu="Tasks:2"
Type="xmenu"
Tabs="false"
Code="f08a"
Cond="@filesize('/boot/config/favorites.cfg')"
---
<script>
function delPage(page) {
$.post('/webGui/include/MyFavorites.php',{action:'del',page:page},function(){refresh();});
}
$(function(){
$('div.Panel').each(function(){
var page = $(this).find('a').prop('href').split('/').pop();
$(this).find('span').append('<i class="fa fa-trash-o 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();});
});
$.post('/webGui/include/MyFavorites.php',{action:'clear'},function(){if ($('div.Panel').length==0) $('#nofavs').show();});
});
</script>

View File

@@ -3,4 +3,37 @@ Type="menu"
Title="My Favorites"
Tag="heart"
---
<div id="nofavs" style="display:none;width:100%"><center>_(No favorites available)_</center></div>
<script>
function delPage(page) {
$.post('/webGui/include/MyFavorites.php',{
action: 'del',
page: page,
}, function() {
refresh();
});
}
$(function(){
$('div.Panel').each(function(){
const page = $(this).find('a')
.prop('href')
.split('/')
.pop();
$(this).find('span')
.append('<i class="fa fa-trash-o 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 ($('div.Panel').length === 0) {
$('#nofavs').show();
}
});
</script>
<h3 id="nofavs" class="text-center" style="display: none">
_(No favorites available)_
</h3>