TheDesk Miho(ver.7)

This commit is contained in:
cutls
2018-02-04 23:56:31 +09:00
parent 108086c48a
commit df86d32b33
17 changed files with 229 additions and 24 deletions

View File

@@ -46,8 +46,13 @@ function additional(acct_id, tlid) {
$("[toot-id=" + id + "]").addClass("parsed");
}
});
}else{
$(this).attr("title",text);
}
});
$("#timeline_" + tlid + " .toot:not(:has(a:not(.add-show)))").each(function(i, elem) {
$(this).parent().find(".add-show").hide();
});
//Markdownイメージビューワー
$("#timeline_" + tlid + " .toot a:not(.img-parsed):has(img)").each(function(i, elem) {
var ilink=$(this).attr("href");
@@ -61,6 +66,50 @@ function additional(acct_id, tlid) {
});
}
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");
}
});
}
}
//各TL上方のLink[On/Off]
function cardToggle(tlid) {
var card = localStorage.getItem("card_" + tlid);

View File

@@ -33,13 +33,14 @@ function notf(acct_id, tlid, sys) {
at;
console.log(start);
var websocket = new WebSocket(start);
console.log(websocket);
websocket.onopen = function(mess) {
var wsid = websocketNotf.length;
websocketNotf[wsid] = new WebSocket(start);
console.log(websocketNotf);
websocketNotf[wsid].onopen = function(mess) {
console.log("Connect Streaming API:");
console.log(mess);
}
websocket.onmessage = function(mess) {
websocketNotf[wsid].onmessage = function(mess) {
console.log("Receive Streaming API:");
var obj = JSON.parse(JSON.parse(mess.data).payload);
@@ -62,7 +63,7 @@ function notf(acct_id, tlid, sys) {
}
}
websocket.onerror = function(error) {
websocketNotf[wsid].onerror = function(error) {
console.error('WebSocket Error ' + error);
};
}

View File

@@ -177,7 +177,8 @@ function parse(obj, mix, acct_id) {
api_spoil + ' cw_text_' + toot.id + '">' + spoil + spoiler_show +
'</span>' +
'' + viewer + '' +
'<div class="additional"></div><span class="cbadge"><i class="fa fa-clock-o"></i>' +
'<div class="additional"><a onclick="additionalIndv(\'' + tlid + '\',' + acct_id +
',\''+id+'\')" class="add-show pointer">URL解析</a></div><span class="cbadge"><i class="fa fa-clock-o"></i>' +
date(toot.created_at, datetype) + '</span>' +
'<span class="cbadge">via ' + via +
'<help class="white-text">どこから投稿したか</help></span>' + mentions + tags +

View File

@@ -139,6 +139,11 @@ function moreload(type, tlid) {
var acct_id = obj[tlid].domain;
if (!type) {
var type = obj[tlid].type;
}else{
var data;
}
if(type=="tag"){
var data=obj[tlid].data;
}
var sid = $("#timeline_" + tlid + " .cvo").last().attr("toot-id");
console.log(localStorage.getItem("morelock") + ":" + sid)
@@ -152,7 +157,7 @@ function moreload(type, tlid) {
todo(cap(type) + " TL MoreLoading");
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/timelines/" + com(type) +
var start = "https://" + domain + "/api/v1/timelines/" + com(type,data) +
"max_id=" + sid;
fetch(start, {
method: 'GET',
@@ -206,6 +211,14 @@ function tlCloser() {
});
websocketLocal = [];
Object.keys(websocketNotf).forEach(function(tlid) {
if (websocketNotf[tlid]) {
websocketNotf[tlid].close();
console.log("Close Streaming API:Notf" + tlid);
}
});
websocketLocal = [];
}
//TLのタイトル