Skip to content

Commit e7fddba

Browse files
committed
Improve translations and dialogs
1 parent 5998f02 commit e7fddba

File tree

9 files changed

+159
-20
lines changed

9 files changed

+159
-20
lines changed

_locales/de/messages.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
"useDefaultProfile": {
1212
"message": "Standardbrowserprofil verwenden"
1313
},
14+
"uiOk": {
15+
"message": "Ok"
16+
},
17+
"uiCancel": {
18+
"message": "Abbrechen"
19+
},
1420
"uiURL": {
1521
"message": "URL"
1622
},
@@ -49,5 +55,14 @@
4955
},
5056
"warningEmptyName": {
5157
"message": "Der Name darf nicht leer sein"
58+
},
59+
"warningExceedCommandSize": {
60+
"message": "Maximale Befehlsgröße überschritten. Bitte geben Sie die URL oder den Namen der Website kurz an."
61+
},
62+
"uiDialogDesktopShortcutsTitle": {
63+
"message": "Desktop-Verknüpfungen"
64+
},
65+
"uiDialogDesktopShortcutsDescription": {
66+
"message": "Die Erweiterung erstellt Desktop-Verknüpfungen für den einfachen Zugriff auf Ihre SSB-Sites.\nDesktop-Verknüpfungen haben keine Ausführungsberechtigung, bis Sie die Berechtigung erteilen. Heruntergeladene Dateien werden vom Betriebssystem erst erkannt, wenn die Dateierweiterung „.download“ in ihren Namen gelöscht wird. Dies ist auch eine Sicherheitsmaßnahme, die von Firefox gefordert wird."
5267
}
5368
}

_locales/en/messages.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
"useDefaultProfile": {
1212
"message": "Use Default Browser Profile"
1313
},
14+
"uiOk": {
15+
"message": "Ok"
16+
},
17+
"uiCancel": {
18+
"message": "Cancel"
19+
},
1420
"uiURL": {
1521
"message": "URL"
1622
},
@@ -49,5 +55,14 @@
4955
},
5056
"warningEmptyName": {
5157
"message": "Name cannot be empty"
58+
},
59+
"warningExceedCommandSize": {
60+
"message": "Exceeded maximum command size. Please short the URL or Name of Website."
61+
},
62+
"uiDialogDesktopShortcutsTitle": {
63+
"message": "Desktop Shortcuts"
64+
},
65+
"uiDialogDesktopShortcutsDescription": {
66+
"message": "The extension will create desktop shortcuts to access your SSB sites easily.\nDesktop shortcuts would be not have execute permission until you give the permission. Downloaded files will not be recognized by the OS until the \".download\" file extension in their names is deleted. It's also a security measure that required by Firefox."
5267
}
5368
}

_locales/es/messages.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
"useDefaultProfile": {
1212
"message": "Usar perfil de navegador predeterminado"
1313
},
14+
"uiOk": {
15+
"message": "Aceptar"
16+
},
17+
"uiCancel": {
18+
"message": "Cancelar"
19+
},
1420
"uiURL": {
1521
"message": "URL"
1622
},
@@ -49,5 +55,14 @@
4955
},
5056
"warningEmptyName": {
5157
"message": "El nombre no puede estar vacío"
58+
},
59+
"warningExceedCommandSize": {
60+
"message": "Se superó el tamaño máximo de comando. Acorte la URL o el nombre del sitio web."
61+
},
62+
"uiDialogDesktopShortcutsTitle": {
63+
"message": "Accesos directos del escritorio"
64+
},
65+
"uiDialogDesktopShortcutsDescription": {
66+
"message": "La extensión creará accesos directos en el escritorio para acceder fácilmente a sus sitios SSB.\nLos accesos directos en el escritorio no tendrán permiso de ejecución hasta que usted los otorgue. El sistema operativo no reconocerá los archivos descargados hasta que se elimine la extensión de archivo \".download\" en sus nombres. También es una medida de seguridad requerida por Firefox."
5267
}
5368
}

_locales/ru/messages.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
"useDefaultProfile": {
1212
"message": "Использовать профиль браузера по умолчанию"
1313
},
14+
"uiOk": {
15+
"message": "ок"
16+
},
17+
"uiCancel": {
18+
"message": "Отменить"
19+
},
1420
"uiURL": {
1521
"message": "URL"
1622
},
@@ -49,5 +55,14 @@
4955
},
5056
"warningEmptyName": {
5157
"message": "Имя не может быть пустым"
58+
},
59+
"warningExceedCommandSize": {
60+
"message": "Превышен максимальный размер команды. Сократите URL-адрес или имя веб-сайта."
61+
},
62+
"uiDialogDesktopShortcutsTitle": {
63+
"message": "Ярлыки на рабочем столе"
64+
},
65+
"uiDialogDesktopShortcutsDescription": {
66+
"message": "Расширение создаст ярлыки на рабочем столе для быстрого доступа к вашим сайтам SSB.\nЯрлыки на рабочем столе не будут иметь разрешения на выполнение, пока вы не дадите разрешение. Загруженные файлы не будут распознаваться операционной системой до тех пор, пока в их именах не будет удалено расширение файла «.download». Это также мера безопасности, необходимая Firefox."
5267
}
5368
}

_locales/tr/messages.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111
"useDefaultProfile": {
1212
"message": "Varsayılan Tarayıcı Profilini Kullan"
1313
},
14+
"uiOk": {
15+
"message": "Tamam"
16+
},
17+
"uiCancel": {
18+
"message": "İptal"
19+
},
1420
"uiURL": {
1521
"message": "URL"
1622
},
@@ -49,5 +55,14 @@
4955
},
5056
"warningEmptyName": {
5157
"message": "İsim boş bırakılamaz"
58+
},
59+
"warningExceedCommandSize": {
60+
"message": "Maksimum komut sınırı aşıldı. Lütfen Web Sitesinin URL'ini veya İsmini kısaltın."
61+
},
62+
"uiDialogDesktopShortcutsTitle": {
63+
"message": "Masaüstü Kısayolları"
64+
},
65+
"uiDialogDesktopShortcutsDescription": {
66+
"message": "Uzantı, SSB sitelerinize kolayca erişmenizi sağlayacak masaüstü kısayolları oluşturacaktır.\nSiz izin verene kadar masaüstü kısayollarının yürütme izni olmayacaktır. İndirilen dosyalar, adlarındaki \".download\" dosya uzantısı silinene kadar işletim sistemi tarafından tanınmayacaktır. Bu aynı zamanda Firefox'un gerektirdiği bir güvenlik önlemidir."
5267
}
5368
}

comparison_chart.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
| Works with forks of Firefox | Yes | Maybe(5) |
1616
| Auto-creation of Desktop Entry support | Partial(6)| Yes |
1717

18-
> If something is wrong or changed about this table, please open a issue.
18+
> If something is wrong or changed about this table, please open a issue.
1919
2020
> PWAsForFirefox extension has more integration with system, however their native executable (runtime) dependency and their workarounds is increasing the possibility of profile/extension corruption. FireSSB is using standarts of WebExtension, so it will be more stable.
2121
@@ -26,9 +26,9 @@
2626
> 3: Not supported [PWAsForFirefox#354](https://github.com/filips123/PWAsForFirefox/issues/354)
2727
2828
> 4: FireSSB is not depended to a native depency or some quirks. All APIs that used by FireSSB is documentated in WebExtension Specification. So it can be ported easily any browser that supports WebExtension.
29-
>
29+
>
3030
> PWAsForFirefox is heavily depended browser behaviour and native depency. [PWAsForFirefox#475](https://github.com/filips123/PWAsForFirefox/issues/475)
3131
3232
> 5: Firefox forks can be require some workaround [PWAsForFirefox#357](https://github.com/filips123/PWAsForFirefox/issues/357)
3333
34-
> 6: Desktop Entries can be created by clicking "Create Desktop File" on Linux. (Will not add to application list due to lack of FileSystem permissions of extensions.). No support for other OSs yet.
34+
> 6: Desktop Entries can be created by clicking "Create Desktop File" on Linux and Windows. (Will not add to application list due to lack of FileSystem permissions of extensions.). No support for other OSs yet.

css/index.css

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ body {
3232
box-sizing: border-box;
3333
transition-duration: 50ms;
3434
color: var(--font-color);
35+
font-size: 18px;
3536
}
3637

3738
#warning {
@@ -61,6 +62,10 @@ body {
6162
word-wrap: anywhere;
6263
}
6364

65+
body[dialog_open] {
66+
height: 235px;
67+
}
68+
6469
#dialog[open] {
6570
position: fixed;
6671
top: 0;
@@ -77,6 +82,10 @@ body {
7782
gap: 10px;
7883
}
7984

85+
#dialog[open][dialog_type="confirm"] #dialog-input {
86+
display: none;
87+
}
88+
8089
#dialog .control-container {
8190
display: flex;
8291
flex-direction: row;
@@ -97,6 +106,10 @@ body {
97106
font-size: 24px;
98107
}
99108

109+
#dialog #dialog-description {
110+
overflow-y: auto;
111+
}
112+
100113
#input {
101114
display: flex;
102115
flex-direction: column;

index.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515

1616
<div id="dialog">
1717
<div id="dialog-title"></div>
18-
<div><input type="url" id="dialog-input"/></div>
18+
<div id="dialog-description">It's description.</div>
19+
<div><input type="name" id="dialog-input"/></div>
20+
<div style="flex-grow: 1;"></div>
1921
<div class="control-container"><button id="dialog-ok">OK</button><button id="dialog-cancel">Cancel</button></div>
2022
</div>
2123

js/index.js

Lines changed: 65 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ var components = {
1212
_: document.querySelector("#dialog"),
1313
title: document.querySelector("#dialog #dialog-title"),
1414
input: document.querySelector("#dialog #dialog-input"),
15+
description: document.querySelector("#dialog #dialog-description"),
1516
ok: document.querySelector("#dialog #dialog-ok"),
1617
cancel: document.querySelector("#dialog #dialog-cancel"),
1718
resolve: null
@@ -61,9 +62,9 @@ async function active_tab_info() {
6162
};
6263

6364
function create_ssb_url() {
64-
let the_url = location.origin +
65+
let the_url = location.origin +
6566
"/ssb.html?url=" + encodeURIComponent(components.input.url.value) +
66-
"&name=" + encodeURIComponent(components.input.name.value) +
67+
"&name=" + encodeURIComponent(components.input.name.value) +
6768
"&incognito=" + encodeURIComponent(components.input.incognito.checked);
6869
the_url = the_url.replaceAll("%","=-=");
6970
return the_url;
@@ -101,16 +102,32 @@ function download_file(url, name){ // Download helper to download desktop files
101102
link.remove();
102103
};
103104

104-
function modern_prompt(title, pretext = "", placeholder = ""){
105+
function modern_dialog({title="", pretext="", placeholder="", type="prompt", description=""}){
105106
components.dialog._.setAttribute("open", true);
107+
components.dialog._.setAttribute("dialog_type", type);
108+
document.body.setAttribute("dialog_open", true);
106109
return new Promise((resolve) => {
107110
components.dialog.title.innerText = title;
108-
components.dialog.input.value = pretext;
109-
components.dialog.input.placeholder = placeholder;
111+
components.dialog.description.innerText = description;
112+
components.dialog.description.style.display = ["", "none"][Number(description == "")];
113+
console.warn(title);
114+
console.warn(type == "prompt");
115+
if(type == "prompt"){
116+
components.dialog.input.value = pretext;
117+
components.dialog.input.placeholder = placeholder;
118+
};
119+
components.dialog.ok.innerText = browser.i18n.getMessage("uiOk");
120+
components.dialog.cancel.innerText = browser.i18n.getMessage("uiCancel");
110121
components.dialog.resolve = (content) => {
111122
if(components.dialog._.hasAttribute("open")){
112123
components.dialog._.removeAttribute("open");
113124
};
125+
if(components.dialog._.hasAttribute("dialog_type")){
126+
components.dialog._.removeAttribute("dialog_type");
127+
};
128+
if(document.body.hasAttribute("dialog_open")){
129+
document.body.removeAttribute("dialog_open");
130+
};
114131
resolve(content);
115132
};
116133
});
@@ -119,13 +136,25 @@ function modern_prompt(title, pretext = "", placeholder = ""){
119136
// Event Listeners
120137

121138
components.dialog.ok.addEventListener("click", () => {
122-
components.dialog.resolve(
123-
components.dialog.input.value
124-
);
139+
let type = components.dialog._.getAttribute("dialog_type");
140+
if(type == "prompt") {
141+
components.dialog.resolve(
142+
components.dialog.input.value
143+
);
144+
} else if (type == "confirm") {
145+
components.dialog.resolve(true);
146+
}
147+
components.dialog.resolve(null); // Fallback
125148
});
126149

127150
components.dialog.cancel.addEventListener("click", () => {
128-
components.dialog.resolve(false);
151+
let type = components.dialog._.getAttribute("dialog_type");
152+
if(type == "prompt") {
153+
components.dialog.resolve(false);
154+
} else if (type == "confirm") { // Yes, i know "prompt" and "confirm" has same code however wrong abstraction is worse than having duplication.
155+
components.dialog.resolve(false);
156+
}
157+
components.dialog.resolve(null); // Fallback
129158
});
130159

131160
components.controls.autofill.addEventListener("click", async function() {
@@ -167,17 +196,27 @@ components.controls.open_ssb.addEventListener("click", async function() {
167196
});
168197

169198
components.controls.add_desktop_entry_windows.addEventListener("click", async function() {
199+
let is_user_informed = localStorage.user_informed_desktop_shortcuts === "true" ?? "false";
200+
if(!is_user_informed){
201+
let is_user_confirmed = await modern_dialog({title: browser.i18n.getMessage("uiDialogDesktopShortcutsTitle"), "description": browser.i18n.getMessage("uiDialogDesktopShortcutsDescription"), type: "confirm"});
202+
if(!is_user_confirmed) {
203+
localStorage.user_informed_desktop_shortcuts = "false";
204+
return;
205+
} else {
206+
localStorage.user_informed_desktop_shortcuts = "true";
207+
};
208+
};
170209
if(components.input.url.value == "") return show_warning("warningEmptyURL");
171210
if(components.input.name.value == "") return show_warning("warningEmptyName");
172211

173212
let name = sanitize_input(components.input.name.value);
174213
let ssb_url = create_ssb_url();
175214
let previous_application = localStorage.previous_firefox_application ?? "firefox";
176-
let application = await modern_prompt(browser.i18n.getMessage("browserCommandName"), previous_application, "");
215+
let application = await modern_dialog({title:browser.i18n.getMessage("browserCommandName"), pretext:previous_application});
177216
if(application === false) return;
178217
application = sanitize_input(application);
179218
localStorage.previous_firefox_application = application;
180-
let profile = await modern_prompt(browser.i18n.getMessage("profile"), "", browser.i18n.getMessage("useDefaultProfile"));
219+
let profile = await modern_dialog({title:browser.i18n.getMessage("profile"), placeholder:browser.i18n.getMessage("useDefaultProfile")});
181220
if(profile === false) return;
182221
profile = sanitize_input(profile, true);
183222
if(profile != "") profile = "-P " + profile;
@@ -278,7 +317,7 @@ components.controls.add_desktop_entry_windows.addEventListener("click", async fu
278317
let allowed_app_command_len = 618;
279318

280319
let app_command = `${application} ${profile} -new-window "${ssb_url}"`;
281-
if(app_command.length>=allowed_app_command_len) return show_warning("exceedCommandSize");
320+
if(app_command.length>=allowed_app_command_len) return show_warning("warningExceedCommandSize");
282321

283322
let lnk_mid_of_file = (app_command.padEnd(allowed_app_command_len, "\x00").split("").join("\x00")+"\x00").split("").map(x=>x.charCodeAt(0));
284323

@@ -292,17 +331,27 @@ components.controls.add_desktop_entry_windows.addEventListener("click", async fu
292331
});
293332

294333
components.controls.add_desktop_entry_linux.addEventListener("click", async function() {
295-
if(components.input.url.value == "") return show_warning("warningEmptyURL");
296-
if(components.input.name.value == "") return show_warning("warningEmptyName");
334+
let is_user_informed = localStorage.user_informed_desktop_shortcuts === "true" ?? "false";
335+
if(!is_user_informed){
336+
let is_user_confirmed = await modern_dialog({title: browser.i18n.getMessage("uiDialogDesktopShortcutsTitle"), "description": browser.i18n.getMessage("uiDialogDesktopShortcutsDescription"), type: "confirm"});
337+
if(!is_user_confirmed) {
338+
localStorage.user_informed_desktop_shortcuts = "false";
339+
return;
340+
} else {
341+
localStorage.user_informed_desktop_shortcuts = "true";
342+
};
343+
};
344+
if(components.input.url.value == "") return show_warning("warningEmptyURL");
345+
if(components.input.name.value == "") return show_warning("warningEmptyName");
297346

298347
let name = sanitize_input(components.input.name.value);
299348
let ssb_url = create_ssb_url();
300349
let previous_application = localStorage.previous_firefox_application ?? "firefox";
301-
let application = await modern_prompt(browser.i18n.getMessage("browserCommandName"), previous_application, "");
350+
let application = await modern_dialog({title:browser.i18n.getMessage("browserCommandName"), pretext:previous_application});
302351
if(application === false) return;
303352
application = sanitize_input(application);
304353
localStorage.previous_firefox_application = application;
305-
let profile = await modern_prompt(browser.i18n.getMessage("profile"), "", browser.i18n.getMessage("useDefaultProfile"));
354+
let profile = await modern_dialog({title:browser.i18n.getMessage("profile"), placeholder:browser.i18n.getMessage("useDefaultProfile")});
306355
if(profile === false) return;
307356
profile = sanitize_input(profile, true);
308357
if(profile != "") profile = "-P " + profile;

0 commit comments

Comments
 (0)