Add: JSON parse miss error-log
This commit is contained in:
parent
5dfb28f2de
commit
ffa4ecd673
|
@ -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) {
|
||||
|
|
|
@ -2,16 +2,16 @@
|
|||
//最初に読むやつ
|
||||
//アスタルテ判定初期化
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
//コード受信
|
||||
|
@ -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('<option value="tootsearch">Tootsearch</option>');
|
||||
$("#add-acct-sel").html('<option value="noauth">' + lang.lang_login_noauth + '</option>');
|
||||
$("#add-acct-sel").html('<option value="noauth">' + lang.lang_login_noauth + "</option>");
|
||||
} else {
|
||||
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 = '<option value="' + key + '" data-icon="' + acct.prof +
|
||||
'" class="left circle" ' + sel + '>' + acct.user + '@' + acct.domain +
|
||||
'</option>';
|
||||
templete = '<option value="' + key + '" data-icon="' + acct.prof + '" class="left circle" ' + sel + ">" + acct.user + "@" + acct.domain + "</option>";
|
||||
$(".acct-sel").append(templete);
|
||||
|
||||
});
|
||||
$("#src-acct-sel").append('<option value="tootsearch">Tootsearch</option>');
|
||||
$("#add-acct-sel").append('<option value="noauth">' + lang.lang_login_noauth + '</option><option value="webview">Twitter</option>');
|
||||
$("#dir-acct-sel").append('<option value="noauth">' + lang.lang_login_noauth + '</option>');
|
||||
$("#dir-acct-sel").append('<option value="noauth">' + lang.lang_login_noauth + "</option>");
|
||||
}
|
||||
$('select').formSelect();
|
||||
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));
|
||||
}
|
||||
});
|
||||
})
|
||||
.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));
|
||||
}
|
||||
});
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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 =
|
||||
'<button class="btn waves-effect green" style="width:100%; padding:0; margin-top:0;" onclick="emojiGet(\'true\');">' + lang.lang_emoji_get + '</button>';
|
||||
var html = '<button class="btn waves-effect green" style="width:100%; padding:0; margin-top:0;" onclick="emojiGet(\'true\');">' + lang.lang_emoji_get + "</button>";
|
||||
$("#emoji-list").html(html);
|
||||
} 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;
|
||||
});
|
||||
});
|
||||
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')
|
||||
}
|
||||
});
|
||||
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 + '<a onclick="emojiReaction(\':' + emoji.shortcode +
|
||||
':\')" class="pointer"><img src="' + emoji.url + '" width="20" title="' + emoji.shortcode + '"></a>';
|
||||
html = html + "<a onclick=\"emojiReaction(':" + emoji.shortcode + ':\')" class="pointer"><img src="' + emoji.url + '" width="20" title="' + emoji.shortcode + '"></a>';
|
||||
} else {
|
||||
if(emoji.divider){
|
||||
html = html + '<p style="margin-bottom:0">'+ emoji.cat +'</p>'
|
||||
}else{
|
||||
if (emoji.divider) {
|
||||
html = html + '<p style="margin-bottom:0">' + emoji.cat + "</p>";
|
||||
} else {
|
||||
if (emoji.listed) {
|
||||
html = html + '<a onclick="emojiInsert(\':' + emoji.shortcode +
|
||||
':\')" class="pointer"><img src="' + emoji.url + '" width="20" title="' + emoji.shortcode + '"></a>';
|
||||
html = html + "<a onclick=\"emojiInsert(':" + emoji.shortcode + ':\')" class="pointer"><img src="' + emoji.url + '" width="20" title="' + emoji.shortcode + '"></a>';
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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"
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -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 + '<div class="pointer vote" onclick="vote(\'' + acct_id + '\',\'' + json.id + '\',' + choice.id + ')">' + escapeHTML(choice.text) + '(' + choice.votes + '' + myvote + ')</div>';
|
||||
});
|
||||
$(".vote_" + json.id).html(poll)
|
||||
}
|
||||
}
|
||||
}
|
||||
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 + '<div class="pointer vote" onclick="vote(\'' + acct_id + "','" + json.id + "'," + choice.id + ')">' + escapeHTML(choice.text) + "(" + choice.votes + "" + myvote + ")</div>";
|
||||
});
|
||||
$(".vote_" + json.id).html(poll);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
|
@ -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(
|
||||
"<span class=\"gray\">URL" + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" +
|
||||
escapeHTML(json.description) + "</span>");
|
||||
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
|
||||
$("[toot-id=" + id + "]").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('<span class="gray">URL' + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" + escapeHTML(json.description) + "</span>");
|
||||
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
|
||||
$("[toot-id=" + id + "]").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(
|
||||
"<span class=\"gray\">URL" + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" +
|
||||
escapeHTML(json.description) + "</span>");
|
||||
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
|
||||
$("[toot-id=" + id + "]").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('<span class="gray">URL' + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" + escapeHTML(json.description) + "</span>");
|
||||
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
|
||||
$("[toot-id=" + id + "]").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 = '<br><img src="' + json.image + '" style="max-width:100%" onclick="imgv(\'twi_' + id + '\', 0, \'twitter\');" id="twi_' + id + '-image-0" data-url="' + json.image + '" data-type="image">';
|
||||
} else {
|
||||
var twiImg = '';
|
||||
})
|
||||
.then(function(response) {
|
||||
if (!response.ok) {
|
||||
response.text().then(function(text) {
|
||||
setLog(response.url, response.status, text);
|
||||
});
|
||||
}
|
||||
$("[toot-id=" + id + "] .additional").html(
|
||||
'<div class="twitter-tweet"><b>' + escapeHTML(json.author_name) + '</b><br>' + escapeHTML(json.description) + twiImg + '</div>');
|
||||
} else if (json.provider_name == "pixiv") {
|
||||
if (json.image) {
|
||||
var pxvImg = '<br><img src="' + json.image + '" style="max-width:100%" onclick="imgv(\'pixiv_' + id + '\', 0, \'pixiv\');" id="pixiv_' + id + '-image-0" data-url="' + json.embed_url + '" data-type="image">';
|
||||
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 = '<br><img src="' + json.image + '" style="max-width:100%" onclick="imgv(\'twi_' + id + "', 0, 'twitter');\" id=\"twi_" + id + '-image-0" data-url="' + json.image + '" data-type="image">';
|
||||
} else {
|
||||
var twiImg = "";
|
||||
}
|
||||
$("[toot-id=" + id + "] .additional").html('<div class="twitter-tweet"><b>' + escapeHTML(json.author_name) + "</b><br>" + escapeHTML(json.description) + twiImg + "</div>");
|
||||
} else if (json.provider_name == "pixiv") {
|
||||
if (json.image) {
|
||||
var pxvImg = '<br><img src="' + json.image + '" style="max-width:100%" onclick="imgv(\'pixiv_' + id + "', 0, 'pixiv');\" id=\"pixiv_" + id + '-image-0" data-url="' + json.embed_url + '" data-type="image">';
|
||||
} else {
|
||||
var pxvImg = "";
|
||||
}
|
||||
$("[toot-id=" + id + "] .additional").html('<div class="pixiv-post"><b><a href="' + json.author_url + '" target="_blank">' + escapeHTML(json.author_name) + "</a></b><br>" + escapeHTML(json.title) + pxvImg + "</div>");
|
||||
} else {
|
||||
var pxvImg = '';
|
||||
if (json.title) {
|
||||
$("[toot-id=" + id + "] .additional").html('<span class="gray">URL' + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" + escapeHTML(json.description) + "</span>");
|
||||
}
|
||||
if (json.html) {
|
||||
$("[toot-id=" + id + "] .additional").html(json.html + '<i class="material-icons sml pointer" onclick="pip(\'' + id + '\')" title="' + lang.lang_cards_pip + '">picture_in_picture_alt</i>');
|
||||
}
|
||||
}
|
||||
$("[toot-id=" + id + "] .additional").html(
|
||||
'<div class="pixiv-post"><b><a href="' + json.author_url + '" target="_blank">' + escapeHTML(json.author_name) + '</a></b><br>' + escapeHTML(json.title) + pxvImg + '</div>');
|
||||
} else {
|
||||
if (json.title) {
|
||||
$("[toot-id=" + id + "] .additional").html(
|
||||
"<span class=\"gray\">URL" + lang.lang_cards_check + ":<br>Title:" + escapeHTML(json.title) + "<br>" +
|
||||
escapeHTML(json.description) + "</span>");
|
||||
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
|
||||
$("[toot-id=" + id + "]").addClass("parsed");
|
||||
}
|
||||
if (json.html) {
|
||||
$("[toot-id=" + id + "] .additional").html(json.html + '<i class="material-icons sml pointer" onclick="pip(\'' + id + '\')" title="' + lang.lang_cards_pip + '">picture_in_picture_alt</i>');
|
||||
|
||||
}
|
||||
}
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -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")
|
||||
}
|
||||
|
||||
});
|
||||
})
|
||||
.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");
|
||||
}
|
||||
});
|
||||
}
|
240
app/js/tl/dm.js
240
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 = '<div id="convList' + tlid + '">' + dmListParse(json, type, acct_id, tlid, "", mute) + '</div>';
|
||||
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 = '<div id="convList' + tlid + '">' + dmListParse(json, type, acct_id, tlid, "", mute) + "</div>";
|
||||
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 = '<div id="convList' + tlid + '">' + dmListParse(json, type, acct_id, tlid, "", mute) + '</div>';
|
||||
$("#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 = '<div id="convList' + tlid + '">' + dmListParse(json, type, acct_id, tlid, "", mute) + "</div>";
|
||||
$("#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 = '<img src="' + emoji.url +
|
||||
'" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
|
||||
var emoji_url = '<img src="' + emoji.url + '" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
|
||||
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 = '<a href="#" onclick="cw_show(\'' + toot.id +
|
||||
'\')" class="nex parsed">' + lang.lang_parse_cwshow + '</a><br>';
|
||||
var spoiler_show = '<a href="#" onclick="cw_show(\'' + toot.id + '\')" class="nex parsed">' + lang.lang_parse_cwshow + "</a><br>";
|
||||
} else {
|
||||
var ct1 = toot.content.split('</p>').length + toot.content.split('<br />').length - 2;
|
||||
var ct2 = toot.content.split('</p>').length + toot.content.split('<br>').length - 2;
|
||||
if (ct1 > ct2) { var ct = ct1; } else { var ct = ct2; }
|
||||
var ct1 = toot.content.split("</p>").length + toot.content.split("<br />").length - 2;
|
||||
var ct2 = toot.content.split("</p>").length + toot.content.split("<br>").length - 2;
|
||||
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 = '<span class="gray">' + lang.lang_parse_fulltext + '</span><br>' + toot.content
|
||||
var spoil = '<span class="cw-long-' + toot.id + '">' + $.mb_substr($.strip_tags(
|
||||
toot.content), 0, 100) +
|
||||
'</span><span class="gray">' + lang.lang_parse_autofold + '</span>';
|
||||
var content = '<span class="gray">' + lang.lang_parse_fulltext + "</span><br>" + toot.content;
|
||||
var spoil = '<span class="cw-long-' + toot.id + '">' + $.mb_substr($.strip_tags(toot.content), 0, 100) + '</span><span class="gray">' + lang.lang_parse_autofold + "</span>";
|
||||
var spoiler = "cw cw_hide_" + toot.id;
|
||||
var spoiler_show = '<a href="#" onclick="cw_show(\'' + toot.id +
|
||||
'\')" class="nex parsed">' + lang.lang_parse_more + '</a><br>';
|
||||
var spoiler_show = '<a href="#" onclick="cw_show(\'' + toot.id + '\')" class="nex parsed">' + lang.lang_parse_more + "</a><br>";
|
||||
} 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 = '<a onclick="additionalIndv(\'' + tlid + '\',' + acct_id +
|
||||
',\'' + id + '\')" class="add-show pointer">' + lang.lang_parse_url + '</a><br>';
|
||||
var analyze = "<a onclick=\"additionalIndv('" + tlid + "'," + acct_id + ",'" + id + '\')" class="add-show pointer">' + lang.lang_parse_url + "</a><br>";
|
||||
} 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 = '<img src="' + emoji.url +
|
||||
'" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
|
||||
var emoji_url = '<img src="' + emoji.url + '" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
|
||||
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 = '<img src="' + emoji.url +
|
||||
'" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
|
||||
var emoji_url = '<img src="' + emoji.url + '" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
|
||||
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 + '<a onclick="imgv(\'' + id + '\',\'' + key2 + '\',\'' +
|
||||
acct_id + '\')" id="' + id + '-image-' + key2 + '" data-url="' + url +
|
||||
'" data-type="' + media.type + '" class="img-parsed"><img src="' +
|
||||
purl + '" class="' + sense +
|
||||
' toot-img pointer" style="width:' + cwdt + '%; height:' + imh + 'px;"></a></span>';
|
||||
viewer = viewer + "<a onclick=\"imgv('" + id + "','" + key2 + "','" + acct_id + '\')" id="' + id + "-image-" + key2 + '" data-url="' + url + '" data-type="' + media.type + '" class="img-parsed"><img src="' + purl + '" class="' + sense + ' toot-img pointer" style="width:' + cwdt + "%; height:" + imh + 'px;"></a></span>';
|
||||
});
|
||||
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 + '<a onclick="udg(\'' + mention.id + '\',' +
|
||||
acct_id + ')" class="pointer">@' + mention.acct + '</a> ';
|
||||
mentions = mentions + "<a onclick=\"udg('" + mention.id + "'," + acct_id + ')" class="pointer">@' + mention.acct + "</a> ";
|
||||
});
|
||||
mentions = '<div style="float:right">' + mentions + '</div>';
|
||||
mentions = '<div style="float:right">' + mentions + "</div>";
|
||||
}
|
||||
var tagck = toot.tags[0];
|
||||
var tags = "";
|
||||
//タグであれば
|
||||
if (tagck) {
|
||||
Object.keys(toot.tags).forEach(function (key4) {
|
||||
Object.keys(toot.tags).forEach(function(key4) {
|
||||
var tag = toot.tags[key4];
|
||||
tags = tags + '<span class="hide" data-tag="' + tag.name + '">#' + tag.name + ':<a onclick="tl(\'tag\',\'' + tag.name + '\',' + acct_id +
|
||||
',\'add\')" class="pointer" title="' + lang.lang_parse_tagTL.replace("{{tag}}", '#' + tag.name) + '">TL</a> <a onclick="brInsert(\'#' + tag.name + '\')" class="pointer" title="' + lang.lang_parse_tagtoot.replace("{{tag}}", '#' + tag.name) + '">Toot</a> ' +
|
||||
'<a onclick="tagPin(\'' + tag.name + '\')" class="pointer" title="' + lang.lang_parse_tagpin.replace("{{tag}}", '#' + tag.name) + '">Pin</a></span> ';
|
||||
tags = tags + '<span class="hide" data-tag="' + tag.name + '">#' + tag.name + ":<a onclick=\"tl('tag','" + tag.name + "'," + acct_id + ',\'add\')" class="pointer" title="' + lang.lang_parse_tagTL.replace("{{tag}}", "#" + tag.name) + '">TL</a> <a onclick="brInsert(\'#' + tag.name + '\')" class="pointer" title="' + lang.lang_parse_tagtoot.replace("{{tag}}", "#" + tag.name) + '">Toot</a> ' + "<a onclick=\"tagPin('" + tag.name + '\')" class="pointer" title="' + lang.lang_parse_tagpin.replace("{{tag}}", "#" + tag.name) + '">Pin</a></span> ';
|
||||
});
|
||||
tags = '<div style="float:right">' + tags + '</div>';
|
||||
tags = '<div style="float:right">' + tags + "</div>";
|
||||
}
|
||||
//アニメ再生
|
||||
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 = '<br><img src="' + cards.image + '">';
|
||||
} else {
|
||||
var twiImg = '';
|
||||
var twiImg = "";
|
||||
}
|
||||
analyze = '<blockquote class="twitter-tweet"><b>' + escapeHTML(cards.author_name) + '</b><br>' + escapeHTML(cards.description) + twiImg + '</blockquote>';
|
||||
analyze = '<blockquote class="twitter-tweet"><b>' + escapeHTML(cards.author_name) + "</b><br>" + escapeHTML(cards.description) + twiImg + "</blockquote>";
|
||||
}
|
||||
if (cards.title) {
|
||||
analyze = "<span class=\"gray\">URL" + lang.lang_cards_check + ":<br>Title:" + escapeHTML(cards.title) + "<br>" +
|
||||
escapeHTML(cards.description) + "</span>";
|
||||
analyze = '<span class="gray">URL' + lang.lang_cards_check + ":<br>Title:" + escapeHTML(cards.title) + "<br>" + escapeHTML(cards.description) + "</span>";
|
||||
}
|
||||
if (cards.html) {
|
||||
analyze = cards.html + '<i class="material-icons" onclick="pip(' + id + ')" title="' + lang.lang_cards_pip + '">picture_in_picture_alt</i>';
|
||||
}
|
||||
|
||||
}
|
||||
//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 = '<div style="background:linear-gradient(to left,transparent, ' + value.bg + ' 96%) !important; color:' + value.text + ';width:100%; height:0.9rem; font-size:0.8rem;"><img src="' + value.image + '" style="height:100%;"><span style="position:relative; top:-0.2rem;"> ' + escapeHTML(value.name) + '</span></div>';
|
||||
var tickerdom = '<div style="background:linear-gradient(to left,transparent, ' + value.bg + " 96%) !important; color:" + value.text + ';width:100%; height:0.9rem; font-size:0.8rem;"><img src="' + value.image + '" style="height:100%;"><span style="position:relative; top:-0.2rem;"> ' + escapeHTML(value.name) + "</span></div>";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
templete = templete + '<div id="pub_' + toot.id + '" class="cvo ' +
|
||||
boostback + ' ' + fav_app +
|
||||
' ' + hasmedia + '" toot-id="' + id + '" unique-id="' + uniqueid + '" data-medias="' + media_ids + ' " unixtime="' + date(obj[
|
||||
key].created_at, 'unix') + '" ' + if_notf + ' onclick="dmStatus()">' +
|
||||
'<div class="area-notice"><span class="gray sharesta">' + notice + home +
|
||||
'</span></div>' +
|
||||
'<div class="area-icon"><a onclick="udg(\'' + toot.account.id +
|
||||
'\',' + acct_id + ');" user="' + toot.account.acct + '" class="udg">' +
|
||||
'<img src="' + avatar +
|
||||
'" width="40" class="prof-img" user="' + toot.account.acct +
|
||||
'"></a>' + noticeavatar + '</div>' +
|
||||
'<div class="area-display_name"><div class="flex-name"><span class="user">' +
|
||||
dis_name +
|
||||
'</span><span class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis; cursor:text;"> @' +
|
||||
toot.account.acct + locked + '</span></div>' +
|
||||
'<div class="flex-time"><span class="cbadge cbadge-hover pointer waves-effect" onclick="tootUriCopy(\'' +
|
||||
toot.url + '\');" title="' + date(toot.created_at, 'absolute') +
|
||||
'(' + lang.lang_parse_clickcopyurl + ')"><i class="far fa-clock-o"></i>' +
|
||||
date(toot.created_at, datetype) + '</span>' +
|
||||
'</div></div>' +
|
||||
'<div class="area-toot">' + tickerdom + '<span class="' +
|
||||
api_spoil + ' cw_text_' + toot.id + '"><span class="cw_text">' + spoil + "</span>" + spoiler_show +
|
||||
'</span><span class="toot ' + spoiler + '">' + content +
|
||||
'</span>' +
|
||||
'' + viewer + '' +
|
||||
'<br><a onclick="details(\'' + toot.id + '\',' + acct_id +
|
||||
',\'' + tlid + '\',\'dm\')" class="pointer waves-effect">' + lang.lang_parse_thread + '</a></div>' +
|
||||
'<div class="area-vis"></div>' +
|
||||
'</div></div>';
|
||||
templete = templete + '<div id="pub_' + toot.id + '" class="cvo ' + boostback + " " + fav_app + " " + hasmedia + '" toot-id="' + id + '" unique-id="' + uniqueid + '" data-medias="' + media_ids + ' " unixtime="' + date(obj[key].created_at, "unix") + '" ' + if_notf + ' onclick="dmStatus()">' + '<div class="area-notice"><span class="gray sharesta">' + notice + home + "</span></div>" + '<div class="area-icon"><a onclick="udg(\'' + toot.account.id + "'," + acct_id + ');" user="' + toot.account.acct + '" class="udg">' + '<img src="' + avatar + '" width="40" class="prof-img" user="' + toot.account.acct + '"></a>' + noticeavatar + "</div>" + '<div class="area-display_name"><div class="flex-name"><span class="user">' + dis_name + '</span><span class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis; cursor:text;"> @' + toot.account.acct + locked + "</span></div>" + '<div class="flex-time"><span class="cbadge cbadge-hover pointer waves-effect" onclick="tootUriCopy(\'' + toot.url + '\');" title="' + date(toot.created_at, "absolute") + "(" + lang.lang_parse_clickcopyurl + ')"><i class="far fa-clock-o"></i>' + date(toot.created_at, datetype) + "</span>" + "</div></div>" + '<div class="area-toot">' + tickerdom + '<span class="' + api_spoil + " cw_text_" + toot.id + '"><span class="cw_text">' + spoil + "</span>" + spoiler_show + '</span><span class="toot ' + spoiler + '">' + content + "</span>" + "" + viewer + "" + "<br><a onclick=\"details('" + toot.id + "'," + acct_id + ",'" + tlid + "','dm')\" class=\"pointer waves-effect\">" + lang.lang_parse_thread + "</a></div>" + '<div class="area-vis"></div>' + "</div></div>";
|
||||
});
|
||||
return templete;
|
||||
}
|
||||
|
|
|
@ -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) + '<span class="sml">(for ' + context + ')</span>:<a onclick="filterEdit(\'' + filterword.id + '\',\'' + acct_id +
|
||||
'\')" class="pointer">' + lang.lang_edit + '</a>/<a onclick="filterDel(' + filterword.id + ',' + acct_id +
|
||||
')" class="pointer">' + lang.lang_del + '</a><br> ';
|
||||
});
|
||||
if (filters == "") {
|
||||
filters = lang.lang_filter_nodata + "<br>";
|
||||
})
|
||||
.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) + '<span class="sml">(for ' + context + ")</span>:<a onclick=\"filterEdit('" + filterword.id + "','" + acct_id + '\')" class="pointer">' + lang.lang_edit + '</a>/<a onclick="filterDel(' + filterword.id + "," + acct_id + ')" class="pointer">' + lang.lang_del + "</a><br> ";
|
||||
});
|
||||
if (filters == "") {
|
||||
filters = lang.lang_filter_nodata + "<br>";
|
||||
}
|
||||
$("#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);
|
||||
}
|
|
@ -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) + ":<a onclick=\"listShow('" + list.id + "','" + escapeHTML(list.title) + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_show + "</a><br>";
|
||||
});
|
||||
$("#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) + ':<a onclick="listShow(\'' + list.id + '\',\'' + escapeHTML(list.title) + '\',\'' + acct_id +
|
||||
'\')" class="pointer">' + lang.lang_list_show + '</a><br>';
|
||||
});
|
||||
$("#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) + ':<a onclick="listShow(\'' + list.id + '\',\'' + escapeHTML(list.title) + '\',\'' + acct_id +
|
||||
'\')" class="pointer">' + lang.lang_list_show + '</a>/<a onclick="listUser(\'' + list.id + '\',' + acct_id +
|
||||
')" class="pointer">' + lang.lang_list_users + '</a><br>';
|
||||
});
|
||||
$("#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) + ":<a onclick=\"listShow('" + list.id + "','" + escapeHTML(list.title) + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_show + "</a>/<a onclick=\"listUser('" + list.id + "'," + acct_id + ')" class="pointer">' + lang.lang_list_users + "</a><br>";
|
||||
});
|
||||
$("#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 + "<br>";
|
||||
Object.keys(json).forEach(function (key) {
|
||||
var list = json[key];
|
||||
lists = lists + '<a onclick="listAdd(\'' + list.id + '\',\'' + user + '\',\'' + acct_id +
|
||||
'\')" class="pointer">' + escapeHTML(list.title) + '</a><br> ';
|
||||
});
|
||||
$("#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 + "<br>";
|
||||
Object.keys(json).forEach(function(key) {
|
||||
var list = json[key];
|
||||
lists = lists + "<a onclick=\"listAdd('" + list.id + "','" + user + "','" + acct_id + '\')" class="pointer">' + escapeHTML(list.title) + "</a><br> ";
|
||||
});
|
||||
$("#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 + "<br>";
|
||||
Object.keys(json).forEach(function (key) {
|
||||
var list = json[key];
|
||||
lists = lists + '<a onclick="listRemove(\'' + list.id + '\',\'' + user + '\',\'' + acct_id +
|
||||
'\')" class="pointer">' + escapeHTML(list.title) + '</a><br> ';
|
||||
});
|
||||
$("#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 + "<br>";
|
||||
Object.keys(json).forEach(function(key) {
|
||||
var list = json[key];
|
||||
lists = lists + "<a onclick=\"listRemove('" + list.id + "','" + user + "','" + acct_id + '\')" class="pointer">' + escapeHTML(list.title) + "</a><br> ";
|
||||
});
|
||||
$("#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 + ":<a onclick=\"listShow('" + list.id + "','" + escapeHTML(list.title) + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_show + "</a>/<a onclick=\"listAdd('" + list.id + "','" + user + "','" + acct_id + '\')" class="pointer">' + lang.lang_list_add + lang.lang_list_add_misskey + "</a><br>";
|
||||
});
|
||||
$("#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 + ':<a onclick="listShow(\'' + list.id + '\',\'' + escapeHTML(list.title) + '\',\'' + acct_id +
|
||||
'\')" class="pointer">' + lang.lang_list_show + '</a>/<a onclick="listAdd(\'' + list.id + '\',\'' + user + '\',\'' + acct_id +
|
||||
'\')" class="pointer">' + lang.lang_list_add + lang.lang_list_add_misskey + '</a><br>';
|
||||
});
|
||||
$("#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);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
354
app/js/tl/mix.js
354
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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 + '<div class="hide notif-marker" data-maxid="' + max_id + '"></div>';
|
||||
|
@ -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()
|
||||
allNotfRead();
|
||||
|
|
|
@ -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)+'<div class="divider"></div>');
|
||||
//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) + '<div class="divider"></div>');
|
||||
//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();
|
||||
});
|
||||
});
|
||||
|
||||
}
|
352
app/js/tl/src.js
352
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 + '<a onclick="tl(\'tag\',\'' + tag + '\',\'' + acct_id +
|
||||
'\',\'add\')" class="pointer">#' + escapeHTML(tag) + '</a><br> ';
|
||||
} else {
|
||||
tags = tags + graphDraw(tag, acct_id);
|
||||
}
|
||||
|
||||
});
|
||||
$("#src-contents").append("Tags<br>" + tags);
|
||||
}
|
||||
//トゥート
|
||||
if (json.statuses[0]) {
|
||||
var templete = parse(json.statuses, '', acct_id);
|
||||
$("#src-contents").append("<br>Mentions<br>" + templete);
|
||||
}
|
||||
//アカウント
|
||||
if (json.accounts[0]) {
|
||||
var templete = userparse(json.accounts, '', acct_id);
|
||||
if (!offset) {
|
||||
$("#src-contents").append("<br>Accounts<div id=\"src-accts\">" + templete + '</div><a onclick="src(false,\'more\')" class="pointer">more...</a>');
|
||||
} 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 + "<a onclick=\"tl('tag','" + tag + "','" + acct_id + "','add')\" class=\"pointer\">#" + escapeHTML(tag) + "</a><br> ";
|
||||
} else {
|
||||
tags = tags + graphDraw(tag, acct_id);
|
||||
}
|
||||
});
|
||||
$("#src-contents").append("Tags<br>" + tags);
|
||||
}
|
||||
//トゥート
|
||||
if (json.statuses[0]) {
|
||||
var templete = parse(json.statuses, "", acct_id);
|
||||
$("#src-contents").append("<br>Mentions<br>" + templete);
|
||||
}
|
||||
//アカウント
|
||||
if (json.accounts[0]) {
|
||||
var templete = userparse(json.accounts, "", acct_id);
|
||||
if (!offset) {
|
||||
$("#src-contents").append('<br>Accounts<div id="src-accts">' + templete + '</div><a onclick="src(false,\'more\')" class="pointer">more...</a>');
|
||||
} 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 + '<div class="hide ts-marker" data-maxid="' + max_id + '"></div>';
|
||||
}
|
||||
$("#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 + '<div class="hide ts-marker" data-maxid="' + max_id + '"></div>';
|
||||
}
|
||||
$("#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 + '<div class="hide ts-marker" data-maxid="' + max_id + '"></div>';
|
||||
}
|
||||
$("#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 + '<div class="hide ts-marker" data-maxid="' + max_id + '"></div>';
|
||||
}
|
||||
$("#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 = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' +
|
||||
'</svg><span style="font-size:200%">' + his[0].uses + '</span>toot(s) <a onclick="tl(\'tag\',\'' + escapeHTML(tag.name) + '\',\'' + acct_id +
|
||||
'\',\'add\')" class="pointer">#' + escapeHTML(tag.name) + '</a> ' + his[0].accounts + lang.lang_src_people;
|
||||
tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + '</svg><span style="font-size:200%">' + his[0].uses + "</span>toot(s) <a onclick=\"tl('tag','" + escapeHTML(tag.name) + "','" + acct_id + "','add')\" class=\"pointer\">#" + escapeHTML(tag.name) + "</a> " + his[0].accounts + lang.lang_src_people;
|
||||
} else {
|
||||
tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' +
|
||||
'<g><path d="M0,' + six + ' L10,' + five + ' 20,' + four + ' 30,' + three + ' 40,' + two + ' 50,' + one + ' 60,' + zero + '" style="stroke: #9e9e9e; stroke-width: 1;fill: none;"></path></g>' +
|
||||
'</svg><span style="font-size:200%">' + his[0].uses + '</span>toot <a onclick="tl(\'tag\',\'' + escapeHTML(tag.name) + '\',\'' + acct_id +
|
||||
'\',\'add\')" class="pointer">#' + escapeHTML(tag.name) + '</a> ' + his[0].accounts + lang.lang_src_people;
|
||||
tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + '<g><path d="M0,' + six + " L10," + five + " 20," + four + " 30," + three + " 40," + two + " 50," + one + " 60," + zero + '" style="stroke: #9e9e9e; stroke-width: 1;fill: none;"></path></g>' + '</svg><span style="font-size:200%">' + his[0].uses + "</span>toot <a onclick=\"tl('tag','" + escapeHTML(tag.name) + "','" + acct_id + "','add')\" class=\"pointer\">#" + escapeHTML(tag.name) + "</a> " + his[0].accounts + lang.lang_src_people;
|
||||
}
|
||||
|
||||
return tags;
|
||||
|
@ -221,7 +228,7 @@ function graphDraw(tag, acct_id) {
|
|||
</svg>
|
||||
*/
|
||||
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 = '<svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' +
|
||||
'<g><path d="M-1,51, -1,' + six + ', 0,' + six + ' L10,' + five + ' 20,' + four + ' 30,' + three + ' 40,' + two + ' 50,' + one + ' 60,' + zero + ' 61,' + zero + ' 61,51 -1,51" style="stroke: #0f8c0c;fill: rgba(13,113,19,.25); stroke-width: 1;"></path></g>' +
|
||||
'</svg><span style="font-size:200%">' + his[0].uses + '</span>toots <a onclick="tl(\'tag\',\'' + tag.name + '\',\'' + acct_id +
|
||||
'\',\'add\')" class="pointer">#' + tag.name + '</a> ' + his[0].accounts + lang.lang_src_people + "<br><br>";
|
||||
})
|
||||
.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 = '<svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + '<g><path d="M-1,51, -1,' + six + ", 0," + six + " L10," + five + " 20," + four + " 30," + three + " 40," + two + " 50," + one + " 60," + zero + " 61," + zero + ' 61,51 -1,51" style="stroke: #0f8c0c;fill: rgba(13,113,19,.25); stroke-width: 1;"></path></g>' + '</svg><span style="font-size:200%">' + his[0].uses + "</span>toots <a onclick=\"tl('tag','" + tag.name + "','" + acct_id + "','add')\" class=\"pointer\">#" + tag.name + "</a> " + his[0].accounts + lang.lang_src_people + "<br><br>";
|
||||
|
||||
$("#src-contents").append(tags);
|
||||
$("#src-contents").append(tags);
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
}
|
273
app/js/tl/tag.js
273
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 + '<a onclick="tagShow(\'' + tag + '\')" class="pointer">#' + tag + '</a>' + nowon + '<span class="hide" data-tag="' + tag + '"> <a onclick="tagTL(\'tag\',\'' + tag + '\',false,\'add\')" class="pointer" title="' + lang.lang_parse_tagTL.replace("{{tag}}", '#' + tag) + '">TL</a> <a onclick="brInsert(\'#' + tag + '\')" class="pointer" title="' + lang.lang_parse_tagtoot.replace("{{tag}}", '#' + tag) + '">Toot</a> ' +
|
||||
'<a onclick="autoToot(\'' + tag + '\');" class="pointer" title="' + lang.lang_tags_always + lang.lang_parse_tagtoot.replace("{{tag}}", '#' + tag) + '">' + ptt + '</a> <a onclick="tagRemove(\'' + key + '\')" class="pointer" title="' + lang.lang_tags_tagunpin.replace("{{tag}}", '#' + tag) + '">' + lang.lang_del + '</a></span> ';
|
||||
});
|
||||
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 + "<a onclick=\"tagShow('" + tag + '\')" class="pointer">#' + tag + "</a>" + nowon + '<span class="hide" data-tag="' + tag + "\"> <a onclick=\"tagTL('tag','" + tag + '\',false,\'add\')" class="pointer" title="' + lang.lang_parse_tagTL.replace("{{tag}}", "#" + tag) + '">TL</a> <a onclick="brInsert(\'#' + tag + '\')" class="pointer" title="' + lang.lang_parse_tagtoot.replace("{{tag}}", "#" + tag) + '">Toot</a> ' + "<a onclick=\"autoToot('" + tag + '\');" class="pointer" title="' + lang.lang_tags_always + lang.lang_parse_tagtoot.replace("{{tag}}", "#" + tag) + '">' + ptt + "</a> <a onclick=\"tagRemove('" + key + '\')" class="pointer" title="' + lang.lang_tags_tagunpin.replace("{{tag}}", "#" + tag) + '">' + lang.lang_del + "</a></span> ";
|
||||
});
|
||||
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 + '<a onclick="tagShow(\'' + tag + '\')" class="pointer">#' + tag + '</a><span class="hide" data-tag="' + tag + '"> <a onclick="tagTL(\'tag\',\'' + tag + '\',false,\'add\')" class="pointer" title="#' + tag + 'のタイムライン">TL</a> <a onclick="show();brInsert(\'#' + tag + '\')" class="pointer" title="#' + tag + 'でトゥート">Toot</a></span> ';
|
||||
});
|
||||
$("#taglist").append('<div class="trendtag">アイマストドントレンドタグ<i class="material-icons pointer" onclick="trendTag()" style="font-size:12px">refresh</i>:' + tags + '</div>');
|
||||
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 + "<a onclick=\"tagShow('" + tag + '\')" class="pointer">#' + tag + '</a><span class="hide" data-tag="' + tag + "\"> <a onclick=\"tagTL('tag','" + tag + '\',false,\'add\')" class="pointer" title="#' + tag + 'のタイムライン">TL</a> <a onclick="show();brInsert(\'#' + tag + '\')" class="pointer" title="#' + tag + 'でトゥート">Toot</a></span> ';
|
||||
});
|
||||
$("#taglist").append('<div class="trendtag">アイマストドントレンドタグ<i class="material-icons pointer" onclick="trendTag()" style="font-size:12px">refresh</i>:' + tags + "</div>");
|
||||
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 })
|
||||
});
|
||||
"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 });
|
||||
});
|
||||
}
|
788
app/js/tl/tl.js
788
app/js/tl/tl.js
File diff suppressed because it is too large
Load Diff
|
@ -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 = '<div class="acct" id="acct_' + key + '">' + list +
|
||||
'.' +
|
||||
escapeHTML(cli) + '<button class="btn waves-effect red disTar" onclick="cliMuteDel(' +
|
||||
key + ')">' + lang.lang_del + '</button><br></div>';
|
||||
templete = '<div class="acct" id="acct_' + key + '">' + list + "." + escapeHTML(cli) + '<button class="btn waves-effect red disTar" onclick="cliMuteDel(' + key + ')">' + lang.lang_del + "</button><br></div>";
|
||||
$("#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,92 +461,112 @@ 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('<div class="font pointer" style="font-family:' + font.family + '" onclick="insertFont(\'' + font.family + '\')">' + font.family + "</div>")
|
||||
$("#fonts").append('<div class="font pointer" style="font-family:' + font.family + '" onclick="insertFont(\'' + font.family + "')\">" + font.family + "</div>");
|
||||
}
|
||||
}
|
||||
function insertFont(name) {
|
||||
$("#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)" }
|
||||
if (!primaryC) {
|
||||
primaryC = "rgb(255,255,255)";
|
||||
}
|
||||
var secondaryC = $("#color-picker1_value").val();
|
||||
if (!secondaryC) { secondaryC = "rgb(255,255,255)" }
|
||||
if (!secondaryC) {
|
||||
secondaryC = "rgb(255,255,255)";
|
||||
}
|
||||
var textC = $("#color-picker2_value").val();
|
||||
if (!textC) { textC = "rgb(255,255,255)" }
|
||||
if (!textC) {
|
||||
textC = "rgb(255,255,255)";
|
||||
}
|
||||
var multi = localStorage.getItem("multi");
|
||||
if($("#pickers").hasClass("advanceTheme")){
|
||||
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
|
||||
if (!accentC) {
|
||||
accentC = null;
|
||||
}
|
||||
}else{
|
||||
var advanceTheme = {}
|
||||
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;
|
||||
|
@ -552,20 +574,20 @@ function customComp() {
|
|||
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('<div class="color-picker" id="color-picker' + i + '"></div>')
|
||||
for (var i = 0; i <= 8; i++) {
|
||||
$("#color-picker" + i + "-wrap").html('<div class="color-picker" id="color-picker' + i + '"></div>');
|
||||
$("#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('<div class="color-picker" id="color-picker' + i + '"></div>')
|
||||
for (var i = 0; i <= 8; i++) {
|
||||
$("#color-picker" + i + "-wrap").html('<div class="color-picker" id="color-picker' + i + '"></div>');
|
||||
$("#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 + '<option value="' + themeid + '">' + theme.name + '</option>';
|
||||
var themeid = theme.id;
|
||||
templete = templete + '<option value="' + themeid + '">' + theme.name + "</option>";
|
||||
});
|
||||
if (args[0]) {
|
||||
localStorage.setItem("customtheme-id", args[0].id)
|
||||
localStorage.setItem("customtheme-id", args[0].id);
|
||||
}
|
||||
$("#custom-sel-sel").html(templete);
|
||||
templete = '<option value="add_new">' + $("#edit-selector").attr("data-add") + '</option>' + templete;
|
||||
templete = '<option value="add_new">' + $("#edit-selector").attr("data-add") + "</option>" + templete;
|
||||
$("#custom-edit-sel").html(templete);
|
||||
$('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('<div class="color-picker" id="color-picker' + i + '"></div>')
|
||||
for (var i = 0; i <= 8; i++) {
|
||||
$("#color-picker" + i + "-wrap").html('<div class="color-picker" id="color-picker' + i + '"></div>');
|
||||
$("#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('<div class="color-picker" id="color-picker0"></div>')
|
||||
pickerDefine(0, rgbToHex(args.vars.primary))
|
||||
$("#color-picker0-wrap").html('<div class="color-picker" id="color-picker0"></div>');
|
||||
pickerDefine(0, rgbToHex(args.vars.primary));
|
||||
$("#color-picker0_value").val(args.vars.primary);
|
||||
//Secondary
|
||||
$("#color-picker1-wrap").html('<div class="color-picker" id="color-picker1"></div>')
|
||||
pickerDefine(1, rgbToHex(args.vars.secondary))
|
||||
$("#color-picker1-wrap").html('<div class="color-picker" id="color-picker1"></div>');
|
||||
pickerDefine(1, rgbToHex(args.vars.secondary));
|
||||
$("#color-picker1_value").val(args.vars.secondary);
|
||||
//Text
|
||||
$("#color-picker2-wrap").html('<div class="color-picker" id="color-picker2"></div>')
|
||||
$("#color-picker2-wrap").html('<div class="color-picker" id="color-picker2"></div>');
|
||||
$("#color-picker2_value").val(args.vars.text);
|
||||
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('<div class="color-picker" id="color-picker'+i+'"></div>')
|
||||
$("#color-picker"+i+"_value").val(color);
|
||||
pickerDefine(i, rgbToHex(color))
|
||||
$("#color-picker" + i + "-wrap").html('<div class="color-picker" id="color-picker' + i + '"></div>');
|
||||
$("#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";
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
|
@ -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 {
|
||||
|
||||
}
|
||||
|
||||
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 {
|
||||
}
|
||||
}
|
|
@ -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('<img src="../../img/desk.png" width="20" onclick="todo(\'TheDesk is a nice client!: TheDesk ' + localStorage.getItem("ver") + ' git: '+ gitHash +'\')">TheDesk ' + localStorage.getItem("ver") + ' {'+ gitHash.slice(0, 7) +'} [<i class="material-icons" style="font-size:1.2rem;top: 3px;position: relative;">supervisor_account</i><span id="persons">1+</span>]')
|
||||
localStorage.setItem("tips", "ver")
|
||||
tipsToggle();
|
||||
$("#tips-text").html('<img src="../../img/desk.png" width="20" onclick="todo(\'TheDesk is a nice client!: TheDesk ' + localStorage.getItem("ver") + " git: " + gitHash + "')\">TheDesk " + localStorage.getItem("ver") + " {" + gitHash.slice(0, 7) + '} [<i class="material-icons" style="font-size:1.2rem;top: 3px;position: relative;">supervisor_account</i><span id="persons">1+</span>]');
|
||||
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) + "<br>Memory:" + Math.floor(use / 1024 / 1024 / 102.4) / 10 + "/" + Math.floor(total / 1024 / 1024 / 102.4) / 10 + "GB(" + Math.floor(use / total * 100) + "%)")
|
||||
function renderMem(use, cpu, total) {
|
||||
$("#tips-text").html(escapeHTML(cpu) + "<br>Memory:" + Math.floor(use / 1024 / 1024 / 102.4) / 10 + "/" + Math.floor(total / 1024 / 1024 / 102.4) / 10 + "GB(" + Math.floor((use / total) * 100) + "%)");
|
||||
}
|
||||
//トレンドタグ
|
||||
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 + '<a onclick="tagShow(\'' + tag + '\')" class="pointer">#' + escapeHTML(tag) + '</a><span class="hide" data-tag="' + tag + '"> <a onclick="tagTL(\'tag\',\'' + tag + '\',false,\'add\')" class="pointer" title="#' + tag + 'のタイムライン">TL</a> <a onclick="show();brInsert(\'#' + tag + '\')" class="pointer" title="#' + tag + 'でトゥート">Toot</a></span><br>';
|
||||
});
|
||||
$("#tips-text").html('<div class="trendtag">トレンドタグ<i class="material-icons pointer" onclick="trendTagonTip()" style="font-size:12px">refresh</i>:<br>' + tags + '</div>');
|
||||
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 + "<a onclick=\"tagShow('" + tag + '\')" class="pointer">#' + escapeHTML(tag) + '</a><span class="hide" data-tag="' + tag + "\"> <a onclick=\"tagTL('tag','" + tag + '\',false,\'add\')" class="pointer" title="#' + tag + 'のタイムライン">TL</a> <a onclick="show();brInsert(\'#' + tag + '\')" class="pointer" title="#' + tag + 'でトゥート">Toot</a></span><br>';
|
||||
});
|
||||
$("#tips-text").html('<div class="trendtag">トレンドタグ<i class="material-icons pointer" onclick="trendTagonTip()" style="font-size:12px">refresh</i>:<br>' + tags + "</div>");
|
||||
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('<div id="spot-box"><i class="material-icons pointer" onclick="spotifytips()" style="font-size:12px">refresh</i><img src="' + img + '" width="20" id="spot-img">' + escapeHTML(item.name) + '<span class="gray sml" id="spot-art">' + artisttxt + '</span><span id="spot-m">' + m + '</span>:<span id="spot-s">' + s + '</span>/' + tm + ":" + ts + '</span></div><div class="progress grey"><div class="determinate spotify-prog grey lighten-2" style="width: ' + per + '%" data-s="' + Math.round(ms) + '" data-total="' + item.duration_ms + '"></div></div>');
|
||||
spotint = setInterval(spotStart, 1000);
|
||||
});
|
||||
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('<div id="spot-box"><i class="material-icons pointer" onclick="spotifytips()" style="font-size:12px">refresh</i><img src="' + img + '" width="20" id="spot-img">' + escapeHTML(item.name) + '<span class="gray sml" id="spot-art">' + artisttxt + '</span><span id="spot-m">' + m + '</span>:<span id="spot-s">' + s + "</span>/" + tm + ":" + ts + '</span></div><div class="progress grey"><div class="determinate spotify-prog grey lighten-2" style="width: ' + per + '%" data-s="' + Math.round(ms) + '" data-total="' + item.duration_ms + '"></div></div>');
|
||||
spotint = setInterval(spotStart, 1000);
|
||||
});
|
||||
} 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() + '<span style="font-size:20px; font-family:Open Sans">' + nowHour + ":" + nowMin + ":" + nowSec + "</span>";
|
||||
$("#tips-text").html(msg);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user