Prepare: use officail API instead of instances.social

This commit is contained in:
cutls 2018-09-01 22:02:15 +09:00
parent 0ef0c80ac8
commit 25b385b77c
2 changed files with 34 additions and 5 deletions

View File

@ -383,7 +383,7 @@ function ckdb(acct_id) {
} }
} }
if(localStorage.getItem("mode_" + domain)!="misskey"){ if(localStorage.getItem("mode_" + domain)!="misskey"){
var start = "https://" + domain + "/api/v1/instance/activity"; var start = "https://" + domain + "/api/v1/instance";
fetch(start, { fetch(start, {
method: 'GET', method: 'GET',
headers: { headers: {
@ -399,8 +399,8 @@ function ckdb(acct_id) {
return; return;
} }
if(json){ if(json){
localStorage.setItem("users_" + acct_id, json["logins"]); localStorage.setItem("letters_" + acct_id, json["max_toot_chars"]);
localStorage.setItem("statuses_" + acct_id, json["statuses"]); //localStorage.setItem("statuses_" + acct_id, json["statuses"]);
} }
}); });
@ -442,7 +442,12 @@ function multiSelector() {
if(idata[domain+"_letters"]){ if(idata[domain+"_letters"]){
$("#textarea").attr("data-length", idata[domain+"_letters"]) $("#textarea").attr("data-length", idata[domain+"_letters"])
}else{ }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); var profimg=localStorage.getItem("prof_"+key);
console.log(profimg); console.log(profimg);

View File

@ -75,7 +75,7 @@ function load() {
load(); load();
support(); support();
//instances.social //instances.social/instances API
function data(domain) { function data(domain) {
$("#ins-upd").text("Loading..."); $("#ins-upd").text("Loading...");
$("#ins-add").text("Loading..."); $("#ins-add").text("Loading...");
@ -114,6 +114,30 @@ function data(domain) {
$("#ins-prof").attr('src', json.thumbnail); $("#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);
}
});
} }
//アカウントデータ 消す //アカウントデータ 消す