From 25b385b77c613a6228655049c25da35c0cab2a1a Mon Sep 17 00:00:00 2001 From: cutls Date: Sat, 1 Sep 2018 22:02:15 +0900 Subject: [PATCH] Prepare: use officail API instead of instances.social --- app/js/login/login.js | 13 +++++++++---- app/js/login/manager.js | 26 +++++++++++++++++++++++++- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/app/js/login/login.js b/app/js/login/login.js index 89cf31bc..97547826 100644 --- a/app/js/login/login.js +++ b/app/js/login/login.js @@ -383,7 +383,7 @@ function ckdb(acct_id) { } } if(localStorage.getItem("mode_" + domain)!="misskey"){ - var start = "https://" + domain + "/api/v1/instance/activity"; + var start = "https://" + domain + "/api/v1/instance"; fetch(start, { method: 'GET', headers: { @@ -399,8 +399,8 @@ function ckdb(acct_id) { return; } if(json){ - localStorage.setItem("users_" + acct_id, json["logins"]); - localStorage.setItem("statuses_" + acct_id, json["statuses"]); + localStorage.setItem("letters_" + acct_id, json["max_toot_chars"]); + //localStorage.setItem("statuses_" + acct_id, json["statuses"]); } }); @@ -442,7 +442,12 @@ function multiSelector() { if(idata[domain+"_letters"]){ $("#textarea").attr("data-length", idata[domain+"_letters"]) }else{ - $("#textarea").attr("data-length", 500) + var maxletters = localStorage.getItem("letters_" + key); + if(maxletters){ + $("#textarea").attr("data-length", maxletters) + }else{ + $("#textarea").attr("data-length", 500) + } } var profimg=localStorage.getItem("prof_"+key); console.log(profimg); diff --git a/app/js/login/manager.js b/app/js/login/manager.js index 5823a02c..c6b60403 100644 --- a/app/js/login/manager.js +++ b/app/js/login/manager.js @@ -75,7 +75,7 @@ function load() { load(); support(); -//instances.social +//instances.social/instances API function data(domain) { $("#ins-upd").text("Loading..."); $("#ins-add").text("Loading..."); @@ -114,6 +114,30 @@ function data(domain) { $("#ins-prof").attr('src', json.thumbnail); } }); + var start = "https://" + domain +"/api/v1/instance"; + 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(json) { + console.log(json); + if (!json.error) { + $("#ins-name").text(json.title); + $("#ins-desc").text(text.description); + $("#ins-email").text(json.email); + $("#ins-toot").text(json.stats.status_count); + $("#ins-user").text(json.stats.user_count); + $("#ins-ver").text(json.version); + $("#ins-prof").attr('src', json.thumbnail); + $("#ins-admin").text(json.contanct_acount.username); + } + }); } //アカウントデータ 消す