2018-01-28 23:22:43 +11:00
|
|
|
|
//アカウントマネージャ
|
|
|
|
|
//最初に読むやつ
|
|
|
|
|
function load() {
|
|
|
|
|
$("#acct-list").html("");
|
|
|
|
|
var prof = localStorage.getItem("prof");
|
|
|
|
|
$(".my-prof").attr("src", prof);
|
|
|
|
|
var name = localStorage.getItem("name");
|
|
|
|
|
$("#now-name").text(name);
|
|
|
|
|
var user = localStorage.getItem("user");
|
|
|
|
|
$("#now-user").text(user);
|
|
|
|
|
var domain = localStorage.getItem("domain");
|
|
|
|
|
$(".now-domain").text(domain);
|
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
|
if (!multi) {
|
2018-08-17 03:21:40 +10:00
|
|
|
|
var obj = [];
|
2018-01-28 23:22:43 +11:00
|
|
|
|
} else {
|
|
|
|
|
var obj = JSON.parse(multi);
|
|
|
|
|
}
|
2018-08-17 03:21:40 +10:00
|
|
|
|
if(obj[0]){
|
|
|
|
|
if(!obj[0].at){
|
|
|
|
|
obj=[];
|
|
|
|
|
localStorage.removeItem("multi");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2018-01-28 23:22:43 +11:00
|
|
|
|
console.log(obj);
|
|
|
|
|
var templete;
|
|
|
|
|
Object.keys(obj).forEach(function(key) {
|
|
|
|
|
var acct = obj[key];
|
|
|
|
|
var list = key * 1 + 1;
|
2018-06-18 00:26:45 +10:00
|
|
|
|
if(acct.background!="def" && acct.text!="def"){
|
|
|
|
|
var style='style="background-color:#'+acct.background+'; color:'+acct.text+';"'
|
|
|
|
|
}else{
|
|
|
|
|
var style=""
|
|
|
|
|
}
|
2018-08-23 03:29:39 +10:00
|
|
|
|
if(acct.name){
|
|
|
|
|
var name=acct.name;
|
|
|
|
|
}else{
|
|
|
|
|
var name=acct.user;
|
|
|
|
|
}
|
2018-06-18 00:26:45 +10:00
|
|
|
|
templete = '<div id="acct_' + key + '" class="card" '+style+'><div class="card-content "><span class="lts">' + list +
|
2018-05-20 16:17:10 +10:00
|
|
|
|
'.</span><img src="' + acct.prof + '" width="40" height="40"><span class="card-title">' +
|
2018-08-23 03:29:39 +10:00
|
|
|
|
name + '</span>' + escapeHTML(acct.user) + '@' + acct.domain +
|
2018-05-20 16:17:10 +10:00
|
|
|
|
'</div><div class="card-action"><a class="waves-effect disTar pointer white-text" onclick="data(\'' +
|
2018-01-28 23:22:43 +11:00
|
|
|
|
acct.domain +
|
2018-07-29 17:37:54 +10:00
|
|
|
|
'\')"><i class="material-icons">info</i>'+lang_manager_info[lang]+'</a><a class="waves-effect disTar pointer white-text" onclick="refresh(' +
|
2018-01-28 23:22:43 +11:00
|
|
|
|
key +
|
2018-07-29 17:37:54 +10:00
|
|
|
|
')"><i class="material-icons">refresh</i>'+lang_manager_refresh[lang]+'</a><a class="waves-effect disTar pointer red-text" onclick="multiDel(' +
|
2018-05-20 16:17:10 +10:00
|
|
|
|
key +
|
2018-07-29 17:37:54 +10:00
|
|
|
|
')"><i class="material-icons">delete</i>'+lang_manager_delete[lang]+'</a><br>'+lang_manager_color[lang]+'<div id="colorsel_'+key+'" class="colorsel"></div></div></div>';
|
2018-01-28 23:22:43 +11:00
|
|
|
|
$("#acct-list").append(templete);
|
2018-06-18 00:26:45 +10:00
|
|
|
|
colorpicker(key)
|
2018-01-28 23:22:43 +11:00
|
|
|
|
});
|
2018-05-20 16:17:10 +10:00
|
|
|
|
multisel();
|
2018-01-28 23:22:43 +11:00
|
|
|
|
var acctN = localStorage.getItem("acct");
|
|
|
|
|
if (!acctN) {
|
|
|
|
|
localStorage.setItem("acct", 0);
|
|
|
|
|
var acctN = 0;
|
|
|
|
|
}
|
2018-04-07 14:31:09 +10:00
|
|
|
|
var electron = require("electron");
|
|
|
|
|
var remote=electron.remote;
|
|
|
|
|
var platform=remote.process.platform;
|
|
|
|
|
if(platform=="win32"){
|
|
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
$("#linux").prop("checked", true);
|
2018-07-29 17:37:54 +10:00
|
|
|
|
}
|
|
|
|
|
ipc.send('mkc', "");
|
|
|
|
|
ipc.on('mkcr', function (event, arg) {
|
|
|
|
|
localStorage.setItem("mkc",arg)
|
|
|
|
|
})
|
2018-01-28 23:22:43 +11:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
//最初に読む
|
|
|
|
|
load();
|
|
|
|
|
support();
|
|
|
|
|
|
2018-09-01 23:02:15 +10:00
|
|
|
|
//instances.social/instances API
|
2018-01-28 23:22:43 +11:00
|
|
|
|
function data(domain) {
|
|
|
|
|
$("#ins-upd").text("Loading...");
|
|
|
|
|
$("#ins-add").text("Loading...");
|
|
|
|
|
$("#ins-connect").text("Loading...");
|
|
|
|
|
$("#ins-toot").text("Loading...");
|
|
|
|
|
$("#ins-sys").text("Loading...");
|
|
|
|
|
$("#ins-per").text("Loading...");
|
|
|
|
|
$("#ins-user").text("Loading...");
|
|
|
|
|
$("#ins-ver").text("Loading...");
|
2018-04-07 14:31:09 +10:00
|
|
|
|
$("#ins-name").text("Loading...");
|
2018-01-28 23:22:43 +11:00
|
|
|
|
$("#ins-prof").attr('src', "./img/loading.svg");
|
|
|
|
|
var start = "https://instances.social/api/1.0/instances/show?name=" + domain;
|
|
|
|
|
fetch(start, {
|
|
|
|
|
method: 'GET',
|
|
|
|
|
headers: {
|
|
|
|
|
'content-type': 'application/json',
|
|
|
|
|
'Authorization': 'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M'
|
|
|
|
|
},
|
|
|
|
|
}).then(function(response) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}).catch(function(error) {
|
|
|
|
|
todo(error);
|
|
|
|
|
console.error(error);
|
|
|
|
|
}).then(function(json) {
|
|
|
|
|
console.log(json);
|
|
|
|
|
if (!json.error) {
|
2018-04-07 14:31:09 +10:00
|
|
|
|
$("#ins-name").text(json.name);
|
2018-01-28 23:22:43 +11:00
|
|
|
|
$("#ins-upd").text(date(json.checked_at, 'full'));
|
|
|
|
|
$("#ins-add").text(date(json.added_at, 'full'));
|
|
|
|
|
$("#ins-connect").text(json.connections);
|
|
|
|
|
$("#ins-toot").text(json.statuses);
|
|
|
|
|
$("#ins-sys").text(date(json.updated_at, 'full'));
|
|
|
|
|
$("#ins-per").text(json.uptime * 100);
|
|
|
|
|
$("#ins-user").text(json.users);
|
|
|
|
|
$("#ins-ver").text(json.version);
|
|
|
|
|
}
|
|
|
|
|
});
|
2018-09-01 23:02:15 +10:00
|
|
|
|
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) {
|
2018-09-10 03:06:00 +10:00
|
|
|
|
$("#ins-title").text(json.title);
|
|
|
|
|
$("#ins-desc").html(json.description);
|
2018-09-01 23:02:15 +10:00
|
|
|
|
$("#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);
|
2018-09-10 03:06:00 +10:00
|
|
|
|
$("#ins-admin").text(json.contact_account.username);
|
|
|
|
|
$("#ins-admin").text(json.contact_account.display_name+"("+json.contact_account.acct+")");
|
|
|
|
|
$("#ins-admin").attr("href","index.html?mode=user&code="+json.contact_account.username+"@"+domain);
|
2018-09-01 23:02:15 +10:00
|
|
|
|
}
|
|
|
|
|
});
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//アカウントデータ 消す
|
|
|
|
|
function multiDel(target) {
|
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
|
var obj = JSON.parse(multi);
|
2018-07-07 03:51:48 +10:00
|
|
|
|
//削除確認ダイアログ
|
2018-07-29 17:37:54 +10:00
|
|
|
|
if (confirm(obj[target]["user"] + "@" + obj[target]["domain"] +lang_manager_confirm[lang])) {
|
2018-07-07 03:51:48 +10:00
|
|
|
|
Object.keys(obj).forEach(function(key) {
|
|
|
|
|
var nk=key-1;
|
|
|
|
|
//公開範囲(差分のみ)
|
|
|
|
|
if(key>=target){
|
|
|
|
|
var oldvis=localStorage.getItem("vis-memory-"+key);
|
|
|
|
|
console.log(oldvis);
|
|
|
|
|
if(oldvis){
|
|
|
|
|
localStorage.setItem("vis-memory-"+nk,oldvis);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//独自ロケール
|
|
|
|
|
localStorage.removeItem("home_" + key);
|
|
|
|
|
localStorage.removeItem("local_" + key);
|
|
|
|
|
localStorage.removeItem("public_" + key);
|
|
|
|
|
localStorage.removeItem("notification_" + key);
|
|
|
|
|
//アクセストークンとドメイン、プロフ(差分)
|
|
|
|
|
if(key>target){
|
|
|
|
|
var olddom=localStorage.getItem("domain_"+key);
|
|
|
|
|
localStorage.setItem("domain_"+nk,olddom);
|
|
|
|
|
var oldat=localStorage.getItem("acct_"+key+"_at");
|
|
|
|
|
localStorage.setItem("acct_"+nk+"_at",oldat);
|
|
|
|
|
localStorage.setItem("name_" + nk, localStorage.getItem("name_" + key));
|
|
|
|
|
localStorage.setItem("user_" + target, localStorage.getItem("user_" + key));
|
|
|
|
|
localStorage.setItem("user-id_" + target, localStorage.getItem("user-id_" + key));
|
|
|
|
|
localStorage.setItem("prof_" + target, localStorage.getItem("prof_" + key));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
//とりあえず消す
|
2018-01-28 23:22:43 +11:00
|
|
|
|
obj.splice(target, 1);
|
2018-07-07 03:51:48 +10:00
|
|
|
|
console.log(obj);
|
2018-01-28 23:22:43 +11:00
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
|
localStorage.setItem("multi", json);
|
2018-07-07 03:51:48 +10:00
|
|
|
|
//カラムデータコンフリクト
|
|
|
|
|
var col = localStorage.getItem("column");
|
|
|
|
|
var oldcols = JSON.parse(col);
|
|
|
|
|
var newcols=[];
|
|
|
|
|
Object.keys(oldcols).forEach(function(key) {
|
|
|
|
|
var nk=key-1;
|
|
|
|
|
var oldcol=oldcols[key];
|
|
|
|
|
if(target<oldcol.domain){
|
|
|
|
|
var newdom=oldcol.domain-1;
|
|
|
|
|
}else{
|
|
|
|
|
var newdom=oldcol.domain;
|
|
|
|
|
}
|
|
|
|
|
var type=oldcol.type;
|
|
|
|
|
//消した垢のコラムじゃないときコピー
|
|
|
|
|
if(target!=oldcol.domain){
|
|
|
|
|
var add = {
|
|
|
|
|
domain: newdom,
|
|
|
|
|
type: type
|
|
|
|
|
};
|
|
|
|
|
newcols.push(add);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
var json = JSON.stringify(newcols);
|
|
|
|
|
localStorage.setItem("column", json);
|
|
|
|
|
load();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
function multiDel2(target) {
|
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
|
var obj = JSON.parse(multi);
|
2018-07-29 17:37:54 +10:00
|
|
|
|
if (confirm(obj[target]["user"] + "@" + obj[target]["domain"] +lang_manager_confirm[lang])) {
|
2018-07-07 03:51:48 +10:00
|
|
|
|
obj.splice(target, 1);
|
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
|
localStorage.setItem("multi", json);
|
|
|
|
|
Object.keys(obj).forEach(function(key) {
|
|
|
|
|
if(key>=target){
|
|
|
|
|
var oldvis=localStorage.getItem("vis-memory-"+key);
|
|
|
|
|
console.log(oldvis);
|
|
|
|
|
if(oldvis){
|
|
|
|
|
var nk=key-1;
|
|
|
|
|
localStorage.setItem("vis-memory-"+nk,oldvis);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
localStorage.removeItem("home_" + key);
|
|
|
|
|
localStorage.removeItem("local_" + key);
|
|
|
|
|
localStorage.removeItem("public_" + key);
|
|
|
|
|
localStorage.removeItem("notification_" + key);
|
2018-03-11 01:22:59 +11:00
|
|
|
|
refresh(key);
|
|
|
|
|
});
|
2018-07-07 03:51:48 +10:00
|
|
|
|
var col = localStorage.getItem("column");
|
|
|
|
|
if (!col) {
|
|
|
|
|
var obj = [{
|
|
|
|
|
domain: 0,
|
|
|
|
|
type: 'local'
|
|
|
|
|
}];
|
|
|
|
|
localStorage.setItem("card_0","true");
|
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
|
localStorage.setItem("column", json);
|
|
|
|
|
} else {
|
|
|
|
|
var cobj = JSON.parse(col);
|
|
|
|
|
}
|
|
|
|
|
Object.keys(cobj).forEach(function(key) {
|
|
|
|
|
var column = cobj[key];
|
|
|
|
|
if(column.domain>target){
|
|
|
|
|
var nk=key-1;
|
|
|
|
|
column.domain=nk;
|
|
|
|
|
cobj[key]=column;
|
|
|
|
|
}else if(column.domain==target){
|
|
|
|
|
localStorage.removeItem("card_" + tlid);
|
|
|
|
|
cobj.splice(key, 1);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
var json = JSON.stringify(column);
|
|
|
|
|
localStorage.setItem("column", json);
|
2018-01-28 23:22:43 +11:00
|
|
|
|
load();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//サポートインスタンス
|
|
|
|
|
function support() {
|
2018-06-18 00:26:45 +10:00
|
|
|
|
Object.keys(idata).forEach(function(key) {
|
|
|
|
|
var instance = idata[key];
|
2018-01-28 23:22:43 +11:00
|
|
|
|
if (instance == "instance") {
|
2018-04-01 00:55:47 +11:00
|
|
|
|
templete = '<a onclick="login(\'' + key +
|
2018-06-18 00:26:45 +10:00
|
|
|
|
'\')" class="collection-item pointer transparent">' + idata[key + "_name"] + '(' + key + ')</a>';
|
2018-01-28 23:22:43 +11:00
|
|
|
|
$("#support").append(templete);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//URL指定してポップアップ
|
|
|
|
|
function login(url) {
|
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
|
var obj = JSON.parse(multi);
|
2018-08-21 04:26:14 +10:00
|
|
|
|
if($('#misskey:checked').val()=="on"){
|
|
|
|
|
misskeyLogin(url);
|
2018-07-28 07:25:12 +10:00
|
|
|
|
return;
|
|
|
|
|
}
|
2018-03-11 01:22:59 +11:00
|
|
|
|
if($('#linux:checked').val()=="on"){
|
2018-08-17 03:21:40 +10:00
|
|
|
|
var red = "https://thedesk.top/hello.html"
|
2018-02-26 02:32:10 +11:00
|
|
|
|
}else{
|
|
|
|
|
var red = 'thedesk://manager';
|
|
|
|
|
}
|
2018-05-10 01:33:08 +10:00
|
|
|
|
console.log(red);
|
2018-02-26 02:32:10 +11:00
|
|
|
|
localStorage.setItem("redirect", red);
|
2018-01-28 23:22:43 +11:00
|
|
|
|
var start = "https://" + url + "/api/v1/apps";
|
2018-04-17 03:10:35 +10:00
|
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
|
httpreq.responseType = 'json';
|
|
|
|
|
httpreq.send(JSON.stringify({
|
|
|
|
|
scopes: 'read write follow',
|
|
|
|
|
client_name: "TheDesk(PC)",
|
|
|
|
|
redirect_uris: red,
|
|
|
|
|
website: "https://thedesk.top"
|
|
|
|
|
}));
|
|
|
|
|
httpreq.onreadystatechange = function() {
|
|
|
|
|
if (httpreq.readyState == 4) {
|
|
|
|
|
var json = httpreq.response;
|
|
|
|
|
console.log(json);
|
2018-08-21 04:26:14 +10:00
|
|
|
|
localStorage.setItem("msky","false");
|
2018-04-17 03:10:35 +10:00
|
|
|
|
var auth = "https://" + url + "/oauth/authorize?client_id=" + json[
|
|
|
|
|
"client_id"] + "&client_secret=" + json["client_secret"] +
|
2018-08-17 03:21:40 +10:00
|
|
|
|
"&response_type=code&scope=read+write+follow&redirect_uri=" + encodeURIComponent(red);
|
2018-04-17 03:10:35 +10:00
|
|
|
|
localStorage.setItem("domain_tmp", url);
|
|
|
|
|
localStorage.setItem("client_id", json["client_id"]);
|
|
|
|
|
localStorage.setItem("client_secret", json["client_secret"]);
|
|
|
|
|
$("#auth").show();
|
|
|
|
|
$("#add").hide();
|
|
|
|
|
const {
|
|
|
|
|
shell
|
|
|
|
|
} = require('electron');
|
2018-08-21 04:26:14 +10:00
|
|
|
|
|
2018-04-17 03:10:35 +10:00
|
|
|
|
shell.openExternal(auth);
|
|
|
|
|
var electron = require("electron");
|
|
|
|
|
var ipc = electron.ipcRenderer;
|
|
|
|
|
if ($('#linux:checked').val() == "on") {} else {
|
2018-02-26 02:32:10 +11:00
|
|
|
|
ipc.send('quit', 'go');
|
|
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-07-28 07:25:12 +10:00
|
|
|
|
}
|
|
|
|
|
//これが後のMisskeyである。
|
2018-08-21 04:26:14 +10:00
|
|
|
|
function misskeyLogin(url) {
|
|
|
|
|
if(!url){
|
|
|
|
|
var url=$("#misskey-url").val();
|
|
|
|
|
}
|
2018-07-28 07:25:12 +10:00
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
|
var obj = JSON.parse(multi);
|
2018-08-21 04:26:14 +10:00
|
|
|
|
var start = "https://"+url+"/api/auth/session/generate";
|
2018-07-28 07:25:12 +10:00
|
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
|
httpreq.responseType = 'json';
|
2018-08-23 03:29:39 +10:00
|
|
|
|
localStorage.setItem("msky","true");
|
2018-08-21 04:26:14 +10:00
|
|
|
|
if(url=="misskey.xyz"){
|
|
|
|
|
var mkc=localStorage.getItem("mkc");
|
|
|
|
|
}else{
|
|
|
|
|
var mkc=$("#misskey-key").val();
|
2018-08-23 03:29:39 +10:00
|
|
|
|
localStorage.setItem("mkc",mkc)
|
2018-08-21 04:26:14 +10:00
|
|
|
|
if(!mkc){
|
|
|
|
|
$("#misskeylogin").show();
|
|
|
|
|
$("#misskey-url").val(url);
|
|
|
|
|
if(confirm(lang_manager_godev[lang])){
|
|
|
|
|
const {
|
|
|
|
|
shell
|
|
|
|
|
} = require('electron');
|
|
|
|
|
console.log("https://"+url+"/dev")
|
|
|
|
|
shell.openExternal("https://"+url+"/dev");
|
|
|
|
|
shell.openExternal("https://thedesk.top/how-to-login-misskey.html");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}else{
|
|
|
|
|
$("#misskeylogin").hide();
|
|
|
|
|
$("#misskey-url").val("");
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-07-28 07:25:12 +10:00
|
|
|
|
httpreq.send(JSON.stringify({
|
2018-08-21 04:26:14 +10:00
|
|
|
|
appSecret: mkc
|
2018-07-28 07:25:12 +10:00
|
|
|
|
}));
|
|
|
|
|
httpreq.onreadystatechange = function() {
|
|
|
|
|
if (httpreq.readyState == 4) {
|
|
|
|
|
var json = httpreq.response;
|
|
|
|
|
console.log(json);
|
|
|
|
|
const {
|
|
|
|
|
shell
|
|
|
|
|
} = require('electron');
|
2018-07-30 21:03:49 +10:00
|
|
|
|
var token=json.token;
|
2018-07-28 07:25:12 +10:00
|
|
|
|
$("#auth").show();
|
2018-07-30 21:03:49 +10:00
|
|
|
|
$("#code").val(token);
|
2018-07-28 07:25:12 +10:00
|
|
|
|
$("#add").hide();
|
2018-08-21 04:26:14 +10:00
|
|
|
|
localStorage.setItem("domain_tmp",url);
|
2018-07-30 21:03:49 +10:00
|
|
|
|
shell.openExternal(json.url);
|
2018-07-28 07:25:12 +10:00
|
|
|
|
var electron = require("electron");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//テキストボックスにURL入れた
|
|
|
|
|
function instance() {
|
|
|
|
|
var url = $("#url").val();
|
2018-08-21 04:26:14 +10:00
|
|
|
|
if(url.indexOf("@")!=-1 || url.indexOf("https")!=-1){
|
|
|
|
|
alert("入力形式が違います。(Cutls@mstdn.jpにログインする場合、入力するのは\"mstdn.jp\"です。)")
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
login(url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//コード入れてAccessTokenゲット
|
2018-02-18 16:43:11 +11:00
|
|
|
|
function code(code) {
|
2018-02-26 02:32:10 +11:00
|
|
|
|
localStorage.removeItem("redirect")
|
2018-02-18 16:43:11 +11:00
|
|
|
|
if(!code){
|
|
|
|
|
var code = $("#code").val();
|
2018-08-21 04:26:14 +10:00
|
|
|
|
$("#code").val("");
|
2018-02-18 16:43:11 +11:00
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
var url = localStorage.getItem("domain_tmp");
|
|
|
|
|
localStorage.removeItem("domain_tmp");
|
2018-08-23 03:29:39 +10:00
|
|
|
|
console.log(localStorage.getItem("msky"));
|
2018-08-21 04:26:14 +10:00
|
|
|
|
if(localStorage.getItem("msky")=="true"){
|
|
|
|
|
var start = "https://"+url+"/api/auth/session/userkey";
|
2018-07-30 21:03:49 +10:00
|
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
|
httpreq.responseType = 'json';
|
|
|
|
|
httpreq.send(JSON.stringify({
|
|
|
|
|
token:code,
|
|
|
|
|
appSecret:localStorage.getItem("mkc")
|
|
|
|
|
}));
|
|
|
|
|
httpreq.onreadystatechange = function() {
|
|
|
|
|
if (httpreq.readyState == 4) {
|
|
|
|
|
var json = httpreq.response;
|
|
|
|
|
var i = sha256(json.accessToken + localStorage.getItem("mkc"));
|
|
|
|
|
console.log(json);
|
|
|
|
|
var avatar=json["user"]["avatarUrl"];
|
|
|
|
|
var priv="public";
|
|
|
|
|
var add = {
|
|
|
|
|
at: i,
|
|
|
|
|
name: json["user"]["name"],
|
2018-08-21 04:26:14 +10:00
|
|
|
|
domain: url,
|
2018-07-30 21:03:49 +10:00
|
|
|
|
user: json["user"]["username"],
|
|
|
|
|
prof: avatar,
|
|
|
|
|
id: json["user"]["id"],
|
2018-08-21 04:26:14 +10:00
|
|
|
|
vis: priv,
|
|
|
|
|
mode: "misskey"
|
2018-07-30 21:03:49 +10:00
|
|
|
|
};
|
2018-08-23 03:29:39 +10:00
|
|
|
|
localStorage.setItem("mode_" + url,"misskey")
|
2018-07-30 21:03:49 +10:00
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
|
var obj = JSON.parse(multi);
|
|
|
|
|
var target = obj.lengtth;
|
|
|
|
|
obj.push(add);
|
|
|
|
|
localStorage.setItem("name_" + target, json["user"]["name"]);
|
|
|
|
|
localStorage.setItem("user_" + target, json["user"]["username"]);
|
|
|
|
|
localStorage.setItem("user-id_" + target, json["user"]["id"]);
|
|
|
|
|
localStorage.setItem("prof_" + target, avatar);
|
|
|
|
|
console.log(obj);
|
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
|
localStorage.setItem("multi", json);
|
|
|
|
|
|
|
|
|
|
load();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return;
|
2018-08-17 03:21:40 +10:00
|
|
|
|
}else{
|
|
|
|
|
var start = "https://" + url + "/oauth/token";
|
|
|
|
|
var id = localStorage.getItem("client_id");
|
|
|
|
|
var secret = localStorage.getItem("client_secret");
|
|
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
|
httpreq.responseType = 'json';
|
|
|
|
|
httpreq.send(JSON.stringify({
|
|
|
|
|
grant_type: "authorization_code",
|
|
|
|
|
redirect_uri: "https://thedesk.top/hello.html",
|
|
|
|
|
client_id: id,
|
|
|
|
|
client_secret: secret,
|
|
|
|
|
code: code
|
|
|
|
|
}));
|
|
|
|
|
httpreq.onreadystatechange = function() {
|
|
|
|
|
if (httpreq.readyState == 4) {
|
|
|
|
|
var json = httpreq.response;
|
|
|
|
|
console.log(json);
|
|
|
|
|
if (json["access_token"]) {
|
|
|
|
|
$("#auth").hide();
|
|
|
|
|
$("#add").show();
|
|
|
|
|
getdata(url, json["access_token"]);
|
|
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
2018-04-17 03:10:35 +10:00
|
|
|
|
}
|
2018-08-17 03:21:40 +10:00
|
|
|
|
|
2018-01-28 23:22:43 +11:00
|
|
|
|
}
|
|
|
|
|
//ユーザーデータ取得
|
|
|
|
|
function getdata(domain, at) {
|
|
|
|
|
var start = "https://" + domain + "/api/v1/accounts/verify_credentials";
|
|
|
|
|
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) {
|
|
|
|
|
console.log(json);
|
|
|
|
|
if (json.error) {
|
|
|
|
|
console.error("Error:" + json.error);
|
2018-07-29 17:37:54 +10:00
|
|
|
|
Materialize.toast(lang_fatalerroroccured[lang]+"Error:" + json.error,
|
2018-01-28 23:22:43 +11:00
|
|
|
|
5000);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-03-31 13:39:06 +11:00
|
|
|
|
var avatar=json["avatar"];
|
|
|
|
|
//missingがmissingなやつ
|
|
|
|
|
if(avatar=="/avatars/original/missing.png"){
|
|
|
|
|
avatar="./img/missing.svg";
|
|
|
|
|
}
|
2018-07-07 03:51:48 +10:00
|
|
|
|
if(json["source"]){
|
|
|
|
|
var priv=json["source"]["privacy"];
|
|
|
|
|
}else{
|
|
|
|
|
var priv="public";
|
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
var add = {
|
|
|
|
|
at: at,
|
|
|
|
|
name: json["display_name"],
|
|
|
|
|
domain: domain,
|
|
|
|
|
user: json["acct"],
|
2018-03-31 13:39:06 +11:00
|
|
|
|
prof: avatar,
|
2018-06-18 00:26:45 +10:00
|
|
|
|
id: json["id"],
|
2018-08-21 04:26:14 +10:00
|
|
|
|
vis: priv,
|
|
|
|
|
mode: "mastodon"
|
2018-01-28 23:22:43 +11:00
|
|
|
|
};
|
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
|
var obj = JSON.parse(multi);
|
2018-02-17 00:08:43 +11:00
|
|
|
|
var target = obj.lengtth;
|
2018-01-28 23:22:43 +11:00
|
|
|
|
obj.push(add);
|
2018-02-17 00:08:43 +11:00
|
|
|
|
localStorage.setItem("name_" + target, json["display_name"]);
|
|
|
|
|
localStorage.setItem("user_" + target, json["acct"]);
|
|
|
|
|
localStorage.setItem("user-id_" + target, json["id"]);
|
2018-03-31 13:39:06 +11:00
|
|
|
|
localStorage.setItem("prof_" + target, avatar);
|
2018-01-28 23:22:43 +11:00
|
|
|
|
console.log(obj);
|
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
|
localStorage.setItem("multi", json);
|
|
|
|
|
load();
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ユーザーデータ更新
|
|
|
|
|
function refresh(target) {
|
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
|
var obj = JSON.parse(multi);
|
2018-08-21 04:26:14 +10:00
|
|
|
|
if(obj[target].mode=="misskey"){
|
|
|
|
|
misskeyRefresh(obj,target,obj[target].domain);
|
2018-07-30 21:03:49 +10:00
|
|
|
|
return
|
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
var start = "https://" + obj[target].domain +
|
|
|
|
|
"/api/v1/accounts/verify_credentials";
|
2018-02-17 00:08:43 +11:00
|
|
|
|
console.log(start);
|
2018-01-28 23:22:43 +11:00
|
|
|
|
fetch(start, {
|
|
|
|
|
method: 'GET',
|
|
|
|
|
headers: {
|
|
|
|
|
'content-type': 'application/json',
|
|
|
|
|
'Authorization': 'Bearer ' + obj[target].at
|
|
|
|
|
},
|
|
|
|
|
}).then(function(response) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}).catch(function(error) {
|
|
|
|
|
todo(error);
|
|
|
|
|
console.error(error);
|
|
|
|
|
}).then(function(json) {
|
|
|
|
|
console.log(json);
|
|
|
|
|
if (json.error) {
|
|
|
|
|
console.error("Error:" + json.error);
|
2018-07-29 17:37:54 +10:00
|
|
|
|
Materialize.toast(lang_fatalerroroccured[lang]+"Error:" + json.error,
|
2018-01-28 23:22:43 +11:00
|
|
|
|
5000);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-03-31 13:39:06 +11:00
|
|
|
|
var avatar=json["avatar"];
|
|
|
|
|
//missingがmissingなやつ
|
2018-04-07 14:31:09 +10:00
|
|
|
|
if(avatar=="/avatars/original/missing.png" || !avatar){
|
2018-03-31 13:39:06 +11:00
|
|
|
|
avatar="./img/missing.svg";
|
|
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
|
var ref = {
|
|
|
|
|
at: obj[target].at,
|
|
|
|
|
name: json["display_name"],
|
|
|
|
|
domain: obj[target].domain,
|
|
|
|
|
user: json["acct"],
|
2018-03-31 13:39:06 +11:00
|
|
|
|
prof: avatar,
|
2018-06-18 00:26:45 +10:00
|
|
|
|
id: json["id"],
|
|
|
|
|
vis: json["source"]["privacy"]
|
2018-01-28 23:22:43 +11:00
|
|
|
|
};
|
2018-02-17 00:08:43 +11:00
|
|
|
|
localStorage.setItem("name_" + target, json["display_name"]);
|
|
|
|
|
localStorage.setItem("user_" + target, json["acct"]);
|
|
|
|
|
localStorage.setItem("user-id_" + target, json["id"]);
|
|
|
|
|
console.log("user-id_" + target+":"+json["id"])
|
2018-02-18 05:44:20 +11:00
|
|
|
|
console.log(localStorage.getItem("user-id_"+target));
|
2018-03-31 13:39:06 +11:00
|
|
|
|
localStorage.setItem("prof_" + target, avatar);
|
2018-01-28 23:22:43 +11:00
|
|
|
|
obj[target] = ref;
|
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
|
localStorage.setItem("multi", json);
|
|
|
|
|
|
|
|
|
|
load();
|
|
|
|
|
});
|
|
|
|
|
}
|
2018-08-21 04:26:14 +10:00
|
|
|
|
function misskeyRefresh(obj,target,url){
|
|
|
|
|
var start = "https://"+url+"/api/users/show";
|
2018-07-30 21:03:49 +10:00
|
|
|
|
var httpreq = new XMLHttpRequest();
|
|
|
|
|
httpreq.open('POST', start, true);
|
|
|
|
|
httpreq.setRequestHeader('Content-Type', 'application/json');
|
|
|
|
|
httpreq.responseType = 'json';
|
|
|
|
|
httpreq.send(JSON.stringify({
|
|
|
|
|
username:obj[target].user,
|
|
|
|
|
i:localStorage.getItem("at")
|
|
|
|
|
}));
|
|
|
|
|
httpreq.onreadystatechange = function() {
|
|
|
|
|
if (httpreq.readyState == 4) {
|
|
|
|
|
var json = httpreq.response;
|
|
|
|
|
console.log(json);
|
|
|
|
|
return;
|
|
|
|
|
var avatar=json["user"]["avatarURL"];
|
|
|
|
|
var priv="public";
|
|
|
|
|
var add = {
|
|
|
|
|
at: json.accessToken,
|
|
|
|
|
name: json["user"]["name"],
|
2018-08-21 04:26:14 +10:00
|
|
|
|
domain: url,
|
2018-07-30 21:03:49 +10:00
|
|
|
|
user: json["user"]["username"],
|
|
|
|
|
prof: avatar,
|
|
|
|
|
id: json["user"]["id"],
|
|
|
|
|
vis: priv
|
|
|
|
|
};
|
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
|
var obj = JSON.parse(multi);
|
|
|
|
|
var target = obj.lengtth;
|
|
|
|
|
obj.push(add);
|
|
|
|
|
localStorage.setItem("name_" + target, json["user"]["name"]);
|
|
|
|
|
localStorage.setItem("user_" + target, json["user"]["username"]);
|
|
|
|
|
localStorage.setItem("user-id_" + target, json["user"]["id"]);
|
|
|
|
|
localStorage.setItem("prof_" + target, avatar);
|
|
|
|
|
console.log(obj);
|
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
|
localStorage.setItem("multi", json);
|
|
|
|
|
load();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-05-20 16:17:10 +10:00
|
|
|
|
//アカウントを選択…を実装
|
|
|
|
|
function multisel() {
|
|
|
|
|
var multi = localStorage.getItem("multi");
|
|
|
|
|
if (!multi) {
|
|
|
|
|
var obj = [];
|
|
|
|
|
var json = JSON.stringify(obj);
|
|
|
|
|
localStorage.setItem("multi", json);
|
|
|
|
|
} else {
|
|
|
|
|
var obj = JSON.parse(multi);
|
|
|
|
|
}
|
|
|
|
|
var templete;
|
|
|
|
|
var last = localStorage.getItem("main");
|
|
|
|
|
var sel;
|
|
|
|
|
console.log(obj.length)
|
|
|
|
|
if(obj.length<1){
|
|
|
|
|
$("#src-acct-sel").html('<option value="tootsearch">Tootsearch</option>');
|
2018-07-29 17:37:54 +10:00
|
|
|
|
$("#add-acct-sel").html('<option value="noauth">'+lang_login_noauth[lang]+'</option>');
|
2018-05-20 16:17:10 +10:00
|
|
|
|
}else{
|
|
|
|
|
Object.keys(obj).forEach(function(key) {
|
|
|
|
|
var acct = obj[key];
|
|
|
|
|
var list = key * 1 + 1;
|
|
|
|
|
if (key == last) {
|
|
|
|
|
sel = "selected";
|
2018-07-30 03:35:29 +10:00
|
|
|
|
mainb='('+lang_manager_def[lang]+')'
|
2018-05-20 16:17:10 +10:00
|
|
|
|
var domain = localStorage.getItem("domain_" + key);
|
|
|
|
|
var profimg=localStorage.getItem("prof_"+key);
|
|
|
|
|
var domain=localStorage.getItem("domain_"+key);
|
|
|
|
|
if(!profimg){
|
|
|
|
|
profimg="./img/missing.svg";
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
sel = "";
|
|
|
|
|
mainb=""
|
|
|
|
|
}
|
|
|
|
|
templete = '<option value="' + key + '" data-icon="' + acct.prof +
|
|
|
|
|
'" class="left circle" ' + sel + '>' + acct.user + '@' + acct.domain +mainb+
|
|
|
|
|
'</option>';
|
|
|
|
|
$(".acct-sel").append(templete);
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
$('select').material_select('update');
|
|
|
|
|
}
|
|
|
|
|
function mainacct(){
|
|
|
|
|
var acct_id = $("#main-acct-sel").val();
|
|
|
|
|
localStorage.setItem("main", acct_id);
|
2018-07-29 17:37:54 +10:00
|
|
|
|
Materialize.toast(lang_manager_mainAcct[lang], 3000);
|
2018-06-18 00:26:45 +10:00
|
|
|
|
}
|
|
|
|
|
function colorpicker(key){
|
|
|
|
|
temp=
|
2018-07-30 03:35:29 +10:00
|
|
|
|
'<div onclick="coloradd('+key+',\'def\',\'def\')" class="pointer exc">'+lang_manager_none[lang]+'</div>'+
|
2018-06-18 00:26:45 +10:00
|
|
|
|
'<div onclick="coloradd('+key+',\'f44336\',\'white\')" class="red white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'e91e63\',\'white\')" class="pink white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'9c27b0\',\'white\')" class="purple white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'673ab7\',\'white\')" class="deep-purple white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'3f51b5\',\'white\')" class="indigo white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'2196f3\',\'white\')" class="blue white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'03a9f4\',\'black\')" class="light-blue black-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'00bcd4\',\'black\')" class="cyan black-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'009688\',\'white\')" class="teal white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'4caf50\',\'black\')" class="green black-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'8bc34a\',\'black\')" class="light-green black-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'cddc39\',\'black\')" class="lime black-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'ffeb3b\',\'black\')" class="yellow black-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'ffc107\',\'black\')" class="amber black-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'ff9800\',\'black\')" class="orange black-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'ff5722\',\'white\')" class="deep-orange white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'795548\',\'white\')" class="brown white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'9e9e9e\',\'white\')" class="grey white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'607d8b\',\'white\')" class="blue-grey white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'000000\',\'white\')" class="black white-text pointer"></div>'+
|
|
|
|
|
'<div onclick="coloradd('+key+',\'ffffff\',\'black\')" class="white black-text pointer"></div>';
|
|
|
|
|
$("#colorsel_"+key).html(temp);
|
|
|
|
|
}
|
|
|
|
|
function coloradd(key,bg,txt){
|
|
|
|
|
var col = localStorage.getItem("multi");
|
|
|
|
|
var o = JSON.parse(col);
|
|
|
|
|
var obj=o[key];
|
|
|
|
|
obj.background=bg;
|
|
|
|
|
obj.text=txt;
|
|
|
|
|
o[key]=obj;
|
|
|
|
|
var json = JSON.stringify(o);
|
|
|
|
|
localStorage.setItem("multi", json);
|
|
|
|
|
if(txt=="def"){
|
|
|
|
|
$("#acct_"+key).attr("style","")
|
|
|
|
|
}else{
|
|
|
|
|
$("#acct_"+key).css('background-color','#'+bg);
|
|
|
|
|
if(txt=="black"){
|
|
|
|
|
var bghex="000000";
|
|
|
|
|
var ichex="9e9e9e"
|
|
|
|
|
}else if(txt=="white"){
|
|
|
|
|
var bghex="ffffff";
|
|
|
|
|
var ichex="eeeeee"
|
|
|
|
|
}
|
|
|
|
|
$("#acct_"+key+" .nex").css('color','#'+ichex);
|
|
|
|
|
$("#acct_"+key).css('color','#'+bghex);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//入力時にハッシュタグと@をサジェスト
|
|
|
|
|
var timer = null;
|
|
|
|
|
|
|
|
|
|
var input = document.getElementById("url");
|
|
|
|
|
|
|
|
|
|
var prev_val = input.value;
|
|
|
|
|
var oldSuggest;
|
|
|
|
|
var suggest;
|
|
|
|
|
input.addEventListener("focus", function() {
|
|
|
|
|
$("#ins-suggest").html("");
|
|
|
|
|
window.clearInterval(timer);
|
|
|
|
|
timer = window.setInterval(function() {
|
|
|
|
|
var new_val = input.value;
|
|
|
|
|
if (prev_val != new_val) {
|
|
|
|
|
if (new_val.length > 3) {
|
|
|
|
|
var start = "https://instances.social/api/1.0/instances/search?q=" +
|
|
|
|
|
new_val;
|
|
|
|
|
fetch(start, {
|
|
|
|
|
method: 'GET',
|
|
|
|
|
headers: {
|
|
|
|
|
'content-type': 'application/json',
|
|
|
|
|
'Authorization': 'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M'
|
|
|
|
|
},
|
|
|
|
|
}).then(function(response) {
|
|
|
|
|
return response.json();
|
|
|
|
|
}).catch(function(error) {
|
|
|
|
|
todo(error);
|
|
|
|
|
console.error(error);
|
|
|
|
|
}).then(function(json) {
|
|
|
|
|
console.log(json);
|
|
|
|
|
if (!json.error) {
|
|
|
|
|
|
2018-07-29 17:37:54 +10:00
|
|
|
|
var urls = "Suggest:";
|
2018-06-18 00:26:45 +10:00
|
|
|
|
Object.keys(json.instances).forEach(function(key) {
|
|
|
|
|
var url = json.instances[key];
|
|
|
|
|
urls = urls + ' <a onclick="login(\'' + url.name +
|
|
|
|
|
'\')" class="pointer">' + url.name + '</a> ';
|
|
|
|
|
});
|
|
|
|
|
$("#ins-suggest").html(urls);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
oldSuggest = suggest;
|
|
|
|
|
prev_value = new_val;
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|
|
|
|
|
}, false);
|
|
|
|
|
|
|
|
|
|
input.addEventListener("blur", function() {
|
|
|
|
|
window.clearInterval(timer);
|
2018-08-21 04:26:14 +10:00
|
|
|
|
}, false);
|