diff --git a/src/UI/Settings/UIWindowSettings.js b/src/UI/Settings/UIWindowSettings.js index 616d2e5f..e155bbd9 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 += `

${i18n('clock')}

`; + h += `
` + h += `${i18n('visibility')}:` + h += `` + h += `
` + h += `
`; + h += ``; h += ``; h += ``; @@ -344,6 +357,15 @@ async function UIWindowSettings(options){ }) }); + $(el_window).on('change', 'select.change-clock-visible', function(e){ + const $this = $(this); + const value = $this.val(); + + window.change_clock_visible(value); + }) + + window.change_clock_visible(); + resolve(el_window); }); } diff --git a/src/UI/UIDesktop.js b/src/UI/UIDesktop.js index a36ecc77..a351cc0e 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_visible: await puter.kv.get('user_preferences.clock_visible'), }; // update default apps @@ -1028,7 +1029,6 @@ async function UIDesktop(options){ } }) } - } $(document).on('contextmenu taphold', '.taskbar', function(event){ @@ -1379,14 +1379,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_visible === '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_visible === 'auto' && $('#clock').hide(); } }) diff --git a/src/UI/UITaskbar.js b/src/UI/UITaskbar.js index b76cb899..43b7a603 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_visible(); + //--------------------------------------------- // add `Start` to taskbar //--------------------------------------------- diff --git a/src/globals.js b/src/globals.js index 97d1251a..5d91c0af 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_visible: 'auto', } } diff --git a/src/helpers.js b/src/helpers.js index c4c8bbbd..75b4e7f6 100644 --- a/src/helpers.js +++ b/src/helpers.js @@ -3655,4 +3655,25 @@ window.save_desktop_item_positions = ()=>{ window.delete_desktop_item_positions = ()=>{ desktop_item_positions = {} puter.kv.del('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({ + clock_visible: newValue + }); + + return; + } + + $('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 832ccd72..4f22ecac 100644 --- a/src/i18n/translations/en.js +++ b/src/i18n/translations/en.js @@ -60,6 +60,10 @@ const en = { credits: "Credits", current_password: "Current Password", cut: 'Cut', + clock: "Clock", + 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", @@ -198,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 82e44ab0..c44eb14c 100644 --- a/src/i18n/translations/zh.js +++ b/src/i18n/translations/zh.js @@ -50,6 +50,10 @@ const zh = { create_shortcut: "创建快捷方式", current_password: "当前密码", cut: '剪切', + clock: "时间", + clock_visible_hide: '隐藏 - 始终隐藏', + clock_visible_show: '显示 - 始终显示', + clock_visible_auto: '自动 - 默认值,全屏显示', date_modified: '修改日期', delete: '删除', delete_permanently: "永久删除", @@ -157,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!", diff --git a/src/icons/clock.svg b/src/icons/clock.svg new file mode 100644 index 00000000..52c39737 --- /dev/null +++ b/src/icons/clock.svg @@ -0,0 +1 @@ + \ No newline at end of file