Add: JSON parse miss error-log

This commit is contained in:
cutls 2019-11-04 01:10:06 +09:00
parent 5dfb28f2de
commit ffa4ecd673
23 changed files with 3799 additions and 3594 deletions

View File

@ -92,7 +92,8 @@ function verck(ver, jp) {
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);setLog(start, "JSON", error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(mess) { .then(function(mess) {
@ -144,7 +145,7 @@ function verck(ver, jp) {
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(mess) { .then(function(mess) {

View File

@ -2,16 +2,16 @@
//最初に読むやつ //最初に読むやつ
//アスタルテ判定初期化 //アスタルテ判定初期化
localStorage.removeItem("kirishima") localStorage.removeItem("kirishima");
localStorage.removeItem("quoters") localStorage.removeItem("quoters");
localStorage.removeItem("imas") localStorage.removeItem("imas");
localStorage.removeItem("image"); localStorage.removeItem("image");
localStorage.removeItem("stable") localStorage.removeItem("stable");
localStorage.setItem("mode_misskey.xyz", "misskey") localStorage.setItem("mode_misskey.xyz", "misskey");
function ck() { function ck() {
var main = localStorage.getItem("main"); var main = localStorage.getItem("main");
if (!main) { if (!main) {
localStorage.setItem("main", 0) localStorage.setItem("main", 0);
} }
//コード受信 //コード受信
@ -27,18 +27,18 @@ function ck() {
var multi = localStorage.getItem("multi"); var multi = localStorage.getItem("multi");
if (!multi || multi == "[]") { if (!multi || multi == "[]") {
var date = new Date(); var date = new Date();
localStorage.setItem("showSupportMe", date.getMonth() + 2) localStorage.setItem("showSupportMe", date.getMonth() + 2);
location.href = "acct.html?mode=first&code=true" location.href = "acct.html?mode=first&code=true";
} else { } else {
var obj = JSON.parse(multi); var obj = JSON.parse(multi);
var jp=false var jp = false;
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function(key) {
var acct = obj[key]; var acct = obj[key];
if (acct.domain) { if (acct.domain) {
refresh(key, true) refresh(key, true);
} }
if (acct.domain == "mstdn.jp") { if (acct.domain == "mstdn.jp") {
jp=true jp = true;
} }
}); });
if (obj[0].domain) { if (obj[0].domain) {
@ -46,53 +46,54 @@ function ck() {
ticker(); ticker();
multiSelector(false); multiSelector(false);
verck(ver, jp); verck(ver, jp);
$(".stw").show() $(".stw").show();
$("#something-wrong img").attr("src", "../../img/thinking.svg") $("#something-wrong img").attr("src", "../../img/thinking.svg");
} }
} }
} }
ck(); ck();
//ログインポップアップ //ログインポップアップ
function login(url) { function login(url) {
if ($('#linux:checked').val() == "on") { if ($("#linux:checked").val() == "on") {
var red = "urn:ietf:wg:oauth:2.0:oob" var red = "urn:ietf:wg:oauth:2.0:oob";
} else { } else {
var red = 'thedesk://login'; var red = "thedesk://login";
} }
localStorage.setItem("redirect", red); localStorage.setItem("redirect", red);
var start = "https://" + url + "/api/v1/apps"; var start = "https://" + url + "/api/v1/apps";
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true); httpreq.open("POST", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(JSON.stringify({ httpreq.send(
scopes: 'read write follow', JSON.stringify({
scopes: "read write follow",
client_name: "TheDesk(PC)", client_name: "TheDesk(PC)",
redirect_uris: red, redirect_uris: red,
website: "https://thedesk.top" website: "https://thedesk.top"
})); })
);
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
var auth = "https://" + url + "/oauth/authorize?client_id=" + json[ setLog(start, this.status, json);
"client_id"] + "&client_secret=" + json["client_secret"] + }
"&response_type=code&redirect_uri=" + red + "&scope=read+write+follow"; 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";
localStorage.setItem("domain_" + acct_id, url); localStorage.setItem("domain_" + acct_id, url);
localStorage.setItem("client_id", json["client_id"]); localStorage.setItem("client_id", json["client_id"]);
localStorage.setItem("client_secret", json["client_secret"]); localStorage.setItem("client_secret", json["client_secret"]);
$("#auth").show(); $("#auth").show();
$("#masara").hide(); $("#masara").hide();
postMessage(["openUrl", auth], "*") postMessage(["openUrl", auth], "*");
if ($('#linux:checked').val() == "on") { if ($("#linux:checked").val() == "on") {
} else { } else {
postMessage(["sendSinmpleIpc", "quit"], "*") postMessage(["sendSinmpleIpc", "quit"], "*");
}
} }
} }
};
} }
//テキストボックスにURL入れた //テキストボックスにURL入れた
@ -101,11 +102,10 @@ function instance() {
login(url); login(url);
} }
//コードを入れた後認証 //コードを入れた後認証
function code(code, mode) { function code(code, mode) {
var red = localStorage.getItem("redirect"); var red = localStorage.getItem("redirect");
localStorage.removeItem("redirect") localStorage.removeItem("redirect");
if (!code) { if (!code) {
var code = $("#code").val(); var code = $("#code").val();
} }
@ -118,9 +118,9 @@ function code(code, mode) {
var id = localStorage.getItem("client_id"); var id = localStorage.getItem("client_id");
var secret = localStorage.getItem("client_secret"); var secret = localStorage.getItem("client_secret");
fetch(start, { fetch(start, {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
}, },
body: JSON.stringify({ body: JSON.stringify({
grant_type: "authorization_code", grant_type: "authorization_code",
@ -129,17 +129,21 @@ function code(code, mode) {
client_secret: secret, client_secret: secret,
code: code code: code
}) })
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
todo(json); todo(json);
if (json["access_token"]) { if (json["access_token"]) {
localStorage.setItem(url + "_at", json["access_token"]); localStorage.setItem(url + "_at", json["access_token"]);
@ -148,7 +152,6 @@ function code(code, mode) {
} else { } else {
getdata(); getdata();
} }
} }
}); });
} }
@ -160,25 +163,29 @@ function getdata() {
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/accounts/verify_credentials"; var start = "https://" + domain + "/api/v1/accounts/verify_credentials";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json.error) { if (json.error) {
console.error("Error:" + json.error); console.error("Error:" + json.error);
M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 }) M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 });
return; return;
} }
var avatar = json["avatar"]; var avatar = json["avatar"];
@ -186,7 +193,8 @@ function getdata() {
if (avatar == "/avatars/original/missing.png") { if (avatar == "/avatars/original/missing.png") {
avatar = "./img/missing.svg"; avatar = "./img/missing.svg";
} }
var obj = [{ var obj = [
{
at: at, at: at,
name: json["display_name"], name: json["display_name"],
domain: domain, domain: domain,
@ -194,7 +202,8 @@ function getdata() {
prof: avatar, prof: avatar,
id: json["id"], id: json["id"],
vis: json["source"]["privacy"] vis: json["source"]["privacy"]
}]; }
];
var json = JSON.stringify(obj); var json = JSON.stringify(obj);
localStorage.setItem("multi", json); localStorage.setItem("multi", json);
localStorage.setItem("name_" + acct_id, json["display_name"]); localStorage.setItem("name_" + acct_id, json["display_name"]);
@ -204,7 +213,7 @@ function getdata() {
$("#masara").hide(); $("#masara").hide();
$("#auth").hide(); $("#auth").hide();
$("#tl").show(); $("#tl").show();
parseColumn() parseColumn();
ckdb(); ckdb();
}); });
} }
@ -212,25 +221,29 @@ function getdata() {
function getdataAdv(domain, at) { function getdataAdv(domain, at) {
var start = "https://" + domain + "/api/v1/accounts/verify_credentials"; var start = "https://" + domain + "/api/v1/accounts/verify_credentials";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json.error) { if (json.error) {
console.error("Error:" + json.error); console.error("Error:" + json.error);
M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 }) M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 });
return; return;
} }
var avatar = json["avatar"]; var avatar = json["avatar"];
@ -270,30 +283,33 @@ function refresh(target, loadskip) {
var multi = localStorage.getItem("multi"); var multi = localStorage.getItem("multi");
var obj = JSON.parse(multi); var obj = JSON.parse(multi);
if (obj[target].mode == "misskey") { if (obj[target].mode == "misskey") {
return return;
} }
var start = "https://" + obj[target].domain + var start = "https://" + obj[target].domain + "/api/v1/accounts/verify_credentials";
"/api/v1/accounts/verify_credentials";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + obj[target].at Authorization: "Bearer " + obj[target].at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json.error) { if (json.error) {
console.error("Error:" + json.error); console.error("Error:" + json.error);
M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 }) M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 });
return; return;
} }
var avatar = json["avatar"]; var avatar = json["avatar"];
@ -408,15 +424,18 @@ function ckdb(acct_id) {
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem("mode_" + domain) != "misskey") {
var start = "https://" + domain + "/api/v1/instance"; var start = "https://" + domain + "/api/v1/instance";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
}, }
}).then(function (response) { })
.then(function(response) {
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json.error) { if (json.error) {
console.error(json.error); console.error(json.error);
return; return;
@ -432,11 +451,8 @@ function ckdb(acct_id) {
} }
} }
}); });
} else { } else {
} }
} }
//アカウントを選択…を実装 //アカウントを選択…を実装
@ -464,7 +480,7 @@ function multiSelector(parseC) {
var sel; var sel;
if (obj.length < 1) { if (obj.length < 1) {
$("#src-acct-sel").html('<option value="tootsearch">Tootsearch</option>'); $("#src-acct-sel").html('<option value="tootsearch">Tootsearch</option>');
$("#add-acct-sel").html('<option value="noauth">' + lang.lang_login_noauth + '</option>'); $("#add-acct-sel").html('<option value="noauth">' + lang.lang_login_noauth + "</option>");
} else { } else {
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function(key) {
var acct = obj[key]; var acct = obj[key];
@ -474,17 +490,17 @@ function multiSelector(parseC) {
var domain = acct.domain; var domain = acct.domain;
localStorage.setItem("domain_" + key, domain); localStorage.setItem("domain_" + key, domain);
if (idata[domain + "_letters"]) { if (idata[domain + "_letters"]) {
$("#textarea").attr("data-length", idata[domain + "_letters"]) $("#textarea").attr("data-length", idata[domain + "_letters"]);
} else { } else {
var maxletters = localStorage.getItem("letters_" + key); var maxletters = localStorage.getItem("letters_" + key);
if (maxletters > 0) { if (maxletters > 0) {
$("#textarea").attr("data-length", maxletters) $("#textarea").attr("data-length", maxletters);
} else { } else {
$("#textarea").attr("data-length", 500) $("#textarea").attr("data-length", 500);
} }
} }
if (idata[domain + "_glitch"]) { if (idata[domain + "_glitch"]) {
$("#local-button").removeClass("hide") $("#local-button").removeClass("hide");
} }
var profimg = acct.prof; var profimg = acct.prof;
//localStorage.setItem("prof_" + key, profimg); //localStorage.setItem("prof_" + key, profimg);
@ -517,17 +533,14 @@ function multiSelector(parseC) {
} else { } else {
sel = ""; sel = "";
} }
templete = '<option value="' + key + '" data-icon="' + acct.prof + templete = '<option value="' + key + '" data-icon="' + acct.prof + '" class="left circle" ' + sel + ">" + acct.user + "@" + acct.domain + "</option>";
'" class="left circle" ' + sel + '>' + acct.user + '@' + acct.domain +
'</option>';
$(".acct-sel").append(templete); $(".acct-sel").append(templete);
}); });
$("#src-acct-sel").append('<option value="tootsearch">Tootsearch</option>'); $("#src-acct-sel").append('<option value="tootsearch">Tootsearch</option>');
$("#add-acct-sel").append('<option value="noauth">' + lang.lang_login_noauth + '</option><option value="webview">Twitter</option>'); $("#add-acct-sel").append('<option value="noauth">' + lang.lang_login_noauth + '</option><option value="webview">Twitter</option>');
$("#dir-acct-sel").append('<option value="noauth">' + lang.lang_login_noauth + '</option>'); $("#dir-acct-sel").append('<option value="noauth">' + lang.lang_login_noauth + "</option>");
} }
$('select').formSelect(); $("select").formSelect();
if (!parseC) { if (!parseC) {
parseColumn(null, true); parseColumn(null, true);
} }
@ -546,21 +559,23 @@ function enc(ver) {
function ticker() { function ticker() {
var start = "https://toot.app/toot/"; var start = "https://toot.app/toot/";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
localStorage.setItem("ticker", JSON.stringify(json)); localStorage.setItem("ticker", JSON.stringify(json));
} }

View File

@ -94,6 +94,7 @@ function data(domain) {
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function(json) {
@ -128,6 +129,7 @@ function data(domain) {
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function(json) {
@ -330,7 +332,9 @@ function login(url) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
localStorage.setItem("msky", "false"); 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); 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); localStorage.setItem("domain_tmp", url);
@ -365,6 +369,7 @@ function versionChecker(url) {
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function(json) {
@ -403,6 +408,7 @@ function versionCompat(prefix, ver, title, real) {
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function(json) {
@ -458,7 +464,9 @@ function misskeyLogin(url) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
misskeyAuth(url, json.secret); misskeyAuth(url, json.secret);
} }
}; };
@ -480,7 +488,9 @@ function misskeyAuth(url, mkc) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
var token = json.token; var token = json.token;
$("#auth").show(); $("#auth").show();
$("#code").val(token); $("#code").val(token);
@ -530,7 +540,9 @@ function code(code) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
var i = sha256(json.accessToken + localStorage.getItem("mkc")); var i = sha256(json.accessToken + localStorage.getItem("mkc"));
var avatar = json["user"]["avatarUrl"]; var avatar = json["user"]["avatarUrl"];
var priv = "public"; var priv = "public";
@ -587,7 +599,9 @@ function code(code) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
if (json["access_token"]) { if (json["access_token"]) {
$("#auth").hide(); $("#auth").hide();
$("#add").show(); $("#add").show();
@ -617,6 +631,7 @@ function getdata(domain, at) {
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function(json) {
@ -742,6 +757,7 @@ function refresh(target) {
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function(json) {
@ -795,7 +811,9 @@ function misskeyRefresh(obj, target, url) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
var avatar = json["user"]["avatarUrl"]; var avatar = json["user"]["avatarUrl"];
var priv = "public"; var priv = "public";
var add = { var add = {
@ -929,6 +947,7 @@ input.addEventListener(
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function(json) {

View File

@ -6,106 +6,107 @@ $("#emoji-next").addClass("disabled");
//絵文字ボタンのトグル //絵文字ボタンのトグル
function emojiToggle(reaction) { function emojiToggle(reaction) {
var acct_id = $("#post-acct-sel").val(); var acct_id = $("#post-acct-sel").val();
var selin = $("#textarea").prop('selectionStart'); var selin = $("#textarea").prop("selectionStart");
if (!selin) { if (!selin) {
selin = 0; selin = 0;
} }
if ($("#emoji").hasClass("hide")) { if ($("#emoji").hasClass("hide")) {
$("#emoji").removeClass("hide") $("#emoji").removeClass("hide");
$("#right-side").show() $("#right-side").show();
$("#right-side").css("width", "300px") $("#right-side").css("width", "300px");
$("#left-side").css("width", "calc(100% - 300px)") $("#left-side").css("width", "calc(100% - 300px)");
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem("postbox-width");
if (width) { if (width) {
width = width.replace("px", "") * 1 + 300 width = width.replace("px", "") * 1 + 300;
} else { } else {
width = 600 width = 600;
} }
$("#post-box").css("width", width + "px") $("#post-box").css("width", width + "px");
$("#suggest").html(""); $("#suggest").html("");
if (!localStorage.getItem("emojis_" + acct_id)) { if (!localStorage.getItem("emojis_" + acct_id)) {
var html = var html = '<button class="btn waves-effect green" style="width:100%; padding:0; margin-top:0;" onclick="emojiGet(\'true\');">' + lang.lang_emoji_get + "</button>";
'<button class="btn waves-effect green" style="width:100%; padding:0; margin-top:0;" onclick="emojiGet(\'true\');">' + lang.lang_emoji_get + '</button>';
$("#emoji-list").html(html); $("#emoji-list").html(html);
} else { } else {
emojiList('home', reaction); emojiList("home", reaction);
} }
} else { } else {
$("#poll").addClass("hide") $("#poll").addClass("hide");
$("#right-side").hide() $("#right-side").hide();
$("#right-side").css("width", "300px") $("#right-side").css("width", "300px");
$("#emoji").addClass("hide") $("#emoji").addClass("hide");
$("#suggest").html(""); $("#suggest").html("");
$("#left-side").css("width", "100%") $("#left-side").css("width", "100%");
var width = localStorage.getItem("postbox-width"); var width = localStorage.getItem("postbox-width");
if (width) { if (width) {
width = width.replace("px", "") * 1 width = width.replace("px", "") * 1;
} else { } else {
width = 300 width = 300;
} }
$("#post-box").css("width", width + "px") $("#post-box").css("width", width + "px");
} }
} }
//絵文字リスト挿入 //絵文字リスト挿入
function emojiGet(parse, started) { function emojiGet(parse, started) {
$('#emoji-list').text('Loading...'); $("#emoji-list").text("Loading...");
var acct_id = $("#post-acct-sel").val(); var acct_id = $("#post-acct-sel").val();
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem("mode_" + domain) != "misskey") {
var start = "https://" + domain + "/api/v1/custom_emojis"; var start = "https://" + domain + "/api/v1/custom_emojis";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (parse == "true") { if (parse == "true") {
$('#emoji-list').text('Parsing...'); $("#emoji-list").text("Parsing...");
var md = { var md = {
"categorized": {}, categorized: {},
"uncategorized": [] uncategorized: []
}; };
var if_categorized = false var if_categorized = false;
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var emoji = json[key]; var emoji = json[key];
if (emoji.visible_in_picker) { if (emoji.visible_in_picker) {
var listed = true var listed = true;
} else { } else {
var listed = false var listed = false;
} }
if (emoji.category) { if (emoji.category) {
var cat = emoji.category var cat = emoji.category;
if (!md["categorized"][cat]) { if (!md["categorized"][cat]) {
md["categorized"][cat] = [] md["categorized"][cat] = [];
} }
md["categorized"][cat].push({ md["categorized"][cat].push({
"shortcode": emoji.shortcode, shortcode: emoji.shortcode,
"url": emoji.url, url: emoji.url,
"listed": listed listed: listed
}) });
if_categorized = true if_categorized = true;
} else { } else {
md["uncategorized"].push({ md["uncategorized"].push({
"shortcode": emoji.shortcode, shortcode: emoji.shortcode,
"url": emoji.url, url: emoji.url,
"listed": listed listed: listed
}) });
} }
}); });
console.log(md) console.log(md);
//絵文字をマストドン公式と同順にソート //絵文字をマストドン公式と同順にソート
md["uncategorized"].sort(function(a, b) { md["uncategorized"].sort(function(a, b) {
if (a.shortcode < b.shortcode) return -1; if (a.shortcode < b.shortcode) return -1;
@ -120,52 +121,56 @@ function emojiGet(parse, started) {
}); });
}); });
md["if_categorized"] = if_categorized md["if_categorized"] = if_categorized;
localStorage.setItem("emojis_" + acct_id, JSON.stringify(md)); localStorage.setItem("emojis_" + acct_id, JSON.stringify(md));
} else { } else {
localStorage.setItem("emojis_" + acct_id, JSON.stringify(md)); localStorage.setItem("emojis_" + acct_id, JSON.stringify(md));
} }
localStorage.setItem("emojiseek", 0); localStorage.setItem("emojiseek", 0);
if (!started) { if (!started) {
emojiList('home') emojiList("home");
} }
}); });
} else { } else {
var start = "https://" + domain + "/api/meta"; var start = "https://" + domain + "/api/meta";
fetch(start, { fetch(start, {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json.enableEmojiReaction) { if (json.enableEmojiReaction) {
localStorage.setItem("emojiReaction_" + acct_id, "true"); localStorage.setItem("emojiReaction_" + acct_id, "true");
} else { } else {
localStorage.setItem("emojiReaction_" + acct_id, "disabled"); localStorage.setItem("emojiReaction_" + acct_id, "disabled");
} }
var emojis = json.emojis; var emojis = json.emojis;
var md = {"uncategorized": []} var md = { uncategorized: [] };
Object.keys(emojis).forEach(function(key) { Object.keys(emojis).forEach(function(key) {
var emoji = emojis[key]; var emoji = emojis[key];
md["uncategorized"].push({ md["uncategorized"].push({
"shortcode": emoji.name, shortcode: emoji.name,
"url": emoji.url, url: emoji.url,
"listed": true listed: true
})
}); });
md["if_categorized"] = false });
md["if_categorized"] = false;
if (parse == "true") { if (parse == "true") {
$('#emoji-list').text('Parsing...'); $("#emoji-list").text("Parsing...");
//絵文字をマストドン公式と同順にソート //絵文字をマストドン公式と同順にソート
md["uncategorized"].sort(function(a, b) { md["uncategorized"].sort(function(a, b) {
if (a.shortcode < b.shortcode) return -1; if (a.shortcode < b.shortcode) return -1;
@ -178,7 +183,7 @@ function emojiGet(parse, started) {
} }
localStorage.setItem("emojiseek", 0); localStorage.setItem("emojiseek", 0);
if (!started) { if (!started) {
emojiList('home') emojiList("home");
} }
}); });
} }
@ -189,8 +194,8 @@ function emojiList(target, reaction) {
$("#now-emoji").text(lang.lang_emoji_custom); $("#now-emoji").text(lang.lang_emoji_custom);
var acct_id = $("#post-acct-sel").val(); var acct_id = $("#post-acct-sel").val();
if (reaction && localStorage.getItem("emojiReaction_" + acct_id) != "true") { if (reaction && localStorage.getItem("emojiReaction_" + acct_id) != "true") {
console.error("Disabled") console.error("Disabled");
clear() clear();
hide(); hide();
return false; return false;
} }
@ -203,30 +208,34 @@ function emojiList(target, reaction) {
localStorage.setItem("emojiseek", start); localStorage.setItem("emojiseek", start);
} else { } else {
var start = 0; var start = 0;
localStorage.getItem("emojiseek", 0) localStorage.getItem("emojiseek", 0);
} }
var html = ''; var html = "";
var raw = JSON.parse(localStorage.getItem("emojis_" + acct_id)); var raw = JSON.parse(localStorage.getItem("emojis_" + acct_id));
console.log(raw) console.log(raw);
if (raw.if_categorized) { if (raw.if_categorized) {
var obj = [{ var obj = [
"divider": true, {
"cat": lang.lang_emoji_uncat divider: true,
}] cat: lang.lang_emoji_uncat
var cats = raw["uncategorized"] }
];
var cats = raw["uncategorized"];
obj = obj.concat(cats); obj = obj.concat(cats);
Object.keys(raw["categorized"]).forEach(function(key) { Object.keys(raw["categorized"]).forEach(function(key) {
var cats = raw["categorized"][key]; var cats = raw["categorized"][key];
obj = obj.concat([{ obj = obj.concat([
"divider": true, {
"cat": key divider: true,
}]); cat: key
}
]);
obj = obj.concat(cats); obj = obj.concat(cats);
}); });
} else { } else {
var obj = raw["uncategorized"] var obj = raw["uncategorized"];
} }
console.log(obj) console.log(obj);
var num = obj.length; var num = obj.length;
if (num < start) { if (num < start) {
@ -254,18 +263,15 @@ function emojiList(target, reaction) {
var emoji = obj[i]; var emoji = obj[i];
if (emoji) { if (emoji) {
if (reaction) { if (reaction) {
html = html + '<a onclick="emojiReaction(\':' + emoji.shortcode + html = html + "<a onclick=\"emojiReaction(':" + emoji.shortcode + ':\')" class="pointer"><img src="' + emoji.url + '" width="20" title="' + emoji.shortcode + '"></a>';
':\')" class="pointer"><img src="' + emoji.url + '" width="20" title="' + emoji.shortcode + '"></a>';
} else { } else {
if (emoji.divider) { if (emoji.divider) {
html = html + '<p style="margin-bottom:0">'+ emoji.cat +'</p>' html = html + '<p style="margin-bottom:0">' + emoji.cat + "</p>";
} else { } else {
if (emoji.listed) { if (emoji.listed) {
html = html + '<a onclick="emojiInsert(\':' + emoji.shortcode + html = html + "<a onclick=\"emojiInsert(':" + emoji.shortcode + ':\')" class="pointer"><img src="' + emoji.url + '" width="20" title="' + emoji.shortcode + '"></a>';
':\')" class="pointer"><img src="' + emoji.url + '" width="20" title="' + emoji.shortcode + '"></a>';
} }
} }
} }
} }
} }
@ -275,7 +281,7 @@ function emojiList(target, reaction) {
//絵文字など様々なものをテキストボックスに挿入 //絵文字など様々なものをテキストボックスに挿入
function emojiInsert(code, del) { function emojiInsert(code, del) {
var now = $("#textarea").val(); var now = $("#textarea").val();
var selin = $("#textarea").prop('selectionStart'); var selin = $("#textarea").prop("selectionStart");
if (localStorage.getItem("emoji-zero-width") == "yes") { if (localStorage.getItem("emoji-zero-width") == "yes") {
var blank = ""; var blank = "";
} else { } else {
@ -283,11 +289,11 @@ function emojiInsert(code, del) {
} }
var before = now.substr(0, selin); var before = now.substr(0, selin);
if (before.slice(-1) != " ") { if (before.slice(-1) != " ") {
before = before + blank before = before + blank;
} }
var after = now.substr(selin, now.length); var after = now.substr(selin, now.length);
if (after.slice(-1) != " ") { if (after.slice(-1) != " ") {
after = blank + after after = blank + after;
} }
newt = before + code + after; newt = before + code + after;
if (!del) { if (!del) {
@ -303,7 +309,7 @@ function emojiInsert(code, del) {
} }
//改行挿入 //改行挿入
function brInsert(code) { function brInsert(code) {
if (!$('#post-box').hasClass("appear")) { if (!$("#post-box").hasClass("appear")) {
localStorage.setItem("nohide", true); localStorage.setItem("nohide", true);
show(); show();
} }

View File

@ -118,7 +118,9 @@ function media(b64, type, no) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
if (!json.id) { if (!json.id) {
todc(); todc();
$("#imgup").text(""); $("#imgup").text("");
@ -277,10 +279,11 @@ function altImage(acct_id, id) {
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function(json) {
console.log(json) console.log(json);
$("[data-media=" + id + "]").attr("title", data); $("[data-media=" + id + "]").attr("title", data);
}); });
}, },
@ -288,7 +291,7 @@ function altImage(acct_id, id) {
}).then(result => { }).then(result => {
if (result.value) { if (result.value) {
Swal.fire({ Swal.fire({
title: "Complete", title: "Complete"
}); });
} }
}); });

View File

@ -10,19 +10,21 @@ function renote(id, acct_id, remote) {
return false; return false;
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true); httpreq.open("POST", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(JSON.stringify({ i: at, renoteId: id })); httpreq.send(JSON.stringify({ i: at, renoteId: id }));
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
console.log(["Success: renote", json]); console.log(["Success: renote", json]);
$("[toot-id=" + id + "]").addClass("rted"); $("[toot-id=" + id + "]").addClass("rted");
$(".rt_" + id).toggleClass("teal-text"); $(".rt_" + id).toggleClass("teal-text");
} }
} };
} }
//Renote //Renote
function renoteqt(id, acct_id) { function renoteqt(id, acct_id) {
@ -32,7 +34,7 @@ function renoteqt(id, acct_id) {
$("#rec").text("Renote"); $("#rec").text("Renote");
$("#post-acct-sel").val(acct_id); $("#post-acct-sel").val(acct_id);
$("#post-acct-sel").prop("disabled", true); $("#post-acct-sel").prop("disabled", true);
$('select').formSelect(); $("select").formSelect();
$("#textarea").attr("placeholder", lang.lang_misskeyparse_qt); $("#textarea").attr("placeholder", lang.lang_misskeyparse_qt);
$("#textarea").focus(); $("#textarea").focus();
} }
@ -44,7 +46,7 @@ function misskeyreply(id, acct_id) {
$("#rec").text("Renote"); $("#rec").text("Renote");
$("#post-acct-sel").val(acct_id); $("#post-acct-sel").val(acct_id);
$("#post-acct-sel").prop("disabled", true); $("#post-acct-sel").prop("disabled", true);
$('select').formSelect(); $("select").formSelect();
$("#textarea").attr("placeholder", lang.lang_misskeyparse_qt); $("#textarea").attr("placeholder", lang.lang_misskeyparse_qt);
$("#textarea").focus(); $("#textarea").focus();
} }
@ -57,37 +59,39 @@ function reactiontoggle(id, acct_id, tlid) {
return false; return false;
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true); httpreq.open("POST", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(JSON.stringify({ i: at, noteId: id })); httpreq.send(JSON.stringify({ i: at, noteId: id }));
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
console.log(["Success: reaction", json]); console.log(["Success: reaction", json]);
if (json.reactions) { if (json.reactions) {
var reactions = ["like", "love", "laugh", "hmm", "surprise", "congrats", "angry", "confused", "pudding", "rip"]; var reactions = ["like", "love", "laugh", "hmm", "surprise", "congrats", "angry", "confused", "pudding", "rip"];
for (var i = 0; i < reactions.length; i++) { for (var i = 0; i < reactions.length; i++) {
if (json.reactions[reactions[i]]) { if (json.reactions[reactions[i]]) {
$("#pub_" + id + " .re-" + reactions[i] + "ct").text(json.reactions[reactions[i]]) $("#pub_" + id + " .re-" + reactions[i] + "ct").text(json.reactions[reactions[i]]);
$("#pub_" + id + " .re-" + reactions[i]).removeClass("hide") $("#pub_" + id + " .re-" + reactions[i]).removeClass("hide");
} else { } else {
$("#pub_" + id + " .re-" + reactions[i] + "ct").text(0) $("#pub_" + id + " .re-" + reactions[i] + "ct").text(0);
if ($("#pub_" + id + " .reactions").hasClass("fullreact")) { if ($("#pub_" + id + " .reactions").hasClass("fullreact")) {
$("#pub_" + id + " .re-" + reactions[i]).addClass("hide") $("#pub_" + id + " .re-" + reactions[i]).addClass("hide");
} else { } else {
$("#pub_" + id + " .re-" + reactions[i]).removeClass("hide") $("#pub_" + id + " .re-" + reactions[i]).removeClass("hide");
} }
$("#pub_" + id + " .re-" + reactions[i] + "ct").text(json.reactions[reactions[i]]) $("#pub_" + id + " .re-" + reactions[i] + "ct").text(json.reactions[reactions[i]]);
} }
} }
$("#pub_" + id + " .reactions").removeClass("hide"); $("#pub_" + id + " .reactions").removeClass("hide");
$("#pub_" + id + " .reactions").toggleClass("fullreact") $("#pub_" + id + " .reactions").toggleClass("fullreact");
} else { } else {
if ($("#pub_" + id + " .reactions").hasClass("fullreact")) { if ($("#pub_" + id + " .reactions").hasClass("fullreact")) {
$("#pub_" + id + " .reactions").addClass("hide") $("#pub_" + id + " .reactions").addClass("hide");
$("#pub_" + id + " .reactions").removeClass("fullreact") $("#pub_" + id + " .reactions").removeClass("fullreact");
} else { } else {
$("#pub_" + id + " .reactions").removeClass("hide"); $("#pub_" + id + " .reactions").removeClass("hide");
$("#pub_" + id + " .reaction").removeClass("hide"); $("#pub_" + id + " .reaction").removeClass("hide");
@ -95,7 +99,7 @@ function reactiontoggle(id, acct_id, tlid) {
} }
} }
} }
} };
$("#pub_" + id + " .freeReact").toggleClass("hide"); $("#pub_" + id + " .freeReact").toggleClass("hide");
} }
//reactioncustom //reactioncustom
@ -104,10 +108,10 @@ function reactioncustom(acct_id, id) {
$("#unreact").hide(); $("#unreact").hide();
$("#addreact").removeClass("hide"); $("#addreact").removeClass("hide");
$("#post-acct-sel").val(acct_id); $("#post-acct-sel").val(acct_id);
$('select').formSelect(); $("select").formSelect();
localStorage.setItem("nohide", true); localStorage.setItem("nohide", true);
show() show();
emojiToggle(true) emojiToggle(true);
$("#left-side").hide(); $("#left-side").hide();
$("#default-emoji").hide(); $("#default-emoji").hide();
} }
@ -121,20 +125,23 @@ function reactRefresh(acct_id, id) {
req.noteId = id; req.noteId = id;
var i = { var i = {
method: "POST", method: "POST",
body: JSON.stringify(req), body: JSON.stringify(req)
} };
fetch(start, i, fetch(start, i)
).then(function (response) { .then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (!json) { if (!json) {
return false; return false;
} }
@ -143,26 +150,26 @@ function reactRefresh(acct_id, id) {
$("[toot-id=" + id + "]").hide(); $("[toot-id=" + id + "]").hide();
$("[toot-id=" + id + "]").remove(); $("[toot-id=" + id + "]").remove();
} else { } else {
reactRefreshCore(json) reactRefreshCore(json);
} }
}); });
} }
function reactRefreshCore(json) { function reactRefreshCore(json) {
var id = json.id; var id = json.id;
if (json.reactions) { if (json.reactions) {
$("#pub_" + id + " .reactions").removeClass("hide") $("#pub_" + id + " .reactions").removeClass("hide");
var regExp = new RegExp(":", "g"); var regExp = new RegExp(":", "g");
Object.keys(json.reactions).forEach(function(keye) { Object.keys(json.reactions).forEach(function(keye) {
keyeClass = keye.replace(regExp, ''); keyeClass = keye.replace(regExp, "");
if (json.reactions[keye]) { if (json.reactions[keye]) {
$("#pub_" + id + " .re-" + keyeClass + "ct").text(json.reactions[keye]) $("#pub_" + id + " .re-" + keyeClass + "ct").text(json.reactions[keye]);
$("#pub_" + id + " .re-" + keyeClass).removeClass("hide") $("#pub_" + id + " .re-" + keyeClass).removeClass("hide");
} else { } else {
$("#pub_" + id + " .re-" + keyeClass + "ct").text(0) $("#pub_" + id + " .re-" + keyeClass + "ct").text(0);
if ($("#pub_" + id + " .reactions").hasClass("fullreact")) { if ($("#pub_" + id + " .reactions").hasClass("fullreact")) {
$("#pub_" + id + " .re-" + keyeClass).addClass("hide") $("#pub_" + id + " .re-" + keyeClass).addClass("hide");
} }
$("#pub_" + id + " .re-" + keyeClass + "ct").text(json.reactions[keye]) $("#pub_" + id + " .re-" + keyeClass + "ct").text(json.reactions[keye]);
} }
}); });
} }
@ -170,7 +177,7 @@ function reactRefreshCore(json) {
function emojiReaction(emoji) { function emojiReaction(emoji) {
var acct_id = $("#post-acct-sel").val(); var acct_id = $("#post-acct-sel").val();
var id = $("#reply").val(); var id = $("#reply").val();
reaction(emoji, id, acct_id, null) reaction(emoji, id, acct_id, null);
clear(); clear();
hide(); hide();
} }
@ -187,16 +194,18 @@ function reaction(mode, id, acct_id, tlid) {
return false; return false;
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true); httpreq.open("POST", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(JSON.stringify({ i: at, noteId: id, reaction: mode })); httpreq.send(JSON.stringify({ i: at, noteId: id, reaction: mode }));
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
$(".fav_" + id).toggleClass("yellow-text"); $(".fav_" + id).toggleClass("yellow-text");
} }
} };
} }
//Vote //Vote
function vote(acct_id, id, to) { function vote(acct_id, id, to) {
@ -207,27 +216,29 @@ function vote(acct_id, id, to) {
return false; return false;
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true); httpreq.open("POST", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(JSON.stringify({ i: at, noteId: id, choice: to })); httpreq.send(JSON.stringify({ i: at, noteId: id, choice: to }));
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
voterefresh(acct_id, id) voterefresh(acct_id, id);
} };
} }
function voterefresh(acct_id, id) { function voterefresh(acct_id, id) {
var httpreqd = new XMLHttpRequest(); var httpreqd = new XMLHttpRequest();
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/notes/show"; var start = "https://" + domain + "/api/notes/show";
httpreqd.open('POST', start, true); httpreqd.open("POST", start, true);
httpreqd.setRequestHeader('Content-Type', 'application/json'); httpreqd.setRequestHeader("Content-Type", "application/json");
httpreqd.responseType = 'json'; httpreqd.responseType = "json";
httpreqd.send(JSON.stringify({ i: at, noteId: id })); httpreqd.send(JSON.stringify({ i: at, noteId: id }));
httpreqd.onreadystatechange = function() { httpreqd.onreadystatechange = function() {
if (httpreqd.readyState == 4) { if (httpreqd.readyState == 4) {
var json = httpreqd.response; var json = httpreqd.response;
if(this.status!==200){ setLog(start, this.status, json); } if (this.status !== 200) {
setLog(start, this.status, json);
}
if (!json) { if (!json) {
return false; return false;
} }
@ -241,10 +252,10 @@ function voterefresh(acct_id, id) {
} else { } else {
var myvote = ""; var myvote = "";
} }
poll = poll + '<div class="pointer vote" onclick="vote(\'' + acct_id + '\',\'' + json.id + '\',' + choice.id + ')">' + escapeHTML(choice.text) + '(' + choice.votes + '' + myvote + ')</div>'; poll = poll + '<div class="pointer vote" onclick="vote(\'' + acct_id + "','" + json.id + "'," + choice.id + ')">' + escapeHTML(choice.text) + "(" + choice.votes + "" + myvote + ")</div>";
}); });
$(".vote_" + json.id).html(poll) $(".vote_" + json.id).html(poll);
}
} }
} }
};
} }

View File

@ -7,20 +7,19 @@ function additional(acct_id, tlid) {
$("#timeline-container .mention").addClass("parsed"); $("#timeline-container .mention").addClass("parsed");
$("#timeline-container .hashtag, #timeline-container [rel=tag]").each(function(i, elem) { $("#timeline-container .hashtag, #timeline-container [rel=tag]").each(function(i, elem) {
var tags = $(this).attr("href").match( var tags = $(this)
/https?:\/\/([-a-zA-Z0-9@.]+)\/tags\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/ .attr("href")
); .match(/https?:\/\/([-a-zA-Z0-9@.]+)\/tags\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/);
if (tags) { if (tags) {
var tagThis = tags[2] var tagThis = tags[2];
} else { } else {
var tagThis = $(this).attr("data-tag") var tagThis = $(this).attr("data-tag");
} }
if (tagThis) { if (tagThis) {
$(this).attr("onclick", 'tagShow(\'' + tagThis + '\')'); $(this).attr("onclick", "tagShow('" + tagThis + "')");
$(this).attr("href", "#"); $(this).attr("href", "#");
} }
}); });
//トゥートサムネ //トゥートサムネ
@ -28,16 +27,14 @@ function additional(acct_id, tlid) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var card = localStorage.getItem("card_" + tlid); var card = localStorage.getItem("card_" + tlid);
var text = $(this).attr('href'); var text = $(this).attr("href");
if (text) { if (text) {
if (text.indexOf("twimg.com") === -1) { if (text.indexOf("twimg.com") === -1) {
var urls = text.match( var urls = text.match(/https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/);
/https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/
);
} }
} else { } else {
text = "" text = "";
var urls = [] var urls = [];
} }
//トゥートのURLぽかったら //トゥートのURLぽかったら
@ -50,36 +47,39 @@ function additional(acct_id, tlid) {
if (urls) { if (urls) {
$(this).remove(); $(this).remove();
} else if (!card) { } else if (!card) {
var id = $(this).parents('.cvo').attr("toot-id"); var id = $(this)
.parents(".cvo")
.attr("toot-id");
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/url?url=" + text; var start = "https://" + domain + "/url?url=" + text;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
}, }
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json.title) { if (json.title) {
$("[toot-id=" + id + "] .additional").html( $("[toot-id=" + id + "] .additional").html('<span class="gray">URL' + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" + escapeHTML(json.description) + "</span>");
"<span class=\"gray\">URL" + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" +
escapeHTML(json.description) + "</span>");
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed"); $("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
$("[toot-id=" + id + "]").addClass("parsed"); $("[toot-id=" + id + "]").addClass("parsed");
} }
}); });
} }
} else { } else {
$(this).attr("title", text); $(this).attr("title", text);
} }
@ -93,7 +93,9 @@ function additional(acct_id, tlid) {
if (this.readyState === 4 && this.status === 200) { if (this.readyState === 4 && this.status === 200) {
if (this.response) { if (this.response) {
var json = this.response; var json = this.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
var emojis = json.emojis; var emojis = json.emojis;
for (i = 0; i < emojis.length; i++) { for (i = 0; i < emojis.length; i++) {
var emojie = emojis[i]; var emojie = emojis[i];
@ -109,19 +111,24 @@ function additional(acct_id, tlid) {
} }
} }
} }
} };
xmlHttpRequest.open('GET', start, true); xmlHttpRequest.open("GET", start, true);
xmlHttpRequest.responseType = 'json'; xmlHttpRequest.responseType = "json";
xmlHttpRequest.send(null); xmlHttpRequest.send(null);
}); });
$("#timeline_" + tlid + " .toot:not(:has(a:not(.add-show,.parsed)))").each(function(i, elem) { $("#timeline_" + tlid + " .toot:not(:has(a:not(.add-show,.parsed)))").each(function(i, elem) {
$(this).parent().find(".add-show").hide(); $(this)
.parent()
.find(".add-show")
.hide();
}); });
//Markdownイメージビューワー //Markdownイメージビューワー
$("#timeline_" + tlid + " .toot a:not(.img-parsed):has(img)").each(function(i, elem) { $("#timeline_" + tlid + " .toot a:not(.img-parsed):has(img)").each(function(i, elem) {
var ilink = $(this).attr("href"); var ilink = $(this).attr("href");
var id = $(this).parents('.cvo').attr("toot-id"); var id = $(this)
.parents(".cvo")
.attr("toot-id");
$(this).attr("href", "#"); $(this).attr("href", "#");
$(this).attr("onclick", "imgv('" + id + "','" + i + "')"); $(this).attr("onclick", "imgv('" + id + "','" + i + "')");
$(this).attr("data-type", "image"); $(this).attr("data-type", "image");
@ -134,88 +141,89 @@ function additional(acct_id, tlid) {
function additionalIndv(tlid, acct_id, id) { function additionalIndv(tlid, acct_id, id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var text = $("[toot-id=" + id + "] .toot a").attr('href'); var text = $("[toot-id=" + id + "] .toot a").attr("href");
var urls = text.match( var urls = text.match(/https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/);
/https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/
);
if (urls) { if (urls) {
$("[toot-id=" + id + "] .toot a").remove(); $("[toot-id=" + id + "] .toot a").remove();
} else { } else {
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/url?url=" + text; var start = "https://" + domain + "/url?url=" + text;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
}, }
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json.title) { if (json.title) {
$("[toot-id=" + id + "] .additional").html( $("[toot-id=" + id + "] .additional").html('<span class="gray">URL' + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" + escapeHTML(json.description) + "</span>");
"<span class=\"gray\">URL" + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" +
escapeHTML(json.description) + "</span>");
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed"); $("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
$("[toot-id=" + id + "]").addClass("parsed"); $("[toot-id=" + id + "]").addClass("parsed");
} }
}); });
} else { } else {
var id = $("[toot-id=" + id + "] .toot a").parents('.cvo').attr("toot-id"); var id = $("[toot-id=" + id + "] .toot a")
.parents(".cvo")
.attr("toot-id");
var start = "https://" + domain + "/api/v1/statuses/" + id; var start = "https://" + domain + "/api/v1/statuses/" + id;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
//body: JSON.stringify({}) //body: JSON.stringify({})
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
json = json.card; json = json.card;
//このリンク鳥やんけ、ってとき //このリンク鳥やんけ、ってとき
if (json.provider_name == "Twitter") { if (json.provider_name == "Twitter") {
if (json.image) { if (json.image) {
var twiImg = '<br><img src="' + json.image + '" style="max-width:100%" onclick="imgv(\'twi_' + id + '\', 0, \'twitter\');" id="twi_' + id + '-image-0" data-url="' + json.image + '" data-type="image">'; var twiImg = '<br><img src="' + json.image + '" style="max-width:100%" onclick="imgv(\'twi_' + id + "', 0, 'twitter');\" id=\"twi_" + id + '-image-0" data-url="' + json.image + '" data-type="image">';
} else { } else {
var twiImg = ''; var twiImg = "";
} }
$("[toot-id=" + id + "] .additional").html( $("[toot-id=" + id + "] .additional").html('<div class="twitter-tweet"><b>' + escapeHTML(json.author_name) + "</b><br>" + escapeHTML(json.description) + twiImg + "</div>");
'<div class="twitter-tweet"><b>' + escapeHTML(json.author_name) + '</b><br>' + escapeHTML(json.description) + twiImg + '</div>');
} else if (json.provider_name == "pixiv") { } else if (json.provider_name == "pixiv") {
if (json.image) { if (json.image) {
var pxvImg = '<br><img src="' + json.image + '" style="max-width:100%" onclick="imgv(\'pixiv_' + id + '\', 0, \'pixiv\');" id="pixiv_' + id + '-image-0" data-url="' + json.embed_url + '" data-type="image">'; var pxvImg = '<br><img src="' + json.image + '" style="max-width:100%" onclick="imgv(\'pixiv_' + id + "', 0, 'pixiv');\" id=\"pixiv_" + id + '-image-0" data-url="' + json.embed_url + '" data-type="image">';
} else { } else {
var pxvImg = ''; var pxvImg = "";
} }
$("[toot-id=" + id + "] .additional").html( $("[toot-id=" + id + "] .additional").html('<div class="pixiv-post"><b><a href="' + json.author_url + '" target="_blank">' + escapeHTML(json.author_name) + "</a></b><br>" + escapeHTML(json.title) + pxvImg + "</div>");
'<div class="pixiv-post"><b><a href="' + json.author_url + '" target="_blank">' + escapeHTML(json.author_name) + '</a></b><br>' + escapeHTML(json.title) + pxvImg + '</div>');
} else { } else {
if (json.title) { if (json.title) {
$("[toot-id=" + id + "] .additional").html( $("[toot-id=" + id + "] .additional").html('<span class="gray">URL' + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" + escapeHTML(json.description) + "</span>");
"<span class=\"gray\">URL" + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" +
escapeHTML(json.description) + "</span>");
} }
if (json.html) { if (json.html) {
$("[toot-id=" + id + "] .additional").html(json.html + '<i class="material-icons sml pointer" onclick="pip(\'' + id + '\')" title="' + lang.lang_cards_pip + '">picture_in_picture_alt</i>'); $("[toot-id=" + id + "] .additional").html(json.html + '<i class="material-icons sml pointer" onclick="pip(\'' + id + '\')" title="' + lang.lang_cards_pip + '">picture_in_picture_alt</i>');
} }
} }
if (json.title) { if (json.title) {
@ -224,7 +232,6 @@ function additionalIndv(tlid, acct_id, id) {
} }
}); });
} }
} }
} }
@ -234,11 +241,11 @@ function cardToggle(tlid) {
if (!card) { if (!card) {
localStorage.setItem("card_" + tlid, "true"); localStorage.setItem("card_" + tlid, "true");
$("#sta-card-" + tlid).text("Off"); $("#sta-card-" + tlid).text("Off");
$("#sta-card-" + tlid).css("color", 'red'); $("#sta-card-" + tlid).css("color", "red");
} else { } else {
localStorage.removeItem("card_" + tlid); localStorage.removeItem("card_" + tlid);
$("#sta-card-" + tlid).text("On"); $("#sta-card-" + tlid).text("On");
$("#sta-card-" + tlid).css("color", '#009688'); $("#sta-card-" + tlid).css("color", "#009688");
} }
} }
//各TL上方のLink[On/Off]をチェック //各TL上方のLink[On/Off]をチェック
@ -246,15 +253,15 @@ function cardCheck(tlid) {
var card = localStorage.getItem("card_" + tlid); var card = localStorage.getItem("card_" + tlid);
if (!card) { if (!card) {
$("#sta-card-" + tlid).text("On"); $("#sta-card-" + tlid).text("On");
$("#sta-card-" + tlid).css("color", '#009688'); $("#sta-card-" + tlid).css("color", "#009688");
} else { } else {
$("#sta-card-" + tlid).text("Off"); $("#sta-card-" + tlid).text("Off");
$("#sta-card-" + tlid).css("color", 'red'); $("#sta-card-" + tlid).css("color", "red");
} }
} }
function mov(id, tlid, type) { function mov(id, tlid, type) {
var click = false var click = false;
if (tlid == "notf") { if (tlid == "notf") {
var tlide = "[data-notf=" + acct_id + "]"; var tlide = "[data-notf=" + acct_id + "]";
} else if (tlid == "user") { } else if (tlid == "user") {
@ -274,21 +281,20 @@ function mov(id, tlid, type) {
} else { } else {
mouseover = "hide"; mouseover = "hide";
} }
click=true click = true;
} else if (mouseover == "no") { } else if (mouseover == "no") {
mouseover = ""; mouseover = "";
} }
if (mouseover == "hide") { if (mouseover == "hide") {
if (click) { if (click) {
$(tlide + " [toot-id=" + id + "]").toggleClass("hide-actions") $(tlide + " [toot-id=" + id + "]").toggleClass("hide-actions");
} else { } else {
$(tlide + " [toot-id=" + id + "]").removeClass("hide-actions") $(tlide + " [toot-id=" + id + "]").removeClass("hide-actions");
} }
//$(tlide + " [toot-id=" + id + "] .area-vis").toggleClass("hide") //$(tlide + " [toot-id=" + id + "] .area-vis").toggleClass("hide")
//$(tlide + " [toot-id=" + id + "] .area-actions").toggleClass("hide") //$(tlide + " [toot-id=" + id + "] .area-actions").toggleClass("hide")
//$(tlide + " [toot-id=" + id + "] .area-side").toggleClass("hide") //$(tlide + " [toot-id=" + id + "] .area-side").toggleClass("hide")
} }
} }
@ -304,10 +310,9 @@ function resetmv(type) {
mouseover = "hide"; mouseover = "hide";
} }
if (mouseover == "hide") { if (mouseover == "hide") {
$(".cvo").addClass("hide-actions") $(".cvo").addClass("hide-actions");
//$(".area-vis").addClass("hide"); //$(".area-vis").addClass("hide");
//$(".area-actions").addClass("hide"); //$(".area-actions").addClass("hide");
//$(".area-side").addClass("hide"); //$(".area-side").addClass("hide");
} }
} }

View File

@ -5,49 +5,53 @@ function details(id, acct_id, tlid, mode) {
} else { } else {
$(".dm-hide").show(); $(".dm-hide").show();
} }
$(".toot-reset").html('<span class="no-data">' + lang.lang_details_nodata + '</span>'); $(".toot-reset").html('<span class="no-data">' + lang.lang_details_nodata + "</span>");
var html = $("#timeline_" + tlid + " [toot-id=" + id + "]").html(); var html = $("#timeline_" + tlid + " [toot-id=" + id + "]").html();
$("#toot-this").html(html); $("#toot-this").html(html);
$('#tootmodal').modal('open'); $("#tootmodal").modal("open");
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/notes/show"; var start = "https://" + domain + "/api/notes/show";
var i = { var i = {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify({ body: JSON.stringify({
i: at, i: at,
noteId: id noteId: id
}) })
} };
} else { } else {
var start = "https://" + domain + "/api/v1/statuses/" + id; var start = "https://" + domain + "/api/v1/statuses/" + id;
var i = { var i = {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
},
} }
};
} }
fetch(start, i).then(function (response) { fetch(start, i)
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
console.log(["Toot data:", json]); console.log(["Toot data:", json]);
if (!$("#timeline_" + tlid + " #pub_" + id).length) { if (!$("#timeline_" + tlid + " #pub_" + id).length) {
var html = parse([json], '', acct_id); var html = parse([json], "", acct_id);
$("#toot-this").html(html); $("#toot-this").html(html);
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
} }
@ -66,7 +70,7 @@ function details(id, acct_id, tlid, mode) {
replyTL(json._replyIds[0], acct_id); replyTL(json._replyIds[0], acct_id);
} }
} else { } else {
var url = json.url var url = json.url;
if (json.account.acct == json.account.username) { if (json.account.acct == json.account.username) {
var local = true; var local = true;
} else { } else {
@ -91,7 +95,7 @@ function details(id, acct_id, tlid, mode) {
getContext(id, acct_id); getContext(id, acct_id);
var dom = null; var dom = null;
if (!local) { if (!local) {
dom = scn.replace(/.+@/g, ''); dom = scn.replace(/.+@/g, "");
} else { } else {
dom = domain; dom = domain;
} }
@ -110,9 +114,8 @@ function details(id, acct_id, tlid, mode) {
} }
} }
if (!$("#activator").hasClass("active")) { if (!$("#activator").hasClass("active")) {
$('#det-col').collapsible('open', 4); $("#det-col").collapsible("open", 4);
} }
}); });
} }
@ -123,36 +126,40 @@ function replyTL(id, acct_id) {
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/notes/show"; var start = "https://" + domain + "/api/notes/show";
var i = { var i = {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify({ body: JSON.stringify({
i: at, i: at,
noteId: id noteId: id
}) })
} };
} else { } else {
return false return false;
} }
fetch(start, i).then(function (response) { fetch(start, i)
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (localStorage.getItem("filter_" + acct_id) != "undefined") { if (localStorage.getItem("filter_" + acct_id) != "undefined") {
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "thread"); var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "thread");
} else { } else {
var mute = []; var mute = [];
} }
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var templete = misskeyParse([json], '', acct_id, "", "", mute); var templete = misskeyParse([json], "", acct_id, "", "", mute);
$("#toot-after").prepend(templete); $("#toot-after").prepend(templete);
$("#toot-after .hide").html(lang.lang_details_filtered); $("#toot-after .hide").html(lang.lang_details_filtered);
$("#toot-after .by_filter").css("display", "block"); $("#toot-after .by_filter").css("display", "block");
@ -162,7 +169,6 @@ function replyTL(id, acct_id) {
replyTL(json[rep][0], acct_id); replyTL(json[rep][0], acct_id);
} }
} }
}); });
} }
@ -173,39 +179,43 @@ function getContext(id, acct_id) {
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/notes/conversation"; var start = "https://" + domain + "/api/notes/conversation";
var i = { var i = {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify({ body: JSON.stringify({
i: at, i: at,
noteId: id noteId: id
}) })
} };
} else { } else {
var start = "https://" + domain + "/api/v1/statuses/" + id + "/context"; var start = "https://" + domain + "/api/v1/statuses/" + id + "/context";
var i = { var i = {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
},
} }
};
} }
fetch(start, i).then(function (response) { fetch(start, i)
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
json.reverse(); json.reverse();
var templete = misskeyParse(json, '', acct_id, "", "", []); var templete = misskeyParse(json, "", acct_id, "", "", []);
$("#toot-reply").html(templete); $("#toot-reply").html(templete);
$("#toot-reply .hide").html(lang.lang_details_filtered); $("#toot-reply .hide").html(lang.lang_details_filtered);
$("#toot-reply .by_filter").css("display", "block"); $("#toot-reply .by_filter").css("display", "block");
@ -217,7 +227,7 @@ function getContext(id, acct_id) {
} else { } else {
var mute = []; var mute = [];
} }
var templete = parse(json.descendants, '', acct_id, "", "", mute); var templete = parse(json.descendants, "", acct_id, "", "", mute);
if (templete != "") { if (templete != "") {
$("#toot-after .no-data").hide(); $("#toot-after .no-data").hide();
} }
@ -225,7 +235,7 @@ function getContext(id, acct_id) {
$("#toot-after .hide").html(lang.lang_details_filtered); $("#toot-after .hide").html(lang.lang_details_filtered);
$("#toot-after .by_filter").css("display", "block"); $("#toot-after .by_filter").css("display", "block");
$("#toot-after .by_filter").removeClass("hide"); $("#toot-after .by_filter").removeClass("hide");
var templete = parse(json.ancestors, '', acct_id, "", "", mute); var templete = parse(json.ancestors, "", acct_id, "", "", mute);
if (templete != "") { if (templete != "") {
$("#toot-reply .no-data").hide(); $("#toot-reply .no-data").hide();
} }
@ -235,7 +245,6 @@ function getContext(id, acct_id) {
$("#toot-reply .by_filter").removeClass("hide"); $("#toot-reply .by_filter").removeClass("hide");
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
} }
}); });
} }
@ -244,52 +253,58 @@ function beforeToot(id, acct_id, domain) {
//var domain = localStorage.getItem("domain_" + acct_id); //var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + var start = "https://" + domain + "/api/notes/local-timeline";
"/api/notes/local-timeline"
fetch(start, { fetch(start, {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify({ body: JSON.stringify({
i: at, i: at,
untilID: id untilID: id
}) })
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = misskeyParse(json, 'noauth', acct_id); .then(function(json) {
var templete = misskeyParse(json, "noauth", acct_id);
$("#toot-before").html(templete); $("#toot-before").html(templete);
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
}); });
} else { } else {
var start = "https://" + domain + var start = "https://" + domain + "/api/v1/timelines/public?local=true&max_id=" + id;
"/api/v1/timelines/public?local=true&max_id=" + id;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = parse(json, 'noauth', acct_id); .then(function(json) {
var templete = parse(json, "noauth", acct_id);
if (templete != "") { if (templete != "") {
$("#toot-before .no-data").hide(); $("#toot-before .no-data").hide();
} }
@ -303,53 +318,60 @@ function userToot(id, acct_id, user) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + var start = "https://" + domain + "/api/users/notes";
"/api/users/notes"
fetch(start, { fetch(start, {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify({ body: JSON.stringify({
i: at, i: at,
untilID: id, untilID: id,
userId: user userId: user
}) })
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = misskeyParse(json, 'noauth', acct_id); .then(function(json) {
var templete = misskeyParse(json, "noauth", acct_id);
$("#user-before").html(templete); $("#user-before").html(templete);
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
}); });
} else { } else {
var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses?max_id=" + id; var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses?max_id=" + id;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = parse(json, '', acct_id); .then(function(json) {
var templete = parse(json, "", acct_id);
if (templete != "") { if (templete != "") {
$("#user-before .no-data").hide(); $("#user-before .no-data").hide();
} }
@ -357,31 +379,33 @@ function userToot(id, acct_id, user) {
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
}); });
} }
} }
//後のLTL //後のLTL
function afterToot(id, acct_id, domain) { function afterToot(id, acct_id, domain) {
//var domain = localStorage.getItem("domain_" + acct_id); //var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + var start = "https://" + domain + "/api/v1/timelines/public?local=true&min_id=" + id;
"/api/v1/timelines/public?local=true&min_id=" + id;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = parse(json, 'noauth', acct_id); .then(function(json) {
var templete = parse(json, "noauth", acct_id);
if (templete != "") { if (templete != "") {
$("#ltl-after .no-data").hide(); $("#ltl-after .no-data").hide();
} }
@ -395,23 +419,27 @@ function afterUserToot(id, acct_id, user) {
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses?min_id=" + id; var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses?min_id=" + id;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = parse(json, '', acct_id); .then(function(json) {
var templete = parse(json, "", acct_id);
if (templete != "") { if (templete != "") {
$("#user-after .no-data").hide(); $("#user-after .no-data").hide();
} }
@ -423,25 +451,28 @@ function afterUserToot(id, acct_id, user) {
function afterFTLToot(id, acct_id, domain) { function afterFTLToot(id, acct_id, domain) {
//var domain = localStorage.getItem("domain_" + acct_id); //var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + var start = "https://" + domain + "/api/v1/timelines/public?min_id=" + id;
"/api/v1/timelines/public?min_id=" + id;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = parse(json, 'noauth', acct_id); .then(function(json) {
var templete = parse(json, "noauth", acct_id);
if (templete != "") { if (templete != "") {
$("#ftl-after .no-data").hide(); $("#ftl-after .no-data").hide();
} }
@ -453,27 +484,33 @@ function afterFTLToot(id, acct_id, domain) {
//ふぁぼ一覧 //ふぁぼ一覧
function faved(id, acct_id) { function faved(id, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
if (localStorage.getItem("mode_" + domain) == "misskey") { return false; } if (localStorage.getItem("mode_" + domain) == "misskey") {
return false;
}
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/statuses/" + id + "/favourited_by"; var start = "https://" + domain + "/api/v1/statuses/" + id + "/favourited_by";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = userparse(json, '', acct_id); .then(function(json) {
var templete = userparse(json, "", acct_id);
if (templete != "") { if (templete != "") {
$("#toot-fav .no-data").hide(); $("#toot-fav .no-data").hide();
} }
@ -485,27 +522,33 @@ function faved(id, acct_id) {
//ブースト一覧 //ブースト一覧
function rted(id, acct_id) { function rted(id, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
if (localStorage.getItem("mode_" + domain) == "misskey") { return false; } if (localStorage.getItem("mode_" + domain) == "misskey") {
return false;
}
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/statuses/" + id + "/reblogged_by"; var start = "https://" + domain + "/api/v1/statuses/" + id + "/reblogged_by";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = userparse(json, '', acct_id); .then(function(json) {
var templete = userparse(json, "", acct_id);
$("#toot-rt").html(templete); $("#toot-rt").html(templete);
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
}); });
@ -517,13 +560,12 @@ function cbCopy(mode) {
var domain = urls[1]; var domain = urls[1];
if (mode == "emb") { if (mode == "emb") {
var emb = '<iframe src="' + url + '/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400"></iframe><script src="https://' + domain + '/embed.js" async="async"></script>'; var emb = '<iframe src="' + url + '/embed" class="mastodon-embed" style="max-width: 100%; border: 0" width="400"></iframe><script src="https://' + domain + '/embed.js" async="async"></script>';
execCopy(emb) execCopy(emb);
M.toast({ html: lang.lang_details_embed, displayLength: 1500 }) M.toast({ html: lang.lang_details_embed, displayLength: 1500 });
} else { } else {
if (execCopy(url)) { if (execCopy(url)) {
M.toast({ html: lang.lang_details_url, displayLength: 1500 }) M.toast({ html: lang.lang_details_url, displayLength: 1500 });
} }
} }
} }
//本文のコピー //本文のコピー
@ -537,9 +579,8 @@ function staCopy(id) {
html = html.replace(/<img[\s\S]*alt="(.+?)"[\s\S]*?>/g, "$1"); html = html.replace(/<img[\s\S]*alt="(.+?)"[\s\S]*?>/g, "$1");
html = $.strip_tags(html); html = $.strip_tags(html);
if (execCopy(html)) { if (execCopy(html)) {
M.toast({ html: lang.lang_details_txt, displayLength: 1500 }) M.toast({ html: lang.lang_details_txt, displayLength: 1500 });
} }
} }
//翻訳 //翻訳
function trans(tar, to) { function trans(tar, to) {
@ -555,28 +596,32 @@ function trans(tar, to) {
tar = "zh"; tar = "zh";
} }
$("#toot-this .additional").text("Loading...(Powered by Google Translate)"); $("#toot-this .additional").text("Loading...(Powered by Google Translate)");
var exec = 'https://script.google.com/macros/s/AKfycbxhwW5tjjop9Irg-y1zr_WsXlCKEzwWG6KuoOt_vVRDfEbRv0c/exec?format=json&text=' + encodeURIComponent(html) + '&source=' + tar + '&target=' + to var exec = "https://script.google.com/macros/s/AKfycbxhwW5tjjop9Irg-y1zr_WsXlCKEzwWG6KuoOt_vVRDfEbRv0c/exec?format=json&text=" + encodeURIComponent(html) + "&source=" + tar + "&target=" + to;
console.log("Try to translate from " + tar + " to " + to + " at " + exec); console.log("Try to translate from " + tar + " to " + to + " at " + exec);
fetch(exec, { fetch(exec, {
method: 'GET', method: "GET"
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (text) { })
$("#toot-this .additional").html('<span class="gray translate">' + text.text + '</span>'); .then(function(text) {
$("#toot-this .additional").html('<span class="gray translate">' + text.text + "</span>");
}); });
} }
//ブラウザで開く //ブラウザで開く
function brws() { function brws() {
var url = $("#tootmodal").attr("data-url"); var url = $("#tootmodal").attr("data-url");
postMessage(["openUrl", url], "*") postMessage(["openUrl", url], "*");
} }
//外部からトゥート開く //外部からトゥート開く
function detEx(url, acct_id) { function detEx(url, acct_id) {
@ -585,33 +630,36 @@ function detEx(url, acct_id) {
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v2/search?resolve=true&q=" + url var start = "https://" + domain + "/api/v2/search?resolve=true&q=" + url;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
} }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (!json.statuses) { if (!json.statuses) {
postMessage(["openUrl", url], "*") postMessage(["openUrl", url], "*");
} else { } else {
var id = json.statuses[0].id; var id = json.statuses[0].id;
$(".loadp").text($(".loadp").attr("href")); $(".loadp").text($(".loadp").attr("href"));
$(".loadp").removeClass("loadp"); $(".loadp").removeClass("loadp");
details(id, acct_id, 0) details(id, acct_id, 0);
} }
}); });
return; return;
} }

View File

@ -18,15 +18,15 @@ function dirselCk() {
} }
} }
function directory(isMore) { function directory(isMore) {
var order = $("[name=sort]:checked").val() var order = $("[name=sort]:checked").val();
if (!order) { if (!order) {
order = "active" order = "active";
} }
var local_only = $("#local_only:checked").val() var local_only = $("#local_only:checked").val();
if (local_only) { if (local_only) {
local_only = "true" local_only = "true";
} else { } else {
local_only = "false" local_only = "false";
} }
var acct_id = $("#dir-acct-sel").val(); var acct_id = $("#dir-acct-sel").val();
if (acct_id == "noauth") { if (acct_id == "noauth") {
@ -37,38 +37,40 @@ function directory(isMore) {
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
} }
if (isMore) { if (isMore) {
var addOffset = $("#dir-contents .cvo").length var addOffset = $("#dir-contents .cvo").length;
} else { } else {
var addOffset = 0 var addOffset = 0;
$("#dir-contents").html(""); $("#dir-contents").html("");
} }
var start = "https://" + domain + "/api/v1/directory?order=" + order + "&local=" + local_only + "&offset=" + addOffset var start = "https://" + domain + "/api/v1/directory?order=" + order + "&local=" + local_only + "&offset=" + addOffset;
console.log(start) console.log(start);
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
//todo(error); .catch(function(error) {
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
$("#moreDir").removeClass("disabled") $("#moreDir").removeClass("disabled");
var html = userparse(json, null, acct_id, "dir", null) var html = userparse(json, null, acct_id, "dir", null);
$("#dir-contents").append(html) $("#dir-contents").append(html);
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
} else { } else {
$("#moreDir").addClass("disabled") $("#moreDir").addClass("disabled");
} }
}); });
} }

View File

@ -1,28 +1,31 @@
//DM(Conv) TL //DM(Conv) TL
function dm(acct_id, tlid, type, delc, voice) { function dm(acct_id, tlid, type, delc, voice) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/conversations"; var start = "https://" + domain + "/api/v1/conversations";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = '<div id="convList' + tlid + '">' + dmListParse(json, type, acct_id, tlid, "", mute) + '</div>'; .then(function(json) {
localStorage.setItem("lastobj_" + tlid, json[0].id) var templete = '<div id="convList' + tlid + '">' + dmListParse(json, type, acct_id, tlid, "", mute) + "</div>";
localStorage.setItem("lastobj_" + tlid, json[0].id);
$("#timeline_" + tlid).html(templete); $("#timeline_" + tlid).html(templete);
additional(acct_id, tlid); additional(acct_id, tlid);
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
@ -30,7 +33,6 @@ function dm(acct_id, tlid, type, delc, voice) {
//reload(type, '', acct_id, tlid, data, mute, delc,voice); //reload(type, '', acct_id, tlid, data, mute, delc,voice);
$(window).scrollTop(0); $(window).scrollTop(0);
}); });
} }
function dmmore(tlid) { function dmmore(tlid) {
var multi = localStorage.getItem("column"); var multi = localStorage.getItem("column");
@ -38,44 +40,50 @@ function dmmore(tlid) {
var acct_id = obj[tlid].domain; var acct_id = obj[tlid].domain;
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var sid = $("#timeline_" + tlid + " .cvo").last().attr("unique-id"); var sid = $("#timeline_" + tlid + " .cvo")
.last()
.attr("unique-id");
var start = "https://" + domain + "/api/v1/conversations?max_id=" + sid; var start = "https://" + domain + "/api/v1/conversations?max_id=" + sid;
var type = "dm"; var type = "dm";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
var templete = '<div id="convList' + tlid + '">' + dmListParse(json, type, acct_id, tlid, "", mute) + '</div>'; .then(function(json) {
var templete = '<div id="convList' + tlid + '">' + dmListParse(json, type, acct_id, tlid, "", mute) + "</div>";
$("#timeline_" + tlid).append(templete); $("#timeline_" + tlid).append(templete);
additional(acct_id, tlid); additional(acct_id, tlid);
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
moreloading = false; moreloading = false;
}) });
} }
//DMオブジェクトパーサー(トゥート) //DMオブジェクトパーサー(トゥート)
function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) { function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
var templete = ''; var templete = "";
if (obj[0]) { if (obj[0]) {
localStorage.setItem("lastunix_" + tlid, date(obj[0].created_at, 'unix')); localStorage.setItem("lastunix_" + tlid, date(obj[0].created_at, "unix"));
} }
var actb = localStorage.getItem("action_btns"); var actb = localStorage.getItem("action_btns");
var actb = 're,rt,fav,qt,del,pin,red'; var actb = "re,rt,fav,qt,del,pin,red";
if (actb) { if (actb) {
var actb = actb.split(','); var actb = actb.split(",");
var disp = {}; var disp = {};
for (var k = 0; k < actb.length; k++) { for (var k = 0; k < actb.length; k++) {
if (k < 4) { if (k < 4) {
@ -222,11 +230,9 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
Object.keys(toot.account.emojis).forEach(function(key5) { Object.keys(toot.account.emojis).forEach(function(key5) {
var emoji = toot.account.emojis[key5]; var emoji = toot.account.emojis[key5];
var shortcode = emoji.shortcode; var shortcode = emoji.shortcode;
var emoji_url = '<img src="' + emoji.url + var emoji_url = '<img src="' + emoji.url + '" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
'" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
var regExp = new RegExp(":" + shortcode + ":", "g"); var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url); dis_name = dis_name.replace(regExp, emoji_url);
}); });
} }
var noticeavatar = ""; var noticeavatar = "";
@ -257,7 +263,7 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
var locked = ""; var locked = "";
} }
if (!toot.application) { if (!toot.application) {
var via = ''; var via = "";
viashow = "hide"; viashow = "hide";
} else { } else {
var via = escapeHTML(toot.application.name); var via = escapeHTML(toot.application.name);
@ -284,20 +290,20 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
var spoil = escapeHTML(toot.spoiler_text); var spoil = escapeHTML(toot.spoiler_text);
var spoiler = "cw cw_hide_" + toot.id; var spoiler = "cw cw_hide_" + toot.id;
var api_spoil = "gray"; var api_spoil = "gray";
var spoiler_show = '<a href="#" onclick="cw_show(\'' + toot.id + var spoiler_show = '<a href="#" onclick="cw_show(\'' + toot.id + '\')" class="nex parsed">' + lang.lang_parse_cwshow + "</a><br>";
'\')" class="nex parsed">' + lang.lang_parse_cwshow + '</a><br>';
} else { } else {
var ct1 = toot.content.split('</p>').length + toot.content.split('<br />').length - 2; var ct1 = toot.content.split("</p>").length + toot.content.split("<br />").length - 2;
var ct2 = toot.content.split('</p>').length + toot.content.split('<br>').length - 2; var ct2 = toot.content.split("</p>").length + toot.content.split("<br>").length - 2;
if (ct1 > ct2) { var ct = ct1; } else { var ct = ct2; } if (ct1 > ct2) {
var ct = ct1;
} else {
var ct = ct2;
}
if ((sent < ct && $.mb_strlen($.strip_tags(toot.content)) > 5) || ($.strip_tags(toot.content).length > ltr && $.mb_strlen($.strip_tags(toot.content)) > 5)) { if ((sent < ct && $.mb_strlen($.strip_tags(toot.content)) > 5) || ($.strip_tags(toot.content).length > ltr && $.mb_strlen($.strip_tags(toot.content)) > 5)) {
var content = '<span class="gray">' + lang.lang_parse_fulltext + '</span><br>' + toot.content var content = '<span class="gray">' + lang.lang_parse_fulltext + "</span><br>" + toot.content;
var spoil = '<span class="cw-long-' + toot.id + '">' + $.mb_substr($.strip_tags( var spoil = '<span class="cw-long-' + toot.id + '">' + $.mb_substr($.strip_tags(toot.content), 0, 100) + '</span><span class="gray">' + lang.lang_parse_autofold + "</span>";
toot.content), 0, 100) +
'</span><span class="gray">' + lang.lang_parse_autofold + '</span>';
var spoiler = "cw cw_hide_" + toot.id; var spoiler = "cw cw_hide_" + toot.id;
var spoiler_show = '<a href="#" onclick="cw_show(\'' + toot.id + var spoiler_show = '<a href="#" onclick="cw_show(\'' + toot.id + '\')" class="nex parsed">' + lang.lang_parse_more + "</a><br>";
'\')" class="nex parsed">' + lang.lang_parse_more + '</a><br>';
} else { } else {
var content = toot.content; var content = toot.content;
var spoil = escapeHTML(toot.spoiler_text); var spoil = escapeHTML(toot.spoiler_text);
@ -305,14 +311,13 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
var spoiler_show = ""; var spoiler_show = "";
} }
} }
var urls = $.strip_tags(content).replace(/\n/g, " ").match( var urls = $.strip_tags(content)
/https?:\/\/([-a-zA-Z0-9@.]+)\/?(?!.*((media|tags)|mentions)).*([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)?/ .replace(/\n/g, " ")
); .match(/https?:\/\/([-a-zA-Z0-9@.]+)\/?(?!.*((media|tags)|mentions)).*([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)?/);
if (urls) { if (urls) {
var analyze = '<a onclick="additionalIndv(\'' + tlid + '\',' + acct_id + var analyze = "<a onclick=\"additionalIndv('" + tlid + "'," + acct_id + ",'" + id + '\')" class="add-show pointer">' + lang.lang_parse_url + "</a><br>";
',\'' + id + '\')" class="add-show pointer">' + lang.lang_parse_url + '</a><br>';
} else { } else {
var analyze = ''; var analyze = "";
} }
var viewer = ""; var viewer = "";
var hasmedia = ""; var hasmedia = "";
@ -327,8 +332,7 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
Object.keys(toot.emojis).forEach(function(key5) { Object.keys(toot.emojis).forEach(function(key5) {
var emoji = toot.emojis[key5]; var emoji = toot.emojis[key5];
var shortcode = emoji.shortcode; var shortcode = emoji.shortcode;
var emoji_url = '<img src="' + emoji.url + var emoji_url = '<img src="' + emoji.url + '" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
'" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
var regExp = new RegExp(":" + shortcode + ":", "g"); var regExp = new RegExp(":" + shortcode + ":", "g");
content = content.replace(regExp, emoji_url); content = content.replace(regExp, emoji_url);
spoil = spoil.replace(regExp, emoji_url); spoil = spoil.replace(regExp, emoji_url);
@ -345,8 +349,7 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
Object.keys(toot.profile_emojis).forEach(function(keynico) { Object.keys(toot.profile_emojis).forEach(function(keynico) {
var emoji = toot.profile_emojis[keynico]; var emoji = toot.profile_emojis[keynico];
var shortcode = emoji.shortcode; var shortcode = emoji.shortcode;
var emoji_url = '<img src="' + emoji.url + var emoji_url = '<img src="' + emoji.url + '" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
'" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
var regExp = new RegExp(":" + shortcode + ":", "g"); var regExp = new RegExp(":" + shortcode + ":", "g");
content = content.replace(regExp, emoji_url); content = content.replace(regExp, emoji_url);
spoil = spoil.replace(regExp, emoji_url); spoil = spoil.replace(regExp, emoji_url);
@ -372,15 +375,11 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
media_ids = media_ids + media.id + ","; media_ids = media_ids + media.id + ",";
var url = media.url; var url = media.url;
if (toot.sensitive && nsfw) { if (toot.sensitive && nsfw) {
var sense = "sensitive" var sense = "sensitive";
} else { } else {
var sense = "" var sense = "";
} }
viewer = viewer + '<a onclick="imgv(\'' + id + '\',\'' + key2 + '\',\'' + viewer = viewer + "<a onclick=\"imgv('" + id + "','" + key2 + "','" + acct_id + '\')" id="' + id + "-image-" + key2 + '" data-url="' + url + '" data-type="' + media.type + '" class="img-parsed"><img src="' + purl + '" class="' + sense + ' toot-img pointer" style="width:' + cwdt + "%; height:" + imh + 'px;"></a></span>';
acct_id + '\')" id="' + id + '-image-' + key2 + '" data-url="' + url +
'" data-type="' + media.type + '" class="img-parsed"><img src="' +
purl + '" class="' + sense +
' toot-img pointer" style="width:' + cwdt + '%; height:' + imh + 'px;"></a></span>';
}); });
media_ids = media_ids.slice(0, -1); media_ids = media_ids.slice(0, -1);
} else { } else {
@ -394,10 +393,9 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
mentions = ""; mentions = "";
Object.keys(toot.mentions).forEach(function(key3) { Object.keys(toot.mentions).forEach(function(key3) {
var mention = toot.mentions[key3]; var mention = toot.mentions[key3];
mentions = mentions + '<a onclick="udg(\'' + mention.id + '\',' + mentions = mentions + "<a onclick=\"udg('" + mention.id + "'," + acct_id + ')" class="pointer">@' + mention.acct + "</a> ";
acct_id + ')" class="pointer">@' + mention.acct + '</a> ';
}); });
mentions = '<div style="float:right">' + mentions + '</div>'; mentions = '<div style="float:right">' + mentions + "</div>";
} }
var tagck = toot.tags[0]; var tagck = toot.tags[0];
var tags = ""; var tags = "";
@ -405,11 +403,9 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
if (tagck) { if (tagck) {
Object.keys(toot.tags).forEach(function(key4) { Object.keys(toot.tags).forEach(function(key4) {
var tag = toot.tags[key4]; var tag = toot.tags[key4];
tags = tags + '<span class="hide" data-tag="' + tag.name + '">#' + tag.name + ':<a onclick="tl(\'tag\',\'' + tag.name + '\',' + acct_id + tags = tags + '<span class="hide" data-tag="' + tag.name + '">#' + tag.name + ":<a onclick=\"tl('tag','" + tag.name + "'," + acct_id + ',\'add\')" class="pointer" title="' + lang.lang_parse_tagTL.replace("{{tag}}", "#" + tag.name) + '">TL</a> <a onclick="brInsert(\'#' + tag.name + '\')" class="pointer" title="' + lang.lang_parse_tagtoot.replace("{{tag}}", "#" + tag.name) + '">Toot</a> ' + "<a onclick=\"tagPin('" + tag.name + '\')" class="pointer" title="' + lang.lang_parse_tagpin.replace("{{tag}}", "#" + tag.name) + '">Pin</a></span> ';
',\'add\')" class="pointer" title="' + lang.lang_parse_tagTL.replace("{{tag}}", '#' + tag.name) + '">TL</a> <a onclick="brInsert(\'#' + tag.name + '\')" class="pointer" title="' + lang.lang_parse_tagtoot.replace("{{tag}}", '#' + tag.name) + '">Toot</a> ' +
'<a onclick="tagPin(\'' + tag.name + '\')" class="pointer" title="' + lang.lang_parse_tagpin.replace("{{tag}}", '#' + tag.name) + '">Pin</a></span> ';
}); });
tags = '<div style="float:right">' + tags + '</div>'; tags = '<div style="float:right">' + tags + "</div>";
} }
//アニメ再生 //アニメ再生
if (gif == "yes") { if (gif == "yes") {
@ -425,7 +421,7 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
if (worde.tag) { if (worde.tag) {
var word = worde.tag; var word = worde.tag;
} else { } else {
var word = worde var word = worde;
} }
var regExp = new RegExp(word, "g"); var regExp = new RegExp(word, "g");
if ($.strip_tags(content).match(regExp)) { if ($.strip_tags(content).match(regExp)) {
@ -465,23 +461,21 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
if (cards.image) { if (cards.image) {
var twiImg = '<br><img src="' + cards.image + '">'; var twiImg = '<br><img src="' + cards.image + '">';
} else { } else {
var twiImg = ''; var twiImg = "";
} }
analyze = '<blockquote class="twitter-tweet"><b>' + escapeHTML(cards.author_name) + '</b><br>' + escapeHTML(cards.description) + twiImg + '</blockquote>'; analyze = '<blockquote class="twitter-tweet"><b>' + escapeHTML(cards.author_name) + "</b><br>" + escapeHTML(cards.description) + twiImg + "</blockquote>";
} }
if (cards.title) { if (cards.title) {
analyze = "<span class=\"gray\">URL" + lang.lang_cards_check + ":<br>Title:" + escapeHTML(cards.title) + "<br>" + analyze = '<span class="gray">URL' + lang.lang_cards_check + ":<br>Title:" + escapeHTML(cards.title) + "<br>" + escapeHTML(cards.description) + "</span>";
escapeHTML(cards.description) + "</span>";
} }
if (cards.html) { if (cards.html) {
analyze = cards.html + '<i class="material-icons" onclick="pip(' + id + ')" title="' + lang.lang_cards_pip + '">picture_in_picture_alt</i>'; analyze = cards.html + '<i class="material-icons" onclick="pip(' + id + ')" title="' + lang.lang_cards_pip + '">picture_in_picture_alt</i>';
} }
} }
//Ticker //Ticker
var tickerdom = ""; var tickerdom = "";
if (ticker) { if (ticker) {
var tickerdata = localStorage.getItem("ticker") var tickerdata = localStorage.getItem("ticker");
if (tickerdata) { if (tickerdata) {
var tickerdata = JSON.parse(tickerdata); var tickerdata = JSON.parse(tickerdata);
@ -492,41 +486,13 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
for (var i = 0; i < tickerdata.length; i++) { for (var i = 0; i < tickerdata.length; i++) {
var value = tickerdata[i]; var value = tickerdata[i];
if (value.domain == thisdomain) { if (value.domain == thisdomain) {
var tickerdom = '<div style="background:linear-gradient(to left,transparent, ' + value.bg + ' 96%) !important; color:' + value.text + ';width:100%; height:0.9rem; font-size:0.8rem;"><img src="' + value.image + '" style="height:100%;"><span style="position:relative; top:-0.2rem;"> ' + escapeHTML(value.name) + '</span></div>'; var tickerdom = '<div style="background:linear-gradient(to left,transparent, ' + value.bg + " 96%) !important; color:" + value.text + ';width:100%; height:0.9rem; font-size:0.8rem;"><img src="' + value.image + '" style="height:100%;"><span style="position:relative; top:-0.2rem;"> ' + escapeHTML(value.name) + "</span></div>";
break; break;
} }
} }
} }
} }
templete = templete + '<div id="pub_' + toot.id + '" class="cvo ' + templete = templete + '<div id="pub_' + toot.id + '" class="cvo ' + boostback + " " + fav_app + " " + hasmedia + '" toot-id="' + id + '" unique-id="' + uniqueid + '" data-medias="' + media_ids + ' " unixtime="' + date(obj[key].created_at, "unix") + '" ' + if_notf + ' onclick="dmStatus()">' + '<div class="area-notice"><span class="gray sharesta">' + notice + home + "</span></div>" + '<div class="area-icon"><a onclick="udg(\'' + toot.account.id + "'," + acct_id + ');" user="' + toot.account.acct + '" class="udg">' + '<img src="' + avatar + '" width="40" class="prof-img" user="' + toot.account.acct + '"></a>' + noticeavatar + "</div>" + '<div class="area-display_name"><div class="flex-name"><span class="user">' + dis_name + '</span><span class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis; cursor:text;"> @' + toot.account.acct + locked + "</span></div>" + '<div class="flex-time"><span class="cbadge cbadge-hover pointer waves-effect" onclick="tootUriCopy(\'' + toot.url + '\');" title="' + date(toot.created_at, "absolute") + "(" + lang.lang_parse_clickcopyurl + ')"><i class="far fa-clock-o"></i>' + date(toot.created_at, datetype) + "</span>" + "</div></div>" + '<div class="area-toot">' + tickerdom + '<span class="' + api_spoil + " cw_text_" + toot.id + '"><span class="cw_text">' + spoil + "</span>" + spoiler_show + '</span><span class="toot ' + spoiler + '">' + content + "</span>" + "" + viewer + "" + "<br><a onclick=\"details('" + toot.id + "'," + acct_id + ",'" + tlid + "','dm')\" class=\"pointer waves-effect\">" + lang.lang_parse_thread + "</a></div>" + '<div class="area-vis"></div>' + "</div></div>";
boostback + ' ' + fav_app +
' ' + hasmedia + '" toot-id="' + id + '" unique-id="' + uniqueid + '" data-medias="' + media_ids + ' " unixtime="' + date(obj[
key].created_at, 'unix') + '" ' + if_notf + ' onclick="dmStatus()">' +
'<div class="area-notice"><span class="gray sharesta">' + notice + home +
'</span></div>' +
'<div class="area-icon"><a onclick="udg(\'' + toot.account.id +
'\',' + acct_id + ');" user="' + toot.account.acct + '" class="udg">' +
'<img src="' + avatar +
'" width="40" class="prof-img" user="' + toot.account.acct +
'"></a>' + noticeavatar + '</div>' +
'<div class="area-display_name"><div class="flex-name"><span class="user">' +
dis_name +
'</span><span class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis; cursor:text;"> @' +
toot.account.acct + locked + '</span></div>' +
'<div class="flex-time"><span class="cbadge cbadge-hover pointer waves-effect" onclick="tootUriCopy(\'' +
toot.url + '\');" title="' + date(toot.created_at, 'absolute') +
'(' + lang.lang_parse_clickcopyurl + ')"><i class="far fa-clock-o"></i>' +
date(toot.created_at, datetype) + '</span>' +
'</div></div>' +
'<div class="area-toot">' + tickerdom + '<span class="' +
api_spoil + ' cw_text_' + toot.id + '"><span class="cw_text">' + spoil + "</span>" + spoiler_show +
'</span><span class="toot ' + spoiler + '">' + content +
'</span>' +
'' + viewer + '' +
'<br><a onclick="details(\'' + toot.id + '\',' + acct_id +
',\'' + tlid + '\',\'dm\')" class="pointer waves-effect">' + lang.lang_parse_thread + '</a></div>' +
'<div class="area-vis"></div>' +
'</div></div>';
}); });
return templete; return templete;
} }

View File

@ -5,13 +5,13 @@ function mediaToggle(tlid) {
if (media) { if (media) {
localStorage.removeItem("media_" + tlid); localStorage.removeItem("media_" + tlid);
$("#sta-media-" + tlid).text("Off"); $("#sta-media-" + tlid).text("Off");
$("#sta-media-" + tlid).css("color", 'red'); $("#sta-media-" + tlid).css("color", "red");
$("#timeline_" + tlid).removeClass("media-filter") $("#timeline_" + tlid).removeClass("media-filter");
} else { } else {
localStorage.setItem("media_" + tlid, "true"); localStorage.setItem("media_" + tlid, "true");
$("#sta-media-" + tlid).text("On"); $("#sta-media-" + tlid).text("On");
$("#sta-media-" + tlid).css("color", '#009688'); $("#sta-media-" + tlid).css("color", "#009688");
$("#timeline_" + tlid).addClass("media-filter") $("#timeline_" + tlid).addClass("media-filter");
} }
} }
//各TL上方のBT[BTOnly/BTExc/Off] //各TL上方のBT[BTOnly/BTExc/Off]
@ -20,21 +20,21 @@ function ebtToggle(tlid) {
if (ebt == "true") { if (ebt == "true") {
localStorage.setItem("ebt_" + tlid, "but"); localStorage.setItem("ebt_" + tlid, "but");
$("#sta-bt-" + tlid).text("BT Only"); $("#sta-bt-" + tlid).text("BT Only");
$("#sta-bt-" + tlid).css("color", '#ff9800'); $("#sta-bt-" + tlid).css("color", "#ff9800");
$("#timeline_" + tlid).addClass("except-bt-filter") $("#timeline_" + tlid).addClass("except-bt-filter");
$("#timeline_" + tlid).removeClass("bt-filter") $("#timeline_" + tlid).removeClass("bt-filter");
} else if (ebt == "but") { } else if (ebt == "but") {
localStorage.removeItem("ebt_" + tlid); localStorage.removeItem("ebt_" + tlid);
$("#sta-bt-" + tlid).text("Off"); $("#sta-bt-" + tlid).text("Off");
$("#sta-bt-" + tlid).css("color", 'red'); $("#sta-bt-" + tlid).css("color", "red");
$("#timeline_" + tlid).removeClass("bt-filter") $("#timeline_" + tlid).removeClass("bt-filter");
$("#timeline_" + tlid).removeClass("except-bt-filter") $("#timeline_" + tlid).removeClass("except-bt-filter");
} else { } else {
localStorage.setItem("ebt_" + tlid, "true"); localStorage.setItem("ebt_" + tlid, "true");
$("#sta-bt-" + tlid).text("BT Ex"); $("#sta-bt-" + tlid).text("BT Ex");
$("#sta-bt-" + tlid).css("color", '#009688'); $("#sta-bt-" + tlid).css("color", "#009688");
$("#timeline_" + tlid).addClass("bt-filter") $("#timeline_" + tlid).addClass("bt-filter");
$("#timeline_" + tlid).removeClass("except-bt-filter") $("#timeline_" + tlid).removeClass("except-bt-filter");
} }
} }
//各TL上方のMedia[On/Off]をチェック //各TL上方のMedia[On/Off]をチェック
@ -42,12 +42,12 @@ function mediaCheck(tlid) {
var media = localStorage.getItem("media_" + tlid); var media = localStorage.getItem("media_" + tlid);
if (media) { if (media) {
$("#sta-media-" + tlid).text("On"); $("#sta-media-" + tlid).text("On");
$("#sta-media-" + tlid).css("color", '#009688'); $("#sta-media-" + tlid).css("color", "#009688");
$("#timeline_" + tlid).addClass("media-filter") $("#timeline_" + tlid).addClass("media-filter");
} else { } else {
$("#sta-media-" + tlid).text("Off"); $("#sta-media-" + tlid).text("Off");
$("#sta-media-" + tlid).css("color", 'red'); $("#sta-media-" + tlid).css("color", "red");
$("#timeline_" + tlid).removeClass("media-filter") $("#timeline_" + tlid).removeClass("media-filter");
} }
} }
//各TL上方のBT[On/Off]をチェック //各TL上方のBT[On/Off]をチェック
@ -55,19 +55,19 @@ function ebtCheck(tlid) {
var ebt = localStorage.getItem("ebt_" + tlid); var ebt = localStorage.getItem("ebt_" + tlid);
if (ebt == "true") { if (ebt == "true") {
$("#sta-bt-" + tlid).text("BT Ex"); $("#sta-bt-" + tlid).text("BT Ex");
$("#sta-bt-" + tlid).css("color", '#009688'); $("#sta-bt-" + tlid).css("color", "#009688");
$("#timeline_" + tlid).addClass("bt-filter") $("#timeline_" + tlid).addClass("bt-filter");
$("#timeline_" + tlid).removeClass("except-bt-filter") $("#timeline_" + tlid).removeClass("except-bt-filter");
} else if (ebt == "but") { } else if (ebt == "but") {
$("#sta-bt-" + tlid).text("BT Only"); $("#sta-bt-" + tlid).text("BT Only");
$("#sta-bt-" + tlid).css("color", '#ff9800'); $("#sta-bt-" + tlid).css("color", "#ff9800");
$("#timeline_" + tlid).addClass("except-bt-filter") $("#timeline_" + tlid).addClass("except-bt-filter");
$("#timeline_" + tlid).removeClass("bt-filter") $("#timeline_" + tlid).removeClass("bt-filter");
} else { } else {
$("#sta-bt-" + tlid).text("Off"); $("#sta-bt-" + tlid).text("Off");
$("#sta-bt-" + tlid).css("color", 'red'); $("#sta-bt-" + tlid).css("color", "red");
$("#timeline_" + tlid).removeClass("bt-filter") $("#timeline_" + tlid).removeClass("bt-filter");
$("#timeline_" + tlid).removeClass("except-bt-filter") $("#timeline_" + tlid).removeClass("except-bt-filter");
} }
} }
/* 削除追跡*/ /* 削除追跡*/
@ -76,12 +76,12 @@ function catchToggle(tlid) {
if (catchck) { if (catchck) {
localStorage.removeItem("catch_" + tlid); localStorage.removeItem("catch_" + tlid);
$("#sta-del-" + tlid).text("Off"); $("#sta-del-" + tlid).text("Off");
$("#sta-del-" + tlid).css("color", 'red'); $("#sta-del-" + tlid).css("color", "red");
parseColumn(tlid); parseColumn(tlid);
} else { } else {
localStorage.setItem("catch_" + tlid, "true"); localStorage.setItem("catch_" + tlid, "true");
$("#sta-del-" + tlid).text("On"); $("#sta-del-" + tlid).text("On");
$("#sta-del-" + tlid).css("color", '#009688'); $("#sta-del-" + tlid).css("color", "#009688");
parseColumn(tlid); parseColumn(tlid);
} }
} }
@ -89,16 +89,15 @@ function catchCheck(tlid) {
var catchck = localStorage.getItem("catch_" + tlid); var catchck = localStorage.getItem("catch_" + tlid);
if (catchck) { if (catchck) {
$("#sta-del-" + tlid).text("On"); $("#sta-del-" + tlid).text("On");
$("#sta-del-" + tlid).css("color", '#009688'); $("#sta-del-" + tlid).css("color", "#009688");
} else { } else {
$("#sta-del-" + tlid).text("Off"); $("#sta-del-" + tlid).text("Off");
$("#sta-del-" + tlid).css("color", 'red'); $("#sta-del-" + tlid).css("color", "red");
} }
} }
function delreset(tlid) { function delreset(tlid) {
$("[tlid=" + tlid + "] .by_delcatch").hide(); $("[tlid=" + tlid + "] .by_delcatch").hide();
$("[tlid=" + tlid + "] .by_delcatch").remove(); $("[tlid=" + tlid + "] .by_delcatch").remove();
} }
/*ワードフィルター機能*/ /*ワードフィルター機能*/
function filterMenu() { function filterMenu() {
@ -109,36 +108,38 @@ function filterMenu() {
} }
function filter() { function filter() {
$("#filtered-words").html(""); $("#filtered-words").html("");
$("#filter-edit-id").val("") $("#filter-edit-id").val("");
var acct_id = $("#filter-acct-sel").val(); var acct_id = $("#filter-acct-sel").val();
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/filters" var start = "https://" + domain + "/api/v1/filters";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
var filters = ""; var filters = "";
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var filterword = json[key]; var filterword = json[key];
var context = filterword.context.join(','); var context = filterword.context.join(",");
filters = filters + escapeHTML(filterword.phrase) + '<span class="sml">(for ' + context + ')</span>:<a onclick="filterEdit(\'' + filterword.id + '\',\'' + acct_id + filters = filters + escapeHTML(filterword.phrase) + '<span class="sml">(for ' + context + ")</span>:<a onclick=\"filterEdit('" + filterword.id + "','" + acct_id + '\')" class="pointer">' + lang.lang_edit + '</a>/<a onclick="filterDel(' + filterword.id + "," + acct_id + ')" class="pointer">' + lang.lang_del + "</a><br> ";
'\')" class="pointer">' + lang.lang_edit + '</a>/<a onclick="filterDel(' + filterword.id + ',' + acct_id +
')" class="pointer">' + lang.lang_del + '</a><br> ';
}); });
if (filters == "") { if (filters == "") {
filters = lang.lang_filter_nodata + "<br>"; filters = lang.lang_filter_nodata + "<br>";
@ -150,9 +151,9 @@ function filter() {
}); });
} }
function filterTime(day, hour, min) { function filterTime(day, hour, min) {
$("#days_filter").val(day) $("#days_filter").val(day);
$("#hours_filter").val(hour) $("#hours_filter").val(hour);
$("#mins_filter").val(min) $("#mins_filter").val(min);
} }
function makeNewFilter() { function makeNewFilter() {
var acct_id = $("#filter-acct-sel").val(); var acct_id = $("#filter-acct-sel").val();
@ -171,7 +172,7 @@ function makeNewFilter() {
cont.push("thread"); cont.push("thread");
} }
if (!cont.length) { if (!cont.length) {
$("#filtered-words").html('Error:' + lang.lang_filter_errordegree); $("#filtered-words").html("Error:" + lang.lang_filter_errordegree);
} }
var exc = $("#except_filter:checked").val(); var exc = $("#except_filter:checked").val();
var who = $("#wholeword_filter:checked").val(); var who = $("#wholeword_filter:checked").val();
@ -183,30 +184,34 @@ function makeNewFilter() {
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if ($("#filter-edit-id").val()) { if ($("#filter-edit-id").val()) {
var start = "https://" + domain + "/api/v1/filters/" + $("#filter-edit-id").val(); var start = "https://" + domain + "/api/v1/filters/" + $("#filter-edit-id").val();
var method = "PUT" var method = "PUT";
} else { } else {
var start = "https://" + domain + "/api/v1/filters" var start = "https://" + domain + "/api/v1/filters";
var method = "POST" var method = "POST";
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open(method, start, true); httpreq.open(method, start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader('Authorization', 'Bearer ' + at); httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(JSON.stringify({ httpreq.send(
JSON.stringify({
phrase: phr, phrase: phr,
context: cont, context: cont,
irreversible: exc, irreversible: exc,
whole_word: who, whole_word: who,
expires_in: time expires_in: time
})); })
);
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
filter(); filter();
filterUpdate(acct_id) filterUpdate(acct_id);
$("#filter-add-word").val(""); $("#filter-add-word").val("");
$("#home_filter").prop("checked", false); $("#home_filter").prop("checked", false);
$("#local_filter").prop("checked", false); $("#local_filter").prop("checked", false);
@ -218,9 +223,9 @@ function makeNewFilter() {
$("#hours_filter").val("0"); $("#hours_filter").val("0");
$("#mins_filter").val("0"); $("#mins_filter").val("0");
$("#add-filter-btn").text(lang.lang_add); $("#add-filter-btn").text(lang.lang_add);
$("#filter-edit-id").val("") $("#filter-edit-id").val("");
}
} }
};
} }
function filterEdit(id, acct_id) { function filterEdit(id, acct_id) {
$("#filter-add-word").val(""); $("#filter-add-word").val("");
@ -237,24 +242,28 @@ function filterEdit(id, acct_id) {
$("#filter-edit-id").val(id); $("#filter-edit-id").val(id);
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/filters/" + id var start = "https://" + domain + "/api/v1/filters/" + id;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
var now = new Date(); var now = new Date();
now = now.getTime(); now = now.getTime();
@ -270,7 +279,7 @@ function filterEdit(id, acct_id) {
if (json.whole_word) { if (json.whole_word) {
$("#wholeword_filter").prop("checked", true); $("#wholeword_filter").prop("checked", true);
} }
var expires = date(json.expires_at, 'unix') - now; var expires = date(json.expires_at, "unix") - now;
var mins = Math.floor(expires / 60) % 60; var mins = Math.floor(expires / 60) % 60;
var hours = Math.floor(expires / 3600) % 24; var hours = Math.floor(expires / 3600) % 24;
var days = Math.floor(expires / 3600 / 24); var days = Math.floor(expires / 3600 / 24);
@ -286,41 +295,47 @@ function filterDel(id, acct_id) {
var start = "https://" + domain + "/api/v1/filters/" + id; var start = "https://" + domain + "/api/v1/filters/" + id;
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open("DELETE", start, true); httpreq.open("DELETE", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader('Authorization', 'Bearer ' + at); httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(); httpreq.send();
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
filter(); filter();
filterUpdate(acct_id) filterUpdate(acct_id);
}
} }
};
} }
function getFilter(acct_id) { function getFilter(acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem("mode_" + domain) != "misskey") {
var start = "https://" + domain + "/api/v1/filters" var start = "https://" + domain + "/api/v1/filters";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
localStorage.setItem("filter_" + acct_id, JSON.stringify(json)); localStorage.setItem("filter_" + acct_id, JSON.stringify(json));
}); });
} else { } else {
@ -351,32 +366,34 @@ function getFilterType(json, type) {
function filterUpdate(acct_id) { function filterUpdate(acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/filters" var start = "https://" + domain + "/api/v1/filters";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
localStorage.setItem("filter_" + acct_id, JSON.stringify(json)); localStorage.setItem("filter_" + acct_id, JSON.stringify(json));
filterUpdateInternal(json, "home"); filterUpdateInternal(json, "home");
filterUpdateInternal(json, "local"); filterUpdateInternal(json, "local");
filterUpdateInternal(json, "notf"); filterUpdateInternal(json, "notf");
filterUpdateInternal(json, "pub"); filterUpdateInternal(json, "pub");
}); });
} }
function filterUpdateInternal(json, type) { function filterUpdateInternal(json, type) {
var home = getFilterType(json, type); var home = getFilterType(json, type);
@ -389,7 +406,9 @@ function filterUpdateInternal(json, type) {
$("[data-acct=" + acct_id + "] [data-type=" + type + "] .cvo").each(function(i, elem) { $("[data-acct=" + acct_id + "] [data-type=" + type + "] .cvo").each(function(i, elem) {
var id = $(elem).attr("toot-id"); var id = $(elem).attr("toot-id");
$("[toot-id=" + id + "]").removeClass("hide"); $("[toot-id=" + id + "]").removeClass("hide");
var text = $(elem).find('.toot').html(); var text = $(elem)
.find(".toot")
.html();
Object.keys(home).forEach(function(key8) { Object.keys(home).forEach(function(key8) {
var word = home[key8]; var word = home[key8];
var regExp = new RegExp(word.replace(/[.*+?^=!:${}()|[\]\/\\]/g, "\\$&"), "g"); var regExp = new RegExp(word.replace(/[.*+?^=!:${}()|[\]\/\\]/g, "\\$&"), "g");
@ -408,41 +427,41 @@ function filterUpdateInternal(json, type) {
*/ */
//通知フィルター //通知フィルター
function exclude(key) { function exclude(key) {
localStorage.setItem("exclude-" + key, "") localStorage.setItem("exclude-" + key, "");
var excludetxt = localStorage.getItem("exclude-" + key); var excludetxt = localStorage.getItem("exclude-" + key);
if ($('#exc-reply-' + key + ':checked').val()) { if ($("#exc-reply-" + key + ":checked").val()) {
excludetxt = "?exclude_types[]=mention" excludetxt = "?exclude_types[]=mention";
} }
if ($('#exc-fav-' + key + ':checked').val()) { if ($("#exc-fav-" + key + ":checked").val()) {
if (excludetxt || excludetxt != "") { if (excludetxt || excludetxt != "") {
excludetxt = excludetxt + "&exclude_types[]=favourite" excludetxt = excludetxt + "&exclude_types[]=favourite";
} else { } else {
excludetxt = "?exclude_types[]=favourite" excludetxt = "?exclude_types[]=favourite";
} }
} }
if ($('#exc-bt-' + key + ':checked').val()) { if ($("#exc-bt-" + key + ":checked").val()) {
if (excludetxt || excludetxt != "") { if (excludetxt || excludetxt != "") {
excludetxt = excludetxt + "&exclude_types[]=reblog" excludetxt = excludetxt + "&exclude_types[]=reblog";
} else { } else {
excludetxt = "?exclude_types[]=reblog" excludetxt = "?exclude_types[]=reblog";
} }
} }
if ($('#exc-follow-' + key + ':checked').val()) { if ($("#exc-follow-" + key + ":checked").val()) {
if (excludetxt || excludetxt != "") { if (excludetxt || excludetxt != "") {
excludetxt = excludetxt + "&exclude_types[]=follow" excludetxt = excludetxt + "&exclude_types[]=follow";
} else { } else {
excludetxt = "?exclude_types[]=follow" excludetxt = "?exclude_types[]=follow";
} }
} }
if ($('#exc-poll-' + key + ':checked').val()) { if ($("#exc-poll-" + key + ":checked").val()) {
if (excludetxt || excludetxt != "") { if (excludetxt || excludetxt != "") {
excludetxt = excludetxt + "&exclude_types[]=poll" excludetxt = excludetxt + "&exclude_types[]=poll";
} else { } else {
excludetxt = "?exclude_types[]=poll" excludetxt = "?exclude_types[]=poll";
} }
} else { } else {
} }
localStorage.setItem("exclude-" + key, excludetxt) localStorage.setItem("exclude-" + key, excludetxt);
parseColumn(key); parseColumn(key);
} }
function excludeCk(key, target) { function excludeCk(key, target) {
@ -451,7 +470,7 @@ function excludeCk(key, target) {
return ""; return "";
} }
if (~exc.indexOf(target)) { if (~exc.indexOf(target)) {
return "checked" return "checked";
} else { } else {
return ""; return "";
} }
@ -465,16 +484,16 @@ function checkNotfFilter(tlid){
} }
} }
function resetNotfFilter(tlid) { function resetNotfFilter(tlid) {
localStorage.setItem("exclude-" + tlid, "") localStorage.setItem("exclude-" + tlid, "");
parseColumn(tlid); parseColumn(tlid);
} }
function notfFilter(id, tlid, acct_id) { function notfFilter(id, tlid, acct_id) {
var excludetxt = localStorage.getItem("exclude-" + tlid); var excludetxt = localStorage.getItem("exclude-" + tlid);
if (excludetxt || excludetxt != "") { if (excludetxt || excludetxt != "") {
excludetxt = excludetxt + "&account_id="+id excludetxt = excludetxt + "&account_id=" + id;
} else { } else {
excludetxt = "?account_id="+id excludetxt = "?account_id=" + id;
} }
localStorage.setItem("exclude-" + tlid, excludetxt) localStorage.setItem("exclude-" + tlid, excludetxt);
parseColumn(tlid); parseColumn(tlid);
} }

View File

@ -3,40 +3,42 @@ function listMenu() {
$("#listMenu").addClass("active"); $("#listMenu").addClass("active");
$(".menu-content").addClass("hide"); $(".menu-content").addClass("hide");
$("#list-box").removeClass("hide"); $("#list-box").removeClass("hide");
$('ul.tabs').tabs('select_tab', 'src-sta'); $("ul.tabs").tabs("select_tab", "src-sta");
$("#src-contents").html(""); $("#src-contents").html("");
} }
function list() { function list() {
$("#lists-user").html(""); $("#lists-user").html("");
var acct_id = $("#list-acct-sel").val(); var acct_id = $("#list-acct-sel").val();
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/users/lists/list" var start = "https://" + domain + "/api/users/lists/list";
fetch(start, { fetch(start, {
method: 'POST', method: "POST",
body: JSON.stringify({ body: JSON.stringify({
i: at i: at
}), })
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
var lists = ""; var lists = "";
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var list = json[key]; var list = json[key];
lists = lists + escapeHTML(list.title) + ':<a onclick="listShow(\'' + list.id + '\',\'' + escapeHTML(list.title) + '\',\'' + acct_id + lists = lists + escapeHTML(list.title) + ":<a onclick=\"listShow('" + list.id + "','" + escapeHTML(list.title) + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_show + "</a><br>";
'\')" class="pointer">' + lang.lang_list_show + '</a><br>';
}); });
$("#lists").html(lists); $("#lists").html(lists);
} else { } else {
@ -44,31 +46,33 @@ function list() {
} }
}); });
} else { } else {
var start = "https://" + domain + "/api/v1/lists" var start = "https://" + domain + "/api/v1/lists";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
var lists = ""; var lists = "";
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var list = json[key]; var list = json[key];
lists = lists + escapeHTML(list.title) + ':<a onclick="listShow(\'' + list.id + '\',\'' + escapeHTML(list.title) + '\',\'' + acct_id + lists = lists + escapeHTML(list.title) + ":<a onclick=\"listShow('" + list.id + "','" + escapeHTML(list.title) + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_show + "</a>/<a onclick=\"listUser('" + list.id + "'," + acct_id + ')" class="pointer">' + lang.lang_list_users + "</a><br>";
'\')" class="pointer">' + lang.lang_list_show + '</a>/<a onclick="listUser(\'' + list.id + '\',' + acct_id +
')" class="pointer">' + lang.lang_list_users + '</a><br>';
}); });
$("#lists").html(lists); $("#lists").html(lists);
} else { } else {
@ -83,71 +87,83 @@ function makeNewList() {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem("mode_" + domain) != "misskey") {
var start = "https://" + domain + "/api/v1/lists" var start = "https://" + domain + "/api/v1/lists";
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true); httpreq.open("POST", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader('Authorization', 'Bearer ' + at); httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(JSON.stringify({ httpreq.send(
JSON.stringify({
title: text title: text
})); })
);
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
list(); list();
$("#list-add").val("") $("#list-add").val("");
}
} }
};
} else { } else {
var start = "https://" + domain + "/api/users/lists/create" var start = "https://" + domain + "/api/users/lists/create";
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true); httpreq.open("POST", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(JSON.stringify({ httpreq.send(
JSON.stringify({
i: at, i: at,
title: text title: text
})); })
);
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
list(); list();
$("#list-add").val("") $("#list-add").val("");
}
} }
};
} }
} }
function listShow(id, title, acct_id) { function listShow(id, title, acct_id) {
localStorage.setItem("list_" + id + "_" + acct_id, title); localStorage.setItem("list_" + id + "_" + acct_id, title);
tl('list', id, acct_id, 'add'); tl("list", id, acct_id, "add");
} }
function listUser(id, acct_id) { function listUser(id, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts" var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
var lists = ""; var lists = "";
var templete = userparse(json, '', acct_id); var templete = userparse(json, "", acct_id);
if (!json[0]) { if (!json[0]) {
templete = lang.lang_list_nouser; templete = lang.lang_list_nouser;
} }
@ -162,60 +178,66 @@ function hisList(user, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) != "misskey") { if (localStorage.getItem("mode_" + domain) != "misskey") {
var start = "https://" + domain + "/api/v1/lists" var start = "https://" + domain + "/api/v1/lists";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
var lists = lang.lang_list_add + "<br>"; var lists = lang.lang_list_add + "<br>";
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var list = json[key]; var list = json[key];
lists = lists + '<a onclick="listAdd(\'' + list.id + '\',\'' + user + '\',\'' + acct_id + lists = lists + "<a onclick=\"listAdd('" + list.id + "','" + user + "','" + acct_id + '\')" class="pointer">' + escapeHTML(list.title) + "</a><br> ";
'\')" class="pointer">' + escapeHTML(list.title) + '</a><br> ';
}); });
$("#his-lists-a").html(lists); $("#his-lists-a").html(lists);
} else { } else {
$("#his-lists-a").html(lang.lang_list_nodata); $("#his-lists-a").html(lang.lang_list_nodata);
} }
}); });
var start = "https://" + domain + "/api/v1/accounts/" + user + "/lists" var start = "https://" + domain + "/api/v1/accounts/" + user + "/lists";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
var lists = lang.lang_list_remove + "<br>"; var lists = lang.lang_list_remove + "<br>";
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var list = json[key]; var list = json[key];
lists = lists + '<a onclick="listRemove(\'' + list.id + '\',\'' + user + '\',\'' + acct_id + lists = lists + "<a onclick=\"listRemove('" + list.id + "','" + user + "','" + acct_id + '\')" class="pointer">' + escapeHTML(list.title) + "</a><br> ";
'\')" class="pointer">' + escapeHTML(list.title) + '</a><br> ';
}); });
$("#his-lists-b").html(lists); $("#his-lists-b").html(lists);
} else { } else {
@ -223,30 +245,32 @@ function hisList(user, acct_id) {
} }
}); });
} else { } else {
var start = "https://" + domain + "/api/users/lists/list" var start = "https://" + domain + "/api/users/lists/list";
fetch(start, { fetch(start, {
method: 'POST', method: "POST",
body: JSON.stringify({ body: JSON.stringify({
i: at i: at
}), })
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
var lists = ""; var lists = "";
Object.keys(json).forEach(function(key) { Object.keys(json).forEach(function(key) {
var list = json[key]; var list = json[key];
lists = lists + list.title + ':<a onclick="listShow(\'' + list.id + '\',\'' + escapeHTML(list.title) + '\',\'' + acct_id + lists = lists + list.title + ":<a onclick=\"listShow('" + list.id + "','" + escapeHTML(list.title) + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_show + "</a>/<a onclick=\"listAdd('" + list.id + "','" + user + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_add + lang.lang_list_add_misskey + "</a><br>";
'\')" class="pointer">' + lang.lang_list_show + '</a>/<a onclick="listAdd(\'' + list.id + '\',\'' + user + '\',\'' + acct_id +
'\')" class="pointer">' + lang.lang_list_add + lang.lang_list_add_misskey + '</a><br>';
}); });
$("#his-lists-a").html(lists); $("#his-lists-a").html(lists);
} else { } else {
@ -260,61 +284,65 @@ function listAdd(id, user, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/users/lists/push" var start = "https://" + domain + "/api/users/lists/push";
var i = { var i = {
i: at, i: at,
listId: id, listId: id,
userId: user userId: user
} };
} else { } else {
var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts" var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts";
var i = { var i = {
account_ids: [user] account_ids: [user]
} };
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open('POST', start, true); httpreq.open("POST", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader('Authorization', 'Bearer ' + at); httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(JSON.stringify(i)); httpreq.send(JSON.stringify(i));
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
hisList(user, acct_id) setLog(start, this.status, this.response);
} }
hisList(user, acct_id);
} }
};
} }
function listRemove(id, user, acct_id) { function listRemove(id, user, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") { if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/users/lists/push" var start = "https://" + domain + "/api/users/lists/push";
var method = 'POST' var method = "POST";
var i = { var i = {
i: at, i: at,
listId: id, listId: id,
userId: user userId: user
} };
} else { } else {
var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts" var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts";
var method = 'DELETE' var method = "DELETE";
var i = { var i = {
account_ids: [user] account_ids: [user]
} };
} }
var httpreq = new XMLHttpRequest(); var httpreq = new XMLHttpRequest();
httpreq.open(method, start, true); httpreq.open(method, start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader('Authorization', 'Bearer ' + at); httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json"; httpreq.responseType = "json";
httpreq.send(JSON.stringify(i)); httpreq.send(JSON.stringify(i));
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
hisList(user, acct_id) setLog(start, this.status, this.response);
} }
hisList(user, acct_id);
} }
};
} }

View File

@ -1,6 +1,6 @@
//Integrated TL //Integrated TL
function mixtl(acct_id, tlid, type, delc, voice) { function mixtl(acct_id, tlid, type, delc, voice) {
localStorage.removeItem("morelock") localStorage.removeItem("morelock");
localStorage.setItem("now", type); localStorage.setItem("now", type);
todo("Integrated TL Loading...(Local)"); todo("Integrated TL Loading...(Local)");
//まずLocal //まずLocal
@ -8,40 +8,48 @@ function mixtl(acct_id, tlid, type, delc, voice) {
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/timelines/public?local=true"; var start = "https://" + domain + "/api/v1/timelines/public?local=true";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (jsonL) { })
.then(function(jsonL) {
var start = "https://" + domain + "/api/v1/timelines/home"; var start = "https://" + domain + "/api/v1/timelines/home";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (jsonH) { })
.then(function(jsonH) {
var homearr = []; var homearr = [];
var timeline = jsonL.concat(jsonH); var timeline = jsonL.concat(jsonH);
timeline.sort(function(a, b) { timeline.sort(function(a, b) {
@ -63,15 +71,14 @@ function mixtl(acct_id, tlid, type, delc, voice) {
if (pkey < timeline.length) { if (pkey < timeline.length) {
if (date(timeline[key].created_at, "unix") != date(timeline[pkey].created_at, "unix")) { if (date(timeline[key].created_at, "unix") != date(timeline[pkey].created_at, "unix")) {
if (type == "integrated") { if (type == "integrated") {
templete = templete + parse([timeline[key]], '', acct_id, tlid, "", mute, "mix"); templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "mix");
} else if (type == "plus") { } else if (type == "plus") {
if (timeline[key].account.acct == timeline[key].account.username) { if (timeline[key].account.acct == timeline[key].account.username) {
templete = templete + parse([timeline[key]], '', acct_id, tlid, "", mute, "plus"); templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "plus");
} }
} }
} }
} }
}); });
$("#landing_" + tlid).hide(); $("#landing_" + tlid).hide();
$("#timeline_" + tlid).html(templete); $("#timeline_" + tlid).html(templete);
@ -83,34 +90,31 @@ function mixtl(acct_id, tlid, type, delc, voice) {
}); });
} }
//Streamingに接続 //Streamingに接続
function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) { function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("streaming_" + acct_id)) { if (localStorage.getItem("streaming_" + acct_id)) {
var wss = localStorage.getItem("streaming_" + acct_id) var wss = localStorage.getItem("streaming_" + acct_id);
} else { } else {
var wss = "wss://" + domain var wss = "wss://" + domain;
} }
var startHome = wss + var startHome = wss + "/api/v1/streaming/?stream=user&access_token=" + at;
"/api/v1/streaming/?stream=user&access_token=" + at; var startLocal = wss + "/api/v1/streaming/?stream=public:local&access_token=" + at;
var startLocal = wss +
"/api/v1/streaming/?stream=public:local&access_token=" + at;
var wshid = websocketHome.length; var wshid = websocketHome.length;
var wslid = websocketLocal.length; var wslid = websocketLocal.length;
websocketHome[wshid] = new WebSocket(startHome); websocketHome[wshid] = new WebSocket(startHome);
websocketLocal[wslid] = new WebSocket(startLocal); websocketLocal[wslid] = new WebSocket(startLocal);
websocketHome[wshid].onopen = function(mess) { websocketHome[wshid].onopen = function(mess) {
localStorage.setItem("wssH_" + tlid, wshid); localStorage.setItem("wssH_" + tlid, wshid);
console.table({ "tlid": tlid, "type": "Connect Streaming API(Integrated:Home)", "domain": domain, "message": mess }) console.table({ tlid: tlid, type: "Connect Streaming API(Integrated:Home)", domain: domain, message: mess });
$("#notice_icon_" + tlid).removeClass("red-text"); $("#notice_icon_" + tlid).removeClass("red-text");
} };
websocketLocal[wslid].onopen = function(mess) { websocketLocal[wslid].onopen = function(mess) {
localStorage.setItem("wssL_" + tlid, wslid); localStorage.setItem("wssL_" + tlid, wslid);
console.table({ "tlid": tlid, "type": "Connect Streaming API(Integrated:Local)", "domain": domain, "message": mess }) console.table({ tlid: tlid, type: "Connect Streaming API(Integrated:Local)", domain: domain, message: mess });
$("#notice_icon_" + tlid).removeClass("red-text"); $("#notice_icon_" + tlid).removeClass("red-text");
} };
websocketLocal[wslid].onmessage = function(mess) { websocketLocal[wslid].onmessage = function(mess) {
console.log(["Receive Streaming API:(Integrated:Local)", obj]); console.log(["Receive Streaming API:(Integrated:Local)", obj]);
@ -124,19 +128,18 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide(); $("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove(); $("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
} }
} else if (type == "update") { } else if (type == "update") {
var templete = parse([obj], '', acct_id, tlid, "", mute); var templete = parse([obj], "", acct_id, tlid, "", mute);
if ($("#timeline_" + tlid + " [toot-id=" + obj.id + "]").length < 1) { if ($("#timeline_" + tlid + " [toot-id=" + obj.id + "]").length < 1) {
if (voice) { if (voice) {
say(obj.content) say(obj.content);
} }
var templete = parse([obj], type, acct_id, tlid, "", mute, "mix"); var templete = parse([obj], type, acct_id, tlid, "", mute, "mix");
var pool = localStorage.getItem("pool_" + tlid); var pool = localStorage.getItem("pool_" + tlid);
if (pool) { if (pool) {
pool = templete + pool; pool = templete + pool;
} else { } else {
pool = templete pool = templete;
} }
localStorage.setItem("pool_" + tlid, pool); localStorage.setItem("pool_" + tlid, pool);
@ -147,18 +150,17 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
} else { } else {
todo("二重取得発生中"); todo("二重取得発生中");
} }
}
} }
};
websocketHome[wshid].onmessage = function(mess) { websocketHome[wshid].onmessage = function(mess) {
console.log(["Receive Streaming API:(Integrated:Home)", obj]); console.log(["Receive Streaming API:(Integrated:Home)", obj]);
var obj = JSON.parse(JSON.parse(mess.data).payload); var obj = JSON.parse(JSON.parse(mess.data).payload);
var type = JSON.parse(mess.data).event; var type = JSON.parse(mess.data).event;
if (type == "delete") { if (type == "delete") {
if (del > 10) { if (del > 10) {
reconnector(tlid, type, acct_id, data) reconnector(tlid, type, acct_id, data);
} else { } else {
localStorage.setItem("delete", del * 1 + 1) localStorage.setItem("delete", del * 1 + 1);
} }
if (delc == "true") { if (delc == "true") {
$("[toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized"); $("[toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized");
@ -170,24 +172,24 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
} else if (type == "update") { } else if (type == "update") {
localStorage.removeItem("delete"); localStorage.removeItem("delete");
if (TLtype == "integrated") { if (TLtype == "integrated") {
var templete = parse([obj], '', acct_id, tlid); var templete = parse([obj], "", acct_id, tlid);
} else if (TLtype == "plus") { } else if (TLtype == "plus") {
if (obj.account.acct == obj.account.username) { if (obj.account.acct == obj.account.username) {
var templete = parse([obj], '', acct_id, tlid, "", mute, "mix"); var templete = parse([obj], "", acct_id, tlid, "", mute, "mix");
} else { } else {
var templete = ""; var templete = "";
} }
} }
if ($("#timeline_" + tlid + " [toot-id=" + obj.id + "]").length < 1) { if ($("#timeline_" + tlid + " [toot-id=" + obj.id + "]").length < 1) {
if (voice) { if (voice) {
say(obj.content) say(obj.content);
} }
var templete = parse([obj], type, acct_id, tlid, "", mute, "mix"); var templete = parse([obj], type, acct_id, tlid, "", mute, "mix");
var pool = localStorage.getItem("pool_" + tlid); var pool = localStorage.getItem("pool_" + tlid);
if (pool) { if (pool) {
pool = templete + pool; pool = templete + pool;
} else { } else {
pool = templete pool = templete;
} }
localStorage.setItem("pool_" + tlid, pool); localStorage.setItem("pool_" + tlid, pool);
@ -199,13 +201,13 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
todo("二重取得発生中"); todo("二重取得発生中");
} }
} }
} };
websocketLocal[wslid].onerror = function(error) { websocketLocal[wslid].onerror = function(error) {
console.error('WebSocketLocal Error') console.error("WebSocketLocal Error");
console.error(error); console.error(error);
if (mode == "error") { if (mode == "error") {
$("#notice_icon_" + tlid).addClass("red-text"); $("#notice_icon_" + tlid).addClass("red-text");
todo('WebSocket Error ' + error); todo("WebSocket Error " + error);
} else { } else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1;
localStorage.setItem("wserror_" + tlid, errorct); localStorage.setItem("wserror_" + tlid, errorct);
@ -215,10 +217,10 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
} }
}; };
websocketLocal[wslid].onclose = function() { websocketLocal[wslid].onclose = function() {
console.warn('WebSocketLocal Closing:' + tlid); console.warn("WebSocketLocal Closing:" + tlid);
if (mode == "error") { if (mode == "error") {
$("#notice_icon_" + tlid).addClass("red-text"); $("#notice_icon_" + tlid).addClass("red-text");
todo('WebSocket Closed'); todo("WebSocket Closed");
} else { } else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1;
localStorage.setItem("wserror_" + tlid, errorct); localStorage.setItem("wserror_" + tlid, errorct);
@ -228,10 +230,10 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
} }
}; };
websocketHome[wshid].onerror = function(error) { websocketHome[wshid].onerror = function(error) {
console.error(['WebSocketHome Error', error]) console.error(["WebSocketHome Error", error]);
if (mode == "error") { if (mode == "error") {
$("#notice_icon_" + tlid).addClass("red-text"); $("#notice_icon_" + tlid).addClass("red-text");
todo('WebSocket Error ' + error); todo("WebSocket Error " + error);
} else { } else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1;
localStorage.setItem("wserror_" + tlid, errorct); localStorage.setItem("wserror_" + tlid, errorct);
@ -241,10 +243,10 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
} }
}; };
websocketHome[wshid].onclose = function() { websocketHome[wshid].onclose = function() {
console.warn('WebSocketHome Closing:' + tlid); console.warn("WebSocketHome Closing:" + tlid);
if (mode == "error") { if (mode == "error") {
$("#notice_icon_" + tlid).addClass("red-text"); $("#notice_icon_" + tlid).addClass("red-text");
todo('WebSocket Closed'); todo("WebSocket Closed");
} else { } else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1; var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1;
localStorage.setItem("wserror_" + tlid, errorct); localStorage.setItem("wserror_" + tlid, errorct);
@ -252,9 +254,7 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
reconnector(tlid, TLtype, acct_id, "", "error"); reconnector(tlid, TLtype, acct_id, "", "error");
} }
} }
}; };
} }
//ある程度のスクロールで発火 //ある程度のスクロールで発火
@ -266,45 +266,54 @@ function mixmore(tlid, type) {
todo("Integrated TL MoreLoading...(Local)"); todo("Integrated TL MoreLoading...(Local)");
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var sid = $("#timeline_" + tlid + " .cvo").last().attr("unique-id"); var sid = $("#timeline_" + tlid + " .cvo")
.last()
.attr("unique-id");
var start = "https://" + domain + "/api/v1/timelines/public?local=true&max_id=" + sid; var start = "https://" + domain + "/api/v1/timelines/public?local=true&max_id=" + sid;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (jsonL) { })
.then(function(jsonL) {
var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid; var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (jsonH) { })
.then(function(jsonH) {
var homearr = []; var homearr = [];
var timeline = jsonL.concat(jsonH); var timeline = jsonL.concat(jsonH);
timeline.sort(function(a, b) { timeline.sort(function(a, b) {
@ -324,15 +333,14 @@ function mixmore(tlid, type) {
var mute = []; var mute = [];
} }
if (type == "integrated") { if (type == "integrated") {
templete = templete + parse([timeline[key]], '', acct_id, tlid, "", mute, "mix"); templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "mix");
} else if (type == "plus") { } else if (type == "plus") {
if (timeline[key].account.acct == timeline[key].account.username) { if (timeline[key].account.acct == timeline[key].account.username) {
templete = templete + parse([timeline[key]], '', acct_id, tlid, "", mute, "mix"); templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "mix");
} }
} }
} }
} }
}); });
$("#timeline_" + tlid).append(templete); $("#timeline_" + tlid).append(templete);
@ -342,6 +350,4 @@ function mixmore(tlid, type) {
todc(); todc();
}); });
}); });
} }

View File

@ -2,9 +2,9 @@
//取得+Streaming接続 //取得+Streaming接続
function notf(acct_id, tlid, sys) { function notf(acct_id, tlid, sys) {
if (sys == "direct") { if (sys == "direct") {
notfColumn(acct_id, tlid, sys) notfColumn(acct_id, tlid, sys);
} else { } else {
notfCommon(acct_id, tlid, sys) notfCommon(acct_id, tlid, sys);
} }
} }
function notfColumn(acct_id, tlid, sys) { function notfColumn(acct_id, tlid, sys) {
@ -20,7 +20,7 @@ function notfColumn(acct_id, tlid, sys) {
var misskey = true; var misskey = true;
var start = "https://" + domain + "/api/i/notifications"; var start = "https://" + domain + "/api/i/notifications";
httpreq.open("POST", start, true); httpreq.open("POST", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
var body = JSON.stringify({ var body = JSON.stringify({
i: at i: at
}); });
@ -33,8 +33,8 @@ function notfColumn(acct_id, tlid, sys) {
} }
var start = "https://" + domain + "/api/v1/notifications" + exc; var start = "https://" + domain + "/api/v1/notifications" + exc;
httpreq.open("GET", start, true); httpreq.open("GET", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader('Authorization', 'Bearer ' + at); httpreq.setRequestHeader("Authorization", "Bearer " + at);
var body = ""; var body = "";
} }
@ -43,10 +43,12 @@ function notfColumn(acct_id, tlid, sys) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
var max_id = httpreq.getResponseHeader("link"); var max_id = httpreq.getResponseHeader("link");
if (max_id) { if (max_id) {
max_id = max_id.match(/[?&]{1}max_id=([0-9]+)/)[1] max_id = max_id.match(/[?&]{1}max_id=([0-9]+)/)[1];
} }
if (json[0]) { if (json[0]) {
var templete = ""; var templete = "";
@ -64,8 +66,7 @@ function notfColumn(acct_id, tlid, sys) {
body: ct + lang.lang_notf_new, body: ct + lang.lang_notf_new,
icon: localStorage.getItem("prof_" + acct_id) icon: localStorage.getItem("prof_" + acct_id)
}; };
var n = new Notification('TheDesk:' + domain, options); var n = new Notification("TheDesk:" + domain, options);
} }
if (localStorage.getItem("filter_" + acct_id) != "undefined") { if (localStorage.getItem("filter_" + acct_id) != "undefined") {
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "notif"); var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "notif");
@ -74,17 +75,16 @@ function notfColumn(acct_id, tlid, sys) {
} }
if (obj.type != "follow") { if (obj.type != "follow") {
if (misskey) { if (misskey) {
templete = templete + misskeyParse([obj], 'notf', acct_id, tlid, -1, mute); templete = templete + misskeyParse([obj], "notf", acct_id, tlid, -1, mute);
} else { } else {
templete = templete + parse([obj], 'notf', acct_id, tlid, -1, mute); templete = templete + parse([obj], "notf", acct_id, tlid, -1, mute);
} }
} else { } else {
if (misskey) { if (misskey) {
templete = templete + misskeyUserparse([obj], 'notf', acct_id, tlid, -1, mute); templete = templete + misskeyUserparse([obj], "notf", acct_id, tlid, -1, mute);
} else { } else {
templete = templete + userparse([obj.account], 'notf', acct_id, tlid, -1); templete = templete + userparse([obj.account], "notf", acct_id, tlid, -1);
} }
} }
}); });
templete = templete + '<div class="hide notif-marker" data-maxid="' + max_id + '"></div>'; templete = templete + '<div class="hide notif-marker" data-maxid="' + max_id + '"></div>';
@ -99,26 +99,23 @@ function notfColumn(acct_id, tlid, sys) {
if (markers == "yes") { if (markers == "yes") {
markers = true; markers = true;
} else { } else {
markers = false markers = false;
} }
if (markers) { if (markers) {
getMarker(tlid, "notf", acct_id) getMarker(tlid, "notf", acct_id);
}
} }
} }
};
if (!misskey) { if (!misskey) {
if (localStorage.getItem("streaming_" + acct_id)) { if (localStorage.getItem("streaming_" + acct_id)) {
var wss = localStorage.getItem("streaming_" + acct_id) var wss = localStorage.getItem("streaming_" + acct_id);
} else { } else {
var wss = "wss://" + domain var wss = "wss://" + domain;
} }
var start = wss + "/api/v1/streaming/?stream=user&access_token=" + var start = wss + "/api/v1/streaming/?stream=user&access_token=" + at;
at;
} else { } else {
var start = "wss://" + domain + "/?i=" + var start = "wss://" + domain + "/?i=" + at;
at;
} }
} }
function notfCommon(acct_id, tlid, sys) { function notfCommon(acct_id, tlid, sys) {
todo("Notifications Loading..."); todo("Notifications Loading...");
@ -132,37 +129,41 @@ function notfCommon(acct_id, tlid, sys) {
var misskey = true; var misskey = true;
var start = "https://" + domain + "/api/i/notifications"; var start = "https://" + domain + "/api/i/notifications";
var i = { var i = {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json"
}, },
body: JSON.stringify({ body: JSON.stringify({
i: at i: at
}) })
} };
} else { } else {
var misskey = false; var misskey = false;
var start = "https://" + domain + "/api/v1/notifications"; var start = "https://" + domain + "/api/v1/notifications";
var i = { var i = {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
},
} }
};
} }
fetch(start, i).then(function (response) { fetch(start, i)
console.log("header to get param:" + response.headers.get('link')); .then(function(response) {
console.log("header to get param:" + response.headers.get("link"));
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json[0]) { if (json[0]) {
var templete = ""; var templete = "";
var lastnotf = localStorage.getItem("lastnotf_" + acct_id); var lastnotf = localStorage.getItem("lastnotf_" + acct_id);
@ -179,8 +180,7 @@ function notfCommon(acct_id, tlid, sys) {
body: ct + lang.lang_notf_new, body: ct + lang.lang_notf_new,
icon: localStorage.getItem("prof_" + acct_id) icon: localStorage.getItem("prof_" + acct_id)
}; };
var n = new Notification('TheDesk:' + domain, options); var n = new Notification("TheDesk:" + domain, options);
} }
if (localStorage.getItem("filter_" + acct_id) != "undefined") { if (localStorage.getItem("filter_" + acct_id) != "undefined") {
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "notif"); var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "notif");
@ -189,17 +189,16 @@ function notfCommon(acct_id, tlid, sys) {
} }
if (obj.type != "follow") { if (obj.type != "follow") {
if (misskey) { if (misskey) {
templete = templete + misskeyParse([obj], 'notf', acct_id, 'notf', -1, mute); templete = templete + misskeyParse([obj], "notf", acct_id, "notf", -1, mute);
} else { } else {
templete = templete + parse([obj], 'notf', acct_id, 'notf', -1, mute); templete = templete + parse([obj], "notf", acct_id, "notf", -1, mute);
} }
} else { } else {
if (misskey) { if (misskey) {
templete = templete + misskeyUserparse([obj], 'notf', acct_id, 'notf', -1, mute); templete = templete + misskeyUserparse([obj], "notf", acct_id, "notf", -1, mute);
} else { } else {
templete = templete + userparse([obj.account], 'notf', acct_id, 'notf', -1); templete = templete + userparse([obj.account], "notf", acct_id, "notf", -1);
} }
} }
}); });
$("div[data-notf=" + acct_id + "]").html(templete); $("div[data-notf=" + acct_id + "]").html(templete);
@ -208,27 +207,24 @@ function notfCommon(acct_id, tlid, sys) {
} }
$("#notf-box").addClass("fetched"); $("#notf-box").addClass("fetched");
todc(); todc();
notfWS(misskey, acct_id, tlid, domain, at) notfWS(misskey, acct_id, tlid, domain, at);
}); });
} }
function notfWS(misskey, acct_id, tlid, domain, at) { function notfWS(misskey, acct_id, tlid, domain, at) {
if (!misskey) { if (!misskey) {
if (localStorage.getItem("streaming_" + acct_id)) { if (localStorage.getItem("streaming_" + acct_id)) {
var wss = localStorage.getItem("streaming_" + acct_id) var wss = localStorage.getItem("streaming_" + acct_id);
} else { } else {
var wss = "wss://" + domain var wss = "wss://" + domain;
} }
var start = wss + "/api/v1/streaming/?stream=user&access_token=" + var start = wss + "/api/v1/streaming/?stream=user&access_token=" + at;
at;
var wsid = websocketNotf.length; var wsid = websocketNotf.length;
websocketNotf[acct_id] = new WebSocket(start); websocketNotf[acct_id] = new WebSocket(start);
websocketNotf[acct_id].onopen = function(mess) { websocketNotf[acct_id].onopen = function(mess) {
console.table({ "acct_id": acct_id, "type": "Connect Streaming API(Notf)", "domain": domain, "message": [mess] }) console.table({ acct_id: acct_id, type: "Connect Streaming API(Notf)", domain: domain, message: [mess] });
$("i[data-notf=" + acct_id + "]").removeClass("red-text"); $("i[data-notf=" + acct_id + "]").removeClass("red-text");
};
}
websocketNotf[acct_id].onmessage = function(mess) { websocketNotf[acct_id].onmessage = function(mess) {
//console.log(["Receive Streaming API(Notf):" + acct_id + "(" + domain + ")", JSON.parse(JSON.parse(mess.data).payload)]); //console.log(["Receive Streaming API(Notf):" + acct_id + "(" + domain + ")", JSON.parse(JSON.parse(mess.data).payload)]);
var popup = localStorage.getItem("popup"); var popup = localStorage.getItem("popup");
@ -243,9 +239,9 @@ function notfWS(misskey, acct_id, tlid, domain, at) {
if (!$("#unread_" + tlid + " .material-icons").hasClass("teal-text")) { if (!$("#unread_" + tlid + " .material-icons").hasClass("teal-text")) {
//markers show中はダメ //markers show中はダメ
if (obj.type != "follow") { if (obj.type != "follow") {
templete = parse([obj], 'notf', acct_id, 'notf', popup); templete = parse([obj], "notf", acct_id, "notf", popup);
} else { } else {
templete = userparse([obj], 'notf', acct_id, 'notf', popup); templete = userparse([obj], "notf", acct_id, "notf", popup);
} }
if (!$("div[data-notfIndv=" + acct_id + "_" + obj.id + "]").length) { if (!$("div[data-notfIndv=" + acct_id + "_" + obj.id + "]").length) {
$("div[data-notf=" + acct_id + "]").prepend(templete); $("div[data-notf=" + acct_id + "]").prepend(templete);
@ -257,30 +253,28 @@ function notfWS(misskey, acct_id, tlid, domain, at) {
$("[toot-id=" + obj + "]").hide(); $("[toot-id=" + obj + "]").hide();
$("[toot-id=" + obj + "]").remove(); $("[toot-id=" + obj + "]").remove();
} }
} };
websocketNotf[acct_id].onerror = function(error) { websocketNotf[acct_id].onerror = function(error) {
console.error('WebSocket Error ' + error); console.error("WebSocket Error " + error);
errorct++; errorct++;
console.log(errorct) console.log(errorct);
if (errorct < 3) { if (errorct < 3) {
notfWS(misskey, acct_id, tlid, domain, at) notfWS(misskey, acct_id, tlid, domain, at);
} }
}; };
websocketNotf[acct_id].onclose = function(error) { websocketNotf[acct_id].onclose = function(error) {
console.error('WebSocket Close ' + error); console.error("WebSocket Close " + error);
errorct++; errorct++;
console.log(errorct) console.log(errorct);
if (errorct < 3) { if (errorct < 3) {
notfWS(misskey, acct_id, tlid, domain, at) notfWS(misskey, acct_id, tlid, domain, at);
} }
}; };
} }
} }
//一定のスクロールで発火 //一定のスクロールで発火
function notfmore(tlid) { function notfmore(tlid) {
console.log({ "status": "kicked", "status": moreloading }); console.log({ status: "kicked", status: moreloading });
var multi = localStorage.getItem("column"); var multi = localStorage.getItem("column");
var obj = JSON.parse(multi); var obj = JSON.parse(multi);
var acct_id = obj[tlid].domain; var acct_id = obj[tlid].domain;
@ -289,7 +283,9 @@ function notfmore(tlid) {
} else { } else {
var data; var data;
} }
var sid = $("#timeline_" + tlid + " .notif-marker").last().attr("data-maxid"); var sid = $("#timeline_" + tlid + " .notif-marker")
.last()
.attr("data-maxid");
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
if (sid && !moreloading) { if (sid && !moreloading) {
@ -299,7 +295,7 @@ function notfmore(tlid) {
var misskey = true; var misskey = true;
var start = "https://" + domain + "/api/i/notifications"; var start = "https://" + domain + "/api/i/notifications";
httpreq.open(POST, start, true); httpreq.open(POST, start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
var body = JSON.stringify({ var body = JSON.stringify({
i: at, i: at,
untilID: sid untilID: sid
@ -313,8 +309,8 @@ function notfmore(tlid) {
} }
var start = "https://" + domain + "/api/v1/notifications" + exc; var start = "https://" + domain + "/api/v1/notifications" + exc;
httpreq.open("GET", start, true); httpreq.open("GET", start, true);
httpreq.setRequestHeader('Content-Type', 'application/json'); httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.setRequestHeader('Authorization', 'Bearer ' + at); httpreq.setRequestHeader("Authorization", "Bearer " + at);
var body = ""; var body = "";
} }
@ -323,7 +319,9 @@ function notfmore(tlid) {
httpreq.onreadystatechange = function() { httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) { if (httpreq.readyState === 4) {
var json = httpreq.response; var json = httpreq.response;
if(this.status!==200){ setLog(start, this.status, this.response); } if (this.status !== 200) {
setLog(start, this.status, this.response);
}
console.log(["More notifications on " + tlid, json]); console.log(["More notifications on " + tlid, json]);
var max_id = httpreq.getResponseHeader("link").match(/[?&]{1}max_id=([0-9]+)/)[1]; var max_id = httpreq.getResponseHeader("link").match(/[?&]{1}max_id=([0-9]+)/)[1];
if (json[0]) { if (json[0]) {
@ -339,17 +337,16 @@ function notfmore(tlid) {
} }
if (obj.type != "follow") { if (obj.type != "follow") {
if (misskey) { if (misskey) {
templete = templete + misskeyParse([obj], 'notf', acct_id, 'notf', -1, mute); templete = templete + misskeyParse([obj], "notf", acct_id, "notf", -1, mute);
} else { } else {
templete = templete + parse([obj], 'notf', acct_id, 'notf', -1, mute); templete = templete + parse([obj], "notf", acct_id, "notf", -1, mute);
} }
} else { } else {
if (misskey) { if (misskey) {
templete = templete + misskeyUserparse([obj], 'notf', acct_id, 'notf', -1, mute); templete = templete + misskeyUserparse([obj], "notf", acct_id, "notf", -1, mute);
} else { } else {
templete = templete + userparse([obj.account], 'notf', acct_id, 'notf', -1); templete = templete + userparse([obj.account], "notf", acct_id, "notf", -1);
} }
} }
}); });
moreloading = false; moreloading = false;
@ -361,49 +358,55 @@ function notfmore(tlid) {
$("#notf-box").addClass("fetched"); $("#notf-box").addClass("fetched");
todc(); todc();
} }
} };
} }
} }
//通知トグルボタン //通知トグルボタン
function notfToggle(acct, tlid) { function notfToggle(acct, tlid) {
if ($("#notf-box_" + tlid).hasClass("column-hide")) { if ($("#notf-box_" + tlid).hasClass("column-hide")) {
$("#notf-box_" + tlid).css("display", "block") $("#notf-box_" + tlid).css("display", "block");
$("#notf-box_" + tlid).animate({ $("#notf-box_" + tlid).animate(
'height': '400px' {
}, { height: "400px"
'duration': 300, },
'complete': function () { {
$("#notf-box_" + tlid).css("overflow-y", "scroll") duration: 300,
$("#notf-box_" + tlid).removeClass("column-hide") complete: function() {
$("#notf-box_" + tlid).css("overflow-y", "scroll");
$("#notf-box_" + tlid).removeClass("column-hide");
} }
}); }
);
} else { } else {
$("#notf-box_" + tlid).css("overflow-y", "hidden") $("#notf-box_" + tlid).css("overflow-y", "hidden");
$("#notf-box_" + tlid).animate({ $("#notf-box_" + tlid).animate(
'height': '0' {
}, { height: "0"
'duration': 300, },
'complete': function () { {
$("#notf-box_" + tlid).addClass("column-hide") duration: 300,
$("#notf-box_" + tlid).css("display", "none") complete: function() {
$("#notf-box_" + tlid).addClass("column-hide");
$("#notf-box_" + tlid).css("display", "none");
} }
});
} }
notfCanceler(acct) );
}
notfCanceler(acct);
} }
function notfCanceler(acct) { function notfCanceler(acct) {
$(".notf-reply_" + acct).text(0); $(".notf-reply_" + acct).text(0);
localStorage.removeItem("notf-reply_" + acct) localStorage.removeItem("notf-reply_" + acct);
$(".notf-reply_" + acct).addClass("hide"); $(".notf-reply_" + acct).addClass("hide");
$(".notf-fav_" + acct).text(0); $(".notf-fav_" + acct).text(0);
localStorage.removeItem("notf-fav_" + acct) localStorage.removeItem("notf-fav_" + acct);
$(".notf-fav_" + acct).addClass("hide"); $(".notf-fav_" + acct).addClass("hide");
$(".notf-bt_" + acct).text(0); $(".notf-bt_" + acct).text(0);
localStorage.removeItem("notf-bt_" + acct) localStorage.removeItem("notf-bt_" + acct);
$(".notf-bt_" + acct).addClass("hide"); $(".notf-bt_" + acct).addClass("hide");
$(".notf-follow_" + acct).text(0); $(".notf-follow_" + acct).text(0);
localStorage.removeItem("notf-follow_" + acct) localStorage.removeItem("notf-follow_" + acct);
$(".notf-follow_" + acct).addClass("hide"); $(".notf-follow_" + acct).addClass("hide");
$(".notf-icon_" + acct).removeClass("red-text"); $(".notf-icon_" + acct).removeClass("red-text");
} }
@ -412,8 +415,8 @@ function allNotfRead() {
if (multi) { if (multi) {
var obj = JSON.parse(multi); var obj = JSON.parse(multi);
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function(key) {
notfCanceler(key) notfCanceler(key);
}); });
} }
} }
allNotfRead() allNotfRead();

View File

@ -1,7 +1,7 @@
//Integrated TL //Integrated TL
function mixtl(acct_id, tlid) { function mixtl(acct_id, tlid) {
var type = "mix"; var type = "mix";
localStorage.removeItem("morelock") localStorage.removeItem("morelock");
localStorage.setItem("now", type); localStorage.setItem("now", type);
todo("Integrated TL Loading...(Local)"); todo("Integrated TL Loading...(Local)");
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
@ -9,24 +9,28 @@ function mixtl(acct_id, tlid) {
//まずLocal //まずLocal
var start = "https://" + domain + "/api/v1/timelines/public?local=true"; var start = "https://" + domain + "/api/v1/timelines/public?local=true";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function(response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function(error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function(json) { })
.then(function(json) {
//パースして描画 //パースして描画
var templete = parse(json, 'mix', acct_id, tlid); var templete = parse(json, "mix", acct_id, tlid);
$("#timeline_" + tlid).html(templete[0]); $("#timeline_" + tlid).html(templete[0]);
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
@ -37,26 +41,31 @@ function mixtl(acct_id, tlid) {
//Home //Home
var start = "https://" + domain + "/api/v1/timelines/home"; var start = "https://" + domain + "/api/v1/timelines/home";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function(response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function(error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function(obj) { })
.then(function(obj) {
//ホームのオブジェクトをUnix時間で走査 //ホームのオブジェクトをUnix時間で走査
if (!$("[toot-id=" + obj[0].id + "]").length) { if (!$("[toot-id=" + obj[0].id + "]").length) {
$("#timeline_" + tlid + " .cvo").first().before(parse([obj[0]], 'home', $("#timeline_" + tlid + " .cvo")
acct_id)); .first()
.before(parse([obj[0]], "home", acct_id));
//delete obj[0]; //delete obj[0];
} }
//Localが遅すぎてHomeの全てより過去の場合 //Localが遅すぎてHomeの全てより過去の場合
@ -71,7 +80,7 @@ function mixtl(acct_id, tlid) {
var id = toot.id; var id = toot.id;
if ($("#timeline_" + tlid + " [toot-id=" + toot.id + "]").length < 1) { if ($("#timeline_" + tlid + " [toot-id=" + toot.id + "]").length < 1) {
//console.log(toot.id); //console.log(toot.id);
var tarunix = date(toot.created_at, 'unix'); var tarunix = date(toot.created_at, "unix");
var beforekey2; var beforekey2;
var key2; var key2;
//console.log(locals) //console.log(locals)
@ -80,19 +89,16 @@ function mixtl(acct_id, tlid) {
if (times[key2] < tarunix) { if (times[key2] < tarunix) {
var local = json[key2].id; var local = json[key2].id;
//console.log($.strip_tags(toot.content)); //console.log($.strip_tags(toot.content));
html = parse( html = parse([toot], "home", acct_id, tlid);
[toot], 'home', acct_id, tlid);
$("#timeline_" + tlid + " [toot-id=" + local + "]").before(html); $("#timeline_" + tlid + " [toot-id=" + local + "]").before(html);
//console.log("#timeline_" + tlid + " [toot-id=" + local + "]"); //console.log("#timeline_" + tlid + " [toot-id=" + local + "]");
tarunix = 0; tarunix = 0;
} }
}); });
} }
}); });
} else { } else {
html = parse( html = parse(obj, "home", acct_id, tlid);
obj, 'home', acct_id, tlid);
$("#timeline_" + tlid).html(html); $("#timeline_" + tlid).html(html);
} }
todc(); todc();
@ -109,11 +115,9 @@ function mixre(acct_id, tlid) {
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var type = "mix"; var type = "mix";
localStorage.setItem("now", type); localStorage.setItem("now", type);
var startHome = "wss://" + domain + var startHome = "wss://" + domain + "/api/v1/streaming/?stream=user&access_token=" + at;
"/api/v1/streaming/?stream=user&access_token=" + at;
var startLocal = "wss://" + domain + var startLocal = "wss://" + domain + "/api/v1/streaming/?stream=public:local&access_token=" + at;
"/api/v1/streaming/?stream=public:local&access_token=" + at;
var wshid = websocketHome.length; var wshid = websocketHome.length;
var wslid = websocketLocal.length; var wslid = websocketLocal.length;
websocketHome[wshid] = new WebSocket(startHome); websocketHome[wshid] = new WebSocket(startHome);
@ -121,11 +125,11 @@ function mixre(acct_id, tlid) {
websocketHome[wshid].onopen = function(mess) { websocketHome[wshid].onopen = function(mess) {
console.log("Connect Streaming API(Home)"); console.log("Connect Streaming API(Home)");
$("#notice_icon_" + tlid).removeClass("red-text"); $("#notice_icon_" + tlid).removeClass("red-text");
} };
websocketLocal[wslid].onopen = function(mess) { websocketLocal[wslid].onopen = function(mess) {
console.log("Connect Streaming API(Local)"); console.log("Connect Streaming API(Local)");
$("#notice_icon_" + tlid).removeClass("red-text"); $("#notice_icon_" + tlid).removeClass("red-text");
} };
websocketLocal[wslid].onmessage = function(mess) { websocketLocal[wslid].onmessage = function(mess) {
console.log("Receive Streaming API:"); console.log("Receive Streaming API:");
@ -136,12 +140,12 @@ function mixre(acct_id, tlid) {
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide(); $("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove(); $("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
} else if (type == "update") { } else if (type == "update") {
var templete = parse([obj], '', acct_id, tlid); var templete = parse([obj], "", acct_id, tlid);
var pool = localStorage.getItem("pool_" + tlid); var pool = localStorage.getItem("pool_" + tlid);
if (pool) { if (pool) {
pool = templete + pool; pool = templete + pool;
} else { } else {
pool = templete pool = templete;
} }
localStorage.setItem("pool_" + tlid, pool); localStorage.setItem("pool_" + tlid, pool);
scrollck(); scrollck();
@ -149,7 +153,7 @@ function mixre(acct_id, tlid) {
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
todc(); todc();
} }
} };
websocketHome[wshid].onmessage = function(mess) { websocketHome[wshid].onmessage = function(mess) {
console.log("Receive Streaming API:(Home)"); console.log("Receive Streaming API:(Home)");
@ -160,13 +164,13 @@ function mixre(acct_id, tlid) {
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide(); $("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove(); $("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
} else if (type == "update") { } else if (type == "update") {
var templete = parse([obj], '', acct_id, tlid); var templete = parse([obj], "", acct_id, tlid);
if (obj.visibility != "public" || obj.account.acct != obj.account.username) { if (obj.visibility != "public" || obj.account.acct != obj.account.username) {
var pool = localStorage.getItem("pool_" + tlid); var pool = localStorage.getItem("pool_" + tlid);
if (pool) { if (pool) {
pool = templete + pool; pool = templete + pool;
} else { } else {
pool = templete pool = templete;
} }
localStorage.setItem("pool_" + tlid, pool); localStorage.setItem("pool_" + tlid, pool);
scrollck(); scrollck();
@ -174,12 +178,12 @@ function mixre(acct_id, tlid) {
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
} }
} }
} };
websocketLocal[wslid].onerror = function(error) { websocketLocal[wslid].onerror = function(error) {
console.error('WebSocket Error ' + error); console.error("WebSocket Error " + error);
}; };
websocketHome[wshid].onerror = function(error) { websocketHome[wshid].onerror = function(error) {
console.error('WebSocket Error ' + error); console.error("WebSocket Error " + error);
}; };
} }
@ -191,72 +195,80 @@ function mixmore(tlid) {
todo("Integrated TL MoreLoading...(Local)"); todo("Integrated TL MoreLoading...(Local)");
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var sid = $("#timeline_" + tlid + " .cvo").last().attr("toot-id"); var sid = $("#timeline_" + tlid + " .cvo")
var len = $("#timeline_" + tlid + " .cvo").length .last()
var start = "https://" + domain + .attr("toot-id");
"/api/v1/timelines/public?local=true&max_id=" + sid; var len = $("#timeline_" + tlid + " .cvo").length;
var start = "https://" + domain + "/api/v1/timelines/public?local=true&max_id=" + sid;
console.log(start); console.log(start);
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function(response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function(error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function(json) { })
var templete = parse(json, 'mix', acct_id, tlid); .then(function(json) {
var templete = parse(json, "mix", acct_id, tlid);
$("#timeline_" + tlid).append(templete[0]); $("#timeline_" + tlid).append(templete[0]);
var locals = templete[1]; var locals = templete[1];
todo("Integrated TL MoreLoading...(Home)"); todo("Integrated TL MoreLoading...(Home)");
console.log(sid); console.log(sid);
var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid; var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid;
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function(response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function(error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function(obj) { })
.then(function(obj) {
if ($("[toot-id=" + obj[0].id + "]").length < 1) { if ($("[toot-id=" + obj[0].id + "]").length < 1) {
$("#timeline_" + tlid + " .cvo").eq(len).before(parse([obj[0]], 'home', $("#timeline_" + tlid + " .cvo")
acct_id)+'<div class="divider"></div>'); .eq(len)
.before(parse([obj[0]], "home", acct_id) + '<div class="divider"></div>');
//delete obj[0]; //delete obj[0];
} }
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function(key) {
var skey = obj.length - key - 1; var skey = obj.length - key - 1;
var toot = obj[skey]; var toot = obj[skey];
var id = toot.id; var id = toot.id;
var tarunix = date(toot.created_at, 'unix'); var tarunix = date(toot.created_at, "unix");
var beforekey2; var beforekey2;
var key2; var key2;
Object.keys(locals).forEach(function(key2) { Object.keys(locals).forEach(function(key2) {
if ($("[toot-id=" + toot.id + "]").length < 1) { if ($("[toot-id=" + toot.id + "]").length < 1) {
if (key2 > tarunix) { if (key2 > tarunix) {
var local = locals[key2]; var local = locals[key2];
$("#timeline_" + tlid + " [toot-id=" + local + "]").after(parse([toot], 'home', $("#timeline_" + tlid + " [toot-id=" + local + "]").after(parse([toot], "home", acct_id, tlid));
acct_id, tlid));
tarunix = 2147483647; tarunix = 2147483647;
} }
} }
}); });
}); });
@ -265,5 +277,4 @@ function mixmore(tlid) {
todc(); todc();
}); });
}); });
} }

View File

@ -14,48 +14,53 @@ function searchMenu() {
function src(mode, offset) { function src(mode, offset) {
if (!offset) { if (!offset) {
$("#src-contents").html(""); $("#src-contents").html("");
var add = "" var add = "";
} else { } else {
var add = "&type=accounts&offset=" + $("#src-accts .cvo").length var add = "&type=accounts&offset=" + $("#src-accts .cvo").length;
} }
var q = $("#src").val(); var q = $("#src").val();
var acct_id = $("#src-acct-sel").val(); var acct_id = $("#src-acct-sel").val();
if (acct_id == "tootsearch") { if (acct_id == "tootsearch") {
tsAdd(q) tsAdd(q);
return false; return false;
} }
localStorage.setItem("last-use", acct_id); localStorage.setItem("last-use", acct_id);
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var m = q.match(/^#(.+)$/); var m = q.match(/^#(.+)$/);
if (m) { q = m[1]; } if (m) {
q = m[1];
}
if (user == "--now") { if (user == "--now") {
var user = $('#his-data').attr("user-id"); var user = $("#his-data").attr("user-id");
} }
if (!mode) { if (!mode) {
var start = "https://" + domain + "/api/v2/search?q=" + q + add var start = "https://" + domain + "/api/v2/search?q=" + q + add;
} else { } else {
var start = "https://" + domain + "/api/v1/search?q=" + q var start = "https://" + domain + "/api/v1/search?q=" + q;
} }
console.log("Try to search at " + start) console.log("Try to search at " + start);
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
src("v1") .catch(function(error) {
src("v1");
return false; return false;
}).then(function (json) { })
.then(function(json) {
console.log(["Search", json]); console.log(["Search", json]);
//ハッシュタグ //ハッシュタグ
if (json.hashtags[0]) { if (json.hashtags[0]) {
@ -63,29 +68,26 @@ function src(mode, offset) {
Object.keys(json.hashtags).forEach(function(key4) { Object.keys(json.hashtags).forEach(function(key4) {
var tag = json.hashtags[key4]; var tag = json.hashtags[key4];
if (mode) { if (mode) {
tags = tags + '<a onclick="tl(\'tag\',\'' + tag + '\',\'' + acct_id + tags = tags + "<a onclick=\"tl('tag','" + tag + "','" + acct_id + "','add')\" class=\"pointer\">#" + escapeHTML(tag) + "</a><br> ";
'\',\'add\')" class="pointer">#' + escapeHTML(tag) + '</a><br> ';
} else { } else {
tags = tags + graphDraw(tag, acct_id); tags = tags + graphDraw(tag, acct_id);
} }
}); });
$("#src-contents").append("Tags<br>" + tags); $("#src-contents").append("Tags<br>" + tags);
} }
//トゥート //トゥート
if (json.statuses[0]) { if (json.statuses[0]) {
var templete = parse(json.statuses, '', acct_id); var templete = parse(json.statuses, "", acct_id);
$("#src-contents").append("<br>Mentions<br>" + templete); $("#src-contents").append("<br>Mentions<br>" + templete);
} }
//アカウント //アカウント
if (json.accounts[0]) { if (json.accounts[0]) {
var templete = userparse(json.accounts, '', acct_id); var templete = userparse(json.accounts, "", acct_id);
if (!offset) { if (!offset) {
$("#src-contents").append("<br>Accounts<div id=\"src-accts\">" + templete + '</div><a onclick="src(false,\'more\')" class="pointer">more...</a>'); $("#src-contents").append('<br>Accounts<div id="src-accts">' + templete + '</div><a onclick="src(false,\'more\')" class="pointer">more...</a>');
} else { } else {
$("#src-accts").append(templete) $("#src-accts").append(templete);
} }
} }
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
}); });
@ -102,29 +104,33 @@ function tsAdd(q) {
obj.push(add); obj.push(add);
var json = JSON.stringify(obj); var json = JSON.stringify(obj);
localStorage.setItem("column", json); localStorage.setItem("column", json);
parseColumn('add'); parseColumn("add");
} }
function tootsearch(tlid, q) { function tootsearch(tlid, q) {
var start = "https://tootsearch.chotto.moe/api/v1/search?from=0&sort=created_at%3Adesc&q=" + q var start = "https://tootsearch.chotto.moe/api/v1/search?from=0&sort=created_at%3Adesc&q=" + q;
console.log("Toot srrach at " + start) console.log("Toot srrach at " + start);
$("#notice_" + tlid).text("tootsearch(" + q + ")"); $("#notice_" + tlid).text("tootsearch(" + q + ")");
$("#notice_icon_" + tlid).text("search"); $("#notice_icon_" + tlid).text("search");
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (raw) { })
.then(function(raw) {
var templete = ""; var templete = "";
var json = raw.hits.hits; var json = raw.hits.hits;
var max_id = raw["hits"].length; var max_id = raw["hits"].length;
@ -132,7 +138,7 @@ function tootsearch(tlid, q) {
var toot = json[i]["_source"]; var toot = json[i]["_source"];
if (lastid != toot.uri) { if (lastid != toot.uri) {
if (toot && toot.account) { if (toot && toot.account) {
templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch") templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch");
} }
} }
var lastid = toot.uri; var lastid = toot.uri;
@ -148,27 +154,33 @@ function tootsearch(tlid, q) {
}); });
} }
function moreTs(tlid, q) { function moreTs(tlid, q) {
var sid = $("#timeline_" + tlid + " .ts-marker").last().attr("data-maxid"); var sid = $("#timeline_" + tlid + " .ts-marker")
.last()
.attr("data-maxid");
moreloading = true; moreloading = true;
var start = "https://tootsearch.chotto.moe/api/v1/search?from=" + sid + "&sort=created_at%3Adesc&q=" + q var start = "https://tootsearch.chotto.moe/api/v1/search?from=" + sid + "&sort=created_at%3Adesc&q=" + q;
$("#notice_" + tlid).text("tootsearch(" + q + ")"); $("#notice_" + tlid).text("tootsearch(" + q + ")");
$("#notice_icon_" + tlid).text("search"); $("#notice_icon_" + tlid).text("search");
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (raw) { })
.then(function(raw) {
var templete = ""; var templete = "";
var json = raw.hits.hits; var json = raw.hits.hits;
var max_id = raw["hits"].length; var max_id = raw["hits"].length;
@ -176,7 +188,7 @@ function moreTs(tlid, q) {
var toot = json[i]["_source"]; var toot = json[i]["_source"];
if (lastid != toot.uri) { if (lastid != toot.uri) {
if (toot && toot.account) { if (toot && toot.account) {
templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch") templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch");
} }
} }
var lastid = toot.uri; var lastid = toot.uri;
@ -195,22 +207,17 @@ function graphDraw(tag, acct_id) {
var tags = ""; var tags = "";
var his = tag.history; var his = tag.history;
var max = Math.max.apply(null, [his[0].uses, his[1].uses, his[2].uses, his[3].uses, his[4].uses, his[5].uses, his[6].uses]); var max = Math.max.apply(null, [his[0].uses, his[1].uses, his[2].uses, his[3].uses, his[4].uses, his[5].uses, his[6].uses]);
var six = 50 - (his[6].uses / max * 50); var six = 50 - (his[6].uses / max) * 50;
var five = 50 - (his[5].uses / max * 50); var five = 50 - (his[5].uses / max) * 50;
var four = 50 - (his[4].uses / max * 50); var four = 50 - (his[4].uses / max) * 50;
var three = 50 - (his[3].uses / max * 50); var three = 50 - (his[3].uses / max) * 50;
var two = 50 - (his[2].uses / max * 50); var two = 50 - (his[2].uses / max) * 50;
var one = 50 - (his[1].uses / max * 50); var one = 50 - (his[1].uses / max) * 50;
var zero = 50 - (his[0].uses / max * 50); var zero = 50 - (his[0].uses / max) * 50;
if (max === 0) { if (max === 0) {
tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + '</svg><span style="font-size:200%">' + his[0].uses + "</span>toot(s)&nbsp;<a onclick=\"tl('tag','" + escapeHTML(tag.name) + "','" + acct_id + "','add')\" class=\"pointer\">#" + escapeHTML(tag.name) + "</a>&nbsp;" + his[0].accounts + lang.lang_src_people;
'</svg><span style="font-size:200%">' + his[0].uses + '</span>toot(s)&nbsp;<a onclick="tl(\'tag\',\'' + escapeHTML(tag.name) + '\',\'' + acct_id +
'\',\'add\')" class="pointer">#' + escapeHTML(tag.name) + '</a>&nbsp;' + his[0].accounts + lang.lang_src_people;
} else { } else {
tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + '<g><path d="M0,' + six + " L10," + five + " 20," + four + " 30," + three + " 40," + two + " 50," + one + " 60," + zero + '" style="stroke: #9e9e9e; stroke-width: 1;fill: none;"></path></g>' + '</svg><span style="font-size:200%">' + his[0].uses + "</span>toot&nbsp;<a onclick=\"tl('tag','" + escapeHTML(tag.name) + "','" + acct_id + "','add')\" class=\"pointer\">#" + escapeHTML(tag.name) + "</a>&nbsp;" + his[0].accounts + lang.lang_src_people;
'<g><path d="M0,' + six + ' L10,' + five + ' 20,' + four + ' 30,' + three + ' 40,' + two + ' 50,' + one + ' 60,' + zero + '" style="stroke: #9e9e9e; stroke-width: 1;fill: none;"></path></g>' +
'</svg><span style="font-size:200%">' + his[0].uses + '</span>toot&nbsp;<a onclick="tl(\'tag\',\'' + escapeHTML(tag.name) + '\',\'' + acct_id +
'\',\'add\')" class="pointer">#' + escapeHTML(tag.name) + '</a>&nbsp;' + his[0].accounts + lang.lang_src_people;
} }
return tags; return tags;
@ -221,7 +228,7 @@ function graphDraw(tag, acct_id) {
</svg> </svg>
*/ */
function trend() { function trend() {
console.log("get trend") console.log("get trend");
$("#src-contents").html(""); $("#src-contents").html("");
var acct_id = $("#src-acct-sel").val(); var acct_id = $("#src-acct-sel").val();
if (acct_id == "tootsearch") { if (acct_id == "tootsearch") {
@ -229,44 +236,43 @@ function trend() {
} }
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/trends" var start = "https://" + domain + "/api/v1/trends";
console.log(start) console.log(start);
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
//todo(error); .catch(function(error) {
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
var tags = ""; var tags = "";
Object.keys(json).forEach(function(keye) { Object.keys(json).forEach(function(keye) {
var tag = json[keye]; var tag = json[keye];
var his = tag.history; var his = tag.history;
var max = Math.max.apply(null, [his[0].uses, his[1].uses, his[2].uses, his[3].uses, his[4].uses, his[5].uses, his[6].uses]); var max = Math.max.apply(null, [his[0].uses, his[1].uses, his[2].uses, his[3].uses, his[4].uses, his[5].uses, his[6].uses]);
var six = 50 - (his[6].uses / max * 50); var six = 50 - (his[6].uses / max) * 50;
var five = 50 - (his[5].uses / max * 50); var five = 50 - (his[5].uses / max) * 50;
var four = 50 - (his[4].uses / max * 50); var four = 50 - (his[4].uses / max) * 50;
var three = 50 - (his[3].uses / max * 50); var three = 50 - (his[3].uses / max) * 50;
var two = 50 - (his[2].uses / max * 50); var two = 50 - (his[2].uses / max) * 50;
var one = 50 - (his[1].uses / max * 50); var one = 50 - (his[1].uses / max) * 50;
var zero = 50 - (his[0].uses / max * 50); var zero = 50 - (his[0].uses / max) * 50;
tags = '<svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + tags = '<svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + '<g><path d="M-1,51, -1,' + six + ", 0," + six + " L10," + five + " 20," + four + " 30," + three + " 40," + two + " 50," + one + " 60," + zero + " 61," + zero + ' 61,51 -1,51" style="stroke: #0f8c0c;fill: rgba(13,113,19,.25); stroke-width: 1;"></path></g>' + '</svg><span style="font-size:200%">' + his[0].uses + "</span>toots&nbsp;<a onclick=\"tl('tag','" + tag.name + "','" + acct_id + "','add')\" class=\"pointer\">#" + tag.name + "</a>&nbsp;" + his[0].accounts + lang.lang_src_people + "<br><br>";
'<g><path d="M-1,51, -1,' + six + ', 0,' + six + ' L10,' + five + ' 20,' + four + ' 30,' + three + ' 40,' + two + ' 50,' + one + ' 60,' + zero + ' 61,' + zero + ' 61,51 -1,51" style="stroke: #0f8c0c;fill: rgba(13,113,19,.25); stroke-width: 1;"></path></g>' +
'</svg><span style="font-size:200%">' + his[0].uses + '</span>toots&nbsp;<a onclick="tl(\'tag\',\'' + tag.name + '\',\'' + acct_id +
'\',\'add\')" class="pointer">#' + tag.name + '</a>&nbsp;' + his[0].accounts + lang.lang_src_people + "<br><br>";
$("#src-contents").append(tags); $("#src-contents").append(tags);
}); });
}); });
} }

View File

@ -5,7 +5,7 @@ if (location.search) {
var codex = m[2]; var codex = m[2];
if (mode == "tag") { if (mode == "tag") {
var acct_id = localStorage.getItem("main"); var acct_id = localStorage.getItem("main");
tl('tag', decodeURI(codex), acct_id, 'add'); tl("tag", decodeURI(codex), acct_id, "add");
} }
} }
//よく使うタグ //よく使うタグ
@ -54,7 +54,7 @@ function favTag() {
var obj = JSON.parse(tagarr); var obj = JSON.parse(tagarr);
} }
var tags = ""; var tags = "";
var nowPT = localStorage.getItem("stable") var nowPT = localStorage.getItem("stable");
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function(key) {
var tag = obj[key]; var tag = obj[key];
if (nowPT != tag) { if (nowPT != tag) {
@ -66,8 +66,7 @@ function favTag() {
var nowon = "(" + lang.lang_tags_realtime + ")"; var nowon = "(" + lang.lang_tags_realtime + ")";
} }
tag = escapeHTML(tag); tag = escapeHTML(tag);
tags = tags + '<a onclick="tagShow(\'' + tag + '\')" class="pointer">#' + tag + '</a>' + nowon + '<span class="hide" data-tag="' + tag + '"> <a onclick="tagTL(\'tag\',\'' + tag + '\',false,\'add\')" class="pointer" title="' + lang.lang_parse_tagTL.replace("{{tag}}", '#' + tag) + '">TL</a> <a onclick="brInsert(\'#' + tag + '\')" class="pointer" title="' + lang.lang_parse_tagtoot.replace("{{tag}}", '#' + tag) + '">Toot</a> ' + tags = tags + "<a onclick=\"tagShow('" + tag + '\')" class="pointer">#' + tag + "</a>" + nowon + '<span class="hide" data-tag="' + tag + "\"> <a onclick=\"tagTL('tag','" + tag + '\',false,\'add\')" class="pointer" title="' + lang.lang_parse_tagTL.replace("{{tag}}", "#" + tag) + '">TL</a> <a onclick="brInsert(\'#' + tag + '\')" class="pointer" title="' + lang.lang_parse_tagtoot.replace("{{tag}}", "#" + tag) + '">Toot</a> ' + "<a onclick=\"autoToot('" + tag + '\');" class="pointer" title="' + lang.lang_tags_always + lang.lang_parse_tagtoot.replace("{{tag}}", "#" + tag) + '">' + ptt + "</a> <a onclick=\"tagRemove('" + key + '\')" class="pointer" title="' + lang.lang_tags_tagunpin.replace("{{tag}}", "#" + tag) + '">' + lang.lang_del + "</a></span> ";
'<a onclick="autoToot(\'' + tag + '\');" class="pointer" title="' + lang.lang_tags_always + lang.lang_parse_tagtoot.replace("{{tag}}", '#' + tag) + '">' + ptt + '</a> <a onclick="tagRemove(\'' + key + '\')" class="pointer" title="' + lang.lang_tags_tagunpin.replace("{{tag}}", '#' + tag) + '">' + lang.lang_del + '</a></span> ';
}); });
if (obj.length > 0) { if (obj.length > 0) {
$("#taglist").append("My Tags:" + tags); $("#taglist").append("My Tags:" + tags);
@ -77,40 +76,43 @@ function favTag() {
} }
function trendTag() { function trendTag() {
$(".trendtag").remove(); $(".trendtag").remove();
var domain = "imastodon.net" var domain = "imastodon.net";
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/trend_tags" var start = "https://" + domain + "/api/v1/trend_tags";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
var tags = ""; var tags = "";
json = json.score; json = json.score;
Object.keys(json).forEach(function(tag) { Object.keys(json).forEach(function(tag) {
tag = escapeHTML(tag); tag = escapeHTML(tag);
tags = tags + '<a onclick="tagShow(\'' + tag + '\')" class="pointer">#' + tag + '</a><span class="hide" data-tag="' + tag + '"> <a onclick="tagTL(\'tag\',\'' + tag + '\',false,\'add\')" class="pointer" title="#' + tag + 'のタイムライン">TL</a> <a onclick="show();brInsert(\'#' + tag + '\')" class="pointer" title="#' + tag + 'でトゥート">Toot</a></span> '; tags = tags + "<a onclick=\"tagShow('" + tag + '\')" class="pointer">#' + tag + '</a><span class="hide" data-tag="' + tag + "\"> <a onclick=\"tagTL('tag','" + tag + '\',false,\'add\')" class="pointer" title="#' + tag + 'のタイムライン">TL</a> <a onclick="show();brInsert(\'#' + tag + '\')" class="pointer" title="#' + tag + 'でトゥート">Toot</a></span> ';
}); });
$("#taglist").append('<div class="trendtag">アイマストドントレンドタグ<i class="material-icons pointer" onclick="trendTag()" style="font-size:12px">refresh</i>:' + tags + '</div>'); $("#taglist").append('<div class="trendtag">アイマストドントレンドタグ<i class="material-icons pointer" onclick="trendTag()" style="font-size:12px">refresh</i>:' + tags + "</div>");
trendintervalset() trendintervalset();
} else { } else {
$("#taglist").html(""); $("#taglist").html("");
} }
}); });
} }
function trendintervalset() { function trendintervalset() {
@ -121,15 +123,15 @@ function tagTL(a, b, c, d) {
tl(a, b, acct_id, d); tl(a, b, acct_id, d);
} }
function autoToot(tag) { function autoToot(tag) {
tag = escapeHTML(tag) tag = escapeHTML(tag);
var nowPT = localStorage.getItem("stable") var nowPT = localStorage.getItem("stable");
if (nowPT == tag) { if (nowPT == tag) {
localStorage.removeItem("stable"); localStorage.removeItem("stable");
M.toast({ html: lang.lang_tags_unrealtime, displayLength: 3000 }) M.toast({ html: lang.lang_tags_unrealtime, displayLength: 3000 });
} else { } else {
localStorage.setItem("stable", tag); localStorage.setItem("stable", tag);
M.toast({ html: lang.lang_tags_tagwarn.replace("{{tag}}", tag).replace("{{tag}}", tag), displayLength: 3000 }) M.toast({ html: lang.lang_tags_tagwarn.replace("{{tag}}", tag).replace("{{tag}}", tag), displayLength: 3000 });
brInsert('#' + tag + " ") brInsert("#" + tag + " ");
} }
favTag(); favTag();
} }
@ -137,27 +139,30 @@ function autoToot(tag) {
function tagFeature(name, acct_id) { function tagFeature(name, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/featured_tags" var start = "https://" + domain + "/api/v1/featured_tags";
fetch(start, { fetch(start, {
method: 'POST', method: "POST",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, },
body: JSON.stringify({ body: JSON.stringify({
name: name name: name
}) })
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
return false; return false;
}).then(function (json) { })
console.log(json) .then(function(json) {
M.toast({ html: "Complete: " + escapeHTML(name), displayLength: 3000 }) console.log(json);
M.toast({ html: "Complete: " + escapeHTML(name), displayLength: 3000 });
}); });
} }

File diff suppressed because it is too large Load Diff

View File

@ -1,73 +1,73 @@
//設定(setting.html)で読む //設定(setting.html)で読む
var envView = new Vue({ var envView = new Vue({
el: '#envView', el: "#envView",
data: { config: envConstruction }, data: { config: envConstruction },
methods: { methods: {
complete: function(i, val) { complete: function(i, val) {
var ls = envView.config[i].storage; var ls = envView.config[i].storage;
M.toast({ html: 'Complete', displayLength: 3000 }) M.toast({ html: "Complete", displayLength: 3000 });
if (!val) { if (!val) {
var id = envView.config[i].id; var id = envView.config[i].id;
var val = $("#" + id).val() var val = $("#" + id).val();
} }
localStorage.setItem(ls, val) localStorage.setItem(ls, val);
if (ls == "ha") { if (ls == "ha") {
hardwareAcceleration(val) hardwareAcceleration(val);
} }
if (ls == "ua_setting") { if (ls == "ua_setting") {
useragent(val) useragent(val);
} }
return true return true;
} }
} }
}); });
var tlView = new Vue({ var tlView = new Vue({
el: '#tlView', el: "#tlView",
data: { config: tlConstruction }, data: { config: tlConstruction },
methods: { methods: {
complete: function(i, val) { complete: function(i, val) {
var ls = tlView.config[i]; var ls = tlView.config[i];
if (val) { if (val) {
localStorage.setItem(ls.storage, val) localStorage.setItem(ls.storage, val);
} else { } else {
if (!ls.data) { if (!ls.data) {
ls = [ls] ls = [ls];
} else { } else {
ls = ls.data ls = ls.data;
} }
for (var j = 0; j < ls.length; j++) { for (var j = 0; j < ls.length; j++) {
M.toast({ html: 'Complete', displayLength: 3000 }) M.toast({ html: "Complete", displayLength: 3000 });
var id = ls[j].id; var id = ls[j].id;
var val = $("#" + id).val() var val = $("#" + id).val();
localStorage.setItem(ls[j].storage, val) localStorage.setItem(ls[j].storage, val);
} }
} }
return true return true;
} }
} }
}); });
var postView = new Vue({ var postView = new Vue({
el: '#postView', el: "#postView",
data: { config: postConstruction, kirishima: localStorage.getItem('kirishima'), quoters: localStorage.getItem('quoters') }, data: { config: postConstruction, kirishima: localStorage.getItem("kirishima"), quoters: localStorage.getItem("quoters") },
methods: { methods: {
complete: function(i, val) { complete: function(i, val) {
var ls = postView.config[i]; var ls = postView.config[i];
if (val) { if (val) {
localStorage.setItem(ls.storage, val) localStorage.setItem(ls.storage, val);
} else { } else {
if (!ls.data) { if (!ls.data) {
ls = [ls] ls = [ls];
} else { } else {
ls = ls.data ls = ls.data;
} }
for (var j = 0; j < ls.length; j++) { for (var j = 0; j < ls.length; j++) {
M.toast({ html: 'Complete', displayLength: 3000 }) M.toast({ html: "Complete", displayLength: 3000 });
var id = ls[j].id; var id = ls[j].id;
var val = $("#" + id).val() var val = $("#" + id).val();
localStorage.setItem(ls[j].storage, val) localStorage.setItem(ls[j].storage, val);
} }
} }
return true return true;
} }
} }
}); });
@ -83,7 +83,7 @@ function settings() {
$("#" + theme).prop("checked", true); $("#" + theme).prop("checked", true);
} else { } else {
if (cd != localStorage.getItem("theme")) { if (cd != localStorage.getItem("theme")) {
M.toast({ html: lang.lang_setting_theme.replace("{{set}}", ct), displayLength: 3000 }) M.toast({ html: lang.lang_setting_theme.replace("{{set}}", ct), displayLength: 3000 });
} }
//テーマはこの場で設定 //テーマはこの場で設定
themes(cd); themes(cd);
@ -92,14 +92,14 @@ function settings() {
var fontd = $("#font").val(); var fontd = $("#font").val();
if (fontd) { if (fontd) {
if (fontd != localStorage.getItem("font")) { if (fontd != localStorage.getItem("font")) {
M.toast({ html: lang.lang_setting_font.replace("{{set}}", ct), displayLength: 3000 }) M.toast({ html: lang.lang_setting_font.replace("{{set}}", ct), displayLength: 3000 });
} }
localStorage.setItem("font", fontd); localStorage.setItem("font", fontd);
themes(); themes();
} else { } else {
if (localStorage.getItem("font")) { if (localStorage.getItem("font")) {
localStorage.removeItem("font"); localStorage.removeItem("font");
M.toast({ html: lang.lang_setting_font.replace("{{set}}", ct), displayLength: 3000 }) M.toast({ html: lang.lang_setting_font.replace("{{set}}", ct), displayLength: 3000 });
themes(); themes();
} }
} }
@ -111,7 +111,7 @@ function load() {
for (var i = 0; i < max; i++) { for (var i = 0; i < max; i++) {
var ls = envView.config[i].storage; var ls = envView.config[i].storage;
if (localStorage.getItem(ls)) { if (localStorage.getItem(ls)) {
envView.config[i].setValue = localStorage.getItem(ls) envView.config[i].setValue = localStorage.getItem(ls);
} }
} }
var max = tlView.config.length; var max = tlView.config.length;
@ -119,13 +119,13 @@ function load() {
var ls = tlView.config[i].storage; var ls = tlView.config[i].storage;
if (ls) { if (ls) {
if (localStorage.getItem(ls)) { if (localStorage.getItem(ls)) {
tlView.config[i].setValue = localStorage.getItem(ls) tlView.config[i].setValue = localStorage.getItem(ls);
} }
} else { } else {
ls = tlView.config[i].data ls = tlView.config[i].data;
for (var j = 0; j < ls.length; j++) { for (var j = 0; j < ls.length; j++) {
if (localStorage.getItem(tlView.config[i].data[j].storage)) { if (localStorage.getItem(tlView.config[i].data[j].storage)) {
tlView.config[i].data[j].setValue = localStorage.getItem(tlView.config[i].data[j].storage) tlView.config[i].data[j].setValue = localStorage.getItem(tlView.config[i].data[j].storage);
} }
} }
} }
@ -135,12 +135,12 @@ function load() {
var ls = postView.config[i].storage; var ls = postView.config[i].storage;
if (ls) { if (ls) {
if (localStorage.getItem(ls)) { if (localStorage.getItem(ls)) {
postView.config[i].setValue = localStorage.getItem(ls) postView.config[i].setValue = localStorage.getItem(ls);
} }
} else { } else {
ls = postView.config[i].data ls = postView.config[i].data;
for (var j = 0; j < ls.length; j++) { for (var j = 0; j < ls.length; j++) {
postView.config[i].data[j].setValue = localStorage.getItem(ls[j].storage) postView.config[i].data[j].setValue = localStorage.getItem(ls[j].storage);
} }
} }
} }
@ -160,24 +160,24 @@ function load() {
var font = ""; var font = "";
} }
$("#font").val(font); $("#font").val(font);
$("#c1-file").text(localStorage.getItem("custom1")) $("#c1-file").text(localStorage.getItem("custom1"));
$("#c2-file").text(localStorage.getItem("custom2")); $("#c2-file").text(localStorage.getItem("custom2"));
$("#c3-file").text(localStorage.getItem("custom3")); $("#c3-file").text(localStorage.getItem("custom3"));
$("#c4-file").text(localStorage.getItem("custom4")); $("#c4-file").text(localStorage.getItem("custom4"));
var cvol = localStorage.getItem("customVol") var cvol = localStorage.getItem("customVol");
if (cvol) { if (cvol) {
$("#soundvol").val(cvol * 100); $("#soundvol").val(cvol * 100);
$("#soundVolVal").text(cvol * 100) $("#soundVolVal").text(cvol * 100);
} }
//$("#log").val(localStorage.getItem("errors")) //$("#log").val(localStorage.getItem("errors"))
} }
function customVol() { function customVol() {
var cvol = $("#soundvol").val() var cvol = $("#soundvol").val();
$("#soundVolVal").text(cvol) $("#soundVolVal").text(cvol);
localStorage.setItem("customVol", cvol / 100) localStorage.setItem("customVol", cvol / 100);
var sound = localStorage.getItem("favSound"); var sound = localStorage.getItem("favSound");
if (sound == "default") { if (sound == "default") {
var file = "../../source/notif.wav" var file = "../../source/notif.wav";
} else { } else {
if (sound == "c1") { if (sound == "c1") {
var file = localStorage.getItem("custom1"); var file = localStorage.getItem("custom1");
@ -211,10 +211,7 @@ function climute() {
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function(key) {
var cli = obj[key]; var cli = obj[key];
var list = key * 1 + 1; var list = key * 1 + 1;
templete = '<div class="acct" id="acct_' + key + '">' + list + templete = '<div class="acct" id="acct_' + key + '">' + list + "." + escapeHTML(cli) + '<button class="btn waves-effect red disTar" onclick="cliMuteDel(' + key + ')">' + lang.lang_del + "</button><br></div>";
'.' +
escapeHTML(cli) + '<button class="btn waves-effect red disTar" onclick="cliMuteDel(' +
key + ')">' + lang.lang_del + '</button><br></div>';
$("#mute-cli").append(templete); $("#mute-cli").append(templete);
}); });
} }
@ -231,9 +228,11 @@ function cliMuteDel(key) {
function wordmute() { function wordmute() {
var word = localStorage.getItem("word_mute"); var word = localStorage.getItem("word_mute");
var obj = JSON.parse(word); var obj = JSON.parse(word);
if (!obj) { obj = [] } if (!obj) {
$('#wordmute').chips({ obj = [];
data: obj, }
$("#wordmute").chips({
data: obj
}); });
} }
function wordmuteSave() { function wordmuteSave() {
@ -245,9 +244,11 @@ function wordmuteSave() {
function wordemp() { function wordemp() {
var word = localStorage.getItem("word_emp"); var word = localStorage.getItem("word_emp");
var obj = JSON.parse(word); var obj = JSON.parse(word);
if (!obj) { obj = [] } if (!obj) {
$('#wordemp').chips({ obj = [];
data: obj, }
$("#wordemp").chips({
data: obj
}); });
} }
function wordempSave() { function wordempSave() {
@ -258,39 +259,44 @@ function wordempSave() {
function notftest() { function notftest() {
var os = localStorage.getItem("platform"); var os = localStorage.getItem("platform");
var options = { var options = {
body: lang.lang_setting_notftest + '(' + lang.lang_setting_notftestprof + ')', body: lang.lang_setting_notftest + "(" + lang.lang_setting_notftestprof + ")",
icon: localStorage.getItem("prof_0") icon: localStorage.getItem("prof_0")
}; };
var n = new Notification('TheDesk' + lang.lang_setting_notftest, options); var n = new Notification("TheDesk" + lang.lang_setting_notftest, options);
} }
function oks(no) { function oks(no) {
var txt = $("#oks-" + no).val(); var txt = $("#oks-" + no).val();
localStorage.setItem("oks-" + no, txt); localStorage.setItem("oks-" + no, txt);
M.toast({ html: lang.lang_setting_ksref, displayLength: 3000 }) M.toast({ html: lang.lang_setting_ksref, displayLength: 3000 });
} }
function oksload() { function oksload() {
if (localStorage.getItem("oks-1")) { $("#oks-1").val(localStorage.getItem("oks-1")) } if (localStorage.getItem("oks-1")) {
if (localStorage.getItem("oks-2")) { $("#oks-2").val(localStorage.getItem("oks-2")) } $("#oks-1").val(localStorage.getItem("oks-1"));
if (localStorage.getItem("oks-3")) { $("#oks-3").val(localStorage.getItem("oks-3")) } }
if (localStorage.getItem("oks-2")) {
$("#oks-2").val(localStorage.getItem("oks-2"));
}
if (localStorage.getItem("oks-3")) {
$("#oks-3").val(localStorage.getItem("oks-3"));
}
} }
function changelang(lang) { function changelang(lang) {
postMessage(["lang", lang], "*") postMessage(["lang", lang], "*");
} }
function exportSettings() { function exportSettings() {
Swal.fire({ Swal.fire({
title: lang.lang_setting_exportwarn, title: lang.lang_setting_exportwarn,
type: 'warning', type: "warning",
showCancelButton: true, showCancelButton: true,
confirmButtonColor: '#3085d6', confirmButtonColor: "#3085d6",
cancelButtonColor: '#d33', cancelButtonColor: "#d33",
confirmButtonText: lang.lang_yesno, confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no cancelButtonText: lang.lang_no
}).then((result) => { }).then(result => {
if (result.value) { if (result.value) {
postMessage(["exportSettings", ""], "*") postMessage(["exportSettings", ""], "*");
} }
}) });
} }
function exportSettingsCore() { function exportSettingsCore() {
var exp = {}; var exp = {};
@ -309,27 +315,23 @@ function exportSettingsCore() {
var max = envView.config.length; var max = envView.config.length;
for (var i = 0; i < max; i++) { for (var i = 0; i < max; i++) {
var ls = envView.config[i].storage; var ls = envView.config[i].storage;
config[ls] = localStorage.getItem(ls) config[ls] = localStorage.getItem(ls);
} }
var max = tlView.config.length; var max = tlView.config.length;
for (var i = 0; i < max; i++) { for (var i = 0; i < max; i++) {
var ls = tlView.config[i].storage; var ls = tlView.config[i].storage;
config[ls] = localStorage.getItem(ls) config[ls] = localStorage.getItem(ls);
} }
var max = postView.config.length; var max = postView.config.length;
for (var i = 0; i < max; i++) { for (var i = 0; i < max; i++) {
var ls = postView.config[i].storage; var ls = postView.config[i].storage;
config[ls] = localStorage.getItem(ls) config[ls] = localStorage.getItem(ls);
} }
//Font //Font
config.font = localStorage.getItem("font"); config.font = localStorage.getItem("font");
exp.config = config; exp.config = config;
//keysc //keysc
exp.ksc = [ exp.ksc = [localStorage.getItem("oks-1"), localStorage.getItem("oks-2"), localStorage.getItem("oks-3")];
localStorage.getItem("oks-1"),
localStorage.getItem("oks-2"),
localStorage.getItem("oks-3")
];
//climu //climu
var cli = localStorage.getItem("client_mute"); var cli = localStorage.getItem("client_mute");
var climu = JSON.parse(cli); var climu = JSON.parse(cli);
@ -339,7 +341,7 @@ function exportSettingsCore() {
var wordmu = JSON.parse(wdm); var wordmu = JSON.parse(wdm);
exp.wordMute = wordmu; exp.wordMute = wordmu;
//spotify //spotify
exp.spotifyArtwork = localStorage.getItem("artwork") exp.spotifyArtwork = localStorage.getItem("artwork");
var content = localStorage.getItem("np-temp"); var content = localStorage.getItem("np-temp");
if (content || content == "" || content == "null") { if (content || content == "" || content == "null") {
exp.spotifyTemplete = content; exp.spotifyTemplete = content;
@ -350,27 +352,27 @@ function exportSettingsCore() {
var tagarr = localStorage.getItem("tag"); var tagarr = localStorage.getItem("tag");
var favtag = JSON.parse(tagarr); var favtag = JSON.parse(tagarr);
exp.favoriteTags = favtag; exp.favoriteTags = favtag;
exp.revisons = 2.1 exp.revisons = 2.1;
exp.meta = {} exp.meta = {};
exp.meta.date = new Date() exp.meta.date = new Date();
exp.meta.thedesk = localStorage.getItem("ver") exp.meta.thedesk = localStorage.getItem("ver");
exp.meta.platform = localStorage.getItem("platform") exp.meta.platform = localStorage.getItem("platform");
return exp; return exp;
} }
function importSettings() { function importSettings() {
Swal.fire({ Swal.fire({
title: lang.lang_setting_importwarn, title: lang.lang_setting_importwarn,
type: 'warning', type: "warning",
showCancelButton: true, showCancelButton: true,
confirmButtonColor: '#3085d6', confirmButtonColor: "#3085d6",
cancelButtonColor: '#d33', cancelButtonColor: "#d33",
confirmButtonText: lang.lang_yesno, confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no cancelButtonText: lang.lang_no
}).then((result) => { }).then(result => {
if (result.value) { if (result.value) {
postMessage(["importSettings", ""], "*") postMessage(["importSettings", ""], "*");
} }
}) });
} }
function importSettingsCore(obj) { function importSettingsCore(obj) {
if (obj) { if (obj) {
@ -392,21 +394,21 @@ function importSettingsCore(obj) {
for (var i = 0; i < max; i++) { for (var i = 0; i < max; i++) {
var ls = envView.config[i].storage; var ls = envView.config[i].storage;
if (obj.config[ls]) { if (obj.config[ls]) {
localStorage.setItem(ls, obj.config[ls]) localStorage.setItem(ls, obj.config[ls]);
} }
} }
var max = tlView.config.length; var max = tlView.config.length;
for (var i = 0; i < max; i++) { for (var i = 0; i < max; i++) {
var ls = tlView.config[i].storage; var ls = tlView.config[i].storage;
if (obj.config[ls]) { if (obj.config[ls]) {
localStorage.setItem(ls, obj.config[ls]) localStorage.setItem(ls, obj.config[ls]);
} }
} }
var max = postView.config.length; var max = postView.config.length;
for (var i = 0; i < max; i++) { for (var i = 0; i < max; i++) {
var ls = postView.config[i].storage; var ls = postView.config[i].storage;
if (obj.config[ls]) { if (obj.config[ls]) {
localStorage.setItem(ls, obj.config[ls]) localStorage.setItem(ls, obj.config[ls]);
} }
} }
} else { } else {
@ -459,23 +461,23 @@ function importSettingsCore(obj) {
location.href = "index.html"; location.href = "index.html";
} else { } else {
Swal.fire({ Swal.fire({
type: 'error', type: "error",
title: 'Error' title: "Error"
}) });
} }
} }
function savefolder() { function savefolder() {
postMessage(["sendSinmpleIpc", "savefolder"], "*") postMessage(["sendSinmpleIpc", "savefolder"], "*");
} }
function font() { function font() {
postMessage(["sendSinmpleIpc", "fonts"], "*") postMessage(["sendSinmpleIpc", "fonts"], "*");
} }
function fontList(arg) { function fontList(arg) {
$("#fonts").removeClass("hide"); $("#fonts").removeClass("hide");
for (var i = 0; i < arg.length; i++) { for (var i = 0; i < arg.length; i++) {
var font = arg[i]; var font = arg[i];
$("#fonts").append('<div class="font pointer" style="font-family:' + font.family + '" onclick="insertFont(\'' + font.family + '\')">' + font.family + "</div>") $("#fonts").append('<div class="font pointer" style="font-family:' + font.family + '" onclick="insertFont(\'' + font.family + "')\">" + font.family + "</div>");
} }
} }
function insertFont(name) { function insertFont(name) {
@ -486,11 +488,11 @@ $(".color-picker").each(function (i, elem) {
}); });
function pickerDefine(i, color) { function pickerDefine(i, color) {
var pickr = new Pickr({ var pickr = new Pickr({
el: '#color-picker' + i, el: "#color-picker" + i,
default: color, default: color,
showAlways: true, showAlways: true,
appendToBody: true, appendToBody: true,
closeWithKey: 'Escape', closeWithKey: "Escape",
comparison: false, comparison: false,
components: { components: {
preview: true, // Left side color comparison preview: true, // Left side color comparison
@ -498,53 +500,73 @@ function pickerDefine(i, color) {
hue: true, // Hue slider hue: true, // Hue slider
interaction: { interaction: {
rgba: false, // rgba option (red green blue and alpha) rgba: false, // rgba option (red green blue and alpha)
input: true, // input / output element input: true // input / output element
} }
}, },
strings: { strings: {
save: 'Save', // Default for save button save: "Save", // Default for save button
clear: 'Clear' // Default for clear button clear: "Clear" // Default for clear button
} }
}); });
pickr.on('change', (...args) => { pickr.on("change", (...args) => {
var rgb = 'rgb(' + args[0].toRGBA()[0] + ',' + args[0].toRGBA()[1] + ',' + args[0].toRGBA()[2] + ')'; var rgb = "rgb(" + args[0].toRGBA()[0] + "," + args[0].toRGBA()[1] + "," + args[0].toRGBA()[2] + ")";
$("#color-picker" + i + "_value").val(rgb) $("#color-picker" + i + "_value").val(rgb);
}); });
} }
function customComp() { function customComp() {
var nameC = $("#custom_name").val(); var nameC = $("#custom_name").val();
if (!nameC) { return false; } if (!nameC) {
return false;
}
var descC = $("#custom_desc").val(); var descC = $("#custom_desc").val();
var primaryC = $("#color-picker0_value").val(); var primaryC = $("#color-picker0_value").val();
if (!primaryC) { primaryC = "rgb(255,255,255)" } if (!primaryC) {
primaryC = "rgb(255,255,255)";
}
var secondaryC = $("#color-picker1_value").val(); var secondaryC = $("#color-picker1_value").val();
if (!secondaryC) { secondaryC = "rgb(255,255,255)" } if (!secondaryC) {
secondaryC = "rgb(255,255,255)";
}
var textC = $("#color-picker2_value").val(); var textC = $("#color-picker2_value").val();
if (!textC) { textC = "rgb(255,255,255)" } if (!textC) {
textC = "rgb(255,255,255)";
}
var multi = localStorage.getItem("multi"); var multi = localStorage.getItem("multi");
if ($("#pickers").hasClass("advanceTheme")) { if ($("#pickers").hasClass("advanceTheme")) {
var accentC = $("#color-picker3_value").val(); var accentC = $("#color-picker3_value").val();
if (!accentC) { accentC = null } if (!accentC) {
var activeC = $("#color-picker4_value").val(); accentC = null;
if (!activeC) { activeC = null }
var modalC = $("#color-picker5_value").val();
if (!modalC) { modalC = null }
var bottomC = $("#color-picker6_value").val();
if (!bottomC) { bottomC = null }
var postboxC = $("#color-picker7_value").val();
if (!postboxC) { postboxC = null }
var subcolorC = $("#color-picker8_value").val();
if (!subcolorC) { subcolorC = null }
var advanceTheme = {
"TheDeskAccent": accentC,
"TheDeskActive": activeC,
"TheDeskModal": modalC,
"TheDeskBottom": bottomC,
"TheDeskPostbox": postboxC,
"TheDeskSubcolor": subcolorC
} }
var activeC = $("#color-picker4_value").val();
if (!activeC) {
activeC = null;
}
var modalC = $("#color-picker5_value").val();
if (!modalC) {
modalC = null;
}
var bottomC = $("#color-picker6_value").val();
if (!bottomC) {
bottomC = null;
}
var postboxC = $("#color-picker7_value").val();
if (!postboxC) {
postboxC = null;
}
var subcolorC = $("#color-picker8_value").val();
if (!subcolorC) {
subcolorC = null;
}
var advanceTheme = {
TheDeskAccent: accentC,
TheDeskActive: activeC,
TheDeskModal: modalC,
TheDeskBottom: bottomC,
TheDeskPostbox: postboxC,
TheDeskSubcolor: subcolorC
};
} else { } else {
var advanceTheme = {} var advanceTheme = {};
} }
var my = JSON.parse(multi)[0].name; var my = JSON.parse(multi)[0].name;
@ -552,20 +574,20 @@ function customComp() {
if (id == "add_new") { if (id == "add_new") {
id = makeCID(); id = makeCID();
} }
localStorage.setItem("customtheme-id", id) localStorage.setItem("customtheme-id", id);
var json = { var json = {
"name": nameC, name: nameC,
"author": my, author: my,
"desc": descC, desc: descC,
"base": $("[name=direction]:checked").val(), base: $("[name=direction]:checked").val(),
"vars": { vars: {
"primary": primaryC, primary: primaryC,
"secondary": secondaryC, secondary: secondaryC,
"text": textC text: textC
}, },
"props": advanceTheme, props: advanceTheme,
"id": id id: id
} };
$("#custom_json").val(JSON.stringify(json)); $("#custom_json").val(JSON.stringify(json));
themes("custom"); themes("custom");
$("#custom").prop("checked", true); $("#custom").prop("checked", true);
@ -574,11 +596,11 @@ function customComp() {
$("#dark").prop("checked", true); $("#dark").prop("checked", true);
$("#custom_json").val(""); $("#custom_json").val("");
for (var i = 0; i <= 8; i++) { for (var i = 0; i <= 8; i++) {
$("#color-picker" + i + "-wrap").html('<div class="color-picker" id="color-picker' + i + '"></div>') $("#color-picker" + i + "-wrap").html('<div class="color-picker" id="color-picker' + i + '"></div>');
$("#color-picker" + i + "_value").val(""); $("#color-picker" + i + "_value").val("");
pickerDefine(i, "fff"); pickerDefine(i, "fff");
} }
postMessage(["themeJsonCreate", JSON.stringify(json)], "*") postMessage(["themeJsonCreate", JSON.stringify(json)], "*");
} }
function deleteIt() { function deleteIt() {
var id = $("#custom-sel-sel").val(); var id = $("#custom-sel-sel").val();
@ -587,33 +609,33 @@ function deleteIt() {
$("#dark").prop("checked", true); $("#dark").prop("checked", true);
$("#custom_json").val(""); $("#custom_json").val("");
for (var i = 0; i <= 8; i++) { for (var i = 0; i <= 8; i++) {
$("#color-picker" + i + "-wrap").html('<div class="color-picker" id="color-picker' + i + '"></div>') $("#color-picker" + i + "-wrap").html('<div class="color-picker" id="color-picker' + i + '"></div>');
$("#color-picker" + i + "_value").val(""); $("#color-picker" + i + "_value").val("");
pickerDefine(i, "fff"); pickerDefine(i, "fff");
} }
postMessage(["themeJsonDelete", id], "*") postMessage(["themeJsonDelete", id], "*");
} }
function ctLoad() { function ctLoad() {
postMessage(["sendSinmpleIpc", "theme-json-list"], "*") postMessage(["sendSinmpleIpc", "theme-json-list"], "*");
} }
function ctLoadCore(args) { function ctLoadCore(args) {
var templete = ""; var templete = "";
Object.keys(args).forEach(function(key) { Object.keys(args).forEach(function(key) {
var theme = args[key]; var theme = args[key];
var themeid = theme.id var themeid = theme.id;
templete = templete + '<option value="' + themeid + '">' + theme.name + '</option>'; templete = templete + '<option value="' + themeid + '">' + theme.name + "</option>";
}); });
if (args[0]) { if (args[0]) {
localStorage.setItem("customtheme-id", args[0].id) localStorage.setItem("customtheme-id", args[0].id);
} }
$("#custom-sel-sel").html(templete); $("#custom-sel-sel").html(templete);
templete = '<option value="add_new">' + $("#edit-selector").attr("data-add") + '</option>' + templete; templete = '<option value="add_new">' + $("#edit-selector").attr("data-add") + "</option>" + templete;
$("#custom-edit-sel").html(templete); $("#custom-edit-sel").html(templete);
$('select').formSelect(); $("select").formSelect();
} }
function customSel() { function customSel() {
var id = $("#custom-sel-sel").val(); var id = $("#custom-sel-sel").val();
localStorage.setItem("customtheme-id", id) localStorage.setItem("customtheme-id", id);
} }
function custom() { function custom() {
var id = $("#custom-edit-sel").val(); var id = $("#custom-edit-sel").val();
@ -623,88 +645,88 @@ function custom() {
$("#dark").prop("checked", true); $("#dark").prop("checked", true);
$("#custom_json").val(""); $("#custom_json").val("");
for (var i = 0; i <= 8; i++) { for (var i = 0; i <= 8; i++) {
$("#color-picker" + i + "-wrap").html('<div class="color-picker" id="color-picker' + i + '"></div>') $("#color-picker" + i + "-wrap").html('<div class="color-picker" id="color-picker' + i + '"></div>');
$("#color-picker" + i + "_value").val(""); $("#color-picker" + i + "_value").val("");
pickerDefine(i, "fff"); pickerDefine(i, "fff");
} }
$("#delTheme").addClass("disabled") $("#delTheme").addClass("disabled");
} else { } else {
$("#delTheme").removeClass("disabled") $("#delTheme").removeClass("disabled");
postMessage(["themeJsonRequest", id], "*") postMessage(["themeJsonRequest", id], "*");
} }
} }
function customConnect(raw) { function customConnect(raw) {
var args = raw[0] var args = raw[0];
$("#custom_name").val(args.name); $("#custom_name").val(args.name);
$("#custom_desc").val(args.desc); $("#custom_desc").val(args.desc);
$("#" + args.base).prop("checked", true); $("#" + args.base).prop("checked", true);
//Primary //Primary
$("#color-picker0-wrap").html('<div class="color-picker" id="color-picker0"></div>') $("#color-picker0-wrap").html('<div class="color-picker" id="color-picker0"></div>');
pickerDefine(0, rgbToHex(args.vars.primary)) pickerDefine(0, rgbToHex(args.vars.primary));
$("#color-picker0_value").val(args.vars.primary); $("#color-picker0_value").val(args.vars.primary);
//Secondary //Secondary
$("#color-picker1-wrap").html('<div class="color-picker" id="color-picker1"></div>') $("#color-picker1-wrap").html('<div class="color-picker" id="color-picker1"></div>');
pickerDefine(1, rgbToHex(args.vars.secondary)) pickerDefine(1, rgbToHex(args.vars.secondary));
$("#color-picker1_value").val(args.vars.secondary); $("#color-picker1_value").val(args.vars.secondary);
//Text //Text
$("#color-picker2-wrap").html('<div class="color-picker" id="color-picker2"></div>') $("#color-picker2-wrap").html('<div class="color-picker" id="color-picker2"></div>');
$("#color-picker2_value").val(args.vars.text); $("#color-picker2_value").val(args.vars.text);
pickerDefine(2, rgbToHex(args.vars.text)) pickerDefine(2, rgbToHex(args.vars.text));
//TheDesk Only //TheDesk Only
advancedConncet(args, "TheDeskAccent", "secondary", 3) advancedConncet(args, "TheDeskAccent", "secondary", 3);
advancedConncet(args, "TheDeskActive", "primary", 4) advancedConncet(args, "TheDeskActive", "primary", 4);
advancedConncet(args, "TheDeskModal", "secondary", 5) advancedConncet(args, "TheDeskModal", "secondary", 5);
advancedConncet(args, "TheDeskBottom", "primary", 6) advancedConncet(args, "TheDeskBottom", "primary", 6);
advancedConncet(args, "TheDeskPostbox", "primary", 7) advancedConncet(args, "TheDeskPostbox", "primary", 7);
advancedConncet(args, "TheDeskSubcolor", "primary", 8) advancedConncet(args, "TheDeskSubcolor", "primary", 8);
$("#custom_json").val(raw[1]); $("#custom_json").val(raw[1]);
} }
function advancedConncet(args, tar, sub, i) { function advancedConncet(args, tar, sub, i) {
if (args.props) { if (args.props) {
if (args.props[tar]) { if (args.props[tar]) {
var color = args.props[tar]; var color = args.props[tar];
$("#pickers").addClass("advanceTheme") $("#pickers").addClass("advanceTheme");
$(".advanced").removeClass("hide") $(".advanced").removeClass("hide");
} else { } else {
var color = args.vars[sub]; var color = args.vars[sub];
} }
} else { } else {
var color = args.vars[sub]; var color = args.vars[sub];
} }
$("#color-picker"+i+"-wrap").html('<div class="color-picker" id="color-picker'+i+'"></div>') $("#color-picker" + i + "-wrap").html('<div class="color-picker" id="color-picker' + i + '"></div>');
$("#color-picker" + i + "_value").val(color); $("#color-picker" + i + "_value").val(color);
pickerDefine(i, rgbToHex(color)) pickerDefine(i, rgbToHex(color));
} }
function customImp() { function customImp() {
var json = $("#custom_import").val(); var json = $("#custom_import").val();
if (JSON5.parse(json)) { if (JSON5.parse(json)) {
postMessage(["themeJsonCreate", json], "*") postMessage(["themeJsonCreate", json], "*");
} else { } else {
Swal.fire({ Swal.fire({
type: 'error', type: "error",
title: 'Error' title: "Error"
}) });
} }
} }
function advanced() { function advanced() {
$(".advanced").toggleClass("hide") $(".advanced").toggleClass("hide");
$("#pickers").toggleClass("advanceTheme") $("#pickers").toggleClass("advanceTheme");
} }
function clearCustomImport() { function clearCustomImport() {
$("#custom_import").val(""); $("#custom_import").val("");
} }
function hardwareAcceleration(had) { function hardwareAcceleration(had) {
postMessage(["ha", had], "*") postMessage(["ha", had], "*");
} }
function useragent(val) { function useragent(val) {
postMessage(["ua", val], "*") postMessage(["ua", val], "*");
} }
function customSound(key) { function customSound(key) {
postMessage(["customSound", key], "*") postMessage(["customSound", key], "*");
} }
function customSoundSave(key, file) { function customSoundSave(key, file) {
localStorage.setItem("custom" + key, file); localStorage.setItem("custom" + key, file);
$("#c1-file").text(file) $("#c1-file").text(file);
} }
window.onload = function() { window.onload = function() {
//最初に読む //最初に読む
@ -715,28 +737,32 @@ window.onload = function () {
checkSpotify(); checkSpotify();
voiceSettingLoad(); voiceSettingLoad();
oksload(); oksload();
ctLoad() ctLoad();
}; };
//設定画面で未読マーカーは要らない //設定画面で未読マーカーは要らない
function asReadEnd() { function asReadEnd() {
postMessage(["asReadComp", ""], "*") postMessage(["asReadComp", ""], "*");
} }
function checkupd() { function checkupd() {
var ver = localStorage.getItem("ver"); var ver = localStorage.getItem("ver");
var start = "https://thedesk.top/ver.json"; var start = "https://thedesk.top/ver.json";
fetch(start, { fetch(start, {
method: 'GET' method: "GET"
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (mess) { })
.then(function(mess) {
console.table(mess); console.table(mess);
if (mess) { if (mess) {
var platform = localStorage.getItem("platform"); var platform = localStorage.getItem("platform");
@ -747,19 +773,19 @@ function checkupd(){
} }
if (newest == ver) { if (newest == ver) {
Swal.fire({ Swal.fire({
type: 'info', type: "info",
title: lang.lang_setting_noupd, title: lang.lang_setting_noupd,
html: ver html: ver
}) });
} else if (ver.indexOf("beta") != -1 || winstore) { } else if (ver.indexOf("beta") != -1 || winstore) {
Swal.fire({ Swal.fire({
type: 'info', type: "info",
title: lang.lang_setting_thisisbeta, title: lang.lang_setting_thisisbeta,
html: ver html: ver
}) });
} else { } else {
localStorage.removeItem("new-ver-skip") localStorage.removeItem("new-ver-skip");
location.href="index.html" location.href = "index.html";
} }
} }
}); });

View File

@ -2,15 +2,13 @@ function spotifyConnect() {
var auth = "https://accounts.spotify.com/authorize?client_id=0f18e54abe0b4aedb4591e353d3aff69&redirect_uri=https://thedesk.top/spotify-connect&response_type=code&scope=user-read-currently-playing"; var auth = "https://accounts.spotify.com/authorize?client_id=0f18e54abe0b4aedb4591e353d3aff69&redirect_uri=https://thedesk.top/spotify-connect&response_type=code&scope=user-read-currently-playing";
var platform = localStorage.getItem("platform"); var platform = localStorage.getItem("platform");
if (platform == "win32") { if (platform == "win32") {
postMessage(["openUrl", auth], "*") postMessage(["openUrl", auth], "*");
postMessage(["sendSinmpleIpc", "quit"], "*") postMessage(["sendSinmpleIpc", "quit"], "*");
} else { } else {
auth = auth + "&state=code"; auth = auth + "&state=code";
$("#spotify-code-show").removeClass("hide"); $("#spotify-code-show").removeClass("hide");
postMessage(["openUrl", auth], "*") postMessage(["openUrl", auth], "*");
} }
} }
function spotifyAuth() { function spotifyAuth() {
var code = $("#spotify-code").val(); var code = $("#spotify-code").val();
@ -49,10 +47,10 @@ function spotifyFlagSave() {
var awk = $("[name=awk]:checked").val(); var awk = $("[name=awk]:checked").val();
if (awk == "yes") { if (awk == "yes") {
localStorage.setItem("artwork", "yes"); localStorage.setItem("artwork", "yes");
M.toast({ html: lang.lang_spotify_img, displayLength: 3000 }) M.toast({ html: lang.lang_spotify_img, displayLength: 3000 });
} else { } else {
localStorage.removeItem("artwork"); localStorage.removeItem("artwork");
M.toast({ html: lang.lang_spotify_imgno, displayLength: 3000 }) M.toast({ html: lang.lang_spotify_imgno, displayLength: 3000 });
} }
} }
function nowplaying(mode) { function nowplaying(mode) {
@ -61,21 +59,25 @@ function nowplaying(mode) {
var at = localStorage.getItem("spotify"); var at = localStorage.getItem("spotify");
if (at) { if (at) {
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
} }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
console.table(json); console.table(json);
if (json.length < 1) { if (json.length < 1) {
return false; return false;
@ -84,7 +86,7 @@ function nowplaying(mode) {
var img = item.album.images[0].url; var img = item.album.images[0].url;
var flag = localStorage.getItem("artwork"); var flag = localStorage.getItem("artwork");
if (flag) { if (flag) {
postMessage(["bmpImage", [img, 0]], "*") postMessage(["bmpImage", [img, 0]], "*");
} }
var content = localStorage.getItem("np-temp"); var content = localStorage.getItem("np-temp");
if (!content || content == "" || content == "null") { if (!content || content == "" || content == "null") {
@ -114,12 +116,12 @@ function nowplaying(mode) {
}); });
} else { } else {
Swal.fire({ Swal.fire({
type: 'info', type: "info",
title: lang.lang_spotify_acct title: lang.lang_spotify_acct
}) });
} }
} else if (mode == "itunes") { } else if (mode == "itunes") {
postMessage(["itunes", ""], "*") postMessage(["itunes", ""], "*");
} }
} }
function npCore(arg) { function npCore(arg) {
@ -172,7 +174,7 @@ function npCore(arg) {
function spotifySave() { function spotifySave() {
var temp = $("#np-temp").val(); var temp = $("#np-temp").val();
localStorage.setItem("np-temp", temp); localStorage.setItem("np-temp", temp);
M.toast({ html: lang.lang_spotify_np, displayLength: 3000 }) M.toast({ html: lang.lang_spotify_np, displayLength: 3000 });
} }
if (location.search) { if (location.search) {
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/); var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
@ -183,7 +185,5 @@ if (location.search) {
localStorage.setItem("spotify", coder[0]); localStorage.setItem("spotify", coder[0]);
localStorage.setItem("spotify-refresh", coder[1]); localStorage.setItem("spotify-refresh", coder[1]);
} else { } else {
} }
} }

View File

@ -2,93 +2,96 @@
var todcTrigger = null; var todcTrigger = null;
function todo(mes) { function todo(mes) {
clearInterval(todcTrigger); clearInterval(todcTrigger);
$('#message').text(mes); $("#message").text(mes);
$('#message').fadeIn(); $("#message").fadeIn();
todcTrigger = setTimeout(todc, 4000); todcTrigger = setTimeout(todc, 4000);
} }
function todc() { function todc() {
$('#message').fadeOut(); $("#message").fadeOut();
} }
//reverse //reverse
function bottomReverse() { function bottomReverse() {
$("#bottom").toggleClass("reverse"); $("#bottom").toggleClass("reverse");
$(".leftside").toggleClass("reverse"); $(".leftside").toggleClass("reverse");
if ($("#bottom").hasClass("reverse")) { if ($("#bottom").hasClass("reverse")) {
localStorage.removeItem("reverse") localStorage.removeItem("reverse");
} else { } else {
localStorage.setItem("reverse", "true") localStorage.setItem("reverse", "true");
} }
} }
function tips(mode) { function tips(mode) {
postMessage(["sendSinmpleIpc", "endmem"], "*") postMessage(["sendSinmpleIpc", "endmem"], "*");
clearInterval(clockint); clearInterval(clockint);
clearInterval(spotStart); clearInterval(spotStart);
if (mode == "ver") { if (mode == "ver") {
tipsToggle() tipsToggle();
$("#tips-text").html('<img src="../../img/desk.png" width="20" onclick="todo(\'TheDesk is a nice client!: TheDesk ' + localStorage.getItem("ver") + ' git: '+ gitHash +'\')">TheDesk ' + localStorage.getItem("ver") + ' {'+ gitHash.slice(0, 7) +'} [<i class="material-icons" style="font-size:1.2rem;top: 3px;position: relative;">supervisor_account</i><span id="persons">1+</span>]') $("#tips-text").html('<img src="../../img/desk.png" width="20" onclick="todo(\'TheDesk is a nice client!: TheDesk ' + localStorage.getItem("ver") + " git: " + gitHash + "')\">TheDesk " + localStorage.getItem("ver") + " {" + gitHash.slice(0, 7) + '} [<i class="material-icons" style="font-size:1.2rem;top: 3px;position: relative;">supervisor_account</i><span id="persons">1+</span>]');
localStorage.setItem("tips", "ver") localStorage.setItem("tips", "ver");
} else if (mode == "clock") { } else if (mode == "clock") {
tipsToggle() tipsToggle();
localStorage.setItem("tips", "clock") localStorage.setItem("tips", "clock");
clock() clock();
} else if (mode == "memory") { } else if (mode == "memory") {
tipsToggle() tipsToggle();
localStorage.setItem("tips", "memory") localStorage.setItem("tips", "memory");
startmem(); startmem();
} else if (mode == "trend") { } else if (mode == "trend") {
tipsToggle() tipsToggle();
localStorage.setItem("tips", "trend") localStorage.setItem("tips", "trend");
trendTagonTip() trendTagonTip();
} else if (mode == "spotify") { } else if (mode == "spotify") {
tipsToggle() tipsToggle();
localStorage.setItem("tips", "spotify") localStorage.setItem("tips", "spotify");
var json = nowplaying("spotifytips") var json = nowplaying("spotifytips");
spotifytips(json) spotifytips(json);
} }
} }
//メモリ //メモリ
function startmem() { function startmem() {
postMessage(["sendSinmpleIpc", "startmem"], "*") postMessage(["sendSinmpleIpc", "startmem"], "*");
} }
function renderMem(use, cpu, total) { function renderMem(use, cpu, total) {
$("#tips-text").html(escapeHTML(cpu) + "<br>Memory:" + Math.floor(use / 1024 / 1024 / 102.4) / 10 + "/" + Math.floor(total / 1024 / 1024 / 102.4) / 10 + "GB(" + Math.floor(use / total * 100) + "%)") $("#tips-text").html(escapeHTML(cpu) + "<br>Memory:" + Math.floor(use / 1024 / 1024 / 102.4) / 10 + "/" + Math.floor(total / 1024 / 1024 / 102.4) / 10 + "GB(" + Math.floor((use / total) * 100) + "%)");
} }
//トレンドタグ //トレンドタグ
function trendTagonTip() { function trendTagonTip() {
$(".trendtag").remove(); $(".trendtag").remove();
var domain = "imastodon.net" var domain = "imastodon.net";
var at = localStorage.getItem("acct_" + acct_id + "_at"); var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/trend_tags" var start = "https://" + domain + "/api/v1/trend_tags";
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json', "content-type": "application/json",
'Authorization': 'Bearer ' + at Authorization: "Bearer " + at
}, }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
if (json) { if (json) {
var tags = ""; var tags = "";
json = json.score; json = json.score;
Object.keys(json).forEach(function(tag) { Object.keys(json).forEach(function(tag) {
tags = tags + '<a onclick="tagShow(\'' + tag + '\')" class="pointer">#' + escapeHTML(tag) + '</a><span class="hide" data-tag="' + tag + '"> <a onclick="tagTL(\'tag\',\'' + tag + '\',false,\'add\')" class="pointer" title="#' + tag + 'のタイムライン">TL</a> <a onclick="show();brInsert(\'#' + tag + '\')" class="pointer" title="#' + tag + 'でトゥート">Toot</a></span><br>'; tags = tags + "<a onclick=\"tagShow('" + tag + '\')" class="pointer">#' + escapeHTML(tag) + '</a><span class="hide" data-tag="' + tag + "\"> <a onclick=\"tagTL('tag','" + tag + '\',false,\'add\')" class="pointer" title="#' + tag + 'のタイムライン">TL</a> <a onclick="show();brInsert(\'#' + tag + '\')" class="pointer" title="#' + tag + 'でトゥート">Toot</a></span><br>';
}); });
$("#tips-text").html('<div class="trendtag">トレンドタグ<i class="material-icons pointer" onclick="trendTagonTip()" style="font-size:12px">refresh</i>:<br>' + tags + '</div>'); $("#tips-text").html('<div class="trendtag">トレンドタグ<i class="material-icons pointer" onclick="trendTagonTip()" style="font-size:12px">refresh</i>:<br>' + tags + "</div>");
trendTagonTipInterval() trendTagonTipInterval();
} else { } else {
$("#tips-text").html(""); $("#tips-text").html("");
} }
}); });
} }
//Spotify //Spotify
function spotifytips() { function spotifytips() {
@ -96,23 +99,27 @@ function spotifytips() {
var at = localStorage.getItem("spotify"); var at = localStorage.getItem("spotify");
if (at) { if (at) {
fetch(start, { fetch(start, {
method: 'GET', method: "GET",
headers: { headers: {
'content-type': 'application/json' "content-type": "application/json"
} }
}).then(function (response) { })
.then(function(response) {
if (!response.ok) { if (!response.ok) {
response.text().then(function(text) { response.text().then(function(text) {
setLog(response.url, response.status, text); setLog(response.url, response.status, text);
}); });
} }
return response.json(); return response.json();
}).catch(function (error) { })
.catch(function(error) {
todo(error); todo(error);
setLog(start, "JSON", error);
console.error(error); console.error(error);
}).then(function (json) { })
.then(function(json) {
var ms = json.progress_ms; var ms = json.progress_ms;
var last = 1000 - ms % 1000; var last = 1000 - (ms % 1000);
var item = json.item; var item = json.item;
var img = item.album.images[0].url; var img = item.album.images[0].url;
var artisttxt = ""; var artisttxt = "";
@ -126,34 +133,34 @@ function spotifytips() {
artisttxt = escapeHTML(artisttxt); artisttxt = escapeHTML(artisttxt);
sleep(last); sleep(last);
var tms = item.duration_ms; var tms = item.duration_ms;
var per = ms / item.duration_ms * 100; var per = (ms / item.duration_ms) * 100;
ms = ms / 1000; ms = ms / 1000;
tms = tms / 1000; tms = tms / 1000;
var s = Math.round(ms) % 60; var s = Math.round(ms) % 60;
if (s < 10) { if (s < 10) {
s = "0" + s; s = "0" + s;
} }
var m = (Math.round(ms) - Math.round(ms) % 60) / 60; var m = (Math.round(ms) - (Math.round(ms) % 60)) / 60;
var ts = Math.round(tms) % 60; var ts = Math.round(tms) % 60;
if (ts < 10) { if (ts < 10) {
ts = "0" + ts; ts = "0" + ts;
} }
var tm = (Math.round(tms) - Math.round(tms) % 60) / 60; var tm = (Math.round(tms) - (Math.round(tms) % 60)) / 60;
$("#tips-text").html('<div id="spot-box"><i class="material-icons pointer" onclick="spotifytips()" style="font-size:12px">refresh</i><img src="' + img + '" width="20" id="spot-img">' + escapeHTML(item.name) + '<span class="gray sml" id="spot-art">' + artisttxt + '</span><span id="spot-m">' + m + '</span>:<span id="spot-s">' + s + '</span>/' + tm + ":" + ts + '</span></div><div class="progress grey"><div class="determinate spotify-prog grey lighten-2" style="width: ' + per + '%" data-s="' + Math.round(ms) + '" data-total="' + item.duration_ms + '"></div></div>'); $("#tips-text").html('<div id="spot-box"><i class="material-icons pointer" onclick="spotifytips()" style="font-size:12px">refresh</i><img src="' + img + '" width="20" id="spot-img">' + escapeHTML(item.name) + '<span class="gray sml" id="spot-art">' + artisttxt + '</span><span id="spot-m">' + m + '</span>:<span id="spot-s">' + s + "</span>/" + tm + ":" + ts + '</span></div><div class="progress grey"><div class="determinate spotify-prog grey lighten-2" style="width: ' + per + '%" data-s="' + Math.round(ms) + '" data-total="' + item.duration_ms + '"></div></div>');
spotint = setInterval(spotStart, 1000); spotint = setInterval(spotStart, 1000);
}); });
} else { } else {
Swal.fire({ Swal.fire({
type: 'info', type: "info",
title: lang.lang_spotify_acct title: lang.lang_spotify_acct
}) });
} }
} }
function spotStart() { function spotStart() {
var total = $(".spotify-prog").attr("data-total"); var total = $(".spotify-prog").attr("data-total");
var s = $(".spotify-prog").attr("data-s"); var s = $(".spotify-prog").attr("data-s");
var news = s * 1 + 1; var news = s * 1 + 1;
var per = news * 100000 / total; var per = (news * 100000) / total;
var ns = news % 60; var ns = news % 60;
var nm = (news - ns) / 60; var nm = (news - ns) / 60;
if (ns < 10) { if (ns < 10) {
@ -161,7 +168,7 @@ function spotStart() {
} }
if (per >= 100) { if (per >= 100) {
clearInterval(spotStart); clearInterval(spotStart);
spotifytips() spotifytips();
} else { } else {
$("#spot-m").text(nm); $("#spot-m").text(nm);
$("#spot-s").text(ns); $("#spot-s").text(ns);
@ -170,7 +177,6 @@ function spotStart() {
$(".spotify-prog").css("width", per + "%"); $(".spotify-prog").css("width", per + "%");
} }
function trendTagonTipInterval() { function trendTagonTipInterval() {
setTimeout(trendTagonTip, 6000000); setTimeout(trendTagonTip, 6000000);
} }
@ -178,18 +184,24 @@ function trendTagonTipInterval() {
var clockint; var clockint;
function clock() { function clock() {
var now = new Date(); var now = new Date();
var last = 1000 - now.getTime() % 1000; var last = 1000 - (now.getTime() % 1000);
sleep(last); sleep(last);
clockint = setInterval(clockStart, 1000); clockint = setInterval(clockStart, 1000);
} }
function clockStart() { function clockStart() {
var nowTime = new Date(); // 現在日時を得る var nowTime = new Date(); // 現在日時を得る
var nowHour = nowTime.getHours(); // 時を抜き出す var nowHour = nowTime.getHours(); // 時を抜き出す
if (nowHour < 10) { nowHour = "0" + nowHour } if (nowHour < 10) {
nowHour = "0" + nowHour;
}
var nowMin = nowTime.getMinutes(); // 分を抜き出す var nowMin = nowTime.getMinutes(); // 分を抜き出す
if (nowMin < 10) { nowMin = "0" + nowMin } if (nowMin < 10) {
nowMin = "0" + nowMin;
}
var nowSec = nowTime.getSeconds(); // 秒を抜き出す var nowSec = nowTime.getSeconds(); // 秒を抜き出す
if (nowSec < 10) { nowSec = "0" + nowSec } if (nowSec < 10) {
nowSec = "0" + nowSec;
}
var msg = nowTime.getFullYear() + "/" + (nowTime.getMonth() + 1) + "/" + nowTime.getDate() + '<span style="font-size:20px; font-family:Open Sans">' + nowHour + ":" + nowMin + ":" + nowSec + "</span>"; var msg = nowTime.getFullYear() + "/" + (nowTime.getMonth() + 1) + "/" + nowTime.getDate() + '<span style="font-size:20px; font-family:Open Sans">' + nowHour + ":" + nowMin + ":" + nowSec + "</span>";
$("#tips-text").html(msg); $("#tips-text").html(msg);
} }

View File

@ -256,13 +256,24 @@ function system(mainWindow, dir, lang, dirname) {
}); });
ipc.on("getLogs", (e, arg) => { ipc.on("getLogs", (e, arg) => {
var logs="" var logs=""
var todayLog=""
var yestLog=""
var yest2Log=""
fs.readdir(log_dir_path, function(err, files) { fs.readdir(log_dir_path, function(err, files) {
if (err) throw err; if (err) throw err;
files.filter(function(file) { files.filter(function(file) {
if (file == todayStr || file == yestStr || file == yest2Str) { if (file == todayStr) {
logs=logs+fs.readFileSync(join(log_dir_path, file), "utf8") todayLog=fs.readFileSync(join(log_dir_path, file), "utf8")
} }
if (file == yestStr) {
yestLog=logs+fs.readFileSync(join(log_dir_path, file), "utf8")
}
if (file == yest2Str) {
yest2Log=fs.readFileSync(join(log_dir_path, file), "utf8")
}
logs = todayLog + yestLog + yest2Log;
}); });
logs = yest2Log + yestLog + todayLog;
e.sender.webContents.send("logData", logs); e.sender.webContents.send("logData", logs);
}); });
}); });

View File

@ -156,7 +156,7 @@
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function(json) {
@ -228,7 +228,7 @@
return response.json(); return response.json();
}) })
.catch(function(error) { .catch(function(error) {
todo(error); todo(error);setLog(start, "JSON", error);
console.error(error); console.error(error);
}) })
.then(function(json) { .then(function(json) {