From 3c276b329b1afda66989e2901dc6042fe6a40092 Mon Sep 17 00:00:00 2001 From: Cutls Date: Sat, 15 Jun 2019 01:15:45 +0900 Subject: [PATCH] Remove: node on post.js #86 --- app/js/platform/preload.js | 40 +++++++++++++++++++++++++------------- app/js/post/post.js | 15 +------------- app/main/system.js | 6 ++++++ 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/app/js/platform/preload.js b/app/js/platform/preload.js index f0b14b81..6b173359 100644 --- a/app/js/platform/preload.js +++ b/app/js/platform/preload.js @@ -13,6 +13,8 @@ onmessage = function (e) { ipc.send("dialogStore", e.data[1]) } else if (e.data[0] == "bmpImage") { ipc.send('bmp-image', e.data[1]); + } else if (e.data[0] == "dialogCW") { + ipc.send("dialogCW", e.data[1]) } } //version.js @@ -50,26 +52,38 @@ function nano() { } //first.js ipc.on('custom-css-response', function (event, arg) { - if (arg == "") { return false; } - var styleNode = document.createElement("style"); - styleNode.setAttribute("type", "text/css") + if (arg == "") { return false; } + var styleNode = document.createElement("style"); + styleNode.setAttribute("type", "text/css") - var content = document.createTextNode(arg) - styleNode.append(content) - document.getElementsByTagName("head")[0].append(styleNode) + var content = document.createTextNode(arg) + styleNode.append(content) + document.getElementsByTagName("head")[0].append(styleNode) }) ipc.on('theme-css-response', function (event, arg) { - if (arg == "") { return false; } - var styleNode = document.createElement("style"); - styleNode.setAttribute("type", "text/css") + if (arg == "") { return false; } + var styleNode = document.createElement("style"); + styleNode.setAttribute("type", "text/css") - var content = document.createTextNode(arg) - styleNode.append(content) - document.getElementsByTagName("head")[0].append(styleNode) + var content = document.createTextNode(arg) + styleNode.append(content) + document.getElementsByTagName("head")[0].append(styleNode) }) //img.js ipc.on('bmp-img-comp', function (event, b64) { - media(b64[0], "image/png", b64[1]); + media(b64[0], "image/png", b64[1]); +}); +//post.js +ipc.on('dialogCWRender', function (event, arg) { + if (arg === 1) { + $("#cw-text").show(); + $("#cw").addClass("yellow-text"); + $("#cw").addClass("cw-avail"); + $("#cw-text").val(plus); + post("pass"); + } else if (arg === 2) { + post("pass"); + } }); /* var webviewDom = document.getElementById('webview'); diff --git a/app/js/post/post.js b/app/js/post/post.js index 6adb0d3a..291b35ad 100644 --- a/app/js/post/post.js +++ b/app/js/post/post.js @@ -47,9 +47,6 @@ function post(mode, postvis) { } if (domain != "kirishima.cloud") { if (mode != "pass" && !$("#cw").hasClass("cw-avail") && (str.length > cw_sent || (str.split("\n").length - 1) > cw_ltres)) { - var electron = require("electron"); - var remote = electron.remote; - var dialog = remote.dialog; var plus = str.replace(/\n/g, "").slice(0, 10) + "..."; const options = { type: 'info', @@ -57,17 +54,7 @@ function post(mode, postvis) { message: lang.lang_post_cwtxt + plus, buttons: [lang.lang_post_btn1, lang.lang_post_btn2, lang.lang_post_btn3] } - dialog.showMessageBox(options, function (arg) { - if (arg === 1) { - $("#cw-text").show(); - $("#cw").addClass("yellow-text"); - $("#cw").addClass("cw-avail"); - $("#cw-text").val(plus); - post("pass"); - } else if (arg === 2) { - post("pass"); - } - }) + postMessage(["dialogCW", options], "*") return false; } } diff --git a/app/main/system.js b/app/main/system.js index feaa7614..2f02927e 100644 --- a/app/main/system.js +++ b/app/main/system.js @@ -61,6 +61,12 @@ function system(mainWindow, dir, lang) { } }); }) + //CWのダイアログ + ipc.on('dialogCW', function (e, args) { + dialog.showMessageBox(args, function (arg) { + e.sender.webContents.send('dialogCWRender', arg); + }); + }) //ハードウェアアクセラレーションの無効化 ipc.on('ha', function (e, arg) {