2019-06-15 00:17:16 +10:00
|
|
|
var electron = require("electron");
|
2019-06-15 02:05:53 +10:00
|
|
|
const shell = electron.shell;
|
2019-06-15 00:17:16 +10:00
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
onmessage = function (e) {
|
|
|
|
if (e.data[0] == "openUrl") {
|
2019-06-15 02:05:53 +10:00
|
|
|
urls = e.data[1].match(/https?:\/\/(.+)/);
|
|
|
|
if (urls) {
|
2019-06-15 02:01:07 +10:00
|
|
|
shell.openExternal(e.data[1]);
|
|
|
|
}
|
2019-06-15 00:21:08 +10:00
|
|
|
} else if (e.data[0] == "sendSinmpleIpc") {
|
|
|
|
ipc.send(e.data[1], "")
|
2019-06-15 01:54:44 +10:00
|
|
|
} else if (e.data[0] == "dialogStore") {
|
|
|
|
ipc.send("dialogStore", e.data[1])
|
2019-06-15 02:10:32 +10:00
|
|
|
} else if (e.data[0] == "bmpImage") {
|
|
|
|
ipc.send('bmp-image', e.data[1]);
|
2019-06-15 02:15:45 +10:00
|
|
|
} else if (e.data[0] == "dialogCW") {
|
|
|
|
ipc.send("dialogCW", e.data[1])
|
2019-06-15 02:20:12 +10:00
|
|
|
} else if (e.data[0] == "nativeNotf") {
|
2019-06-16 00:07:18 +10:00
|
|
|
console.log(e.data[1])
|
2019-06-15 02:20:12 +10:00
|
|
|
ipc.send('native-notf', e.data[1]);
|
2019-06-15 02:25:51 +10:00
|
|
|
} else if (e.data[0] == "dialogClient") {
|
|
|
|
ipc.send("dialogClient", e.data[1])
|
2019-06-15 02:32:59 +10:00
|
|
|
} else if (e.data[0] == "generalDL") {
|
|
|
|
ipc.send('general-dl', e.data[1]);
|
|
|
|
} else if (e.data[0] == "openFinder") {
|
|
|
|
ipc.send('open-finder', e.data[1]);
|
|
|
|
} else if (e.data[0] == "columnDel") {
|
|
|
|
ipc.send('column-del', e.data[1]);
|
2019-06-15 03:01:38 +10:00
|
|
|
} else if (e.data[0] == "lang") {
|
|
|
|
ipc.send('lang', e.data[1]);
|
|
|
|
} else if (e.data[0] == "exportSettings") {
|
|
|
|
ipc.send('exportSettings', e.data[1]);
|
|
|
|
} else if (e.data[0] == "importSettings") {
|
|
|
|
ipc.send('importSettings', e.data[1]);
|
|
|
|
} else if (e.data[0] == "customSound") {
|
|
|
|
ipc.send('customSound', e.data[1]);
|
|
|
|
} else if (e.data[0] == "themeJsonDelete") {
|
|
|
|
ipc.send('theme-json-delete', e.data[1]);
|
|
|
|
} else if (e.data[0] == "themeJsonCreate") {
|
|
|
|
ipc.send('theme-json-create', e.data[1]);
|
|
|
|
} else if (e.data[0] == "themeJsonRequest") {
|
2019-06-15 03:10:11 +10:00
|
|
|
ipc.send('theme-json-request', e.data[1]);
|
2019-06-15 03:01:38 +10:00
|
|
|
} else if (e.data[0] == "ha") {
|
2019-06-16 02:08:10 +10:00
|
|
|
ipc.send('ha', e.data[1]);
|
|
|
|
} else if (e.data[0] == "aboutData") {
|
|
|
|
ipc.send('aboutData', "");
|
2019-06-15 03:10:11 +10:00
|
|
|
} else if (e.data[0] == "itunes") {
|
2019-06-16 00:07:18 +10:00
|
|
|
console.log("NowPlaying" + ipc.listenerCount('itunes-np'))
|
|
|
|
if (ipc.listenerCount('itunes-np') > 1) {
|
2019-06-15 03:10:11 +10:00
|
|
|
return false;
|
2019-06-15 03:23:41 +10:00
|
|
|
} else {
|
2019-06-15 03:10:11 +10:00
|
|
|
ipc.send("itunes", e.data[1])
|
|
|
|
}
|
2019-06-15 03:23:41 +10:00
|
|
|
} else if (e.data[0] == "themeCSSRequest") {
|
|
|
|
ipc.send('theme-css-request', e.data[1]);
|
|
|
|
} else if (e.data[0] == "downloadButton") {
|
|
|
|
ipc.send('download-btn', e.data[1]);
|
2019-06-15 00:17:16 +10:00
|
|
|
}
|
|
|
|
}
|
2019-06-15 01:51:41 +10:00
|
|
|
//version.js
|
2019-06-15 00:25:27 +10:00
|
|
|
ipc.send("getPlatform", "")
|
2019-06-16 00:07:18 +10:00
|
|
|
ipc.on('platform', function (event, args) {
|
|
|
|
localStorage.setItem("platform", args[0])
|
|
|
|
localStorage.setItem("bit", args[1])
|
2019-06-16 02:08:10 +10:00
|
|
|
localStorage.setItem("about", JSON.stringify([args[2], args[3], args[4]]))
|
2019-06-15 00:25:27 +10:00
|
|
|
})
|
2019-06-15 01:51:41 +10:00
|
|
|
ipc.on('winstore', function (event, arg) {
|
2019-06-15 02:05:53 +10:00
|
|
|
localStorage.setItem("winstore", arg)
|
2019-06-15 01:51:41 +10:00
|
|
|
})
|
|
|
|
|
2019-06-15 00:17:16 +10:00
|
|
|
ipc.on('reload', function (event, arg) {
|
|
|
|
location.reload();
|
|
|
|
})
|
|
|
|
//Native Notf
|
|
|
|
ipc.on('shownotf', function (event, args) {
|
|
|
|
if (args["type"] == "toot") {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["details", [id, acct_id]], "*")
|
2019-06-15 00:17:16 +10:00
|
|
|
} else if (args["type"] == "userdata") {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["udg", [user, acct_id]], "*")
|
2019-06-15 00:17:16 +10:00
|
|
|
}
|
|
|
|
})
|
|
|
|
function nano() {
|
|
|
|
ipc.send('nano', "");
|
|
|
|
}
|
2019-06-15 02:10:32 +10:00
|
|
|
//first.js
|
|
|
|
ipc.on('custom-css-response', function (event, arg) {
|
2019-06-15 02:15:45 +10:00
|
|
|
if (arg == "") { return false; }
|
|
|
|
var styleNode = document.createElement("style");
|
|
|
|
styleNode.setAttribute("type", "text/css")
|
2019-06-15 02:10:32 +10:00
|
|
|
|
2019-06-15 02:15:45 +10:00
|
|
|
var content = document.createTextNode(arg)
|
|
|
|
styleNode.append(content)
|
|
|
|
document.getElementsByTagName("head")[0].append(styleNode)
|
2019-06-15 02:10:32 +10:00
|
|
|
})
|
|
|
|
ipc.on('theme-css-response', function (event, arg) {
|
2019-06-15 02:15:45 +10:00
|
|
|
if (arg == "") { return false; }
|
|
|
|
var styleNode = document.createElement("style");
|
|
|
|
styleNode.setAttribute("type", "text/css")
|
2019-06-15 02:10:32 +10:00
|
|
|
|
2019-06-15 02:15:45 +10:00
|
|
|
var content = document.createTextNode(arg)
|
|
|
|
styleNode.append(content)
|
|
|
|
document.getElementsByTagName("head")[0].append(styleNode)
|
2019-06-15 02:10:32 +10:00
|
|
|
})
|
|
|
|
//img.js
|
|
|
|
ipc.on('bmp-img-comp', function (event, b64) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["media", [b64[0], "image/png", b64[1]]], "*")
|
2019-06-15 02:15:45 +10:00
|
|
|
});
|
|
|
|
//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);
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["post", ""], "*")
|
2019-06-15 02:15:45 +10:00
|
|
|
} else if (arg === 2) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["post", ""], "*")
|
2019-06-15 02:15:45 +10:00
|
|
|
}
|
2019-06-15 02:10:32 +10:00
|
|
|
});
|
2019-06-15 02:25:51 +10:00
|
|
|
//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);
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["toastEmp", name], "*")
|
2019-06-15 02:25:51 +10:00
|
|
|
} 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);
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["toastUnEmp", name], "*")
|
2019-06-15 02:25:51 +10:00
|
|
|
}
|
|
|
|
});
|
|
|
|
if (!can) {
|
|
|
|
obj.push(name);
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["toastEmp", name], "*")
|
2019-06-15 02:25:51 +10:00
|
|
|
} 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);
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["toastMute", name], "*")
|
2019-06-15 02:25:51 +10:00
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
parseColumn();
|
|
|
|
});
|
2019-06-15 02:32:59 +10:00
|
|
|
//ui,img.js
|
|
|
|
ipc.on('general-dl-prog', function (event, arg) {
|
|
|
|
console.log("Progress: " + arg);
|
|
|
|
})
|
|
|
|
ipc.on('general-dl-message', function (event, arg) {
|
|
|
|
var argC = arg.replace(/\\/g, "\\\\") + "\\\\.";
|
2019-06-16 00:07:18 +10:00
|
|
|
console.log("saved")
|
|
|
|
postMessage(["toastSaved", [arg, argC]], "*")
|
2019-06-15 02:32:59 +10:00
|
|
|
})
|
|
|
|
//layout.js
|
|
|
|
ipc.on('column-del-reply', function (event, args) {
|
|
|
|
if (args[0] === 1) {
|
2019-06-16 00:07:18 +10:00
|
|
|
var multi = localStorage.getItem("column");
|
|
|
|
var obj = JSON.parse(multi);
|
2019-06-15 02:32:59 +10:00
|
|
|
localStorage.removeItem("card_" + args[1]);
|
|
|
|
obj.splice(args[1], 1);
|
|
|
|
for (var i = 0; i < obj.length; i++) {
|
|
|
|
localStorage.setItem("card_" + i, "true");
|
|
|
|
localStorage.removeItem("catch_" + i);
|
|
|
|
}
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
localStorage.setItem("column", json);
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["parseColumn", ""], "*")
|
|
|
|
postMessage(["sortload", ""], "*")
|
2019-06-15 02:32:59 +10:00
|
|
|
}
|
|
|
|
})
|
2019-06-15 03:01:38 +10:00
|
|
|
//setting.js
|
|
|
|
ipc.on('langres', function (event, arg) {
|
|
|
|
location.href = "../" + lang + "/setting.html"
|
|
|
|
});
|
|
|
|
ipc.on('exportSettingsFile', function (event, savedFiles) {
|
|
|
|
var exp = exportSettingsCore()
|
|
|
|
ipc.send('export', [savedFiles, JSON.stringify(exp)]);
|
|
|
|
alert("Done.")
|
|
|
|
//cards
|
|
|
|
//lang
|
|
|
|
});
|
|
|
|
ipc.on('config', function (event, arg) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["importSettingsCore", arg], "*")
|
2019-06-15 03:01:38 +10:00
|
|
|
});
|
|
|
|
ipc.on('savefolder', function (event, arg) {
|
|
|
|
localStorage.setItem("savefolder", arg);
|
|
|
|
});
|
|
|
|
ipc.on('font-list', function (event, arg) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["fontList", arg], "*")
|
2019-06-15 03:01:38 +10:00
|
|
|
});
|
|
|
|
ipc.on('customSoundRender', function (event, args) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["customSoundSave", [args[0], args[1]]], "*")
|
2019-06-15 03:01:38 +10:00
|
|
|
});
|
|
|
|
ipc.on('theme-json-list-response', function (event, args) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["ctLoadCore", args], "*")
|
2019-06-15 03:01:38 +10:00
|
|
|
});
|
|
|
|
ipc.on('theme-json-delete-complete', function (event, args) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["ctLoad", ""], "*")
|
2019-06-15 03:01:38 +10:00
|
|
|
});
|
|
|
|
ipc.on('theme-json-response', function (event, args) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["customConnect", args], "*")
|
2019-06-15 03:01:38 +10:00
|
|
|
});
|
|
|
|
ipc.on('theme-json-create-complete', function (event, args) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["clearCustomImport", ""], "*")
|
|
|
|
postMessage(["ctLoad", ""], "*")
|
2019-06-15 03:01:38 +10:00
|
|
|
});
|
2019-06-15 03:10:11 +10:00
|
|
|
//spotify.js
|
|
|
|
ipc.once('itunes-np', function (event, arg) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["npCore", arg], "*")
|
2019-06-15 03:10:11 +10:00
|
|
|
})
|
|
|
|
//tips.js
|
|
|
|
ipc.on('memory', function (event, arg) {
|
|
|
|
var use = arg[0];
|
|
|
|
var cpu = arg[1];
|
|
|
|
var total = arg[2]
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["renderMem", [use, cpu, total]], "*")
|
2019-06-15 03:10:11 +10:00
|
|
|
})
|
2019-06-15 03:23:41 +10:00
|
|
|
//update.html
|
|
|
|
ipc.on('prog', function (event, arg) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["updateProg", arg], "*")
|
2019-06-15 03:23:41 +10:00
|
|
|
})
|
|
|
|
ipc.on('mess', function (event, arg) {
|
2019-06-16 00:07:18 +10:00
|
|
|
postMessage(["updateMess", arg], "*")
|
2019-06-15 03:23:41 +10:00
|
|
|
})
|
2019-06-15 00:17:16 +10:00
|
|
|
var webviewDom = document.getElementById('webview');
|
2019-06-16 00:07:18 +10:00
|
|
|
if (webviewDom) {
|
2019-06-15 03:30:29 +10:00
|
|
|
webviewDom.addEventListener('new-window', function (e) {
|
|
|
|
shell.openExternal(e.url);
|
|
|
|
});
|
|
|
|
}
|