2018-01-28 23:22:43 +11:00
|
|
|
//カード処理やメンション、ハッシュタグの別途表示
|
|
|
|
//全てのTL処理で呼び出し
|
|
|
|
function additional(acct_id, tlid) {
|
|
|
|
//メンション系
|
|
|
|
$(".mention").attr("href", "#");
|
2018-02-05 02:09:20 +11:00
|
|
|
$(".mention").addClass("parsed");
|
2018-01-28 23:22:43 +11:00
|
|
|
//トゥートサムネ
|
|
|
|
$("#timeline_" + tlid + " .toot a:not(.parsed)").each(function(i, elem) {
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
|
|
|
var at = localStorage.getItem(domain + "_at");
|
|
|
|
var card = localStorage.getItem("card_" + tlid);
|
|
|
|
var text = $(this).attr('href');
|
|
|
|
var urls = text.match(
|
|
|
|
/https?:\/\/([-a-zA-Z0-9@.]+)\/media\/([-_.!~*\'()a-zA-Z0-9;\/?:\@&=+\$,%#]+)/
|
|
|
|
);
|
|
|
|
if (urls) {
|
|
|
|
$(this).remove();
|
|
|
|
} else if (!card) {
|
|
|
|
|
|
|
|
var id = $(this).parents('.cvo').attr("toot-id");
|
|
|
|
var start = "https://" + domain + "/api/v1/statuses/" + id + "/card";
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
//body: JSON.stringify({})
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
console.log(json);
|
|
|
|
if (json.title) {
|
|
|
|
$("[toot-id=" + id + "] .additional").html(
|
|
|
|
"<span class=\"gray\">URLチェック:<br>Title:" + json.title + "<br>" +
|
|
|
|
json.description + "</span>");
|
|
|
|
}
|
|
|
|
if (json.html) {
|
|
|
|
$("[toot-id=" + id + "] .additional").html(json.html);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (json.title) {
|
|
|
|
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
|
|
|
|
$("[toot-id=" + id + "]").addClass("parsed");
|
|
|
|
}
|
|
|
|
});
|
2018-02-05 01:56:31 +11:00
|
|
|
}else{
|
|
|
|
$(this).attr("title",text);
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
});
|
2018-02-05 02:09:20 +11:00
|
|
|
$("#timeline_" + tlid + " .toot:not(:has(a:not(.add-show,.parsed)))").each(function(i, elem) {
|
2018-02-05 01:56:31 +11:00
|
|
|
$(this).parent().find(".add-show").hide();
|
|
|
|
});
|
2018-01-31 03:43:01 +11:00
|
|
|
//Markdownイメージビューワー
|
|
|
|
$("#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");
|
|
|
|
$(this).attr("href","#");
|
|
|
|
$(this).attr("onclick","imgv('"+id+"','"+i+"')");
|
|
|
|
$(this).attr("data-type","image");
|
|
|
|
$(this).attr("id",id+"-image-"+i);
|
|
|
|
$(this).attr("data-url",ilink);
|
|
|
|
$(this).addClass("img-parsed");
|
|
|
|
});
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
|
2018-02-05 01:56:31 +11:00
|
|
|
function additionalIndv(tlid, acct_id, id) {
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
|
|
|
var at = localStorage.getItem(domain + "_at");
|
|
|
|
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 {
|
|
|
|
|
|
|
|
var id = $("[toot-id="+id+"] .toot a").parents('.cvo').attr("toot-id");
|
|
|
|
var start = "https://" + domain + "/api/v1/statuses/" + id + "/card";
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
//body: JSON.stringify({})
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
console.log(json);
|
|
|
|
if (json.title) {
|
|
|
|
$("[toot-id=" + id + "] .additional").html(
|
|
|
|
"<span class=\"gray\">URLチェック:<br>Title:" + json.title + "<br>" +
|
|
|
|
json.description + "</span>");
|
|
|
|
}
|
|
|
|
if (json.html) {
|
|
|
|
$("[toot-id=" + id + "] .additional").html(json.html);
|
|
|
|
|
|
|
|
}
|
|
|
|
if (json.title) {
|
|
|
|
$("[toot-id=" + id + "] a:not(.parsed)").addClass("parsed");
|
|
|
|
$("[toot-id=" + id + "]").addClass("parsed");
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-28 23:22:43 +11:00
|
|
|
//各TL上方のLink[On/Off]
|
|
|
|
function cardToggle(tlid) {
|
|
|
|
var card = localStorage.getItem("card_" + tlid);
|
|
|
|
if (!card) {
|
|
|
|
localStorage.setItem("card_" + tlid, "true");
|
|
|
|
$("#sta-card-" + tlid).text("Off");
|
2018-02-13 06:16:46 +11:00
|
|
|
$("#sta-card-" + tlid).css("color",'red');
|
2018-01-28 23:22:43 +11:00
|
|
|
} else {
|
|
|
|
localStorage.removeItem("card_" + tlid);
|
|
|
|
$("#sta-card-" + tlid).text("On");
|
2018-02-13 06:16:46 +11:00
|
|
|
$("#sta-card-" + tlid).css("color",'#009688');
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//各TL上方のLink[On/Off]をチェック
|
|
|
|
function cardCheck(tlid) {
|
|
|
|
var card = localStorage.getItem("card_" + tlid);
|
|
|
|
if (!card) {
|
|
|
|
$("#sta-card-" + tlid).text("On");
|
2018-02-13 06:16:46 +11:00
|
|
|
$("#sta-card-" + tlid).css("color",'#009688');
|
2018-01-28 23:22:43 +11:00
|
|
|
} else {
|
|
|
|
$("#sta-card-" + tlid).text("Off");
|
2018-02-13 06:16:46 +11:00
|
|
|
$("#sta-card-" + tlid).css("color",'red');
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
}
|