2018-01-28 23:22:43 +11:00
|
|
|
//検索
|
|
|
|
//検索ボックストグル
|
|
|
|
function srcToggle() {
|
|
|
|
$("#src-box").toggleClass("hide");
|
2018-02-25 02:59:53 +11:00
|
|
|
$("#src-box").toggleClass("show");
|
2018-03-13 04:41:38 +11:00
|
|
|
$("#src-box").css("top",$('#src-tgl').offset().top+"px");
|
2018-03-14 17:52:55 +11:00
|
|
|
$("#src-box").css("left",$('#src-tgl').offset().left-410+"px");
|
2018-01-28 23:22:43 +11:00
|
|
|
$('ul.tabs').tabs('select_tab', 'src-sta');
|
|
|
|
$("#src-contents").html("");
|
|
|
|
}
|
|
|
|
|
|
|
|
//検索取得
|
|
|
|
function src() {
|
|
|
|
var q = $("#src").val();
|
|
|
|
var acct_id = $("#src-acct-sel").val();
|
2018-03-18 02:00:53 +11:00
|
|
|
if(acct_id=="tootsearch"){
|
|
|
|
tootsearch(q);
|
|
|
|
return false;
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
localStorage.setItem("last-use", acct_id);
|
|
|
|
var domain = localStorage.getItem("domain_" + acct_id);
|
|
|
|
var at = localStorage.getItem(domain + "_at");
|
|
|
|
if (user == "--now") {
|
|
|
|
var user = $('#his-data').attr("user-id");
|
|
|
|
}
|
|
|
|
var start = "https://" + domain + "/api/v1/search?q=" + q
|
|
|
|
console.log(start)
|
|
|
|
fetch(start, {
|
|
|
|
method: 'GET',
|
|
|
|
headers: {
|
|
|
|
'content-type': 'application/json',
|
|
|
|
'Authorization': 'Bearer ' + at
|
|
|
|
},
|
|
|
|
}).then(function(response) {
|
|
|
|
return response.json();
|
|
|
|
}).catch(function(error) {
|
|
|
|
todo(error);
|
|
|
|
console.error(error);
|
|
|
|
}).then(function(json) {
|
|
|
|
//トゥート
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
//ハッシュタグ
|
|
|
|
if (json.hashtags[0]) {
|
|
|
|
var tags = "";
|
|
|
|
Object.keys(json.hashtags).forEach(function(key4) {
|
|
|
|
var tag = json.hashtags[key4];
|
|
|
|
tags = tags + '<a onclick="tl(\'tag\',\'' + tag + '\',\'' + acct_id +
|
|
|
|
'\',\'add\')" class="pointer">#' + tag + '</a><br> ';
|
|
|
|
});
|
|
|
|
$("#src-contents").append("Tags<br>" + tags);
|
|
|
|
}
|
|
|
|
jQuery("time.timeago").timeago();
|
|
|
|
});
|
|
|
|
}
|
2018-03-18 02:00:53 +11:00
|
|
|
function tootsearch(q){
|
|
|
|
var start = "https://tootsearch.chotto.moe/api/v1/search?from=0&sort=created_at%3Adesc&q=" + q
|
|
|
|
console.log(start)
|
|
|
|
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);
|
|
|
|
Object.keys(json).forEach(function(key5) {
|
|
|
|
var toot = json[key5]["_source"];
|
|
|
|
console.log(toot);
|
|
|
|
if(toot && toot.account){
|
|
|
|
templete = templete+parse([toot],'');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if(!templete){
|
|
|
|
templete="データはありません。";
|
|
|
|
}
|
|
|
|
$("#src-contents").html("Tootsearch(時系列)<br>" + templete);
|
|
|
|
jQuery("time.timeago").timeago();
|
|
|
|
});
|
|
|
|
}
|