diff --git a/tizenbrew-app/TizenBrew/css/style.css b/tizenbrew-app/TizenBrew/css/style.css index ed01ba8..4a8555f 100644 --- a/tizenbrew-app/TizenBrew/css/style.css +++ b/tizenbrew-app/TizenBrew/css/style.css @@ -27,6 +27,7 @@ body { border-radius: 28px 28px 0 0; background-color: #181818; height: 80%; + overflow: hidden; } .header { diff --git a/tizenbrew-app/TizenBrew/index.html b/tizenbrew-app/TizenBrew/index.html index 1e411d6..455001b 100644 --- a/tizenbrew-app/TizenBrew/index.html +++ b/tizenbrew-app/TizenBrew/index.html @@ -1,164 +1,169 @@ - - TizenBrew - + + TizenBrew - + - + - - + - -
-
-
-
TizenBrew Modules
+ -
-

Launch your favorite apps with mods and tweaks on your Tizen device.

+ + + -

Use the GREEN button to access the module manager.

-

Use the BLUE button to access the settings.

-
-
+ +
+
+
+
TizenBrew
+ +
+

-
-

Status

-

Version

+

+

-
- ! - - Error Message Here +
+

Status

+

Version

+
+ +
+ ! -
-
-
-
-
- + Error Message Here +
+ +
+
+
+
+
+
- + +
- + document.querySelector(".error-card").style.display = "flex"; + } + - + break; + + case 404: + location.href = "/moduleManager.html"; + break; + case 406: + location.href = "/settings.html"; + break; + case 38: + canAutoLaunch = false; + break; + } + }; + - + }); + - + - tizen.tvinputdevice.registerKey("Exit"); - - \ No newline at end of file diff --git a/tizenbrew-app/TizenBrew/js/translation.js b/tizenbrew-app/TizenBrew/js/translation.js new file mode 100644 index 0000000..739aebb --- /dev/null +++ b/tizenbrew-app/TizenBrew/js/translation.js @@ -0,0 +1,79 @@ +"use strict"; + +let translations = {}; +let translationLoaded = false; + +const languages = { + "en": "English", + "tr_TR": "Turkish (Türkçe)" +}; + +function loadTranslation(lang) { + const langFile = "lang/" + lang + ".json"; + return new Promise(function (resolve, reject) { + const xhr = new XMLHttpRequest(); + xhr.open("GET", langFile, true); + xhr.onload = function () { + try { + var data = JSON.parse(xhr.responseText); + translations = data; + translationLoaded = true; + window.dispatchEvent(new Event("translationLoaded")); + resolve(translations); + } catch (e) { + reject(e); + } + }; + xhr.onerror = function () { + if (lang !== "en") { + loadTranslation("en").then(resolve).catch(reject); + } else { + resolve(false); + } + }; + xhr.send(); + }); +} + +function template(str, values) { + return str.replace(/\{([\w.]+)\}/g, function (match, key) { + const value = values[key]; + if (key.includes(".")) { + return t(key); + } + return value || match; + }); +} + +function updateTranslations() { + Array.from(document.querySelectorAll("[data-i18n]")).forEach(element => { + const key = element.getAttribute("data-i18n"); + const values = key.split("."); + const templateValues = element.getAttribute("data-i18n-values"); + let parsedTemplateValues = {}; + if (templateValues) { + parsedTemplateValues = templateValues.split("&").reduce((o, i) => { + const splitArray = i.split("="); + o[splitArray[0]] = splitArray[1]; + return o; + }, {}); + } + const string = values.reduce((o, i) => o[i], translations); + element.innerHTML = template(string, parsedTemplateValues); + }); +} + +function t(key, templateValues) { + const values = key.split("."); + const value = values.reduce((o, i) => o[i], translations); + if (templateValues) { + return template(value, templateValues); + } else return value; +} + +window.i18n = { + loadTranslation, + updateTranslations, + template, + t +} \ No newline at end of file diff --git a/tizenbrew-app/TizenBrew/js/wsClient.js b/tizenbrew-app/TizenBrew/js/wsClient.js index ac2f256..1c129b6 100644 --- a/tizenbrew-app/TizenBrew/js/wsClient.js +++ b/tizenbrew-app/TizenBrew/js/wsClient.js @@ -99,7 +99,7 @@ function onMessage(msg) { case 'canLaunchModules': { canLaunchModules = true; - document.getElementById('wsText').innerText = 'Connected to server.'; + document.getElementById('wsText').innerText = t('service.connected'); const autoLaunchService = JSON.parse(localStorage.getItem('autoLaunchService')); diff --git a/tizenbrew-app/TizenBrew/lang/en.json b/tizenbrew-app/TizenBrew/lang/en.json new file mode 100644 index 0000000..cb1fd6b --- /dev/null +++ b/tizenbrew-app/TizenBrew/lang/en.json @@ -0,0 +1,52 @@ +{ + "mainMenu": { + "modules": "Modules", + "description": "Launch your favorite apps with mods and tweaks on your Tizen device.", + "moduleManagerAccess": "Use the {buttons.green} button to access the module manager.", + "settingsAccess": "Use the {buttons.blue} button to access the settings.", + "navigationHelp": "Use the LEFT and RIGHT arrow keys to navigate through the list.", + "autoLaunch": "

AutoLaunch is enabled. Press the [Arrow Up] button to disable AutoLaunch.

" + }, + "service": { + "alreadyRunning": "Service is already running.", + "started": "Service started.", + "connected": "Service connected to the app." + }, + "buttons": { + "red": "RED", + "green": "GREEN", + "yellow": "YELLOW", + "blue": "BLUE" + }, + "errors": { + "serviceDidntConnectYet": "You can't launch modules while the service hasn't connected to the app yet." + }, + "moduleManager": { + "confirmDelete": "Do you want to remove {packageName}?", + "addNPM": "Add NPM Module", + "addNPMDesc": "This is primarily for production and for users.", + "addGH": "Add GitHub Module", + "addGHDesc": "This is primarily for development and for developers.", + "addModule": "Add Module", + "moduleName": "Module Name (For {type}):" + }, + "settings": { + "autolaunch": "Autolaunch Settings", + "autolaunchDesc": "Launch your favorite module automatically when you launch TizenBrew.", + "autolaunchService": "Autolaunch Settings for services", + "autolaunchServiceDesc": "Launch your favorite service automatically when you launch TizenBrew.", + "useragent": "User-Agent Settings", + "useragentDesc": "Change the User-Agent of TizenBrew modules for some effects like fixing the UI in TizenTube.", + "enableAutolaunchPrompt": "Do you want to set {packageName} to launch on start?", + "disableAutolaunchPrompt": "Do you want to disable autolaunch?", + "disableAutolaunch": "Disable Autolaunch", + "noModules": "No modules found.", + "default": "Default", + "worksOnTizen": "(Works on Tizen {version}+)", + "uaBasedOnDevice": "User-Agent based on Device (should bring some features)", + "setUaTo": "Do you want to set the User-Agent to {userAgent}?", + "uaNegativeEffects": "Note that while this could have positive effects, there could also be negative effects.", + "language": "Language Settings", + "languageDesc": "Change the language of the app." + } +} \ No newline at end of file diff --git a/tizenbrew-app/TizenBrew/lang/tr_TR.json b/tizenbrew-app/TizenBrew/lang/tr_TR.json new file mode 100644 index 0000000..719b220 --- /dev/null +++ b/tizenbrew-app/TizenBrew/lang/tr_TR.json @@ -0,0 +1,52 @@ +{ + "mainMenu": { + "modules": "Modülleri", + "description": "Tizen cihazınızda modlar ve özel ayarlarla favori uygulamalarınızı başlatın.", + "moduleManagerAccess": "{buttons.green} butonunu kullanarak modül yöneticisine erişebilirsin.", + "settingsAccess": "{buttons.blue} butonunu kullanarak ayarlara erişebilirsin.", + "navigationHelp": "SAĞ ve SOL ok tuşlarını kullanarak listede gezinebilirsin.", + "autoLaunch": "

Otomatik Başlatma etkin. Otomatik Başlatmayı devre dışı bırakmak için [Yukarı Ok] tuşuna basın.

" + }, + "service": { + "alreadyRunning": "Servis zaten çalışıyor.", + "started": "Servis başlatıldı.", + "connected": "Servis uygulamaya bağlandı." + }, + "buttons": { + "red": "KIRMIZI", + "green": "YEŞİL", + "yellow": "SARI", + "blue": "MAVİ" + }, + "errors": { + "serviceDidntConnectYet": "Servis henüz uygulamaya bağlanmadığı sürece modülleri başlatamazsınız." + }, + "moduleManager": { + "confirmDelete": "{packageName} modülünü kaldırmak istiyor musun?", + "addNPM": "NPM Modülü Ekle", + "addNPMDesc": "Bu öncelikle üretim ve kullanıcılar içindir.", + "addGH": "GitHub Modülü Ekle", + "addGHDesc": "Bu öncelikle geliştirme ve geliştiriciler içindir.", + "addModule": "Modül Ekle", + "moduleName": "Modül Adı ({type} için):" + }, + "settings": { + "autolaunch": "Otomatik Başlatma Ayarları", + "autolaunchDesc": "TizenBrew'u başlattığınızda favori modülünüzü otomatik olarak başlatın.", + "autolaunchService": "Servisler için Otomatik Başlatma Ayarları", + "autolaunchServiceDesc": "TizenBrew'u başlattığınızda favori Servisler otomatik olarak başlatın.", + "useragent": "User-Agent Ayarları", + "useragentDesc": "TizenBrew modüllerinin User-Agent'ını değiştirin, örneğin TizenTube'da UI'yi düzeltmek gibi bazı etkiler için.", + "enableAutolaunchPrompt": "{packageName} paketini başlangıçta başlatmak istiyor musun?", + "disableAutolaunchPrompt": "Otomatik başlatmayı devre dışı bırakmak istiyor musun?", + "disableAutolaunch": "Otomatik Başlatmayı Devre Dışı Bırak", + "noModules": "Modül bulunamadı.", + "default": "Varsayılan", + "worksOnTizen": "(Tizen {version} ve üzerinde çalışır)", + "uaBasedOnDevice": "Cihaza Dayalı User-Agent (bazı özellikler getirebilir)", + "setUaTo": "User-Agent'ı {userAgent} olarak ayarlamak istiyor musun?", + "uaNegativeEffects": "Bunun olumlu etkileri olabileceği gibi, olumsuz etkileri de olabileceğini unutmayın.", + "language": "Dil Ayarları", + "languageDesc": "Uygulamanın dilini değiştirin." + } +} \ No newline at end of file diff --git a/tizenbrew-app/TizenBrew/moduleManager.html b/tizenbrew-app/TizenBrew/moduleManager.html index 32b5281..20cb69b 100644 --- a/tizenbrew-app/TizenBrew/moduleManager.html +++ b/tizenbrew-app/TizenBrew/moduleManager.html @@ -1,179 +1,213 @@ - - TizenBrew - - - - - - -
-
-
-
TizenBrew Modules
-
-

Launch your favorite apps with mods and tweaks on your Tizen device.

-

Use the GREEN button to go back to module launcher.

-
+ + TizenBrew + + + + + + + + + +
+
+
+
TizenBrew
+ +
+

+ +

+

-

Status

-
-
- ! - Error Message Here
-
-
-
-
+

Status

+
+
+ ! + Error Message Here +
+
+
+
+
- -
+
+
- + - - - + - + + window.selectedItem = document.querySelector(".card"); + window.currentRow = selectedItem.parentElement.parentElement; + const input = document.getElementById("appName"); + input.focus(); + input.onblur = () => { + var modules = JSON.parse(localStorage.getItem("modules")); + modules.push({ + name: input.value, + type + }); + localStorage.setItem("modules", JSON.stringify(modules)); + location.reload(); + }; + } + + \ No newline at end of file diff --git a/tizenbrew-app/TizenBrew/settings.html b/tizenbrew-app/TizenBrew/settings.html index 979a036..f8acf4d 100644 --- a/tizenbrew-app/TizenBrew/settings.html +++ b/tizenbrew-app/TizenBrew/settings.html @@ -6,6 +6,18 @@ + + @@ -13,10 +25,14 @@
-
TizenBrew Modules
+
TizenBrew
+
-

Launch your favorite apps with mods and tweaks on your Tizen device.

-

Use the BLUE button to go back to module launcher.

+

+ +

+

Status

@@ -29,25 +45,28 @@
-

Autolaunch Settings

-

Launch your favorite module automatically when you launch TizenBrew.

+

+

-

Autolaunch Settings for services

-

Launch your favorite service automatically when you launch TizenBrew.

+

+

-

User-Agent Settings

-

Change the User-Agent of TizenBrew modules for some effects like fixing the UI on TizenBrew. -

+

+

+
+
+

+

@@ -79,6 +98,7 @@

Change the User-Agent of TizenBrew modules for some effects like fixing the selectedItem.classList.remove("selected"); selectedItem.previousElementSibling.classList.add("selected"); selectedItem = selectedItem.previousElementSibling; + selectedItem.focus(); currentRow.setAttribute("data-selecteditem", indexOf(currentRow.lastElementChild.children, selectedItem).toString()); } break; @@ -87,6 +107,7 @@

Change the User-Agent of TizenBrew modules for some effects like fixing the selectedItem.classList.remove("selected"); selectedItem.nextElementSibling.classList.add("selected"); selectedItem = selectedItem.nextElementSibling; + selectedItem.focus(); currentRow.setAttribute("data-selecteditem", indexOf(currentRow.lastElementChild.children, selectedItem).toString()); } break; @@ -95,7 +116,9 @@

Change the User-Agent of TizenBrew modules for some effects like fixing the var isForService = selectedItem.getAttribute("data-isForService"); var packageType = selectedItem.getAttribute("data-packagetype"); if (packageName != null) { - var hasConfirmined = confirm(`Do you want to set ${packageName} to launch on start?`); + var hasConfirmined = confirm(window.i18n.t('settings.enableAutolaunchPrompt', { + packageName + })); if (hasConfirmined && isForService === 'false') { localStorage.setItem('autoLaunch', JSON.stringify({ name: packageName, type: packageType })); location.reload(); @@ -109,14 +132,20 @@

Change the User-Agent of TizenBrew modules for some effects like fixing the loadModules(true); } else if (selectedItem.id == "userAgent") { setUserAgentMenu(); + } else if (selectedItem.id == "language") { + languageMenu(); + } else if (selectedItem.id == "languageSelection") { + var lang = selectedItem.getAttribute("data-lang"); + localStorage.setItem('language', lang); + location.reload(); } else if (selectedItem.id == "disableAutoLaunch") { - var hasConfirmined = confirm(`Do you want to disable autolaunch?`); + var hasConfirmined = confirm(window.i18n.t('settings.disableAutolaunchPrompt')); if (hasConfirmined) { localStorage.removeItem('autoLaunch'); location.reload(); } } else if (selectedItem.id == "disableAutoLaunchService") { - var hasConfirmined = confirm(`Do you want to disable autolaunch?`); + var hasConfirmined = confirm(window.i18n.t('settings.disableAutolaunchPrompt')); if (hasConfirmined) { localStorage.removeItem('autoLaunchService'); location.reload(); @@ -140,7 +169,7 @@

Change the User-Agent of TizenBrew modules for some effects like fixing the chipsetModel = buildString.split("-")[3]; deviceName = `_TV_${chipsetModel}`; var newUserAgent = `${window.navigator.userAgent}, ${deviceName}/${firmware} (Samsung, ${model}, ${connectionType})`; - userAgentWarnMenu(newUserAgent, false); + userAgentWarnMenu(newUserAgent, false); } break; @@ -160,6 +189,14 @@

Change the User-Agent of TizenBrew modules for some effects like fixing the \ No newline at end of file