Add: JSON parse miss error-log

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

View File

@ -92,7 +92,8 @@ function verck(ver, jp) {
return response.json();
})
.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) {

View File

@ -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',
httpreq.send(
JSON.stringify({
scopes: "read write follow",
client_name: "TheDesk(PC)",
redirect_uris: red,
website: "https://thedesk.top"
}));
httpreq.onreadystatechange = function () {
})
);
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,17 +129,21 @@ function code(code, mode) {
client_secret: secret,
code: code
})
}).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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
todo(json);
if (json["access_token"]) {
localStorage.setItem(url + "_at", json["access_token"]);
@ -148,7 +152,6 @@ function code(code, mode) {
} else {
getdata();
}
}
});
}
@ -160,25 +163,29 @@ 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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json.error) {
console.error("Error:" + json.error);
M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 })
M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 });
return;
}
var avatar = json["avatar"];
@ -186,7 +193,8 @@ function getdata() {
if (avatar == "/avatars/original/missing.png") {
avatar = "./img/missing.svg";
}
var obj = [{
var obj = [
{
at: at,
name: json["display_name"],
domain: domain,
@ -194,7 +202,8 @@ function getdata() {
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"]);
@ -204,7 +213,7 @@ function getdata() {
$("#masara").hide();
$("#auth").hide();
$("#tl").show();
parseColumn()
parseColumn();
ckdb();
});
}
@ -212,25 +221,29 @@ function getdata() {
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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json.error) {
console.error("Error:" + json.error);
M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 })
M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 });
return;
}
var avatar = json["avatar"];
@ -270,30 +283,33 @@ 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) {
"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);
});
}
return response.json();
}).catch(function (error) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json.error) {
console.error("Error:" + json.error);
M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 })
M.toast({ html: lang.lang_fatalerroroccured + "Error:" + json.error, displayLength: 5000 });
return;
}
var avatar = json["avatar"];
@ -315,9 +331,9 @@ function refresh(target, loadskip) {
localStorage.setItem("user-id_" + target, json["id"]);
localStorage.setItem("prof_" + target, avatar);
localStorage.setItem("follow_" + target, json["following_count"]);
if(json["source"]["sensitive"]){
if (json["source"]["sensitive"]) {
localStorage.setItem("nsfw_" + target, "true");
}else{
} else {
localStorage.removeItem("nsfw_" + target);
}
obj[target] = ref;
@ -408,15 +424,18 @@ 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) {
"content-type": "application/json"
}
})
.then(function(response) {
return response.json();
}).catch(function (error) {
})
.catch(function(error) {
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json.error) {
console.error(json.error);
return;
@ -427,16 +446,13 @@ function ckdb(acct_id) {
}
if (json["urls"]["streaming_api"]) {
localStorage.setItem("streaming_" + acct_id, json["urls"]["streaming_api"]);
}else{
} 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,21 +559,23 @@ 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) {
"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) {
})
.catch(function(error) {
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json) {
localStorage.setItem("ticker", JSON.stringify(json));
}

View File

@ -94,6 +94,7 @@ function data(domain) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
@ -128,6 +129,7 @@ function data(domain) {
})
.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);
@ -365,6 +369,7 @@ function versionChecker(url) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
@ -403,6 +408,7 @@ function versionCompat(prefix, ver, title, real) {
})
.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();
@ -617,6 +631,7 @@ function getdata(domain, at) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {
@ -742,6 +757,7 @@ function refresh(target) {
})
.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 = {
@ -929,6 +947,7 @@ input.addEventListener(
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
})
.then(function(json) {

View File

@ -6,168 +6,173 @@ $("#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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (parse == "true") {
$('#emoji-list').text('Parsing...');
$("#emoji-list").text("Parsing...");
var md = {
"categorized": {},
"uncategorized": []
categorized: {},
uncategorized: []
};
var if_categorized = false
Object.keys(json).forEach(function (key) {
var if_categorized = false;
Object.keys(json).forEach(function(key) {
var emoji = json[key];
if (emoji.visible_in_picker) {
var listed = true
var listed = true;
} else {
var listed = false
var listed = false;
}
if (emoji.category) {
var cat = emoji.category
var cat = emoji.category;
if (!md["categorized"][cat]) {
md["categorized"][cat] = []
md["categorized"][cat] = [];
}
md["categorized"][cat].push({
"shortcode": emoji.shortcode,
"url": emoji.url,
"listed": listed
})
if_categorized = true
shortcode: emoji.shortcode,
url: emoji.url,
listed: listed
});
if_categorized = true;
} else {
md["uncategorized"].push({
"shortcode": emoji.shortcode,
"url": emoji.url,
"listed": listed
})
shortcode: emoji.shortcode,
url: emoji.url,
listed: listed
});
}
});
console.log(md)
console.log(md);
//絵文字をマストドン公式と同順にソート
md["uncategorized"].sort(function (a, b) {
md["uncategorized"].sort(function(a, b) {
if (a.shortcode < b.shortcode) return -1;
if (a.shortcode > b.shortcode) return 1;
return 0;
});
Object.keys(md["categorized"]).forEach(function (key) {
md["categorized"][key].sort(function (a, b) {
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
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')
emojiList("home");
}
});
} else {
var start = "https://" + domain + "/api/meta";
fetch(start, {
method: 'POST',
method: "POST",
headers: {
'content-type': 'application/json'
},
}).then(function (response) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.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 md = { uncategorized: [] };
Object.keys(emojis).forEach(function(key) {
var emoji = emojis[key];
md["uncategorized"].push({
"shortcode": emoji.name,
"url": emoji.url,
"listed": true
})
shortcode: emoji.name,
url: emoji.url,
listed: true
});
md["if_categorized"] = false
});
md["if_categorized"] = false;
if (parse == "true") {
$('#emoji-list').text('Parsing...');
$("#emoji-list").text("Parsing...");
//絵文字をマストドン公式と同順にソート
md["uncategorized"].sort(function (a, b) {
md["uncategorized"].sort(function(a, b) {
if (a.shortcode < b.shortcode) return -1;
if (a.shortcode > b.shortcode) return 1;
return 0;
@ -178,7 +183,7 @@ function emojiGet(parse, started) {
}
localStorage.setItem("emojiseek", 0);
if (!started) {
emojiList('home')
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();
}

View File

@ -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("");
@ -277,10 +279,11 @@ function altImage(acct_id, id) {
})
.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"
});
}
});

View File

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

View File

@ -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'
},
"content-type": "application/json"
}
//body: JSON.stringify({})
}).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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.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 + "] .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,88 +141,89 @@ 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'
},
"content-type": "application/json"
}
//body: JSON.stringify({})
}).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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.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 + "] .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) {
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.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">';
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 = '';
var twiImg = "";
}
$("[toot-id=" + id + "] .additional").html(
'<div class="twitter-tweet"><b>' + escapeHTML(json.author_name) + '</b><br>' + escapeHTML(json.description) + twiImg + '</div>');
$("[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">';
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 = '';
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>');
$("[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 + "] .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>');
}
}
if (json.title) {
@ -224,7 +232,6 @@ function additionalIndv(tlid, acct_id, id) {
}
});
}
}
}
@ -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");
}
}

View File

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

View File

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

View File

@ -1,28 +1,31 @@
//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) {
"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) {
})
.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)
})
.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();
@ -30,7 +33,6 @@ function dm(acct_id, tlid, type, delc, voice) {
//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) {
"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) {
})
.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>';
})
.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;
}

View File

@ -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,36 +108,38 @@ 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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json) {
var filters = "";
Object.keys(json).forEach(function (key) {
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> ';
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>";
@ -150,9 +151,9 @@ function filter() {
});
}
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({
httpreq.send(
JSON.stringify({
phrase: phr,
context: cont,
irreversible: exc,
whole_word: who,
expires_in: time
}));
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);
$("#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,30 +242,34 @@ 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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.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) {
Object.keys(json.context).forEach(function(key) {
var context = json.context[key];
$("[value=" + context + "]").prop("checked", true);
});
@ -270,7 +279,7 @@ function filterEdit(id, acct_id) {
if (json.whole_word) {
$("#wholeword_filter").prop("checked", true);
}
var expires = date(json.expires_at, 'unix') - now;
var expires = date(json.expires_at, "unix") - now;
var mins = Math.floor(expires / 60) % 60;
var hours = Math.floor(expires / 3600) % 24;
var days = Math.floor(expires / 3600 / 24);
@ -286,41 +295,47 @@ function filterDel(id, acct_id) {
var start = "https://" + domain + "/api/v1/filters/" + id;
var 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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
localStorage.setItem("filter_" + acct_id, JSON.stringify(json));
});
} else {
@ -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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.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);
}

View File

@ -3,40 +3,42 @@ 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) {
})
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json) {
var lists = "";
Object.keys(json).forEach(function (key) {
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 = 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 {
@ -44,31 +46,33 @@ function list() {
}
});
} 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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json) {
var lists = "";
Object.keys(json).forEach(function (key) {
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 = 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 {
@ -83,71 +87,83 @@ 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({
httpreq.send(
JSON.stringify({
title: text
}));
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);
}
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({
httpreq.send(
JSON.stringify({
i: at,
title: text
}));
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);
}
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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json) {
var lists = "";
var templete = userparse(json, '', acct_id);
var templete = userparse(json, "", acct_id);
if (!json[0]) {
templete = lang.lang_list_nouser;
}
@ -162,60 +178,66 @@ 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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json) {
var lists = lang.lang_list_add + "<br>";
Object.keys(json).forEach(function (key) {
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> ';
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"
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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json) {
var lists = lang.lang_list_remove + "<br>";
Object.keys(json).forEach(function (key) {
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> ';
lists = lists + "<a onclick=\"listRemove('" + list.id + "','" + user + "','" + acct_id + '\')" class="pointer">' + escapeHTML(list.title) + "</a><br> ";
});
$("#his-lists-b").html(lists);
} else {
@ -223,30 +245,32 @@ function hisList(user, acct_id) {
}
});
} 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) {
})
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json) {
var lists = "";
Object.keys(json).forEach(function (key) {
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>';
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 {
@ -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);
}
};
}

View File

@ -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,43 +8,51 @@ 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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (jsonL) {
})
.then(function(jsonL) {
var start = "https://" + domain + "/api/v1/timelines/home";
fetch(start, {
method: 'GET',
method: "GET",
headers: {
'content-type': 'application/json',
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (jsonH) {
})
.then(function(jsonH) {
var homearr = [];
var timeline = jsonL.concat(jsonH);
timeline.sort(function (a, b) {
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;
@ -58,20 +66,19 @@ function mixtl(acct_id, tlid, type, delc, voice) {
} else {
var mute = [];
}
Object.keys(timeline).forEach(function (key) {
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");
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");
templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "plus");
}
}
}
}
});
$("#landing_" + tlid).hide();
$("#timeline_" + tlid).html(templete);
@ -83,35 +90,32 @@ function mixtl(acct_id, tlid, type, delc, voice) {
});
}
//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,55 +266,64 @@ 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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (jsonL) {
})
.then(function(jsonL) {
var start = "https://" + domain + "/api/v1/timelines/home?max_id=" + sid;
fetch(start, {
method: 'GET',
method: "GET",
headers: {
'content-type': 'application/json',
'Authorization': 'Bearer ' + at
},
}).then(function (response) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (jsonH) {
})
.then(function(jsonH) {
var homearr = [];
var timeline = jsonL.concat(jsonH);
timeline.sort(function (a, b) {
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) {
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")) {
@ -324,15 +333,14 @@ function mixmore(tlid, type) {
var mute = [];
}
if (type == "integrated") {
templete = templete + parse([timeline[key]], '', acct_id, tlid, "", mute, "mix");
templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "mix");
} else if (type == "plus") {
if (timeline[key].account.acct == timeline[key].account.username) {
templete = templete + parse([timeline[key]], '', acct_id, tlid, "", mute, "mix");
templete = templete + parse([timeline[key]], "", acct_id, tlid, "", mute, "mix");
}
}
}
}
});
$("#timeline_" + tlid).append(templete);
@ -342,6 +350,4 @@ function mixmore(tlid, type) {
todc();
});
});
}

View File

@ -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,42 +129,46 @@ 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'));
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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.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) {
Object.keys(json).forEach(function(key) {
var obj = json[key];
if (lastnotf == obj.id && key > 0 && native == "yes") {
var ct = key;
@ -179,8 +180,7 @@ function notfCommon(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");
@ -189,17 +189,16 @@ function notfCommon(acct_id, tlid, sys) {
}
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);
}
}
});
$("div[data-notf=" + acct_id + "]").html(templete);
@ -208,28 +207,25 @@ function notfCommon(acct_id, tlid, sys) {
}
$("#notf-box").addClass("fetched");
todc();
notfWS(misskey, acct_id, tlid, domain, at)
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();

View File

@ -1,32 +1,36 @@
//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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function(json) {
})
.then(function(json) {
//パースして描画
var templete = parse(json, 'mix', acct_id, tlid);
var templete = parse(json, "mix", acct_id, tlid);
$("#timeline_" + tlid).html(templete[0]);
jQuery("time.timeago").timeago();
@ -37,33 +41,38 @@ function mixtl(acct_id, tlid) {
//Home
var start = "https://" + domain + "/api/v1/timelines/home";
fetch(start, {
method: 'GET',
method: "GET",
headers: {
'content-type': 'application/json',
'Authorization': 'Bearer ' + at
},
}).then(function(response) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function(obj) {
})
.then(function(obj) {
//ホームのオブジェクトをUnix時間で走査
if (!$("[toot-id=" + obj[0].id + "]").length) {
$("#timeline_" + tlid + " .cvo").first().before(parse([obj[0]], 'home',
acct_id));
$("#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");
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){
if (unixH < unixL) {
Object.keys(obj).forEach(function(key) {
var skey = obj.length - key - 1;
var toot = obj[key];
@ -71,7 +80,7 @@ function mixtl(acct_id, tlid) {
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 tarunix = date(toot.created_at, "unix");
var beforekey2;
var key2;
//console.log(locals)
@ -80,19 +89,16 @@ function mixtl(acct_id, tlid) {
if (times[key2] < tarunix) {
var local = json[key2].id;
//console.log($.strip_tags(toot.content));
html = parse(
[toot], 'home', acct_id, tlid);
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);
} else {
html = parse(obj, "home", acct_id, tlid);
$("#timeline_" + tlid).html(html);
}
todc();
@ -106,14 +112,12 @@ function mixtl(acct_id, tlid) {
//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,12 +140,12 @@ 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 templete = parse([obj], "", acct_id, tlid);
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
pool = templete + pool;
} else {
pool = templete
pool = templete;
}
localStorage.setItem("pool_" + tlid, pool);
scrollck();
@ -149,7 +153,7 @@ function mixre(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);
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,73 +194,81 @@ 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;
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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function(json) {
var templete = parse(json, 'mix', acct_id, tlid);
})
.then(function(json) {
var templete = parse(json, "mix", acct_id, tlid);
$("#timeline_" + tlid).append(templete[0]);
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',
method: "GET",
headers: {
'content-type': 'application/json',
'Authorization': 'Bearer ' + at
},
}).then(function(response) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function(obj) {
})
.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>');
$("#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 tarunix = date(toot.created_at, "unix");
var beforekey2;
var key2;
Object.keys(locals).forEach(function(key2) {
if ($("[toot-id=" + toot.id + "]").length <1) {
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));
$("#timeline_" + tlid + " [toot-id=" + local + "]").after(parse([toot], "home", acct_id, tlid));
tarunix = 2147483647;
}
}
});
});
@ -265,5 +277,4 @@ function mixmore(tlid) {
todc();
});
});
}

View File

@ -14,78 +14,80 @@ 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) {
"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) {
src("v1")
})
.catch(function(error) {
src("v1");
return false;
}).then(function (json) {
})
.then(function(json) {
console.log(["Search", json]);
//ハッシュタグ
if (json.hashtags[0]) {
var tags = "";
Object.keys(json.hashtags).forEach(function (key4) {
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> ';
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);
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);
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>');
$("#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)
$("#src-accts").append(templete);
}
}
jQuery("time.timeago").timeago();
});
@ -102,29 +104,33 @@ 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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (raw) {
})
.then(function(raw) {
var templete = "";
var json = raw.hits.hits;
var max_id = raw["hits"].length;
@ -132,7 +138,7 @@ function tootsearch(tlid, q) {
var toot = json[i]["_source"];
if (lastid != toot.uri) {
if (toot && toot.account) {
templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch")
templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch");
}
}
var lastid = toot.uri;
@ -148,27 +154,33 @@ function tootsearch(tlid, q) {
});
}
function moreTs(tlid, q) {
var sid = $("#timeline_" + tlid + " .ts-marker").last().attr("data-maxid");
var sid = $("#timeline_" + tlid + " .ts-marker")
.last()
.attr("data-maxid");
moreloading = true;
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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (raw) {
})
.then(function(raw) {
var templete = "";
var json = raw.hits.hits;
var max_id = raw["hits"].length;
@ -176,7 +188,7 @@ function moreTs(tlid, q) {
var toot = json[i]["_source"];
if (lastid != toot.uri) {
if (toot && toot.account) {
templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch")
templete = templete + parse([toot], "noauth", null, tlid, 0, [], "tootsearch");
}
}
var lastid = toot.uri;
@ -195,22 +207,17 @@ 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)&nbsp;<a onclick="tl(\'tag\',\'' + escapeHTML(tag.name) + '\',\'' + acct_id +
'\',\'add\')" class="pointer">#' + escapeHTML(tag.name) + '</a>&nbsp;' + his[0].accounts + lang.lang_src_people;
tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + '</svg><span style="font-size:200%">' + his[0].uses + "</span>toot(s)&nbsp;<a onclick=\"tl('tag','" + escapeHTML(tag.name) + "','" + acct_id + "','add')\" class=\"pointer\">#" + escapeHTML(tag.name) + "</a>&nbsp;" + his[0].accounts + lang.lang_src_people;
} 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&nbsp;<a onclick="tl(\'tag\',\'' + escapeHTML(tag.name) + '\',\'' + acct_id +
'\',\'add\')" class="pointer">#' + escapeHTML(tag.name) + '</a>&nbsp;' + his[0].accounts + lang.lang_src_people;
tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">' + '<g><path d="M0,' + six + " L10," + five + " 20," + four + " 30," + three + " 40," + two + " 50," + one + " 60," + zero + '" style="stroke: #9e9e9e; stroke-width: 1;fill: none;"></path></g>' + '</svg><span style="font-size:200%">' + his[0].uses + "</span>toot&nbsp;<a onclick=\"tl('tag','" + escapeHTML(tag.name) + "','" + acct_id + "','add')\" class=\"pointer\">#" + escapeHTML(tag.name) + "</a>&nbsp;" + his[0].accounts + lang.lang_src_people;
}
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) {
"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);
})
.catch(function(error) {
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
var tags = "";
Object.keys(json).forEach(function (keye) {
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&nbsp;<a onclick="tl(\'tag\',\'' + tag.name + '\',\'' + acct_id +
'\',\'add\')" class="pointer">#' + tag.name + '</a>&nbsp;' + his[0].accounts + lang.lang_src_people + "<br><br>";
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&nbsp;<a onclick=\"tl('tag','" + tag.name + "','" + acct_id + "','add')\" class=\"pointer\">#" + tag.name + "</a>&nbsp;" + his[0].accounts + lang.lang_src_people + "<br><br>";
$("#src-contents").append(tags);
});
});
}

View File

@ -5,7 +5,7 @@ if (location.search) {
var codex = m[2];
if (mode == "tag") {
var acct_id = localStorage.getItem("main");
tl('tag', decodeURI(codex), acct_id, 'add');
tl("tag", decodeURI(codex), acct_id, "add");
}
}
//よく使うタグ
@ -21,7 +21,7 @@ function tagPin(tag) {
var obj = JSON.parse(tags);
}
var can;
Object.keys(obj).forEach(function (key) {
Object.keys(obj).forEach(function(key) {
var tagT = obj[key];
if (tagT == tag) {
can = true;
@ -54,8 +54,8 @@ function favTag() {
var obj = JSON.parse(tagarr);
}
var tags = "";
var nowPT = localStorage.getItem("stable")
Object.keys(obj).forEach(function (key) {
var nowPT = localStorage.getItem("stable");
Object.keys(obj).forEach(function(key) {
var tag = obj[key];
if (nowPT != tag) {
console.log("stable tags:" + nowPT + "/" + tag);
@ -66,8 +66,7 @@ function favTag() {
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> ';
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);
@ -77,40 +76,43 @@ function favTag() {
}
function trendTag() {
$(".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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
if (json) {
var tags = "";
json = json.score;
Object.keys(json).forEach(function (tag) {
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> ';
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()
$("#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() {
@ -121,43 +123,46 @@ function tagTL(a, b, c, d) {
tl(a, b, acct_id, d);
}
function autoToot(tag) {
tag = escapeHTML(tag)
var nowPT = localStorage.getItem("stable")
tag = escapeHTML(tag);
var nowPT = localStorage.getItem("stable");
if (nowPT == tag) {
localStorage.removeItem("stable");
M.toast({ html: lang.lang_tags_unrealtime, displayLength: 3000 })
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 + " ")
M.toast({ html: lang.lang_tags_tagwarn.replace("{{tag}}", tag).replace("{{tag}}", tag), displayLength: 3000 });
brInsert("#" + tag + " ");
}
favTag();
}
//タグをフィーチャー
function tagFeature(name, 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
"content-type": "application/json",
Authorization: "Bearer " + at
},
body: JSON.stringify({
name: name
})
}).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) {
})
.catch(function(error) {
return false;
}).then(function (json) {
console.log(json)
M.toast({ html: "Complete: " + escapeHTML(name), displayLength: 3000 })
})
.then(function(json) {
console.log(json);
M.toast({ html: "Complete: " + escapeHTML(name), displayLength: 3000 });
});
}

File diff suppressed because it is too large Load Diff

View File

@ -1,73 +1,73 @@
//設定(setting.html)で読む
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,38 +461,38 @@ 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
@ -498,53 +500,73 @@ function pickerDefine(i, color) {
hue: true, // Hue slider
interaction: {
rgba: false, // rgba option (red green blue and alpha)
input: true, // input / output element
input: true // input / output element
}
},
strings: {
save: 'Save', // Default for save button
clear: 'Clear' // Default for clear button
save: "Save", // Default for save button
clear: "Clear" // Default for clear button
}
});
pickr.on('change', (...args) => {
var rgb = 'rgb(' + args[0].toRGBA()[0] + ',' + args[0].toRGBA()[1] + ',' + args[0].toRGBA()[2] + ')';
$("#color-picker" + i + "_value").val(rgb)
pickr.on("change", (...args) => {
var rgb = "rgb(" + args[0].toRGBA()[0] + "," + args[0].toRGBA()[1] + "," + args[0].toRGBA()[2] + ")";
$("#color-picker" + i + "_value").val(rgb);
});
}
function customComp() {
var nameC = $("#custom_name").val();
if (!nameC) { return false; }
if (!nameC) {
return false;
}
var descC = $("#custom_desc").val();
var primaryC = $("#color-picker0_value").val();
if (!primaryC) { primaryC = "rgb(255,255,255)" }
var secondaryC = $("#color-picker1_value").val();
if (!secondaryC) { secondaryC = "rgb(255,255,255)" }
var textC = $("#color-picker2_value").val();
if (!textC) { textC = "rgb(255,255,255)" }
var multi = localStorage.getItem("multi");
if($("#pickers").hasClass("advanceTheme")){
var accentC = $("#color-picker3_value").val();
if (!accentC) { accentC = null }
var activeC = $("#color-picker4_value").val();
if (!activeC) { activeC = null }
var modalC = $("#color-picker5_value").val();
if (!modalC) { modalC = null }
var bottomC = $("#color-picker6_value").val();
if (!bottomC) { bottomC = null }
var postboxC = $("#color-picker7_value").val();
if (!postboxC) { postboxC = null }
var subcolorC = $("#color-picker8_value").val();
if (!subcolorC) { subcolorC = null }
var advanceTheme = {
"TheDeskAccent": accentC,
"TheDeskActive": activeC,
"TheDeskModal": modalC,
"TheDeskBottom": bottomC,
"TheDeskPostbox": postboxC,
"TheDeskSubcolor": subcolorC
if (!primaryC) {
primaryC = "rgb(255,255,255)";
}
}else{
var advanceTheme = {}
var secondaryC = $("#color-picker1_value").val();
if (!secondaryC) {
secondaryC = "rgb(255,255,255)";
}
var textC = $("#color-picker2_value").val();
if (!textC) {
textC = "rgb(255,255,255)";
}
var multi = localStorage.getItem("multi");
if ($("#pickers").hasClass("advanceTheme")) {
var accentC = $("#color-picker3_value").val();
if (!accentC) {
accentC = null;
}
var activeC = $("#color-picker4_value").val();
if (!activeC) {
activeC = null;
}
var modalC = $("#color-picker5_value").val();
if (!modalC) {
modalC = null;
}
var bottomC = $("#color-picker6_value").val();
if (!bottomC) {
bottomC = null;
}
var postboxC = $("#color-picker7_value").val();
if (!postboxC) {
postboxC = null;
}
var subcolorC = $("#color-picker8_value").val();
if (!subcolorC) {
subcolorC = null;
}
var advanceTheme = {
TheDeskAccent: accentC,
TheDeskActive: activeC,
TheDeskModal: modalC,
TheDeskBottom: bottomC,
TheDeskPostbox: postboxC,
TheDeskSubcolor: subcolorC
};
} else {
var advanceTheme = {};
}
var my = JSON.parse(multi)[0].name;
@ -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,28 +737,32 @@ 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) {
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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (mess) {
})
.then(function(mess) {
console.table(mess);
if (mess) {
var platform = localStorage.getItem("platform");
@ -747,19 +773,19 @@ function checkupd(){
}
if (newest == ver) {
Swal.fire({
type: 'info',
type: "info",
title: lang.lang_setting_noupd,
html: ver
})
});
} else if (ver.indexOf("beta") != -1 || winstore) {
Swal.fire({
type: 'info',
type: "info",
title: lang.lang_setting_thisisbeta,
html: ver
})
});
} else {
localStorage.removeItem("new-ver-skip")
location.href="index.html"
localStorage.removeItem("new-ver-skip");
location.href = "index.html";
}
}
});

View File

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

View File

@ -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) {
"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) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.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>';
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()
$("#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,23 +99,27 @@ 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) {
})
.then(function(response) {
if (!response.ok) {
response.text().then(function(text) {
setLog(response.url, response.status, text);
});
}
return response.json();
}).catch(function (error) {
})
.catch(function(error) {
todo(error);
setLog(start, "JSON", error);
console.error(error);
}).then(function (json) {
})
.then(function(json) {
var ms = json.progress_ms;
var last = 1000 - ms % 1000;
var last = 1000 - (ms % 1000);
var item = json.item;
var img = item.album.images[0].url;
var artisttxt = "";
@ -126,34 +133,34 @@ function spotifytips() {
artisttxt = escapeHTML(artisttxt);
sleep(last);
var tms = item.duration_ms;
var per = ms / item.duration_ms * 100;
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 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>');
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);
}

View File

@ -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);
});
});

View File

@ -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) {