Remove: node on notification/parse.js #86

This commit is contained in:
Cutls 2019-06-15 01:25:51 +09:00
parent 772a5438aa
commit 725f0f789a
4 changed files with 68 additions and 65 deletions

View File

@ -17,6 +17,8 @@ onmessage = function (e) {
ipc.send("dialogCW", e.data[1]) ipc.send("dialogCW", e.data[1])
} else if (e.data[0] == "nativeNotf") { } else if (e.data[0] == "nativeNotf") {
ipc.send('native-notf', e.data[1]); ipc.send('native-notf', e.data[1]);
} else if (e.data[0] == "dialogClient") {
ipc.send("dialogClient", e.data[1])
} }
} }
//version.js //version.js
@ -87,6 +89,51 @@ ipc.on('dialogCWRender', function (event, arg) {
post("pass"); post("pass");
} }
}); });
//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);
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);
} 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);
M.toast({ html: escapeHTML(name) + lang.lang_parse_mute, displayLength: 2000 })
} else {
return;
}
parseColumn();
});
/* /*
var webviewDom = document.getElementById('webview'); var webviewDom = document.getElementById('webview');
const { const {

View File

@ -58,9 +58,7 @@ function notfColumn(acct_id, tlid, sys) {
if (key > 14) { if (key > 14) {
ct = "15+"; ct = "15+";
} }
var electron = require("electron"); var os = localStorage.getItem("platform");
var ipc = electron.ipcRenderer;
var os = electron.remote.process.platform;
var options = { var options = {
body: ct + lang.lang_notf_new, body: ct + lang.lang_notf_new,
icon: localStorage.getItem("prof_" + acct_id) icon: localStorage.getItem("prof_" + acct_id)
@ -68,7 +66,8 @@ function notfColumn(acct_id, tlid, sys) {
if (os == "darwin") { if (os == "darwin") {
var n = new Notification('TheDesk:' + domain, options); var n = new Notification('TheDesk:' + domain, options);
} else { } else {
ipc.send('native-notf', ['TheDesk:' + domain, ct + lang.lang_notf_new, localStorage.getItem("prof_" + acct_id)]); var nativeNotfOpt=['TheDesk:' + domain, ct + lang.lang_notf_new, localStorage.getItem("prof_" + acct_id)]
postMessage(["nativeNotf", nativeNotfOpt], "*")
} }
} }
@ -164,9 +163,7 @@ function notfCommon(acct_id, tlid, sys) {
if (key > 14) { if (key > 14) {
ct = "15+"; ct = "15+";
} }
var electron = require("electron"); var os = localStorage.getItem("platform");
var ipc = electron.ipcRenderer;
var os = electron.remote.process.platform;
var options = { var options = {
body: ct + lang.lang_notf_new, body: ct + lang.lang_notf_new,
icon: localStorage.getItem("prof_" + acct_id) icon: localStorage.getItem("prof_" + acct_id)
@ -174,7 +171,8 @@ function notfCommon(acct_id, tlid, sys) {
if (os == "darwin") { if (os == "darwin") {
var n = new Notification('TheDesk:' + domain, options); var n = new Notification('TheDesk:' + domain, options);
} else { } else {
ipc.send('native-notf', ['TheDesk:' + domain, ct + lang.lang_notf_new, localStorage.getItem("prof_" + acct_id)]); var nativeNotfOpt=['TheDesk:' + domain, ct + lang.lang_notf_new, localStorage.getItem("prof_" + acct_id)]
postMessage(["nativeNotf", nativeNotfOpt], "*")
} }
} }

View File

@ -304,9 +304,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
request.send(); request.send();
} }
if (native == "yes") { if (native == "yes") {
var electron = require("electron"); var os = localStorage.getItem("platform");
var ipc = electron.ipcRenderer;
var os = electron.remote.process.platform;
var options = { var options = {
body: toot.account.display_name + "(" + toot.account.acct + ")" + what + "\n\n" + $.strip_tags(toot.status.content), body: toot.account.display_name + "(" + toot.account.acct + ")" + what + "\n\n" + $.strip_tags(toot.status.content),
icon: toot.account.avatar icon: toot.account.avatar
@ -314,14 +312,15 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
if (os == "darwin") { if (os == "darwin") {
var n = new Notification('TheDesk:' + domain, options); var n = new Notification('TheDesk:' + domain, options);
} else { } else {
ipc.send('native-notf', [ var nativeNotfOpt = [
'TheDesk:' + domain, 'TheDesk:' + domain,
toot.account.display_name + "(" + toot.account.acct + ")" + what + "\n\n" + $.strip_tags(toot.status.content), toot.account.display_name + "(" + toot.account.acct + ")" + what + "\n\n" + $.strip_tags(toot.status.content),
toot.account.avatar, toot.account.avatar,
"toot", "toot",
acct_id, acct_id,
toot.status.id toot.status.id
]); ]
postMessage(["nativeNotf", nativeNotfOpt], "*")
} }
} }
if (localStorage.getItem("hasNotfC_" + acct_id) != "true") { if (localStorage.getItem("hasNotfC_" + acct_id) != "true") {
@ -929,9 +928,7 @@ function userparse(obj, auth, acct_id, tlid, popup) {
native = "yes"; native = "yes";
} }
if (native == "yes") { if (native == "yes") {
var electron = require("electron"); var os = localStorage.getItem("platform");
var ipc = electron.ipcRenderer;
var os = electron.remote.process.platform;
var options = { var options = {
body: toot.display_name + "(" + toot.acct + ")" + ftxt, body: toot.display_name + "(" + toot.acct + ")" + ftxt,
icon: toot.avatar icon: toot.avatar
@ -940,14 +937,15 @@ function userparse(obj, auth, acct_id, tlid, popup) {
if (os == "darwin") { if (os == "darwin") {
var n = new Notification('TheDesk:' + domain, options); var n = new Notification('TheDesk:' + domain, options);
} else { } else {
ipc.send('native-notf', [ var nativeNotfOpt = [
'TheDesk:' + domain, 'TheDesk:' + domain,
toot.display_name + "(" + toot.acct + ")" + ftxt, toot.display_name + "(" + toot.acct + ")" + ftxt,
toot.avatar, toot.avatar,
"userdata", "userdata",
acct_id, acct_id,
toot.id toot.id
]); ]
postMessage(["nativeNotf", nativeNotfOpt], "*")
} }
} }
} }
@ -1011,59 +1009,13 @@ function userparse(obj, auth, acct_id, tlid, popup) {
function client(name) { function client(name) {
if (name != "Unknown") { if (name != "Unknown") {
//聞く //聞く
var electron = require("electron");
var remote = electron.remote;
var dialog = remote.dialog;
const options = { const options = {
type: 'info', type: 'info',
title: lang.lang_parse_clientop, title: lang.lang_parse_clientop,
message: name + lang.lang_parse_clienttxt, message: name + lang.lang_parse_clienttxt,
buttons: [lang.lang_parse_clientno, lang.lang_parse_clientemp, lang.lang_parse_clientmute] buttons: [lang.lang_parse_clientno, lang.lang_parse_clientemp, lang.lang_parse_clientmute]
} }
dialog.showMessageBox(options, function (arg) { postMessage(["dialogClient", options], "*")
if (arg === 1) {
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);
} 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);
M.toast({ html: escapeHTML(name) + lang.lang_parse_mute, displayLength: 2000 })
} else {
return;
}
parseColumn();
})
} }
} }

View File

@ -67,6 +67,12 @@ function system(mainWindow, dir, lang) {
e.sender.webContents.send('dialogCWRender', arg); e.sender.webContents.send('dialogCWRender', arg);
}); });
}) })
//クライアントのダイアログ
ipc.on('dialogClient', function (e, args) {
dialog.showMessageBox(args, function (arg) {
e.sender.webContents.send('dialogClientRender', arg);
});
})
//ハードウェアアクセラレーションの無効化 //ハードウェアアクセラレーションの無効化
ipc.on('ha', function (e, arg) { ipc.on('ha', function (e, arg) {