TheDesk Mio (15.6.0)
This commit is contained in:
123
app/js/tl/src.js
123
app/js/tl/src.js
@@ -3,6 +3,9 @@
|
||||
function srcToggle() {
|
||||
$("#src-box").toggleClass("hide");
|
||||
$("#src-box").toggleClass("show");
|
||||
if($("#src-box").hasClass("show")){
|
||||
trend();
|
||||
}
|
||||
$("#src-box").css("top",$('#src-tgl').offset().top-$("#src-box").height()/2+"px");
|
||||
$("#src-box").css("left",$('#src-tgl').offset().left-410+"px");
|
||||
$('ul.tabs').tabs('select_tab', 'src-sta');
|
||||
@@ -10,7 +13,8 @@ function srcToggle() {
|
||||
}
|
||||
|
||||
//検索取得
|
||||
function src() {
|
||||
function src(mode) {
|
||||
$("#src-contents").html("");
|
||||
var q = $("#src").val();
|
||||
var acct_id = $("#src-acct-sel").val();
|
||||
if(acct_id=="tootsearch"){
|
||||
@@ -23,7 +27,11 @@ function src() {
|
||||
if (user == "--now") {
|
||||
var user = $('#his-data').attr("user-id");
|
||||
}
|
||||
var start = "https://" + domain + "/api/v1/search?q=" + q
|
||||
if(!mode){
|
||||
var start = "https://" + domain + "/api/v2/search?q=" + q
|
||||
}else{
|
||||
var start = "https://" + domain + "/api/v1/search?q=" + q
|
||||
}
|
||||
console.log(start)
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
@@ -34,9 +42,25 @@ function src() {
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
src("v1")
|
||||
return false;
|
||||
}).then(function(json) {
|
||||
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 +
|
||||
'\',\'add\')" class="pointer">#' + tag + '</a><br> ';
|
||||
}else{
|
||||
tags=tags+graphDraw(tag);
|
||||
}
|
||||
|
||||
});
|
||||
$("#src-contents").append("Tags<br>" + tags);
|
||||
}
|
||||
//トゥート
|
||||
if (json.statuses[0]) {
|
||||
var templete = parse(json.statuses,'',acct_id);
|
||||
@@ -47,16 +71,6 @@ function src() {
|
||||
var templete = userparse(json.accounts,'',acct_id);
|
||||
$("#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();
|
||||
});
|
||||
}
|
||||
@@ -81,7 +95,7 @@ function tootsearch(q){
|
||||
var toot = json[key5]["_source"];
|
||||
console.log(toot);
|
||||
if(toot && toot.account){
|
||||
templete = templete+parse([toot],'');
|
||||
templete = templete+parse([toot],'noauth');
|
||||
}
|
||||
});
|
||||
if(!templete){
|
||||
@@ -90,4 +104,81 @@ function tootsearch(q){
|
||||
$("#src-contents").html("Tootsearch(時系列)<br>" + templete);
|
||||
jQuery("time.timeago").timeago();
|
||||
});
|
||||
}
|
||||
}
|
||||
function trend(){
|
||||
$("#src-contents").html("");
|
||||
var acct_id = $("#src-acct-sel").val();
|
||||
if(acct_id=="tootsearch"){
|
||||
return false;
|
||||
}
|
||||
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/trends"
|
||||
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) {
|
||||
var tags = "";
|
||||
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 = '<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>toots <a onclick="tl(\'tag\',\'' + tag.name + '\',\'' + acct_id +
|
||||
'\',\'add\')" class="pointer">#' + tag.name + '</a> '+his[0].accounts+"人がトゥート";
|
||||
|
||||
$("#src-contents").append(tags);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
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);
|
||||
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>toots <a onclick="tl(\'tag\',\'' + tag.name + '\',\'' + acct_id +
|
||||
'\',\'add\')" class="pointer">#' + tag.name + '</a> '+his[0].accounts+"人がトゥート";
|
||||
}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>toots <a onclick="tl(\'tag\',\'' + tag.name + '\',\'' + acct_id +
|
||||
'\',\'add\')" class="pointer">#' + tag.name + '</a> '+his[0].accounts+"人がトゥート";
|
||||
}
|
||||
|
||||
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>
|
||||
*/
|
@@ -66,7 +66,7 @@ function favTag(){
|
||||
}
|
||||
}
|
||||
function trendTag(){
|
||||
$("#trendtag").html("");
|
||||
$(".trendtag").remove();
|
||||
var domain="imastodon.net"
|
||||
var at = localStorage.getItem(domain + "_at");
|
||||
var start = "https://" + domain + "/api/v1/trend_tags"
|
||||
@@ -89,7 +89,7 @@ function trendTag(){
|
||||
Object.keys(json).forEach(function(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="brInsert(\'#' + tag + '\')" class="pointer" title="#' + tag + 'でトゥート">Toot</a></span> ';
|
||||
});
|
||||
$("#taglist").append('<span id="trendtag">トレンドタグ<i class="material-icons pointer" onclick="trendTag()" style="font-size:12px">refresh</i>:' + tags+'</span>');
|
||||
$("#taglist").append('<span class="trendtag">トレンドタグ<i class="material-icons pointer" onclick="trendTag()" style="font-size:12px">refresh</i>:' + tags+'</span>');
|
||||
trendintervalset()
|
||||
}else{
|
||||
$("#taglist").html("");
|
||||
@@ -101,7 +101,6 @@ function trendTag(){
|
||||
function trendintervalset(){
|
||||
setTimeout(trendTag, 6000000);
|
||||
|
||||
|
||||
}
|
||||
function tagTL(a,b,c,d){
|
||||
var acct_id = $("#post-acct-sel").val();
|
||||
|
@@ -113,9 +113,15 @@ function reload(type, cc, acct_id, tlid, data) {
|
||||
} else if (type == "pub") {
|
||||
var start = "wss://" + domain +
|
||||
"/api/v1/streaming/?stream=public&access_token=" + at;
|
||||
} else if (type == "pub-media") {
|
||||
var start = "wss://" + domain +
|
||||
"/api/v1/streaming/?stream=public:media&access_token=" + at;
|
||||
} else if (type == "local") {
|
||||
var start = "wss://" + domain +
|
||||
"/api/v1/streaming/?stream=public:local&access_token=" + at;
|
||||
} else if (type == "local-media") {
|
||||
var start = "wss://" + domain +
|
||||
"/api/v1/streaming/?stream=public:local:media&only_media=true&access_token=" + at;
|
||||
} else if (type == "tag") {
|
||||
if(type=="tag"){
|
||||
var tag = localStorage.getItem("tag-range");
|
||||
@@ -305,12 +311,24 @@ function cap(type, data, acct_id) {
|
||||
}else{
|
||||
var response="Local TL";
|
||||
}
|
||||
} else if (type == "local-media") {
|
||||
if(localStorage.getItem("local_" + acct_id) && !locale){
|
||||
var response=localStorage.getItem("local_" + acct_id)+"(メディア)";
|
||||
}else{
|
||||
var response="Local TL(Media)";
|
||||
}
|
||||
} else if (type == "pub") {
|
||||
if(localStorage.getItem("public_" + acct_id) && !locale){
|
||||
var response=localStorage.getItem("public_" + acct_id);
|
||||
}else{
|
||||
var response="Federated TL";
|
||||
}
|
||||
} else if (type == "pub-media") {
|
||||
if(localStorage.getItem("public_" + acct_id) && !locale){
|
||||
var response=localStorage.getItem("public_" + acct_id)+"(メディア)";
|
||||
}else{
|
||||
var response="Federated TL(Media)";
|
||||
}
|
||||
} else if (type == "tag") {
|
||||
var response= "#" + data
|
||||
} else if (type == "list") {
|
||||
@@ -336,8 +354,12 @@ function com(type, data) {
|
||||
return "home?"
|
||||
} else if (type == "local" || type == "noauth") {
|
||||
return "public?local=true&"
|
||||
} else if (type == "local-media") {
|
||||
return "public?local=true&only_media=true&"
|
||||
} else if (type == "pub") {
|
||||
return "public?"
|
||||
} else if (type == "pub-media") {
|
||||
return "public?only_media=true&"
|
||||
} else if (type == "tag") {
|
||||
return "tag/" + data + "?"
|
||||
}else if (type == "list") {
|
||||
@@ -351,9 +373,9 @@ function com(type, data) {
|
||||
function icon(type) {
|
||||
if (type == "home") {
|
||||
return "home"
|
||||
} else if (type == "local" || type == "noauth") {
|
||||
} else if (type == "local" || type == "noauth" || type == "local-media") {
|
||||
return "people_outline"
|
||||
} else if (type == "pub") {
|
||||
} else if (type == "pub" || type == "pub-media") {
|
||||
return "language"
|
||||
} else if (type == "tag") {
|
||||
return "search"
|
||||
|
Reference in New Issue
Block a user