Skip to content

Commit 0094e2e

Browse files
authored
Merge pull request #191 from meetqy/main
Make showing/hiding the clock configurable
2 parents b4be6aa + 8883c89 commit 0094e2e

File tree

8 files changed

+63
-4
lines changed

8 files changed

+63
-4
lines changed

Diff for: src/UI/Settings/UIWindowSettings.js

+23-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ async function UIWindowSettings(options){
4040
h += `<div class="settings-sidebar-item disable-user-select" data-settings="usage" style="background-image: url(${icons['speedometer-outline.svg']});">${i18n('usage')}</div>`;
4141
h += `<div class="settings-sidebar-item disable-user-select" data-settings="account" style="background-image: url(${icons['user.svg']});">${i18n('account')}</div>`;
4242
h += `<div class="settings-sidebar-item disable-user-select" data-settings="language" style="background-image: url(${icons['language.svg']});">${i18n('language')}</div>`;
43+
h += `<div class="settings-sidebar-item disable-user-select" data-settings="clock" style="background-image: url(${icons['clock.svg']});">${i18n('clock')}</div>`;
4344
h += `</div>`;
4445

4546
// content
@@ -124,9 +125,21 @@ async function UIWindowSettings(options){
124125
h += `<div class="language-item ${window.locale === lang.code ? 'active': ''}" data-lang="${lang.code}" data-english-name="${html_encode(lang.english_name)}">${lang.name}</div>`;
125126
}
126127
h += `</div>`;
127-
128128
h += `</div>`;
129129

130+
// Clock
131+
h += `<div class="settings-content" data-settings="clock">`;
132+
h += `<h1>${i18n('clock')}</h1>`;
133+
h += `<div style="display: flex;align-items: center">`
134+
h += `<span>${i18n('visibility')}:</span>`
135+
h += `<select class="change-clock-visible" style="margin-left: 10px;flex: 1">`
136+
h += `<option value="auto">${i18n('clock_visible_auto')}</option>`
137+
h += `<option value="hide">${i18n('clock_visible_hide')}</option>`
138+
h += `<option value="show">${i18n('clock_visible_show')}</option>`
139+
h += `</select>`
140+
h += `</div>`
141+
h += `</div>`;
142+
130143
h += `</div>`;
131144
h += `</div>`;
132145
h += `</div>`;
@@ -344,6 +357,15 @@ async function UIWindowSettings(options){
344357
})
345358
});
346359

360+
$(el_window).on('change', 'select.change-clock-visible', function(e){
361+
const $this = $(this);
362+
const value = $this.val();
363+
364+
window.change_clock_visible(value);
365+
})
366+
367+
window.change_clock_visible();
368+
347369
resolve(el_window);
348370
});
349371
}

Diff for: src/UI/UIDesktop.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,7 @@ async function UIDesktop(options){
505505
const user_preferences = {
506506
show_hidden_files: JSON.parse(await puter.kv.get('user_preferences.show_hidden_files')),
507507
language: await puter.kv.get('user_preferences.language'),
508+
clock_visible: await puter.kv.get('user_preferences.clock_visible'),
508509
};
509510

510511
// update default apps
@@ -1028,7 +1029,6 @@ async function UIDesktop(options){
10281029
}
10291030
})
10301031
}
1031-
10321032
}
10331033

10341034
$(document).on('contextmenu taphold', '.taskbar', function(event){
@@ -1379,14 +1379,15 @@ document.addEventListener('fullscreenchange', (event) => {
13791379
// document.fullscreenElement will point to the element that
13801380
// is in fullscreen mode if there is one. If there isn't one,
13811381
// the value of the property is null.
1382+
13821383
if (document.fullscreenElement) {
13831384
$('.fullscreen-btn').css('background-image', `url(${window.icons['shrink.svg']})`);
13841385
$('.fullscreen-btn').attr('title', 'Exit Full Screen');
1385-
$('#clock').show();
1386+
window.user_preferences.clock_visible === 'auto' && $('#clock').show();
13861387
} else {
13871388
$('.fullscreen-btn').css('background-image', `url(${window.icons['fullscreen.svg']})`);
13881389
$('.fullscreen-btn').attr('title', 'Enter Full Screen');
1389-
$('#clock').hide();
1390+
window.user_preferences.clock_visible === 'auto' && $('#clock').hide();
13901391
}
13911392
})
13921393

Diff for: src/UI/UITaskbar.js

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ async function UITaskbar(options){
4545

4646
$('.desktop').append(h);
4747

48+
// init clock visibility
49+
window.change_clock_visible();
50+
4851
//---------------------------------------------
4952
// add `Start` to taskbar
5053
//---------------------------------------------

Diff for: src/globals.js

+1
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ if (window.user_preferences === null) {
9797
window.user_preferences = {
9898
show_hidden_files: false,
9999
language: navigator.language.split("-")[0] || navigator.userLanguage || 'en',
100+
clock_visible: 'auto',
100101
}
101102
}
102103

Diff for: src/helpers.js

+21
Original file line numberDiff line numberDiff line change
@@ -3655,4 +3655,25 @@ window.save_desktop_item_positions = ()=>{
36553655
window.delete_desktop_item_positions = ()=>{
36563656
desktop_item_positions = {}
36573657
puter.kv.del('desktop_item_positions');
3658+
}
3659+
3660+
window.change_clock_visible = (clock_visible) => {
3661+
let newValue = clock_visible || window.user_preferences.clock_visible;
3662+
3663+
3664+
newValue === 'auto' && is_fullscreen() ? $('#clock').show() : $('#clock').hide();
3665+
3666+
newValue === 'show' && $('#clock').show();
3667+
newValue === 'hide' && $('#clock').hide();
3668+
3669+
if(clock_visible) {
3670+
// save clock_visible to user preferences
3671+
window.mutate_user_preferences({
3672+
clock_visible: newValue
3673+
});
3674+
3675+
return;
3676+
}
3677+
3678+
$('select.change-clock-visible').val(window.user_preferences.clock_visible);
36583679
}

Diff for: src/i18n/translations/en.js

+5
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ const en = {
6060
credits: "Credits",
6161
current_password: "Current Password",
6262
cut: 'Cut',
63+
clock: "Clock",
64+
clock_visible_hide: 'Hide - Always hidden',
65+
clock_visible_show: 'Show - Always visible',
66+
clock_visible_auto: 'Auto - Default, visible only in full-screen mode.',
6367
date_modified: 'Date modified',
6468
delete: 'Delete',
6569
delete_account: "Delete Account",
@@ -198,6 +202,7 @@ const en = {
198202
username: "Username",
199203
username_changed: 'Username updated successfully.',
200204
versions: "Versions",
205+
visibility: 'Visibility',
201206
yes: 'Yes',
202207
yes_release_it: 'Yes, Release It',
203208
you_have_been_referred_to_puter_by_a_friend: "You have been referred to Puter by a friend!",

Diff for: src/i18n/translations/zh.js

+5
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ const zh = {
5050
create_shortcut: "创建快捷方式",
5151
current_password: "当前密码",
5252
cut: '剪切',
53+
clock: "时间",
54+
clock_visible_hide: '隐藏 - 始终隐藏',
55+
clock_visible_show: '显示 - 始终显示',
56+
clock_visible_auto: '自动 - 默认值,全屏显示',
5357
date_modified: '修改日期',
5458
delete: '删除',
5559
delete_permanently: "永久删除",
@@ -157,6 +161,7 @@ const zh = {
157161
upload_here: '在此上传',
158162
username: "用户名",
159163
username_changed: '用户名已成功更新。',
164+
visibility: "可见性",
160165
versions: "版本",
161166
yes_release_it: '是的,释放它',
162167
you_have_been_referred_to_puter_by_a_friend: "您已经被朋友推荐到 Puter!",

Diff for: src/icons/clock.svg

+1
Loading

0 commit comments

Comments
 (0)