diff --git a/app/js/common/version.js b/app/js/common/version.js
index ee3ecdae..1fbfe991 100644
--- a/app/js/common/version.js
+++ b/app/js/common/version.js
@@ -1,13 +1,13 @@
//バージョンチェッカー
function verck(ver, jp) {
- console.log("%c Welcome😊", "color: red;font-size:200%;")
+ console.log("%c Welcome😊", "color: red;font-size:200%;");
var date = new Date();
- var show = false
+ var show = false;
if (localStorage.getItem("ver") != ver && localStorage.getItem("winstore")) {
//ちょっと削除とリンク解析の都合上アレ(s)
//対象外のアプデ:storageが20の最初まで"Usamin (18.6.5)"
if (!localStorage.getItem("usamin_18_6_5_flag")) {
- localStorage.setItem("usamin_18_6_5_flag", true)
+ localStorage.setItem("usamin_18_6_5_flag", true);
var multi = localStorage.getItem("column");
var obj = JSON.parse(multi);
for (var i = 0; i < obj.length; i++) {
@@ -15,19 +15,19 @@ function verck(ver, jp) {
}
}
//ちょっと削除とリンク解析の都合上アレ(e)
- show = true
+ show = true;
console.log("%c Thank you for your update🎉", "color: red;font-size:200%;");
- $(document).ready(function () {
+ $(document).ready(function() {
if (localStorage.getItem("winstore")) {
- $('#releasenote').modal('open');
+ $("#releasenote").modal("open");
}
- verp = ver.replace('(', '');
- verp = verp.replace('.', '-');
- verp = verp.replace('.', '-');
- verp = verp.replace('[', '-');
- verp = verp.replace(']', '');
- verp = verp.replace(')', '');
- verp = verp.replace(' ', '_');
+ 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();
@@ -38,30 +38,33 @@ function verck(ver, jp) {
}
localStorage.setItem("ver", ver);
if (!show) {
- console.log(show)
+ console.log(show);
if (date.getMonth() + 1 >= localStorage.getItem("showSupportMe") || !localStorage.getItem("showSupportMe")) {
if (date.getMonth() == 11) {
- var nextmonth = 1
+ var nextmonth = 1;
} else {
- var nextmonth = date.getMonth() + 2
+ var nextmonth = date.getMonth() + 2;
}
if (lang.language != "ja") {
$("#support-btm-ja").addClass("hide");
$("#support-btm-en").removeClass("hide");
}
- localStorage.setItem("showSupportMe", nextmonth)
- $("#support-btm").removeClass("hide")
- $("#support-btm").animate({
- 'bottom': '0'
- }, {
- 'duration': 300
- });
+ localStorage.setItem("showSupportMe", nextmonth);
+ $("#support-btm").removeClass("hide");
+ $("#support-btm").animate(
+ {
+ bottom: "0"
+ },
+ {
+ duration: 300
+ }
+ );
}
}
var platform = localStorage.getItem("platform");
- console.log("Your platform:" + platform)
+ console.log("Your platform:" + platform);
if (!localStorage.getItem("winstore")) {
- $("#start").css('display', 'flex');
+ $("#start").css("display", "flex");
}
if (localStorage.getItem("winstore") == "brewcask" || localStorage.getItem("winstore") == "snapcraft" || localStorage.getItem("winstore") == "winstore") {
var winstore = true;
@@ -78,124 +81,138 @@ function verck(ver, jp) {
}
var start = "https://thedesk.top/ver.json";
fetch(start, {
- method: 'GET'
- }).then(function (response) {
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (mess) {
- console.table(mess);
- if (mess) {
- //askjp_jp_ua: 2019年10月24日、mstdn.jpによるユーザーエージェントアクセス制限
- if(jp && mess.jp_ua && !localStorage.getItem("askjp_jp_ua")){
- localStorage.setItem("askjp_jp_ua", true)
- $("#askjp_jp_ua").removeClass("hide")
+ method: "GET"
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
- var platform = localStorage.getItem("platform");
- if (platform == "darwin") {
- var newest = mess.desk_mac;
- } else {
- var newest = mess.desk;
- }
- if (newest == ver) {
- todo(lang.lang_version_usever.replace("{{ver}}", mess.desk));
- //betaかWinstoreならアプデチェックしない
- } else if (ver.indexOf("beta") != -1 || winstore) {
-
- } else {
- localStorage.removeItem("instance")
- if (localStorage.getItem("new-ver-skip")) {
- if (localStorage.getItem("next-ver") != newest) {
- postMessage(["sendSinmpleIpc", "update"], "*")
- } else {
- console.warn(lang.lang_version_skipver);
- todo(lang.lang_version_skipver);
- }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ console.error(error);
+ })
+ .then(function(mess) {
+ console.table(mess);
+ if (mess) {
+ //askjp_jp_ua: 2019年10月24日、mstdn.jpによるユーザーエージェントアクセス制限
+ if (jp && mess.jp_ua && !localStorage.getItem("askjp_jp_ua")) {
+ localStorage.setItem("askjp_jp_ua", true);
+ $("#askjp_jp_ua").removeClass("hide");
+ }
+ var platform = localStorage.getItem("platform");
+ if (platform == "darwin") {
+ var newest = mess.desk_mac;
} else {
- postMessage(["sendSinmpleIpc", "update"], "*")
+ var newest = mess.desk;
+ }
+ if (newest == ver) {
+ todo(lang.lang_version_usever.replace("{{ver}}", mess.desk));
+ //betaかWinstoreならアプデチェックしない
+ } else if (ver.indexOf("beta") != -1 || winstore) {
+ } else {
+ localStorage.removeItem("instance");
+ if (localStorage.getItem("new-ver-skip")) {
+ if (localStorage.getItem("next-ver") != newest) {
+ postMessage(["sendSinmpleIpc", "update"], "*");
+ } else {
+ console.warn(lang.lang_version_skipver);
+ todo(lang.lang_version_skipver);
+ }
+ } else {
+ postMessage(["sendSinmpleIpc", "update"], "*");
+ }
}
}
- }
- });
+ });
if (!localStorage.getItem("last-notice-id")) {
- localStorage.setItem("last-notice-id", 0)
+ localStorage.setItem("last-notice-id", 0);
}
var start = "https://thedesk.top/notice?since_id=" + localStorage.getItem("last-notice-id");
fetch(start, {
- method: 'GET'
- }).then(function (response) {
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (mess) {
- 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 {
- if (obj.type == "textv2") {
- if (~obj.languages.indexOf(lang.language)) {
- var show = true;
- if (obj.toot != "") {
- var toot = '';
- } else {
- var toot = "";
- }
- if (obj.ver != "") {
- if (obj.ver == ver) {
- show = true;
+ method: "GET"
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ console.error(error);
+ })
+ .then(function(mess) {
+ 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 {
+ if (obj.type == "textv2") {
+ if (~obj.languages.indexOf(lang.language)) {
+ var show = true;
+ if (obj.toot != "") {
+ var toot = '";
} else {
- show = false;
+ var toot = "";
}
- }
- 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 (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) {
+ M.toast({ html: escapeHTML(obj.text) + toot + '(スライドして消去)', displayLength: 86400 });
}
- }
- if (show) {
- M.toast({ html: escapeHTML(obj.text) + toot + '(スライドして消去)', displayLength: 86400 })
}
}
}
}
-
}
- }
- });
+ });
}
var infostreaming = false;
function infowebsocket() {
infows = new WebSocket("wss://thedesk.top/ws/");
- infows.onopen = function (mess) {
+ infows.onopen = function(mess) {
console.log([tlid, ":Connect Streaming Info:", mess]);
infostreaming = true;
- }
- infows.onmessage = function (mess) {
+ };
+ infows.onmessage = function(mess) {
console.log([tlid, ":Receive Streaming:", JSON.parse(mess.data)]);
var obj = JSON.parse(mess.data);
if (obj.type != "counter") {
if (obj.type == "textv2") {
if (~obj.languages.indexOf(lang.language)) {
- localStorage.setItem("last-notice-id", obj.id)
+ localStorage.setItem("last-notice-id", obj.id);
var show = true;
if (obj.toot != "") {
- var toot = '';
+ var toot = '";
} else {
var toot = "";
}
@@ -211,7 +228,7 @@ function infowebsocket() {
if (multi) {
show = false;
var accts = JSON.parse(multi);
- Object.keys(accts).forEach(function (key) {
+ Object.keys(accts).forEach(function(key) {
var acct = accts[key];
if (acct.domain == obj.domain) {
show = true;
@@ -220,57 +237,60 @@ function infowebsocket() {
}
}
if (show) {
- console.log(obj.text)
- console.log(escapeHTML(obj.text))
- M.toast({ html: escapeHTML(obj.text) + toot + '(スライドして消去)', displayLength: 86400 })
+ console.log(obj.text);
+ console.log(escapeHTML(obj.text));
+ M.toast({ html: escapeHTML(obj.text) + toot + '(スライドして消去)', displayLength: 86400 });
}
}
}
} else {
$("#persons").text(obj.text);
}
- }
- infows.onerror = function (error) {
+ };
+ infows.onerror = function(error) {
infostreaming = false;
console.error("Error closing:info");
console.error(error);
return false;
};
- infows.onclose = function () {
+ infows.onclose = function() {
infostreaming = false;
console.error("Closing:info");
};
}
-setInterval(function () {
+setInterval(function() {
if (!infostreaming) {
- console.log("try to connect to base-streaming")
+ console.log("try to connect to base-streaming");
infowebsocket();
}
}, 10000);
function openRN() {
- $('#releasenote').modal('open');
+ $("#releasenote").modal("open");
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(' ', '_');
+ 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 {
$("#release-en").show();
}
}
function closeSupport() {
- $("#support-btm").animate({
- 'bottom': '-300px'
- }, {
- 'duration': 300,
- 'complete': function () {
- $("#support-btm").addClass("hide")
+ $("#support-btm").animate(
+ {
+ bottom: "-300px"
+ },
+ {
+ duration: 300,
+ complete: function() {
+ $("#support-btm").addClass("hide");
}
- });
+ }
+ );
}
function storeDialog(platform, ver) {
if (platform == "win32") {
@@ -283,31 +303,31 @@ function storeDialog(platform, ver) {
Swal.fire({
title: "Select your platform",
text: mes,
- type: 'info',
+ type: "info",
showCancelButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#3085d6',
+ confirmButtonColor: "#3085d6",
+ cancelButtonColor: "#3085d6",
confirmButtonText: lang.lang_no,
cancelButtonText: lang.lang_yesno
- }).then((result) => {
+ }).then(result => {
//逆にしてる
if (!result.value) {
- localStorage.setItem("winstore", "winstore")
+ localStorage.setItem("winstore", "winstore");
} else {
- localStorage.setItem("winstore", "localinstall")
+ localStorage.setItem("winstore", "localinstall");
}
localStorage.setItem("ver", ver);
- show = true
+ show = true;
console.log("%c Thank you for your update🎉", "color: red;font-size:200%;");
- $(document).ready(function () {
- $('#releasenote').modal('open');
- verp = ver.replace('(', '');
- verp = verp.replace('.', '-');
- verp = verp.replace('.', '-');
- verp = verp.replace('[', '-');
- verp = verp.replace(']', '');
- verp = verp.replace(')', '');
- verp = verp.replace(' ', '_');
+ $(document).ready(function() {
+ $("#releasenote").modal("open");
+ 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();
@@ -315,11 +335,11 @@ function storeDialog(platform, ver) {
$("#release-en").show();
}
});
- })
+ });
}
function closeStart() {
- $("#start").css('display', 'none');
+ $("#start").css("display", "none");
var platform = localStorage.getItem("platform");
var ver = localStorage.getItem("ver");
- storeDialog(platform, ver)
-}
\ No newline at end of file
+ storeDialog(platform, ver);
+}
diff --git a/app/js/login/login.js b/app/js/login/login.js
index 51859ebd..79260023 100644
--- a/app/js/login/login.js
+++ b/app/js/login/login.js
@@ -76,6 +76,7 @@ function login(url) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
var auth = "https://" + url + "/oauth/authorize?client_id=" + json[
"client_id"] + "&client_secret=" + json["client_secret"] +
"&response_type=code&redirect_uri=" + red + "&scope=read+write+follow";
@@ -129,6 +130,11 @@ function code(code, mode) {
code: code
})
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -160,6 +166,11 @@ function getdata() {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -207,6 +218,11 @@ function getdataAdv(domain, at) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -265,6 +281,11 @@ function refresh(target, loadskip) {
'Authorization': 'Bearer ' + obj[target].at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -531,6 +552,11 @@ function ticker() {
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
console.error(error);
diff --git a/app/js/login/manager.js b/app/js/login/manager.js
index 414b4f1f..fc7ee277 100644
--- a/app/js/login/manager.js
+++ b/app/js/login/manager.js
@@ -85,7 +85,12 @@ function data(domain) {
}
})
.then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
@@ -114,7 +119,12 @@ function data(domain) {
}
})
.then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
@@ -320,6 +330,7 @@ function login(url) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
localStorage.setItem("msky", "false");
var auth = "https://" + url + "/oauth/authorize?client_id=" + json["client_id"] + "&client_secret=" + json["client_secret"] + "&response_type=code&scope=read+write+follow&redirect_uri=" + encodeURIComponent(red);
localStorage.setItem("domain_tmp", url);
@@ -345,7 +356,12 @@ function versionChecker(url) {
}
})
.then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
@@ -378,7 +394,12 @@ function versionCompat(prefix, ver, title, real) {
}
})
.then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
@@ -437,6 +458,7 @@ function misskeyLogin(url) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
misskeyAuth(url, json.secret);
}
};
@@ -458,6 +480,7 @@ function misskeyAuth(url, mkc) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
var token = json.token;
$("#auth").show();
$("#code").val(token);
@@ -486,9 +509,9 @@ function code(code) {
var code = $("#code").val();
$("#code").val("");
}
- if(!code || code==""){
+ if (!code || code == "") {
M.toast({ html: lang.lang_fatalerroroccured + "Error: no code", displayLength: 5000 });
- return false
+ return false;
}
var url = localStorage.getItem("domain_tmp");
localStorage.removeItem("domain_tmp");
@@ -507,6 +530,7 @@ function code(code) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
var i = sha256(json.accessToken + localStorage.getItem("mkc"));
var avatar = json["user"]["avatarUrl"];
var priv = "public";
@@ -563,6 +587,7 @@ function code(code) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
if (json["access_token"]) {
$("#auth").hide();
$("#add").show();
@@ -583,7 +608,12 @@ function getdata(domain, at) {
}
})
.then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
@@ -664,9 +694,9 @@ function atSetup(type) {
mode: ""
};
}
- if(!i || i==""){
+ if (!i || i == "") {
M.toast({ html: lang.lang_fatalerroroccured + "Error: access token", displayLength: 5000 });
- return false
+ return false;
}
var obj = JSON.parse(multi);
var target = obj.length;
@@ -684,7 +714,7 @@ function atSetup(type) {
function refresh(target) {
var multi = localStorage.getItem("multi");
var obj = JSON.parse(multi);
- console.log(obj)
+ console.log(obj);
if (obj[target].mode == "misskey") {
misskeyRefresh(obj, target, obj[target].domain);
return;
@@ -698,7 +728,17 @@ function refresh(target) {
}
})
.then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
@@ -755,6 +795,7 @@ function misskeyRefresh(obj, target, url) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
var avatar = json["user"]["avatarUrl"];
var priv = "public";
var add = {
@@ -879,7 +920,12 @@ input.addEventListener(
}
})
.then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
diff --git a/app/js/platform/first.js b/app/js/platform/first.js
index 403c3a0e..e79f0f6c 100644
--- a/app/js/platform/first.js
+++ b/app/js/platform/first.js
@@ -196,4 +196,19 @@ function object_array_sort(data, key, order, fn) {
}
fn(data);
}
-localStorage.removeItem("errors");
\ No newline at end of file
+function setLog(txt1, txt2,txt3){
+ //url,statuscode,responsetext
+ var text = new Date().toUTCString()
+ text=text+","+txt1+","+txt2+","+escapeCsv(txt3)
+ console.error(text)
+ postMessage(["log", text], "*")
+}
+function escapeCsv(str) {
+ if(!str){return str;}
+ var result;
+ result = str.replace(/\"/g, "\"\"");
+ if (result.indexOf(",") >= 0) {
+ result = "\"" + result + "\""
+ }
+ return result;
+}
\ No newline at end of file
diff --git a/app/js/platform/nano.js b/app/js/platform/nano.js
index c871b4ed..7147145d 100644
--- a/app/js/platform/nano.js
+++ b/app/js/platform/nano.js
@@ -25,6 +25,11 @@ function tl(data) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
console.error(error);
@@ -199,6 +204,7 @@ function post() {
httpreq.send(JSON.stringify(toot));
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
+ if(this.status!==200){ setLog(start, this.status, this.response); }
$("#textarea").val("");
}
};
diff --git a/app/js/platform/preload.js b/app/js/platform/preload.js
index da1c733a..367bf6eb 100644
--- a/app/js/platform/preload.js
+++ b/app/js/platform/preload.js
@@ -63,6 +63,8 @@ onmessage = function(e) {
ipc.send("sendMarkersComplete", null);
} else if (e.data[0] == "copy") {
ipc.send("copy", e.data[1]);
+ } else if (e.data[0] == "log") {
+ ipc.send("log", e.data[1]);
}
};
//version.js
diff --git a/app/js/post/emoji.js b/app/js/post/emoji.js
index ae096630..d387d005 100644
--- a/app/js/post/emoji.js
+++ b/app/js/post/emoji.js
@@ -62,7 +62,12 @@ function emojiGet(parse, started) {
'content-type': 'application/json'
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -133,7 +138,12 @@ function emojiGet(parse, started) {
'content-type': 'application/json'
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
diff --git a/app/js/post/img.js b/app/js/post/img.js
index c869874d..e9e03e9b 100644
--- a/app/js/post/img.js
+++ b/app/js/post/img.js
@@ -118,6 +118,7 @@ function media(b64, type, no) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
if (!json.id) {
todc();
$("#imgup").text("");
@@ -267,7 +268,12 @@ function altImage(acct_id, id) {
})
})
.then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
diff --git a/app/js/post/misskeystatus.js b/app/js/post/misskeystatus.js
index e5190574..6b4ba699 100644
--- a/app/js/post/misskeystatus.js
+++ b/app/js/post/misskeystatus.js
@@ -17,6 +17,7 @@ function renote(id, acct_id, remote) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
console.log(["Success: renote", json]);
$("[toot-id=" + id + "]").addClass("rted");
$(".rt_" + id).toggleClass("teal-text");
@@ -63,6 +64,7 @@ function reactiontoggle(id, acct_id, tlid) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
console.log(["Success: reaction", json]);
if (json.reactions) {
var reactions = ["like", "love", "laugh", "hmm", "surprise", "congrats", "angry", "confused", "pudding", "rip"];
@@ -123,7 +125,12 @@ function reactRefresh(acct_id, id) {
}
fetch(start, i,
).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -186,6 +193,7 @@ function reaction(mode, id, acct_id, tlid) {
httpreq.send(JSON.stringify({ i: at, noteId: id, reaction: mode }));
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
+ if(this.status!==200){ setLog(start, this.status, this.response); }
$(".fav_" + id).toggleClass("yellow-text");
}
}
@@ -219,6 +227,7 @@ function voterefresh(acct_id, id) {
httpreqd.onreadystatechange = function () {
if (httpreqd.readyState == 4) {
var json = httpreqd.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
if (!json) {
return false;
}
diff --git a/app/js/post/post.js b/app/js/post/post.js
index 52563c3c..7eb95496 100644
--- a/app/js/post/post.js
+++ b/app/js/post/post.js
@@ -153,6 +153,7 @@ function post(mode, postvis) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
var box = localStorage.getItem("box");
if (box == "yes" || !box) {
$("#textarea").blur();
@@ -224,6 +225,7 @@ function misskeyPost() {
localStorage.removeItem("stable")
}
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
console.log(["Success: toot", json]);
var box = localStorage.getItem("box");
if (box == "yes") {
diff --git a/app/js/post/status.js b/app/js/post/status.js
index 4a24cff3..dc1d69ff 100644
--- a/app/js/post/status.js
+++ b/app/js/post/status.js
@@ -18,6 +18,7 @@ function fav(id, acct_id, remote) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
if (json.reblog) {
json = json.reblog;
}
@@ -75,6 +76,7 @@ function rt(id, acct_id, remote, vis) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
if (json.reblog) {
json = json.reblog;
}
@@ -147,6 +149,7 @@ function follow(acct_id, remote) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, json); }
console.log(["Success: folllow", json]);
if ($("#his-data").hasClass("following")) {
$("#his-data").removeClass("following");
@@ -194,6 +197,7 @@ function block(acct_id) {
httpreq.send();
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
+ if(this.status!==200){ setLog(start, this.status, this.response); }
if ($("#his-data").hasClass("blocking")) {
$("#his-data").removeClass("blocking");
$("#his-block-btn-text").text(lang.lang_status_block);
@@ -251,6 +255,7 @@ function muteDo(acct_id) {
httpreq.send(rq);
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
+ if(this.status!==200){ setLog(start, this.status, this.response); }
if ($("#his-data").hasClass("muting")) {
$("#his-data").removeClass("muting");
$("#his-mute-btn-text").text(lang.lang_status_mute);
@@ -288,6 +293,7 @@ function del(id, acct_id) {
}
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
+ if(this.status!==200){ setLog(start, this.status, this.response); }
}
};
}
@@ -362,6 +368,7 @@ function pin(id, acct_id) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
console.log(["Success: pinned", json]);
if ($("[toot-id=" + id + "]").hasClass("pined")) {
$("[toot-id=" + id + "]").removeClass("pined");
@@ -389,6 +396,7 @@ function request(id, flag, acct_id) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
console.log(["Success: request", "type:" + flag, json]);
showReq();
}
@@ -412,6 +420,7 @@ function domainblock(add, flag, acct_id) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
console.log(["Success: domain block", json]);
showDom();
}
@@ -468,6 +477,7 @@ function pinUser() {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
if ($("#his-end-btn").hasClass("endorsed")) {
$("#his-end-btn").removeClass("endorsed");
$("#his-end-btn").text(lang.lang_status_endorse);
@@ -499,7 +509,12 @@ function staEx(mode) {
}
})
.then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
diff --git a/app/js/post/suggest.js b/app/js/post/suggest.js
index cd5a4313..90f1c363 100644
--- a/app/js/post/suggest.js
+++ b/app/js/post/suggest.js
@@ -113,7 +113,12 @@ input.addEventListener("focus", function () {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -258,7 +263,12 @@ function cgNPs(q) {
'content-type': 'application/json'
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
diff --git a/app/js/tl/card.js b/app/js/tl/card.js
index d768c801..140c7363 100644
--- a/app/js/tl/card.js
+++ b/app/js/tl/card.js
@@ -60,7 +60,12 @@ function additional(acct_id, tlid) {
},
//body: JSON.stringify({})
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -88,6 +93,7 @@ function additional(acct_id, tlid) {
if (this.readyState === 4 && this.status === 200) {
if (this.response) {
var json = this.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
var emojis = json.emojis;
for (i = 0; i < emojis.length; i++) {
var emojie = emojis[i];
@@ -144,7 +150,12 @@ function additionalIndv(tlid, acct_id, id) {
},
//body: JSON.stringify({})
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -168,7 +179,12 @@ function additionalIndv(tlid, acct_id, id) {
},
//body: JSON.stringify({})
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
diff --git a/app/js/tl/datails.js b/app/js/tl/datails.js
index 569b152b..e547750e 100644
--- a/app/js/tl/datails.js
+++ b/app/js/tl/datails.js
@@ -35,6 +35,11 @@ function details(id, acct_id, tlid, mode) {
}
fetch(start, i).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -131,6 +136,11 @@ function replyTL(id, acct_id) {
return false
}
fetch(start, i).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -183,6 +193,11 @@ function getContext(id, acct_id) {
}
}
fetch(start, i).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -241,7 +256,12 @@ function beforeToot(id, acct_id, domain) {
untilID: id
})
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -259,7 +279,12 @@ function beforeToot(id, acct_id, domain) {
'content-type': 'application/json',
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -291,7 +316,12 @@ function userToot(id, acct_id, user) {
userId: user
})
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -309,7 +339,12 @@ function userToot(id, acct_id, user) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -336,6 +371,11 @@ function afterToot(id, acct_id, domain) {
'content-type': 'application/json',
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -361,6 +401,11 @@ function afterUserToot(id, acct_id, user) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -386,6 +431,11 @@ function afterFTLToot(id, acct_id, domain) {
'content-type': 'application/json',
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -413,6 +463,11 @@ function faved(id, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -440,6 +495,11 @@ function rted(id, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -500,6 +560,11 @@ function trans(tar, to) {
fetch(exec, {
method: 'GET',
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -528,6 +593,11 @@ function detEx(url, acct_id) {
'Authorization': 'Bearer ' + at
}
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
diff --git a/app/js/tl/directory.js b/app/js/tl/directory.js
index c5fee767..33e8be84 100644
--- a/app/js/tl/directory.js
+++ b/app/js/tl/directory.js
@@ -51,7 +51,12 @@ function directory(isMore) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
//todo(error);
console.error(error);
diff --git a/app/js/tl/dm.js b/app/js/tl/dm.js
index 079dc737..4602c2d5 100644
--- a/app/js/tl/dm.js
+++ b/app/js/tl/dm.js
@@ -11,6 +11,11 @@ function dm(acct_id, tlid, type, delc, voice) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -43,6 +48,11 @@ function dmmore(tlid) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
diff --git a/app/js/tl/filter.js b/app/js/tl/filter.js
index 2c52d94a..6ada0237 100644
--- a/app/js/tl/filter.js
+++ b/app/js/tl/filter.js
@@ -121,6 +121,11 @@ function filter() {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -199,6 +204,7 @@ function makeNewFilter() {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
filter();
filterUpdate(acct_id)
$("#filter-add-word").val("");
@@ -239,6 +245,11 @@ function filterEdit(id, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -282,6 +293,7 @@ function filterDel(id, acct_id) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
filter();
filterUpdate(acct_id)
}
@@ -299,7 +311,12 @@ function getFilter(acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -342,6 +359,11 @@ function filterUpdate(acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
diff --git a/app/js/tl/list.js b/app/js/tl/list.js
index 6e6af919..05b10678 100644
--- a/app/js/tl/list.js
+++ b/app/js/tl/list.js
@@ -21,7 +21,12 @@ function list() {
i: at
}),
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -47,7 +52,12 @@ function list() {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -85,6 +95,7 @@ function makeNewList() {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
list();
$("#list-add").val("")
}
@@ -102,6 +113,7 @@ function makeNewList() {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
list();
$("#list-add").val("")
}
@@ -123,6 +135,11 @@ function listUser(id, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -153,7 +170,12 @@ function hisList(user, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -178,7 +200,12 @@ function hisList(user, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -203,7 +230,12 @@ function hisList(user, acct_id) {
i: at
}),
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -249,6 +281,7 @@ function listAdd(id, user, acct_id) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
hisList(user, acct_id)
}
}
@@ -280,6 +313,7 @@ function listRemove(id, user, acct_id) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
hisList(user, acct_id)
}
}
diff --git a/app/js/tl/mix.js b/app/js/tl/mix.js
index e2ee13c5..20f17382 100644
--- a/app/js/tl/mix.js
+++ b/app/js/tl/mix.js
@@ -14,6 +14,11 @@ function mixtl(acct_id, tlid, type, delc, voice) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -27,7 +32,12 @@ function mixtl(acct_id, tlid, type, delc, voice) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -267,6 +277,11 @@ function mixmore(tlid, type) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -280,7 +295,12 @@ function mixmore(tlid, type) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
diff --git a/app/js/tl/notification.js b/app/js/tl/notification.js
index 37af46b5..48463025 100644
--- a/app/js/tl/notification.js
+++ b/app/js/tl/notification.js
@@ -43,6 +43,7 @@ function notfColumn(acct_id, tlid, sys) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
var max_id = httpreq.getResponseHeader("link");
if (max_id) {
max_id = max_id.match(/[?&]{1}max_id=([0-9]+)/)[1]
@@ -152,6 +153,11 @@ function notfCommon(acct_id, tlid, sys) {
}
fetch(start, i).then(function (response) {
console.log("header to get param:" + response.headers.get('link'));
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -317,6 +323,7 @@ function notfmore(tlid) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
console.log(["More notifications on " + tlid, json]);
var max_id = httpreq.getResponseHeader("link").match(/[?&]{1}max_id=([0-9]+)/)[1];
if (json[0]) {
diff --git a/app/js/tl/old-mix.js b/app/js/tl/old-mix.js
index 9bb938fb..65708629 100644
--- a/app/js/tl/old-mix.js
+++ b/app/js/tl/old-mix.js
@@ -15,6 +15,11 @@ function mixtl(acct_id, tlid) {
'Authorization': 'Bearer ' + at
},
}).then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function(error) {
todo(error);
@@ -38,7 +43,12 @@ function mixtl(acct_id, tlid) {
'Authorization': 'Bearer ' + at
},
}).then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function(error) {
todo(error);
console.error(error);
@@ -193,6 +203,11 @@ function mixmore(tlid) {
'Authorization': 'Bearer ' + at
},
}).then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function(error) {
todo(error);
@@ -211,7 +226,12 @@ function mixmore(tlid) {
'Authorization': 'Bearer ' + at
},
}).then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function(error) {
todo(error);
console.error(error);
diff --git a/app/js/tl/poll.js b/app/js/tl/poll.js
index ac5bfde5..9c70344a 100644
--- a/app/js/tl/poll.js
+++ b/app/js/tl/poll.js
@@ -114,6 +114,7 @@ function voteMastodonrefresh(acct_id, id) {
httpreqd.send();
httpreqd.onreadystatechange = function () {
if (httpreqd.readyState == 4) {
+ if(this.status!==200){ setLog(start, this.status, this.response); }
var json = httpreqd.response;
console.log(["Refresh vote", json]);
if (!json) {
diff --git a/app/js/tl/src.js b/app/js/tl/src.js
index cd5da7ba..19e50de7 100644
--- a/app/js/tl/src.js
+++ b/app/js/tl/src.js
@@ -46,6 +46,11 @@ function src(mode, offset) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
src("v1")
@@ -110,6 +115,11 @@ function tootsearch(tlid, q) {
'content-type': 'application/json'
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -149,6 +159,11 @@ function moreTs(tlid, q) {
'content-type': 'application/json'
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -223,6 +238,11 @@ function trend() {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
//todo(error);
diff --git a/app/js/tl/tag.js b/app/js/tl/tag.js
index 6ac3ba5f..b32d31c0 100644
--- a/app/js/tl/tag.js
+++ b/app/js/tl/tag.js
@@ -87,7 +87,12 @@ function trendTag() {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -143,6 +148,11 @@ function tagFeature(name, acct_id){
name: name
})
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
return false;
diff --git a/app/js/tl/tl.js b/app/js/tl/tl.js
index 39c4bb19..d9afe93b 100644
--- a/app/js/tl/tl.js
+++ b/app/js/tl/tl.js
@@ -128,6 +128,11 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
console.log(["Try to get timeline of " + tlid, start])
fetch(start, i).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -438,7 +443,12 @@ function moreload(type, tlid) {
};
}
fetch(start, i).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -551,7 +561,12 @@ function tlDiff(type, data, acct_id, tlid, delc, voice, mode) {
fetch(start, i).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
@@ -897,6 +912,11 @@ function getMarker(tlid, type, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
$("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + lang.lang_nothing)
@@ -940,6 +960,11 @@ function showUnread(tlid, type, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -991,6 +1016,11 @@ function ueload(tlid) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -1062,6 +1092,7 @@ function asRead(callback) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response
+ if(this.status!==200){ setLog(start, this.status, this.response); }
console.log(json)
ct++
if (ct == obl && callback) {
diff --git a/app/js/ui/settings.js b/app/js/ui/settings.js
index a9874619..d8cdd5ea 100644
--- a/app/js/ui/settings.js
+++ b/app/js/ui/settings.js
@@ -727,6 +727,11 @@ function checkupd(){
fetch(start, {
method: 'GET'
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
diff --git a/app/js/ui/spotify.js b/app/js/ui/spotify.js
index 0d73e9cd..bfab5905 100644
--- a/app/js/ui/spotify.js
+++ b/app/js/ui/spotify.js
@@ -66,7 +66,12 @@ function nowplaying(mode) {
'content-type': 'application/json'
}
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
diff --git a/app/js/ui/tips.js b/app/js/ui/tips.js
index 4318a0f8..8ef05985 100644
--- a/app/js/ui/tips.js
+++ b/app/js/ui/tips.js
@@ -66,6 +66,11 @@ function trendTagonTip() {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -96,7 +101,12 @@ function spotifytips() {
'content-type': 'application/json'
}
}).then(function (response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
}).catch(function (error) {
todo(error);
console.error(error);
diff --git a/app/js/userdata/his-data.js b/app/js/userdata/his-data.js
index 4e877055..6e937c56 100644
--- a/app/js/userdata/his-data.js
+++ b/app/js/userdata/his-data.js
@@ -42,6 +42,11 @@ function utl(user, more, acct_id) {
}
}
fetch(start, i).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -87,6 +92,11 @@ function pinutl(before, user, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -144,6 +154,11 @@ function flw(user, more, acct_id) {
}
}
fetch(start, i).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -210,6 +225,11 @@ function fer(user, more, acct_id) {
}
}
fetch(start, i).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -272,6 +292,11 @@ function showFav(more, acct_id) {
}
fetch(start, i).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -333,6 +358,11 @@ function showMut(more, acct_id) {
}
fetch(start, i).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -376,6 +406,11 @@ function showBlo(more, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -433,6 +468,11 @@ function showReq(more, acct_id) {
}
}
fetch(start, i).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -483,6 +523,11 @@ function showDom(more, acct_id) {
},
//body: JSON.stringify({})
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -533,6 +578,11 @@ function showFrl(more, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
$("#his-follow-recom-contents").html(lang.lang_details_nodata + "(" + lang.lang_hisdata_frcreq + ")
");
@@ -566,6 +616,11 @@ function udAdd(acct_id, id, start) {
},
//body: JSON.stringify({})
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -583,6 +638,11 @@ function udAdd(acct_id, id, start) {
'Accept': 'application/json'
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -612,6 +672,11 @@ function showMat() {
},
//body: JSON.stringify({})
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
diff --git a/app/js/userdata/prof-edit.js b/app/js/userdata/prof-edit.js
index 17d0e1e1..939b2ad0 100644
--- a/app/js/userdata/prof-edit.js
+++ b/app/js/userdata/prof-edit.js
@@ -52,6 +52,7 @@ function imgChange(imgfile, target) {
httpreq.onreadystatechange = function () {
if (httpreq.readyState === 4) {
var json = httpreq.response;
+ if(this.status!==200){ setLog(start, this.status, this.response); }
$('#his-data').modal('close');
todc();
localStorage.removeItem("image");
diff --git a/app/js/userdata/showOnTL.js b/app/js/userdata/showOnTL.js
index 2da0b6a9..62d974ff 100644
--- a/app/js/userdata/showOnTL.js
+++ b/app/js/userdata/showOnTL.js
@@ -31,6 +31,11 @@ function udgEx(user, acct_id) {
'Authorization': 'Bearer ' + at
}
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -65,6 +70,11 @@ function udg(user, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -235,6 +245,11 @@ function misskeyUdg(user, acct_id) {
userId: user
})
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
@@ -357,6 +372,11 @@ function relations(user, acct_id) {
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
return response.json();
}).catch(function (error) {
todo(error);
diff --git a/app/main.js b/app/main.js
index dfc12db2..d05e1965 100644
--- a/app/main.js
+++ b/app/main.js
@@ -194,10 +194,12 @@ function createWindow() {
// Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) thedesk/18.11.3 Chrome/76.0.3809.146 Electron/6.0.12 Safari/537.36
const crypto = require("crypto");
const N = 100;
- var ua = "Mastodon client: "+crypto
- .randomBytes(N)
- .toString("base64")
- .substring(0, N);
+ var ua =
+ "Mastodon client: " +
+ crypto
+ .randomBytes(N)
+ .toString("base64")
+ .substring(0, N);
}
mainWindow.loadURL(base + lang + "/index.html" + plus, { userAgent: ua });
if (!window_size.x && !window_size.y) {
diff --git a/app/main/system.js b/app/main/system.js
index 24ccee62..7136f938 100644
--- a/app/main/system.js
+++ b/app/main/system.js
@@ -1,116 +1,126 @@
function system(mainWindow, dir, lang, dirname) {
const electron = require("electron");
const app = electron.app;
- const join = require('path').join;
+ const join = require("path").join;
var Jimp = require("jimp");
const fs = require("fs");
- var JSON5 = require('json5');
+ var JSON5 = require("json5");
var ipc = electron.ipcMain;
const clipboard = electron.clipboard;
var tmp_img = join(app.getPath("userData"), "tmp.png");
var ha_path = join(app.getPath("userData"), "hardwareAcceleration");
var ua_path = join(app.getPath("userData"), "useragent");
var lang_path = join(app.getPath("userData"), "language");
+ var log_dir_path = join(app.getPath("userData"), "logs");
const BrowserWindow = electron.BrowserWindow;
const dialog = electron.dialog;
- const os = require('os')
+ const os = require("os");
const language = require("../main/language.js");
//プラットフォーム
- ipc.on('getPlatform', function (e, arg) {
+ ipc.on("getPlatform", function(e, arg) {
try {
- var gitHash = fs.readFileSync("git", 'utf8')
- } catch{
- var gitHash = null
+ var gitHash = fs.readFileSync("git", "utf8");
+ } catch {
+ var gitHash = null;
}
- e.sender.webContents.send('platform', [process.platform, process.arch, process.version, process.versions.chrome, process.versions.electron, gitHash]);
- })
+ e.sender.webContents.send("platform", [process.platform, process.arch, process.version, process.versions.chrome, process.versions.electron, gitHash]);
+ });
//言語
- ipc.on('lang', function (e, arg) {
-
+ ipc.on("lang", function(e, arg) {
console.log("set:" + arg);
fs.writeFileSync(lang_path, arg);
- e.sender.webContents.send('langres', arg);
- })
+ e.sender.webContents.send("langres", arg);
+ });
//エクスポートのダイアログ
- ipc.on('exportSettings', function (e, args) {
- dialog.showSaveDialog(null, {
- title: 'Export',
- properties: ['openFile', 'createDirectory'],
- defaultPath: "export.thedeskconfig.json5"
- }, (savedFiles) => {
- if (!savedFiles) {
- return false;
+ ipc.on("exportSettings", function(e, args) {
+ dialog.showSaveDialog(
+ null,
+ {
+ title: "Export",
+ properties: ["openFile", "createDirectory"],
+ defaultPath: "export.thedeskconfig.json5"
+ },
+ savedFiles => {
+ if (!savedFiles) {
+ return false;
+ }
+ e.sender.webContents.send("exportSettingsFile", savedFiles);
}
- e.sender.webContents.send('exportSettingsFile', savedFiles);
- })
- })
+ );
+ });
//インポートのダイアログ
- ipc.on('importSettings', function (e, args) {
- dialog.showOpenDialog(null, {
- title: 'Import',
- properties: ['openFile'],
- filters: [
- { name: 'TheDesk Config', extensions: ['thedeskconfig', 'thedeskconfigv2', 'json5'] },
- ]
- }, (fileNames) => {
- if (!fileNames) {
- return false;
+ ipc.on("importSettings", function(e, args) {
+ dialog.showOpenDialog(
+ null,
+ {
+ title: "Import",
+ properties: ["openFile"],
+ filters: [{ name: "TheDesk Config", extensions: ["thedeskconfig", "thedeskconfigv2", "json5"] }]
+ },
+ fileNames => {
+ if (!fileNames) {
+ return false;
+ }
+ e.sender.webContents.send("config", JSON5.parse(fs.readFileSync(fileNames[0], "utf8")));
}
- e.sender.webContents.send('config', JSON5.parse(fs.readFileSync(fileNames[0], 'utf8')));
- })
- })
+ );
+ });
//保存フォルダのダイアログ
- ipc.on('savefolder', function (e, args) {
- dialog.showOpenDialog(null, {
- title: 'Save folder',
- properties: ['openDirectory'],
- }, (fileNames) => {
- e.sender.webContents.send('savefolder', fileNames[0]);
- });
- })
+ ipc.on("savefolder", function(e, args) {
+ dialog.showOpenDialog(
+ null,
+ {
+ title: "Save folder",
+ properties: ["openDirectory"]
+ },
+ fileNames => {
+ e.sender.webContents.send("savefolder", fileNames[0]);
+ }
+ );
+ });
//カスタムサウンドのダイアログ
- ipc.on('customSound', function (e, arg) {
- dialog.showOpenDialog(null, {
- title: 'Custom sound',
- properties: ['openFile'],
- filters: [
- { name: 'Audio', extensions: ['mp3', 'aac', 'wav', 'flac', 'm4a'] },
- { name: 'All', extensions: ['*'] },
- ]
- }, (fileNames) => {
- e.sender.webContents.send('customSoundRender', [arg, fileNames[0]]);
- });
- })
+ ipc.on("customSound", function(e, arg) {
+ dialog.showOpenDialog(
+ null,
+ {
+ title: "Custom sound",
+ properties: ["openFile"],
+ filters: [{ name: "Audio", extensions: ["mp3", "aac", "wav", "flac", "m4a"] }, { name: "All", extensions: ["*"] }]
+ },
+ fileNames => {
+ e.sender.webContents.send("customSoundRender", [arg, fileNames[0]]);
+ }
+ );
+ });
//ハードウェアアクセラレーションの無効化
- ipc.on('ha', function (e, arg) {
-
+ ipc.on("ha", function(e, arg) {
if (arg == "true") {
fs.writeFileSync(ha_path, arg);
} else {
- fs.unlink(ha_path, function (err) { });
+ fs.unlink(ha_path, function(err) {});
}
- app.relaunch()
- app.exit()
- })
- ipc.on('ua', function (e, arg) {
+ app.relaunch();
+ app.exit();
+ });
+ ipc.on("ua", function(e, arg) {
if (arg == "") {
- fs.unlink(ua_path, function (err) { });
+ fs.unlink(ua_path, function(err) {});
} else {
fs.writeFileSync(ua_path, arg);
}
- app.relaunch()
- app.exit()
- })
+ app.relaunch();
+ app.exit();
+ });
- ipc.on('quit', (e, args) => {
+ ipc.on("quit", (e, args) => {
app.quit();
});
- ipc.on('about', (e, args) => {
+ ipc.on("about", (e, args) => {
about();
});
function about() {
- var ver = app.getVersion()
+ var ver = app.getVersion();
var window = new BrowserWindow({
webPreferences: {
webviewTag: false,
@@ -120,20 +130,18 @@ function system(mainWindow, dir, lang, dirname) {
},
width: 300,
height: 500,
- "transparent": false, // ウィンドウの背景を透過
- "frame": false, // 枠の無いウィンドウ
- "resizable": false
+ transparent: false, // ウィンドウの背景を透過
+ frame: false, // 枠の無いウィンドウ
+ resizable: false
});
- window.loadURL(dir + '/about.html?ver=' + ver);
- return "true"
+ window.loadURL(dir + "/about.html?ver=" + ver);
+ return "true";
}
- ipc.on('nano', function (e, x, y) {
-
- var nano_info_path = join(app.getPath("userData"),
- "nano-window-position.json");
+ ipc.on("nano", function(e, x, y) {
+ var nano_info_path = join(app.getPath("userData"), "nano-window-position.json");
var window_pos;
try {
- window_pos = JSON.parse(fs.readFileSync(nano_info_path, 'utf8'));
+ window_pos = JSON.parse(fs.readFileSync(nano_info_path, "utf8"));
} catch (e) {
window_pos = [0, 0]; // デフォルトバリュー
}
@@ -146,40 +154,39 @@ function system(mainWindow, dir, lang, dirname) {
},
width: 350,
height: 140,
- "transparent": false, // ウィンドウの背景を透過
- "frame": false, // 枠の無いウィンドウ
- "resizable": false
+ transparent: false, // ウィンドウの背景を透過
+ frame: false, // 枠の無いウィンドウ
+ resizable: false
});
- nanowindow.loadURL(dir + '/nano.html');
+ nanowindow.loadURL(dir + "/nano.html");
nanowindow.setAlwaysOnTop(true);
//nanowindow.toggleDevTools()
nanowindow.setPosition(window_pos[0], window_pos[1]);
- nanowindow.on('close', function () {
+ nanowindow.on("close", function() {
fs.writeFileSync(nano_info_path, JSON.stringify(nanowindow.getPosition()));
});
return true;
- })
+ });
var cbTimer1;
- ipc.on('startmem', (e, arg) => {
- event = e.sender
+ ipc.on("startmem", (e, arg) => {
+ event = e.sender;
cbTimer1 = setInterval(mems, 1000);
});
function mems() {
var mem = os.totalmem() - os.freemem();
if (mainWindow) {
- event.webContents.send('memory', [mem, os.cpus()[0].model, os.totalmem()]);
+ event.webContents.send("memory", [mem, os.cpus()[0].model, os.totalmem()]);
}
}
- ipc.on('endmem', (e, arg) => {
+ ipc.on("endmem", (e, arg) => {
if (cbTimer1) {
clearInterval(cbTimer1);
}
});
-
- ipc.on('export', (e, args) => {
+ ipc.on("export", (e, args) => {
fs.writeFileSync(args[0], JSON5.stringify(args[1]));
- e.sender.webContents.send('exportAllComplete', "");
+ e.sender.webContents.send("exportAllComplete", "");
});
//フォント
function object_array_sort(data, key, order, fn) {
@@ -187,12 +194,13 @@ function system(mainWindow, dir, lang, dirname) {
var num_a = -1;
var num_b = 1;
- if (order === 'asc') { //指定があれば昇順(ASC)
+ if (order === "asc") {
+ //指定があれば昇順(ASC)
num_a = 1;
num_b = -1;
}
- data = data.sort(function (a, b) {
+ data = data.sort(function(a, b) {
var x = a[key];
var y = b[key];
if (x > y) return num_a;
@@ -203,7 +211,7 @@ function system(mainWindow, dir, lang, dirname) {
//重複排除
var arrObj = {};
for (var i = 0; i < data.length; i++) {
- arrObj[data[i]['family']] = data[i];
+ arrObj[data[i]["family"]] = data[i];
}
data = [];
@@ -213,16 +221,56 @@ function system(mainWindow, dir, lang, dirname) {
fn(data); // ソート後の配列を返す
}
- ipc.on('fonts', (e, arg) => {
- const fm = require('font-manager');
+ ipc.on("fonts", (e, arg) => {
+ const fm = require("font-manager");
var fonts = fm.getAvailableFontsSync();
- object_array_sort(fonts, 'family', 'asc', function (fonts_sorted) {
- e.sender.webContents.send('font-list', fonts_sorted);
+ object_array_sort(fonts, "family", "asc", function(fonts_sorted) {
+ e.sender.webContents.send("font-list", fonts_sorted);
});
});
//コピー
- ipc.on('copy', (e, arg) => {
- clipboard.writeText(arg)
+ ipc.on("copy", (e, arg) => {
+ clipboard.writeText(arg);
+ });
+ //ログ
+ ipc.on("log", (e, arg) => {
+ var today = new Date();
+ var todayStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate();
+ var log_path = join(log_dir_path, todayStr + ".log");
+ fs.appendFile(log_path, "\n" + arg, function(err) {
+ if (err) {
+ throw err;
+ }
+ });
+ });
+ //起動時ログディレクトリ存在確認と作成、古ログ削除
+ fs.access(log_dir_path, fs.constants.R_OK | fs.constants.W_OK, error => {
+ var today = new Date();
+ //今日のやつ
+ var todayStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
+ //昨日のやつ
+ today.setDate(today.getDate() - 1);
+ var yestStr = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
+ //一昨日のやつ
+ today.setDate(today.getDate() - 1);
+ var yest2Str = today.getFullYear() + "" + (today.getMonth() + 1) + "" + today.getDate() + ".log";
+ if (error) {
+ if (error.code === "ENOENT") {
+ fs.mkdirSync(log_dir_path);
+ } else {
+ return;
+ }
+ } else {
+ fs.readdir(log_dir_path, function(err, files) {
+ if (err) throw err;
+ files.filter(function(file) {
+ if (file != todayStr && file != yestStr && file != yest2Str) {
+ console.log(file, todayStr, yest2Str, yest2Str);
+ fs.unlinkSync(join(log_dir_path, file));
+ }
+ });
+ });
+ }
});
}
-exports.system = system;
\ No newline at end of file
+exports.system = system;
diff --git a/app/view/make/update.sample.html b/app/view/make/update.sample.html
index b3d24f18..9cc00a3b 100644
--- a/app/view/make/update.sample.html
+++ b/app/view/make/update.sample.html
@@ -148,7 +148,12 @@
headers: { "content-type": "application/json" }
})
.then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
@@ -215,7 +220,12 @@
headers: { "content-type": "application/json" }
})
.then(function(response) {
- return response.json();
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);