Save last used plugin in local storage

This commit is contained in:
Alex Ling 2020-07-26 12:42:28 +00:00
parent 0e1e4de528
commit 8349fb68a4
2 changed files with 19 additions and 7 deletions

View File

@ -1,18 +1,30 @@
const loadPlugin = title => {
localStorage.setItem('plugin', title);
const url = `${location.protocol}//${location.host}${location.pathname}`;
const newURL = `${url}?${$.param({
plugin: encodeURIComponent(title)
})}`;
window.location.href = newURL;
};
$(() => { $(() => {
var storedTitle = localStorage.getItem('plugin');
if (storedTitle && storedTitle !== plugin) {
loadPlugin(storedTitle);
} else {
$('#controls').removeAttr('hidden');
}
$('#search-input').keypress(event => { $('#search-input').keypress(event => {
if (event.which === 13) { if (event.which === 13) {
search(); search();
} }
}); });
$('#plugin-select').val(plugin);
$('#plugin-select').change(() => { $('#plugin-select').change(() => {
const title = $('#plugin-select').val(); const title = $('#plugin-select').val();
const url = `${location.protocol}//${location.host}${location.pathname}`; loadPlugin(title);
const newURL = `${url}?${$.param({
plugin: encodeURIComponent(title)
})}`;
window.location.href = newURL;
}); });
$('#plugin-select').val(plugin);
}); });
let mangaTitle = ""; let mangaTitle = "";

View File

@ -8,7 +8,7 @@
<% else %> <% else %>
<h2 class=uk-title>Download with Plugins</h2> <h2 class=uk-title>Download with Plugins</h2>
<div class="uk-grid-small" uk-grid> <div id="controls" class="uk-grid-small" uk-grid hidden>
<div class="uk-width-3-4@m uk-child-width-1-1"> <div class="uk-width-3-4@m uk-child-width-1-1">
<div class="uk-margin"> <div class="uk-margin">
<label class="uk-form-label" for="search-input">&nbsp;</label> <label class="uk-form-label" for="search-input">&nbsp;</label>