mirror of
https://github.com/hkalexling/Mango.git
synced 2025-08-03 11:25:29 -04:00
Save the sorting option in local storage (#76)
This commit is contained in:
parent
c00016fa19
commit
38ba324fa9
@ -1,6 +1,10 @@
|
||||
$(() => {
|
||||
const titleID = $('.data').attr('data-title-id') || 'library';
|
||||
|
||||
const sortItems = () => {
|
||||
const sort = $('#sort-select').find(':selected').attr('id');
|
||||
localStorage.setItem(`sort-${titleID}`, sort);
|
||||
|
||||
const ary = sort.split('-');
|
||||
const by = ary[0];
|
||||
const dir = ary[1];
|
||||
@ -115,7 +119,10 @@ $(() => {
|
||||
sortItems();
|
||||
});
|
||||
|
||||
if ($('option#auto-up').length > 0)
|
||||
const sortID = localStorage.getItem(`sort-${titleID}`);
|
||||
if (sortID)
|
||||
$(`option#${sortID}`).attr('selected', '');
|
||||
else if ($('option#auto-up').length > 0)
|
||||
$('option#auto-up').attr('selected', '');
|
||||
else
|
||||
$('option#name-up').attr('selected', '');
|
||||
|
@ -1,3 +1,4 @@
|
||||
<div class="data" data-title-id="<%= title.id %>"></div>
|
||||
<div>
|
||||
<h2 class=uk-title><span><%= title.display_name %></span>
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user