From ffa4ecd673d2042512104858d3cf5594e6262426 Mon Sep 17 00:00:00 2001
From: cutls
Date: Mon, 4 Nov 2019 01:10:06 +0900
Subject: [PATCH] Add: JSON parse miss error-log
---
app/js/common/version.js | 5 +-
app/js/login/login.js | 545 ++++++++++----------
app/js/login/manager.js | 101 ++--
app/js/post/emoji.js | 334 ++++++------
app/js/post/img.js | 19 +-
app/js/post/misskeystatus.js | 455 +++++++++--------
app/js/tl/card.js | 285 ++++++-----
app/js/tl/datails.js | 850 ++++++++++++++++---------------
app/js/tl/directory.js | 134 ++---
app/js/tl/dm.js | 240 ++++-----
app/js/tl/filter.js | 425 ++++++++--------
app/js/tl/list.js | 444 ++++++++--------
app/js/tl/mix.js | 354 ++++++-------
app/js/tl/notification.js | 311 +++++------
app/js/tl/old-mix.js | 379 +++++++-------
app/js/tl/src.js | 354 ++++++-------
app/js/tl/tag.js | 275 +++++-----
app/js/tl/tl.js | 790 ++++++++++++++--------------
app/js/ui/settings.js | 512 ++++++++++---------
app/js/ui/spotify.js | 340 ++++++-------
app/js/ui/tips.js | 222 ++++----
app/main/system.js | 15 +-
app/view/make/update.sample.html | 4 +-
23 files changed, 3799 insertions(+), 3594 deletions(-)
diff --git a/app/js/common/version.js b/app/js/common/version.js
index 1fbfe991..61960d6d 100644
--- a/app/js/common/version.js
+++ b/app/js/common/version.js
@@ -92,7 +92,8 @@ function verck(ver, jp) {
return response.json();
})
.catch(function(error) {
- todo(error);
+ todo(error);setLog(start, "JSON", error);
+ setLog(start, "JSON", error);
console.error(error);
})
.then(function(mess) {
@@ -144,7 +145,7 @@ function verck(ver, jp) {
return response.json();
})
.catch(function(error) {
- todo(error);
+ todo(error);setLog(start, "JSON", error);
console.error(error);
})
.then(function(mess) {
diff --git a/app/js/login/login.js b/app/js/login/login.js
index 79260023..6ff69574 100644
--- a/app/js/login/login.js
+++ b/app/js/login/login.js
@@ -2,18 +2,18 @@
//最初に読むやつ
//アスタルテ判定初期化
-localStorage.removeItem("kirishima")
-localStorage.removeItem("quoters")
-localStorage.removeItem("imas")
+localStorage.removeItem("kirishima");
+localStorage.removeItem("quoters");
+localStorage.removeItem("imas");
localStorage.removeItem("image");
-localStorage.removeItem("stable")
-localStorage.setItem("mode_misskey.xyz", "misskey")
+localStorage.removeItem("stable");
+localStorage.setItem("mode_misskey.xyz", "misskey");
function ck() {
var main = localStorage.getItem("main");
if (!main) {
- localStorage.setItem("main", 0)
+ localStorage.setItem("main", 0);
}
-
+
//コード受信
if (location.search) {
var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
@@ -27,18 +27,18 @@ function ck() {
var multi = localStorage.getItem("multi");
if (!multi || multi == "[]") {
var date = new Date();
- localStorage.setItem("showSupportMe", date.getMonth() + 2)
- location.href = "acct.html?mode=first&code=true"
+ localStorage.setItem("showSupportMe", date.getMonth() + 2);
+ location.href = "acct.html?mode=first&code=true";
} else {
var obj = JSON.parse(multi);
- var jp=false
- Object.keys(obj).forEach(function (key) {
+ var jp = false;
+ Object.keys(obj).forEach(function(key) {
var acct = obj[key];
if (acct.domain) {
- refresh(key, true)
+ refresh(key, true);
}
- if(acct.domain=="mstdn.jp"){
- jp=true
+ if (acct.domain == "mstdn.jp") {
+ jp = true;
}
});
if (obj[0].domain) {
@@ -46,53 +46,54 @@ function ck() {
ticker();
multiSelector(false);
verck(ver, jp);
- $(".stw").show()
- $("#something-wrong img").attr("src", "../../img/thinking.svg")
+ $(".stw").show();
+ $("#something-wrong img").attr("src", "../../img/thinking.svg");
}
}
}
ck();
-
//ログインポップアップ
function login(url) {
- if ($('#linux:checked').val() == "on") {
- var red = "urn:ietf:wg:oauth:2.0:oob"
+ if ($("#linux:checked").val() == "on") {
+ var red = "urn:ietf:wg:oauth:2.0:oob";
} else {
- var red = 'thedesk://login';
+ var red = "thedesk://login";
}
localStorage.setItem("redirect", red);
var start = "https://" + url + "/api/v1/apps";
var httpreq = new XMLHttpRequest();
- httpreq.open('POST', start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
+ httpreq.open("POST", start, true);
+ httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.responseType = "json";
- httpreq.send(JSON.stringify({
- scopes: 'read write follow',
- client_name: "TheDesk(PC)",
- redirect_uris: red,
- website: "https://thedesk.top"
- }));
- httpreq.onreadystatechange = function () {
+ httpreq.send(
+ JSON.stringify({
+ scopes: "read write follow",
+ client_name: "TheDesk(PC)",
+ redirect_uris: red,
+ website: "https://thedesk.top"
+ })
+ );
+ httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
- if(this.status!==200){ setLog(start, this.status, json); }
- var auth = "https://" + url + "/oauth/authorize?client_id=" + json[
- "client_id"] + "&client_secret=" + json["client_secret"] +
- "&response_type=code&redirect_uri=" + red + "&scope=read+write+follow";
+ if (this.status !== 200) {
+ setLog(start, this.status, json);
+ }
+ var auth = "https://" + url + "/oauth/authorize?client_id=" + json["client_id"] + "&client_secret=" + json["client_secret"] + "&response_type=code&redirect_uri=" + red + "&scope=read+write+follow";
localStorage.setItem("domain_" + acct_id, url);
localStorage.setItem("client_id", json["client_id"]);
localStorage.setItem("client_secret", json["client_secret"]);
$("#auth").show();
$("#masara").hide();
- postMessage(["openUrl", auth], "*")
+ postMessage(["openUrl", auth], "*");
- if ($('#linux:checked').val() == "on") {
+ if ($("#linux:checked").val() == "on") {
} else {
- postMessage(["sendSinmpleIpc", "quit"], "*")
+ postMessage(["sendSinmpleIpc", "quit"], "*");
}
}
- }
+ };
}
//テキストボックスにURL入れた
@@ -101,11 +102,10 @@ function instance() {
login(url);
}
-
//コードを入れた後認証
function code(code, mode) {
var red = localStorage.getItem("redirect");
- localStorage.removeItem("redirect")
+ localStorage.removeItem("redirect");
if (!code) {
var code = $("#code").val();
}
@@ -118,9 +118,9 @@ function code(code, mode) {
var id = localStorage.getItem("client_id");
var secret = localStorage.getItem("client_secret");
fetch(start, {
- method: 'POST',
+ method: "POST",
headers: {
- 'content-type': 'application/json'
+ "content-type": "application/json"
},
body: JSON.stringify({
grant_type: "authorization_code",
@@ -129,28 +129,31 @@ function code(code, mode) {
client_secret: secret,
code: code
})
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- todo(json);
- if (json["access_token"]) {
- localStorage.setItem(url + "_at", json["access_token"]);
- if (mode == "manager") {
- getdataAdv(url, json["access_token"]);
- } else {
- getdata();
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
-
- }
- });
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ todo(json);
+ if (json["access_token"]) {
+ localStorage.setItem(url + "_at", json["access_token"]);
+ if (mode == "manager") {
+ getdataAdv(url, json["access_token"]);
+ } else {
+ getdata();
+ }
+ }
+ });
}
//ユーザーデータ取得(最初)
@@ -160,173 +163,186 @@ function getdata() {
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/accounts/verify_credentials";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json.error) {
- console.error("Error:" + json.error);
- M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 })
- return;
- }
- var avatar = json["avatar"];
- //missingがmissingなやつ
- if (avatar == "/avatars/original/missing.png") {
- avatar = "./img/missing.svg";
- }
- var obj = [{
- at: at,
- name: json["display_name"],
- domain: domain,
- user: json["acct"],
- prof: avatar,
- id: json["id"],
- vis: json["source"]["privacy"]
- }];
- var json = JSON.stringify(obj);
- localStorage.setItem("multi", json);
- localStorage.setItem("name_" + acct_id, json["display_name"]);
- localStorage.setItem("user_" + acct_id, json["acct"]);
- localStorage.setItem("user-id_" + acct_id, json["id"]);
- localStorage.setItem("prof_" + acct_id, avatar);
- $("#masara").hide();
- $("#auth").hide();
- $("#tl").show();
- parseColumn()
- ckdb();
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json.error) {
+ console.error("Error:" + json.error);
+ M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 });
+ return;
+ }
+ var avatar = json["avatar"];
+ //missingがmissingなやつ
+ if (avatar == "/avatars/original/missing.png") {
+ avatar = "./img/missing.svg";
+ }
+ var obj = [
+ {
+ at: at,
+ name: json["display_name"],
+ domain: domain,
+ user: json["acct"],
+ prof: avatar,
+ id: json["id"],
+ vis: json["source"]["privacy"]
+ }
+ ];
+ var json = JSON.stringify(obj);
+ localStorage.setItem("multi", json);
+ localStorage.setItem("name_" + acct_id, json["display_name"]);
+ localStorage.setItem("user_" + acct_id, json["acct"]);
+ localStorage.setItem("user-id_" + acct_id, json["id"]);
+ localStorage.setItem("prof_" + acct_id, avatar);
+ $("#masara").hide();
+ $("#auth").hide();
+ $("#tl").show();
+ parseColumn();
+ ckdb();
+ });
}
//ユーザーデータ取得(追加)
function getdataAdv(domain, at) {
var start = "https://" + domain + "/api/v1/accounts/verify_credentials";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json.error) {
- console.error("Error:" + json.error);
- M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 })
- return;
- }
- var avatar = json["avatar"];
- //missingがmissingなやつ
- if (avatar == "/avatars/original/missing.png") {
- avatar = "../../img/missing.svg";
- }
- if (json["source"]["privacy"]) {
- var priv = json["source"]["privacy"];
- } else {
- var priv = "public";
- }
- var add = {
- at: at,
- name: json["display_name"],
- domain: domain,
- user: json["acct"],
- prof: avatar,
- id: json["id"],
- vis: priv
- };
- var multi = localStorage.getItem("multi");
- var obj = JSON.parse(multi);
- var target = obj.lengtth;
- obj.push(add);
- localStorage.setItem("name_" + target, json["display_name"]);
- localStorage.setItem("user_" + target, json["acct"]);
- localStorage.setItem("user-id_" + target, json["id"]);
- localStorage.setItem("prof_" + target, avatar);
- var json = JSON.stringify(obj);
- localStorage.setItem("multi", json);
- location.href = "index.html";
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json.error) {
+ console.error("Error:" + json.error);
+ M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 });
+ return;
+ }
+ var avatar = json["avatar"];
+ //missingがmissingなやつ
+ if (avatar == "/avatars/original/missing.png") {
+ avatar = "../../img/missing.svg";
+ }
+ if (json["source"]["privacy"]) {
+ var priv = json["source"]["privacy"];
+ } else {
+ var priv = "public";
+ }
+ var add = {
+ at: at,
+ name: json["display_name"],
+ domain: domain,
+ user: json["acct"],
+ prof: avatar,
+ id: json["id"],
+ vis: priv
+ };
+ var multi = localStorage.getItem("multi");
+ var obj = JSON.parse(multi);
+ var target = obj.lengtth;
+ obj.push(add);
+ localStorage.setItem("name_" + target, json["display_name"]);
+ localStorage.setItem("user_" + target, json["acct"]);
+ localStorage.setItem("user-id_" + target, json["id"]);
+ localStorage.setItem("prof_" + target, avatar);
+ var json = JSON.stringify(obj);
+ localStorage.setItem("multi", json);
+ location.href = "index.html";
+ });
}
//ユーザーデータ更新
function refresh(target, loadskip) {
var multi = localStorage.getItem("multi");
var obj = JSON.parse(multi);
if (obj[target].mode == "misskey") {
- return
+ return;
}
- var start = "https://" + obj[target].domain +
- "/api/v1/accounts/verify_credentials";
+ var start = "https://" + obj[target].domain + "/api/v1/accounts/verify_credentials";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + obj[target].at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + obj[target].at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json.error) {
- console.error("Error:" + json.error);
- M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 })
- return;
- }
- var avatar = json["avatar"];
- //missingがmissingなやつ
- if (avatar == "/avatars/original/missing.png" || !avatar) {
- avatar = "./img/missing.svg";
- }
- var ref = {
- at: obj[target].at,
- name: json["display_name"],
- domain: obj[target].domain,
- user: json["acct"],
- prof: avatar,
- id: json["id"],
- vis: json["source"]["privacy"]
- };
- localStorage.setItem("name_" + target, json["display_name"]);
- localStorage.setItem("user_" + target, json["acct"]);
- localStorage.setItem("user-id_" + target, json["id"]);
- localStorage.setItem("prof_" + target, avatar);
- localStorage.setItem("follow_" + target, json["following_count"]);
- if(json["source"]["sensitive"]){
- localStorage.setItem("nsfw_" + target, "true");
- }else{
- localStorage.removeItem("nsfw_" + target);
- }
- obj[target] = ref;
- var json = JSON.stringify(obj);
- localStorage.setItem("multi", json);
- if (!loadskip) {
- load();
- }
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json.error) {
+ console.error("Error:" + json.error);
+ M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 });
+ return;
+ }
+ var avatar = json["avatar"];
+ //missingがmissingなやつ
+ if (avatar == "/avatars/original/missing.png" || !avatar) {
+ avatar = "./img/missing.svg";
+ }
+ var ref = {
+ at: obj[target].at,
+ name: json["display_name"],
+ domain: obj[target].domain,
+ user: json["acct"],
+ prof: avatar,
+ id: json["id"],
+ vis: json["source"]["privacy"]
+ };
+ localStorage.setItem("name_" + target, json["display_name"]);
+ localStorage.setItem("user_" + target, json["acct"]);
+ localStorage.setItem("user-id_" + target, json["id"]);
+ localStorage.setItem("prof_" + target, avatar);
+ localStorage.setItem("follow_" + target, json["following_count"]);
+ if (json["source"]["sensitive"]) {
+ localStorage.setItem("nsfw_" + target, "true");
+ } else {
+ localStorage.removeItem("nsfw_" + target);
+ }
+ obj[target] = ref;
+ var json = JSON.stringify(obj);
+ localStorage.setItem("multi", json);
+ if (!loadskip) {
+ load();
+ }
+ });
}
//MarkdownやBBCodeの対応、文字数制限をチェック
//絶対ストリーミングを閉じさせないマン
@@ -408,35 +424,35 @@ function ckdb(acct_id) {
if (localStorage.getItem("mode_" + domain) != "misskey") {
var start = "https://" + domain + "/api/v1/instance";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json'
- },
- }).then(function (response) {
- return response.json();
- }).catch(function (error) {
- console.error(error);
- }).then(function (json) {
- if (json.error) {
- console.error(json.error);
- return;
+ "content-type": "application/json"
}
- if (json) {
- if (json["max_toot_chars"]) {
- localStorage.setItem("letters_" + acct_id, json["max_toot_chars"]);
+ })
+ .then(function(response) {
+ return response.json();
+ })
+ .catch(function(error) {
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json.error) {
+ console.error(json.error);
+ return;
}
- if (json["urls"]["streaming_api"]) {
- localStorage.setItem("streaming_" + acct_id, json["urls"]["streaming_api"]);
- }else{
- localStorage.removeItem("streaming_" + acct_id);
+ if (json) {
+ if (json["max_toot_chars"]) {
+ localStorage.setItem("letters_" + acct_id, json["max_toot_chars"]);
+ }
+ if (json["urls"]["streaming_api"]) {
+ localStorage.setItem("streaming_" + acct_id, json["urls"]["streaming_api"]);
+ } else {
+ localStorage.removeItem("streaming_" + acct_id);
+ }
}
- }
- });
-
+ });
} else {
}
-
-
}
//アカウントを選択…を実装
@@ -464,27 +480,27 @@ function multiSelector(parseC) {
var sel;
if (obj.length < 1) {
$("#src-acct-sel").html('');
- $("#add-acct-sel").html('');
+ $("#add-acct-sel").html('");
} else {
- Object.keys(obj).forEach(function (key) {
+ Object.keys(obj).forEach(function(key) {
var acct = obj[key];
var list = key * 1 + 1;
- if (key+"" === last) {
+ if (key + "" === last) {
sel = "selected";
var domain = acct.domain;
localStorage.setItem("domain_" + key, domain);
if (idata[domain + "_letters"]) {
- $("#textarea").attr("data-length", idata[domain + "_letters"])
+ $("#textarea").attr("data-length", idata[domain + "_letters"]);
} else {
var maxletters = localStorage.getItem("letters_" + key);
if (maxletters > 0) {
- $("#textarea").attr("data-length", maxletters)
+ $("#textarea").attr("data-length", maxletters);
} else {
- $("#textarea").attr("data-length", 500)
+ $("#textarea").attr("data-length", 500);
}
}
if (idata[domain + "_glitch"]) {
- $("#local-button").removeClass("hide")
+ $("#local-button").removeClass("hide");
}
var profimg = acct.prof;
//localStorage.setItem("prof_" + key, profimg);
@@ -517,18 +533,15 @@ function multiSelector(parseC) {
} else {
sel = "";
}
- templete = '';
+ templete = '";
$(".acct-sel").append(templete);
-
});
$("#src-acct-sel").append('');
$("#add-acct-sel").append('');
- $("#dir-acct-sel").append('');
+ $("#dir-acct-sel").append('");
}
- $('select').formSelect();
- if(!parseC){
+ $("select").formSelect();
+ if (!parseC) {
parseColumn(null, true);
}
}
@@ -546,23 +559,25 @@ function enc(ver) {
function ticker() {
var start = "https://toot.app/toot/";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json'
- },
- }).then(function (response) {
-
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json"
}
- return response.json();
- }).catch(function (error) {
- console.error(error);
- }).then(function (json) {
- if (json) {
- localStorage.setItem("ticker", JSON.stringify(json));
- }
- });
-}
\ No newline at end of file
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ localStorage.setItem("ticker", JSON.stringify(json));
+ }
+ });
+}
diff --git a/app/js/login/manager.js b/app/js/login/manager.js
index fc7ee277..225c0aef 100644
--- a/app/js/login/manager.js
+++ b/app/js/login/manager.js
@@ -86,14 +86,15 @@ function data(domain) {
})
.then(function(response) {
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
+ setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
@@ -120,14 +121,15 @@ function data(domain) {
})
.then(function(response) {
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
+ setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
@@ -330,7 +332,9 @@ function login(url) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
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");
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);
@@ -357,14 +361,15 @@ function versionChecker(url) {
})
.then(function(response) {
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
+ setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
@@ -395,14 +400,15 @@ function versionCompat(prefix, ver, title, real) {
})
.then(function(response) {
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
+ setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
@@ -458,7 +464,9 @@ function misskeyLogin(url) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
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);
}
};
@@ -480,7 +488,9 @@ function misskeyAuth(url, mkc) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
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;
$("#auth").show();
$("#code").val(token);
@@ -530,7 +540,9 @@ function code(code) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
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 avatar = json["user"]["avatarUrl"];
var priv = "public";
@@ -587,7 +599,9 @@ function code(code) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
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"]) {
$("#auth").hide();
$("#add").show();
@@ -609,14 +623,15 @@ function getdata(domain, at) {
})
.then(function(response) {
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
+ setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
@@ -734,14 +749,15 @@ function refresh(target) {
});
}
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
+ setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
@@ -795,7 +811,9 @@ function misskeyRefresh(obj, target, url) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
- if(this.status!==200){ setLog(start, this.status, json); }
+ if (this.status !== 200) {
+ setLog(start, this.status, json);
+ }
var avatar = json["user"]["avatarUrl"];
var priv = "public";
var add = {
@@ -921,14 +939,15 @@ input.addEventListener(
})
.then(function(response) {
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
+ setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
diff --git a/app/js/post/emoji.js b/app/js/post/emoji.js
index d387d005..6f10b382 100644
--- a/app/js/post/emoji.js
+++ b/app/js/post/emoji.js
@@ -6,181 +6,186 @@ $("#emoji-next").addClass("disabled");
//絵文字ボタンのトグル
function emojiToggle(reaction) {
var acct_id = $("#post-acct-sel").val();
- var selin = $("#textarea").prop('selectionStart');
+ var selin = $("#textarea").prop("selectionStart");
if (!selin) {
selin = 0;
}
if ($("#emoji").hasClass("hide")) {
- $("#emoji").removeClass("hide")
- $("#right-side").show()
- $("#right-side").css("width", "300px")
- $("#left-side").css("width", "calc(100% - 300px)")
+ $("#emoji").removeClass("hide");
+ $("#right-side").show();
+ $("#right-side").css("width", "300px");
+ $("#left-side").css("width", "calc(100% - 300px)");
var width = localStorage.getItem("postbox-width");
if (width) {
- width = width.replace("px", "") * 1 + 300
+ width = width.replace("px", "") * 1 + 300;
} else {
- width = 600
+ width = 600;
}
- $("#post-box").css("width", width + "px")
+ $("#post-box").css("width", width + "px");
$("#suggest").html("");
if (!localStorage.getItem("emojis_" + acct_id)) {
- var html =
- '';
+ var html = '";
$("#emoji-list").html(html);
} else {
- emojiList('home', reaction);
+ emojiList("home", reaction);
}
} else {
- $("#poll").addClass("hide")
- $("#right-side").hide()
- $("#right-side").css("width", "300px")
- $("#emoji").addClass("hide")
+ $("#poll").addClass("hide");
+ $("#right-side").hide();
+ $("#right-side").css("width", "300px");
+ $("#emoji").addClass("hide");
$("#suggest").html("");
- $("#left-side").css("width", "100%")
+ $("#left-side").css("width", "100%");
var width = localStorage.getItem("postbox-width");
if (width) {
- width = width.replace("px", "") * 1
+ width = width.replace("px", "") * 1;
} else {
- width = 300
+ width = 300;
}
- $("#post-box").css("width", width + "px")
+ $("#post-box").css("width", width + "px");
}
-
-
}
//絵文字リスト挿入
function emojiGet(parse, started) {
- $('#emoji-list').text('Loading...');
+ $("#emoji-list").text("Loading...");
var acct_id = $("#post-acct-sel").val();
var domain = localStorage.getItem("domain_" + acct_id);
if (localStorage.getItem("mode_" + domain) != "misskey") {
var start = "https://" + domain + "/api/v1/custom_emojis";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json'
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (parse == "true") {
- $('#emoji-list').text('Parsing...');
- var md = {
- "categorized": {},
- "uncategorized": []
- };
- var if_categorized = false
- Object.keys(json).forEach(function (key) {
- var emoji = json[key];
- if (emoji.visible_in_picker) {
- var listed = true
- } else {
- var listed = false
- }
- if (emoji.category) {
- var cat = emoji.category
- if (!md["categorized"][cat]) {
- md["categorized"][cat] = []
+ "content-type": "application/json"
+ }
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (parse == "true") {
+ $("#emoji-list").text("Parsing...");
+ var md = {
+ categorized: {},
+ uncategorized: []
+ };
+ var if_categorized = false;
+ Object.keys(json).forEach(function(key) {
+ var emoji = json[key];
+ if (emoji.visible_in_picker) {
+ var listed = true;
+ } else {
+ var listed = false;
}
- md["categorized"][cat].push({
- "shortcode": emoji.shortcode,
- "url": emoji.url,
- "listed": listed
- })
- if_categorized = true
- } else {
- md["uncategorized"].push({
- "shortcode": emoji.shortcode,
- "url": emoji.url,
- "listed": listed
- })
- }
- });
- console.log(md)
- //絵文字をマストドン公式と同順にソート
- md["uncategorized"].sort(function (a, b) {
- if (a.shortcode < b.shortcode) return -1;
- if (a.shortcode > b.shortcode) return 1;
- return 0;
- });
- Object.keys(md["categorized"]).forEach(function (key) {
- md["categorized"][key].sort(function (a, b) {
+ if (emoji.category) {
+ var cat = emoji.category;
+ if (!md["categorized"][cat]) {
+ md["categorized"][cat] = [];
+ }
+ md["categorized"][cat].push({
+ shortcode: emoji.shortcode,
+ url: emoji.url,
+ listed: listed
+ });
+ if_categorized = true;
+ } else {
+ md["uncategorized"].push({
+ shortcode: emoji.shortcode,
+ url: emoji.url,
+ listed: listed
+ });
+ }
+ });
+ console.log(md);
+ //絵文字をマストドン公式と同順にソート
+ md["uncategorized"].sort(function(a, b) {
if (a.shortcode < b.shortcode) return -1;
if (a.shortcode > b.shortcode) return 1;
return 0;
});
- });
-
- md["if_categorized"] = if_categorized
- localStorage.setItem("emojis_" + acct_id, JSON.stringify(md));
- } else {
- localStorage.setItem("emojis_" + acct_id, JSON.stringify(md));
- }
- localStorage.setItem("emojiseek", 0);
- if (!started) {
- emojiList('home')
- }
- });
+ Object.keys(md["categorized"]).forEach(function(key) {
+ md["categorized"][key].sort(function(a, b) {
+ if (a.shortcode < b.shortcode) return -1;
+ if (a.shortcode > b.shortcode) return 1;
+ return 0;
+ });
+ });
+
+ md["if_categorized"] = if_categorized;
+ localStorage.setItem("emojis_" + acct_id, JSON.stringify(md));
+ } else {
+ localStorage.setItem("emojis_" + acct_id, JSON.stringify(md));
+ }
+ localStorage.setItem("emojiseek", 0);
+ if (!started) {
+ emojiList("home");
+ }
+ });
} else {
var start = "https://" + domain + "/api/meta";
fetch(start, {
- method: 'POST',
+ method: "POST",
headers: {
- 'content-type': 'application/json'
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json.enableEmojiReaction) {
- localStorage.setItem("emojiReaction_" + acct_id, "true");
- } else {
- localStorage.setItem("emojiReaction_" + acct_id, "disabled");
+ "content-type": "application/json"
}
- var emojis = json.emojis;
- var md = {"uncategorized": []}
- Object.keys(emojis).forEach(function (key) {
- var emoji = emojis[key];
- md["uncategorized"].push({
- "shortcode": emoji.name,
- "url": emoji.url,
- "listed": true
- })
- });
- md["if_categorized"] = false
- if (parse == "true") {
- $('#emoji-list').text('Parsing...');
- //絵文字をマストドン公式と同順にソート
- md["uncategorized"].sort(function (a, b) {
- if (a.shortcode < b.shortcode) return -1;
- if (a.shortcode > b.shortcode) return 1;
- return 0;
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json.enableEmojiReaction) {
+ localStorage.setItem("emojiReaction_" + acct_id, "true");
+ } else {
+ localStorage.setItem("emojiReaction_" + acct_id, "disabled");
+ }
+ var emojis = json.emojis;
+ var md = { uncategorized: [] };
+ Object.keys(emojis).forEach(function(key) {
+ var emoji = emojis[key];
+ md["uncategorized"].push({
+ shortcode: emoji.name,
+ url: emoji.url,
+ listed: true
+ });
});
- localStorage.setItem("emojis_" + acct_id, JSON.stringify(md));
- } else {
- localStorage.setItem("emojis_" + acct_id, JSON.stringify(md));
- }
- localStorage.setItem("emojiseek", 0);
- if (!started) {
- emojiList('home')
- }
- });
+ md["if_categorized"] = false;
+ if (parse == "true") {
+ $("#emoji-list").text("Parsing...");
+ //絵文字をマストドン公式と同順にソート
+ md["uncategorized"].sort(function(a, b) {
+ if (a.shortcode < b.shortcode) return -1;
+ if (a.shortcode > b.shortcode) return 1;
+ return 0;
+ });
+ localStorage.setItem("emojis_" + acct_id, JSON.stringify(md));
+ } else {
+ localStorage.setItem("emojis_" + acct_id, JSON.stringify(md));
+ }
+ localStorage.setItem("emojiseek", 0);
+ if (!started) {
+ emojiList("home");
+ }
+ });
}
}
@@ -189,8 +194,8 @@ function emojiList(target, reaction) {
$("#now-emoji").text(lang.lang_emoji_custom);
var acct_id = $("#post-acct-sel").val();
if (reaction && localStorage.getItem("emojiReaction_" + acct_id) != "true") {
- console.error("Disabled")
- clear()
+ console.error("Disabled");
+ clear();
hide();
return false;
}
@@ -203,30 +208,34 @@ function emojiList(target, reaction) {
localStorage.setItem("emojiseek", start);
} else {
var start = 0;
- localStorage.getItem("emojiseek", 0)
+ localStorage.getItem("emojiseek", 0);
}
- var html = '';
+ var html = "";
var raw = JSON.parse(localStorage.getItem("emojis_" + acct_id));
- console.log(raw)
+ console.log(raw);
if (raw.if_categorized) {
- var obj = [{
- "divider": true,
- "cat": lang.lang_emoji_uncat
- }]
- var cats = raw["uncategorized"]
+ var obj = [
+ {
+ divider: true,
+ cat: lang.lang_emoji_uncat
+ }
+ ];
+ var cats = raw["uncategorized"];
obj = obj.concat(cats);
- Object.keys(raw["categorized"]).forEach(function (key) {
+ Object.keys(raw["categorized"]).forEach(function(key) {
var cats = raw["categorized"][key];
- obj = obj.concat([{
- "divider": true,
- "cat": key
- }]);
+ obj = obj.concat([
+ {
+ divider: true,
+ cat: key
+ }
+ ]);
obj = obj.concat(cats);
});
} else {
- var obj = raw["uncategorized"]
+ var obj = raw["uncategorized"];
}
- console.log(obj)
+ console.log(obj);
var num = obj.length;
if (num < start) {
@@ -237,7 +246,7 @@ function emojiList(target, reaction) {
$("#emoji-sum").text(page);
var ct = Math.ceil(start / 126);
if (ct === 0) {
- if(num > 0){
+ if (num > 0) {
var ct = 1;
}
$("#emoji-before").addClass("disabled");
@@ -254,18 +263,15 @@ function emojiList(target, reaction) {
var emoji = obj[i];
if (emoji) {
if (reaction) {
- html = html + '';
+ html = html + "';
} else {
- if(emoji.divider){
- html = html + ''+ emoji.cat +'
'
- }else{
+ if (emoji.divider) {
+ html = html + '' + emoji.cat + "
";
+ } else {
if (emoji.listed) {
- html = html + '';
+ html = html + "';
}
}
-
}
}
}
@@ -275,7 +281,7 @@ function emojiList(target, reaction) {
//絵文字など様々なものをテキストボックスに挿入
function emojiInsert(code, del) {
var now = $("#textarea").val();
- var selin = $("#textarea").prop('selectionStart');
+ var selin = $("#textarea").prop("selectionStart");
if (localStorage.getItem("emoji-zero-width") == "yes") {
var blank = "";
} else {
@@ -283,11 +289,11 @@ function emojiInsert(code, del) {
}
var before = now.substr(0, selin);
if (before.slice(-1) != " ") {
- before = before + blank
+ before = before + blank;
}
var after = now.substr(selin, now.length);
if (after.slice(-1) != " ") {
- after = blank + after
+ after = blank + after;
}
newt = before + code + after;
if (!del) {
@@ -303,7 +309,7 @@ function emojiInsert(code, del) {
}
//改行挿入
function brInsert(code) {
- if (!$('#post-box').hasClass("appear")) {
+ if (!$("#post-box").hasClass("appear")) {
localStorage.setItem("nohide", true);
show();
}
diff --git a/app/js/post/img.js b/app/js/post/img.js
index e9e03e9b..68eb86c3 100644
--- a/app/js/post/img.js
+++ b/app/js/post/img.js
@@ -118,7 +118,9 @@ function media(b64, type, no) {
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
- if(this.status!==200){ setLog(start, this.status, json); }
+ if (this.status !== 200) {
+ setLog(start, this.status, json);
+ }
if (!json.id) {
todc();
$("#imgup").text("");
@@ -269,18 +271,19 @@ function altImage(acct_id, id) {
})
.then(function(response) {
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
})
.catch(function(error) {
todo(error);
+ setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
- console.log(json)
+ console.log(json);
$("[data-media=" + id + "]").attr("title", data);
});
},
@@ -288,7 +291,7 @@ function altImage(acct_id, id) {
}).then(result => {
if (result.value) {
Swal.fire({
- title: "Complete",
+ title: "Complete"
});
}
});
diff --git a/app/js/post/misskeystatus.js b/app/js/post/misskeystatus.js
index 6b4ba699..f53a7fb7 100644
--- a/app/js/post/misskeystatus.js
+++ b/app/js/post/misskeystatus.js
@@ -1,250 +1,261 @@
//Renpost
function renote(id, acct_id, remote) {
- if ($("#pub_" + id).hasClass("rted")) {
- return false;
- }
- var domain = localStorage.getItem("domain_" + acct_id);
- var at = localStorage.getItem("acct_" + acct_id + "_at");
- var start = "https://" + domain + "/api/notes/create";
- if (localStorage.getItem("mode_" + domain) != "misskey") {
- return false;
- }
- var httpreq = new XMLHttpRequest();
- httpreq.open('POST', start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
- httpreq.responseType = "json";
- httpreq.send(JSON.stringify({ i: at, renoteId: id }));
- httpreq.onreadystatechange = function () {
- if (httpreq.readyState === 4) {
- var json = httpreq.response;
- if(this.status!==200){ setLog(start, this.status, json); }
- console.log(["Success: renote", json]);
- $("[toot-id=" + id + "]").addClass("rted");
- $(".rt_" + id).toggleClass("teal-text");
- }
- }
+ if ($("#pub_" + id).hasClass("rted")) {
+ return false;
+ }
+ var domain = localStorage.getItem("domain_" + acct_id);
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
+ var start = "https://" + domain + "/api/notes/create";
+ if (localStorage.getItem("mode_" + domain) != "misskey") {
+ return false;
+ }
+ var httpreq = new XMLHttpRequest();
+ httpreq.open("POST", start, true);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.responseType = "json";
+ httpreq.send(JSON.stringify({ i: at, renoteId: id }));
+ httpreq.onreadystatechange = function() {
+ if (httpreq.readyState === 4) {
+ var json = httpreq.response;
+ if (this.status !== 200) {
+ setLog(start, this.status, json);
+ }
+ console.log(["Success: renote", json]);
+ $("[toot-id=" + id + "]").addClass("rted");
+ $(".rt_" + id).toggleClass("teal-text");
+ }
+ };
}
//Renote
function renoteqt(id, acct_id) {
- localStorage.setItem("nohide", true);
- show();
- $("#reply").val("renote_" + id);
- $("#rec").text("Renote");
- $("#post-acct-sel").val(acct_id);
- $("#post-acct-sel").prop("disabled", true);
- $('select').formSelect();
- $("#textarea").attr("placeholder", lang.lang_misskeyparse_qt);
- $("#textarea").focus();
+ localStorage.setItem("nohide", true);
+ show();
+ $("#reply").val("renote_" + id);
+ $("#rec").text("Renote");
+ $("#post-acct-sel").val(acct_id);
+ $("#post-acct-sel").prop("disabled", true);
+ $("select").formSelect();
+ $("#textarea").attr("placeholder", lang.lang_misskeyparse_qt);
+ $("#textarea").focus();
}
//Reply
function misskeyreply(id, acct_id) {
- localStorage.setItem("nohide", true);
- show();
- $("#reply").val(id);
- $("#rec").text("Renote");
- $("#post-acct-sel").val(acct_id);
- $("#post-acct-sel").prop("disabled", true);
- $('select').formSelect();
- $("#textarea").attr("placeholder", lang.lang_misskeyparse_qt);
- $("#textarea").focus();
+ localStorage.setItem("nohide", true);
+ show();
+ $("#reply").val(id);
+ $("#rec").text("Renote");
+ $("#post-acct-sel").val(acct_id);
+ $("#post-acct-sel").prop("disabled", true);
+ $("select").formSelect();
+ $("#textarea").attr("placeholder", lang.lang_misskeyparse_qt);
+ $("#textarea").focus();
}
//Reaction
function reactiontoggle(id, acct_id, tlid) {
- var domain = localStorage.getItem("domain_" + acct_id);
- var at = localStorage.getItem("acct_" + acct_id + "_at");
- var start = "https://" + domain + "/api/notes/show";
- if (localStorage.getItem("mode_" + domain) != "misskey") {
- return false;
- }
- var httpreq = new XMLHttpRequest();
- httpreq.open('POST', start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
- httpreq.responseType = "json";
- httpreq.send(JSON.stringify({ i: at, noteId: id }));
- httpreq.onreadystatechange = function () {
- if (httpreq.readyState === 4) {
- var json = httpreq.response;
- if(this.status!==200){ setLog(start, this.status, json); }
- console.log(["Success: reaction", json]);
- if (json.reactions) {
- var reactions = ["like", "love", "laugh", "hmm", "surprise", "congrats", "angry", "confused", "pudding", "rip"];
- for (var i = 0; i < reactions.length; i++) {
- if (json.reactions[reactions[i]]) {
- $("#pub_" + id + " .re-" + reactions[i] + "ct").text(json.reactions[reactions[i]])
- $("#pub_" + id + " .re-" + reactions[i]).removeClass("hide")
- } else {
- $("#pub_" + id + " .re-" + reactions[i] + "ct").text(0)
- if ($("#pub_" + id + " .reactions").hasClass("fullreact")) {
- $("#pub_" + id + " .re-" + reactions[i]).addClass("hide")
- } else {
- $("#pub_" + id + " .re-" + reactions[i]).removeClass("hide")
- }
- $("#pub_" + id + " .re-" + reactions[i] + "ct").text(json.reactions[reactions[i]])
- }
- }
- $("#pub_" + id + " .reactions").removeClass("hide");
- $("#pub_" + id + " .reactions").toggleClass("fullreact")
- } else {
- if ($("#pub_" + id + " .reactions").hasClass("fullreact")) {
- $("#pub_" + id + " .reactions").addClass("hide")
- $("#pub_" + id + " .reactions").removeClass("fullreact")
- } else {
- $("#pub_" + id + " .reactions").removeClass("hide");
- $("#pub_" + id + " .reaction").removeClass("hide");
- $("#pub_" + id + " .reactions").addClass("fullreact");
- }
- }
- }
- }
- $("#pub_" + id + " .freeReact").toggleClass("hide");
+ var domain = localStorage.getItem("domain_" + acct_id);
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
+ var start = "https://" + domain + "/api/notes/show";
+ if (localStorage.getItem("mode_" + domain) != "misskey") {
+ return false;
+ }
+ var httpreq = new XMLHttpRequest();
+ httpreq.open("POST", start, true);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.responseType = "json";
+ httpreq.send(JSON.stringify({ i: at, noteId: id }));
+ httpreq.onreadystatechange = function() {
+ if (httpreq.readyState === 4) {
+ var json = httpreq.response;
+ if (this.status !== 200) {
+ setLog(start, this.status, json);
+ }
+ console.log(["Success: reaction", json]);
+ if (json.reactions) {
+ var reactions = ["like", "love", "laugh", "hmm", "surprise", "congrats", "angry", "confused", "pudding", "rip"];
+ for (var i = 0; i < reactions.length; i++) {
+ if (json.reactions[reactions[i]]) {
+ $("#pub_" + id + " .re-" + reactions[i] + "ct").text(json.reactions[reactions[i]]);
+ $("#pub_" + id + " .re-" + reactions[i]).removeClass("hide");
+ } else {
+ $("#pub_" + id + " .re-" + reactions[i] + "ct").text(0);
+ if ($("#pub_" + id + " .reactions").hasClass("fullreact")) {
+ $("#pub_" + id + " .re-" + reactions[i]).addClass("hide");
+ } else {
+ $("#pub_" + id + " .re-" + reactions[i]).removeClass("hide");
+ }
+ $("#pub_" + id + " .re-" + reactions[i] + "ct").text(json.reactions[reactions[i]]);
+ }
+ }
+ $("#pub_" + id + " .reactions").removeClass("hide");
+ $("#pub_" + id + " .reactions").toggleClass("fullreact");
+ } else {
+ if ($("#pub_" + id + " .reactions").hasClass("fullreact")) {
+ $("#pub_" + id + " .reactions").addClass("hide");
+ $("#pub_" + id + " .reactions").removeClass("fullreact");
+ } else {
+ $("#pub_" + id + " .reactions").removeClass("hide");
+ $("#pub_" + id + " .reaction").removeClass("hide");
+ $("#pub_" + id + " .reactions").addClass("fullreact");
+ }
+ }
+ }
+ };
+ $("#pub_" + id + " .freeReact").toggleClass("hide");
}
//reactioncustom
function reactioncustom(acct_id, id) {
- $("#reply").val(id);
- $("#unreact").hide();
- $("#addreact").removeClass("hide");
- $("#post-acct-sel").val(acct_id);
- $('select').formSelect();
- localStorage.setItem("nohide", true);
- show()
- emojiToggle(true)
- $("#left-side").hide();
- $("#default-emoji").hide();
+ $("#reply").val(id);
+ $("#unreact").hide();
+ $("#addreact").removeClass("hide");
+ $("#post-acct-sel").val(acct_id);
+ $("select").formSelect();
+ localStorage.setItem("nohide", true);
+ show();
+ emojiToggle(true);
+ $("#left-side").hide();
+ $("#default-emoji").hide();
}
function reactRefresh(acct_id, id) {
- var domain = localStorage.getItem("domain_" + acct_id);
- var at = localStorage.getItem("acct_" + acct_id + "_at");
- var start = "https://" + domain + "/api/notes/show";
+ var domain = localStorage.getItem("domain_" + acct_id);
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
+ var start = "https://" + domain + "/api/notes/show";
- var req = {};
- req.i = at;
- req.noteId = id;
- var i = {
- method: "POST",
- body: JSON.stringify(req),
- }
- fetch(start, i,
- ).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (!json) {
- return false;
- }
- var poll = "";
- if (json.error) {
- $("[toot-id=" + id + "]").hide();
- $("[toot-id=" + id + "]").remove();
- } else {
- reactRefreshCore(json)
- }
- });
+ var req = {};
+ req.i = at;
+ req.noteId = id;
+ var i = {
+ method: "POST",
+ body: JSON.stringify(req)
+ };
+ fetch(start, i)
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (!json) {
+ return false;
+ }
+ var poll = "";
+ if (json.error) {
+ $("[toot-id=" + id + "]").hide();
+ $("[toot-id=" + id + "]").remove();
+ } else {
+ reactRefreshCore(json);
+ }
+ });
}
function reactRefreshCore(json) {
- var id = json.id;
- if (json.reactions) {
- $("#pub_" + id + " .reactions").removeClass("hide")
- var regExp = new RegExp(":", "g");
- Object.keys(json.reactions).forEach(function (keye) {
- keyeClass = keye.replace(regExp, '');
- if (json.reactions[keye]) {
- $("#pub_" + id + " .re-" + keyeClass + "ct").text(json.reactions[keye])
- $("#pub_" + id + " .re-" + keyeClass).removeClass("hide")
- } else {
- $("#pub_" + id + " .re-" + keyeClass + "ct").text(0)
- if ($("#pub_" + id + " .reactions").hasClass("fullreact")) {
- $("#pub_" + id + " .re-" + keyeClass).addClass("hide")
- }
- $("#pub_" + id + " .re-" + keyeClass + "ct").text(json.reactions[keye])
- }
- });
- }
+ var id = json.id;
+ if (json.reactions) {
+ $("#pub_" + id + " .reactions").removeClass("hide");
+ var regExp = new RegExp(":", "g");
+ Object.keys(json.reactions).forEach(function(keye) {
+ keyeClass = keye.replace(regExp, "");
+ if (json.reactions[keye]) {
+ $("#pub_" + id + " .re-" + keyeClass + "ct").text(json.reactions[keye]);
+ $("#pub_" + id + " .re-" + keyeClass).removeClass("hide");
+ } else {
+ $("#pub_" + id + " .re-" + keyeClass + "ct").text(0);
+ if ($("#pub_" + id + " .reactions").hasClass("fullreact")) {
+ $("#pub_" + id + " .re-" + keyeClass).addClass("hide");
+ }
+ $("#pub_" + id + " .re-" + keyeClass + "ct").text(json.reactions[keye]);
+ }
+ });
+ }
}
function emojiReaction(emoji) {
- var acct_id = $("#post-acct-sel").val();
- var id = $("#reply").val();
- reaction(emoji, id, acct_id, null)
- clear();
- hide();
+ var acct_id = $("#post-acct-sel").val();
+ var id = $("#reply").val();
+ reaction(emoji, id, acct_id, null);
+ clear();
+ hide();
}
function reaction(mode, id, acct_id, tlid) {
- var domain = localStorage.getItem("domain_" + acct_id);
- var at = localStorage.getItem("acct_" + acct_id + "_at");
- if ($(".fav_" + id).hasClass("yellow-text")) {
- var flag = "delete";
- } else {
- var flag = "create";
- }
- var start = "https://" + domain + "/api/notes/reactions/" + flag;
- if (localStorage.getItem("mode_" + domain) != "misskey") {
- return false;
- }
- var httpreq = new XMLHttpRequest();
- httpreq.open('POST', start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
- httpreq.responseType = "json";
- httpreq.send(JSON.stringify({ i: at, noteId: id, reaction: mode }));
- httpreq.onreadystatechange = function () {
- if (httpreq.readyState === 4) {
- if(this.status!==200){ setLog(start, this.status, this.response); }
- $(".fav_" + id).toggleClass("yellow-text");
- }
- }
+ var domain = localStorage.getItem("domain_" + acct_id);
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
+ if ($(".fav_" + id).hasClass("yellow-text")) {
+ var flag = "delete";
+ } else {
+ var flag = "create";
+ }
+ var start = "https://" + domain + "/api/notes/reactions/" + flag;
+ if (localStorage.getItem("mode_" + domain) != "misskey") {
+ return false;
+ }
+ var httpreq = new XMLHttpRequest();
+ httpreq.open("POST", start, true);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.responseType = "json";
+ httpreq.send(JSON.stringify({ i: at, noteId: id, reaction: mode }));
+ httpreq.onreadystatechange = function() {
+ if (httpreq.readyState === 4) {
+ if (this.status !== 200) {
+ setLog(start, this.status, this.response);
+ }
+ $(".fav_" + id).toggleClass("yellow-text");
+ }
+ };
}
//Vote
function vote(acct_id, id, to) {
- var domain = localStorage.getItem("domain_" + acct_id);
- var at = localStorage.getItem("acct_" + acct_id + "_at");
- var start = "https://" + domain + "/api/notes/polls/vote";
- if (localStorage.getItem("mode_" + domain) != "misskey") {
- return false;
- }
- var httpreq = new XMLHttpRequest();
- httpreq.open('POST', start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
- httpreq.responseType = "json";
- httpreq.send(JSON.stringify({ i: at, noteId: id, choice: to }));
- httpreq.onreadystatechange = function () {
- voterefresh(acct_id, id)
- }
+ var domain = localStorage.getItem("domain_" + acct_id);
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
+ var start = "https://" + domain + "/api/notes/polls/vote";
+ if (localStorage.getItem("mode_" + domain) != "misskey") {
+ return false;
+ }
+ var httpreq = new XMLHttpRequest();
+ httpreq.open("POST", start, true);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.responseType = "json";
+ httpreq.send(JSON.stringify({ i: at, noteId: id, choice: to }));
+ httpreq.onreadystatechange = function() {
+ voterefresh(acct_id, id);
+ };
}
function voterefresh(acct_id, id) {
- var httpreqd = new XMLHttpRequest();
- var domain = localStorage.getItem("domain_" + acct_id);
- var at = localStorage.getItem("acct_" + acct_id + "_at");
- var start = "https://" + domain + "/api/notes/show";
- httpreqd.open('POST', start, true);
- httpreqd.setRequestHeader('Content-Type', 'application/json');
- httpreqd.responseType = 'json';
- httpreqd.send(JSON.stringify({ i: at, noteId: id }));
- httpreqd.onreadystatechange = function () {
- if (httpreqd.readyState == 4) {
- var json = httpreqd.response;
- if(this.status!==200){ setLog(start, this.status, json); }
- if (!json) {
- return false;
- }
- var poll = "";
- if (json.poll) {
- var choices = json.poll.choices;
- Object.keys(choices).forEach(function (keyc) {
- var choice = choices[keyc];
- if (choice.isVoted) {
- var myvote = twemoji.parse("✅");
- } else {
- var myvote = "";
- }
- poll = poll + '' + escapeHTML(choice.text) + '(' + choice.votes + '' + myvote + ')
';
- });
- $(".vote_" + json.id).html(poll)
- }
- }
- }
-}
\ No newline at end of file
+ var httpreqd = new XMLHttpRequest();
+ var domain = localStorage.getItem("domain_" + acct_id);
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
+ var start = "https://" + domain + "/api/notes/show";
+ httpreqd.open("POST", start, true);
+ httpreqd.setRequestHeader("Content-Type", "application/json");
+ httpreqd.responseType = "json";
+ httpreqd.send(JSON.stringify({ i: at, noteId: id }));
+ httpreqd.onreadystatechange = function() {
+ if (httpreqd.readyState == 4) {
+ var json = httpreqd.response;
+ if (this.status !== 200) {
+ setLog(start, this.status, json);
+ }
+ if (!json) {
+ return false;
+ }
+ var poll = "";
+ if (json.poll) {
+ var choices = json.poll.choices;
+ Object.keys(choices).forEach(function(keyc) {
+ var choice = choices[keyc];
+ if (choice.isVoted) {
+ var myvote = twemoji.parse("✅");
+ } else {
+ var myvote = "";
+ }
+ poll = poll + '' + escapeHTML(choice.text) + "(" + choice.votes + "" + myvote + ")
";
+ });
+ $(".vote_" + json.id).html(poll);
+ }
+ }
+ };
+}
diff --git a/app/js/tl/card.js b/app/js/tl/card.js
index 140c7363..5cd30895 100644
--- a/app/js/tl/card.js
+++ b/app/js/tl/card.js
@@ -6,38 +6,35 @@ function additional(acct_id, tlid) {
$("#timeline-container .mention").addClass("parsed");
- $("#timeline-container .hashtag, #timeline-container [rel=tag]").each(function (i, elem) {
- var tags = $(this).attr("href").match(
- /https?:\/\/([-a-zA-Z0-9@.]+)\/tags\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/
- );
- if(tags){
- var tagThis = tags[2]
- }else{
- var tagThis = $(this).attr("data-tag")
+ $("#timeline-container .hashtag, #timeline-container [rel=tag]").each(function(i, elem) {
+ var tags = $(this)
+ .attr("href")
+ .match(/https?:\/\/([-a-zA-Z0-9@.]+)\/tags\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/);
+ if (tags) {
+ var tagThis = tags[2];
+ } else {
+ var tagThis = $(this).attr("data-tag");
}
-
- if(tagThis){
- $(this).attr("onclick", 'tagShow(\'' + tagThis + '\')');
+
+ if (tagThis) {
+ $(this).attr("onclick", "tagShow('" + tagThis + "')");
$(this).attr("href", "#");
}
-
});
//トゥートサムネ
- $("#timeline_" + tlid + " .toot a:not(.parsed)").each(function (i, elem) {
+ $("#timeline_" + tlid + " .toot a:not(.parsed)").each(function(i, elem) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
var card = localStorage.getItem("card_" + tlid);
- var text = $(this).attr('href');
+ var text = $(this).attr("href");
if (text) {
if (text.indexOf("twimg.com") === -1) {
- var urls = text.match(
- /https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/
- );
+ var urls = text.match(/https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/);
}
} else {
- text = ""
- var urls = []
+ text = "";
+ var urls = [];
}
//トゥートのURLぽかったら
@@ -50,50 +47,55 @@ function additional(acct_id, tlid) {
if (urls) {
$(this).remove();
} 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") {
var start = "https://" + domain + "/url?url=" + text;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json'
- },
- //body: JSON.stringify({})
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json.title) {
- $("[toot-id=" + id + "] .additional").html(
- "URL" + lang.lang_cards_check + ":
Title:" + escapeHTML(json.title) + "
" +
- escapeHTML(json.description) + "");
- $("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
- $("[toot-id=" + id + "]").addClass("parsed");
+ "content-type": "application/json"
}
- });
+ //body: JSON.stringify({})
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json.title) {
+ $("[toot-id=" + id + "] .additional").html('URL' + lang.lang_cards_check + ":
Title:" + escapeHTML(json.title) + "
" + escapeHTML(json.description) + "");
+ $("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
+ $("[toot-id=" + id + "]").addClass("parsed");
+ }
+ });
}
-
} else {
$(this).attr("title", text);
}
});
- $("i.unparsed").each(function (i, elem) {
+ $("i.unparsed").each(function(i, elem) {
var dem = $(this).text();
var dom = $(this);
var start = "./js/emoji/emoji-map.json";
var xmlHttpRequest = new XMLHttpRequest();
- xmlHttpRequest.onreadystatechange = function () {
+ xmlHttpRequest.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
if (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;
for (i = 0; i < emojis.length; i++) {
var emojie = emojis[i];
@@ -109,19 +111,24 @@ function additional(acct_id, tlid) {
}
}
}
- }
- xmlHttpRequest.open('GET', start, true);
- xmlHttpRequest.responseType = 'json';
+ };
+ xmlHttpRequest.open("GET", start, true);
+ xmlHttpRequest.responseType = "json";
xmlHttpRequest.send(null);
});
- $("#timeline_" + tlid + " .toot:not(:has(a:not(.add-show,.parsed)))").each(function (i, elem) {
- $(this).parent().find(".add-show").hide();
+ $("#timeline_" + tlid + " .toot:not(:has(a:not(.add-show,.parsed)))").each(function(i, elem) {
+ $(this)
+ .parent()
+ .find(".add-show")
+ .hide();
});
//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 id = $(this).parents('.cvo').attr("toot-id");
+ var id = $(this)
+ .parents(".cvo")
+ .attr("toot-id");
$(this).attr("href", "#");
$(this).attr("onclick", "imgv('" + id + "','" + i + "')");
$(this).attr("data-type", "image");
@@ -134,97 +141,97 @@ function additional(acct_id, tlid) {
function additionalIndv(tlid, acct_id, id) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
- var text = $("[toot-id=" + id + "] .toot a").attr('href');
- var urls = text.match(
- /https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/
- );
+ var text = $("[toot-id=" + id + "] .toot a").attr("href");
+ var urls = text.match(/https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/);
if (urls) {
$("[toot-id=" + id + "] .toot a").remove();
} else {
if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/url?url=" + text;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json'
- },
- //body: JSON.stringify({})
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json.title) {
- $("[toot-id=" + id + "] .additional").html(
- "URL" + lang.lang_cards_check + ":
Title:" + escapeHTML(json.title) + "
" +
- escapeHTML(json.description) + "");
- $("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
- $("[toot-id=" + id + "]").addClass("parsed");
+ "content-type": "application/json"
}
- });
+ //body: JSON.stringify({})
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json.title) {
+ $("[toot-id=" + id + "] .additional").html('URL' + lang.lang_cards_check + ":
Title:" + escapeHTML(json.title) + "
" + escapeHTML(json.description) + "");
+ $("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
+ $("[toot-id=" + id + "]").addClass("parsed");
+ }
+ });
} 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;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
+ }
//body: JSON.stringify({})
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- json = json.card;
- //このリンク鳥やんけ、ってとき
- if (json.provider_name == "Twitter") {
- if (json.image) {
- var twiImg = '
';
- } else {
- var twiImg = '';
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
- $("[toot-id=" + id + "] .additional").html(
- '');
- } else if (json.provider_name == "pixiv") {
- if (json.image) {
- var pxvImg = '
';
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ json = json.card;
+ //このリンク鳥やんけ、ってとき
+ if (json.provider_name == "Twitter") {
+ if (json.image) {
+ var twiImg = '
';
+ } else {
+ var twiImg = "";
+ }
+ $("[toot-id=" + id + "] .additional").html('");
+ } else if (json.provider_name == "pixiv") {
+ if (json.image) {
+ var pxvImg = '
';
+ } else {
+ var pxvImg = "";
+ }
+ $("[toot-id=" + id + "] .additional").html('' + escapeHTML(json.author_name) + "" + escapeHTML(json.title) + pxvImg + "
");
} else {
- var pxvImg = '';
+ if (json.title) {
+ $("[toot-id=" + id + "] .additional").html('URL' + lang.lang_cards_check + ":
Title:" + escapeHTML(json.title) + "
" + escapeHTML(json.description) + "");
+ }
+ if (json.html) {
+ $("[toot-id=" + id + "] .additional").html(json.html + 'picture_in_picture_alt');
+ }
}
- $("[toot-id=" + id + "] .additional").html(
- '' + escapeHTML(json.author_name) + '' + escapeHTML(json.title) + pxvImg + '
');
- } else {
if (json.title) {
- $("[toot-id=" + id + "] .additional").html(
- "URL" + lang.lang_cards_check + ":
Title:" + escapeHTML(json.title) + "
" +
- escapeHTML(json.description) + "");
+ $("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
+ $("[toot-id=" + id + "]").addClass("parsed");
}
- if (json.html) {
- $("[toot-id=" + id + "] .additional").html(json.html + 'picture_in_picture_alt');
-
- }
- }
- if (json.title) {
- $("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
- $("[toot-id=" + id + "]").addClass("parsed");
- }
- });
+ });
}
-
}
}
@@ -234,11 +241,11 @@ function cardToggle(tlid) {
if (!card) {
localStorage.setItem("card_" + tlid, "true");
$("#sta-card-" + tlid).text("Off");
- $("#sta-card-" + tlid).css("color", 'red');
+ $("#sta-card-" + tlid).css("color", "red");
} else {
localStorage.removeItem("card_" + tlid);
$("#sta-card-" + tlid).text("On");
- $("#sta-card-" + tlid).css("color", '#009688');
+ $("#sta-card-" + tlid).css("color", "#009688");
}
}
//各TL上方のLink[On/Off]をチェック
@@ -246,15 +253,15 @@ function cardCheck(tlid) {
var card = localStorage.getItem("card_" + tlid);
if (!card) {
$("#sta-card-" + tlid).text("On");
- $("#sta-card-" + tlid).css("color", '#009688');
+ $("#sta-card-" + tlid).css("color", "#009688");
} else {
$("#sta-card-" + tlid).text("Off");
- $("#sta-card-" + tlid).css("color", 'red');
+ $("#sta-card-" + tlid).css("color", "red");
}
}
function mov(id, tlid, type) {
- var click = false
+ var click = false;
if (tlid == "notf") {
var tlide = "[data-notf=" + acct_id + "]";
} else if (tlid == "user") {
@@ -274,21 +281,20 @@ function mov(id, tlid, type) {
} else {
mouseover = "hide";
}
- click=true
+ click = true;
} else if (mouseover == "no") {
mouseover = "";
}
if (mouseover == "hide") {
- if(click){
- $(tlide + " [toot-id=" + id + "]").toggleClass("hide-actions")
- }else{
- $(tlide + " [toot-id=" + id + "]").removeClass("hide-actions")
+ if (click) {
+ $(tlide + " [toot-id=" + id + "]").toggleClass("hide-actions");
+ } else {
+ $(tlide + " [toot-id=" + id + "]").removeClass("hide-actions");
}
-
+
//$(tlide + " [toot-id=" + id + "] .area-vis").toggleClass("hide")
//$(tlide + " [toot-id=" + id + "] .area-actions").toggleClass("hide")
//$(tlide + " [toot-id=" + id + "] .area-side").toggleClass("hide")
-
}
}
@@ -304,10 +310,9 @@ function resetmv(type) {
mouseover = "hide";
}
if (mouseover == "hide") {
- $(".cvo").addClass("hide-actions")
+ $(".cvo").addClass("hide-actions");
//$(".area-vis").addClass("hide");
//$(".area-actions").addClass("hide");
//$(".area-side").addClass("hide");
}
-
-}
\ No newline at end of file
+}
diff --git a/app/js/tl/datails.js b/app/js/tl/datails.js
index e547750e..d18dd3ac 100644
--- a/app/js/tl/datails.js
+++ b/app/js/tl/datails.js
@@ -5,115 +5,118 @@ function details(id, acct_id, tlid, mode) {
} else {
$(".dm-hide").show();
}
- $(".toot-reset").html('' + lang.lang_details_nodata + '');
+ $(".toot-reset").html('' + lang.lang_details_nodata + "");
var html = $("#timeline_" + tlid + " [toot-id=" + id + "]").html();
$("#toot-this").html(html);
- $('#tootmodal').modal('open');
+ $("#tootmodal").modal("open");
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/notes/show";
var i = {
- method: 'POST',
+ method: "POST",
headers: {
- 'content-type': 'application/json',
+ "content-type": "application/json"
},
body: JSON.stringify({
i: at,
noteId: id
})
- }
+ };
} else {
var start = "https://" + domain + "/api/v1/statuses/" + id;
var i = {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
+ }
+ };
}
- fetch(start, i).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- console.log(["Toot data:", json]);
- if (!$("#timeline_" + tlid + " #pub_" + id).length) {
- var html = parse([json], '', acct_id);
- $("#toot-this").html(html);
- jQuery("time.timeago").timeago();
- }
- if (localStorage.getItem("mode_" + domain) == "misskey") {
- var url = "https://" + domain + "/notes/" + json.id;
- var scn = json.user.username;
- if (!json.user.host) {
- var local = true;
+ fetch(start, i)
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ console.log(["Toot data:", json]);
+ if (!$("#timeline_" + tlid + " #pub_" + id).length) {
+ var html = parse([json], "", acct_id);
+ $("#toot-this").html(html);
+ jQuery("time.timeago").timeago();
+ }
+ if (localStorage.getItem("mode_" + domain) == "misskey") {
+ var url = "https://" + domain + "/notes/" + json.id;
+ var scn = json.user.username;
+ if (!json.user.host) {
+ var local = true;
+ } else {
+ var local = false;
+ scn = scn + "@" + host;
+ }
+ var rep = "";
+ var uid = json.user.id;
+ if (json._replyIds) {
+ replyTL(json._replyIds[0], acct_id);
+ }
} else {
- var local = false;
- scn = scn + "@" + host;
+ var url = json.url;
+ if (json.account.acct == json.account.username) {
+ var local = true;
+ } else {
+ var local = false;
+ }
+ var scn = json.account.acct;
+ var uid = json.account.id;
+ if (json["in_reply_to_id"]) {
+ replyTL(json["in_reply_to_id"], acct_id);
+ }
}
- var rep = "";
- var uid = json.user.id;
- if (json._replyIds) {
- replyTL(json._replyIds[0], acct_id);
- }
- } else {
- var url = json.url
- if (json.account.acct == json.account.username) {
- var local = true;
+ $("#toot-this .fav_ct").text(json.favourites_count);
+ $("#toot-this .rt_ct").text(json.reblogs_count);
+ $("#tootmodal").attr("data-url", url);
+ $("#tootmodal").attr("data-id", json.id);
+ $("#tootmodal").attr("data-acct", acct_id);
+ if (local) {
+ $("#tootmodal").attr("data-user", scn + "@" + domain);
} else {
- var local = false;
+ $("#tootmodal").attr("data-user", scn);
}
- var scn = json.account.acct;
- var uid = json.account.id;
- if (json["in_reply_to_id"]) {
- replyTL(json["in_reply_to_id"], acct_id);
+ getContext(id, acct_id);
+ var dom = null;
+ if (!local) {
+ dom = scn.replace(/.+@/g, "");
+ } else {
+ dom = domain;
}
- }
- $("#toot-this .fav_ct").text(json.favourites_count);
- $("#toot-this .rt_ct").text(json.reblogs_count);
- $("#tootmodal").attr("data-url", url);
- $("#tootmodal").attr("data-id", json.id);
- $("#tootmodal").attr("data-acct", acct_id);
- if (local) {
- $("#tootmodal").attr("data-user", scn + "@" + domain);
- } else {
- $("#tootmodal").attr("data-user", scn);
- }
- getContext(id, acct_id);
- var dom = null;
- if (!local) {
- dom = scn.replace(/.+@/g, '');
- } else {
- dom = domain;
- }
- beforeToot(id, acct_id, dom);
- userToot(id, acct_id, uid);
- afterToot(id, acct_id, dom);
- afterUserToot(id, acct_id, uid);
- afterFTLToot(id, acct_id, dom);
- faved(id, acct_id);
- rted(id, acct_id);
- if ($("#toot-this div").hasClass("cvo")) {
- $("#toot-this").removeClass("cvo");
- } else {
- if(!$("#toot-this .cvo").hasClass("cvo")){
- $("#toot-this").addClass("cvo");
+ beforeToot(id, acct_id, dom);
+ userToot(id, acct_id, uid);
+ afterToot(id, acct_id, dom);
+ afterUserToot(id, acct_id, uid);
+ afterFTLToot(id, acct_id, dom);
+ faved(id, acct_id);
+ rted(id, acct_id);
+ if ($("#toot-this div").hasClass("cvo")) {
+ $("#toot-this").removeClass("cvo");
+ } else {
+ if (!$("#toot-this .cvo").hasClass("cvo")) {
+ $("#toot-this").addClass("cvo");
+ }
}
- }
- if (!$("#activator").hasClass("active")) {
- $('#det-col').collapsible('open', 4);
- }
-
- });
+ if (!$("#activator").hasClass("active")) {
+ $("#det-col").collapsible("open", 4);
+ }
+ });
}
//返信タイムライン
@@ -123,47 +126,50 @@ function replyTL(id, acct_id) {
if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/notes/show";
var i = {
- method: 'POST',
+ method: "POST",
headers: {
- 'content-type': 'application/json',
+ "content-type": "application/json"
},
body: JSON.stringify({
i: at,
noteId: id
})
- }
+ };
} else {
- return false
+ return false;
}
- fetch(start, i).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (localStorage.getItem("filter_" + acct_id) != "undefined") {
- var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "thread");
- } else {
- var mute = [];
- }
- if (localStorage.getItem("mode_" + domain) == "misskey") {
- var templete = misskeyParse([json], '', acct_id, "", "", mute);
- $("#toot-after").prepend(templete);
- $("#toot-after .hide").html(lang.lang_details_filtered);
- $("#toot-after .by_filter").css("display", "block");
- $("#toot-after .by_filter").removeClass("hide");
- var rep = "_replyIds";
- if (json[rep]) {
- replyTL(json[rep][0], acct_id);
+ fetch(start, i)
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
- }
-
- });
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (localStorage.getItem("filter_" + acct_id) != "undefined") {
+ var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "thread");
+ } else {
+ var mute = [];
+ }
+ if (localStorage.getItem("mode_" + domain) == "misskey") {
+ var templete = misskeyParse([json], "", acct_id, "", "", mute);
+ $("#toot-after").prepend(templete);
+ $("#toot-after .hide").html(lang.lang_details_filtered);
+ $("#toot-after .by_filter").css("display", "block");
+ $("#toot-after .by_filter").removeClass("hide");
+ var rep = "_replyIds";
+ if (json[rep]) {
+ replyTL(json[rep][0], acct_id);
+ }
+ }
+ });
}
//コンテクストってなんですか
@@ -173,70 +179,73 @@ function getContext(id, acct_id) {
if (localStorage.getItem("mode_" + domain) == "misskey") {
var start = "https://" + domain + "/api/notes/conversation";
var i = {
- method: 'POST',
+ method: "POST",
headers: {
- 'content-type': 'application/json',
+ "content-type": "application/json"
},
body: JSON.stringify({
i: at,
noteId: id
})
- }
+ };
} else {
var start = "https://" + domain + "/api/v1/statuses/" + id + "/context";
var i = {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
+ }
+ };
}
- fetch(start, i).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (localStorage.getItem("mode_" + domain) == "misskey") {
- json.reverse();
- var templete = misskeyParse(json, '', acct_id, "", "", []);
- $("#toot-reply").html(templete);
- $("#toot-reply .hide").html(lang.lang_details_filtered);
- $("#toot-reply .by_filter").css("display", "block");
- $("#toot-reply .by_filter").removeClass("hide");
- jQuery("time.timeago").timeago();
- } else {
- if (localStorage.getItem("filter_" + acct_id) != "undefined") {
- var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "thread");
+ fetch(start, i)
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (localStorage.getItem("mode_" + domain) == "misskey") {
+ json.reverse();
+ var templete = misskeyParse(json, "", acct_id, "", "", []);
+ $("#toot-reply").html(templete);
+ $("#toot-reply .hide").html(lang.lang_details_filtered);
+ $("#toot-reply .by_filter").css("display", "block");
+ $("#toot-reply .by_filter").removeClass("hide");
+ jQuery("time.timeago").timeago();
} else {
- var mute = [];
+ if (localStorage.getItem("filter_" + acct_id) != "undefined") {
+ var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "thread");
+ } else {
+ var mute = [];
+ }
+ var templete = parse(json.descendants, "", acct_id, "", "", mute);
+ if (templete != "") {
+ $("#toot-after .no-data").hide();
+ }
+ $("#toot-after").html(templete);
+ $("#toot-after .hide").html(lang.lang_details_filtered);
+ $("#toot-after .by_filter").css("display", "block");
+ $("#toot-after .by_filter").removeClass("hide");
+ var templete = parse(json.ancestors, "", acct_id, "", "", mute);
+ if (templete != "") {
+ $("#toot-reply .no-data").hide();
+ }
+ $("#toot-reply").prepend(templete);
+ $("#toot-reply .hide").html(lang.lang_details_filtered);
+ $("#toot-reply .by_filter").css("display", "block");
+ $("#toot-reply .by_filter").removeClass("hide");
+ jQuery("time.timeago").timeago();
}
- var templete = parse(json.descendants, '', acct_id, "", "", mute);
- if (templete != "") {
- $("#toot-after .no-data").hide();
- }
- $("#toot-after").html(templete);
- $("#toot-after .hide").html(lang.lang_details_filtered);
- $("#toot-after .by_filter").css("display", "block");
- $("#toot-after .by_filter").removeClass("hide");
- var templete = parse(json.ancestors, '', acct_id, "", "", mute);
- if (templete != "") {
- $("#toot-reply .no-data").hide();
- }
- $("#toot-reply").prepend(templete);
- $("#toot-reply .hide").html(lang.lang_details_filtered);
- $("#toot-reply .by_filter").css("display", "block");
- $("#toot-reply .by_filter").removeClass("hide");
- jQuery("time.timeago").timeago();
- }
-
- });
+ });
}
//前のトゥート(Back TL)
@@ -244,58 +253,64 @@ function beforeToot(id, acct_id, domain) {
//var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") {
- var start = "https://" + domain +
- "/api/notes/local-timeline"
+ var start = "https://" + domain + "/api/notes/local-timeline";
fetch(start, {
- method: 'POST',
+ method: "POST",
headers: {
- 'content-type': 'application/json',
+ "content-type": "application/json"
},
body: JSON.stringify({
i: at,
untilID: id
})
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = misskeyParse(json, "noauth", acct_id);
+ $("#toot-before").html(templete);
+ jQuery("time.timeago").timeago();
});
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var templete = misskeyParse(json, 'noauth', acct_id);
- $("#toot-before").html(templete);
- jQuery("time.timeago").timeago();
- });
} else {
- var start = "https://" + domain +
- "/api/v1/timelines/public?local=true&max_id=" + id;
+ var start = "https://" + domain + "/api/v1/timelines/public?local=true&max_id=" + id;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var templete = parse(json, 'noauth', acct_id);
- if (templete != "") {
- $("#toot-before .no-data").hide();
+ "content-type": "application/json"
}
- $("#toot-before").html(templete);
- jQuery("time.timeago").timeago();
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = parse(json, "noauth", acct_id);
+ if (templete != "") {
+ $("#toot-before .no-data").hide();
+ }
+ $("#toot-before").html(templete);
+ jQuery("time.timeago").timeago();
+ });
}
}
//前のユーザーのトゥート
@@ -303,91 +318,100 @@ function userToot(id, acct_id, user) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") {
- var start = "https://" + domain +
- "/api/users/notes"
+ var start = "https://" + domain + "/api/users/notes";
fetch(start, {
- method: 'POST',
+ method: "POST",
headers: {
- 'content-type': 'application/json',
+ "content-type": "application/json"
},
body: JSON.stringify({
i: at,
untilID: id,
userId: user
})
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = misskeyParse(json, "noauth", acct_id);
+ $("#user-before").html(templete);
+ jQuery("time.timeago").timeago();
});
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var templete = misskeyParse(json, 'noauth', acct_id);
- $("#user-before").html(templete);
- jQuery("time.timeago").timeago();
- });
} else {
var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses?max_id=" + id;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var templete = parse(json, '', acct_id);
- if (templete != "") {
- $("#user-before .no-data").hide();
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- $("#user-before").html(templete);
- jQuery("time.timeago").timeago();
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = parse(json, "", acct_id);
+ if (templete != "") {
+ $("#user-before .no-data").hide();
+ }
+ $("#user-before").html(templete);
+ jQuery("time.timeago").timeago();
+ });
}
-
}
//後のLTL
function afterToot(id, acct_id, domain) {
//var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
- var start = "https://" + domain +
- "/api/v1/timelines/public?local=true&min_id=" + id;
+ var start = "https://" + domain + "/api/v1/timelines/public?local=true&min_id=" + id;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json"
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var templete = parse(json, 'noauth', acct_id);
- if (templete != "") {
- $("#ltl-after .no-data").hide();
- }
- $("#ltl-after").html(templete);
- jQuery("time.timeago").timeago();
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = parse(json, "noauth", acct_id);
+ if (templete != "") {
+ $("#ltl-after .no-data").hide();
+ }
+ $("#ltl-after").html(templete);
+ jQuery("time.timeago").timeago();
+ });
}
//後のUTL
function afterUserToot(id, acct_id, user) {
@@ -395,120 +419,139 @@ function afterUserToot(id, acct_id, user) {
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/accounts/" + user + "/statuses?min_id=" + id;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var templete = parse(json, '', acct_id);
- if (templete != "") {
- $("#user-after .no-data").hide();
- }
- $("#user-after").html(templete);
- jQuery("time.timeago").timeago();
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = parse(json, "", acct_id);
+ if (templete != "") {
+ $("#user-after .no-data").hide();
+ }
+ $("#user-after").html(templete);
+ jQuery("time.timeago").timeago();
+ });
}
//後のFTL
function afterFTLToot(id, acct_id, domain) {
//var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
- var start = "https://" + domain +
- "/api/v1/timelines/public?min_id=" + id;
+ var start = "https://" + domain + "/api/v1/timelines/public?min_id=" + id;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json"
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var templete = parse(json, 'noauth', acct_id);
- if (templete != "") {
- $("#ftl-after .no-data").hide();
- }
- $("#ftl-after").html(templete);
- jQuery("time.timeago").timeago();
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = parse(json, "noauth", acct_id);
+ if (templete != "") {
+ $("#ftl-after .no-data").hide();
+ }
+ $("#ftl-after").html(templete);
+ jQuery("time.timeago").timeago();
+ });
}
//ふぁぼ一覧
function faved(id, 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 start = "https://" + domain + "/api/v1/statuses/" + id + "/favourited_by";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var templete = userparse(json, '', acct_id);
- if (templete != "") {
- $("#toot-fav .no-data").hide();
- }
- $("#toot-fav").html(templete);
- jQuery("time.timeago").timeago();
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = userparse(json, "", acct_id);
+ if (templete != "") {
+ $("#toot-fav .no-data").hide();
+ }
+ $("#toot-fav").html(templete);
+ jQuery("time.timeago").timeago();
+ });
}
//ブースト一覧
function rted(id, 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 start = "https://" + domain + "/api/v1/statuses/" + id + "/reblogged_by";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var templete = userparse(json, '', acct_id);
- $("#toot-rt").html(templete);
- jQuery("time.timeago").timeago();
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = userparse(json, "", acct_id);
+ $("#toot-rt").html(templete);
+ jQuery("time.timeago").timeago();
+ });
}
//URL等のコピー
function cbCopy(mode) {
@@ -517,13 +560,12 @@ function cbCopy(mode) {
var domain = urls[1];
if (mode == "emb") {
var emb = '';
- execCopy(emb)
- M.toast({ html: lang.lang_details_embed, displayLength: 1500 })
+ execCopy(emb);
+ M.toast({ html: lang.lang_details_embed, displayLength: 1500 });
} else {
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(//g, "$1");
html = $.strip_tags(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) {
@@ -555,28 +596,32 @@ function trans(tar, to) {
tar = "zh";
}
$("#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);
fetch(exec, {
- method: 'GET',
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (text) {
- $("#toot-this .additional").html('' + text.text + '');
- });
+ method: "GET"
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(text) {
+ $("#toot-this .additional").html('' + text.text + "");
+ });
}
//ブラウザで開く
function brws() {
var url = $("#tootmodal").attr("data-url");
- postMessage(["openUrl", url], "*")
+ postMessage(["openUrl", url], "*");
}
//外部からトゥート開く
function detEx(url, acct_id) {
@@ -585,33 +630,36 @@ function detEx(url, acct_id) {
}
var domain = localStorage.getItem("domain_" + acct_id);
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, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (!json.statuses) {
- postMessage(["openUrl", url], "*")
- } else {
- var id = json.statuses[0].id;
- $(".loadp").text($(".loadp").attr("href"));
- $(".loadp").removeClass("loadp");
- details(id, acct_id, 0)
- }
-
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (!json.statuses) {
+ postMessage(["openUrl", url], "*");
+ } else {
+ var id = json.statuses[0].id;
+ $(".loadp").text($(".loadp").attr("href"));
+ $(".loadp").removeClass("loadp");
+ details(id, acct_id, 0);
+ }
+ });
return;
-}
\ No newline at end of file
+}
diff --git a/app/js/tl/directory.js b/app/js/tl/directory.js
index 33e8be84..85470633 100644
--- a/app/js/tl/directory.js
+++ b/app/js/tl/directory.js
@@ -1,74 +1,76 @@
//ディレクトリ
//ディレクトリトグル
function dirMenu() {
- $("#dir-contents").html("");
- directory();
- $("#left-menu div").removeClass("active");
- $("#dirMenu").addClass("active");
- $(".menu-content").addClass("hide");
- $("#dir-box").removeClass("hide");
+ $("#dir-contents").html("");
+ directory();
+ $("#left-menu div").removeClass("active");
+ $("#dirMenu").addClass("active");
+ $(".menu-content").addClass("hide");
+ $("#dir-box").removeClass("hide");
}
function dirselCk() {
- var acct = $("#dir-acct-sel").val();
- if (acct == "noauth") {
- $("#dirNoAuth").removeClass("hide");
- } else {
- $("#dirNoAuth").addClass("hide");
- directory();
- }
+ var acct = $("#dir-acct-sel").val();
+ if (acct == "noauth") {
+ $("#dirNoAuth").removeClass("hide");
+ } else {
+ $("#dirNoAuth").addClass("hide");
+ directory();
+ }
}
function directory(isMore) {
- var order = $("[name=sort]:checked").val()
- if (!order) {
- order = "active"
- }
- var local_only = $("#local_only:checked").val()
- if (local_only) {
- local_only = "true"
- } else {
- local_only = "false"
- }
- var acct_id = $("#dir-acct-sel").val();
- if (acct_id == "noauth") {
- var domain = $("#dirNoAuth-url").val();
- var at = "";
- } else {
- var domain = localStorage.getItem("domain_" + acct_id);
- var at = localStorage.getItem("acct_" + acct_id + "_at");
- }
- if (isMore) {
- var addOffset = $("#dir-contents .cvo").length
- } else {
- var addOffset = 0
- $("#dir-contents").html("");
- }
- var start = "https://" + domain + "/api/v1/directory?order=" + order + "&local=" + local_only + "&offset=" + addOffset
- console.log(start)
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ var order = $("[name=sort]:checked").val();
+ if (!order) {
+ order = "active";
+ }
+ var local_only = $("#local_only:checked").val();
+ if (local_only) {
+ local_only = "true";
+ } else {
+ local_only = "false";
+ }
+ var acct_id = $("#dir-acct-sel").val();
+ if (acct_id == "noauth") {
+ var domain = $("#dirNoAuth-url").val();
+ var at = "";
+ } else {
+ var domain = localStorage.getItem("domain_" + acct_id);
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
+ }
+ if (isMore) {
+ var addOffset = $("#dir-contents .cvo").length;
+ } else {
+ var addOffset = 0;
+ $("#dir-contents").html("");
+ }
+ var start = "https://" + domain + "/api/v1/directory?order=" + order + "&local=" + local_only + "&offset=" + addOffset;
+ console.log(start);
+ fetch(start, {
+ method: "GET",
+ headers: {
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- //todo(error);
- console.error(error);
- }).then(function (json) {
- if (json) {
- $("#moreDir").removeClass("disabled")
- var html = userparse(json, null, acct_id, "dir", null)
- $("#dir-contents").append(html)
- jQuery("time.timeago").timeago();
- } else {
- $("#moreDir").addClass("disabled")
- }
-
- });
-}
\ No newline at end of file
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ $("#moreDir").removeClass("disabled");
+ var html = userparse(json, null, acct_id, "dir", null);
+ $("#dir-contents").append(html);
+ jQuery("time.timeago").timeago();
+ } else {
+ $("#moreDir").addClass("disabled");
+ }
+ });
+}
diff --git a/app/js/tl/dm.js b/app/js/tl/dm.js
index 4602c2d5..8c1f7078 100644
--- a/app/js/tl/dm.js
+++ b/app/js/tl/dm.js
@@ -1,36 +1,38 @@
//DM(Conv) TL
function dm(acct_id, tlid, type, delc, voice) {
-
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/conversations";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var templete = '' + dmListParse(json, type, acct_id, tlid, "", mute) + '
';
- localStorage.setItem("lastobj_" + tlid, json[0].id)
- $("#timeline_" + tlid).html(templete);
- additional(acct_id, tlid);
- jQuery("time.timeago").timeago();
- todc();
- //reload(type, '', acct_id, tlid, data, mute, delc,voice);
- $(window).scrollTop(0);
- });
-
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = '' + dmListParse(json, type, acct_id, tlid, "", mute) + "
";
+ localStorage.setItem("lastobj_" + tlid, json[0].id);
+ $("#timeline_" + tlid).html(templete);
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ todc();
+ //reload(type, '', acct_id, tlid, data, mute, delc,voice);
+ $(window).scrollTop(0);
+ });
}
function dmmore(tlid) {
var multi = localStorage.getItem("column");
@@ -38,44 +40,50 @@ function dmmore(tlid) {
var acct_id = obj[tlid].domain;
var domain = localStorage.getItem("domain_" + acct_id);
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 type = "dm";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var templete = '' + dmListParse(json, type, acct_id, tlid, "", mute) + '
';
- $("#timeline_" + tlid).append(templete);
- additional(acct_id, tlid);
- jQuery("time.timeago").timeago();
- moreloading = false;
})
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = '' + dmListParse(json, type, acct_id, tlid, "", mute) + "
";
+ $("#timeline_" + tlid).append(templete);
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ moreloading = false;
+ });
}
//DMオブジェクトパーサー(トゥート)
function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
- var templete = '';
+ var templete = "";
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 = 're,rt,fav,qt,del,pin,red';
+ var actb = "re,rt,fav,qt,del,pin,red";
if (actb) {
- var actb = actb.split(',');
+ var actb = actb.split(",");
var disp = {};
for (var k = 0; k < actb.length; k++) {
if (k < 4) {
@@ -208,7 +216,7 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
}
var local = [];
var times = [];
- Object.keys(obj).forEach(function (key) {
+ Object.keys(obj).forEach(function(key) {
var conv_id = obj[key].id;
var toot = obj[key].last_status;
var dis_name = escapeHTML(toot.account.display_name);
@@ -219,14 +227,12 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
}
//絵文字があれば
if (actemojick) {
- Object.keys(toot.account.emojis).forEach(function (key5) {
+ Object.keys(toot.account.emojis).forEach(function(key5) {
var emoji = toot.account.emojis[key5];
var shortcode = emoji.shortcode;
- var emoji_url = '';
+ var emoji_url = '';
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
-
});
}
var noticeavatar = "";
@@ -242,7 +248,7 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
var fullname = toot.account.acct + "@" + domain;
}
if (useremp) {
- Object.keys(useremp).forEach(function (key10) {
+ Object.keys(useremp).forEach(function(key10) {
var user = useremp[key10];
if (user == fullname) {
boostback = "emphasized";
@@ -257,19 +263,19 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
var locked = "";
}
if (!toot.application) {
- var via = '';
+ var via = "";
viashow = "hide";
} else {
var via = escapeHTML(toot.application.name);
//強調チェック
- Object.keys(emp).forEach(function (key6) {
+ Object.keys(emp).forEach(function(key6) {
var cli = emp[key6];
if (cli == via) {
boostback = "emphasized";
}
});
//ミュートチェック
- Object.keys(mute).forEach(function (key7) {
+ Object.keys(mute).forEach(function(key7) {
var cli = mute[key7];
if (cli == via) {
boostback = "hide";
@@ -284,20 +290,20 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
var spoil = escapeHTML(toot.spoiler_text);
var spoiler = "cw cw_hide_" + toot.id;
var api_spoil = "gray";
- var spoiler_show = '' + lang.lang_parse_cwshow + '
';
+ var spoiler_show = '' + lang.lang_parse_cwshow + "
";
} else {
- var ct1 = toot.content.split('
').length + toot.content.split('
').length - 2;
- var ct2 = toot.content.split('').length + toot.content.split('
').length - 2;
- if (ct1 > ct2) { var ct = ct1; } else { var ct = ct2; }
+ var ct1 = toot.content.split("").length + toot.content.split("
").length - 2;
+ var ct2 = toot.content.split("").length + toot.content.split("
").length - 2;
+ 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)) {
- var content = '' + lang.lang_parse_fulltext + '
' + toot.content
- var spoil = '' + $.mb_substr($.strip_tags(
- toot.content), 0, 100) +
- '' + lang.lang_parse_autofold + '';
+ var content = '' + lang.lang_parse_fulltext + "
" + toot.content;
+ var spoil = '' + $.mb_substr($.strip_tags(toot.content), 0, 100) + '' + lang.lang_parse_autofold + "";
var spoiler = "cw cw_hide_" + toot.id;
- var spoiler_show = '' + lang.lang_parse_more + '
';
+ var spoiler_show = '' + lang.lang_parse_more + "
";
} else {
var content = toot.content;
var spoil = escapeHTML(toot.spoiler_text);
@@ -305,14 +311,13 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
var spoiler_show = "";
}
}
- var urls = $.strip_tags(content).replace(/\n/g, " ").match(
- /https?:\/\/([-a-zA-Z0-9@.]+)\/?(?!.*((media|tags)|mentions)).*([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)?/
- );
+ var urls = $.strip_tags(content)
+ .replace(/\n/g, " ")
+ .match(/https?:\/\/([-a-zA-Z0-9@.]+)\/?(?!.*((media|tags)|mentions)).*([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)?/);
if (urls) {
- var analyze = '' + lang.lang_parse_url + '
';
+ var analyze = "' + lang.lang_parse_url + "
";
} else {
- var analyze = '';
+ var analyze = "";
}
var viewer = "";
var hasmedia = "";
@@ -324,11 +329,10 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
}
//絵文字があれば
if (emojick) {
- Object.keys(toot.emojis).forEach(function (key5) {
+ Object.keys(toot.emojis).forEach(function(key5) {
var emoji = toot.emojis[key5];
var shortcode = emoji.shortcode;
- var emoji_url = '';
+ var emoji_url = '';
var regExp = new RegExp(":" + shortcode + ":", "g");
content = content.replace(regExp, emoji_url);
spoil = spoil.replace(regExp, emoji_url);
@@ -342,11 +346,10 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
}
//絵文字があれば
if (nicoemojick) {
- Object.keys(toot.profile_emojis).forEach(function (keynico) {
+ Object.keys(toot.profile_emojis).forEach(function(keynico) {
var emoji = toot.profile_emojis[keynico];
var shortcode = emoji.shortcode;
- var emoji_url = '';
+ var emoji_url = '';
var regExp = new RegExp(":" + shortcode + ":", "g");
content = content.replace(regExp, emoji_url);
spoil = spoil.replace(regExp, emoji_url);
@@ -366,21 +369,17 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
if (mediack) {
hasmedia = "hasmedia";
var cwdt = 100 / toot.media_attachments.length;
- Object.keys(toot.media_attachments).forEach(function (key2) {
+ Object.keys(toot.media_attachments).forEach(function(key2) {
var media = toot.media_attachments[key2];
var purl = media.preview_url;
media_ids = media_ids + media.id + ",";
var url = media.url;
if (toot.sensitive && nsfw) {
- var sense = "sensitive"
+ var sense = "sensitive";
} else {
- var sense = ""
+ var sense = "";
}
- viewer = viewer + '';
+ viewer = viewer + "';
});
media_ids = media_ids.slice(0, -1);
} else {
@@ -392,24 +391,21 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
//メンションであれば
if (menck) {
mentions = "";
- Object.keys(toot.mentions).forEach(function (key3) {
+ Object.keys(toot.mentions).forEach(function(key3) {
var mention = toot.mentions[key3];
- mentions = mentions + '@' + mention.acct + ' ';
+ mentions = mentions + "@' + mention.acct + " ";
});
- mentions = '' + mentions + '
';
+ mentions = '' + mentions + "
";
}
var tagck = toot.tags[0];
var tags = "";
//タグであれば
if (tagck) {
- Object.keys(toot.tags).forEach(function (key4) {
+ Object.keys(toot.tags).forEach(function(key4) {
var tag = toot.tags[key4];
- tags = tags + '#' + tag.name + ':TL Toot ' +
- 'Pin ';
+ tags = tags + '#' + tag.name + ":TL Toot ' + "Pin ';
});
- tags = '' + tags + '
';
+ tags = '' + tags + "
";
}
//アニメ再生
if (gif == "yes") {
@@ -419,13 +415,13 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
}
//ワードミュート
if (wordmute) {
- Object.keys(wordmute).forEach(function (key8) {
+ Object.keys(wordmute).forEach(function(key8) {
var worde = wordmute[key8];
if (worde) {
if (worde.tag) {
var word = worde.tag;
} else {
- var word = worde
+ var word = worde;
}
var regExp = new RegExp(word, "g");
if ($.strip_tags(content).match(regExp)) {
@@ -436,7 +432,7 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
}
//ワード強調
if (wordemp) {
- Object.keys(wordemp).forEach(function (key9) {
+ Object.keys(wordemp).forEach(function(key9) {
var word = wordemp[key9];
if (word) {
var word = word.tag;
@@ -465,23 +461,21 @@ function dmListParse(obj, mix, acct_id, tlid, popup, mutefilter) {
if (cards.image) {
var twiImg = '
';
} else {
- var twiImg = '';
+ var twiImg = "";
}
- analyze = '';
+ analyze = '";
}
if (cards.title) {
- analyze = "URL" + lang.lang_cards_check + ":
Title:" + escapeHTML(cards.title) + "
" +
- escapeHTML(cards.description) + "";
+ analyze = 'URL' + lang.lang_cards_check + ":
Title:" + escapeHTML(cards.title) + "
" + escapeHTML(cards.description) + "";
}
if (cards.html) {
analyze = cards.html + 'picture_in_picture_alt';
}
-
}
//Ticker
var tickerdom = "";
if (ticker) {
- var tickerdata = localStorage.getItem("ticker")
+ var tickerdata = localStorage.getItem("ticker");
if (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++) {
var value = tickerdata[i];
if (value.domain == thisdomain) {
- var tickerdom = ' ' + escapeHTML(value.name) + ' ';
+ var tickerdom = ' ' + escapeHTML(value.name) + " ";
break;
}
}
}
}
- templete = templete + '';
+ templete = templete + '' + '
' + notice + home + "
" + '
' + '' + noticeavatar + "
" + '
' + dis_name + ' @' + toot.account.acct + locked + "
" + '
' + date(toot.created_at, datetype) + "" + "
" + '
" + '
' + "
";
});
return templete;
}
diff --git a/app/js/tl/filter.js b/app/js/tl/filter.js
index 6ada0237..adc4b2db 100644
--- a/app/js/tl/filter.js
+++ b/app/js/tl/filter.js
@@ -5,13 +5,13 @@ function mediaToggle(tlid) {
if (media) {
localStorage.removeItem("media_" + tlid);
$("#sta-media-" + tlid).text("Off");
- $("#sta-media-" + tlid).css("color", 'red');
- $("#timeline_" + tlid).removeClass("media-filter")
+ $("#sta-media-" + tlid).css("color", "red");
+ $("#timeline_" + tlid).removeClass("media-filter");
} else {
localStorage.setItem("media_" + tlid, "true");
$("#sta-media-" + tlid).text("On");
- $("#sta-media-" + tlid).css("color", '#009688');
- $("#timeline_" + tlid).addClass("media-filter")
+ $("#sta-media-" + tlid).css("color", "#009688");
+ $("#timeline_" + tlid).addClass("media-filter");
}
}
//各TL上方のBT[BTOnly/BTExc/Off]
@@ -20,21 +20,21 @@ function ebtToggle(tlid) {
if (ebt == "true") {
localStorage.setItem("ebt_" + tlid, "but");
$("#sta-bt-" + tlid).text("BT Only");
- $("#sta-bt-" + tlid).css("color", '#ff9800');
- $("#timeline_" + tlid).addClass("except-bt-filter")
- $("#timeline_" + tlid).removeClass("bt-filter")
+ $("#sta-bt-" + tlid).css("color", "#ff9800");
+ $("#timeline_" + tlid).addClass("except-bt-filter");
+ $("#timeline_" + tlid).removeClass("bt-filter");
} else if (ebt == "but") {
localStorage.removeItem("ebt_" + tlid);
$("#sta-bt-" + tlid).text("Off");
- $("#sta-bt-" + tlid).css("color", 'red');
- $("#timeline_" + tlid).removeClass("bt-filter")
- $("#timeline_" + tlid).removeClass("except-bt-filter")
+ $("#sta-bt-" + tlid).css("color", "red");
+ $("#timeline_" + tlid).removeClass("bt-filter");
+ $("#timeline_" + tlid).removeClass("except-bt-filter");
} else {
localStorage.setItem("ebt_" + tlid, "true");
$("#sta-bt-" + tlid).text("BT Ex");
- $("#sta-bt-" + tlid).css("color", '#009688');
- $("#timeline_" + tlid).addClass("bt-filter")
- $("#timeline_" + tlid).removeClass("except-bt-filter")
+ $("#sta-bt-" + tlid).css("color", "#009688");
+ $("#timeline_" + tlid).addClass("bt-filter");
+ $("#timeline_" + tlid).removeClass("except-bt-filter");
}
}
//各TL上方のMedia[On/Off]をチェック
@@ -42,12 +42,12 @@ function mediaCheck(tlid) {
var media = localStorage.getItem("media_" + tlid);
if (media) {
$("#sta-media-" + tlid).text("On");
- $("#sta-media-" + tlid).css("color", '#009688');
- $("#timeline_" + tlid).addClass("media-filter")
+ $("#sta-media-" + tlid).css("color", "#009688");
+ $("#timeline_" + tlid).addClass("media-filter");
} else {
$("#sta-media-" + tlid).text("Off");
- $("#sta-media-" + tlid).css("color", 'red');
- $("#timeline_" + tlid).removeClass("media-filter")
+ $("#sta-media-" + tlid).css("color", "red");
+ $("#timeline_" + tlid).removeClass("media-filter");
}
}
//各TL上方のBT[On/Off]をチェック
@@ -55,19 +55,19 @@ function ebtCheck(tlid) {
var ebt = localStorage.getItem("ebt_" + tlid);
if (ebt == "true") {
$("#sta-bt-" + tlid).text("BT Ex");
- $("#sta-bt-" + tlid).css("color", '#009688');
- $("#timeline_" + tlid).addClass("bt-filter")
- $("#timeline_" + tlid).removeClass("except-bt-filter")
+ $("#sta-bt-" + tlid).css("color", "#009688");
+ $("#timeline_" + tlid).addClass("bt-filter");
+ $("#timeline_" + tlid).removeClass("except-bt-filter");
} else if (ebt == "but") {
$("#sta-bt-" + tlid).text("BT Only");
- $("#sta-bt-" + tlid).css("color", '#ff9800');
- $("#timeline_" + tlid).addClass("except-bt-filter")
- $("#timeline_" + tlid).removeClass("bt-filter")
+ $("#sta-bt-" + tlid).css("color", "#ff9800");
+ $("#timeline_" + tlid).addClass("except-bt-filter");
+ $("#timeline_" + tlid).removeClass("bt-filter");
} else {
$("#sta-bt-" + tlid).text("Off");
- $("#sta-bt-" + tlid).css("color", 'red');
- $("#timeline_" + tlid).removeClass("bt-filter")
- $("#timeline_" + tlid).removeClass("except-bt-filter")
+ $("#sta-bt-" + tlid).css("color", "red");
+ $("#timeline_" + tlid).removeClass("bt-filter");
+ $("#timeline_" + tlid).removeClass("except-bt-filter");
}
}
/* 削除追跡*/
@@ -76,12 +76,12 @@ function catchToggle(tlid) {
if (catchck) {
localStorage.removeItem("catch_" + tlid);
$("#sta-del-" + tlid).text("Off");
- $("#sta-del-" + tlid).css("color", 'red');
+ $("#sta-del-" + tlid).css("color", "red");
parseColumn(tlid);
} else {
localStorage.setItem("catch_" + tlid, "true");
$("#sta-del-" + tlid).text("On");
- $("#sta-del-" + tlid).css("color", '#009688');
+ $("#sta-del-" + tlid).css("color", "#009688");
parseColumn(tlid);
}
}
@@ -89,16 +89,15 @@ function catchCheck(tlid) {
var catchck = localStorage.getItem("catch_" + tlid);
if (catchck) {
$("#sta-del-" + tlid).text("On");
- $("#sta-del-" + tlid).css("color", '#009688');
+ $("#sta-del-" + tlid).css("color", "#009688");
} else {
$("#sta-del-" + tlid).text("Off");
- $("#sta-del-" + tlid).css("color", 'red');
+ $("#sta-del-" + tlid).css("color", "red");
}
}
function delreset(tlid) {
$("[tlid=" + tlid + "] .by_delcatch").hide();
$("[tlid=" + tlid + "] .by_delcatch").remove();
-
}
/*ワードフィルター機能*/
function filterMenu() {
@@ -109,50 +108,52 @@ function filterMenu() {
}
function filter() {
$("#filtered-words").html("");
- $("#filter-edit-id").val("")
+ $("#filter-edit-id").val("");
var acct_id = $("#filter-acct-sel").val();
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
- var start = "https://" + domain + "/api/v1/filters"
+ var start = "https://" + domain + "/api/v1/filters";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json) {
- var filters = "";
- Object.keys(json).forEach(function (key) {
- var filterword = json[key];
- var context = filterword.context.join(',');
- filters = filters + escapeHTML(filterword.phrase) + '(for ' + context + '):' + lang.lang_edit + '/' + lang.lang_del + '
';
- });
- if (filters == "") {
- filters = lang.lang_filter_nodata + "
";
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
- $("#filtered-words").html(filters);
- } else {
- $("#filtered-words").html(lang_filter_nodata);
- }
- });
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ var filters = "";
+ Object.keys(json).forEach(function(key) {
+ var filterword = json[key];
+ var context = filterword.context.join(",");
+ filters = filters + escapeHTML(filterword.phrase) + '(for ' + context + "):' + lang.lang_edit + '/' + lang.lang_del + "
";
+ });
+ if (filters == "") {
+ filters = lang.lang_filter_nodata + "
";
+ }
+ $("#filtered-words").html(filters);
+ } else {
+ $("#filtered-words").html(lang_filter_nodata);
+ }
+ });
}
function filterTime(day, hour, min) {
- $("#days_filter").val(day)
- $("#hours_filter").val(hour)
- $("#mins_filter").val(min)
+ $("#days_filter").val(day);
+ $("#hours_filter").val(hour);
+ $("#mins_filter").val(min);
}
function makeNewFilter() {
var acct_id = $("#filter-acct-sel").val();
@@ -171,7 +172,7 @@ function makeNewFilter() {
cont.push("thread");
}
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 who = $("#wholeword_filter:checked").val();
@@ -183,30 +184,34 @@ function makeNewFilter() {
var at = localStorage.getItem("acct_" + acct_id + "_at");
if ($("#filter-edit-id").val()) {
var start = "https://" + domain + "/api/v1/filters/" + $("#filter-edit-id").val();
- var method = "PUT"
+ var method = "PUT";
} else {
- var start = "https://" + domain + "/api/v1/filters"
- var method = "POST"
+ var start = "https://" + domain + "/api/v1/filters";
+ var method = "POST";
}
var httpreq = new XMLHttpRequest();
httpreq.open(method, start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
- httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
- httpreq.send(JSON.stringify({
- phrase: phr,
- context: cont,
- irreversible: exc,
- whole_word: who,
- expires_in: time
- }));
- httpreq.onreadystatechange = function () {
+ httpreq.send(
+ JSON.stringify({
+ phrase: phr,
+ context: cont,
+ irreversible: exc,
+ whole_word: who,
+ expires_in: time
+ })
+ );
+ httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
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();
- filterUpdate(acct_id)
+ filterUpdate(acct_id);
$("#filter-add-word").val("");
$("#home_filter").prop("checked", false);
$("#local_filter").prop("checked", false);
@@ -218,9 +223,9 @@ function makeNewFilter() {
$("#hours_filter").val("0");
$("#mins_filter").val("0");
$("#add-filter-btn").text(lang.lang_add);
- $("#filter-edit-id").val("")
+ $("#filter-edit-id").val("");
}
- }
+ };
}
function filterEdit(id, acct_id) {
$("#filter-add-word").val("");
@@ -237,48 +242,52 @@ function filterEdit(id, acct_id) {
$("#filter-edit-id").val(id);
var domain = localStorage.getItem("domain_" + acct_id);
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, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json) {
- var now = new Date();
- now = now.getTime();
- var now = Math.floor(now / 1000);
- $("#filter-add-word").val(json.phrase);
- Object.keys(json.context).forEach(function (key) {
- var context = json.context[key];
- $("[value=" + context + "]").prop("checked", true);
- });
- if (json.irreversible) {
- $("#except_filter").prop("checked", true);
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
- if (json.whole_word) {
- $("#wholeword_filter").prop("checked", true);
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ var now = new Date();
+ now = now.getTime();
+ var now = Math.floor(now / 1000);
+ $("#filter-add-word").val(json.phrase);
+ Object.keys(json.context).forEach(function(key) {
+ var context = json.context[key];
+ $("[value=" + context + "]").prop("checked", true);
+ });
+ if (json.irreversible) {
+ $("#except_filter").prop("checked", true);
+ }
+ if (json.whole_word) {
+ $("#wholeword_filter").prop("checked", true);
+ }
+ var expires = date(json.expires_at, "unix") - now;
+ var mins = Math.floor(expires / 60) % 60;
+ var hours = Math.floor(expires / 3600) % 24;
+ var days = Math.floor(expires / 3600 / 24);
+ $("#days_filter").val(days);
+ $("#hours_filter").val(hours);
+ $("#mins_filter").val(mins);
}
- var expires = date(json.expires_at, 'unix') - now;
- var mins = Math.floor(expires / 60) % 60;
- var hours = Math.floor(expires / 3600) % 24;
- var days = Math.floor(expires / 3600 / 24);
- $("#days_filter").val(days);
- $("#hours_filter").val(hours);
- $("#mins_filter").val(mins);
- }
- });
+ });
}
function filterDel(id, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id);
@@ -286,43 +295,49 @@ function filterDel(id, acct_id) {
var start = "https://" + domain + "/api/v1/filters/" + id;
var httpreq = new XMLHttpRequest();
httpreq.open("DELETE", start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
- httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send();
- httpreq.onreadystatechange = function () {
+ httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
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();
- filterUpdate(acct_id)
+ filterUpdate(acct_id);
}
- }
+ };
}
function getFilter(acct_id) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) != "misskey") {
- var start = "https://" + domain + "/api/v1/filters"
+ var start = "https://" + domain + "/api/v1/filters";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
+ }
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ localStorage.setItem("filter_" + acct_id, JSON.stringify(json));
});
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- localStorage.setItem("filter_" + acct_id, JSON.stringify(json));
- });
} else {
localStorage.setItem("filter_" + acct_id, JSON.stringify({}));
}
@@ -339,7 +354,7 @@ function getFilterType(json, type) {
type = "notifi";
}
var mutedfilters = [];
- Object.keys(json).forEach(function (key) {
+ Object.keys(json).forEach(function(key) {
var filterword = json[key];
var phrases = filterword.phrase;
if (filterword.context.join(",").indexOf(type) !== -1) {
@@ -351,32 +366,34 @@ function getFilterType(json, type) {
function filterUpdate(acct_id) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
- var start = "https://" + domain + "/api/v1/filters"
+ var start = "https://" + domain + "/api/v1/filters";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- localStorage.setItem("filter_" + acct_id, JSON.stringify(json));
- filterUpdateInternal(json, "home");
- filterUpdateInternal(json, "local");
- filterUpdateInternal(json, "notf");
- filterUpdateInternal(json, "pub");
- });
-
-
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ localStorage.setItem("filter_" + acct_id, JSON.stringify(json));
+ filterUpdateInternal(json, "home");
+ filterUpdateInternal(json, "local");
+ filterUpdateInternal(json, "notf");
+ filterUpdateInternal(json, "pub");
+ });
}
function filterUpdateInternal(json, type) {
var home = getFilterType(json, type);
@@ -386,11 +403,13 @@ function filterUpdateInternal(json, type) {
home = home.concat(wordmute);
}
if (home) {
- $("[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");
$("[toot-id=" + id + "]").removeClass("hide");
- var text = $(elem).find('.toot').html();
- Object.keys(home).forEach(function (key8) {
+ var text = $(elem)
+ .find(".toot")
+ .html();
+ Object.keys(home).forEach(function(key8) {
var word = home[key8];
var regExp = new RegExp(word.replace(/[.*+?^=!:${}()|[\]\/\\]/g, "\\$&"), "g");
if ($.strip_tags(text).match(regExp)) {
@@ -408,41 +427,41 @@ function filterUpdateInternal(json, type) {
*/
//通知フィルター
function exclude(key) {
- localStorage.setItem("exclude-" + key, "")
+ localStorage.setItem("exclude-" + key, "");
var excludetxt = localStorage.getItem("exclude-" + key);
- if ($('#exc-reply-' + key + ':checked').val()) {
- excludetxt = "?exclude_types[]=mention"
+ if ($("#exc-reply-" + key + ":checked").val()) {
+ excludetxt = "?exclude_types[]=mention";
}
- if ($('#exc-fav-' + key + ':checked').val()) {
- if (excludetxt || excludetxt !="") {
- excludetxt = excludetxt + "&exclude_types[]=favourite"
+ if ($("#exc-fav-" + key + ":checked").val()) {
+ if (excludetxt || excludetxt != "") {
+ excludetxt = excludetxt + "&exclude_types[]=favourite";
} else {
- excludetxt = "?exclude_types[]=favourite"
+ excludetxt = "?exclude_types[]=favourite";
}
}
- if ($('#exc-bt-' + key + ':checked').val()) {
- if (excludetxt || excludetxt !="") {
- excludetxt = excludetxt + "&exclude_types[]=reblog"
+ if ($("#exc-bt-" + key + ":checked").val()) {
+ if (excludetxt || excludetxt != "") {
+ excludetxt = excludetxt + "&exclude_types[]=reblog";
} else {
- excludetxt = "?exclude_types[]=reblog"
+ excludetxt = "?exclude_types[]=reblog";
}
}
- if ($('#exc-follow-' + key + ':checked').val()) {
- if (excludetxt || excludetxt !="") {
- excludetxt = excludetxt + "&exclude_types[]=follow"
+ if ($("#exc-follow-" + key + ":checked").val()) {
+ if (excludetxt || excludetxt != "") {
+ excludetxt = excludetxt + "&exclude_types[]=follow";
} else {
- excludetxt = "?exclude_types[]=follow"
+ excludetxt = "?exclude_types[]=follow";
}
}
- if ($('#exc-poll-' + key + ':checked').val()) {
- if (excludetxt || excludetxt !="") {
- excludetxt = excludetxt + "&exclude_types[]=poll"
+ if ($("#exc-poll-" + key + ":checked").val()) {
+ if (excludetxt || excludetxt != "") {
+ excludetxt = excludetxt + "&exclude_types[]=poll";
} else {
- excludetxt = "?exclude_types[]=poll"
+ excludetxt = "?exclude_types[]=poll";
}
} else {
}
- localStorage.setItem("exclude-" + key, excludetxt)
+ localStorage.setItem("exclude-" + key, excludetxt);
parseColumn(key);
}
function excludeCk(key, target) {
@@ -451,30 +470,30 @@ function excludeCk(key, target) {
return "";
}
if (~exc.indexOf(target)) {
- return "checked"
+ return "checked";
} else {
return "";
}
}
-function checkNotfFilter(tlid){
+function checkNotfFilter(tlid) {
var excludetxt = localStorage.getItem("exclude-" + tlid);
- if(!excludetxt || excludetxt != ""){
+ if (!excludetxt || excludetxt != "") {
return true;
- }else{
+ } else {
return false;
}
}
-function resetNotfFilter(tlid){
- localStorage.setItem("exclude-" + tlid, "")
+function resetNotfFilter(tlid) {
+ localStorage.setItem("exclude-" + tlid, "");
parseColumn(tlid);
}
-function notfFilter(id,tlid,acct_id){
+function notfFilter(id, tlid, acct_id) {
var excludetxt = localStorage.getItem("exclude-" + tlid);
- if (excludetxt || excludetxt !="") {
- excludetxt = excludetxt + "&account_id="+id
+ if (excludetxt || excludetxt != "") {
+ excludetxt = excludetxt + "&account_id=" + id;
} else {
- excludetxt = "?account_id="+id
+ excludetxt = "?account_id=" + id;
}
- localStorage.setItem("exclude-" + tlid, excludetxt)
+ localStorage.setItem("exclude-" + tlid, excludetxt);
parseColumn(tlid);
-}
\ No newline at end of file
+}
diff --git a/app/js/tl/list.js b/app/js/tl/list.js
index 05b10678..33fb1478 100644
--- a/app/js/tl/list.js
+++ b/app/js/tl/list.js
@@ -3,78 +3,82 @@ function listMenu() {
$("#listMenu").addClass("active");
$(".menu-content").addClass("hide");
$("#list-box").removeClass("hide");
- $('ul.tabs').tabs('select_tab', 'src-sta');
+ $("ul.tabs").tabs("select_tab", "src-sta");
$("#src-contents").html("");
}
-
function list() {
$("#lists-user").html("");
var acct_id = $("#list-acct-sel").val();
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") {
- var start = "https://" + domain + "/api/users/lists/list"
+ var start = "https://" + domain + "/api/users/lists/list";
fetch(start, {
- method: 'POST',
+ method: "POST",
body: JSON.stringify({
i: at
- }),
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
+ })
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ var lists = "";
+ Object.keys(json).forEach(function(key) {
+ var list = json[key];
+ lists = lists + escapeHTML(list.title) + ":' + lang.lang_list_show + "
";
+ });
+ $("#lists").html(lists);
+ } else {
+ $("#lists").html(lang.lang_list_nodata);
+ }
});
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json) {
- var lists = "";
- Object.keys(json).forEach(function (key) {
- var list = json[key];
- lists = lists + escapeHTML(list.title) + ':' + lang.lang_list_show + '
';
- });
- $("#lists").html(lists);
- } else {
- $("#lists").html(lang.lang_list_nodata);
- }
- });
} else {
- var start = "https://" + domain + "/api/v1/lists"
+ var start = "https://" + domain + "/api/v1/lists";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json) {
- var lists = "";
- Object.keys(json).forEach(function (key) {
- var list = json[key];
- lists = lists + escapeHTML(list.title) + ':' + lang.lang_list_show + '/' + lang.lang_list_users + '
';
- });
- $("#lists").html(lists);
- } else {
- $("#lists").html(lang.lang_list_nodata);
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ var lists = "";
+ Object.keys(json).forEach(function(key) {
+ var list = json[key];
+ lists = lists + escapeHTML(list.title) + ":' + lang.lang_list_show + "/' + lang.lang_list_users + "
";
+ });
+ $("#lists").html(lists);
+ } else {
+ $("#lists").html(lang.lang_list_nodata);
+ }
+ });
}
}
function makeNewList() {
@@ -83,176 +87,196 @@ function makeNewList() {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) != "misskey") {
- var start = "https://" + domain + "/api/v1/lists"
+ var start = "https://" + domain + "/api/v1/lists";
var httpreq = new XMLHttpRequest();
- httpreq.open('POST', start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
- httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
+ httpreq.open("POST", start, true);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
- httpreq.send(JSON.stringify({
- title: text
- }));
- httpreq.onreadystatechange = function () {
+ httpreq.send(
+ JSON.stringify({
+ title: text
+ })
+ );
+ httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
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-add").val("")
+ $("#list-add").val("");
}
- }
+ };
} else {
- var start = "https://" + domain + "/api/users/lists/create"
+ var start = "https://" + domain + "/api/users/lists/create";
var httpreq = new XMLHttpRequest();
- httpreq.open('POST', start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
+ httpreq.open("POST", start, true);
+ httpreq.setRequestHeader("Content-Type", "application/json");
httpreq.responseType = "json";
- httpreq.send(JSON.stringify({
- i: at,
- title: text
- }));
- httpreq.onreadystatechange = function () {
+ httpreq.send(
+ JSON.stringify({
+ i: at,
+ title: text
+ })
+ );
+ httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
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-add").val("")
+ $("#list-add").val("");
}
- }
+ };
}
}
function listShow(id, title, acct_id) {
localStorage.setItem("list_" + id + "_" + acct_id, title);
- tl('list', id, acct_id, 'add');
+ tl("list", id, acct_id, "add");
}
function listUser(id, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id);
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, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json) {
- var lists = "";
- var templete = userparse(json, '', acct_id);
- if (!json[0]) {
- templete = lang.lang_list_nouser;
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
- $("#lists-user").html(templete);
- jQuery("time.timeago").timeago();
- } else {
- $("#lists-user").html(lang.lang_list_nouser);
- }
- });
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ var lists = "";
+ var templete = userparse(json, "", acct_id);
+ if (!json[0]) {
+ templete = lang.lang_list_nouser;
+ }
+ $("#lists-user").html(templete);
+ jQuery("time.timeago").timeago();
+ } else {
+ $("#lists-user").html(lang.lang_list_nouser);
+ }
+ });
}
function hisList(user, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) != "misskey") {
- var start = "https://" + domain + "/api/v1/lists"
+ var start = "https://" + domain + "/api/v1/lists";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json) {
- var lists = lang.lang_list_add + "
";
- Object.keys(json).forEach(function (key) {
- var list = json[key];
- lists = lists + '' + escapeHTML(list.title) + '
';
- });
- $("#his-lists-a").html(lists);
- } else {
- $("#his-lists-a").html(lang.lang_list_nodata);
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- });
- var start = "https://" + domain + "/api/v1/accounts/" + user + "/lists"
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ var lists = lang.lang_list_add + "
";
+ Object.keys(json).forEach(function(key) {
+ var list = json[key];
+ lists = lists + "' + escapeHTML(list.title) + "
";
+ });
+ $("#his-lists-a").html(lists);
+ } else {
+ $("#his-lists-a").html(lang.lang_list_nodata);
+ }
+ });
+ var start = "https://" + domain + "/api/v1/accounts/" + user + "/lists";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json) {
- var lists = lang.lang_list_remove + "
";
- Object.keys(json).forEach(function (key) {
- var list = json[key];
- lists = lists + '' + escapeHTML(list.title) + '
';
- });
- $("#his-lists-b").html(lists);
- } else {
- $("#his-lists-b").html(lang.lang_list_nodata);
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ var lists = lang.lang_list_remove + "
";
+ Object.keys(json).forEach(function(key) {
+ var list = json[key];
+ lists = lists + "' + escapeHTML(list.title) + "
";
+ });
+ $("#his-lists-b").html(lists);
+ } else {
+ $("#his-lists-b").html(lang.lang_list_nodata);
+ }
+ });
} else {
- var start = "https://" + domain + "/api/users/lists/list"
+ var start = "https://" + domain + "/api/users/lists/list";
fetch(start, {
- method: 'POST',
+ method: "POST",
body: JSON.stringify({
i: at
- }),
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
+ })
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ var lists = "";
+ Object.keys(json).forEach(function(key) {
+ var list = json[key];
+ lists = lists + list.title + ":' + lang.lang_list_show + "/' + lang.lang_list_add + lang.lang_list_add_misskey + "
";
+ });
+ $("#his-lists-a").html(lists);
+ } else {
+ $("#his-lists-a").html(lang.lang_list_nodata);
+ }
});
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json) {
- var lists = "";
- Object.keys(json).forEach(function (key) {
- var list = json[key];
- lists = lists + list.title + ':' + lang.lang_list_show + '/' + lang.lang_list_add + lang.lang_list_add_misskey + '
';
- });
- $("#his-lists-a").html(lists);
- } else {
- $("#his-lists-a").html(lang.lang_list_nodata);
- }
- });
$("#his-lists-b").html("");
}
}
@@ -260,61 +284,65 @@ function listAdd(id, user, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") {
- var start = "https://" + domain + "/api/users/lists/push"
+ var start = "https://" + domain + "/api/users/lists/push";
var i = {
i: at,
listId: id,
userId: user
- }
+ };
} else {
- var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts"
+ var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts";
var i = {
account_ids: [user]
- }
+ };
}
var httpreq = new XMLHttpRequest();
- httpreq.open('POST', start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
- httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
+ httpreq.open("POST", start, true);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send(JSON.stringify(i));
- httpreq.onreadystatechange = function () {
+ httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
- if(this.status!==200){ setLog(start, this.status, this.response); }
- hisList(user, acct_id)
+ if (this.status !== 200) {
+ setLog(start, this.status, this.response);
+ }
+ hisList(user, acct_id);
}
- }
+ };
}
function listRemove(id, user, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("mode_" + domain) == "misskey") {
- var start = "https://" + domain + "/api/users/lists/push"
- var method = 'POST'
+ var start = "https://" + domain + "/api/users/lists/push";
+ var method = "POST";
var i = {
i: at,
listId: id,
userId: user
- }
+ };
} else {
- var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts"
- var method = 'DELETE'
+ var start = "https://" + domain + "/api/v1/lists/" + id + "/accounts";
+ var method = "DELETE";
var i = {
account_ids: [user]
- }
+ };
}
var httpreq = new XMLHttpRequest();
httpreq.open(method, start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
- httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.setRequestHeader("Authorization", "Bearer " + at);
httpreq.responseType = "json";
httpreq.send(JSON.stringify(i));
- httpreq.onreadystatechange = function () {
+ httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response;
- if(this.status!==200){ setLog(start, this.status, this.response); }
- hisList(user, acct_id)
+ if (this.status !== 200) {
+ setLog(start, this.status, this.response);
+ }
+ hisList(user, acct_id);
}
- }
-}
\ No newline at end of file
+ };
+}
diff --git a/app/js/tl/mix.js b/app/js/tl/mix.js
index 20f17382..f6dc9ed4 100644
--- a/app/js/tl/mix.js
+++ b/app/js/tl/mix.js
@@ -1,6 +1,6 @@
//Integrated TL
function mixtl(acct_id, tlid, type, delc, voice) {
- localStorage.removeItem("morelock")
+ localStorage.removeItem("morelock");
localStorage.setItem("now", type);
todo("Integrated TL Loading...(Local)");
//まずLocal
@@ -8,110 +8,114 @@ function mixtl(acct_id, tlid, type, delc, voice) {
var at = localStorage.getItem("acct_" + acct_id + "_at");
var start = "https://" + domain + "/api/v1/timelines/public?local=true";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (jsonL) {
- var start = "https://" + domain + "/api/v1/timelines/home";
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
+ })
+ .then(function(response) {
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
todo(error);
+ setLog(start, "JSON", error);
console.error(error);
- }).then(function (jsonH) {
- var homearr = [];
- var timeline = jsonL.concat(jsonH);
- timeline.sort(function (a, b) {
- if (date(a.created_at, "unix") >= date(b.created_at, "unix")) return -1;
- if (date(a.created_at, "unix") < date(b.created_at, "unix")) return 1;
- return 0;
- });
- if (type == "integrated") {
- timeline.splice(20);
- }
- var templete = "";
- if (localStorage.getItem("filter_" + acct_id) != "undefined") {
- var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "mix");
- } else {
- var mute = [];
- }
- Object.keys(timeline).forEach(function (key) {
- var pkey = key * 1 + 1;
- if (pkey < timeline.length) {
- if (date(timeline[key].created_at, "unix") != date(timeline[pkey].created_at, "unix")) {
- if (type == "integrated") {
- templete = templete + parse([timeline[key]], '', acct_id, tlid, "", mute, "mix");
- } else if (type == "plus") {
- if (timeline[key].account.acct == timeline[key].account.username) {
- templete = templete + parse([timeline[key]], '', acct_id, tlid, "", mute, "plus");
+ })
+ .then(function(jsonL) {
+ var start = "https://" + domain + "/api/v1/timelines/home";
+ fetch(start, {
+ method: "GET",
+ headers: {
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
+ }
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(jsonH) {
+ var homearr = [];
+ var timeline = jsonL.concat(jsonH);
+ timeline.sort(function(a, b) {
+ if (date(a.created_at, "unix") >= date(b.created_at, "unix")) return -1;
+ if (date(a.created_at, "unix") < date(b.created_at, "unix")) return 1;
+ return 0;
+ });
+ if (type == "integrated") {
+ timeline.splice(20);
+ }
+ var templete = "";
+ if (localStorage.getItem("filter_" + acct_id) != "undefined") {
+ var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "mix");
+ } else {
+ var mute = [];
+ }
+ Object.keys(timeline).forEach(function(key) {
+ var pkey = key * 1 + 1;
+ if (pkey < timeline.length) {
+ if (date(timeline[key].created_at, "unix") != date(timeline[pkey].created_at, "unix")) {
+ if (type == "integrated") {
+ templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "mix");
+ } else if (type == "plus") {
+ if (timeline[key].account.acct == timeline[key].account.username) {
+ templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "plus");
+ }
+ }
}
}
- }
- }
-
- });
- $("#landing_" + tlid).hide();
- $("#timeline_" + tlid).html(templete);
- mixre(acct_id, tlid, type, mute, delc, voice);
- additional(acct_id, tlid);
- jQuery("time.timeago").timeago();
- todc();
+ });
+ $("#landing_" + tlid).hide();
+ $("#timeline_" + tlid).html(templete);
+ mixre(acct_id, tlid, type, mute, delc, voice);
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ todc();
+ });
});
- });
}
-
//Streamingに接続
function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (localStorage.getItem("streaming_" + acct_id)) {
- var wss = localStorage.getItem("streaming_" + acct_id)
+ var wss = localStorage.getItem("streaming_" + acct_id);
} else {
- var wss = "wss://" + domain
+ var wss = "wss://" + domain;
}
- var startHome = wss +
- "/api/v1/streaming/?stream=user&access_token=" + at;
- var startLocal = wss +
- "/api/v1/streaming/?stream=public:local&access_token=" + at;
+ var startHome = wss + "/api/v1/streaming/?stream=user&access_token=" + at;
+ var startLocal = wss + "/api/v1/streaming/?stream=public:local&access_token=" + at;
var wshid = websocketHome.length;
var wslid = websocketLocal.length;
websocketHome[wshid] = new WebSocket(startHome);
websocketLocal[wslid] = new WebSocket(startLocal);
- websocketHome[wshid].onopen = function (mess) {
+ websocketHome[wshid].onopen = function(mess) {
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");
- }
- websocketLocal[wslid].onopen = function (mess) {
+ };
+ websocketLocal[wslid].onopen = function(mess) {
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");
- }
- websocketLocal[wslid].onmessage = function (mess) {
+ };
+ websocketLocal[wslid].onmessage = function(mess) {
console.log(["Receive Streaming API:(Integrated:Local)", obj]);
var obj = JSON.parse(JSON.parse(mess.data).payload);
@@ -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 + "]").remove();
}
-
} 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 (voice) {
- say(obj.content)
+ say(obj.content);
}
var templete = parse([obj], type, acct_id, tlid, "", mute, "mix");
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
pool = templete + pool;
} else {
- pool = templete
+ pool = templete;
}
localStorage.setItem("pool_" + tlid, pool);
@@ -147,18 +150,17 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
} else {
todo("二重取得発生中");
}
-
}
- }
- websocketHome[wshid].onmessage = function (mess) {
+ };
+ websocketHome[wshid].onmessage = function(mess) {
console.log(["Receive Streaming API:(Integrated:Home)", obj]);
var obj = JSON.parse(JSON.parse(mess.data).payload);
var type = JSON.parse(mess.data).event;
if (type == "delete") {
if (del > 10) {
- reconnector(tlid, type, acct_id, data)
+ reconnector(tlid, type, acct_id, data);
} else {
- localStorage.setItem("delete", del * 1 + 1)
+ localStorage.setItem("delete", del * 1 + 1);
}
if (delc == "true") {
$("[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") {
localStorage.removeItem("delete");
if (TLtype == "integrated") {
- var templete = parse([obj], '', acct_id, tlid);
+ var templete = parse([obj], "", acct_id, tlid);
} else if (TLtype == "plus") {
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 {
var templete = "";
}
}
if ($("#timeline_" + tlid + " [toot-id=" + obj.id + "]").length < 1) {
if (voice) {
- say(obj.content)
+ say(obj.content);
}
var templete = parse([obj], type, acct_id, tlid, "", mute, "mix");
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
pool = templete + pool;
} else {
- pool = templete
+ pool = templete;
}
localStorage.setItem("pool_" + tlid, pool);
@@ -199,13 +201,13 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
todo("二重取得発生中");
}
}
- }
- websocketLocal[wslid].onerror = function (error) {
- console.error('WebSocketLocal Error')
+ };
+ websocketLocal[wslid].onerror = function(error) {
+ console.error("WebSocketLocal Error");
console.error(error);
if (mode == "error") {
$("#notice_icon_" + tlid).addClass("red-text");
- todo('WebSocket Error ' + error);
+ todo("WebSocket Error " + error);
} else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1;
localStorage.setItem("wserror_" + tlid, errorct);
@@ -214,11 +216,11 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
}
}
};
- websocketLocal[wslid].onclose = function () {
- console.warn('WebSocketLocal Closing:' + tlid);
+ websocketLocal[wslid].onclose = function() {
+ console.warn("WebSocketLocal Closing:" + tlid);
if (mode == "error") {
$("#notice_icon_" + tlid).addClass("red-text");
- todo('WebSocket Closed');
+ todo("WebSocket Closed");
} else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1;
localStorage.setItem("wserror_" + tlid, errorct);
@@ -227,11 +229,11 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
}
}
};
- websocketHome[wshid].onerror = function (error) {
- console.error(['WebSocketHome Error', error])
+ websocketHome[wshid].onerror = function(error) {
+ console.error(["WebSocketHome Error", error]);
if (mode == "error") {
$("#notice_icon_" + tlid).addClass("red-text");
- todo('WebSocket Error ' + error);
+ todo("WebSocket Error " + error);
} else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1;
localStorage.setItem("wserror_" + tlid, errorct);
@@ -240,11 +242,11 @@ function mixre(acct_id, tlid, TLtype, mute, delc, voice, mode) {
}
}
};
- websocketHome[wshid].onclose = function () {
- console.warn('WebSocketHome Closing:' + tlid);
+ websocketHome[wshid].onclose = function() {
+ console.warn("WebSocketHome Closing:" + tlid);
if (mode == "error") {
$("#notice_icon_" + tlid).addClass("red-text");
- todo('WebSocket Closed');
+ todo("WebSocket Closed");
} else {
var errorct = localStorage.getItem("wserror_" + tlid) * 1 + 1;
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");
}
}
-
};
-
}
//ある程度のスクロールで発火
@@ -266,82 +266,88 @@ function mixmore(tlid, type) {
todo("Integrated TL MoreLoading...(Local)");
var domain = localStorage.getItem("domain_" + acct_id);
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;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (jsonL) {
- var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid;
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
+ })
+ .then(function(response) {
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
todo(error);
+ setLog(start, "JSON", error);
console.error(error);
- }).then(function (jsonH) {
- var homearr = [];
- var timeline = jsonL.concat(jsonH);
- timeline.sort(function (a, b) {
- if (date(a.created_at, "unix") > date(b.created_at, "unix")) return -1;
- if (date(a.created_at, "unix") < date(b.created_at, "unix")) return 1;
- return 0;
- });
- timeline.splice(20);
- var templete = "";
- Object.keys(timeline).forEach(function (key) {
- var pkey = key * 1 + 1;
- if (pkey < 20) {
- if (date(timeline[key].created_at, "unix") != date(timeline[pkey].created_at, "unix")) {
- if (localStorage.getItem("filter_" + acct_id) != "undefined") {
- var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "mix");
- } else {
- var mute = [];
- }
- if (type == "integrated") {
- templete = templete + parse([timeline[key]], '', acct_id, tlid, "", mute, "mix");
- } else if (type == "plus") {
- if (timeline[key].account.acct == timeline[key].account.username) {
- templete = templete + parse([timeline[key]], '', acct_id, tlid, "", mute, "mix");
+ })
+ .then(function(jsonL) {
+ var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid;
+ fetch(start, {
+ method: "GET",
+ headers: {
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
+ }
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(jsonH) {
+ var homearr = [];
+ var timeline = jsonL.concat(jsonH);
+ timeline.sort(function(a, b) {
+ if (date(a.created_at, "unix") > date(b.created_at, "unix")) return -1;
+ if (date(a.created_at, "unix") < date(b.created_at, "unix")) return 1;
+ return 0;
+ });
+ timeline.splice(20);
+ var templete = "";
+ Object.keys(timeline).forEach(function(key) {
+ var pkey = key * 1 + 1;
+ if (pkey < 20) {
+ if (date(timeline[key].created_at, "unix") != date(timeline[pkey].created_at, "unix")) {
+ if (localStorage.getItem("filter_" + acct_id) != "undefined") {
+ var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "mix");
+ } else {
+ var mute = [];
+ }
+ if (type == "integrated") {
+ templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "mix");
+ } else if (type == "plus") {
+ if (timeline[key].account.acct == timeline[key].account.username) {
+ templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "mix");
+ }
+ }
}
}
- }
- }
+ });
- });
-
- $("#timeline_" + tlid).append(templete);
- additional(acct_id, tlid);
- jQuery("time.timeago").timeago();
- moreloading = false;
- todc();
+ $("#timeline_" + tlid).append(templete);
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ moreloading = false;
+ todc();
+ });
});
- });
-
-
}
diff --git a/app/js/tl/notification.js b/app/js/tl/notification.js
index 48463025..094a314c 100644
--- a/app/js/tl/notification.js
+++ b/app/js/tl/notification.js
@@ -2,9 +2,9 @@
//取得+Streaming接続
function notf(acct_id, tlid, sys) {
if (sys == "direct") {
- notfColumn(acct_id, tlid, sys)
+ notfColumn(acct_id, tlid, sys);
} else {
- notfCommon(acct_id, tlid, sys)
+ notfCommon(acct_id, tlid, sys);
}
}
function notfColumn(acct_id, tlid, sys) {
@@ -20,7 +20,7 @@ function notfColumn(acct_id, tlid, sys) {
var misskey = true;
var start = "https://" + domain + "/api/i/notifications";
httpreq.open("POST", start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
+ httpreq.setRequestHeader("Content-Type", "application/json");
var body = JSON.stringify({
i: at
});
@@ -33,26 +33,28 @@ function notfColumn(acct_id, tlid, sys) {
}
var start = "https://" + domain + "/api/v1/notifications" + exc;
httpreq.open("GET", start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
- httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.setRequestHeader("Authorization", "Bearer " + at);
var body = "";
}
httpreq.responseType = "json";
httpreq.send(body);
- httpreq.onreadystatechange = function () {
+ httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
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");
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]) {
var templete = "";
var lastnotf = localStorage.getItem("lastnotf_" + acct_id);
localStorage.setItem("lastnotf_" + acct_id, json[0].id);
- Object.keys(json).forEach(function (key) {
+ Object.keys(json).forEach(function(key) {
var obj = json[key];
if (lastnotf == obj.id && key > 0 && native == "yes") {
var ct = key;
@@ -64,8 +66,7 @@ function notfColumn(acct_id, tlid, sys) {
body: ct + lang.lang_notf_new,
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") {
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 (misskey) {
- templete = templete + misskeyParse([obj], 'notf', acct_id, tlid, -1, mute);
+ templete = templete + misskeyParse([obj], "notf", acct_id, tlid, -1, mute);
} else {
- templete = templete + parse([obj], 'notf', acct_id, tlid, -1, mute);
+ templete = templete + parse([obj], "notf", acct_id, tlid, -1, mute);
}
} else {
if (misskey) {
- templete = templete + misskeyUserparse([obj], 'notf', acct_id, tlid, -1, mute);
+ templete = templete + misskeyUserparse([obj], "notf", acct_id, tlid, -1, mute);
} else {
- templete = templete + userparse([obj.account], 'notf', acct_id, tlid, -1);
+ templete = templete + userparse([obj.account], "notf", acct_id, tlid, -1);
}
-
}
});
templete = templete + '';
@@ -99,26 +99,23 @@ function notfColumn(acct_id, tlid, sys) {
if (markers == "yes") {
markers = true;
} else {
- markers = false
+ markers = false;
}
if (markers) {
- getMarker(tlid, "notf", acct_id)
+ getMarker(tlid, "notf", acct_id);
}
}
- }
+ };
if (!misskey) {
if (localStorage.getItem("streaming_" + acct_id)) {
- var wss = localStorage.getItem("streaming_" + acct_id)
+ var wss = localStorage.getItem("streaming_" + acct_id);
} else {
- var wss = "wss://" + domain
+ var wss = "wss://" + domain;
}
- var start = wss + "/api/v1/streaming/?stream=user&access_token=" +
- at;
+ var start = wss + "/api/v1/streaming/?stream=user&access_token=" + at;
} else {
- var start = "wss://" + domain + "/?i=" +
- at;
+ var start = "wss://" + domain + "/?i=" + at;
}
-
}
function notfCommon(acct_id, tlid, sys) {
todo("Notifications Loading...");
@@ -132,104 +129,103 @@ function notfCommon(acct_id, tlid, sys) {
var misskey = true;
var start = "https://" + domain + "/api/i/notifications";
var i = {
- method: 'POST',
+ method: "POST",
headers: {
- 'content-type': 'application/json',
+ "content-type": "application/json"
},
body: JSON.stringify({
i: at
})
- }
+ };
} else {
var misskey = false;
var start = "https://" + domain + "/api/v1/notifications";
var i = {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
+ }
+ };
}
- fetch(start, i).then(function (response) {
- console.log("header to get param:" + response.headers.get('link'));
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json[0]) {
- var templete = "";
- var lastnotf = localStorage.getItem("lastnotf_" + acct_id);
- localStorage.setItem("lastnotf_" + acct_id, json[0].id);
- Object.keys(json).forEach(function (key) {
- var obj = json[key];
- if (lastnotf == obj.id && key > 0 && native == "yes") {
- var ct = key;
- if (key > 14) {
- ct = "15+";
+ fetch(start, i)
+ .then(function(response) {
+ console.log("header to get param:" + response.headers.get("link"));
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json[0]) {
+ var templete = "";
+ var lastnotf = localStorage.getItem("lastnotf_" + acct_id);
+ localStorage.setItem("lastnotf_" + acct_id, json[0].id);
+ Object.keys(json).forEach(function(key) {
+ var obj = json[key];
+ if (lastnotf == obj.id && key > 0 && native == "yes") {
+ var ct = key;
+ if (key > 14) {
+ ct = "15+";
+ }
+ var os = localStorage.getItem("platform");
+ var options = {
+ body: ct + lang.lang_notf_new,
+ icon: localStorage.getItem("prof_" + acct_id)
+ };
+ var n = new Notification("TheDesk:" + domain, options);
}
- var os = localStorage.getItem("platform");
- var options = {
- body: ct + lang.lang_notf_new,
- icon: localStorage.getItem("prof_" + acct_id)
- };
- var n = new Notification('TheDesk:' + domain, options);
-
- }
- if (localStorage.getItem("filter_" + acct_id) != "undefined") {
- var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "notif");
- } else {
- var mute = [];
- }
- if (obj.type != "follow") {
- if (misskey) {
- templete = templete + misskeyParse([obj], 'notf', acct_id, 'notf', -1, mute);
+ if (localStorage.getItem("filter_" + acct_id) != "undefined") {
+ var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "notif");
} else {
- templete = templete + parse([obj], 'notf', acct_id, 'notf', -1, mute);
+ var mute = [];
}
- } else {
- if (misskey) {
- templete = templete + misskeyUserparse([obj], 'notf', acct_id, 'notf', -1, mute);
+ if (obj.type != "follow") {
+ if (misskey) {
+ templete = templete + misskeyParse([obj], "notf", acct_id, "notf", -1, mute);
+ } else {
+ templete = templete + parse([obj], "notf", acct_id, "notf", -1, mute);
+ }
} else {
- templete = templete + userparse([obj.account], 'notf', acct_id, 'notf', -1);
+ if (misskey) {
+ templete = templete + misskeyUserparse([obj], "notf", acct_id, "notf", -1, mute);
+ } else {
+ templete = templete + userparse([obj.account], "notf", acct_id, "notf", -1);
+ }
}
-
- }
- });
- $("div[data-notf=" + acct_id + "]").html(templete);
- $("#landing_" + tlid).hide();
- jQuery("time.timeago").timeago();
- }
- $("#notf-box").addClass("fetched");
- todc();
- notfWS(misskey, acct_id, tlid, domain, at)
- });
-
+ });
+ $("div[data-notf=" + acct_id + "]").html(templete);
+ $("#landing_" + tlid).hide();
+ jQuery("time.timeago").timeago();
+ }
+ $("#notf-box").addClass("fetched");
+ todc();
+ notfWS(misskey, acct_id, tlid, domain, at);
+ });
}
function notfWS(misskey, acct_id, tlid, domain, at) {
if (!misskey) {
if (localStorage.getItem("streaming_" + acct_id)) {
- var wss = localStorage.getItem("streaming_" + acct_id)
+ var wss = localStorage.getItem("streaming_" + acct_id);
} else {
- var wss = "wss://" + domain
+ var wss = "wss://" + domain;
}
- var start = wss + "/api/v1/streaming/?stream=user&access_token=" +
- at;
+ var start = wss + "/api/v1/streaming/?stream=user&access_token=" + at;
var wsid = websocketNotf.length;
websocketNotf[acct_id] = new WebSocket(start);
- websocketNotf[acct_id].onopen = function (mess) {
- console.table({ "acct_id": acct_id, "type": "Connect Streaming API(Notf)", "domain": domain, "message": [mess] })
+ websocketNotf[acct_id].onopen = function(mess) {
+ console.table({ acct_id: acct_id, type: "Connect Streaming API(Notf)", domain: domain, message: [mess] });
$("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)]);
var popup = localStorage.getItem("popup");
if (!popup) {
@@ -243,9 +239,9 @@ function notfWS(misskey, acct_id, tlid, domain, at) {
if (!$("#unread_" + tlid + " .material-icons").hasClass("teal-text")) {
//markers show中はダメ
if (obj.type != "follow") {
- templete = parse([obj], 'notf', acct_id, 'notf', popup);
+ templete = parse([obj], "notf", acct_id, "notf", popup);
} 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) {
$("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 + "]").remove();
}
- }
- websocketNotf[acct_id].onerror = function (error) {
- console.error('WebSocket Error ' + error);
- errorct++;
- console.log(errorct)
- if (errorct < 3) {
- notfWS(misskey, acct_id, tlid, domain, at)
- }
-
};
- websocketNotf[acct_id].onclose = function (error) {
- console.error('WebSocket Close ' + error);
+ websocketNotf[acct_id].onerror = function(error) {
+ console.error("WebSocket Error " + error);
errorct++;
- console.log(errorct)
+ console.log(errorct);
if (errorct < 3) {
- notfWS(misskey, acct_id, tlid, domain, at)
+ notfWS(misskey, acct_id, tlid, domain, at);
+ }
+ };
+ websocketNotf[acct_id].onclose = function(error) {
+ console.error("WebSocket Close " + error);
+ errorct++;
+ console.log(errorct);
+ if (errorct < 3) {
+ notfWS(misskey, acct_id, tlid, domain, at);
}
-
};
}
}
//一定のスクロールで発火
function notfmore(tlid) {
- console.log({ "status": "kicked", "status": moreloading });
+ console.log({ status: "kicked", status: moreloading });
var multi = localStorage.getItem("column");
var obj = JSON.parse(multi);
var acct_id = obj[tlid].domain;
@@ -289,7 +283,9 @@ function notfmore(tlid) {
} else {
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 domain = localStorage.getItem("domain_" + acct_id);
if (sid && !moreloading) {
@@ -299,7 +295,7 @@ function notfmore(tlid) {
var misskey = true;
var start = "https://" + domain + "/api/i/notifications";
httpreq.open(POST, start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
+ httpreq.setRequestHeader("Content-Type", "application/json");
var body = JSON.stringify({
i: at,
untilID: sid
@@ -313,24 +309,26 @@ function notfmore(tlid) {
}
var start = "https://" + domain + "/api/v1/notifications" + exc;
httpreq.open("GET", start, true);
- httpreq.setRequestHeader('Content-Type', 'application/json');
- httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.setRequestHeader("Authorization", "Bearer " + at);
var body = "";
}
httpreq.responseType = "json";
httpreq.send(body);
- httpreq.onreadystatechange = function () {
+ httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
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]);
var max_id = httpreq.getResponseHeader("link").match(/[?&]{1}max_id=([0-9]+)/)[1];
if (json[0]) {
var templete = "";
var lastnotf = localStorage.getItem("lastnotf_" + acct_id);
localStorage.setItem("lastnotf_" + acct_id, json[0].id);
- Object.keys(json).forEach(function (key) {
+ Object.keys(json).forEach(function(key) {
var obj = json[key];
if (localStorage.getItem("filter_" + acct_id) != "undefined") {
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), "notif");
@@ -339,17 +337,16 @@ function notfmore(tlid) {
}
if (obj.type != "follow") {
if (misskey) {
- templete = templete + misskeyParse([obj], 'notf', acct_id, 'notf', -1, mute);
+ templete = templete + misskeyParse([obj], "notf", acct_id, "notf", -1, mute);
} else {
- templete = templete + parse([obj], 'notf', acct_id, 'notf', -1, mute);
+ templete = templete + parse([obj], "notf", acct_id, "notf", -1, mute);
}
} else {
if (misskey) {
- templete = templete + misskeyUserparse([obj], 'notf', acct_id, 'notf', -1, mute);
+ templete = templete + misskeyUserparse([obj], "notf", acct_id, "notf", -1, mute);
} else {
- templete = templete + userparse([obj.account], 'notf', acct_id, 'notf', -1);
+ templete = templete + userparse([obj.account], "notf", acct_id, "notf", -1);
}
-
}
});
moreloading = false;
@@ -361,49 +358,55 @@ function notfmore(tlid) {
$("#notf-box").addClass("fetched");
todc();
}
- }
+ };
}
}
//通知トグルボタン
function notfToggle(acct, tlid) {
if ($("#notf-box_" + tlid).hasClass("column-hide")) {
- $("#notf-box_" + tlid).css("display", "block")
- $("#notf-box_" + tlid).animate({
- 'height': '400px'
- }, {
- 'duration': 300,
- 'complete': function () {
- $("#notf-box_" + tlid).css("overflow-y", "scroll")
- $("#notf-box_" + tlid).removeClass("column-hide")
+ $("#notf-box_" + tlid).css("display", "block");
+ $("#notf-box_" + tlid).animate(
+ {
+ height: "400px"
+ },
+ {
+ duration: 300,
+ complete: function() {
+ $("#notf-box_" + tlid).css("overflow-y", "scroll");
+ $("#notf-box_" + tlid).removeClass("column-hide");
+ }
}
- });
+ );
} else {
- $("#notf-box_" + tlid).css("overflow-y", "hidden")
- $("#notf-box_" + tlid).animate({
- 'height': '0'
- }, {
- 'duration': 300,
- 'complete': function () {
- $("#notf-box_" + tlid).addClass("column-hide")
- $("#notf-box_" + tlid).css("display", "none")
+ $("#notf-box_" + tlid).css("overflow-y", "hidden");
+ $("#notf-box_" + tlid).animate(
+ {
+ height: "0"
+ },
+ {
+ duration: 300,
+ complete: function() {
+ $("#notf-box_" + tlid).addClass("column-hide");
+ $("#notf-box_" + tlid).css("display", "none");
+ }
}
- });
+ );
}
- notfCanceler(acct)
+ notfCanceler(acct);
}
function notfCanceler(acct) {
$(".notf-reply_" + acct).text(0);
- localStorage.removeItem("notf-reply_" + acct)
+ localStorage.removeItem("notf-reply_" + acct);
$(".notf-reply_" + acct).addClass("hide");
$(".notf-fav_" + acct).text(0);
- localStorage.removeItem("notf-fav_" + acct)
+ localStorage.removeItem("notf-fav_" + acct);
$(".notf-fav_" + acct).addClass("hide");
$(".notf-bt_" + acct).text(0);
- localStorage.removeItem("notf-bt_" + acct)
+ localStorage.removeItem("notf-bt_" + acct);
$(".notf-bt_" + acct).addClass("hide");
$(".notf-follow_" + acct).text(0);
- localStorage.removeItem("notf-follow_" + acct)
+ localStorage.removeItem("notf-follow_" + acct);
$(".notf-follow_" + acct).addClass("hide");
$(".notf-icon_" + acct).removeClass("red-text");
}
@@ -411,9 +414,9 @@ function allNotfRead() {
var multi = localStorage.getItem("multi");
if (multi) {
var obj = JSON.parse(multi);
- Object.keys(obj).forEach(function (key) {
- notfCanceler(key)
+ Object.keys(obj).forEach(function(key) {
+ notfCanceler(key);
});
}
}
-allNotfRead()
\ No newline at end of file
+allNotfRead();
diff --git a/app/js/tl/old-mix.js b/app/js/tl/old-mix.js
index 65708629..a89db7a5 100644
--- a/app/js/tl/old-mix.js
+++ b/app/js/tl/old-mix.js
@@ -1,119 +1,123 @@
//Integrated TL
function mixtl(acct_id, tlid) {
var type = "mix";
- localStorage.removeItem("morelock")
+ localStorage.removeItem("morelock");
localStorage.setItem("now", type);
todo("Integrated TL Loading...(Local)");
var domain = localStorage.getItem("domain_" + acct_id);
- var at = localStorage.getItem("acct_"+ acct_id + "_at");
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
//まずLocal
var start = "https://" + domain + "/api/v1/timelines/public?local=true";
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function(response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function(error) {
- todo(error);
- console.error(error);
- }).then(function(json) {
- //パースして描画
- var templete = parse(json, 'mix', acct_id, tlid);
- $("#timeline_" + tlid).html(templete[0]);
-
- jQuery("time.timeago").timeago();
- $(window).scrollTop(0);
- var locals = templete[1];
- var times = templete[2];
- todo("Integrated TL Loading...(Home)");
- //Home
- var start = "https://" + domain + "/api/v1/timelines/home";
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function(response) {
+ })
+ .then(function(response) {
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function(error) {
- todo(error);
- console.error(error);
- }).then(function(obj) {
- //ホームのオブジェクトをUnix時間で走査
- if (!$("[toot-id=" + obj[0].id + "]").length) {
- $("#timeline_" + tlid + " .cvo").first().before(parse([obj[0]], 'home',
- acct_id));
- //delete obj[0];
- }
- //Localが遅すぎてHomeの全てより過去の場合
- var unixL=date(json[0].created_at,"unix");
- var unixH=date(obj[obj.length-1].created_at,"unix");
- //console.log(unixH+"vs"+unixL)
- if(unixH < unixL){
- Object.keys(obj).forEach(function(key) {
- var skey = obj.length - key - 1;
- var toot = obj[key];
- console.log(toot);
- var id = toot.id;
- if ($("#timeline_" + tlid + " [toot-id=" + toot.id + "]").length < 1) {
- //console.log(toot.id);
- var tarunix = date(toot.created_at, 'unix');
- var beforekey2;
- var key2;
- //console.log(locals)
- //ホームのオブジェクトに対してLocalのオブジェクトを時間走査
- Object.keys(times).forEach(function(key2) {
- if (times[key2] < tarunix) {
- var local = json[key2].id;
- //console.log($.strip_tags(toot.content));
- html = parse(
- [toot], 'home', acct_id, tlid);
- $("#timeline_" + tlid + " [toot-id=" + local + "]").before(html);
- //console.log("#timeline_" + tlid + " [toot-id=" + local + "]");
- tarunix = 0;
- }
-
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
});
}
- });
- }else{
- html = parse(
- obj, 'home', acct_id, tlid);
- $("#timeline_" + tlid).html(html);
- }
- todc();
- mixre(acct_id, tlid);
- additional(acct_id, tlid);
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ //パースして描画
+ var templete = parse(json, "mix", acct_id, tlid);
+ $("#timeline_" + tlid).html(templete[0]);
+
jQuery("time.timeago").timeago();
+ $(window).scrollTop(0);
+ var locals = templete[1];
+ var times = templete[2];
+ todo("Integrated TL Loading...(Home)");
+ //Home
+ var start = "https://" + domain + "/api/v1/timelines/home";
+ fetch(start, {
+ method: "GET",
+ headers: {
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
+ }
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(obj) {
+ //ホームのオブジェクトをUnix時間で走査
+ if (!$("[toot-id=" + obj[0].id + "]").length) {
+ $("#timeline_" + tlid + " .cvo")
+ .first()
+ .before(parse([obj[0]], "home", acct_id));
+ //delete obj[0];
+ }
+ //Localが遅すぎてHomeの全てより過去の場合
+ var unixL = date(json[0].created_at, "unix");
+ var unixH = date(obj[obj.length - 1].created_at, "unix");
+ //console.log(unixH+"vs"+unixL)
+ if (unixH < unixL) {
+ Object.keys(obj).forEach(function(key) {
+ var skey = obj.length - key - 1;
+ var toot = obj[key];
+ console.log(toot);
+ var id = toot.id;
+ if ($("#timeline_" + tlid + " [toot-id=" + toot.id + "]").length < 1) {
+ //console.log(toot.id);
+ var tarunix = date(toot.created_at, "unix");
+ var beforekey2;
+ var key2;
+ //console.log(locals)
+ //ホームのオブジェクトに対してLocalのオブジェクトを時間走査
+ Object.keys(times).forEach(function(key2) {
+ if (times[key2] < tarunix) {
+ var local = json[key2].id;
+ //console.log($.strip_tags(toot.content));
+ html = parse([toot], "home", acct_id, tlid);
+ $("#timeline_" + tlid + " [toot-id=" + local + "]").before(html);
+ //console.log("#timeline_" + tlid + " [toot-id=" + local + "]");
+ tarunix = 0;
+ }
+ });
+ }
+ });
+ } else {
+ html = parse(obj, "home", acct_id, tlid);
+ $("#timeline_" + tlid).html(html);
+ }
+ todc();
+ mixre(acct_id, tlid);
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ });
});
- });
}
//Streamingに接続
function mixre(acct_id, tlid) {
var domain = localStorage.getItem("domain_" + acct_id);
- var at = localStorage.getItem("acct_"+ acct_id + "_at");
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
var type = "mix";
localStorage.setItem("now", type);
- var startHome = "wss://" + domain +
- "/api/v1/streaming/?stream=user&access_token=" + at;
+ var startHome = "wss://" + domain + "/api/v1/streaming/?stream=user&access_token=" + at;
- var startLocal = "wss://" + domain +
- "/api/v1/streaming/?stream=public:local&access_token=" + at;
+ var startLocal = "wss://" + domain + "/api/v1/streaming/?stream=public:local&access_token=" + at;
var wshid = websocketHome.length;
var wslid = websocketLocal.length;
websocketHome[wshid] = new WebSocket(startHome);
@@ -121,11 +125,11 @@ function mixre(acct_id, tlid) {
websocketHome[wshid].onopen = function(mess) {
console.log("Connect Streaming API(Home)");
$("#notice_icon_" + tlid).removeClass("red-text");
- }
+ };
websocketLocal[wslid].onopen = function(mess) {
console.log("Connect Streaming API(Local)");
$("#notice_icon_" + tlid).removeClass("red-text");
- }
+ };
websocketLocal[wslid].onmessage = function(mess) {
console.log("Receive Streaming API:");
@@ -136,20 +140,20 @@ function mixre(acct_id, tlid) {
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
} else if (type == "update") {
- var templete = parse([obj], '', acct_id, tlid);
- var pool = localStorage.getItem("pool_" + tlid);
- if (pool) {
- pool = templete + pool;
- } else {
- pool = templete
- }
- localStorage.setItem("pool_" + tlid, pool);
- scrollck();
- additional(acct_id, tlid);
- jQuery("time.timeago").timeago();
- todc();
+ var templete = parse([obj], "", acct_id, tlid);
+ var pool = localStorage.getItem("pool_" + tlid);
+ if (pool) {
+ pool = templete + pool;
+ } else {
+ pool = templete;
+ }
+ localStorage.setItem("pool_" + tlid, pool);
+ scrollck();
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ todc();
}
- }
+ };
websocketHome[wshid].onmessage = function(mess) {
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 + "]").remove();
} else if (type == "update") {
- var templete = parse([obj], '', acct_id, tlid);
- if (obj.visibility != "public" || obj.account.acct != obj.account.username) {
+ var templete = parse([obj], "", acct_id, tlid);
+ if (obj.visibility != "public" || obj.account.acct != obj.account.username) {
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
pool = templete + pool;
} else {
- pool = templete
+ pool = templete;
}
localStorage.setItem("pool_" + tlid, pool);
scrollck();
@@ -174,12 +178,12 @@ function mixre(acct_id, tlid) {
jQuery("time.timeago").timeago();
}
}
- }
+ };
websocketLocal[wslid].onerror = function(error) {
- console.error('WebSocket Error ' + error);
+ console.error("WebSocket Error " + error);
};
websocketHome[wshid].onerror = function(error) {
- console.error('WebSocket Error ' + error);
+ console.error("WebSocket Error " + error);
};
}
@@ -190,80 +194,87 @@ function mixmore(tlid) {
var acct_id = obj[tlid].domain;
todo("Integrated TL MoreLoading...(Local)");
var domain = localStorage.getItem("domain_" + acct_id);
- var at = localStorage.getItem("acct_"+ acct_id + "_at");
- var sid = $("#timeline_" + tlid + " .cvo").last().attr("toot-id");
- var len = $("#timeline_" + tlid + " .cvo").length
- var start = "https://" + domain +
- "/api/v1/timelines/public?local=true&max_id=" + sid;
- console.log(start);
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
+ var sid = $("#timeline_" + tlid + " .cvo")
+ .last()
+ .attr("toot-id");
+ var len = $("#timeline_" + tlid + " .cvo").length;
+ var start = "https://" + domain + "/api/v1/timelines/public?local=true&max_id=" + sid;
+ console.log(start);
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function(response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function(error) {
- todo(error);
- console.error(error);
- }).then(function(json) {
- var templete = parse(json, 'mix', acct_id, tlid);
- $("#timeline_" + tlid).append(templete[0]);
- var locals = templete[1];
- todo("Integrated TL MoreLoading...(Home)");
- console.log(sid);
- var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid;
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function(response) {
+ })
+ .then(function(response) {
if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function(error) {
- todo(error);
- console.error(error);
- }).then(function(obj) {
- if ($("[toot-id=" + obj[0].id + "]").length < 1) {
- $("#timeline_" + tlid + " .cvo").eq(len).before(parse([obj[0]], 'home',
- acct_id)+'');
- //delete obj[0];
- }
- Object.keys(obj).forEach(function(key) {
- var skey = obj.length - key - 1;
- var toot = obj[skey];
- var id = toot.id;
- var tarunix = date(toot.created_at, 'unix');
- var beforekey2;
- var key2;
- Object.keys(locals).forEach(function(key2) {
- if ($("[toot-id=" + toot.id + "]").length <1) {
- if (key2 > tarunix) {
- var local = locals[key2];
- $("#timeline_" + tlid + " [toot-id=" + local + "]").after(parse([toot], 'home',
- acct_id, tlid));
- tarunix = 2147483647;
- }
-
- }
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var templete = parse(json, "mix", acct_id, tlid);
+ $("#timeline_" + tlid).append(templete[0]);
+ var locals = templete[1];
+ todo("Integrated TL MoreLoading...(Home)");
+ console.log(sid);
+ var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid;
+ fetch(start, {
+ method: "GET",
+ headers: {
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
+ }
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(obj) {
+ if ($("[toot-id=" + obj[0].id + "]").length < 1) {
+ $("#timeline_" + tlid + " .cvo")
+ .eq(len)
+ .before(parse([obj[0]], "home", acct_id) + '');
+ //delete obj[0];
+ }
+ Object.keys(obj).forEach(function(key) {
+ var skey = obj.length - key - 1;
+ var toot = obj[skey];
+ var id = toot.id;
+ var tarunix = date(toot.created_at, "unix");
+ var beforekey2;
+ var key2;
+ Object.keys(locals).forEach(function(key2) {
+ if ($("[toot-id=" + toot.id + "]").length < 1) {
+ if (key2 > tarunix) {
+ var local = locals[key2];
+ $("#timeline_" + tlid + " [toot-id=" + local + "]").after(parse([toot], "home", acct_id, tlid));
+ tarunix = 2147483647;
+ }
+ }
+ });
+ });
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ todc();
});
- });
- additional(acct_id, tlid);
- jQuery("time.timeago").timeago();
- todc();
});
- });
-
-}
\ No newline at end of file
+}
diff --git a/app/js/tl/src.js b/app/js/tl/src.js
index 19e50de7..db174225 100644
--- a/app/js/tl/src.js
+++ b/app/js/tl/src.js
@@ -14,81 +14,83 @@ function searchMenu() {
function src(mode, offset) {
if (!offset) {
$("#src-contents").html("");
- var add = ""
+ var add = "";
} else {
- var add = "&type=accounts&offset=" + $("#src-accts .cvo").length
+ var add = "&type=accounts&offset=" + $("#src-accts .cvo").length;
}
var q = $("#src").val();
var acct_id = $("#src-acct-sel").val();
if (acct_id == "tootsearch") {
- tsAdd(q)
+ tsAdd(q);
return false;
}
localStorage.setItem("last-use", acct_id);
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
var m = q.match(/^#(.+)$/);
- if (m) { q = m[1]; }
+ if (m) {
+ q = m[1];
+ }
if (user == "--now") {
- var user = $('#his-data').attr("user-id");
+ var user = $("#his-data").attr("user-id");
}
if (!mode) {
- var start = "https://" + domain + "/api/v2/search?q=" + q + add
+ var start = "https://" + domain + "/api/v2/search?q=" + q + add;
} 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, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- src("v1")
- return false;
- }).then(function (json) {
- console.log(["Search", json]);
- //ハッシュタグ
- if (json.hashtags[0]) {
- var tags = "";
- Object.keys(json.hashtags).forEach(function (key4) {
- var tag = json.hashtags[key4];
- if (mode) {
- tags = tags + '#' + escapeHTML(tag) + '
';
- } else {
- tags = tags + graphDraw(tag, acct_id);
- }
-
- });
- $("#src-contents").append("Tags
" + tags);
- }
- //トゥート
- if (json.statuses[0]) {
- var templete = parse(json.statuses, '', acct_id);
- $("#src-contents").append("
Mentions
" + templete);
- }
- //アカウント
- if (json.accounts[0]) {
- var templete = userparse(json.accounts, '', acct_id);
- if (!offset) {
- $("#src-contents").append("
Accounts" + templete + '
more...');
- } else {
- $("#src-accts").append(templete)
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
-
- }
- jQuery("time.timeago").timeago();
- });
+ return response.json();
+ })
+ .catch(function(error) {
+ src("v1");
+ return false;
+ })
+ .then(function(json) {
+ console.log(["Search", json]);
+ //ハッシュタグ
+ if (json.hashtags[0]) {
+ var tags = "";
+ Object.keys(json.hashtags).forEach(function(key4) {
+ var tag = json.hashtags[key4];
+ if (mode) {
+ tags = tags + "#" + escapeHTML(tag) + "
";
+ } else {
+ tags = tags + graphDraw(tag, acct_id);
+ }
+ });
+ $("#src-contents").append("Tags
" + tags);
+ }
+ //トゥート
+ if (json.statuses[0]) {
+ var templete = parse(json.statuses, "", acct_id);
+ $("#src-contents").append("
Mentions
" + templete);
+ }
+ //アカウント
+ if (json.accounts[0]) {
+ var templete = userparse(json.accounts, "", acct_id);
+ if (!offset) {
+ $("#src-contents").append('
Accounts' + templete + '
more...');
+ } else {
+ $("#src-accts").append(templete);
+ }
+ }
+ jQuery("time.timeago").timeago();
+ });
}
function tsAdd(q) {
var add = {
@@ -102,115 +104,120 @@ function tsAdd(q) {
obj.push(add);
var json = JSON.stringify(obj);
localStorage.setItem("column", json);
- parseColumn('add');
+ parseColumn("add");
}
function tootsearch(tlid, q) {
- var start = "https://tootsearch.chotto.moe/api/v1/search?from=0&sort=created_at%3Adesc&q=" + q
- console.log("Toot srrach at " + start)
+ var start = "https://tootsearch.chotto.moe/api/v1/search?from=0&sort=created_at%3Adesc&q=" + q;
+ console.log("Toot srrach at " + start);
$("#notice_" + tlid).text("tootsearch(" + q + ")");
$("#notice_icon_" + tlid).text("search");
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json'
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json"
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (raw) {
- var templete = "";
- var json = raw.hits.hits;
- var max_id = raw["hits"].length;
- for (var i = 0; i < json.length; i++) {
- var toot = json[i]["_source"];
- if (lastid != toot.uri) {
- if (toot && toot.account) {
- templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch")
- }
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
- var lastid = toot.uri;
- }
- if (!templete) {
- templete = lang.lang_details_nodata;
- } else {
- templete = templete + '';
- }
- $("#timeline_" + tlid).html(templete);
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(raw) {
+ var templete = "";
+ var json = raw.hits.hits;
+ var max_id = raw["hits"].length;
+ for (var i = 0; i < json.length; i++) {
+ var toot = json[i]["_source"];
+ if (lastid != toot.uri) {
+ if (toot && toot.account) {
+ templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch");
+ }
+ }
+ var lastid = toot.uri;
+ }
+ if (!templete) {
+ templete = lang.lang_details_nodata;
+ } else {
+ templete = templete + '';
+ }
+ $("#timeline_" + tlid).html(templete);
- jQuery("time.timeago").timeago();
- });
+ jQuery("time.timeago").timeago();
+ });
}
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;
- 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_icon_" + tlid).text("search");
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json'
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json"
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (raw) {
- var templete = "";
- var json = raw.hits.hits;
- var max_id = raw["hits"].length;
- for (var i = 0; i < json.length; i++) {
- var toot = json[i]["_source"];
- if (lastid != toot.uri) {
- if (toot && toot.account) {
- templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch")
- }
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
- var lastid = toot.uri;
- }
- if (!templete) {
- templete = lang.lang_details_nodata;
- } else {
- templete = templete + '';
- }
- $("#timeline_" + tlid).append(templete);
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(raw) {
+ var templete = "";
+ var json = raw.hits.hits;
+ var max_id = raw["hits"].length;
+ for (var i = 0; i < json.length; i++) {
+ var toot = json[i]["_source"];
+ if (lastid != toot.uri) {
+ if (toot && toot.account) {
+ templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch");
+ }
+ }
+ var lastid = toot.uri;
+ }
+ if (!templete) {
+ templete = lang.lang_details_nodata;
+ } else {
+ templete = templete + '';
+ }
+ $("#timeline_" + tlid).append(templete);
- jQuery("time.timeago").timeago();
- });
+ jQuery("time.timeago").timeago();
+ });
}
function graphDraw(tag, acct_id) {
var tags = "";
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 six = 50 - (his[6].uses / max * 50);
- var five = 50 - (his[5].uses / max * 50);
- var four = 50 - (his[4].uses / max * 50);
- var three = 50 - (his[3].uses / max * 50);
- var two = 50 - (his[2].uses / max * 50);
- var one = 50 - (his[1].uses / max * 50);
- var zero = 50 - (his[0].uses / max * 50);
+ var six = 50 - (his[6].uses / max) * 50;
+ var five = 50 - (his[5].uses / max) * 50;
+ var four = 50 - (his[4].uses / max) * 50;
+ var three = 50 - (his[3].uses / max) * 50;
+ var two = 50 - (his[2].uses / max) * 50;
+ var one = 50 - (his[1].uses / max) * 50;
+ var zero = 50 - (his[0].uses / max) * 50;
if (max === 0) {
- tags = '
' + his[0].uses + 'toot(s) #' + escapeHTML(tag.name) + ' ' + his[0].accounts + lang.lang_src_people;
+ tags = '
' + his[0].uses + "toot(s) #" + escapeHTML(tag.name) + " " + his[0].accounts + lang.lang_src_people;
} else {
- tags = '
' + his[0].uses + 'toot #' + escapeHTML(tag.name) + ' ' + his[0].accounts + lang.lang_src_people;
+ tags = '
' + his[0].uses + "toot #" + escapeHTML(tag.name) + " " + his[0].accounts + lang.lang_src_people;
}
return tags;
@@ -221,7 +228,7 @@ function graphDraw(tag, acct_id) {
*/
function trend() {
- console.log("get trend")
+ console.log("get trend");
$("#src-contents").html("");
var acct_id = $("#src-acct-sel").val();
if (acct_id == "tootsearch") {
@@ -229,44 +236,43 @@ function trend() {
}
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
- var start = "https://" + domain + "/api/v1/trends"
- console.log(start)
+ var start = "https://" + domain + "/api/v1/trends";
+ console.log(start);
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- //todo(error);
- console.error(error);
- }).then(function (json) {
- var tags = "";
- Object.keys(json).forEach(function (keye) {
- var tag = json[keye];
- 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 six = 50 - (his[6].uses / max * 50);
- var five = 50 - (his[5].uses / max * 50);
- var four = 50 - (his[4].uses / max * 50);
- var three = 50 - (his[3].uses / max * 50);
- var two = 50 - (his[2].uses / max * 50);
- var one = 50 - (his[1].uses / max * 50);
- var zero = 50 - (his[0].uses / max * 50);
- tags = '' + his[0].uses + 'toots #' + tag.name + ' ' + his[0].accounts + lang.lang_src_people + "
";
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var tags = "";
+ Object.keys(json).forEach(function(keye) {
+ var tag = json[keye];
+ 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 six = 50 - (his[6].uses / max) * 50;
+ var five = 50 - (his[5].uses / max) * 50;
+ var four = 50 - (his[4].uses / max) * 50;
+ var three = 50 - (his[3].uses / max) * 50;
+ var two = 50 - (his[2].uses / max) * 50;
+ var one = 50 - (his[1].uses / max) * 50;
+ var zero = 50 - (his[0].uses / max) * 50;
+ tags = '' + his[0].uses + "toots #" + tag.name + " " + his[0].accounts + lang.lang_src_people + "
";
- $("#src-contents").append(tags);
+ $("#src-contents").append(tags);
+ });
});
-
- });
-}
\ No newline at end of file
+}
diff --git a/app/js/tl/tag.js b/app/js/tl/tag.js
index b32d31c0..28b1f8b7 100644
--- a/app/js/tl/tag.js
+++ b/app/js/tl/tag.js
@@ -1,163 +1,168 @@
//タグ表示
if (location.search) {
- var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
- var mode = m[1];
- var codex = m[2];
- if (mode == "tag") {
- var acct_id = localStorage.getItem("main");
- tl('tag', decodeURI(codex), acct_id, 'add');
- }
+ var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
+ var mode = m[1];
+ var codex = m[2];
+ if (mode == "tag") {
+ var acct_id = localStorage.getItem("main");
+ tl("tag", decodeURI(codex), acct_id, "add");
+ }
}
//よく使うタグ
function tagShow(tag) {
- $("[data-tag=" + decodeURI(tag).toLowerCase() + "]").toggleClass("hide");
+ $("[data-tag=" + decodeURI(tag).toLowerCase() + "]").toggleClass("hide");
}
//タグ追加
function tagPin(tag) {
- var tags = localStorage.getItem("tag");
- if (!tags) {
- var obj = [];
- } else {
- var obj = JSON.parse(tags);
- }
- var can;
- Object.keys(obj).forEach(function (key) {
- var tagT = obj[key];
- if (tagT == tag) {
- can = true;
- } else {
- can = false;
- }
- });
- if (!can) {
- obj.push(tag);
- }
- var json = JSON.stringify(obj);
- localStorage.setItem("tag", json);
- favTag();
+ var tags = localStorage.getItem("tag");
+ if (!tags) {
+ var obj = [];
+ } else {
+ var obj = JSON.parse(tags);
+ }
+ var can;
+ Object.keys(obj).forEach(function(key) {
+ var tagT = obj[key];
+ if (tagT == tag) {
+ can = true;
+ } else {
+ can = false;
+ }
+ });
+ if (!can) {
+ obj.push(tag);
+ }
+ var json = JSON.stringify(obj);
+ localStorage.setItem("tag", json);
+ favTag();
}
//タグ削除
function tagRemove(key) {
- var tags = localStorage.getItem("tag");
- var obj = JSON.parse(tags);
- obj.splice(key, 1);
- var json = JSON.stringify(obj);
- localStorage.setItem("tag", json);
- favTag();
+ var tags = localStorage.getItem("tag");
+ var obj = JSON.parse(tags);
+ obj.splice(key, 1);
+ var json = JSON.stringify(obj);
+ localStorage.setItem("tag", json);
+ favTag();
}
function favTag() {
- $("#taglist").html("");
- var tagarr = localStorage.getItem("tag");
- if (!tagarr) {
- var obj = [];
- } else {
- var obj = JSON.parse(tagarr);
- }
- var tags = "";
- var nowPT = localStorage.getItem("stable")
- Object.keys(obj).forEach(function (key) {
- var tag = obj[key];
- if (nowPT != tag) {
- console.log("stable tags:" + nowPT + "/" + tag);
- var ptt = lang.lang_tags_realtime;
- var nowon = "";
- } else {
- var ptt = lang.lang_tags_unrealtime;
- var nowon = "(" + lang.lang_tags_realtime + ")";
- }
- tag = escapeHTML(tag);
- tags = tags + '#' + tag + '' + nowon + ' TL Toot ' +
- '' + ptt + ' ' + lang.lang_del + ' ';
- });
- if (obj.length > 0) {
- $("#taglist").append("My Tags:" + tags);
- } else {
- $("#taglist").append("");
- }
+ $("#taglist").html("");
+ var tagarr = localStorage.getItem("tag");
+ if (!tagarr) {
+ var obj = [];
+ } else {
+ var obj = JSON.parse(tagarr);
+ }
+ var tags = "";
+ var nowPT = localStorage.getItem("stable");
+ Object.keys(obj).forEach(function(key) {
+ var tag = obj[key];
+ if (nowPT != tag) {
+ console.log("stable tags:" + nowPT + "/" + tag);
+ var ptt = lang.lang_tags_realtime;
+ var nowon = "";
+ } else {
+ var ptt = lang.lang_tags_unrealtime;
+ var nowon = "(" + lang.lang_tags_realtime + ")";
+ }
+ tag = escapeHTML(tag);
+ tags = tags + "#' + tag + "" + nowon + ' TL Toot ' + "' + ptt + " ' + lang.lang_del + " ";
+ });
+ if (obj.length > 0) {
+ $("#taglist").append("My Tags:" + tags);
+ } else {
+ $("#taglist").append("");
+ }
}
function trendTag() {
- $(".trendtag").remove();
- var domain = "imastodon.net"
- var at = localStorage.getItem("acct_" + acct_id + "_at");
- var start = "https://" + domain + "/api/v1/trend_tags"
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ $(".trendtag").remove();
+ var domain = "imastodon.net";
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
+ var start = "https://" + domain + "/api/v1/trend_tags";
+ fetch(start, {
+ method: "GET",
+ headers: {
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json) {
- var tags = "";
- json = json.score;
- Object.keys(json).forEach(function (tag) {
- tag = escapeHTML(tag);
- tags = tags + '#' + tag + ' TL Toot ';
- });
- $("#taglist").append('アイマストドントレンドタグrefresh:' + tags + '
');
- trendintervalset()
- } else {
- $("#taglist").html("");
- }
- });
-
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ var tags = "";
+ json = json.score;
+ Object.keys(json).forEach(function(tag) {
+ tag = escapeHTML(tag);
+ tags = tags + "#' + tag + ' TL Toot ';
+ });
+ $("#taglist").append('アイマストドントレンドタグrefresh:' + tags + "
");
+ trendintervalset();
+ } else {
+ $("#taglist").html("");
+ }
+ });
}
function trendintervalset() {
- setTimeout(trendTag, 6000000);
+ setTimeout(trendTag, 6000000);
}
function tagTL(a, b, c, d) {
- var acct_id = $("#post-acct-sel").val();
- tl(a, b, acct_id, d);
+ var acct_id = $("#post-acct-sel").val();
+ tl(a, b, acct_id, d);
}
function autoToot(tag) {
- tag = escapeHTML(tag)
- var nowPT = localStorage.getItem("stable")
- if (nowPT == tag) {
- localStorage.removeItem("stable");
- M.toast({ html: lang.lang_tags_unrealtime, displayLength: 3000 })
- } else {
- localStorage.setItem("stable", tag);
- M.toast({ html: lang.lang_tags_tagwarn.replace("{{tag}}", tag).replace("{{tag}}", tag), displayLength: 3000 })
- brInsert('#' + tag + " ")
- }
- favTag();
+ tag = escapeHTML(tag);
+ var nowPT = localStorage.getItem("stable");
+ if (nowPT == tag) {
+ localStorage.removeItem("stable");
+ M.toast({ html: lang.lang_tags_unrealtime, displayLength: 3000 });
+ } else {
+ localStorage.setItem("stable", tag);
+ M.toast({ html: lang.lang_tags_tagwarn.replace("{{tag}}", tag).replace("{{tag}}", tag), displayLength: 3000 });
+ brInsert("#" + tag + " ");
+ }
+ favTag();
}
//タグをフィーチャー
-function tagFeature(name, acct_id){
- var domain = localStorage.getItem("domain_" + acct_id);
+function tagFeature(name, acct_id) {
+ var domain = localStorage.getItem("domain_" + acct_id);
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, {
- method: 'POST',
+ method: "POST",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- body: JSON.stringify({
- name: name
- })
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- return false;
- }).then(function (json) {
- console.log(json)
- M.toast({ html: "Complete: " + escapeHTML(name), displayLength: 3000 })
- });
-}
\ No newline at end of file
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
+ },
+ body: JSON.stringify({
+ name: name
+ })
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ return false;
+ })
+ .then(function(json) {
+ console.log(json);
+ M.toast({ html: "Complete: " + escapeHTML(name), displayLength: 3000 });
+ });
+}
diff --git a/app/js/tl/tl.js b/app/js/tl/tl.js
index d9afe93b..41494e01 100644
--- a/app/js/tl/tl.js
+++ b/app/js/tl/tl.js
@@ -1,9 +1,9 @@
//TL取得
moreloading = false;
-var errorct=0;
+var errorct = 0;
function tl(type, data, acct_id, tlid, delc, voice, mode) {
scrollevent();
- $("#unread_" + tlid + " .material-icons").removeClass("teal-text")
+ $("#unread_" + tlid + " .material-icons").removeClass("teal-text");
localStorage.removeItem("morelock");
localStorage.removeItem("pool");
var domain = localStorage.getItem("domain_" + acct_id);
@@ -22,7 +22,7 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
obj.push(add);
var json = JSON.stringify(obj);
localStorage.setItem("column", json);
- parseColumn('add');
+ parseColumn("add");
return;
}
@@ -35,26 +35,23 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
}
if (type == "mix" && localStorage.getItem("mode_" + domain) != "misskey") {
//Integratedなら飛ばす
- $("#notice_" + tlid).text("Integrated TL(" + localStorage.getItem(
- "user_" + acct_id) + "@" + domain + ")");
+ $("#notice_" + tlid).text("Integrated TL(" + localStorage.getItem("user_" + acct_id) + "@" + domain + ")");
$("#notice_icon_" + tlid).text("merge_type");
mixtl(acct_id, tlid, "integrated", delc, voice);
return;
} else if (type == "plus") {
//Local+なら飛ばす
- $("#notice_" + tlid).text("Local+ TL(" + localStorage.getItem(
- "user_" + acct_id) + "@" + domain + ")");
+ $("#notice_" + tlid).text("Local+ TL(" + localStorage.getItem("user_" + acct_id) + "@" + domain + ")");
$("#notice_icon_" + tlid).text("people_outline");
mixtl(acct_id, tlid, "plus", delc, voice);
return;
} else if (type == "notf") {
//通知なら飛ばす
- notf(acct_id, tlid, 'direct');
- $("#notice_" + tlid).text(cap(type, data, acct_id) + "(" + localStorage.getItem(
- "user_" + acct_id) + "@" + domain + ")");
+ notf(acct_id, tlid, "direct");
+ $("#notice_" + tlid).text(cap(type, data, acct_id) + "(" + localStorage.getItem("user_" + acct_id) + "@" + domain + ")");
$("#notice_icon_" + tlid).text("notifications");
return;
- }/*else if (type == "dm") {
+ } /*else if (type == "dm") {
//DMなら飛ばす
dm(acct_id, tlid, "plus",delc,voice);
$("#notice_" + tlid).text(cap(type, data, acct_id) + "(" + localStorage.getItem(
@@ -67,14 +64,13 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (type != "noauth") {
var hdr = {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
};
- $("#notice_" + tlid).text(cap(type, data, acct_id) + "(" + localStorage.getItem(
- "user_" + acct_id) + "@" + domain + ")");
+ $("#notice_" + tlid).text(cap(type, data, acct_id) + "(" + localStorage.getItem("user_" + acct_id) + "@" + domain + ")");
} else {
var hdr = {
- 'content-type': 'application/json'
+ "content-type": "application/json"
};
domain = acct_id;
$("#notice_" + tlid).text("Glance TL(" + domain + ")");
@@ -103,8 +99,8 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
var i = {
method: method,
headers: hdr,
- body: JSON.stringify(req),
- }
+ body: JSON.stringify(req)
+ };
} else {
var misskey = false;
var url = com(type, data);
@@ -126,50 +122,54 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
};
}
- console.log(["Try to get timeline of " + tlid, start])
- fetch(start, i).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- console.log(["Result of getting timeline of " + tlid, json])
- $("#landing_" + tlid).hide();
- if (localStorage.getItem("filter_" + acct_id) != "undefined") {
- var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type);
- } else {
- var mute = [];
- }
- if (misskey) {
- var templete = misskeyParse(json, type, acct_id, tlid, "", mute);
- } else {
- var templete = parse(json, type, acct_id, tlid, "", mute, type);
- localStorage.setItem("lastobj_" + tlid, json[0].id)
- }
- $("#timeline_" + tlid).html(templete);
- additional(acct_id, tlid);
- jQuery("time.timeago").timeago();
- todc();
- reload(type, '', acct_id, tlid, data, mute, delc, voice);
- if (type == "home" || type == "notf") {
- //Markers
- var markers = localStorage.getItem("markers");
- if (markers == "yes") {
- markers = true;
+ console.log(["Try to get timeline of " + tlid, start]);
+ fetch(start, i)
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ console.log(["Result of getting timeline of " + tlid, json]);
+ $("#landing_" + tlid).hide();
+ if (localStorage.getItem("filter_" + acct_id) != "undefined") {
+ var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type);
} else {
- markers = false
+ var mute = [];
}
- if (markers) {
- getMarker(tlid, type, acct_id)
+ if (misskey) {
+ var templete = misskeyParse(json, type, acct_id, tlid, "", mute);
+ } else {
+ var templete = parse(json, type, acct_id, tlid, "", mute, type);
+ localStorage.setItem("lastobj_" + tlid, json[0].id);
}
- }
- $(window).scrollTop(0);
- });
+ $("#timeline_" + tlid).html(templete);
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ todc();
+ reload(type, "", acct_id, tlid, data, mute, delc, voice);
+ if (type == "home" || type == "notf") {
+ //Markers
+ var markers = localStorage.getItem("markers");
+ if (markers == "yes") {
+ markers = true;
+ } else {
+ markers = false;
+ }
+ if (markers) {
+ getMarker(tlid, type, acct_id);
+ }
+ }
+ $(window).scrollTop(0);
+ });
}
//Streaming接続
@@ -182,36 +182,31 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
localStorage.setItem("now", type);
if (localStorage.getItem("mode_" + domain) == "misskey") {
var misskey = true;
- var key = localStorage.getItem("misskey_wss_" + acct_id)
- var send = '{"type":"connect","body":{"channel":"' + typePs(type) + '","id":"' + tlid + '"}}'
- var mskyset = setInterval(function () {
+ var key = localStorage.getItem("misskey_wss_" + acct_id);
+ var send = '{"type":"connect","body":{"channel":"' + typePs(type) + '","id":"' + tlid + '"}}';
+ var mskyset = setInterval(function() {
if (misskeywsstate[key]) {
- misskeyws[key].send(send)
- clearInterval(mskyset)
+ misskeyws[key].send(send);
+ clearInterval(mskyset);
}
}, 100);
} else {
var misskey = false;
if (localStorage.getItem("streaming_" + acct_id)) {
- var wss = localStorage.getItem("streaming_" + acct_id)
+ var wss = localStorage.getItem("streaming_" + acct_id);
} else {
- var wss = "wss://" + domain
+ var wss = "wss://" + domain;
}
if (type == "home") {
- var start = wss +
- "/api/v1/streaming/?stream=user&access_token=" + at;
+ var start = wss + "/api/v1/streaming/?stream=user&access_token=" + at;
} else if (type == "pub") {
- var start = wss +
- "/api/v1/streaming/?stream=public&access_token=" + at;
+ var start = wss + "/api/v1/streaming/?stream=public&access_token=" + at;
} else if (type == "pub-media") {
- var start = wss +
- "/api/v1/streaming/?stream=public:media&access_token=" + at;
+ var start = wss + "/api/v1/streaming/?stream=public:media&access_token=" + at;
} else if (type == "local") {
- var start = wss +
- "/api/v1/streaming/?stream=public:local&access_token=" + at;
+ var start = wss + "/api/v1/streaming/?stream=public:local&access_token=" + at;
} else if (type == "local-media") {
- var start = wss +
- "/api/v1/streaming/?stream=public:local:media&only_media=true&access_token=" + at;
+ var start = wss + "/api/v1/streaming/?stream=public:local:media&only_media=true&access_token=" + at;
} else if (type == "tag") {
if (type == "tag") {
var tag = localStorage.getItem("tag-range");
@@ -219,44 +214,42 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
data = data + "&local=true";
}
}
- var start = wss +
- "/api/v1/streaming/?stream=hashtag&tag=" + data + "&access_token=" + at;
+ var start = wss + "/api/v1/streaming/?stream=hashtag&tag=" + data + "&access_token=" + at;
} else if (type == "noauth") {
- var start = "wss://" + acct_id +
- "/api/v1/streaming/?stream=public:local";
+ var start = "wss://" + acct_id + "/api/v1/streaming/?stream=public:local";
} else if (type == "list") {
- var start = wss +
- "/api/v1/streaming/?stream=list&list=" + data + "&access_token=" + at;
+ var start = wss + "/api/v1/streaming/?stream=list&list=" + data + "&access_token=" + at;
} else if (type == "dm") {
- var start = wss +
- "/api/v1/streaming/?stream=direct&access_token=" + at;
+ var start = wss + "/api/v1/streaming/?stream=direct&access_token=" + at;
}
var wsid = websocket.length;
localStorage.setItem("wss_" + tlid, wsid);
websocket[wsid] = new WebSocket(start);
- websocket[wsid].onopen = function (mess) {
- console.table({ "tlid": tlid, "type": "Connect Streaming API" + type, "domain": domain, "message": [mess] })
- errorct=0
- $("#notice_icon_" + tlid).removeClass("red-text")
- }
- websocket[wsid].onmessage = function (mess) {
+ websocket[wsid].onopen = function(mess) {
+ console.table({ tlid: tlid, type: "Connect Streaming API" + type, domain: domain, message: [mess] });
+ errorct = 0;
+ $("#notice_icon_" + tlid).removeClass("red-text");
+ };
+ websocket[wsid].onmessage = function(mess) {
console.log([tlid + ":Receive Streaming API:", JSON.parse(mess.data)]);
if (misskey) {
if (JSON.parse(mess.data).type == "note") {
var obj = JSON.parse(mess.data).body;
if (voice) {
- say(obj.text)
+ say(obj.text);
}
- websocketNotf[acct_id].send(JSON.stringify({
- type: 'capture',
- id: obj.id
- }))
+ websocketNotf[acct_id].send(
+ JSON.stringify({
+ type: "capture",
+ id: obj.id
+ })
+ );
var templete = misskeyParse([obj], type, acct_id, tlid, "", mute);
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
pool = templete + pool;
} else {
- pool = templete
+ pool = templete;
}
localStorage.setItem("pool_" + tlid, pool);
scrollck();
@@ -267,27 +260,26 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
if (typeA == "delete") {
var del = localStorage.getItem("delete");
if (del > 10) {
- reconnector(tlid, type, acct_id, data)
+ reconnector(tlid, type, acct_id, data);
} else {
- localStorage.setItem("delete", del * 1 + 1)
+ localStorage.setItem("delete", del * 1 + 1);
}
var obj = JSON.parse(mess.data).payload;
if (delc == "true") {
$("#timeline_" + tlid + " [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("emphasized");
$("#timeline_" + tlid + " [toot-id=" + JSON.parse(mess.data).payload + "]").addClass("by_delcatch");
} else {
- $("[toot-id=" + JSON.parse(mess.data).payload + "]").hide()
- $("[toot-id=" + JSON.parse(mess.data).payload + "]").remove()
+ $("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
+ $("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
}
-
} else if (typeA == "update" || typeA == "conversation") {
- localStorage.removeItem("delete")
+ localStorage.removeItem("delete");
if (!$("#unread_" + tlid + " .material-icons").hasClass("teal-text")) {
//markers show中はダメ
var obj = JSON.parse(JSON.parse(mess.data).payload);
if ($("#timeline_" + tlid + " [toot-id=" + obj.id + "]").length < 1) {
if (voice) {
- say(obj.content)
+ say(obj.content);
}
var templete = parse([obj], type, acct_id, tlid, "", mute, type);
if ($("timeline_box_" + tlid + "_box .tl-box").scrollTop() === 0) {
@@ -297,7 +289,7 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
if (pool) {
pool = templete + pool;
} else {
- pool = templete
+ pool = templete;
}
localStorage.setItem("pool_" + tlid, pool);
}
@@ -314,32 +306,30 @@ function reload(type, cc, acct_id, tlid, data, mute, delc, voice, mode) {
filterUpdate(acct_id);
}
}
-
-
- }
- websocket[wsid].onerror = function (error) {
+ };
+ websocket[wsid].onerror = function(error) {
console.error("Error closing");
console.error(error);
if (mode == "error") {
- $("#notice_icon_" + tlid).addClass("red-text")
- todo('WebSocket Error ' + error);
+ $("#notice_icon_" + tlid).addClass("red-text");
+ todo("WebSocket Error " + error);
} else {
errorct++;
- console.log(errorct)
+ console.log(errorct);
if (errorct < 3) {
reconnector(tlid, type, acct_id, data, "error");
}
}
return false;
};
- websocket[wsid].onclose = function () {
+ websocket[wsid].onclose = function() {
console.warn("Closing " + tlid);
if (mode == "error") {
- $("#notice_icon_" + tlid).addClass("red-text")
- todo('WebSocket Closed');
+ $("#notice_icon_" + tlid).addClass("red-text");
+ todo("WebSocket Closed");
} else {
errorct++;
- console.log(errorct)
+ console.log(errorct);
if (errorct < 3) {
reconnector(tlid, type, acct_id, data, "error");
}
@@ -368,7 +358,9 @@ function moreload(type, tlid) {
} else if (type == "list") {
var data = obj[tlid].data;
}
- var sid = $("#timeline_" + tlid + " .cvo").last().attr("unique-id");
+ var sid = $("#timeline_" + tlid + " .cvo")
+ .last()
+ .attr("unique-id");
if (sid && !moreloading) {
if (type == "mix" && localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id)) != "misskey") {
mixmore(tlid, "integrated");
@@ -390,20 +382,20 @@ function moreload(type, tlid) {
if (type != "noauth") {
var at = localStorage.getItem("acct_" + acct_id + "_at");
var hdr = {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
};
var domain = localStorage.getItem("domain_" + acct_id);
} else {
var hdr = {
- 'content-type': 'application/json'
+ "content-type": "application/json"
};
domain = acct_id;
}
if (localStorage.getItem("mode_" + domain) == "misskey") {
var misskey = true;
hdr = {
- 'content-type': 'application/json'
+ "content-type": "application/json"
};
var url = misskeycom(type, data);
var start = "https://" + domain + "/api/notes/" + url;
@@ -426,15 +418,13 @@ function moreload(type, tlid) {
var i = {
method: method,
headers: hdr,
- body: JSON.stringify(req),
- }
+ body: JSON.stringify(req)
+ };
} else {
var misskey = false;
- var start = "https://" + domain + "/api/v1/timelines/" + com(type, data) +
- "max_id=" + sid;
+ var start = "https://" + domain + "/api/v1/timelines/" + com(type, data) + "max_id=" + sid;
if (type == "dm") {
- var start = "https://" + domain + "/api/v1/conversations?" +
- "max_id=" + sid;
+ var start = "https://" + domain + "/api/v1/conversations?" + "max_id=" + sid;
}
var method = "GET";
var i = {
@@ -442,38 +432,42 @@ function moreload(type, tlid) {
headers: hdr
};
}
- fetch(start, i).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
+ fetch(start, i)
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (localStorage.getItem("filter_" + acct_id) != "undefined") {
+ var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type);
+ } else {
+ var mute = [];
+ }
+ if (misskey) {
+ var templete = misskeyParse(json, "", acct_id, tlid, "", mute);
+ } else {
+ var templete = parse(json, "", acct_id, tlid, "", mute, type);
+ }
+ $("#timeline_" + tlid).append(templete);
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ moreloading = false;
+ todc();
});
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (localStorage.getItem("filter_" + acct_id) != "undefined") {
- var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type);
- } else {
- var mute = [];
- }
- if (misskey) {
- var templete = misskeyParse(json, '', acct_id, tlid, "", mute);
- } else {
- var templete = parse(json, '', acct_id, tlid, "", mute, type);
- }
- $("#timeline_" + tlid).append(templete);
- additional(acct_id, tlid);
- jQuery("time.timeago").timeago();
- moreloading = false;
- todc();
- });
}
}
//TL差分取得
function tlDiff(type, data, acct_id, tlid, delc, voice, mode) {
- console.log("Get diff of TL" + tlid)
+ console.log("Get diff of TL" + tlid);
var multi = localStorage.getItem("column");
var obj = JSON.parse(multi);
var acct_id = obj[tlid].domain;
@@ -491,7 +485,9 @@ function tlDiff(type, data, acct_id, tlid, delc, voice, mode) {
} else if (type == "list") {
var data = obj[tlid].data;
}
- var sid = $("#timeline_" + tlid + " .cvo").first().attr("unique-id");
+ var sid = $("#timeline_" + tlid + " .cvo")
+ .first()
+ .attr("unique-id");
if (sid && !moreloading) {
if (type == "mix" && localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id)) != "misskey") {
return;
@@ -506,20 +502,20 @@ function tlDiff(type, data, acct_id, tlid, delc, voice, mode) {
if (type != "noauth") {
var at = localStorage.getItem("acct_" + acct_id + "_at");
var hdr = {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
};
var domain = localStorage.getItem("domain_" + acct_id);
} else {
var hdr = {
- 'content-type': 'application/json'
+ "content-type": "application/json"
};
domain = acct_id;
}
if (localStorage.getItem("mode_" + domain) == "misskey") {
var misskey = true;
hdr = {
- 'content-type': 'application/json'
+ "content-type": "application/json"
};
var url = misskeycom(type, data);
var start = "https://" + domain + "/api/notes/" + url;
@@ -542,15 +538,13 @@ function tlDiff(type, data, acct_id, tlid, delc, voice, mode) {
var i = {
method: method,
headers: hdr,
- body: JSON.stringify(req),
- }
+ body: JSON.stringify(req)
+ };
} else {
var misskey = false;
- var start = "https://" + domain + "/api/v1/timelines/" + com(type, data) +
- "since_id=" + sid;
+ var start = "https://" + domain + "/api/v1/timelines/" + com(type, data) + "since_id=" + sid;
if (type == "dm") {
- var start = "https://" + domain + "/api/v1/conversations?" +
- "since_id=" + sid;
+ var start = "https://" + domain + "/api/v1/conversations?" + "since_id=" + sid;
}
var method = "GET";
var i = {
@@ -559,30 +553,33 @@ function tlDiff(type, data, acct_id, tlid, delc, voice, mode) {
};
}
-
- fetch(start, i).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
+ fetch(start, i)
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ console.log(["Result diff of TL" + tlid, json]);
+ if (misskey) {
+ var templete = misskeyParse(json, "", acct_id, tlid, "", mute);
+ } else {
+ var templete = parse(json, "", acct_id, tlid, "", mute, type);
+ }
+ $("#timeline_" + tlid).prepend(templete);
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ moreloading = false;
+ todc();
});
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- console.log(["Result diff of TL" + tlid, json]);
- if (misskey) {
- var templete = misskeyParse(json, '', acct_id, tlid, "", mute);
- } else {
- var templete = parse(json, '', acct_id, tlid, "", mute, type);
- }
- $("#timeline_" + tlid).prepend(templete);
- additional(acct_id, tlid);
- jQuery("time.timeago").timeago();
- moreloading = false;
- todc();
- });
}
}
//TL再取得
@@ -592,7 +589,7 @@ function reloadTL(type, data, acct_id, key, delc, voice) {
//WebSocket切断
function tlCloser() {
- Object.keys(websocket).forEach(function (tlid) {
+ Object.keys(websocket).forEach(function(tlid) {
if (websocketOld[tlid]) {
websocketOld[tlid].close();
console.log("%c Close Streaming API: Old" + tlid, "color:blue");
@@ -602,39 +599,35 @@ function tlCloser() {
websocket[tlid].close();
console.log("%c Close Streaming API:" + tlid, "color:blue");
}
-
});
websocket = [];
- Object.keys(websocketHome).forEach(function (tlid) {
+ Object.keys(websocketHome).forEach(function(tlid) {
if (websocketHome[tlid]) {
websocketHome[tlid].close();
console.log("%c Close Streaming API:Integrated Home" + tlid, "color:blue");
}
-
});
websocketHome = [];
- Object.keys(websocketLocal).forEach(function (tlid) {
+ Object.keys(websocketLocal).forEach(function(tlid) {
if (websocketLocal[tlid]) {
websocketLocal[tlid].close();
console.log("%c Close Streaming API:Integrated Local" + tlid, "color:blue");
}
-
});
websocketLocal = [];
- Object.keys(websocketNotf).forEach(function (tlid) {
+ Object.keys(websocketNotf).forEach(function(tlid) {
if (websocketNotf[tlid]) {
websocketNotf[tlid].close();
console.log("%c Close Streaming API:Notf" + tlid, "color:blue");
}
-
});
- Object.keys(misskeyws).forEach(function (tlid) {
+ Object.keys(misskeyws).forEach(function(tlid) {
if (misskeyws[tlid]) {
misskeyws[tlid].close();
console.log("%c Close Streaming API:Misskey" + tlid, "color:blue");
}
});
- misskeyws = {}
+ misskeyws = {};
}
//TLのタイトル
@@ -675,10 +668,10 @@ function cap(type, data, acct_id) {
var response = "Federated TL(Media)";
}
} else if (type == "tag") {
- var response = "#" + escapeHTML(data)
+ var response = "#" + escapeHTML(data);
} else if (type == "list") {
var ltitle = localStorage.getItem("list_" + data + "_" + acct_id);
- var response = "List(" + ltitle + ")"
+ var response = "List(" + ltitle + ")";
} else if (type == "notf") {
if (localStorage.getItem("notification_" + acct_id) && !locale) {
var response = localStorage.getItem("notification_" + acct_id);
@@ -686,19 +679,19 @@ function cap(type, data, acct_id) {
var response = "Notification TL";
}
} else if (type == "noauth") {
- var response = "Glance TL"
+ var response = "Glance TL";
} else if (type == "dm") {
- var response = "DM"
+ var response = "DM";
} else if (type == "mix") {
if (localStorage.getItem("mode_" + localStorage.getItem("domain_" + acct_id)) == "misskey") {
- var response = "Social TL"
+ var response = "Social TL";
} else {
- var response = "Integrated"
+ var response = "Integrated";
}
} else if (type == "plus") {
- var response = "Local+"
+ var response = "Local+";
} else if (type == "webview") {
- var response = "Twitter"
+ var response = "Twitter";
} else if (type == "tootsearch") {
var response = "tootsearch(" + escapeHTML(data) + ")";
}
@@ -708,58 +701,58 @@ function cap(type, data, acct_id) {
//TLのURL
function com(type, data) {
if (type == "home") {
- return "home?"
+ return "home?";
} else if (type == "local" || type == "noauth") {
- return "public?local=true&"
+ return "public?local=true&";
} else if (type == "local-media") {
- return "public?local=true&only_media=true&"
+ return "public?local=true&only_media=true&";
} else if (type == "pub") {
- return "public?"
+ return "public?";
} else if (type == "pub-media") {
- return "public?only_media=true&"
+ return "public?only_media=true&";
} else if (type == "tag") {
- return "tag/" + data + "?"
+ return "tag/" + data + "?";
} else if (type == "list") {
- return "list/" + data + "?"
+ return "list/" + data + "?";
} else if (type == "dm") {
- return "direct?"
+ return "direct?";
}
}
//Misskey
function typePs(type) {
if (type == "home") {
- return "homeTimeline"
+ return "homeTimeline";
} else if (type == "local" || type == "noauth") {
- return "localTimeline"
+ return "localTimeline";
} else if (type == "local-media") {
- return "localTimeline"
+ return "localTimeline";
} else if (type == "pub") {
- return "globalTimeline"
+ return "globalTimeline";
} else if (type == "mix") {
- return "hybridTimeline"
+ return "hybridTimeline";
} else if (type == "tag") {
- return "hashtag"
+ return "hashtag";
} else if (type == "list") {
- return "userList"
+ return "userList";
}
}
function misskeycom(type, data) {
if (type == "home") {
- return "timeline"
+ return "timeline";
} else if (type == "mix") {
- return "hybrid-timeline"
+ return "hybrid-timeline";
} else if (type == "local" || type == "noauth") {
- return "local-timeline"
+ return "local-timeline";
} else if (type == "local-media") {
- return "local-timeline"
+ return "local-timeline";
} else if (type == "pub") {
- return "global-timeline"
+ return "global-timeline";
} else if (type == "pub-media") {
- return "global-timeline"
+ return "global-timeline";
} else if (type == "tag") {
- return "search_by_tag"
+ return "search_by_tag";
} else if (type == "list") {
- return "user-list-timeline"
+ return "user-list-timeline";
}
}
@@ -803,7 +796,7 @@ function strAlive() {
var col = localStorage.getItem("column");
if (col) {
var obj = JSON.parse(col);
- Object.keys(obj).forEach(function (key) {
+ Object.keys(obj).forEach(function(key) {
if ($("#notice_icon_" + key).hasClass("red-text")) {
var type = obj[key].type;
var acct_id = obj[key].domain;
@@ -819,7 +812,7 @@ function strAliveInt() {
setTimeout(strAlive, 10000);
}
function reconnector(tlid, type, acct_id, data, mode) {
- console.log("%c Reconnector:" + mode + "(timeline" + tlid + ")", "color:pink")
+ console.log("%c Reconnector:" + mode + "(timeline" + tlid + ")", "color:pink");
if (type == "mix" || type == "integrated" || type == "plus") {
if (localStorage.getItem("voice_" + tlid)) {
var voice = true;
@@ -837,7 +830,7 @@ function reconnector(tlid, type, acct_id, data, mode) {
websocketLocal[wssl].close();
mixre(acct_id, tlid, type, mute, "", voice, mode);
} else if (type == "notf") {
- notfColumn(acct_id, tlid, "")
+ notfColumn(acct_id, tlid, "");
} else {
var wss = localStorage.getItem("wss_" + tlid);
websocket[wss].close();
@@ -851,14 +844,13 @@ function reconnector(tlid, type, acct_id, data, mode) {
} else {
var mute = [];
}
- reload(type, '', acct_id, tlid, data, mute, "", voice, mode);
+ reload(type, "", acct_id, tlid, data, mute, "", voice, mode);
}
- M.toast({ html: lang.lang_tl_reconnect, displayLength: 2000 })
-
+ M.toast({ html: lang.lang_tl_reconnect, displayLength: 2000 });
}
function columnReload(tlid, type) {
$("#notice_icon_" + tlid).addClass("red-text");
- $("#unread_" + tlid + " .material-icons").removeClass("teal-text")
+ $("#unread_" + tlid + " .material-icons").removeClass("teal-text");
if (type == "mix" || type == "integrated" || type == "plus") {
if (localStorage.getItem("voice_" + tlid)) {
var voice = true;
@@ -874,10 +866,10 @@ function columnReload(tlid, type) {
websocketHome[wssh].close();
var wssl = localStorage.getItem("wssL_" + tlid);
websocketLocal[wssl].close();
- parseColumn(tlid)
+ parseColumn(tlid);
} else if (type == "notf") {
$("#notice_icon_" + tlid).removeClass("red-text");
- notfColumn(acct_id, tlid, "")
+ notfColumn(acct_id, tlid, "");
} else {
var wss = localStorage.getItem("wss_" + tlid);
websocket[wss].close();
@@ -891,161 +883,172 @@ function columnReload(tlid, type) {
} else {
var mute = [];
}
- parseColumn(tlid)
+ parseColumn(tlid);
}
}
-strAliveInt()
+strAliveInt();
//Markers
function getMarker(tlid, type, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
if (type == "home") {
- var add = "home"
+ var add = "home";
} else if (type == "notf") {
- var add = "notifications"
+ var add = "notifications";
}
- var start = "https://" + domain + "/api/v1/markers?timeline=" + add
+ var start = "https://" + domain + "/api/v1/markers?timeline=" + add;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- $("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + lang.lang_nothing)
- $("#unread_" + tlid).attr("data-id", "")
- return false;
- }).then(function (json) {
- if (json) {
- if (json[add]) {
- json = json[add]
- $("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + json.updated_at + ' v' + json.version)
- $("#unread_" + tlid).attr("data-id", json.last_read_id)
- } else {
- $("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + lang.lang_nothing)
- $("#unread_" + tlid).attr("data-id", "")
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
- } else {
- $("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + lang.lang_nothing)
- $("#unread_" + tlid).attr("data-id", "")
- }
- });
+ return response.json();
+ })
+ .catch(function(error) {
+ $("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + lang.lang_nothing);
+ $("#unread_" + tlid).attr("data-id", "");
+ return false;
+ })
+ .then(function(json) {
+ if (json) {
+ if (json[add]) {
+ json = json[add];
+ $("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + json.updated_at + " v" + json.version);
+ $("#unread_" + tlid).attr("data-id", json.last_read_id);
+ } else {
+ $("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + lang.lang_nothing);
+ $("#unread_" + tlid).attr("data-id", "");
+ }
+ } else {
+ $("#unread_" + tlid).attr("title", lang.lang_layout_unread + ":" + lang.lang_nothing);
+ $("#unread_" + tlid).attr("data-id", "");
+ }
+ });
}
function showUnread(tlid, type, acct_id) {
if ($("#unread_" + tlid + " .material-icons").hasClass("teal-text")) {
- goTop(tlid)
- return
+ goTop(tlid);
+ return;
}
- $("#unread_" + tlid + " .material-icons").addClass("teal-text")
+ $("#unread_" + tlid + " .material-icons").addClass("teal-text");
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem("acct_" + acct_id + "_at");
- var id = $("#unread_" + tlid).attr("data-id")
+ var id = $("#unread_" + tlid).attr("data-id");
if (type == "home") {
- var add = "timelines/home?min_id=" + id
+ var add = "timelines/home?min_id=" + id;
} else if (type == "notf") {
- var add = "notifications?min_id=" + id
+ var add = "notifications?min_id=" + id;
}
- var start = "https://" + domain + "/api/v1/" + add
+ var start = "https://" + domain + "/api/v1/" + add;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (!json || !json.length) {
- columnReload(tlid, type)
- }
- if (localStorage.getItem("filter_" + acct_id) != "undefined") {
- var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type);
- } else {
- var mute = [];
- }
- var templete = parse(json, type, acct_id, tlid, "", mute, type);
- var len = json.length - 1
- $("#timeline_" + tlid).html(templete);
- if ($("#timeline_" + tlid + " .cvo:eq(" + len + ")").length) {
- var to = $("#timeline_" + tlid + " .cvo:eq(" + len + ")").offset().top
- $("#timeline_box_" + tlid + "_box .tl-box").scrollTop(to)
- }
- additional(acct_id, tlid);
- jQuery("time.timeago").timeago();
- todc();
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (!json || !json.length) {
+ columnReload(tlid, type);
+ }
+ if (localStorage.getItem("filter_" + acct_id) != "undefined") {
+ var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type);
+ } else {
+ var mute = [];
+ }
+ var templete = parse(json, type, acct_id, tlid, "", mute, type);
+ var len = json.length - 1;
+ $("#timeline_" + tlid).html(templete);
+ if ($("#timeline_" + tlid + " .cvo:eq(" + len + ")").length) {
+ var to = $("#timeline_" + tlid + " .cvo:eq(" + len + ")").offset().top;
+ $("#timeline_box_" + tlid + "_box .tl-box").scrollTop(to);
+ }
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ todc();
+ });
}
-var ueloadlock = false
+var ueloadlock = false;
function ueload(tlid) {
if (ueloadlock) {
- return false
+ return false;
}
- ueloadlock = true
- var multi = localStorage.getItem("column")
- var obj = JSON.parse(multi)
- var acct_id = obj[tlid * 1].domain
- var type = obj[tlid * 1].type
- var domain = localStorage.getItem("domain_" + acct_id)
- var at = localStorage.getItem("acct_" + acct_id + "_at")
- var id = $("#timeline_" + tlid + " .cvo:eq(0)").attr("unique-id")
+ ueloadlock = true;
+ var multi = localStorage.getItem("column");
+ var obj = JSON.parse(multi);
+ var acct_id = obj[tlid * 1].domain;
+ var type = obj[tlid * 1].type;
+ var domain = localStorage.getItem("domain_" + acct_id);
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
+ var id = $("#timeline_" + tlid + " .cvo:eq(0)").attr("unique-id");
if (type == "home") {
- var add = "timelines/home?min_id=" + id
+ var add = "timelines/home?min_id=" + id;
} else if (type == "notf") {
- var add = "notifications?min_id=" + id
+ var add = "notifications?min_id=" + id;
}
- var start = "https://" + domain + "/api/v1/" + add
+ var start = "https://" + domain + "/api/v1/" + add;
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (!json) {
- columnReload(tlid, type)
- }
- if (localStorage.getItem("filter_" + acct_id) != "undefined") {
- var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type)
- } else {
- var mute = []
- }
- var templete = parse(json, '', acct_id, tlid, "", mute, type)
- var len = json.length - 1
- $("#timeline_" + tlid).prepend(templete)
- if ($("#timeline_" + tlid + " .cvo:eq(" + len + ")").length) {
- var to = $("#timeline_" + tlid + " .cvo:eq(" + len + ")").offset().top
- $("#timeline_box_" + tlid + "_box .tl-box").scrollTop(to)
- }
- additional(acct_id, tlid)
- jQuery("time.timeago").timeago()
- todc()
- ueloadlock = false
- });
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (!json) {
+ columnReload(tlid, type);
+ }
+ if (localStorage.getItem("filter_" + acct_id) != "undefined") {
+ var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type);
+ } else {
+ var mute = [];
+ }
+ var templete = parse(json, "", acct_id, tlid, "", mute, type);
+ var len = json.length - 1;
+ $("#timeline_" + tlid).prepend(templete);
+ if ($("#timeline_" + tlid + " .cvo:eq(" + len + ")").length) {
+ var to = $("#timeline_" + tlid + " .cvo:eq(" + len + ")").offset().top;
+ $("#timeline_box_" + tlid + "_box .tl-box").scrollTop(to);
+ }
+ additional(acct_id, tlid);
+ jQuery("time.timeago").timeago();
+ todc();
+ ueloadlock = false;
+ });
}
function asRead(callback) {
//Markers
@@ -1053,53 +1056,55 @@ function asRead(callback) {
if (markers == "no") {
markers = false;
} else {
- markers = true
+ markers = true;
}
if (markers) {
- var multi = localStorage.getItem("column")
- var obj = JSON.parse(multi)
- var obl = obj.length
- ct = 0
+ var multi = localStorage.getItem("column");
+ var obj = JSON.parse(multi);
+ var obl = obj.length;
+ ct = 0;
for (var i = 0; i < obl; i++) {
- var acct_id = obj[i].domain
- var type = obj[i].type
+ var acct_id = obj[i].domain;
+ var type = obj[i].type;
if (type == "home" || type == "notf") {
if (type == "home") {
- var id = $("#timeline_" + i + " .cvo:eq(0)").attr("unique-id")
+ var id = $("#timeline_" + i + " .cvo:eq(0)").attr("unique-id");
var poster = {
home: {
last_read_id: id
}
- }
+ };
} else {
- var id = $("#timeline_" + i + " .cvo:eq(0)").attr("data-notf")
+ var id = $("#timeline_" + i + " .cvo:eq(0)").attr("data-notf");
var poster = {
notifications: {
last_read_id: id
}
- }
+ };
}
- var domain = localStorage.getItem("domain_" + acct_id)
- var at = localStorage.getItem("acct_" + acct_id + "_at")
- var httpreq = new XMLHttpRequest()
- var start = "https://" + domain + "/api/v1/markers"
- httpreq.open('POST', start, true)
- httpreq.setRequestHeader('Content-Type', 'application/json')
- httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
- httpreq.responseType = "json"
- httpreq.send(JSON.stringify(poster))
- httpreq.onreadystatechange = function () {
+ var domain = localStorage.getItem("domain_" + acct_id);
+ var at = localStorage.getItem("acct_" + acct_id + "_at");
+ var httpreq = new XMLHttpRequest();
+ var start = "https://" + domain + "/api/v1/markers";
+ httpreq.open("POST", start, true);
+ httpreq.setRequestHeader("Content-Type", "application/json");
+ httpreq.setRequestHeader("Authorization", "Bearer " + at);
+ httpreq.responseType = "json";
+ httpreq.send(JSON.stringify(poster));
+ httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
- var json = httpreq.response
- if(this.status!==200){ setLog(start, this.status, this.response); }
- console.log(json)
- ct++
+ var json = httpreq.response;
+ if (this.status !== 200) {
+ setLog(start, this.status, this.response);
+ }
+ console.log(json);
+ ct++;
if (ct == obl && callback) {
- postMessage(["asReadComp", ""], "*")
+ postMessage(["asReadComp", ""], "*");
}
}
- }
+ };
}
}
}
@@ -1110,23 +1115,20 @@ function asReadEnd() {
if (markers == "no") {
markers = false;
} else {
- markers = true
+ markers = true;
}
if (markers) {
- asRead(true)
+ asRead(true);
Swal.fire({
title: lang.lang_tl_postmarkers_title,
html: lang.lang_tl_postmarkers,
timer: 3000,
onBeforeOpen: () => {
- Swal.showLoading()
+ Swal.showLoading();
},
- onClose: () => {
- }
- }).then((result) => {
-
- })
+ onClose: () => {}
+ }).then(result => {});
} else {
- postMessage(["asReadComp", ""], "*")
+ postMessage(["asReadComp", ""], "*");
}
-}
\ No newline at end of file
+}
diff --git a/app/js/ui/settings.js b/app/js/ui/settings.js
index d8cdd5ea..2c9d0539 100644
--- a/app/js/ui/settings.js
+++ b/app/js/ui/settings.js
@@ -1,73 +1,73 @@
//設定(setting.html)で読む
var envView = new Vue({
- el: '#envView',
+ el: "#envView",
data: { config: envConstruction },
methods: {
- complete: function (i, val) {
+ complete: function(i, val) {
var ls = envView.config[i].storage;
- M.toast({ html: 'Complete', displayLength: 3000 })
+ M.toast({ html: "Complete", displayLength: 3000 });
if (!val) {
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") {
- hardwareAcceleration(val)
+ hardwareAcceleration(val);
}
if (ls == "ua_setting") {
- useragent(val)
+ useragent(val);
}
- return true
+ return true;
}
}
});
var tlView = new Vue({
- el: '#tlView',
+ el: "#tlView",
data: { config: tlConstruction },
methods: {
- complete: function (i, val) {
+ complete: function(i, val) {
var ls = tlView.config[i];
if (val) {
- localStorage.setItem(ls.storage, val)
+ localStorage.setItem(ls.storage, val);
} else {
if (!ls.data) {
- ls = [ls]
+ ls = [ls];
} else {
- ls = ls.data
+ ls = ls.data;
}
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 val = $("#" + id).val()
- localStorage.setItem(ls[j].storage, val)
+ var val = $("#" + id).val();
+ localStorage.setItem(ls[j].storage, val);
}
}
- return true
+ return true;
}
}
});
var postView = new Vue({
- el: '#postView',
- data: { config: postConstruction, kirishima: localStorage.getItem('kirishima'), quoters: localStorage.getItem('quoters') },
+ el: "#postView",
+ data: { config: postConstruction, kirishima: localStorage.getItem("kirishima"), quoters: localStorage.getItem("quoters") },
methods: {
- complete: function (i, val) {
+ complete: function(i, val) {
var ls = postView.config[i];
if (val) {
- localStorage.setItem(ls.storage, val)
+ localStorage.setItem(ls.storage, val);
} else {
if (!ls.data) {
- ls = [ls]
+ ls = [ls];
} else {
- ls = ls.data
+ ls = ls.data;
}
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 val = $("#" + id).val()
- localStorage.setItem(ls[j].storage, val)
+ var val = $("#" + id).val();
+ localStorage.setItem(ls[j].storage, val);
}
}
- return true
+ return true;
}
}
});
@@ -83,7 +83,7 @@ function settings() {
$("#" + theme).prop("checked", true);
} else {
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);
@@ -92,14 +92,14 @@ function settings() {
var fontd = $("#font").val();
if (fontd) {
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);
themes();
} else {
if (localStorage.getItem("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();
}
}
@@ -111,7 +111,7 @@ function load() {
for (var i = 0; i < max; i++) {
var ls = envView.config[i].storage;
if (localStorage.getItem(ls)) {
- envView.config[i].setValue = localStorage.getItem(ls)
+ envView.config[i].setValue = localStorage.getItem(ls);
}
}
var max = tlView.config.length;
@@ -119,13 +119,13 @@ function load() {
var ls = tlView.config[i].storage;
if (ls) {
if (localStorage.getItem(ls)) {
- tlView.config[i].setValue = localStorage.getItem(ls)
+ tlView.config[i].setValue = localStorage.getItem(ls);
}
} else {
- ls = tlView.config[i].data
+ ls = tlView.config[i].data;
for (var j = 0; j < ls.length; j++) {
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;
if (ls) {
if (localStorage.getItem(ls)) {
- postView.config[i].setValue = localStorage.getItem(ls)
+ postView.config[i].setValue = localStorage.getItem(ls);
}
} else {
- ls = postView.config[i].data
+ ls = postView.config[i].data;
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,25 +160,25 @@ function load() {
var font = "";
}
$("#font").val(font);
- $("#c1-file").text(localStorage.getItem("custom1"))
+ $("#c1-file").text(localStorage.getItem("custom1"));
$("#c2-file").text(localStorage.getItem("custom2"));
$("#c3-file").text(localStorage.getItem("custom3"));
$("#c4-file").text(localStorage.getItem("custom4"));
- var cvol = localStorage.getItem("customVol")
+ var cvol = localStorage.getItem("customVol");
if (cvol) {
$("#soundvol").val(cvol * 100);
- $("#soundVolVal").text(cvol * 100)
+ $("#soundVolVal").text(cvol * 100);
}
//$("#log").val(localStorage.getItem("errors"))
}
function customVol() {
- var cvol = $("#soundvol").val()
- $("#soundVolVal").text(cvol)
- localStorage.setItem("customVol", cvol / 100)
+ var cvol = $("#soundvol").val();
+ $("#soundVolVal").text(cvol);
+ localStorage.setItem("customVol", cvol / 100);
var sound = localStorage.getItem("favSound");
if (sound == "default") {
- var file = "../../source/notif.wav"
- }else{
+ var file = "../../source/notif.wav";
+ } else {
if (sound == "c1") {
var file = localStorage.getItem("custom1");
} else if (sound == "c2") {
@@ -208,13 +208,10 @@ function climute() {
return;
}
var templete;
- Object.keys(obj).forEach(function (key) {
+ Object.keys(obj).forEach(function(key) {
var cli = obj[key];
var list = key * 1 + 1;
- templete = '' + list +
- '.' +
- escapeHTML(cli) + '
';
+ templete = '' + list + "." + escapeHTML(cli) + '
";
$("#mute-cli").append(templete);
});
}
@@ -231,9 +228,11 @@ function cliMuteDel(key) {
function wordmute() {
var word = localStorage.getItem("word_mute");
var obj = JSON.parse(word);
- if (!obj) { obj = [] }
- $('#wordmute').chips({
- data: obj,
+ if (!obj) {
+ obj = [];
+ }
+ $("#wordmute").chips({
+ data: obj
});
}
function wordmuteSave() {
@@ -245,9 +244,11 @@ function wordmuteSave() {
function wordemp() {
var word = localStorage.getItem("word_emp");
var obj = JSON.parse(word);
- if (!obj) { obj = [] }
- $('#wordemp').chips({
- data: obj,
+ if (!obj) {
+ obj = [];
+ }
+ $("#wordemp").chips({
+ data: obj
});
}
function wordempSave() {
@@ -258,39 +259,44 @@ function wordempSave() {
function notftest() {
var os = localStorage.getItem("platform");
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")
};
- var n = new Notification('TheDesk' + lang.lang_setting_notftest, options);
-
+ var n = new Notification("TheDesk" + lang.lang_setting_notftest, options);
}
function oks(no) {
var txt = $("#oks-" + no).val();
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() {
- if (localStorage.getItem("oks-1")) { $("#oks-1").val(localStorage.getItem("oks-1")) }
- if (localStorage.getItem("oks-2")) { $("#oks-2").val(localStorage.getItem("oks-2")) }
- if (localStorage.getItem("oks-3")) { $("#oks-3").val(localStorage.getItem("oks-3")) }
+ if (localStorage.getItem("oks-1")) {
+ $("#oks-1").val(localStorage.getItem("oks-1"));
+ }
+ 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) {
- postMessage(["lang", lang], "*")
+ postMessage(["lang", lang], "*");
}
function exportSettings() {
Swal.fire({
title: lang.lang_setting_exportwarn,
- type: 'warning',
+ type: "warning",
showCancelButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#d33',
+ confirmButtonColor: "#3085d6",
+ cancelButtonColor: "#d33",
confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no
- }).then((result) => {
+ }).then(result => {
if (result.value) {
- postMessage(["exportSettings", ""], "*")
+ postMessage(["exportSettings", ""], "*");
}
- })
+ });
}
function exportSettingsCore() {
var exp = {};
@@ -309,27 +315,23 @@ function exportSettingsCore() {
var max = envView.config.length;
for (var i = 0; i < max; i++) {
var ls = envView.config[i].storage;
- config[ls] = localStorage.getItem(ls)
+ config[ls] = localStorage.getItem(ls);
}
var max = tlView.config.length;
for (var i = 0; i < max; i++) {
var ls = tlView.config[i].storage;
- config[ls] = localStorage.getItem(ls)
+ config[ls] = localStorage.getItem(ls);
}
var max = postView.config.length;
for (var i = 0; i < max; i++) {
var ls = postView.config[i].storage;
- config[ls] = localStorage.getItem(ls)
+ config[ls] = localStorage.getItem(ls);
}
//Font
config.font = localStorage.getItem("font");
exp.config = config;
//keysc
- exp.ksc = [
- localStorage.getItem("oks-1"),
- localStorage.getItem("oks-2"),
- localStorage.getItem("oks-3")
- ];
+ exp.ksc = [localStorage.getItem("oks-1"), localStorage.getItem("oks-2"), localStorage.getItem("oks-3")];
//climu
var cli = localStorage.getItem("client_mute");
var climu = JSON.parse(cli);
@@ -339,7 +341,7 @@ function exportSettingsCore() {
var wordmu = JSON.parse(wdm);
exp.wordMute = wordmu;
//spotify
- exp.spotifyArtwork = localStorage.getItem("artwork")
+ exp.spotifyArtwork = localStorage.getItem("artwork");
var content = localStorage.getItem("np-temp");
if (content || content == "" || content == "null") {
exp.spotifyTemplete = content;
@@ -350,27 +352,27 @@ function exportSettingsCore() {
var tagarr = localStorage.getItem("tag");
var favtag = JSON.parse(tagarr);
exp.favoriteTags = favtag;
- exp.revisons = 2.1
- exp.meta = {}
- exp.meta.date = new Date()
- exp.meta.thedesk = localStorage.getItem("ver")
- exp.meta.platform = localStorage.getItem("platform")
+ exp.revisons = 2.1;
+ exp.meta = {};
+ exp.meta.date = new Date();
+ exp.meta.thedesk = localStorage.getItem("ver");
+ exp.meta.platform = localStorage.getItem("platform");
return exp;
}
function importSettings() {
Swal.fire({
title: lang.lang_setting_importwarn,
- type: 'warning',
+ type: "warning",
showCancelButton: true,
- confirmButtonColor: '#3085d6',
- cancelButtonColor: '#d33',
+ confirmButtonColor: "#3085d6",
+ cancelButtonColor: "#d33",
confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no
- }).then((result) => {
+ }).then(result => {
if (result.value) {
- postMessage(["importSettings", ""], "*")
+ postMessage(["importSettings", ""], "*");
}
- })
+ });
}
function importSettingsCore(obj) {
if (obj) {
@@ -392,21 +394,21 @@ function importSettingsCore(obj) {
for (var i = 0; i < max; i++) {
var ls = envView.config[i].storage;
if (obj.config[ls]) {
- localStorage.setItem(ls, obj.config[ls])
+ localStorage.setItem(ls, obj.config[ls]);
}
}
var max = tlView.config.length;
for (var i = 0; i < max; i++) {
var ls = tlView.config[i].storage;
if (obj.config[ls]) {
- localStorage.setItem(ls, obj.config[ls])
+ localStorage.setItem(ls, obj.config[ls]);
}
}
var max = postView.config.length;
for (var i = 0; i < max; i++) {
var ls = postView.config[i].storage;
if (obj.config[ls]) {
- localStorage.setItem(ls, obj.config[ls])
+ localStorage.setItem(ls, obj.config[ls]);
}
}
} else {
@@ -459,113 +461,133 @@ function importSettingsCore(obj) {
location.href = "index.html";
} else {
Swal.fire({
- type: 'error',
- title: 'Error'
- })
+ type: "error",
+ title: "Error"
+ });
}
}
function savefolder() {
- postMessage(["sendSinmpleIpc", "savefolder"], "*")
+ postMessage(["sendSinmpleIpc", "savefolder"], "*");
}
function font() {
- postMessage(["sendSinmpleIpc", "fonts"], "*")
+ postMessage(["sendSinmpleIpc", "fonts"], "*");
}
function fontList(arg) {
$("#fonts").removeClass("hide");
for (var i = 0; i < arg.length; i++) {
var font = arg[i];
- $("#fonts").append('' + font.family + "
")
+ $("#fonts").append('" + font.family + "
");
}
}
function insertFont(name) {
$("#font").val(name);
}
-$(".color-picker").each(function (i, elem) {
+$(".color-picker").each(function(i, elem) {
pickerDefine(i, "fff");
});
function pickerDefine(i, color) {
var pickr = new Pickr({
- el: '#color-picker' + i,
+ el: "#color-picker" + i,
default: color,
showAlways: true,
appendToBody: true,
- closeWithKey: 'Escape',
+ closeWithKey: "Escape",
comparison: false,
components: {
preview: true, // Left side color comparison
opacity: false, // Opacity slider
- hue: true, // Hue slider
+ hue: true, // Hue slider
interaction: {
rgba: false, // rgba option (red green blue and alpha)
- input: true, // input / output element
+ input: true // input / output element
}
},
strings: {
- save: 'Save', // Default for save button
- clear: 'Clear' // Default for clear button
+ save: "Save", // Default for save button
+ clear: "Clear" // Default for clear button
}
});
- pickr.on('change', (...args) => {
- var rgb = 'rgb(' + args[0].toRGBA()[0] + ',' + args[0].toRGBA()[1] + ',' + args[0].toRGBA()[2] + ')';
- $("#color-picker" + i + "_value").val(rgb)
+ pickr.on("change", (...args) => {
+ var rgb = "rgb(" + args[0].toRGBA()[0] + "," + args[0].toRGBA()[1] + "," + args[0].toRGBA()[2] + ")";
+ $("#color-picker" + i + "_value").val(rgb);
});
}
function customComp() {
var nameC = $("#custom_name").val();
- if (!nameC) { return false; }
+ if (!nameC) {
+ return false;
+ }
var descC = $("#custom_desc").val();
var primaryC = $("#color-picker0_value").val();
- if (!primaryC) { primaryC = "rgb(255,255,255)" }
- var secondaryC = $("#color-picker1_value").val();
- if (!secondaryC) { secondaryC = "rgb(255,255,255)" }
- var textC = $("#color-picker2_value").val();
- if (!textC) { textC = "rgb(255,255,255)" }
- var multi = localStorage.getItem("multi");
- if($("#pickers").hasClass("advanceTheme")){
- var accentC = $("#color-picker3_value").val();
- if (!accentC) { accentC = null }
- 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{
- var advanceTheme = {}
+ if (!primaryC) {
+ primaryC = "rgb(255,255,255)";
}
-
+ var secondaryC = $("#color-picker1_value").val();
+ if (!secondaryC) {
+ secondaryC = "rgb(255,255,255)";
+ }
+ var textC = $("#color-picker2_value").val();
+ if (!textC) {
+ textC = "rgb(255,255,255)";
+ }
+ var multi = localStorage.getItem("multi");
+ if ($("#pickers").hasClass("advanceTheme")) {
+ var accentC = $("#color-picker3_value").val();
+ if (!accentC) {
+ accentC = null;
+ }
+ 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 {
+ var advanceTheme = {};
+ }
+
var my = JSON.parse(multi)[0].name;
var id = $("#custom-edit-sel").val();
if (id == "add_new") {
id = makeCID();
}
- localStorage.setItem("customtheme-id", id)
+ localStorage.setItem("customtheme-id", id);
var json = {
- "name": nameC,
- "author": my,
- "desc": descC,
- "base": $("[name=direction]:checked").val(),
- "vars": {
- "primary": primaryC,
- "secondary": secondaryC,
- "text": textC
+ name: nameC,
+ author: my,
+ desc: descC,
+ base: $("[name=direction]:checked").val(),
+ vars: {
+ primary: primaryC,
+ secondary: secondaryC,
+ text: textC
},
- "props": advanceTheme,
- "id": id
- }
+ props: advanceTheme,
+ id: id
+ };
$("#custom_json").val(JSON.stringify(json));
themes("custom");
$("#custom").prop("checked", true);
@@ -573,12 +595,12 @@ function customComp() {
$("#custom_desc").val("");
$("#dark").prop("checked", true);
$("#custom_json").val("");
- for(var i =0;i <= 8; i++){
- $("#color-picker" + i + "-wrap").html('')
+ for (var i = 0; i <= 8; i++) {
+ $("#color-picker" + i + "-wrap").html('');
$("#color-picker" + i + "_value").val("");
pickerDefine(i, "fff");
}
- postMessage(["themeJsonCreate", JSON.stringify(json)], "*")
+ postMessage(["themeJsonCreate", JSON.stringify(json)], "*");
}
function deleteIt() {
var id = $("#custom-sel-sel").val();
@@ -586,34 +608,34 @@ function deleteIt() {
$("#custom_desc").val("");
$("#dark").prop("checked", true);
$("#custom_json").val("");
- for(var i =0;i <= 8; i++){
- $("#color-picker" + i + "-wrap").html('')
+ for (var i = 0; i <= 8; i++) {
+ $("#color-picker" + i + "-wrap").html('');
$("#color-picker" + i + "_value").val("");
pickerDefine(i, "fff");
}
- postMessage(["themeJsonDelete", id], "*")
+ postMessage(["themeJsonDelete", id], "*");
}
function ctLoad() {
- postMessage(["sendSinmpleIpc", "theme-json-list"], "*")
+ postMessage(["sendSinmpleIpc", "theme-json-list"], "*");
}
function ctLoadCore(args) {
var templete = "";
- Object.keys(args).forEach(function (key) {
+ Object.keys(args).forEach(function(key) {
var theme = args[key];
- var themeid = theme.id
- templete = templete + '';
+ var themeid = theme.id;
+ templete = templete + '";
});
if (args[0]) {
- localStorage.setItem("customtheme-id", args[0].id)
+ localStorage.setItem("customtheme-id", args[0].id);
}
$("#custom-sel-sel").html(templete);
- templete = '' + templete;
+ templete = '" + templete;
$("#custom-edit-sel").html(templete);
- $('select').formSelect();
+ $("select").formSelect();
}
function customSel() {
var id = $("#custom-sel-sel").val();
- localStorage.setItem("customtheme-id", id)
+ localStorage.setItem("customtheme-id", id);
}
function custom() {
var id = $("#custom-edit-sel").val();
@@ -622,91 +644,91 @@ function custom() {
$("#custom_desc").val("");
$("#dark").prop("checked", true);
$("#custom_json").val("");
- for(var i =0;i <= 8; i++){
- $("#color-picker" + i + "-wrap").html('')
+ for (var i = 0; i <= 8; i++) {
+ $("#color-picker" + i + "-wrap").html('');
$("#color-picker" + i + "_value").val("");
pickerDefine(i, "fff");
}
- $("#delTheme").addClass("disabled")
+ $("#delTheme").addClass("disabled");
} else {
- $("#delTheme").removeClass("disabled")
- postMessage(["themeJsonRequest", id], "*")
+ $("#delTheme").removeClass("disabled");
+ postMessage(["themeJsonRequest", id], "*");
}
}
function customConnect(raw) {
- var args = raw[0]
+ var args = raw[0];
$("#custom_name").val(args.name);
$("#custom_desc").val(args.desc);
$("#" + args.base).prop("checked", true);
//Primary
- $("#color-picker0-wrap").html('')
- pickerDefine(0, rgbToHex(args.vars.primary))
+ $("#color-picker0-wrap").html('');
+ pickerDefine(0, rgbToHex(args.vars.primary));
$("#color-picker0_value").val(args.vars.primary);
//Secondary
- $("#color-picker1-wrap").html('')
- pickerDefine(1, rgbToHex(args.vars.secondary))
+ $("#color-picker1-wrap").html('');
+ pickerDefine(1, rgbToHex(args.vars.secondary));
$("#color-picker1_value").val(args.vars.secondary);
//Text
- $("#color-picker2-wrap").html('')
+ $("#color-picker2-wrap").html('');
$("#color-picker2_value").val(args.vars.text);
- pickerDefine(2, rgbToHex(args.vars.text))
+ pickerDefine(2, rgbToHex(args.vars.text));
//TheDesk Only
- advancedConncet(args, "TheDeskAccent", "secondary", 3)
- advancedConncet(args, "TheDeskActive", "primary", 4)
- advancedConncet(args, "TheDeskModal", "secondary", 5)
- advancedConncet(args, "TheDeskBottom", "primary", 6)
- advancedConncet(args, "TheDeskPostbox", "primary", 7)
- advancedConncet(args, "TheDeskSubcolor", "primary", 8)
+ advancedConncet(args, "TheDeskAccent", "secondary", 3);
+ advancedConncet(args, "TheDeskActive", "primary", 4);
+ advancedConncet(args, "TheDeskModal", "secondary", 5);
+ advancedConncet(args, "TheDeskBottom", "primary", 6);
+ advancedConncet(args, "TheDeskPostbox", "primary", 7);
+ advancedConncet(args, "TheDeskSubcolor", "primary", 8);
$("#custom_json").val(raw[1]);
}
-function advancedConncet(args, tar, sub, i){
+function advancedConncet(args, tar, sub, i) {
if (args.props) {
if (args.props[tar]) {
var color = args.props[tar];
- $("#pickers").addClass("advanceTheme")
- $(".advanced").removeClass("hide")
+ $("#pickers").addClass("advanceTheme");
+ $(".advanced").removeClass("hide");
} else {
var color = args.vars[sub];
}
} else {
var color = args.vars[sub];
}
- $("#color-picker"+i+"-wrap").html('')
- $("#color-picker"+i+"_value").val(color);
- pickerDefine(i, rgbToHex(color))
+ $("#color-picker" + i + "-wrap").html('');
+ $("#color-picker" + i + "_value").val(color);
+ pickerDefine(i, rgbToHex(color));
}
function customImp() {
var json = $("#custom_import").val();
if (JSON5.parse(json)) {
- postMessage(["themeJsonCreate", json], "*")
+ postMessage(["themeJsonCreate", json], "*");
} else {
Swal.fire({
- type: 'error',
- title: 'Error'
- })
+ type: "error",
+ title: "Error"
+ });
}
}
-function advanced(){
- $(".advanced").toggleClass("hide")
- $("#pickers").toggleClass("advanceTheme")
+function advanced() {
+ $(".advanced").toggleClass("hide");
+ $("#pickers").toggleClass("advanceTheme");
}
function clearCustomImport() {
$("#custom_import").val("");
}
function hardwareAcceleration(had) {
- postMessage(["ha", had], "*")
+ postMessage(["ha", had], "*");
}
-function useragent(val){
- postMessage(["ua", val], "*")
+function useragent(val) {
+ postMessage(["ua", val], "*");
}
function customSound(key) {
- postMessage(["customSound", key], "*")
+ postMessage(["customSound", key], "*");
}
function customSoundSave(key, file) {
localStorage.setItem("custom" + key, file);
- $("#c1-file").text(file)
+ $("#c1-file").text(file);
}
-window.onload = function () {
+window.onload = function() {
//最初に読む
load();
climute();
@@ -715,52 +737,56 @@ window.onload = function () {
checkSpotify();
voiceSettingLoad();
oksload();
- ctLoad()
+ ctLoad();
};
//設定画面で未読マーカーは要らない
function asReadEnd() {
- postMessage(["asReadComp", ""], "*")
+ postMessage(["asReadComp", ""], "*");
}
-function checkupd(){
+function checkupd() {
var ver = localStorage.getItem("ver");
var start = "https://thedesk.top/ver.json";
fetch(start, {
- method: 'GET'
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (mess) {
- console.table(mess);
- if (mess) {
- var platform = localStorage.getItem("platform");
- if (platform == "darwin") {
- var newest = mess.desk_mac;
- } else {
- var newest = mess.desk;
+ method: "GET"
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
- if (newest == ver) {
- Swal.fire({
- type: 'info',
- title: lang.lang_setting_noupd,
- html: ver
- })
- } else if (ver.indexOf("beta") != -1 || winstore) {
- Swal.fire({
- type: 'info',
- title: lang.lang_setting_thisisbeta,
- html: ver
- })
- } else {
- localStorage.removeItem("new-ver-skip")
- location.href="index.html"
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(mess) {
+ console.table(mess);
+ if (mess) {
+ var platform = localStorage.getItem("platform");
+ if (platform == "darwin") {
+ var newest = mess.desk_mac;
+ } else {
+ var newest = mess.desk;
+ }
+ if (newest == ver) {
+ Swal.fire({
+ type: "info",
+ title: lang.lang_setting_noupd,
+ html: ver
+ });
+ } else if (ver.indexOf("beta") != -1 || winstore) {
+ Swal.fire({
+ type: "info",
+ title: lang.lang_setting_thisisbeta,
+ html: ver
+ });
+ } else {
+ localStorage.removeItem("new-ver-skip");
+ location.href = "index.html";
+ }
}
- }
- });
-}
\ No newline at end of file
+ });
+}
diff --git a/app/js/ui/spotify.js b/app/js/ui/spotify.js
index bfab5905..f514def9 100644
--- a/app/js/ui/spotify.js
+++ b/app/js/ui/spotify.js
@@ -1,189 +1,189 @@
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 platform = localStorage.getItem("platform");
- if (platform == "win32") {
- postMessage(["openUrl", auth], "*")
- postMessage(["sendSinmpleIpc", "quit"], "*")
- } else {
- auth = auth + "&state=code";
- $("#spotify-code-show").removeClass("hide");
- postMessage(["openUrl", auth], "*")
- }
-
-
+ 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");
+ if (platform == "win32") {
+ postMessage(["openUrl", auth], "*");
+ postMessage(["sendSinmpleIpc", "quit"], "*");
+ } else {
+ auth = auth + "&state=code";
+ $("#spotify-code-show").removeClass("hide");
+ postMessage(["openUrl", auth], "*");
+ }
}
function spotifyAuth() {
- var code = $("#spotify-code").val();
- localStorage.setItem("spotify", "code");
- localStorage.setItem("spotify-refresh", code);
- $("#spotify-code-show").addClass("hide");
- $("#spotify-enable").addClass("disabled");
- $("#spotify-disable").removeClass("disabled");
+ var code = $("#spotify-code").val();
+ localStorage.setItem("spotify", "code");
+ localStorage.setItem("spotify-refresh", code);
+ $("#spotify-code-show").addClass("hide");
+ $("#spotify-enable").addClass("disabled");
+ $("#spotify-disable").removeClass("disabled");
}
function spotifyDisconnect() {
- localStorage.removeItem("spotify");
- localStorage.removeItem("spotify-refresh");
- checkSpotify();
+ localStorage.removeItem("spotify");
+ localStorage.removeItem("spotify-refresh");
+ checkSpotify();
}
function checkSpotify() {
- if (localStorage.getItem("spotify")) {
- $("#spotify-enable").addClass("disabled");
- $("#spotify-disable").removeClass("disabled");
- } else {
- $("#spotify-enable").removeClass("disabled");
- $("#spotify-disable").addClass("disabled");
- }
- var content = localStorage.getItem("np-temp");
- if (!content || content == "" || content == "null") {
- var content = "#NowPlaying {song} / {album} / {artist}\n{url} #SpotifyWithTheDesk";
- }
- $("#np-temp").val(content);
- var flag = localStorage.getItem("artwork");
- if (flag) {
- $("#awk_yes").prop("checked", true);
- } else {
- $("#awk_no").prop("checked", true);
- }
+ if (localStorage.getItem("spotify")) {
+ $("#spotify-enable").addClass("disabled");
+ $("#spotify-disable").removeClass("disabled");
+ } else {
+ $("#spotify-enable").removeClass("disabled");
+ $("#spotify-disable").addClass("disabled");
+ }
+ var content = localStorage.getItem("np-temp");
+ if (!content || content == "" || content == "null") {
+ var content = "#NowPlaying {song} / {album} / {artist}\n{url} #SpotifyWithTheDesk";
+ }
+ $("#np-temp").val(content);
+ var flag = localStorage.getItem("artwork");
+ if (flag) {
+ $("#awk_yes").prop("checked", true);
+ } else {
+ $("#awk_no").prop("checked", true);
+ }
}
function spotifyFlagSave() {
- var awk = $("[name=awk]:checked").val();
- if (awk == "yes") {
- localStorage.setItem("artwork", "yes");
- M.toast({ html: lang.lang_spotify_img, displayLength: 3000 })
- } else {
- localStorage.removeItem("artwork");
- M.toast({ html: lang.lang_spotify_imgno, displayLength: 3000 })
- }
+ var awk = $("[name=awk]:checked").val();
+ if (awk == "yes") {
+ localStorage.setItem("artwork", "yes");
+ M.toast({ html: lang.lang_spotify_img, displayLength: 3000 });
+ } else {
+ localStorage.removeItem("artwork");
+ M.toast({ html: lang.lang_spotify_imgno, displayLength: 3000 });
+ }
}
function nowplaying(mode) {
- if (mode == "spotify") {
- var start = "https://thedesk.top/now-playing?at=" + localStorage.getItem("spotify") + "&rt=" + localStorage.getItem("spotify-refresh");
- var at = localStorage.getItem("spotify");
- if (at) {
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json'
- }
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
+ if (mode == "spotify") {
+ var start = "https://thedesk.top/now-playing?at=" + localStorage.getItem("spotify") + "&rt=" + localStorage.getItem("spotify-refresh");
+ var at = localStorage.getItem("spotify");
+ if (at) {
+ fetch(start, {
+ method: "GET",
+ headers: {
+ "content-type": "application/json"
+ }
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ console.table(json);
+ if (json.length < 1) {
+ return false;
+ }
+ var item = json.item;
+ var img = item.album.images[0].url;
+ var flag = localStorage.getItem("artwork");
+ if (flag) {
+ postMessage(["bmpImage", [img, 0]], "*");
+ }
+ var content = localStorage.getItem("np-temp");
+ if (!content || content == "" || content == "null") {
+ var content = "#NowPlaying {song} / {album} / {artist}\n{url}";
+ }
+ var regExp = new RegExp("{song}", "g");
+ content = content.replace(regExp, item.name);
+ var regExp = new RegExp("{album}", "g");
+ content = content.replace(regExp, item.album.name);
+ var regExp = new RegExp("{artist}", "g");
+ content = content.replace(regExp, item.artists[0].name);
+ var regExp = new RegExp("{url}", "g");
+ content = content.replace(regExp, item.external_urls.spotify);
+ var regExp = new RegExp("{composer}", "g");
+ content = content.replace(regExp, "");
+ var regExp = new RegExp("{hz}", "g");
+ content = content.replace(regExp, "");
+ var regExp = new RegExp("{bitRate}", "g");
+ content = content.replace(regExp, "");
+ var regExp = new RegExp("{lyricist}", "g");
+ content = content.replace(regExp, "");
+ var regExp = new RegExp("{bpm}", "g");
+ content = content.replace(regExp, "");
+ var regExp = new RegExp("{genre}", "g");
+ content = content.replace(regExp, "");
+ $("#textarea").val(content);
+ });
+ } else {
+ Swal.fire({
+ type: "info",
+ title: lang.lang_spotify_acct
});
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- console.table(json);
- if (json.length < 1) {
- return false;
- }
- var item = json.item;
- var img = item.album.images[0].url;
- var flag = localStorage.getItem("artwork");
- if (flag) {
- postMessage(["bmpImage", [img, 0]], "*")
- }
- var content = localStorage.getItem("np-temp");
- if (!content || content == "" || content == "null") {
- var content = "#NowPlaying {song} / {album} / {artist}\n{url}";
- }
- var regExp = new RegExp("{song}", "g");
- content = content.replace(regExp, item.name);
- var regExp = new RegExp("{album}", "g");
- content = content.replace(regExp, item.album.name);
- var regExp = new RegExp("{artist}", "g");
- content = content.replace(regExp, item.artists[0].name);
- var regExp = new RegExp("{url}", "g");
- content = content.replace(regExp, item.external_urls.spotify);
- var regExp = new RegExp("{composer}", "g");
- content = content.replace(regExp, "");
- var regExp = new RegExp("{hz}", "g");
- content = content.replace(regExp, "");
- var regExp = new RegExp("{bitRate}", "g");
- content = content.replace(regExp, "");
- var regExp = new RegExp("{lyricist}", "g");
- content = content.replace(regExp, "");
- var regExp = new RegExp("{bpm}", "g");
- content = content.replace(regExp, "");
- var regExp = new RegExp("{genre}", "g");
- content = content.replace(regExp, "");
- $("#textarea").val(content);
- });
- } else {
- Swal.fire({
- type: 'info',
- title: lang.lang_spotify_acct
- })
- }
- } else if (mode == "itunes") {
- postMessage(["itunes", ""], "*")
- }
+ } else if (mode == "itunes") {
+ postMessage(["itunes", ""], "*");
+ }
}
function npCore(arg) {
- if (arg.cmd) {
- console.error(arg);
- return;
- }
- console.table(arg);
- var content = localStorage.getItem("np-temp");
- if (!content || content == "" || content == "null") {
- var content = "#NowPlaying {song} / {album} / {artist}\n{url}";
- }
- var flag = localStorage.getItem("artwork");
- var platform = localStorage.getItem("platform");
- if (platform == "win32") {
- if (flag && arg.path) {
- media(arg.path, "image/png", "new");
- }
- } else if (platform == "darwin") {
- if (flag && arg.artwork) {
- media(arg.artwork, "image/png", "new");
- }
- }
- var regExp = new RegExp("{song}", "g");
- content = content.replace(regExp, arg.name);
- var regExp = new RegExp("{album}", "g");
- if(arg.album){
- if(arg.album.name){
- content = content.replace(regExp, arg.album.name);
- }
- }
- var regExp = new RegExp("{artist}", "g");
- content = content.replace(regExp, arg.artist);
- var regExp = new RegExp("{url}", "g");
- content = content.replace(regExp, "");
- var regExp = new RegExp("{composer}", "g");
- content = content.replace(regExp, arg.composer);
- var regExp = new RegExp("{hz}", "g");
- content = content.replace(regExp, arg.sampleRate / 1000 + "kHz");
- var regExp = new RegExp("{lyricist}", "g");
- content = content.replace(regExp, "");
- var regExp = new RegExp("{bpm}", "g");
- content = content.replace(regExp, "");
- var regExp = new RegExp("{bitRate}", "g");
- content = content.replace(regExp, arg.bitRate + "kbps");
- var regExp = new RegExp("{genre}", "g");
- content = content.replace(regExp, arg.genre);
- $("#textarea").val(content);
+ if (arg.cmd) {
+ console.error(arg);
+ return;
+ }
+ console.table(arg);
+ var content = localStorage.getItem("np-temp");
+ if (!content || content == "" || content == "null") {
+ var content = "#NowPlaying {song} / {album} / {artist}\n{url}";
+ }
+ var flag = localStorage.getItem("artwork");
+ var platform = localStorage.getItem("platform");
+ if (platform == "win32") {
+ if (flag && arg.path) {
+ media(arg.path, "image/png", "new");
+ }
+ } else if (platform == "darwin") {
+ if (flag && arg.artwork) {
+ media(arg.artwork, "image/png", "new");
+ }
+ }
+ var regExp = new RegExp("{song}", "g");
+ content = content.replace(regExp, arg.name);
+ var regExp = new RegExp("{album}", "g");
+ if (arg.album) {
+ if (arg.album.name) {
+ content = content.replace(regExp, arg.album.name);
+ }
+ }
+ var regExp = new RegExp("{artist}", "g");
+ content = content.replace(regExp, arg.artist);
+ var regExp = new RegExp("{url}", "g");
+ content = content.replace(regExp, "");
+ var regExp = new RegExp("{composer}", "g");
+ content = content.replace(regExp, arg.composer);
+ var regExp = new RegExp("{hz}", "g");
+ content = content.replace(regExp, arg.sampleRate / 1000 + "kHz");
+ var regExp = new RegExp("{lyricist}", "g");
+ content = content.replace(regExp, "");
+ var regExp = new RegExp("{bpm}", "g");
+ content = content.replace(regExp, "");
+ var regExp = new RegExp("{bitRate}", "g");
+ content = content.replace(regExp, arg.bitRate + "kbps");
+ var regExp = new RegExp("{genre}", "g");
+ content = content.replace(regExp, arg.genre);
+ $("#textarea").val(content);
}
function spotifySave() {
- var temp = $("#np-temp").val();
- localStorage.setItem("np-temp", temp);
- M.toast({ html: lang.lang_spotify_np, displayLength: 3000 })
+ var temp = $("#np-temp").val();
+ localStorage.setItem("np-temp", temp);
+ M.toast({ html: lang.lang_spotify_np, displayLength: 3000 });
}
if (location.search) {
- var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
- var mode = m[1];
- var codex = m[2];
- if (mode == "spotify") {
- var coder = codex.split(":");
- localStorage.setItem("spotify", coder[0]);
- localStorage.setItem("spotify-refresh", coder[1]);
- } else {
-
- }
-
-}
\ No newline at end of file
+ var m = location.search.match(/\?mode=([a-zA-Z-0-9]+)\&code=(.+)/);
+ var mode = m[1];
+ var codex = m[2];
+ if (mode == "spotify") {
+ var coder = codex.split(":");
+ localStorage.setItem("spotify", coder[0]);
+ localStorage.setItem("spotify-refresh", coder[1]);
+ } else {
+ }
+}
diff --git a/app/js/ui/tips.js b/app/js/ui/tips.js
index 8ef05985..fa23419a 100644
--- a/app/js/ui/tips.js
+++ b/app/js/ui/tips.js
@@ -2,93 +2,96 @@
var todcTrigger = null;
function todo(mes) {
clearInterval(todcTrigger);
- $('#message').text(mes);
- $('#message').fadeIn();
+ $("#message").text(mes);
+ $("#message").fadeIn();
todcTrigger = setTimeout(todc, 4000);
}
function todc() {
- $('#message').fadeOut();
+ $("#message").fadeOut();
}
//reverse
function bottomReverse() {
$("#bottom").toggleClass("reverse");
$(".leftside").toggleClass("reverse");
if ($("#bottom").hasClass("reverse")) {
- localStorage.removeItem("reverse")
+ localStorage.removeItem("reverse");
} else {
- localStorage.setItem("reverse", "true")
+ localStorage.setItem("reverse", "true");
}
}
function tips(mode) {
- postMessage(["sendSinmpleIpc", "endmem"], "*")
+ postMessage(["sendSinmpleIpc", "endmem"], "*");
clearInterval(clockint);
clearInterval(spotStart);
if (mode == "ver") {
- tipsToggle()
- $("#tips-text").html('TheDesk ' + localStorage.getItem("ver") + ' {'+ gitHash.slice(0, 7) +'} [supervisor_account1+]')
- localStorage.setItem("tips", "ver")
+ tipsToggle();
+ $("#tips-text").html('TheDesk " + localStorage.getItem("ver") + " {" + gitHash.slice(0, 7) + '} [supervisor_account1+]');
+ localStorage.setItem("tips", "ver");
} else if (mode == "clock") {
- tipsToggle()
- localStorage.setItem("tips", "clock")
- clock()
+ tipsToggle();
+ localStorage.setItem("tips", "clock");
+ clock();
} else if (mode == "memory") {
- tipsToggle()
- localStorage.setItem("tips", "memory")
+ tipsToggle();
+ localStorage.setItem("tips", "memory");
startmem();
} else if (mode == "trend") {
- tipsToggle()
- localStorage.setItem("tips", "trend")
- trendTagonTip()
+ tipsToggle();
+ localStorage.setItem("tips", "trend");
+ trendTagonTip();
} else if (mode == "spotify") {
- tipsToggle()
- localStorage.setItem("tips", "spotify")
- var json = nowplaying("spotifytips")
- spotifytips(json)
+ tipsToggle();
+ localStorage.setItem("tips", "spotify");
+ var json = nowplaying("spotifytips");
+ spotifytips(json);
}
}
//メモリ
function startmem() {
- postMessage(["sendSinmpleIpc", "startmem"], "*")
+ postMessage(["sendSinmpleIpc", "startmem"], "*");
}
-function renderMem(use, cpu, total){
- $("#tips-text").html(escapeHTML(cpu) + "
Memory:" + Math.floor(use / 1024 / 1024 / 102.4) / 10 + "/" + Math.floor(total / 1024 / 1024 / 102.4) / 10 + "GB(" + Math.floor(use / total * 100) + "%)")
+function renderMem(use, cpu, total) {
+ $("#tips-text").html(escapeHTML(cpu) + "
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() {
$(".trendtag").remove();
- var domain = "imastodon.net"
+ var domain = "imastodon.net";
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, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json',
- 'Authorization': 'Bearer ' + at
- },
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
+ "content-type": "application/json",
+ Authorization: "Bearer " + at
}
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- if (json) {
- var tags = "";
- json = json.score;
- Object.keys(json).forEach(function (tag) {
- tags = tags + '#' + escapeHTML(tag) + ' TL Toot
';
- });
- $("#tips-text").html('トレンドタグrefresh:
' + tags + '
');
- trendTagonTipInterval()
- } else {
- $("#tips-text").html("");
- }
- });
-
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
+ }
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ if (json) {
+ var tags = "";
+ json = json.score;
+ Object.keys(json).forEach(function(tag) {
+ tags = tags + "#' + escapeHTML(tag) + ' TL Toot
';
+ });
+ $("#tips-text").html('トレンドタグrefresh:
' + tags + "
");
+ trendTagonTipInterval();
+ } else {
+ $("#tips-text").html("");
+ }
+ });
}
//Spotify
function spotifytips() {
@@ -96,64 +99,68 @@ function spotifytips() {
var at = localStorage.getItem("spotify");
if (at) {
fetch(start, {
- method: 'GET',
+ method: "GET",
headers: {
- 'content-type': 'application/json'
+ "content-type": "application/json"
}
- }).then(function (response) {
- if (!response.ok) {
- response.text().then(function(text) {
- setLog(response.url, response.status, text);
- });
- }
- return response.json();
- }).catch(function (error) {
- todo(error);
- console.error(error);
- }).then(function (json) {
- var ms = json.progress_ms;
- var last = 1000 - ms % 1000;
- var item = json.item;
- var img = item.album.images[0].url;
- var artisttxt = "";
- for (i = 0; i < item.artists.length; i++) {
- if (i > 0) {
- artisttxt = artisttxt + "," + item.artists[i].name;
- } else {
- artisttxt = item.artists[0].name;
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text);
+ });
}
- }
- artisttxt = escapeHTML(artisttxt);
- sleep(last);
- var tms = item.duration_ms;
- var per = ms / item.duration_ms * 100;
- ms = ms / 1000;
- tms = tms / 1000;
- var s = Math.round(ms) % 60;
- if (s < 10) {
- s = "0" + s;
- }
- var m = (Math.round(ms) - Math.round(ms) % 60) / 60;
- var ts = Math.round(tms) % 60;
- if (ts < 10) {
- ts = "0" + ts;
- }
- var tm = (Math.round(tms) - Math.round(tms) % 60) / 60;
- $("#tips-text").html('refresh' + escapeHTML(item.name) + '
' + artisttxt + '' + m + ':
' + s + '/' + tm + ":" + ts + '
');
- spotint = setInterval(spotStart, 1000);
- });
+ return response.json();
+ })
+ .catch(function(error) {
+ todo(error);
+ setLog(start, "JSON", error);
+ console.error(error);
+ })
+ .then(function(json) {
+ var ms = json.progress_ms;
+ var last = 1000 - (ms % 1000);
+ var item = json.item;
+ var img = item.album.images[0].url;
+ var artisttxt = "";
+ for (i = 0; i < item.artists.length; i++) {
+ if (i > 0) {
+ artisttxt = artisttxt + "," + item.artists[i].name;
+ } else {
+ artisttxt = item.artists[0].name;
+ }
+ }
+ artisttxt = escapeHTML(artisttxt);
+ sleep(last);
+ var tms = item.duration_ms;
+ var per = (ms / item.duration_ms) * 100;
+ ms = ms / 1000;
+ tms = tms / 1000;
+ var s = Math.round(ms) % 60;
+ if (s < 10) {
+ s = "0" + s;
+ }
+ var m = (Math.round(ms) - (Math.round(ms) % 60)) / 60;
+ var ts = Math.round(tms) % 60;
+ if (ts < 10) {
+ ts = "0" + ts;
+ }
+ var tm = (Math.round(tms) - (Math.round(tms) % 60)) / 60;
+ $("#tips-text").html('refresh' + escapeHTML(item.name) + '
' + artisttxt + '' + m + ':
' + s + "/" + tm + ":" + ts + '
');
+ spotint = setInterval(spotStart, 1000);
+ });
} else {
Swal.fire({
- type: 'info',
+ type: "info",
title: lang.lang_spotify_acct
- })
+ });
}
}
function spotStart() {
var total = $(".spotify-prog").attr("data-total");
var s = $(".spotify-prog").attr("data-s");
var news = s * 1 + 1;
- var per = news * 100000 / total;
+ var per = (news * 100000) / total;
var ns = news % 60;
var nm = (news - ns) / 60;
if (ns < 10) {
@@ -161,7 +168,7 @@ function spotStart() {
}
if (per >= 100) {
clearInterval(spotStart);
- spotifytips()
+ spotifytips();
} else {
$("#spot-m").text(nm);
$("#spot-s").text(ns);
@@ -170,7 +177,6 @@ function spotStart() {
$(".spotify-prog").css("width", per + "%");
}
-
function trendTagonTipInterval() {
setTimeout(trendTagonTip, 6000000);
}
@@ -178,18 +184,24 @@ function trendTagonTipInterval() {
var clockint;
function clock() {
var now = new Date();
- var last = 1000 - now.getTime() % 1000;
+ var last = 1000 - (now.getTime() % 1000);
sleep(last);
clockint = setInterval(clockStart, 1000);
}
function clockStart() {
var nowTime = new Date(); // 現在日時を得る
var nowHour = nowTime.getHours(); // 時を抜き出す
- if (nowHour < 10) { nowHour = "0" + nowHour }
+ if (nowHour < 10) {
+ nowHour = "0" + nowHour;
+ }
var nowMin = nowTime.getMinutes(); // 分を抜き出す
- if (nowMin < 10) { nowMin = "0" + nowMin }
+ if (nowMin < 10) {
+ nowMin = "0" + nowMin;
+ }
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() + '' + nowHour + ":" + nowMin + ":" + nowSec + "";
$("#tips-text").html(msg);
}
diff --git a/app/main/system.js b/app/main/system.js
index afe3c777..2d19e760 100644
--- a/app/main/system.js
+++ b/app/main/system.js
@@ -256,13 +256,24 @@ function system(mainWindow, dir, lang, dirname) {
});
ipc.on("getLogs", (e, arg) => {
var logs=""
+ var todayLog=""
+ var yestLog=""
+ var yest2Log=""
fs.readdir(log_dir_path, function(err, files) {
if (err) throw err;
files.filter(function(file) {
- if (file == todayStr || file == yestStr || file == yest2Str) {
- logs=logs+fs.readFileSync(join(log_dir_path, file), "utf8")
+ if (file == todayStr) {
+ 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);
});
});
diff --git a/app/view/make/update.sample.html b/app/view/make/update.sample.html
index 9cc00a3b..5d6e9032 100644
--- a/app/view/make/update.sample.html
+++ b/app/view/make/update.sample.html
@@ -156,7 +156,7 @@
return response.json();
})
.catch(function(error) {
- todo(error);
+ todo(error);setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
@@ -228,7 +228,7 @@
return response.json();
})
.catch(function(error) {
- todo(error);
+ todo(error);setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {