From 14f91fa2751dffa34fd8e4773adf6ee6906a2a26 Mon Sep 17 00:00:00 2001 From: RemixDev Date: Tue, 14 Apr 2020 19:58:54 +0200 Subject: [PATCH] Implemented settings load and save --- public/css/style.css | 12 +++++++ public/index.html | 13 +++++--- public/js/{init.js => app/app.js} | 52 ++++++++++++++++++++++++++--- public/js/{ => app}/downloadList.js | 0 public/js/{app.js => app/search.js} | 24 ------------- public/js/{ => app}/utils.js | 0 6 files changed, 68 insertions(+), 33 deletions(-) rename public/js/{init.js => app/app.js} (76%) rename public/js/{ => app}/downloadList.js (100%) rename public/js/{app.js => app/search.js} (78%) rename public/js/{ => app}/utils.js (100%) diff --git a/public/css/style.css b/public/css/style.css index 399d9f1..3f2af9d 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -430,3 +430,15 @@ input[type="text"], input[type="password"], input[type="number"]{ .right{ float: right; } +.fixed_footer footer{ + position: sticky; + display: flex; + align-items: center; + flex-direction: row; + justify-content: flex-end; + background-color: var(--main-background); + bottom: 0px; + height: 64px; + width: 100%; + margin-top: 24px; +} diff --git a/public/index.html b/public/index.html index 0a6c888..ccb5240 100644 --- a/public/index.html +++ b/public/index.html @@ -173,7 +173,7 @@

Home

Link Analyzer

-
+ +
+ +

About

@@ -373,8 +376,8 @@

Settings

- - - - + + + + diff --git a/public/js/init.js b/public/js/app/app.js similarity index 76% rename from public/js/init.js rename to public/js/app/app.js index d5e8808..2af3534 100644 --- a/public/js/init.js +++ b/public/js/app/app.js @@ -6,6 +6,8 @@ search_selected = "" main_selected="" // toasts stuff toastsWithId = {} +// settings +lastSettings = {} function toast(msg, icon=null, dismiss=true, id=null){ if (toastsWithId[id]){ @@ -52,6 +54,11 @@ socket.on("toast", (data)=>{ toast(data.msg, data.icon || null, data.dismiss !== undefined ? data.dismiss : true, data.id || null) }) +// Debug messages for socketio +socket.on("message", function(msg){ + console.log(msg) +}) + window.addEventListener('pywebviewready', function() { if (window.pywebview.platform == "gtk"){ $('#open_login_prompt').prop('disabled', false); @@ -164,7 +171,7 @@ socket.on("logged_out", function(){ $("#settings_picture").attr("src",`https://e-cdns-images.dzcdn.net/images/user/125x125-000000-80-0-0.jpg`) }) -// settings +// settings stuff var settingsTab = new Vue({ el: '#settings_tab', data: { @@ -173,7 +180,44 @@ var settingsTab = new Vue({ }) socket.on("init_settings", function(settings){ - console.log(settings) - settingsTab.settings = settings - toast("Loaded Settings", 'done') + loadSettings(settings) + toast("Settings loaded!", 'settings') }) + +socket.on("updateSettings", function(settings){ + loadSettings(settings) + toast("Settings updated!", 'settings') +}) + +function loadSettings(settings){ + lastSettings = {...settings} + settingsTab.settings = settings +} + +function saveSettings(){ + lastSettings = {...settingsTab.settings} + socket.emit("saveSettings", lastSettings) +} + +// tabs stuff +function changeTab(evt, section, tabName) { + var i, tabcontent, tablinks; + tabcontent = document.getElementsByClassName(section+"_tabcontent"); + for (i = 0; i < tabcontent.length; i++) { + tabcontent[i].style.display = "none"; + } + tablinks = document.getElementsByClassName(section+"_tablinks"); + for (i = 0; i < tablinks.length; i++) { + tablinks[i].className = tablinks[i].className.replace(" active", ""); + } + if (tabName == "settings_tab" && main_selected != "settings_tab"){ + settingsTab.settings = {...lastSettings} + } + document.getElementById(tabName).style.display = "block"; + window[section+"_selected"] = tabName + evt.currentTarget.className += " active"; + // Check if you need to load more content in the search tab + if (document.getElementById("content").offsetHeight >= document.getElementById("content").scrollHeight && main_selected == "search_tab" && ["track_search", "album_search", "artist_search", "playlist_search"].indexOf(search_selected) != -1){ + scrolledSearch(window[search_selected.split("_")[0]+"Search"]) + } +} diff --git a/public/js/downloadList.js b/public/js/app/downloadList.js similarity index 100% rename from public/js/downloadList.js rename to public/js/app/downloadList.js diff --git a/public/js/app.js b/public/js/app/search.js similarity index 78% rename from public/js/app.js rename to public/js/app/search.js index 3325b93..2c9fecf 100644 --- a/public/js/app.js +++ b/public/js/app/search.js @@ -1,27 +1,3 @@ -// Debug messages for socketio -socket.on("message", function(msg){ - console.log(msg) -}) - -function changeTab(evt, section, tabName) { - var i, tabcontent, tablinks; - tabcontent = document.getElementsByClassName(section+"_tabcontent"); - for (i = 0; i < tabcontent.length; i++) { - tabcontent[i].style.display = "none"; - } - tablinks = document.getElementsByClassName(section+"_tablinks"); - for (i = 0; i < tablinks.length; i++) { - tablinks[i].className = tablinks[i].className.replace(" active", ""); - } - document.getElementById(tabName).style.display = "block"; - window[section+"_selected"] = tabName - evt.currentTarget.className += " active"; - // Check if you need to load more content in the search tab - if (document.getElementById("content").offsetHeight >= document.getElementById("content").scrollHeight && main_selected == "search_tab" && ["track_search", "album_search", "artist_search", "playlist_search"].indexOf(search_selected) != -1){ - scrolledSearch(window[search_selected.split("_")[0]+"Search"]) - } -} - // Load more content when the search page is at the end $('#content').on('scroll', function() { if($(this).scrollTop() + $(this).innerHeight() >= $(this)[0].scrollHeight) { diff --git a/public/js/utils.js b/public/js/app/utils.js similarity index 100% rename from public/js/utils.js rename to public/js/app/utils.js