From 0a1d462acee5abe27bd2257b3bea70c100bb2639 Mon Sep 17 00:00:00 2001 From: Cutls Date: Tue, 6 Aug 2019 23:06:09 +0900 Subject: [PATCH] Add: trending tags --- app/js/tl/src.js | 48 +++++++++++++++++++++++++++++++++++++++++++++++- app/main.js | 2 +- app/package.json | 4 ++-- 3 files changed, 50 insertions(+), 4 deletions(-) diff --git a/app/js/tl/src.js b/app/js/tl/src.js index 15de7122..ec725a34 100644 --- a/app/js/tl/src.js +++ b/app/js/tl/src.js @@ -1,6 +1,7 @@ //検索 //検索ボックストグル function searchMenu() { + trend(); $("#left-menu div").removeClass("active"); $("#searchMenu").addClass("active"); $(".menu-content").addClass("hide"); @@ -192,4 +193,49 @@ function graphDraw(tag, acct_id) { -*/ \ No newline at end of file +*/ +function trend(){ + console.log("get 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("acct_"+ acct_id + "_at"); + 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 = ''+ + ''+ + ''+his[0].uses+'toots #' + tag.name + ' '+his[0].accounts+lang.lang_src_people+"

"; + + $("#src-contents").append(tags); + }); + + }); +} \ No newline at end of file diff --git a/app/main.js b/app/main.js index b53267c1..1019f5aa 100644 --- a/app/main.js +++ b/app/main.js @@ -94,7 +94,7 @@ app.on('activate', function () { }); function createWindow() { - if (isFile(lang_path)) { + if (isFile(lang_path)) {1 var lang = fs.readFileSync(lang_path, 'utf8'); } else { var langs = app.getLocale(); diff --git a/app/package.json b/app/package.json index 701fcb89..eee03263 100644 --- a/app/package.json +++ b/app/package.json @@ -116,8 +116,8 @@ ] }, "electronDownload": { - "version": "5.0.4" + "version": "6.0.0" }, - "electronVersion": "5.0.4" + "electronVersion": "6.0.0" } }