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 sortItems = () => {
|
||||||
const sort = $('#sort-select').find(':selected').attr('id');
|
const sort = $('#sort-select').find(':selected').attr('id');
|
||||||
|
localStorage.setItem(`sort-${titleID}`, sort);
|
||||||
|
|
||||||
const ary = sort.split('-');
|
const ary = sort.split('-');
|
||||||
const by = ary[0];
|
const by = ary[0];
|
||||||
const dir = ary[1];
|
const dir = ary[1];
|
||||||
@ -115,7 +119,10 @@ $(() => {
|
|||||||
sortItems();
|
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', '');
|
$('option#auto-up').attr('selected', '');
|
||||||
else
|
else
|
||||||
$('option#name-up').attr('selected', '');
|
$('option#name-up').attr('selected', '');
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
<div class="data" data-title-id="<%= title.id %>"></div>
|
||||||
<div>
|
<div>
|
||||||
<h2 class=uk-title><span><%= title.display_name %></span>
|
<h2 class=uk-title><span><%= title.display_name %></span>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user