2018-01-28 23:22:43 +11:00
|
|
|
//バージョンチェッカー
|
2019-03-16 02:29:54 +11:00
|
|
|
function verck(ver) {
|
2019-05-19 16:17:05 +10:00
|
|
|
console.log("%c Welcome😊", "color: red;font-size:200%;")
|
2019-06-04 02:26:00 +10:00
|
|
|
var date = new Date();
|
|
|
|
var show = false
|
2019-05-19 17:39:30 +10:00
|
|
|
if (localStorage.getItem("ver") != ver) {
|
2018-05-26 02:37:35 +10:00
|
|
|
localStorage.setItem("ver", ver);
|
2019-06-04 02:26:00 +10:00
|
|
|
show = true
|
2019-05-19 16:17:05 +10:00
|
|
|
console.log("%c Thank you for your update🎉", "color: red;font-size:200%;");
|
2019-05-19 17:39:30 +10:00
|
|
|
$(document).ready(function () {
|
2018-05-26 02:37:35 +10:00
|
|
|
$('#releasenote').modal('open');
|
2019-05-19 17:39:30 +10:00
|
|
|
verp = ver.replace('(', '');
|
|
|
|
verp = verp.replace('.', '-');
|
|
|
|
verp = verp.replace('.', '-');
|
|
|
|
verp = verp.replace('[', '-');
|
|
|
|
verp = verp.replace(']', '');
|
|
|
|
verp = verp.replace(')', '');
|
|
|
|
verp = verp.replace(' ', '_');
|
|
|
|
console.log("%c " + verp, "color: red;font-size:200%;");
|
|
|
|
if (lang.language == "ja") {
|
|
|
|
$("#release-" + verp).show();
|
|
|
|
} else {
|
2019-03-16 16:05:04 +11:00
|
|
|
$("#release-en").show();
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
|
|
|
});
|
2018-05-26 02:37:35 +10:00
|
|
|
}
|
2019-06-04 02:26:00 +10:00
|
|
|
if (!show) {
|
|
|
|
console.log(show)
|
2019-06-04 23:29:47 +10:00
|
|
|
if (date.getMonth() + 1 >= localStorage.getItem("showSupportMe") || !localStorage.getItem("showSupportMe")) {
|
2019-06-04 02:26:00 +10:00
|
|
|
if (date.getMonth() == 11) {
|
|
|
|
var nextmonth = 1
|
|
|
|
} else {
|
|
|
|
var nextmonth = date.getMonth() + 2
|
|
|
|
}
|
2019-06-04 23:29:47 +10:00
|
|
|
if (lang.language != "ja") {
|
|
|
|
$("#support-btm-ja").addClass("hide");
|
|
|
|
$("#support-btm-en").removeClass("hide");
|
|
|
|
}
|
2019-06-04 02:26:00 +10:00
|
|
|
localStorage.setItem("showSupportMe", nextmonth)
|
|
|
|
$("#support-btm").removeClass("hide")
|
|
|
|
$("#support-btm").animate({
|
|
|
|
'bottom': '0'
|
|
|
|
}, {
|
|
|
|
'duration': 300
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2019-03-09 13:21:21 +11:00
|
|
|
var electron = require("electron");
|
2019-05-19 17:39:30 +10:00
|
|
|
var remote = electron.remote;
|
|
|
|
var dialog = remote.dialog;
|
|
|
|
var platform = remote.process.platform;
|
2019-06-04 02:26:00 +10:00
|
|
|
console.log("Your platform:" + remote.process.platform)
|
2019-05-19 17:39:30 +10:00
|
|
|
if (platform == "win32") {
|
2019-03-09 13:21:21 +11:00
|
|
|
const options = {
|
|
|
|
type: 'info',
|
|
|
|
title: "Select your platform",
|
|
|
|
message: lang.lang_version_platform,
|
2019-05-19 17:39:30 +10:00
|
|
|
buttons: [lang.lang_no, lang.lang_yesno]
|
|
|
|
}
|
|
|
|
if (!localStorage.getItem("winstore")) {
|
|
|
|
|
|
|
|
dialog.showMessageBox(options, function (arg) {
|
|
|
|
if (arg == 1) {
|
|
|
|
localStorage.setItem("winstore", "winstore")
|
|
|
|
} else {
|
|
|
|
localStorage.setItem("winstore", "localinstall")
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
} else if (platform == "linux") {
|
|
|
|
if (localStorage.getItem("winstore") == "unix") {
|
2019-03-09 13:21:21 +11:00
|
|
|
localStorage.removeItem("winstore")
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!localStorage.getItem("winstore")) {
|
2019-03-09 13:21:21 +11:00
|
|
|
const options = {
|
|
|
|
type: 'info',
|
|
|
|
title: "Select your platform",
|
|
|
|
message: lang.lang_version_platform_linux,
|
2019-05-19 17:39:30 +10:00
|
|
|
buttons: [lang.lang_no, lang.lang_yesno]
|
|
|
|
}
|
|
|
|
dialog.showMessageBox(options, function (arg) {
|
|
|
|
if (arg == 1) {
|
|
|
|
localStorage.setItem("winstore", "snapcraft")
|
|
|
|
} else {
|
|
|
|
localStorage.setItem("winstore", "localinstall")
|
|
|
|
}
|
2019-03-09 13:21:21 +11:00
|
|
|
});
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else if (platform == "darwin") {
|
|
|
|
if (localStorage.getItem("winstore") == "unix") {
|
2019-03-21 19:01:55 +11:00
|
|
|
localStorage.removeItem("winstore")
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!localStorage.getItem("winstore")) {
|
2019-03-21 19:01:55 +11:00
|
|
|
const options = {
|
|
|
|
type: 'info',
|
|
|
|
title: "Select your platform",
|
|
|
|
message: lang.lang_version_platform_mac,
|
2019-05-19 17:39:30 +10:00
|
|
|
buttons: [lang.lang_no, lang.lang_yesno]
|
|
|
|
}
|
|
|
|
dialog.showMessageBox(options, function (arg) {
|
|
|
|
if (arg == 1) {
|
|
|
|
localStorage.setItem("winstore", "brewcask")
|
|
|
|
} else {
|
|
|
|
localStorage.setItem("winstore", "localinstall")
|
|
|
|
}
|
2019-03-21 19:01:55 +11:00
|
|
|
});
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
|
|
|
localStorage.setItem("winstore", "unix")
|
|
|
|
}
|
|
|
|
if (localStorage.getItem("winstore") == "brewcask" || localStorage.getItem("winstore") == "snapcraft" || localStorage.getItem("winstore") == "winstore") {
|
|
|
|
var winstore = true;
|
|
|
|
} else {
|
|
|
|
var winstore = false;
|
|
|
|
}
|
2018-03-14 05:31:31 +11:00
|
|
|
var l = 5;
|
2018-07-07 03:51:48 +10:00
|
|
|
// 生成する文字列に含める文字セット
|
|
|
|
var c = "abcdefghijklmnopqrstuvwxyz0123456789";
|
2018-03-14 05:31:31 +11:00
|
|
|
var cl = c.length;
|
|
|
|
var r = "";
|
2019-05-19 17:39:30 +10:00
|
|
|
for (var i = 0; i < l; i++) {
|
|
|
|
r += c[Math.floor(Math.random() * cl)];
|
2018-03-14 05:31:31 +11:00
|
|
|
}
|
|
|
|
var start = "https://thedesk.top/ver.json";
|
2018-01-28 23:22:43 +11:00
|
|
|
fetch(start, {
|
|
|
|
method: 'GET'
|
2019-05-19 17:39:30 +10:00
|
|
|
}).then(function (response) {
|
2018-01-28 23:22:43 +11:00
|
|
|
return response.json();
|
2019-05-19 17:39:30 +10:00
|
|
|
}).catch(function (error) {
|
2018-01-28 23:22:43 +11:00
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
2019-05-19 17:39:30 +10:00
|
|
|
}).then(function (mess) {
|
2019-05-19 16:17:05 +10:00
|
|
|
console.table(mess);
|
2018-01-28 23:22:43 +11:00
|
|
|
if (mess) {
|
2018-07-07 03:51:48 +10:00
|
|
|
var electron = require("electron");
|
2019-05-19 17:39:30 +10:00
|
|
|
var remote = electron.remote;
|
|
|
|
var platform = remote.process.platform;
|
|
|
|
if (platform == "darwin") {
|
|
|
|
var newest = mess.desk_mac;
|
|
|
|
} else {
|
|
|
|
var newest = mess.desk;
|
2018-07-07 03:51:48 +10:00
|
|
|
}
|
|
|
|
if (newest == ver) {
|
2019-05-19 17:39:30 +10:00
|
|
|
todo(lang.lang_version_usever.replace("{{ver}}", mess.desk));
|
2019-03-16 02:29:54 +11:00
|
|
|
//betaかWinstoreならアプデチェックしない
|
2019-05-19 17:39:30 +10:00
|
|
|
} else if (ver.indexOf("beta") != -1 || winstore) {
|
|
|
|
|
|
|
|
} else {
|
2018-02-25 19:41:34 +11:00
|
|
|
localStorage.removeItem("instance")
|
2019-05-19 17:39:30 +10:00
|
|
|
if (localStorage.getItem("new-ver-skip")) {
|
|
|
|
if (localStorage.getItem("next-ver") != newest) {
|
2018-07-22 23:03:46 +10:00
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
ipc.send('update', "true");
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-05-19 16:17:05 +10:00
|
|
|
console.warn(lang.lang_version_skipver);
|
2019-01-26 14:24:26 +11:00
|
|
|
todo(lang.lang_version_skipver);
|
2018-07-22 23:03:46 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2018-07-22 23:03:46 +10:00
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
ipc.send('update', "true");
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!localStorage.getItem("last-notice-id")) {
|
|
|
|
localStorage.setItem("last-notice-id", 0)
|
2018-08-24 01:15:57 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
var start = "https://thedesk.top/notice?since_id=" + localStorage.getItem("last-notice-id");
|
2018-08-24 01:15:57 +10:00
|
|
|
fetch(start, {
|
|
|
|
method: 'GET'
|
2019-05-19 17:39:30 +10:00
|
|
|
}).then(function (response) {
|
2018-08-24 01:15:57 +10:00
|
|
|
return response.json();
|
2019-05-19 17:39:30 +10:00
|
|
|
}).catch(function (error) {
|
2018-08-24 01:15:57 +10:00
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
2019-05-19 17:39:30 +10:00
|
|
|
}).then(function (mess) {
|
|
|
|
if (mess.length < 1) {
|
2018-08-24 01:15:57 +10:00
|
|
|
return false;
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
|
|
|
var last = localStorage.getItem("last-notice-id")
|
|
|
|
localStorage.setItem("last-notice-id", mess[0].ID)
|
|
|
|
for (i = 0; i < mess.length; i++) {
|
|
|
|
var obj = mess[i];
|
|
|
|
if (obj.ID * 1 <= last) {
|
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
var show = true;
|
2019-05-23 00:39:55 +10:00
|
|
|
if (obj.toot != "") {
|
|
|
|
var toot = '<button class="btn-flat toast-action" onclick="detEx(\'' + obj.toot + '\',\'main\')">Show</button>';
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
|
|
|
var toot = "";
|
2018-08-24 01:15:57 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
if (obj.Ver != "") {
|
|
|
|
if (obj.Ver == ver) {
|
|
|
|
show = true;
|
|
|
|
} else {
|
|
|
|
show = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (obj.Domain != "") {
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
if (multi) {
|
|
|
|
show = false;
|
|
|
|
var accts = JSON.parse(multi);
|
|
|
|
Object.keys(accts).forEach(function (key) {
|
|
|
|
var acct = accts[key];
|
|
|
|
if (acct.domain == obj.Domain) {
|
|
|
|
show = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (show) {
|
2019-06-07 02:11:04 +10:00
|
|
|
M.toast({ html: escapeHTML(obj.Text) + toot + '<span class="sml grey-text">(スライドして消去)</span>', displayLength: 86400 })
|
2018-08-24 01:15:57 +10:00
|
|
|
}
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
|
2018-08-24 01:15:57 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2019-03-23 01:10:23 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
var infostreaming = false;
|
|
|
|
function infowebsocket() {
|
2018-08-24 01:15:57 +10:00
|
|
|
infows = new WebSocket("wss://thedesk.top/ws/");
|
2019-05-19 17:39:30 +10:00
|
|
|
infows.onopen = function (mess) {
|
|
|
|
console.log([tlid, ":Connect Streaming Info:", mess]);
|
|
|
|
infostreaming = true;
|
2018-08-24 01:15:57 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
infows.onmessage = function (mess) {
|
|
|
|
console.log([tlid, ":Receive Streaming:", JSON.parse(mess.data)]);
|
|
|
|
var obj = JSON.parse(mess.data);
|
|
|
|
if (obj.type != "counter") {
|
|
|
|
localStorage.setItem("last-notice-id", obj.id)
|
|
|
|
var show = true;
|
|
|
|
if (obj.toot != "") {
|
|
|
|
var toot = '<button class="btn-flat toast-action" onclick="detEx(\'' + obj.toot + '\',\'main\')">Show</button>';
|
|
|
|
} else {
|
|
|
|
var toot = "";
|
2018-08-24 01:15:57 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
if (obj.ver != "") {
|
|
|
|
if (obj.ver == ver) {
|
|
|
|
show = true;
|
|
|
|
} else {
|
|
|
|
show = false;
|
2018-08-24 01:15:57 +10:00
|
|
|
}
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
if (obj.domain != "") {
|
2018-08-24 01:15:57 +10:00
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
if (multi) {
|
2019-05-19 17:39:30 +10:00
|
|
|
show = false;
|
2018-08-24 01:15:57 +10:00
|
|
|
var accts = JSON.parse(multi);
|
2019-05-19 17:39:30 +10:00
|
|
|
Object.keys(accts).forEach(function (key) {
|
2018-08-24 01:15:57 +10:00
|
|
|
var acct = accts[key];
|
2019-05-19 17:39:30 +10:00
|
|
|
if (acct.domain == obj.domain) {
|
|
|
|
show = true;
|
2018-08-24 01:15:57 +10:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
if (show) {
|
2019-06-07 02:11:04 +10:00
|
|
|
M.toast({ html: escapeHTML(obj.Text) + toot + '<span class="sml grey-text">(スライドして消去)</span>', displayLength: 86400 })
|
2018-08-24 01:15:57 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
|
|
|
$("#persons").text(obj.text);
|
|
|
|
}
|
2018-08-24 01:15:57 +10:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
infows.onerror = function (error) {
|
|
|
|
infostreaming = false;
|
2018-08-24 01:15:57 +10:00
|
|
|
console.error("Error closing:info");
|
|
|
|
console.error(error);
|
|
|
|
return false;
|
|
|
|
};
|
2019-05-19 17:39:30 +10:00
|
|
|
infows.onclose = function () {
|
|
|
|
infostreaming = false;
|
2018-08-24 01:15:57 +10:00
|
|
|
console.error("Closing:info");
|
|
|
|
};
|
2019-03-23 01:10:23 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
setInterval(function () {
|
|
|
|
if (!infostreaming) {
|
2019-05-19 16:17:05 +10:00
|
|
|
console.log("try to connect to base-streaming")
|
2019-03-23 01:10:23 +11:00
|
|
|
infowebsocket();
|
|
|
|
}
|
2019-05-19 16:17:05 +10:00
|
|
|
}, 10000);
|
2019-05-19 17:39:30 +10:00
|
|
|
function openRN() {
|
2019-05-19 16:17:05 +10:00
|
|
|
$('#releasenote').modal('open');
|
2019-05-19 17:39:30 +10:00
|
|
|
if (lang.language == "ja") {
|
|
|
|
verp = ver.replace('(', '');
|
|
|
|
verp = verp.replace('.', '-');
|
|
|
|
verp = verp.replace('.', '-');
|
|
|
|
verp = verp.replace('[', '-');
|
|
|
|
verp = verp.replace(']', '');
|
|
|
|
verp = verp.replace(')', '');
|
|
|
|
verp = verp.replace(' ', '_');
|
|
|
|
$("#release-" + verp).show();
|
|
|
|
} else {
|
2019-05-19 16:17:05 +10:00
|
|
|
$("#release-en").show();
|
|
|
|
}
|
2019-06-04 02:26:00 +10:00
|
|
|
}
|
|
|
|
function closeSupport() {
|
|
|
|
$("#support-btm").animate({
|
|
|
|
'bottom': '-300px'
|
|
|
|
}, {
|
|
|
|
'duration': 300,
|
|
|
|
'complete': function () {
|
|
|
|
$("#support-btm").addClass("hide")
|
|
|
|
}
|
|
|
|
});
|
2019-05-19 16:17:05 +10:00
|
|
|
}
|