aboutsummaryrefslogtreecommitdiff
path: root/views/script/settings_global.js
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-05 17:29:18 +0200
committerGitHub <noreply@github.com>2021-08-05 17:29:18 +0200
commitb865b8f6586ffd4554cdfe45c739030afc882acd (patch)
tree37bcdf6575d8764b7367f34544658886879c0c5e /views/script/settings_global.js
parent79edea37d15f88f086f7775bbbce64a57535b043 (diff)
parent7b541bbf2a8d754d26511895801d90f02cdf99f7 (diff)
downloadkartik-client-b865b8f6586ffd4554cdfe45c739030afc882acd.tar.gz
kartik-client-b865b8f6586ffd4554cdfe45c739030afc882acd.tar.bz2
kartik-client-b865b8f6586ffd4554cdfe45c739030afc882acd.zip
Merge pull request #4 from Minteck-Projects/devel
Branching 21.08
Diffstat (limited to 'views/script/settings_global.js')
-rw-r--r--views/script/settings_global.js353
1 files changed, 127 insertions, 226 deletions
diff --git a/views/script/settings_global.js b/views/script/settings_global.js
index f224ea9..047967a 100644
--- a/views/script/settings_global.js
+++ b/views/script/settings_global.js
@@ -1,226 +1,127 @@
-let menuOpen = true;
-
-if (native) {global.$ = require('jquery');} else {var script = document.createElement('script');script.src = '../webinit/jquery.js';script.type = 'text/javascript';document.getElementsByTagName('head')[0].appendChild(script);}
-$("#box").fadeOut(0);
-setTimeout(() => {
- $("#box").fadeIn(500);
-}, 200)
-
-$("body").focus();
-keysEnabled = true;
-$(document).keydown(function(e) {
- if (keysEnabled) {
- if (e.keyCode === 13 || e.keyCode === 88 || e.keyCode === 32) { // enter
- if ($(".services").is(":visible")) {
- selectOption();
- } else {
- $(".services").show();
- }
- }
- if (e.keyCode === 38 || e.keyCode === 90) { // up
- Sound.menu();
- var selected = $(".selected");
- $(".services li").removeClass("selected");
- if (selected.prev().length === 0) {
- selected.siblings().last().addClass("selected");
- } else {
- selected.prev().addClass("selected");
- }
- }
- if (e.keyCode === 40 || e.keyCode === 83) { // down
- Sound.menu();
- var selected = $(".selected");
- $(".services li").removeClass("selected");
- if (selected.next().length === 0) {
- selected.siblings().first().addClass("selected");
- } else {
- selected.next().addClass("selected");
- }
- }
- if (e.keyCode === 68 || e.keyCode === 39 || e.keyCode === 81 || e.keyCode === 37) { // right/left
- Sound.menu();
- var selected = $(".selected");
- var id = $(".selected")[0].children[0].children[0].id;
-
- if (id === "musicb") {
- if (document.getElementById("setting-music").innerText === "1") {
- document.getElementById("setting-music").innerText = "0";
- require('fs').writeFileSync(homedir + "/.kartik/config/music.txt", "0");
- } else {
- document.getElementById("setting-music").innerText = "1";
- require('fs').writeFileSync(homedir + "/.kartik/config/music.txt", "1");
- }
- }
- if (id === "voice") {
- if (document.getElementById("setting-voice").innerText === "1") {
- document.getElementById("setting-voice").innerText = "0";
- require('fs').writeFileSync(homedir + "/.kartik/config/voice.txt", "0");
- } else {
- document.getElementById("setting-voice").innerText = "1";
- require('fs').writeFileSync(homedir + "/.kartik/config/voice.txt", "2");
- }
- }
- if (id === "zoom") {
- zoom = document.getElementById("setting-zoom").innerText;
-
- switch (zoom) {
- case "0.9":
- document.getElementById("setting-zoom").innerText = "1";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1");
- break;
- case "1":
- document.getElementById("setting-zoom").innerText = "1.1";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.1");
- break;
- case "1.1":
- document.getElementById("setting-zoom").innerText = "1.2";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.2");
- break;
- case "1.2":
- document.getElementById("setting-zoom").innerText = "1.3";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.3");
- break;
- case "1.3":
- document.getElementById("setting-zoom").innerText = "1.4";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.4");
- break;
- case "1.4":
- document.getElementById("setting-zoom").innerText = "1.5";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.5");
- break;
- case "1.5":
- document.getElementById("setting-zoom").innerText = "1.6";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.6");
- break;
- case "1.6":
- document.getElementById("setting-zoom").innerText = "1.7";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.7");
- break;
- case "1.7":
- document.getElementById("setting-zoom").innerText = "1.8";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.8");
- break;
- case "1.8":
- document.getElementById("setting-zoom").innerText = "1.9";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "1.9");
- break;
- case "1.9":
- document.getElementById("setting-zoom").innerText = "2";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "2");
- break;
- case "2":
- document.getElementById("setting-zoom").innerText = "0.9";
- require('fs').writeFileSync(homedir + "/.kartik/config/scale.txt", "0.9");
- break;
- }
- }
- if (id === "lang") {
- lang = document.getElementById("setting-lang").innerText;
- slng = require('../lang/languages.json');
- slst = Object.keys(slng);
- maxl = slst.length - 1;
-
- ci = -1;
- ni = -1;
- slst.forEach((key, index) => {
- if (slng[key] === lang) {
- ci = index;
- if (index + 1 > maxl) {
- ni = 0;
- } else {
- ni = index + 1;
- }
- }
- })
-
- if (ci !== -1 && ni !== -1) {
- document.getElementById("setting-lang").innerText = slng[slst[ni]];
- require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", slst[ni]);
- require('@electron/remote').getCurrentWindow().lp = slst[ni];
- }
-
- /*switch (lang) {
- case "Français":
- document.getElementById("setting-lang").innerText = "English";
- require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "en");
- require('@electron/remote').getCurrentWindow().lp = "en";
- break;
-
- case "English":
- document.getElementById("setting-lang").innerText = "Español";
- require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "es");
- require('@electron/remote').getCurrentWindow().lp = "es";
- break;
-
- case "Español":
- document.getElementById("setting-lang").innerText = "中国人";
- require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "zh");
- require('@electron/remote').getCurrentWindow().lp = "zh";
- break;
-
- case "中国人":
- document.getElementById("setting-lang").innerText = "日本語";
- require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "jp");
- require('@electron/remote').getCurrentWindow().lp = "jp";
- break;
-
- case "日本語":
- document.getElementById("setting-lang").innerText = "русский";
- require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "ru");
- require('@electron/remote').getCurrentWindow().lp = "ru";
- break;
-
- case "русский":
- document.getElementById("setting-lang").innerText = "Deutsche";
- require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "de");
- require('@electron/remote').getCurrentWindow().lp = "de";
- break;
-
- case "Deutsche":
- document.getElementById("setting-lang").innerText = "Nederlands";
- require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "nl");
- require('@electron/remote').getCurrentWindow().lp = "nl";
- break;
-
- case "Nederlands":
- document.getElementById("setting-lang").innerText = "Français";
- require('fs').writeFileSync(homedir + "/.kartik/config/lang.txt", "fr");
- require('@electron/remote').getCurrentWindow().lp = "fr";
- break;
- }*/
- }
- }
- if (e.keyCode === 27 || e.keyCode === 8) { // esc
- keysEnabled = false;
- Sound.click();
- $("#box").fadeOut(500);
- setTimeout(() => {
- info("OptnWindow", "Switching control to MenuWindow");
- location.href = "menu.html";
- }, 1000)
- }
- }
-});
-
-function selectOption() {
- item = document.querySelector(".selected a").id;
- Sound.click();
-
- switch (item) {
- case 'back':
- $("#box").fadeOut(500);
- setTimeout(() => {
- info("OptnWindow", "Switching control to MenuWindow");
- location.href = "menu.html?noreset";
- }, 1000)
- break;
- case 'credits':
- require('electron').ipcRenderer.send('prefademusic', "");
- $("#box").fadeOut(500);
- setTimeout(() => {
- info("OptnWindow", "Switching control to MenuWindow");
- location.href = "credits.html";
- }, 1000)
- break;
- }
-}
+let menuOpen = true;
+
+if (native) {global.$ = require('jquery');} else {var script = document.createElement('script');script.src = '../webinit/jquery.js';script.type = 'text/javascript';document.getElementsByTagName('head')[0].appendChild(script);}
+$("#box").fadeOut(0);
+setTimeout(() => {
+ $("#box").fadeIn(500);
+}, 200)
+
+$("body").focus();
+keysEnabled = true;
+$(document).keydown(function(e) {
+ if (keysEnabled) {
+ if (e.keyCode === 13 || e.keyCode === 88 || e.keyCode === 32) { // enter
+ if ($(".services").is(":visible")) {
+ selectOption();
+ } else {
+ $(".services").show();
+ }
+ }
+ if (e.keyCode === 38 || e.keyCode === 90) { // up
+ Sound.menu();
+ var selected = $(".selected");
+ $(".services li").removeClass("selected");
+ if (selected.prev().length === 0) {
+ selected.siblings().last().addClass("selected");
+ } else {
+ selected.prev().addClass("selected");
+ }
+ }
+ if (e.keyCode === 40 || e.keyCode === 83) { // down
+ Sound.menu();
+ var selected = $(".selected");
+ $(".services li").removeClass("selected");
+ if (selected.next().length === 0) {
+ selected.siblings().first().addClass("selected");
+ } else {
+ selected.next().addClass("selected");
+ }
+ }
+ if (e.keyCode === 68 || e.keyCode === 39 || e.keyCode === 81 || e.keyCode === 37) { // right/left
+ Sound.menu();
+ var selected = $(".selected");
+ var id = $(".selected")[0].children[0].children[0].id;
+
+ if (id === "musicb") {
+ if (document.getElementById("setting-music").innerText === "1") {
+ document.getElementById("setting-music").innerText = "0";
+ currentNest.config.music = false;
+ Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest")
+ } else {
+ document.getElementById("setting-music").innerText = "1";
+ currentNest.config.music = true;
+ Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest")
+ }
+ }
+ if (id === "voice") {
+ if (document.getElementById("setting-voice").innerText === "1") {
+ document.getElementById("setting-voice").innerText = "0";
+ currentNest.config.music = false;
+ Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest")
+ } else {
+ document.getElementById("setting-voice").innerText = "1";
+ currentNest.config.music = true;
+ Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest")
+ }
+ }
+ if (id === "lang") {
+ lang = document.getElementById("setting-lang").innerText;
+ slng = require('../lang/languages.json');
+ slst = Object.keys(slng);
+ maxl = slst.length - 1;
+
+ ci = -1;
+ ni = -1;
+ slst.forEach((key, index) => {
+ if (slng[key] === lang) {
+ ci = index;
+ if (index + 1 > maxl) {
+ ni = 0;
+ } else {
+ ni = index + 1;
+ }
+ }
+ })
+
+ if (ci !== -1 && ni !== -1) {
+ document.getElementById("setting-lang").innerText = slng[slst[ni]];
+ currentNest.config.lang = slst[ni];
+ Nest.export(homedir + "/.kartik/current.kfn", currentNest);require('electron').ipcRenderer.send("reloadNest")
+ require('@electron/remote').getCurrentWindow().lp = slst[ni];
+ }
+ }
+ }
+ if (e.keyCode === 27 || e.keyCode === 8) { // esc
+ keysEnabled = false;
+ Sound.click();
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("OptnWindow", "Switching control to MenuWindow");
+ location.href = "menu.html";
+ }, 1000)
+ }
+ }
+});
+
+function selectOption() {
+ item = document.querySelector(".selected a").id;
+ Sound.click();
+
+ switch (item) {
+ case 'back':
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("OptnWindow", "Switching control to MenuWindow");
+ location.href = "menu.html?noreset";
+ }, 1000)
+ break;
+ case 'credits':
+ require('electron').ipcRenderer.send('prefademusic', "");
+ $("#box").fadeOut(500);
+ setTimeout(() => {
+ info("OptnWindow", "Switching control to MenuWindow");
+ location.href = "credits.html";
+ }, 1000)
+ break;
+ }
+}