From 3ee4cf27d51c0527bb2c8ef25ab03c0ad871dcbe Mon Sep 17 00:00:00 2001 From: Cutls Date: Wed, 26 Jun 2019 00:33:20 +0900 Subject: [PATCH] Good-bye native dialogs --- app/js/lang/lang.ja.js | 4 +-- app/js/platform/end.js | 6 ---- app/js/platform/preload.js | 57 ----------------------------------- app/js/post/post.js | 33 ++++++++++++++++----- app/js/tl/parse.js | 61 ++++++++++++++++++++++++++++++++++---- app/main/system.js | 6 ---- 6 files changed, 83 insertions(+), 84 deletions(-) diff --git a/app/js/lang/lang.ja.js b/app/js/lang/lang.ja.js index f4789016..55fe6ec0 100644 --- a/app/js/lang/lang.ja.js +++ b/app/js/lang/lang.ja.js @@ -186,8 +186,8 @@ var lang = { "lang_parse_det": "詳細(メインアカウント経由)", "lang_parse_redraft": "このトゥートを削除して再編集", "lang_parse_followed": "フォローされました。", - "lang_parse_clientop": "クライアント処理", - "lang_parse_clienttxt": "に対する処理を選択してください。", + "lang_parse_clientop": "クライアント操作", + "lang_parse_clienttxt": " に対する処理を選択してください。", "lang_parse_clientno": "何もしない", "lang_parse_clientemp": "強調表示/解除", "lang_parse_clientmute": "ミュート", diff --git a/app/js/platform/end.js b/app/js/platform/end.js index 5c77b067..66cc8437 100644 --- a/app/js/platform/end.js +++ b/app/js/platform/end.js @@ -134,12 +134,6 @@ onmessage = function (e) { post("pass") } else if (e.data[0] == "toastSaved") { M.toast({ html: lang.lang_img_DLDone + e.data[1][0] + '', displayLength: 5000 }) - } else if (e.data[0] == "toastMute") { - M.toast({ html: escapeHTML(e.data[1]) + lang.lang_parse_mute, displayLength: 2000 }) - } else if (e.data[0] == "toastEmp") { - M.toast({ html: escapeHTML(e.data[1]) + lang.lang_status_emphas, displayLength: 2000 }) - } else if (e.data[0] == "toastUnEmp") { - M.toast({ html: escapeHTML(e.data[1]) + lang.lang_status_unemphas, displayLength: 2000 }) } else if (e.data[0] == "parseColumn") { parseColumn() } else if (e.data[0] == "sortload") { diff --git a/app/js/platform/preload.js b/app/js/platform/preload.js index 50ee329c..fc1373ae 100644 --- a/app/js/platform/preload.js +++ b/app/js/platform/preload.js @@ -102,63 +102,6 @@ ipc.on('theme-css-response', function (event, arg) { ipc.on('bmp-img-comp', function (event, b64) { postMessage(["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); - postMessage(["post", ""], "*") - } else if (arg === 2) { - postMessage(["post", ""], "*") - } -}); -//parse.js -ipc.on('dialogClientRender', function (event, arg) { - if (arg === 1) { - var cli = localStorage.getItem("client_emp"); - var obj = JSON.parse(cli); - if (!obj) { - var obj = []; - obj.push(name); - postMessage(["toastEmp", name], "*") - } else { - var can; - Object.keys(obj).forEach(function (key) { - var cliT = obj[key]; - if (cliT != name && !can) { - can = false; - } else { - can = true; - obj.splice(key, 1); - postMessage(["toastUnEmp", name], "*") - } - }); - if (!can) { - obj.push(name); - postMessage(["toastEmp", name], "*") - } else { - - } - } - var json = JSON.stringify(obj); - localStorage.setItem("client_emp", json); - } else if (arg === 2) { - var cli = localStorage.getItem("client_mute"); - var obj = JSON.parse(cli); - if (!obj) { - obj = []; - } - obj.push(name); - var json = JSON.stringify(obj); - localStorage.setItem("client_mute", json); - postMessage(["toastMute", name], "*") - } else { - return; - } - parseColumn(); -}); //ui,img.js ipc.on('general-dl-prog', function (event, arg) { console.log("Progress: " + arg); diff --git a/app/js/post/post.js b/app/js/post/post.js index 528902e3..3c21cdd2 100644 --- a/app/js/post/post.js +++ b/app/js/post/post.js @@ -23,20 +23,39 @@ function post(mode, postvis) { var cw_sent = localStorage.getItem("cw_sentence"); } if (!localStorage.getItem("cw_letters")) { - var cw_ltres = 500; + var cw_ltres = 7000; } else { var cw_ltres = localStorage.getItem("cw_letters"); } if (domain != "kirishima.cloud") { if (mode != "pass" && !$("#cw").hasClass("cw-avail") && (str.length > cw_sent || (str.split("\n").length - 1) > cw_ltres)) { + console.log("out") var plus = str.replace(/\n/g, "").slice(0, 10) + "..."; - const options = { - type: 'info', + Swal.fire({ title: lang.lang_post_cwtitle, - message: lang.lang_post_cwtxt + plus, - buttons: [lang.lang_post_btn1, lang.lang_post_btn2, lang.lang_post_btn3] - } - postMessage(["dialogCW", options], "*") + text: lang.lang_post_cwtxt + plus, + type: 'info', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#3085d6', + confirmButtonText: lang.lang_post_btn2, + cancelButtonText: lang.lang_post_btn3, + showCloseButton: true, + focusConfirm: false, + }).then((result) => { + console.log(result) + if (result.dismiss == "cancel") { + //btn3:sonomama + post("pass") + } else if (result.value) { + //btn2:auto-CW + $("#cw-text").show(); + $("#cw").addClass("yellow-text"); + $("#cw").addClass("cw-avail"); + $("#cw-text").val(plus); + post("pass") + } + }) return false; } } diff --git a/app/js/tl/parse.js b/app/js/tl/parse.js index bb6da460..528c108a 100644 --- a/app/js/tl/parse.js +++ b/app/js/tl/parse.js @@ -1019,13 +1019,62 @@ function userparse(obj, auth, acct_id, tlid, popup) { function client(name) { if (name != "Unknown") { //聞く - const options = { - type: 'info', + Swal.fire({ title: lang.lang_parse_clientop, - message: name + lang.lang_parse_clienttxt, - buttons: [lang.lang_parse_clientno, lang.lang_parse_clientemp, lang.lang_parse_clientmute] - } - postMessage(["dialogClient", options], "*") + text: name + lang.lang_parse_clienttxt, + type: 'info', + showCancelButton: true, + confirmButtonColor: '#3085d6', + cancelButtonColor: '#3085d6', + confirmButtonText: lang.lang_parse_clientmute, + cancelButtonText: lang.lang_parse_clientemp, + showCloseButton: true, + focusConfirm: false, + }).then((result) => { + console.log(result) + if (result.dismiss == "cancel") { + //Emp + var cli = localStorage.getItem("client_emp"); + var obj = JSON.parse(cli); + if (!obj) { + var obj = []; + obj.push(name); + M.toast({ html: escapeHTML(name) + lang.lang_status_emphas, displayLength: 2000 }) + } else { + var can; + Object.keys(obj).forEach(function (key) { + var cliT = obj[key]; + if (cliT != name && !can) { + can = false; + } else { + can = true; + obj.splice(key, 1); + M.toast({ html: escapeHTML(name) + lang.lang_status_unemphas, displayLength: 2000 }) + } + }); + if (!can) { + obj.push(name); + M.toast({ html: escapeHTML(name) + lang.lang_status_emphas, displayLength: 2000 }) + } else { + } + var json = JSON.stringify(obj); + localStorage.setItem("client_emp", json); + parseColumn() + } + } else if (result.value) { + //Mute + var cli = localStorage.getItem("client_mute"); + var obj = JSON.parse(cli); + if (!obj) { + obj = []; + } + obj.push(name); + var json = JSON.stringify(obj); + localStorage.setItem("client_mute", json); + M.toast({ html: escapeHTML(name) + lang.lang_parse_mute, displayLength: 2000 }) + parseColumn() + } + }) } } \ No newline at end of file diff --git a/app/main/system.js b/app/main/system.js index f7696645..9805d088 100644 --- a/app/main/system.js +++ b/app/main/system.js @@ -51,12 +51,6 @@ function system(mainWindow, dir, lang, dirname) { fs.writeFileSync(lang_path, arg); e.sender.webContents.send('langres', ""); }) - //クライアントのダイアログ - ipc.on('dialogClient', function (e, args) { - dialog.showMessageBox(args, function (arg) { - e.sender.webContents.send('dialogClientRender', arg); - }); - }) //エクスポートのダイアログ ipc.on('exportSettings', function (e, args) { dialog.showSaveDialog(null, {