2018-01-28 23:22:43 +11:00
|
|
|
//バージョンチェッカー
|
2018-12-09 05:46:01 +11:00
|
|
|
function verck(ver,winstore) {
|
2018-05-26 02:37:35 +10:00
|
|
|
if(localStorage.getItem("ver")!=ver){
|
|
|
|
localStorage.setItem("ver", ver);
|
|
|
|
console.log("Thank you for your update");
|
|
|
|
$(document).ready(function(){
|
|
|
|
$('#releasenote').modal('open');
|
|
|
|
verp=ver.replace( '(', '');
|
|
|
|
verp=verp.replace( '.', '-');
|
2018-06-12 01:44:28 +10:00
|
|
|
verp=verp.replace( '.', '-');
|
2018-05-26 02:37:35 +10:00
|
|
|
verp=verp.replace( '[', '-');
|
|
|
|
verp=verp.replace( ']', '');
|
|
|
|
verp=verp.replace( ')', '');
|
|
|
|
verp=verp.replace( ' ', '_');
|
2018-06-12 01:44:28 +10:00
|
|
|
console.log(verp);
|
2018-05-26 02:37:35 +10:00
|
|
|
$("#release-"+verp).show();
|
|
|
|
});
|
|
|
|
}
|
2019-03-07 02:48:18 +11:00
|
|
|
var electron = require("electron");
|
|
|
|
var remote=electron.remote;
|
|
|
|
var dialog=remote.dialog;
|
|
|
|
const options = {
|
|
|
|
type: 'info',
|
|
|
|
title: "Select your platform",
|
|
|
|
message: lang.lang_version_platform,
|
|
|
|
buttons: [lang.lang_no,lang.lang_yesno]
|
|
|
|
}
|
|
|
|
var platform=remote.process.platform;
|
|
|
|
if(platform=="win32"){
|
|
|
|
console.log(localStorage.getItem("winstore"))
|
|
|
|
if(!localStorage.getItem("winstore")){
|
|
|
|
|
|
|
|
dialog.showMessageBox(options, function(arg) {
|
|
|
|
if(arg==1){
|
|
|
|
localStorage.setItem("winstore","winstore")
|
|
|
|
}else{
|
|
|
|
localStorage.setItem("winstore","localinstall")
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}else{
|
|
|
|
localStorage.setItem("winstore","unix")
|
|
|
|
}
|
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 = "";
|
|
|
|
for(var i=0; i<l; i++){
|
|
|
|
r += c[Math.floor(Math.random()*cl)];
|
|
|
|
}
|
|
|
|
var start = "https://thedesk.top/ver.json";
|
2018-01-28 23:22:43 +11:00
|
|
|
fetch(start, {
|
|
|
|
method: 'GET'
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(mess) {
|
|
|
|
console.log(mess);
|
|
|
|
if (mess) {
|
2018-07-07 03:51:48 +10:00
|
|
|
var electron = require("electron");
|
|
|
|
var remote=electron.remote;
|
|
|
|
var platform=remote.process.platform;
|
|
|
|
if(platform=="darwin"){
|
|
|
|
var newest=mess.desk_mac;
|
|
|
|
}else{
|
|
|
|
var newest=mess.desk;
|
|
|
|
}
|
|
|
|
if (newest == ver) {
|
2019-01-26 14:24:26 +11:00
|
|
|
todo(lang.lang_version_usever.replace("{{ver}}" ,mess.desk));
|
2018-09-06 02:53:12 +10:00
|
|
|
//betaかWInstoreならアプデチェックしない
|
2018-12-09 05:46:01 +11:00
|
|
|
} else if (ver.indexOf("beta")!=-1 || winstore) {
|
|
|
|
|
|
|
|
}else{
|
2018-02-25 19:41:34 +11:00
|
|
|
localStorage.removeItem("instance")
|
2018-07-22 23:03:46 +10:00
|
|
|
if(localStorage.getItem("new-ver-skip")){
|
|
|
|
if(localStorage.getItem("next-ver")!=newest){
|
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
ipc.send('update', "true");
|
|
|
|
}else{
|
2019-01-26 14:24:26 +11:00
|
|
|
todo(lang.lang_version_skipver);
|
2018-07-22 23:03:46 +10:00
|
|
|
}
|
|
|
|
}else{
|
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
ipc.send('update', "true");
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2018-08-24 01:15:57 +10:00
|
|
|
if(!localStorage.getItem("last-notice-id")){
|
|
|
|
localStorage.setItem("last-notice-id",0)
|
|
|
|
}
|
|
|
|
console.log(localStorage.getItem("last-notice-id"))
|
|
|
|
var start = "https://thedesk.top/notice?since_id="+localStorage.getItem("last-notice-id");
|
|
|
|
console.log(start);
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET'
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(mess) {
|
|
|
|
console.log(mess.length);
|
|
|
|
if(mess.length<1){
|
|
|
|
return false;
|
|
|
|
}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;
|
|
|
|
if(obj.Toot!=""){
|
|
|
|
var toot='<button class="btn-flat toast-action" onclick="detEx(\''+obj.Toot+'\',\'main\')">Show</button>';
|
|
|
|
}else{
|
|
|
|
var toot="";
|
|
|
|
}
|
|
|
|
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){
|
|
|
|
Materialize.toast(obj.Text+toot+'<span class="sml grey-text">(スライドして消去)</span>', 86400);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
infows = new WebSocket("wss://thedesk.top/ws/");
|
|
|
|
infows.onopen = function(mess) {
|
|
|
|
console.log(tlid + ":Connect Streaming Info:");
|
|
|
|
console.log(mess);
|
|
|
|
}
|
|
|
|
infows.onmessage = function(mess) {
|
|
|
|
console.log(":Receive Streaming:");
|
|
|
|
console.log(JSON.parse(mess.data));
|
|
|
|
var obj=JSON.parse(mess.data);
|
|
|
|
if(obj.type!="counter"){
|
|
|
|
if(obj.id*1<=localStorage.getItem("last-notice-id")){
|
|
|
|
|
|
|
|
}else{
|
|
|
|
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="";
|
|
|
|
}
|
|
|
|
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){
|
|
|
|
Materialize.toast(obj.text+toot+'<span class="sml grey-text">(スライドして消去)</span>', 86400);
|
|
|
|
}
|
|
|
|
}
|
2018-08-29 20:17:34 +10:00
|
|
|
}else{
|
|
|
|
$("#persons").text(obj.text);
|
2018-08-24 01:15:57 +10:00
|
|
|
}
|
|
|
|
}
|
|
|
|
infows.onerror = function(error) {
|
|
|
|
console.error("Error closing:info");
|
|
|
|
console.error(error);
|
|
|
|
return false;
|
|
|
|
};
|
|
|
|
infows.onclose = function() {
|
|
|
|
console.error("Closing:info");
|
|
|
|
};
|
|
|
|
}
|