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"){
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"]);
}
});
@ -441,9 +441,14 @@ function multiSelector() {
var domain = localStorage.getItem("domain_" + key);
if(idata[domain+"_letters"]){
$("#textarea").attr("data-length", idata[domain+"_letters"])
}else{
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);
if(!profimg){

View File

@ -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);
}
});
}
//アカウントデータ 消す