Good-bye native dialogs

This commit is contained in:
Cutls 2019-06-26 00:33:20 +09:00
parent 87da95b9a4
commit 3ee4cf27d5
6 changed files with 83 additions and 84 deletions

View File

@ -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": "ミュート",

View File

@ -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] + '<button class="btn-flat toast-action" onclick="openFinder(\'' + e.data[1][1] + '\')">Show</button>', 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") {

View File

@ -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);

View File

@ -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;
}
}

View File

@ -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()
}
})
}
}

View File

@ -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, {