From 69beb1ff7d9fe1c0ea67ca39d365687a6876134e Mon Sep 17 00:00:00 2001 From: meetqy Date: Thu, 28 Mar 2024 11:09:47 +0800 Subject: [PATCH] not save to server --- src/UI/Settings/UIWindowSettings.js | 31 +++++++---------------------- src/UI/UIDesktop.js | 6 ++++-- src/globals.js | 1 + 3 files changed, 12 insertions(+), 26 deletions(-) diff --git a/src/UI/Settings/UIWindowSettings.js b/src/UI/Settings/UIWindowSettings.js index 7da373536..ad00b3391 100644 --- a/src/UI/Settings/UIWindowSettings.js +++ b/src/UI/Settings/UIWindowSettings.js @@ -360,30 +360,13 @@ async function UIWindowSettings(options){ $(el_window).on('change', 'select.change-clock-visable', function(e){ const $this = $(this); const value = $this.val(); - console.log(value); - // $.ajax({ - // url: api_origin + "/clock", - // type: 'POST', - // async: true, - // headers: { - // "Authorization": "Bearer "+auth_token - // }, - // contentType: "application/json", - // data: value, - // // data: JSON.stringify({ - // // old_pass: current_password, - // // new_pass: new_password, - // // }), - // success: function (data){ - // // $(el_window).find('.form-success-msg').html(i18n('password_changed')); - // // $(el_window).find('.form-success-msg').fadeIn(); - // // $(el_window).find('input').val(''); - // }, - // error: function (err){ - // // $(el_window).find('.form-error-msg').html(err.responseText); - // // $(el_window).find('.form-error-msg').fadeIn(); - // } - // }); + + value === 'show' && $('#clock').show(); + value === 'hide' && $('#clock').hide(); + + window.mutate_user_preferences({ + clock_visable: value + }); }) resolve(el_window); diff --git a/src/UI/UIDesktop.js b/src/UI/UIDesktop.js index a36ecc771..e3c07f442 100644 --- a/src/UI/UIDesktop.js +++ b/src/UI/UIDesktop.js @@ -505,6 +505,7 @@ async function UIDesktop(options){ const user_preferences = { show_hidden_files: JSON.parse(await puter.kv.get('user_preferences.show_hidden_files')), language: await puter.kv.get('user_preferences.language'), + clock_visable: await puter.kv.get('user_preferences.clock_visable'), }; // update default apps @@ -1379,14 +1380,15 @@ document.addEventListener('fullscreenchange', (event) => { // document.fullscreenElement will point to the element that // is in fullscreen mode if there is one. If there isn't one, // the value of the property is null. + if (document.fullscreenElement) { $('.fullscreen-btn').css('background-image', `url(${window.icons['shrink.svg']})`); $('.fullscreen-btn').attr('title', 'Exit Full Screen'); - $('#clock').show(); + window.user_preferences.clock_visable === 'auto' && $('#clock').show(); } else { $('.fullscreen-btn').css('background-image', `url(${window.icons['fullscreen.svg']})`); $('.fullscreen-btn').attr('title', 'Enter Full Screen'); - $('#clock').hide(); + window.user_preferences.clock_visable === 'auto' && $('#clock').hide(); } }) diff --git a/src/globals.js b/src/globals.js index 97d1251a7..607282e6d 100644 --- a/src/globals.js +++ b/src/globals.js @@ -97,6 +97,7 @@ if (window.user_preferences === null) { window.user_preferences = { show_hidden_files: false, language: navigator.language.split("-")[0] || navigator.userLanguage || 'en', + clock_visable: 'auto', } }