aboutsummaryrefslogtreecommitdiff
path: root/views/script/core_head.js
diff options
context:
space:
mode:
Diffstat (limited to 'views/script/core_head.js')
-rw-r--r--views/script/core_head.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/views/script/core_head.js b/views/script/core_head.js
new file mode 100644
index 0000000..be27c87
--- /dev/null
+++ b/views/script/core_head.js
@@ -0,0 +1,31 @@
+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);}
+
+if (native && require('@electron/remote').getCurrentWindow().debug) {
+ document.write('<link rel="stylesheet" href="' + atob("Li92aWV3cy9jb21tb24vZGVidWcuY3Nz") + '">');
+}
+
+if (native) {
+ var ipcRenderer = require('electron').ipcRenderer;
+ ipcRenderer.on('scenario', function (event,obj) {
+ try {
+ console.log(kresources.scenario.voice[obj.lang] + "/" + obj.namespace + obj.id + ".mp3");
+ a = new Audio(kresources.scenario.voice[obj.lang] + "/" + obj.namespace + obj.id + ".mp3");
+ a.onended = () => {
+ setTimeout(() => {
+ $("#message").fadeOut(200);
+ if (typeof obj.cb == "function") {
+ obj.cb();
+ }
+ }, 3000)
+ }
+ a.play();
+ } catch (e) {
+ console.error(e);
+ obj.cb();
+ }
+
+ document.getElementById('message-text').innerText = obj.message;
+ document.getElementById('message-character-inner').src = kresources.scenario.averi[obj.emote];
+ $("#message").fadeIn(200);
+ });
+}