2018-01-28 23:22:43 +11:00
|
|
|
//検索
|
|
|
|
//検索ボックストグル
|
2019-03-15 06:48:01 +11:00
|
|
|
function searchMenu() {
|
|
|
|
$("#left-menu div").removeClass("active");
|
|
|
|
$("#searchMenu").addClass("active");
|
|
|
|
$(".menu-content").addClass("hide");
|
|
|
|
$("#src-box").removeClass("hide");
|
2018-01-28 23:22:43 +11:00
|
|
|
$('ul.tabs').tabs('select_tab', 'src-sta');
|
|
|
|
$("#src-contents").html("");
|
|
|
|
}
|
|
|
|
|
|
|
|
//検索取得
|
2018-06-12 01:44:28 +10:00
|
|
|
function src(mode) {
|
|
|
|
$("#src-contents").html("");
|
2018-01-28 23:22:43 +11:00
|
|
|
var q = $("#src").val();
|
|
|
|
var acct_id = $("#src-acct-sel").val();
|
2018-03-18 02:00:53 +11:00
|
|
|
if(acct_id=="tootsearch"){
|
2019-04-10 00:12:11 +10:00
|
|
|
tsAdd(q)
|
2018-03-18 02:00:53 +11:00
|
|
|
return false;
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
localStorage.setItem("last-use", acct_id);
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
2018-07-07 03:51:48 +10:00
|
|
|
var at = localStorage.getItem("acct_"+ acct_id + "_at");
|
2018-07-11 02:36:56 +10:00
|
|
|
var m = q.match(/^#(.+)$/);
|
|
|
|
if(m){q=m[1];}
|
2018-01-28 23:22:43 +11:00
|
|
|
if (user == "--now") {
|
|
|
|
var user = $('#his-data').attr("user-id");
|
|
|
|
}
|
2018-06-12 01:44:28 +10:00
|
|
|
if(!mode){
|
|
|
|
var start = "https://" + domain + "/api/v2/search?q=" + q
|
|
|
|
}else{
|
|
|
|
var start = "https://" + domain + "/api/v1/search?q=" + q
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
console.log(start)
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
2018-06-12 01:44:28 +10:00
|
|
|
src("v1")
|
|
|
|
return false;
|
2018-01-28 23:22:43 +11:00
|
|
|
}).then(function(json) {
|
2018-06-12 01:44:28 +10:00
|
|
|
console.log(json);
|
|
|
|
//ハッシュタグ
|
|
|
|
if (json.hashtags[0]) {
|
|
|
|
var tags = "";
|
|
|
|
Object.keys(json.hashtags).forEach(function(key4) {
|
|
|
|
var tag = json.hashtags[key4];
|
|
|
|
if(mode){
|
|
|
|
tags = tags + '<a onclick="tl(\'tag\',\'' + tag + '\',\'' + acct_id +
|
2019-04-23 00:16:57 +10:00
|
|
|
'\',\'add\')" class="pointer">#' + escapeHTML(tag) + '</a><br> ';
|
2018-06-12 01:44:28 +10:00
|
|
|
}else{
|
|
|
|
tags=tags+graphDraw(tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
$("#src-contents").append("Tags<br>" + tags);
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
//トゥート
|
|
|
|
if (json.statuses[0]) {
|
2018-03-18 02:00:53 +11:00
|
|
|
var templete = parse(json.statuses,'',acct_id);
|
2018-01-28 23:22:43 +11:00
|
|
|
$("#src-contents").append("Mentions<br>" + templete);
|
|
|
|
}
|
|
|
|
//アカウント
|
|
|
|
if (json.accounts[0]) {
|
2018-03-18 02:00:53 +11:00
|
|
|
var templete = userparse(json.accounts,'',acct_id);
|
2018-01-28 23:22:43 +11:00
|
|
|
$("#src-contents").append("Accounts<br>" + templete);
|
|
|
|
}
|
|
|
|
jQuery("time.timeago").timeago();
|
|
|
|
});
|
|
|
|
}
|
2019-04-10 00:12:11 +10:00
|
|
|
function tsAdd(q){
|
|
|
|
var add = {
|
|
|
|
domain: acct_id,
|
|
|
|
type: "tootsearch",
|
|
|
|
data: q
|
|
|
|
};
|
|
|
|
var multi = localStorage.getItem("column");
|
|
|
|
var obj = JSON.parse(multi);
|
|
|
|
localStorage.setItem("card_" + obj.length,"true");
|
|
|
|
obj.push(add);
|
|
|
|
console.log(obj);
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
localStorage.setItem("column", json);
|
|
|
|
parseColumn();
|
|
|
|
}
|
|
|
|
function tootsearch(tlid,q){
|
2018-03-18 02:00:53 +11:00
|
|
|
var start = "https://tootsearch.chotto.moe/api/v1/search?from=0&sort=created_at%3Adesc&q=" + q
|
|
|
|
console.log(start)
|
2019-04-10 00:12:11 +10:00
|
|
|
$("#notice_" + tlid).text("tootsearch("+q+")");
|
|
|
|
$("#notice_icon_" + tlid).text("search");
|
2018-03-18 02:00:53 +11:00
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json'
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(raw) {
|
|
|
|
var templete="";
|
|
|
|
var json=raw.hits.hits;
|
|
|
|
console.log(json);
|
2019-04-11 13:52:38 +10:00
|
|
|
var max_id = raw["hits"].length;
|
2019-04-10 00:12:11 +10:00
|
|
|
for(var i=0;i<json.length;i++){
|
|
|
|
var toot = json[i]["_source"];
|
|
|
|
console.log(lastid)
|
|
|
|
if(lastid!=toot.uri){
|
|
|
|
console.log(toot);
|
|
|
|
if(toot && toot.account){
|
|
|
|
templete = templete+parse([toot], "noauth", null, tlid, 0, [], "tootsearch")
|
|
|
|
}
|
2018-03-18 02:00:53 +11:00
|
|
|
}
|
2019-04-10 00:12:11 +10:00
|
|
|
var lastid=toot.uri;
|
|
|
|
}
|
2018-03-18 02:00:53 +11:00
|
|
|
if(!templete){
|
2019-01-26 14:24:26 +11:00
|
|
|
templete=lang.lang_details_nodata;
|
2019-04-10 00:12:11 +10:00
|
|
|
}else{
|
|
|
|
templete=templete+'<div class="hide ts-marker" data-maxid="'+max_id+'"></div>';
|
2018-03-18 02:00:53 +11:00
|
|
|
}
|
2019-04-10 00:12:11 +10:00
|
|
|
$("#timeline_" + tlid).html(templete);
|
|
|
|
|
2018-03-18 02:00:53 +11:00
|
|
|
jQuery("time.timeago").timeago();
|
|
|
|
});
|
2018-06-12 01:44:28 +10:00
|
|
|
}
|
2019-04-11 13:52:38 +10:00
|
|
|
function moreTs(tlid,q){
|
|
|
|
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
|
|
|
|
console.log(start)
|
|
|
|
$("#notice_" + tlid).text("tootsearch("+q+")");
|
|
|
|
$("#notice_icon_" + tlid).text("search");
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json'
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(raw) {
|
|
|
|
var templete="";
|
|
|
|
var json=raw.hits.hits;
|
|
|
|
console.log(json);
|
|
|
|
var max_id = raw["hits"].length;
|
|
|
|
for(var i=0;i<json.length;i++){
|
|
|
|
var toot = json[i]["_source"];
|
|
|
|
console.log(lastid)
|
|
|
|
if(lastid!=toot.uri){
|
|
|
|
console.log(toot);
|
|
|
|
if(toot && toot.account){
|
|
|
|
templete = templete+parse([toot], "noauth", null, tlid, 0, [], "tootsearch")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var lastid=toot.uri;
|
|
|
|
}
|
|
|
|
if(!templete){
|
|
|
|
templete=lang.lang_details_nodata;
|
|
|
|
}else{
|
|
|
|
templete=templete+'<div class="hide ts-marker" data-maxid="'+max_id+'"></div>';
|
|
|
|
}
|
|
|
|
$("#timeline_" + tlid).append(templete);
|
|
|
|
|
|
|
|
jQuery("time.timeago").timeago();
|
|
|
|
});
|
|
|
|
}
|
2018-06-12 01:44:28 +10:00
|
|
|
function graphDraw(tag){
|
|
|
|
var tags="";
|
|
|
|
var his=tag.history;
|
|
|
|
console.log(his);
|
|
|
|
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);
|
2019-03-08 05:19:26 +11:00
|
|
|
if(max===0){
|
2018-06-12 01:44:28 +10:00
|
|
|
tags = '<br><br><svg version="1.1" viewbox="0 0 60 50" width="60" height="50">'+
|
2019-04-23 00:16:57 +10:00
|
|
|
'</svg><span style="font-size:200%">'+his[0].uses+'</span>toots <a onclick="tl(\'tag\',\'' + escapeHTML(tag.name) + '\',\'' + acct_id +
|
|
|
|
'\',\'add\')" class="pointer">#' + escapeHTML(tag.name) + '</a> '+his[0].accounts+lang.lang_src_people;
|
2018-06-12 01:44:28 +10:00
|
|
|
}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>'+
|
2019-04-23 00:16:57 +10:00
|
|
|
'</svg><span style="font-size:200%">'+his[0].uses+'</span>toots <a onclick="tl(\'tag\',\'' + escapeHTML(tag.name) + '\',\'' + acct_id +
|
|
|
|
'\',\'add\')" class="pointer">#' + escapeHTML(tag.name) + '</a> '+his[0].accounts+lang.lang_src_people;
|
2018-06-12 01:44:28 +10:00
|
|
|
}
|
|
|
|
|
|
|
|
return tags;
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
<svg version="1.1" viewbox="0 0 50 300" width="100%" height="50">
|
|
|
|
<path d="M0,0 L10,0 20,10 20,50" fill="#3F51B5"></path>
|
|
|
|
</svg>
|
|
|
|
*/
|