From 7ef7cf24e97eb8273cb29e5519e828a4a11e825e Mon Sep 17 00:00:00 2001 From: RainyXeon Date: Sun, 7 Jul 2024 17:03:20 +0700 Subject: [PATCH] add: error history modal for easier to view log and copy --- module/build.gradle.kts | 5 ++++ module/src/customize.sh | 5 ++++ webroot/assets/content.svg | 1 + webroot/assets/error.svg | 1 + webroot/css/index.css | 23 ++++++++++++++-- webroot/index.html | 36 +++++++++++++++++++++++- webroot/js/language.js | 12 ++++++++ webroot/js/light.icon.js | 40 +++++++++++++++++++++++++++ webroot/js/modal/errorHistory.js | 30 ++++++++++++++++++++ webroot/js/restoreError.js | 9 ++++++ webroot/js/theme.js | 47 +++++++++++--------------------- webroot/lang/en_US.json | 4 +++ webroot/lang/ja_JP.json | 4 +++ webroot/lang/pt_BR.json | 4 +++ webroot/lang/ro_RO.json | 4 +++ webroot/lang/ru_RU.json | 4 +++ webroot/lang/vi_VN.json | 4 +++ 17 files changed, 199 insertions(+), 34 deletions(-) create mode 100644 webroot/assets/content.svg create mode 100644 webroot/assets/error.svg create mode 100644 webroot/js/light.icon.js create mode 100644 webroot/js/modal/errorHistory.js create mode 100644 webroot/js/restoreError.js diff --git a/module/build.gradle.kts b/module/build.gradle.kts index 3d7eb36..4133619 100644 --- a/module/build.gradle.kts +++ b/module/build.gradle.kts @@ -168,6 +168,8 @@ androidComponents.onVariants { variant -> set.add(Pair(root.file("webroot/js/kernelsu.js").asFile, null)) set.add(Pair(root.file("webroot/js/theme.js").asFile, null)) set.add(Pair(root.file("webroot/js/language.js").asFile, null)) + set.add(Pair(root.file("webroot/js/light.icon.js").asFile, null)) + set.add(Pair(root.file("webroot/js/restoreError.js").asFile, null)) set.add(Pair(root.file("webroot/js/list/module.js").asFile, null)) set.add(Pair(root.file("webroot/js/list/settings.js").asFile, null)) @@ -181,6 +183,7 @@ androidComponents.onVariants { variant -> set.add(Pair(root.file("webroot/lang/vi_VN.json").asFile, null)) set.add(Pair(root.file("webroot/js/modal/language.js").asFile, null)) + set.add(Pair(root.file("webroot/js/modal/errorHistory.js").asFile, null)) set.add(Pair(root.file("webroot/css/index.css").asFile, null)) @@ -194,6 +197,8 @@ androidComponents.onVariants { variant -> set.add(Pair(root.file("webroot/assets/settings.svg").asFile, null)) set.add(Pair(root.file("webroot/assets/close.svg").asFile, null)) set.add(Pair(root.file("webroot/assets/lang.svg").asFile, null)) + set.add(Pair(root.file("webroot/assets/content.svg").asFile, null)) + set.add(Pair(root.file("webroot/assets/error.svg").asFile, null)) sig.initSign(privKey) set.forEach { it.first.sha(it.second) } val signFile = root.file(name).asFile diff --git a/module/src/customize.sh b/module/src/customize.sh index ea45d4a..6e456ac 100644 --- a/module/src/customize.sh +++ b/module/src/customize.sh @@ -123,6 +123,8 @@ extract "$ZIPFILE" 'webroot/js/language.js' "$MODPATH/webroot/js" true extract "$ZIPFILE" 'webroot/js/list/module.js' "$MODPATH/webroot/js/list" true extract "$ZIPFILE" 'webroot/js/list/settings.js' "$MODPATH/webroot/js/list" true extract "$ZIPFILE" 'webroot/js/list/language.js' "$MODPATH/webroot/js/list" true +extract "$ZIPFILE" 'webroot/js/list/light.icon.js' "$MODPATH/webroot/js/list" true +extract "$ZIPFILE" 'webroot/js/list/restoreError.js' "$MODPATH/webroot/js/list" true extract "$ZIPFILE" 'webroot/lang/en_US.json' "$MODPATH/webroot/lang" true extract "$ZIPFILE" 'webroot/lang/ja_JP.json' "$MODPATH/webroot/lang" true @@ -132,6 +134,7 @@ extract "$ZIPFILE" 'webroot/lang/ru_RU.json' "$MODPATH/webroot/lang" true extract "$ZIPFILE" 'webroot/lang/vi_VN.json' "$MODPATH/webroot/lang" true extract "$ZIPFILE" 'webroot/js/modal/language.js' "$MODPATH/webroot/js/modal" true +extract "$ZIPFILE" 'webroot/js/modal/errorHistory.js' "$MODPATH/webroot/js/modal" true extract "$ZIPFILE" 'webroot/css/index.css' "$MODPATH/webroot/css" true @@ -145,6 +148,8 @@ extract "$ZIPFILE" 'webroot/assets/expand.svg' "$MODPATH/webroot/assets" true extract "$ZIPFILE" 'webroot/assets/settings.svg' "$MODPATH/webroot/assets" true extract "$ZIPFILE" 'webroot/assets/close.svg' "$MODPATH/webroot/assets" true extract "$ZIPFILE" 'webroot/assets/lang.svg' "$MODPATH/webroot/assets" true +extract "$ZIPFILE" 'webroot/assets/content.svg' "$MODPATH/webroot/assets" true +extract "$ZIPFILE" 'webroot/assets/error.svg' "$MODPATH/webroot/assets" true if [ "$ARCH" = "x86" ] || [ "$ARCH" = "x64" ]; then ui_print "- Extracting x86 libraries" diff --git a/webroot/assets/content.svg b/webroot/assets/content.svg new file mode 100644 index 0000000..6d6f8c9 --- /dev/null +++ b/webroot/assets/content.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webroot/assets/error.svg b/webroot/assets/error.svg new file mode 100644 index 0000000..9a02236 --- /dev/null +++ b/webroot/assets/error.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/webroot/css/index.css b/webroot/css/index.css index 1135e07..2b47d23 100644 --- a/webroot/css/index.css +++ b/webroot/css/index.css @@ -137,7 +137,7 @@ a { padding-top: 1em; padding-bottom: 1em; border-radius: 30px; - transition: transform 0.07s ease-in-out; + transition: transform 0.05s ease-in-out; background-color: var(--button); } @@ -172,13 +172,32 @@ a { } .element_animation { - transition: transform 0.15 ease-in-out; + transition: transform 0.15s ease-in-out; } .element_animation:active { transform: scale(95%) } +.card_animation { + transition: transform 0.05s ease-in-out; +} + +.card_animation:active { + transform: scale(95%) +} + +.errorh_textarea { + resize: none; + height: 100%; + width: 100%; + border: none; + outline: none; + font-size: 16px; + padding-bottom: 25px; + font-family: monospace, monospace; +} + /* Card type */ .bright { border: 5px solid var(--bright); diff --git a/webroot/index.html b/webroot/index.html index a5e4bce..1c49c41 100644 --- a/webroot/index.html +++ b/webroot/index.html @@ -11,6 +11,8 @@ + + @@ -19,7 +21,7 @@
- +
@@ -35,6 +37,25 @@
+ +
+
+
+
+ +
+
+
+

Error History

+
+ +
+
+
+ +
+
+
ReZygisk
@@ -141,5 +162,18 @@
+ +
+ +
+
+ +
+
+ Error History +
+
+
+ \ No newline at end of file diff --git a/webroot/js/language.js b/webroot/js/language.js index f978aa5..b1a1c11 100644 --- a/webroot/js/language.js +++ b/webroot/js/language.js @@ -16,6 +16,11 @@ const daemon32_exit_button = document.getElementById('daemon32_exit_button') const daemon64_stop_button = document.getElementById('daemon64_stop_button') const daemon64_start_button = document.getElementById('daemon64_start_button') const daemon64_exit_button = document.getElementById('daemon64_exit_button') +/* INFO: error history button card */ +const errorh_card_title = document.getElementById('errorh_card_title') +/* INFO: error history modal */ +const errorh_modal_title = document.getElementById('errorh_modal_title') +const errorh_panel = document.getElementById('errorh_panel') /* INFO: lang modal */ const lang_modal_title = document.getElementById('lang_modal_title') /* INFO: Variable fields */ @@ -55,6 +60,13 @@ export async function setNewLanguage(locate, initialize) { /* INFO: lang modal */ lang_modal_title.innerHTML = new_lang.langModal.header + /* INFO: error history button card */ + errorh_card_title.innerHTML = new_lang.errorHistory.header + + /* INFO: error history modal */ + errorh_modal_title.innerHTML = new_lang.errorHistory.header + errorh_panel.placeholder = new_lang.errorHistory.placeholder + /* INFO: Translate variables */ switch (rezygisk_state.innerHTML.replace(/(\r\n|\n|\r)/gm,"").trim()) { case old_translations.infoCard.status.ok: { diff --git a/webroot/js/light.icon.js b/webroot/js/light.icon.js new file mode 100644 index 0000000..4f1c9d2 --- /dev/null +++ b/webroot/js/light.icon.js @@ -0,0 +1,40 @@ +export const light_icon = ` + + + +` +export const light_module_icon = ` + + + +` +export const light_expand_icon = ` + + + +` +export const light_settings_icon = ` + + + +` +export const light_lang_icon = ` + + + +` +export const light_close_icon = ` + + + +` +export const light_logs_icon = ` + + + +` +export const light_copy_icon = ` + + + +` \ No newline at end of file diff --git a/webroot/js/modal/errorHistory.js b/webroot/js/modal/errorHistory.js new file mode 100644 index 0000000..0ae4940 --- /dev/null +++ b/webroot/js/modal/errorHistory.js @@ -0,0 +1,30 @@ +const button = document.getElementById('rezygisk_errorh') +const copy_button = document.getElementById('errorh_copy') +const target = document.getElementById('errorh_modal') +const close_button = document.getElementById('errorh_modal_close') +const panel = document.getElementById('errorh_panel') + +let sys_module_mode = localStorage.getItem('/cache/modal/error_history/state') +sys_module_mode = setData('closed') + +button.addEventListener('click', () => { + target.style.top = '0%' + + sys_module_mode = setData('opened') +}) + +close_button.addEventListener('click', () => { + target.style.top = '100%' + + sys_module_mode = setData('closed') +}) + +copy_button.addEventListener('click', () => { + navigator.clipboard.writeText(panel.innerHTML); +}) + +function setData(mode) { + localStorage.setItem('/cache/modal/error_history/state', mode) + + return localStorage.getItem('/cache/modal/error_history/state') +} \ No newline at end of file diff --git a/webroot/js/restoreError.js b/webroot/js/restoreError.js new file mode 100644 index 0000000..980ea0b --- /dev/null +++ b/webroot/js/restoreError.js @@ -0,0 +1,9 @@ +const errorh_panel = document.getElementById('errorh_panel') +let sys_error = localStorage.getItem('/system/error') + +if (!sys_error) { + localStorage.setItem('/system/error', '') + sys_error = localStorage.getItem('/system/error') +} + +if (sys_error.length !== 0) errorh_panel.innerHTML = sys_error \ No newline at end of file diff --git a/webroot/js/theme.js b/webroot/js/theme.js index 3fd6416..769e17c 100644 --- a/webroot/js/theme.js +++ b/webroot/js/theme.js @@ -1,34 +1,13 @@ -const light_icon = ` - - - -` -const light_module_icon = ` - - - -` -const light_expand_icon = ` - - - -` -const light_settings_icon = ` - - - -` -const light_lang_icon = ` - - - -` -const light_close_icon = ` - - - -` - +import { + light_icon, + light_logs_icon, + light_lang_icon, + light_close_icon, + light_expand_icon, + light_module_icon, + light_settings_icon, + light_copy_icon +} from "./light.icon.js" const rootCss = document.querySelector(':root') const button = document.getElementById('theme_switcher') @@ -38,7 +17,9 @@ const module_expand = document.getElementById('module_expand_icon') const settings_expand = document.getElementById('settings_expand_icon') const settings_icon = document.getElementById('setting_icon') const lang_switcher = document.getElementById('lang_switcher') +const logs_icon = document.getElementById('logs_icon') const close_icons = document.getElementsByClassName('close_icon') +const copy_button = document.getElementById('errorh_copy') let sys_theme = localStorage.getItem('/system/theme') if (!sys_theme) sys_theme = setData('dark') @@ -74,6 +55,8 @@ function setDark() { button.innerHTML = '' module_list_icon.innerHTML = '' lang_switcher.innerHTML = '' + logs_icon.innerHTML = '' + copy_button.innerHTML = '' } function setLight() { @@ -98,6 +81,8 @@ function setLight() { button.innerHTML = light_icon module_list_icon.innerHTML = light_module_icon lang_switcher.innerHTML = light_lang_icon + logs_icon.innerHTML = light_logs_icon + copy_button.innerHTML = light_copy_icon } function setData(mode) { diff --git a/webroot/lang/en_US.json b/webroot/lang/en_US.json index 851fac6..17c4f98 100644 --- a/webroot/lang/en_US.json +++ b/webroot/lang/en_US.json @@ -39,5 +39,9 @@ }, "global": { "unknown": "Unknown" + }, + "errorHistory": { + "header": "Error History", + "placeholder": "No error log recorded here!" } } \ No newline at end of file diff --git a/webroot/lang/ja_JP.json b/webroot/lang/ja_JP.json index 8ed168d..e6187d0 100644 --- a/webroot/lang/ja_JP.json +++ b/webroot/lang/ja_JP.json @@ -39,5 +39,9 @@ }, "global": { "unknown": "不明" + }, + "errorHistory": { + "header": "Error History", + "placeholder": "No error log recorded here!" } } \ No newline at end of file diff --git a/webroot/lang/pt_BR.json b/webroot/lang/pt_BR.json index 6fc7773..01907d9 100644 --- a/webroot/lang/pt_BR.json +++ b/webroot/lang/pt_BR.json @@ -39,5 +39,9 @@ }, "global": { "unknown": "Desconhecido" + }, + "errorHistory": { + "header": "Error History", + "placeholder": "No error log recorded here!" } } \ No newline at end of file diff --git a/webroot/lang/ro_RO.json b/webroot/lang/ro_RO.json index c50774d..62f5b91 100644 --- a/webroot/lang/ro_RO.json +++ b/webroot/lang/ro_RO.json @@ -39,5 +39,9 @@ }, "global": { "unknown": "Necunoscut" + }, + "errorHistory": { + "header": "Error History", + "placeholder": "No error log recorded here!" } } \ No newline at end of file diff --git a/webroot/lang/ru_RU.json b/webroot/lang/ru_RU.json index 1298a17..974538c 100644 --- a/webroot/lang/ru_RU.json +++ b/webroot/lang/ru_RU.json @@ -39,5 +39,9 @@ }, "global": { "unknown": "Неизвестно" + }, + "errorHistory": { + "header": "Error History", + "placeholder": "No error log recorded here!" } } \ No newline at end of file diff --git a/webroot/lang/vi_VN.json b/webroot/lang/vi_VN.json index b5dc2fa..30ec685 100644 --- a/webroot/lang/vi_VN.json +++ b/webroot/lang/vi_VN.json @@ -39,5 +39,9 @@ }, "global": { "unknown": "Không xác định" + }, + "errorHistory": { + "header": "Lịch sử lỗi", + "placeholder": "Không có lỗi nào đã được ghi lại ở đây!" } } \ No newline at end of file