mirror of
https://github.com/unraid/webgui.git
synced 2026-01-02 23:50:21 -06:00
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:
@@ -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("'+page+'");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>
|
||||
|
||||
@@ -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("'+page+'");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>
|
||||
|
||||
Reference in New Issue
Block a user