From 0271950b783c4cf1a243d4df6808bce618f12760 Mon Sep 17 00:00:00 2001 From: meetqy Date: Thu, 28 Mar 2024 10:44:52 +0800 Subject: [PATCH 1/7] clock page --- src/UI/Settings/UIWindowSettings.js | 44 ++++++++++++++++++++++++++++- src/i18n/translations/en.js | 1 + src/icons/clock.svg | 1 + 3 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/icons/clock.svg diff --git a/src/UI/Settings/UIWindowSettings.js b/src/UI/Settings/UIWindowSettings.js index 616d2e5f64..7da373536d 100644 --- a/src/UI/Settings/UIWindowSettings.js +++ b/src/UI/Settings/UIWindowSettings.js @@ -40,6 +40,7 @@ async function UIWindowSettings(options){ h += `
${i18n('usage')}
`; h += `
${i18n('account')}
`; h += `
${i18n('language')}
`; + h += `
${i18n('clock')}
`; h += ``; // content @@ -124,9 +125,21 @@ async function UIWindowSettings(options){ h += `
${lang.name}
`; } h += ``; - h += ``; + // Clock + h += `
`; + h += `

Clock

`; + h += `
` + h += `Visable:` + h += `` + h += `
` + h += `
`; + h += ``; h += ``; h += ``; @@ -344,6 +357,35 @@ 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(); + // } + // }); + }) + resolve(el_window); }); } diff --git a/src/i18n/translations/en.js b/src/i18n/translations/en.js index 832ccd7288..4980a14096 100644 --- a/src/i18n/translations/en.js +++ b/src/i18n/translations/en.js @@ -60,6 +60,7 @@ const en = { credits: "Credits", current_password: "Current Password", cut: 'Cut', + clock: "Clock", date_modified: 'Date modified', delete: 'Delete', delete_account: "Delete Account", diff --git a/src/icons/clock.svg b/src/icons/clock.svg new file mode 100644 index 0000000000..52c3973775 --- /dev/null +++ b/src/icons/clock.svg @@ -0,0 +1 @@ + \ No newline at end of file From 69beb1ff7d9fe1c0ea67ca39d365687a6876134e Mon Sep 17 00:00:00 2001 From: meetqy Date: Thu, 28 Mar 2024 11:09:47 +0800 Subject: [PATCH 2/7] 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 7da373536d..ad00b33916 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 a36ecc7710..e3c07f4426 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 97d1251a79..607282e6d5 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', } } From 5d45bfbfe1cf00fca41cac5c56fe211251c2dc98 Mon Sep 17 00:00:00 2001 From: meetqy Date: Sat, 30 Mar 2024 10:33:35 +0800 Subject: [PATCH 3/7] language --- src/UI/Settings/UIWindowSettings.js | 11 ++++++----- src/i18n/translations/en.js | 4 ++++ src/i18n/translations/zh.js | 5 +++++ 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/UI/Settings/UIWindowSettings.js b/src/UI/Settings/UIWindowSettings.js index ad00b33916..5418e4d3d3 100644 --- a/src/UI/Settings/UIWindowSettings.js +++ b/src/UI/Settings/UIWindowSettings.js @@ -131,11 +131,11 @@ async function UIWindowSettings(options){ h += `
`; h += `

Clock

`; h += `
` - h += `Visable:` - h += `` + h += `` + h += `` + h += `` h += `` h += `
` h += `
`; @@ -364,6 +364,7 @@ async function UIWindowSettings(options){ value === 'show' && $('#clock').show(); value === 'hide' && $('#clock').hide(); + // save clock_visable to user preferences window.mutate_user_preferences({ clock_visable: value }); diff --git a/src/i18n/translations/en.js b/src/i18n/translations/en.js index 4980a14096..a72e570d41 100644 --- a/src/i18n/translations/en.js +++ b/src/i18n/translations/en.js @@ -61,6 +61,10 @@ const en = { current_password: "Current Password", cut: 'Cut', clock: "Clock", + click_visable: 'Visible', + click_visable_hide: 'Hide - Always hidden', + click_visable_show: 'Show - Always visible', + click_visable_auto: 'Auto - Default, visible only in full-screen mode.', date_modified: 'Date modified', delete: 'Delete', delete_account: "Delete Account", diff --git a/src/i18n/translations/zh.js b/src/i18n/translations/zh.js index 82e44ab06e..9440c60bb3 100644 --- a/src/i18n/translations/zh.js +++ b/src/i18n/translations/zh.js @@ -50,6 +50,11 @@ const zh = { create_shortcut: "创建快捷方式", current_password: "当前密码", cut: '剪切', + clock: "时间", + click_visable: '显示方式', + click_visable_hide: '隐藏 - 始终隐藏', + click_visable_show: '显示 - 始终显示', + click_visable_auto: '自动 - 默认值,全屏显示', date_modified: '修改日期', delete: '删除', delete_permanently: "永久删除", From 514abf030cf5ecbbc0e57669024ca54f7002eeab Mon Sep 17 00:00:00 2001 From: meetqy Date: Sat, 30 Mar 2024 10:53:39 +0800 Subject: [PATCH 4/7] fix: Make showing/hiding the clock configurable #159 --- src/UI/Settings/UIWindowSettings.js | 16 ++++++---------- src/UI/UIDesktop.js | 1 - src/UI/UITaskbar.js | 3 +++ src/helpers.js | 19 +++++++++++++++++++ 4 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/UI/Settings/UIWindowSettings.js b/src/UI/Settings/UIWindowSettings.js index 5418e4d3d3..5587ea2baa 100644 --- a/src/UI/Settings/UIWindowSettings.js +++ b/src/UI/Settings/UIWindowSettings.js @@ -133,9 +133,9 @@ async function UIWindowSettings(options){ h += `
` h += `${i18n('click_visable')}:` h += `` h += `
` h += ``; @@ -361,15 +361,11 @@ async function UIWindowSettings(options){ const $this = $(this); const value = $this.val(); - value === 'show' && $('#clock').show(); - value === 'hide' && $('#clock').hide(); - - // save clock_visable to user preferences - window.mutate_user_preferences({ - clock_visable: value - }); + changeClockVisable(value); }) + change_clock_visable(); + resolve(el_window); }); } diff --git a/src/UI/UIDesktop.js b/src/UI/UIDesktop.js index e3c07f4426..1b3724b31e 100644 --- a/src/UI/UIDesktop.js +++ b/src/UI/UIDesktop.js @@ -1029,7 +1029,6 @@ async function UIDesktop(options){ } }) } - } $(document).on('contextmenu taphold', '.taskbar', function(event){ diff --git a/src/UI/UITaskbar.js b/src/UI/UITaskbar.js index b76cb899a0..5d00082c14 100644 --- a/src/UI/UITaskbar.js +++ b/src/UI/UITaskbar.js @@ -45,6 +45,9 @@ async function UITaskbar(options){ $('.desktop').append(h); + // init clock visibility + window.change_clock_visable(); + //--------------------------------------------- // add `Start` to taskbar //--------------------------------------------- diff --git a/src/helpers.js b/src/helpers.js index cf3524594a..21676a7125 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -3676,4 +3676,23 @@ window.save_desktop_item_positions = ()=>{ window.delete_desktop_item_positions = ()=>{ desktop_item_positions = {} puter.kv.del('desktop_item_positions'); +} + +window.change_clock_visable = (clock_visable) => { + let newValue = clock_visable || window.user_preferences.clock_visable; + + newValue === 'show' && $('#clock').show(); + newValue === 'hide' && $('#clock').hide(); + + + if(clock_visable) { + // save clock_visable to user preferences + window.mutate_user_preferences({ + clock_visable: newValue + }); + + return; + } + + $('select.change-clock-visable').val(window.user_preferences.clock_visable); } \ No newline at end of file From 9fd32468ad7527a4444286fea6e3e440fbcaae17 Mon Sep 17 00:00:00 2001 From: meetqy Date: Sat, 30 Mar 2024 10:57:57 +0800 Subject: [PATCH 5/7] fix: Make showing/hiding the clock configurable #159 --- src/UI/Settings/UIWindowSettings.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/UI/Settings/UIWindowSettings.js b/src/UI/Settings/UIWindowSettings.js index 5587ea2baa..ee74d75f6e 100644 --- a/src/UI/Settings/UIWindowSettings.js +++ b/src/UI/Settings/UIWindowSettings.js @@ -361,10 +361,10 @@ async function UIWindowSettings(options){ const $this = $(this); const value = $this.val(); - changeClockVisable(value); + window.change_clock_visable(value); }) - change_clock_visable(); + window.change_clock_visable(); resolve(el_window); }); From db245f9ba22ac4e3188ed86a466d98c7845890d4 Mon Sep 17 00:00:00 2001 From: Nariman Jelveh Date: Fri, 29 Mar 2024 20:59:50 -0700 Subject: [PATCH 6/7] Fix spelling mistake --- src/UI/Settings/UIWindowSettings.js | 16 ++++++++-------- src/UI/UIDesktop.js | 6 +++--- src/UI/UITaskbar.js | 2 +- src/globals.js | 2 +- src/helpers.js | 12 ++++++------ src/i18n/translations/en.js | 8 ++++---- src/i18n/translations/zh.js | 8 ++++---- 7 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/UI/Settings/UIWindowSettings.js b/src/UI/Settings/UIWindowSettings.js index ee74d75f6e..7fc6579ea5 100644 --- a/src/UI/Settings/UIWindowSettings.js +++ b/src/UI/Settings/UIWindowSettings.js @@ -131,11 +131,11 @@ async function UIWindowSettings(options){ h += `
`; h += `

Clock

`; h += `
` - h += `${i18n('click_visable')}:` - h += `` + h += `` + h += `` + h += `` h += `` h += `
` h += `
`; @@ -357,14 +357,14 @@ async function UIWindowSettings(options){ }) }); - $(el_window).on('change', 'select.change-clock-visable', function(e){ + $(el_window).on('change', 'select.change-clock-visible', function(e){ const $this = $(this); const value = $this.val(); - window.change_clock_visable(value); + window.change_clock_visible(value); }) - window.change_clock_visable(); + window.change_clock_visible(); resolve(el_window); }); diff --git a/src/UI/UIDesktop.js b/src/UI/UIDesktop.js index 1b3724b31e..a351cc0e36 100644 --- a/src/UI/UIDesktop.js +++ b/src/UI/UIDesktop.js @@ -505,7 +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'), + clock_visible: await puter.kv.get('user_preferences.clock_visible'), }; // update default apps @@ -1383,11 +1383,11 @@ document.addEventListener('fullscreenchange', (event) => { if (document.fullscreenElement) { $('.fullscreen-btn').css('background-image', `url(${window.icons['shrink.svg']})`); $('.fullscreen-btn').attr('title', 'Exit Full Screen'); - window.user_preferences.clock_visable === 'auto' && $('#clock').show(); + window.user_preferences.clock_visible === 'auto' && $('#clock').show(); } else { $('.fullscreen-btn').css('background-image', `url(${window.icons['fullscreen.svg']})`); $('.fullscreen-btn').attr('title', 'Enter Full Screen'); - window.user_preferences.clock_visable === 'auto' && $('#clock').hide(); + window.user_preferences.clock_visible === 'auto' && $('#clock').hide(); } }) diff --git a/src/UI/UITaskbar.js b/src/UI/UITaskbar.js index 5d00082c14..43b7a603e1 100644 --- a/src/UI/UITaskbar.js +++ b/src/UI/UITaskbar.js @@ -46,7 +46,7 @@ async function UITaskbar(options){ $('.desktop').append(h); // init clock visibility - window.change_clock_visable(); + window.change_clock_visible(); //--------------------------------------------- // add `Start` to taskbar diff --git a/src/globals.js b/src/globals.js index 607282e6d5..5d91c0aff5 100644 --- a/src/globals.js +++ b/src/globals.js @@ -97,7 +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', + clock_visible: 'auto', } } diff --git a/src/helpers.js b/src/helpers.js index 25b7f5503c..dd88741438 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -3680,21 +3680,21 @@ window.delete_desktop_item_positions = ()=>{ puter.kv.del('desktop_item_positions'); } -window.change_clock_visable = (clock_visable) => { - let newValue = clock_visable || window.user_preferences.clock_visable; +window.change_clock_visible = (clock_visible) => { + let newValue = clock_visible || window.user_preferences.clock_visible; newValue === 'show' && $('#clock').show(); newValue === 'hide' && $('#clock').hide(); - if(clock_visable) { - // save clock_visable to user preferences + if(clock_visible) { + // save clock_visible to user preferences window.mutate_user_preferences({ - clock_visable: newValue + clock_visible: newValue }); return; } - $('select.change-clock-visable').val(window.user_preferences.clock_visable); + $('select.change-clock-visible').val(window.user_preferences.clock_visible); } \ No newline at end of file diff --git a/src/i18n/translations/en.js b/src/i18n/translations/en.js index a72e570d41..0070912cea 100644 --- a/src/i18n/translations/en.js +++ b/src/i18n/translations/en.js @@ -61,10 +61,10 @@ const en = { current_password: "Current Password", cut: 'Cut', clock: "Clock", - click_visable: 'Visible', - click_visable_hide: 'Hide - Always hidden', - click_visable_show: 'Show - Always visible', - click_visable_auto: 'Auto - Default, visible only in full-screen mode.', + click_visible: 'Visible', + click_visible_hide: 'Hide - Always hidden', + click_visible_show: 'Show - Always visible', + click_visible_auto: 'Auto - Default, visible only in full-screen mode.', date_modified: 'Date modified', delete: 'Delete', delete_account: "Delete Account", diff --git a/src/i18n/translations/zh.js b/src/i18n/translations/zh.js index 9440c60bb3..bd2827d860 100644 --- a/src/i18n/translations/zh.js +++ b/src/i18n/translations/zh.js @@ -51,10 +51,10 @@ const zh = { current_password: "当前密码", cut: '剪切', clock: "时间", - click_visable: '显示方式', - click_visable_hide: '隐藏 - 始终隐藏', - click_visable_show: '显示 - 始终显示', - click_visable_auto: '自动 - 默认值,全屏显示', + click_visible: '显示方式', + click_visible_hide: '隐藏 - 始终隐藏', + click_visible_show: '显示 - 始终显示', + click_visible_auto: '自动 - 默认值,全屏显示', date_modified: '修改日期', delete: '删除', delete_permanently: "永久删除", From 8883c892ed2a0534cda8240b44cb9a38a4b7e213 Mon Sep 17 00:00:00 2001 From: Nariman Jelveh Date: Fri, 29 Mar 2024 21:25:03 -0700 Subject: [PATCH 7/7] Fix `auto` not being triggered when changing visibility --- src/UI/Settings/UIWindowSettings.js | 14 +++++++------- src/helpers.js | 4 +++- src/i18n/translations/en.js | 8 ++++---- src/i18n/translations/zh.js | 8 ++++---- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/UI/Settings/UIWindowSettings.js b/src/UI/Settings/UIWindowSettings.js index 7fc6579ea5..e155bbd9ee 100644 --- a/src/UI/Settings/UIWindowSettings.js +++ b/src/UI/Settings/UIWindowSettings.js @@ -129,14 +129,14 @@ async function UIWindowSettings(options){ // Clock h += `
`; - h += `

Clock

`; + h += `

${i18n('clock')}

`; h += `
` - h += `${i18n('click_visible')}:` - h += `` + h += `${i18n('visibility')}:` + h += `` h += `
` h += `
`; diff --git a/src/helpers.js b/src/helpers.js index dd88741438..8860cd61f2 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -3683,10 +3683,12 @@ window.delete_desktop_item_positions = ()=>{ window.change_clock_visible = (clock_visible) => { let newValue = clock_visible || window.user_preferences.clock_visible; + + newValue === 'auto' && is_fullscreen() ? $('#clock').show() : $('#clock').hide(); + newValue === 'show' && $('#clock').show(); newValue === 'hide' && $('#clock').hide(); - if(clock_visible) { // save clock_visible to user preferences window.mutate_user_preferences({ diff --git a/src/i18n/translations/en.js b/src/i18n/translations/en.js index 0070912cea..4f22ecacdf 100644 --- a/src/i18n/translations/en.js +++ b/src/i18n/translations/en.js @@ -61,10 +61,9 @@ const en = { current_password: "Current Password", cut: 'Cut', clock: "Clock", - click_visible: 'Visible', - click_visible_hide: 'Hide - Always hidden', - click_visible_show: 'Show - Always visible', - click_visible_auto: 'Auto - Default, visible only in full-screen mode.', + clock_visible_hide: 'Hide - Always hidden', + clock_visible_show: 'Show - Always visible', + clock_visible_auto: 'Auto - Default, visible only in full-screen mode.', date_modified: 'Date modified', delete: 'Delete', delete_account: "Delete Account", @@ -203,6 +202,7 @@ const en = { username: "Username", username_changed: 'Username updated successfully.', versions: "Versions", + visibility: 'Visibility', yes: 'Yes', yes_release_it: 'Yes, Release It', you_have_been_referred_to_puter_by_a_friend: "You have been referred to Puter by a friend!", diff --git a/src/i18n/translations/zh.js b/src/i18n/translations/zh.js index bd2827d860..c44eb14c56 100644 --- a/src/i18n/translations/zh.js +++ b/src/i18n/translations/zh.js @@ -51,10 +51,9 @@ const zh = { current_password: "当前密码", cut: '剪切', clock: "时间", - click_visible: '显示方式', - click_visible_hide: '隐藏 - 始终隐藏', - click_visible_show: '显示 - 始终显示', - click_visible_auto: '自动 - 默认值,全屏显示', + clock_visible_hide: '隐藏 - 始终隐藏', + clock_visible_show: '显示 - 始终显示', + clock_visible_auto: '自动 - 默认值,全屏显示', date_modified: '修改日期', delete: '删除', delete_permanently: "永久删除", @@ -162,6 +161,7 @@ const zh = { upload_here: '在此上传', username: "用户名", username_changed: '用户名已成功更新。', + visibility: "可见性", versions: "版本", yes_release_it: '是的,释放它', you_have_been_referred_to_puter_by_a_friend: "您已经被朋友推荐到 Puter!",