TheDesk Mizuki (ver.7)

This commit is contained in:
cutls 2018-04-17 02:10:35 +09:00
parent 223296a4cd
commit b0c8c972e6
15 changed files with 489 additions and 518 deletions

View File

@ -1,18 +1,17 @@
## For Astarte(kirishima.cloud), My Primary Instance ## For Astarte(kirishima.cloud), My Primary Instance
TheDesk :thedesk: Mizuki (ver.6) TheDesk :thedesk: Mizuki (ver.7)
・リストに関するバグを修正 【重要】
・サポートインスタンスに関する修正 このアップデートは必ず適用して下さい。
・カラーテーマ追加 理由:インスタンスにログインできない、トゥートができない等の問題を修正しています。
ほか
https://thedesk.top https://thedesk.top
:github: https://github.com/cutls/TheDesk #Desk #DeskUpdate :github: https://github.com/cutls/TheDesk #Desk #DeskUpdate
## For Other Instances ## For Other Instances
PCクライアントTheDesk :thedesk: Mizuki (ver.6) PCクライアントTheDesk :thedesk: Mizuki (ver.7)
・リストに関するバグを修正 【重要】このトゥートは重要な事項を含むため他のインスタンスでもトゥートされます。
・サポートインスタンスに関する修正 このアップデートは必ず適用して下さい。
・カラーテーマ追加 理由:インスタンスにログインできない、トゥートができない等の問題を修正しています。
TheDeskはマルチカラムマルチアカウントはもちろんのことなにかとマストドンライフをシンプルに効率化するクライアントです。 TheDeskはマルチカラムマルチアカウントはもちろんのことなにかとマストドンライフをシンプルに効率化するクライアントです。
https://thedesk.top https://thedesk.top

View File

@ -26,7 +26,7 @@
<script type="text/javascript" src="./js/ui/jquery-ui.min.js"></script> <script type="text/javascript" src="./js/ui/jquery-ui.min.js"></script>
<script> <script>
//必ずアプデ時のremove instance消して //必ずアプデ時のremove instance消して
var ver="Mizuki (ver.6)"; var ver="Mizuki (ver.7)";
//betaを入れるとバージョンチェックしない //betaを入れるとバージョンチェックしない
//var ver="beta"; //var ver="beta";
var acct_id=0; var acct_id=0;
@ -336,7 +336,8 @@ var tlid=0;
<input type="text" id="cw-text" placeholder="警告文" class="mize"> <input type="text" id="cw-text" placeholder="警告文" class="mize">
</div> </div>
<div class="col s1 mize" style="padding:0;"> <div class="col s1 mize" style="padding:0;">
<i class="material-icons pointer" onclick="fileselect()" title="ファイルを選択">photo_library</i> <span id="imgup"></span>
<span id="imgsel"><i class="material-icons pointer" onclick="fileselect()" title="ファイルを選択">photo_library</i><span id="imgup"></span>
</div> </div>
<div class="col s3 mize"> <div class="col s3 mize">
<button class="btn waves-effect blue darken-3" style="width:100%; padding:0; margin-top:0;" id="cw" onclick="cw()" title="コンテンツワーニング(トゥートを表示する前にメッセージで隠す)(青:OFF)">CW</button> <button class="btn waves-effect blue darken-3" style="width:100%; padding:0; margin-top:0;" id="cw" onclick="cw()" title="コンテンツワーニング(トゥートを表示する前にメッセージで隠す)(青:OFF)">CW</button>
@ -448,16 +449,16 @@ var tlid=0;
<ul class="collapsible" data-collapsible="accordion" id="det-col"> <ul class="collapsible" data-collapsible="accordion" id="det-col">
<li> <li>
<div class="collapsible-header"> <div class="collapsible-header">
<i class="material-icons">arrow_upward</i>これよりあとのコンテクスト <i class="material-icons">arrow_upward</i>これより前の会話
</div> </div>
<div class="collapsible-body toot-reset" id="toot-after"> <div class="collapsible-body toot-reset" id="toot-reply">
</div> </div>
</li> </li>
<li> <li>
<div class="collapsible-header"> <div class="collapsible-header">
<i class="material-icons">reply_all</i>このトゥートからのリプライ <i class="material-icons">arrow_downward</i>これよりあとの会話
</div> </div>
<div class="collapsible-body toot-reset" id="toot-reply"> <div class="collapsible-body toot-reset" id="toot-after">
</div> </div>
</li> </li>
<li> <li>
@ -537,7 +538,7 @@ var tlid=0;
<span class="cbadge">フォロワー: <span class="cbadge">フォロワー:
<span id="his-follower"></span> <span id="his-follower"></span>
</span> </span>
<span class="cbadge">Since: <span class="cbadge" style="max-width:150px; width:150px; ">Since:
<span id="his-since"></span> <span id="his-since"></span>
</div> </div>
<div class="his-float"> <div class="his-float">

View File

@ -13,7 +13,8 @@ input.addEventListener("focus", function() {
var new_val = input.value; var new_val = input.value;
if (prev_val != new_val) { if (prev_val != new_val) {
if (new_val.length > 3) { if (new_val.length > 3) {
var start = "https://instances.social/api/1.0/instances/search?q=" + new_val; var start = "https://instances.social/api/1.0/instances/search?q=" +
new_val;
fetch(start, { fetch(start, {
method: 'GET', method: 'GET',
headers: { headers: {
@ -32,7 +33,8 @@ input.addEventListener("focus", function() {
var urls = "もしかして:"; var urls = "もしかして:";
Object.keys(json.instances).forEach(function(key) { Object.keys(json.instances).forEach(function(key) {
var url = json.instances[key]; var url = json.instances[key];
urls = urls + ' <a onclick="login(\'' + url.name + '\')" class="pointer">' + url.name + '</a> '; urls = urls + ' <a onclick="login(\'' + url.name +
'\')" class="pointer">' + url.name + '</a> ';
}); });
$("#ins-suggest").html(urls); $("#ins-suggest").html(urls);
} }

View File

@ -106,23 +106,20 @@ function login(url) {
} }
localStorage.setItem("redirect", red); localStorage.setItem("redirect", red);
var start = "https://" + url + "/api/v1/apps"; var start = "https://" + url + "/api/v1/apps";
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json' httpreq.responseType = 'json';
}, httpreq.send(JSON.stringify({
body: JSON.stringify({
scopes: 'read write follow', scopes: 'read write follow',
client_name: "TheDesk(PC)", client_name: "TheDesk(PC)",
redirect_uris: red, redirect_uris: red,
website: "https://thedesk.top" website: "https://thedesk.top"
}) }));
}).then(function(response) { httpreq.onreadystatechange = function() {
return response.json(); if (httpreq.readyState == 4) {
}).catch(function(error) { var json = httpreq.response;
todo(error); console.log(json);
console.error(error);
}).then(function(json) {
var auth = "https://" + url + "/oauth/authorize?client_id=" + json[ var auth = "https://" + url + "/oauth/authorize?client_id=" + json[
"client_id"] + "&client_secret=" + json["client_secret"] + "client_id"] + "&client_secret=" + json["client_secret"] +
"&response_type=code&redirect_uri="+red+"&scope=read+write+follow"; "&response_type=code&redirect_uri="+red+"&scope=read+write+follow";
@ -143,8 +140,8 @@ function login(url) {
var ipc = electron.ipcRenderer; var ipc = electron.ipcRenderer;
ipc.send('quit', 'go'); ipc.send('quit', 'go');
} }
}
}); }
} }
//テキストボックスにURL入れた //テキストボックスにURL入れた

View File

@ -153,23 +153,19 @@ function login(url) {
} }
localStorage.setItem("redirect", red); localStorage.setItem("redirect", red);
var start = "https://" + url + "/api/v1/apps"; var start = "https://" + url + "/api/v1/apps";
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json' httpreq.responseType = 'json';
}, httpreq.send(JSON.stringify({
body: JSON.stringify({
scopes: 'read write follow', scopes: 'read write follow',
client_name: "TheDesk(PC)", client_name: "TheDesk(PC)",
redirect_uris: red, redirect_uris: red,
website: "https://thedesk.top" website: "https://thedesk.top"
}) }));
}).then(function(response) { httpreq.onreadystatechange = function() {
return response.json(); if (httpreq.readyState == 4) {
}).catch(function(error) { var json = httpreq.response;
todo(error);
console.error(error);
}).then(function(json) {
console.log(json); console.log(json);
var auth = "https://" + url + "/oauth/authorize?client_id=" + json[ var auth = "https://" + url + "/oauth/authorize?client_id=" + json[
"client_id"] + "&client_secret=" + json["client_secret"] + "client_id"] + "&client_secret=" + json["client_secret"] +
@ -186,12 +182,13 @@ function login(url) {
shell.openExternal(auth); shell.openExternal(auth);
var electron = require("electron"); var electron = require("electron");
var ipc = electron.ipcRenderer; var ipc = electron.ipcRenderer;
if($('#linux:checked').val()=="on"){ if ($('#linux:checked').val() == "on") {} else {
}else{
ipc.send('quit', 'go'); ipc.send('quit', 'go');
} }
}
}
});
} }
//テキストボックスにURL入れた //テキストボックスにURL入れた
@ -211,30 +208,28 @@ function code(code) {
var start = "https://" + url + "/oauth/token"; var start = "https://" + url + "/oauth/token";
var id = localStorage.getItem("client_id"); var id = localStorage.getItem("client_id");
var secret = localStorage.getItem("client_secret"); var secret = localStorage.getItem("client_secret");
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json' httpreq.responseType = 'json';
}, httpreq.send(JSON.stringify({
body: JSON.stringify({
grant_type: "authorization_code", grant_type: "authorization_code",
redirect_uri: "urn:ietf:wg:oauth:2.0:oob", redirect_uri: "urn:ietf:wg:oauth:2.0:oob",
client_id: id, client_id: id,
client_secret: secret, client_secret: secret,
code: code code: code
}) }));
}).then(function(response) { httpreq.onreadystatechange = function() {
return response.json(); if (httpreq.readyState == 4) {
}).catch(function(error) { var json = httpreq.response;
todo(error); console.log(json);
console.error(error);
}).then(function(json) {
if (json["access_token"]) { if (json["access_token"]) {
$("#auth").hide(); $("#auth").hide();
$("#add").show(); $("#add").show();
getdata(url, json["access_token"]); getdata(url, json["access_token"]);
} }
}); }
}
} }
//ユーザーデータ取得 //ユーザーデータ取得

View File

@ -107,3 +107,15 @@ function nano(){
var ipc = electron.ipcRenderer; var ipc = electron.ipcRenderer;
ipc.send('nano', ""); ipc.send('nano', "");
} }
function progshow(e) {
if (e.lengthComputable) {
var percent = e.loaded / e.total;
console.log(percent * 100);
$("#imgsel").hide();
if(percent<1){
$("#imgup").text(Math.floor(percent*100)+"%");
}else{
$("#imgup").text("処理中");
}
}
}

View File

@ -101,19 +101,15 @@ function media(b64, type, no) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/media"; var start = "https://" + domain + "/api/v1/media";
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.upload.addEventListener("progress", progshow, false);
'Authorization': 'Bearer ' + at httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
}, httpreq.responseType = 'json';
body: fd httpreq.send(fd);
}).then(function(response) { httpreq.onreadystatechange = function() {
console.log(response) if (httpreq.readyState == 4) {
return response.json(); var json = httpreq.response;
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
console.log(json); console.log(json);
var img = localStorage.getItem("img"); var img = localStorage.getItem("img");
if (json.type=="image") { if (json.type=="image") {
@ -141,8 +137,11 @@ function media(b64, type, no) {
$('select').material_select(); $('select').material_select();
$("#mec").text("あり"); $("#mec").text("あり");
Materialize.toast("ファイルアップロード後はアカウントを切り替えられません。", 1000); Materialize.toast("ファイルアップロード後はアカウントを切り替えられません。", 1000);
$("#imgup").text("");
$("#imgsel").show();
localStorage.removeItem("image"); localStorage.removeItem("image");
}); }
}
} }
//Base64からBlobへ //Base64からBlobへ
@ -163,3 +162,37 @@ function toBlob(base64, type) {
return blob; return blob;
} }
//画像を貼り付けたら…
var element = document.querySelector("#textarea");
element.addEventListener("paste", function(e){
// 画像の場合
// e.clipboardData.types.length == 0
// かつ
// e.clipboardData.types[0] == "Files"
// となっているので、それ以外を弾く
if (!e.clipboardData
|| !e.clipboardData.types
|| (e.clipboardData.types.length != 1)
|| (e.clipboardData.types[0] != "Files")) {
return true;
}
// ファイルとして得る
// (なぜかgetAsStringでは上手くいかなかった)
var imageFile = e.clipboardData.items[0].getAsFile();
// FileReaderで読み込む
var fr = new FileReader();
fr.onload = function(e) {
// onload内ではe.target.resultにbase64が入っているのであとは煮るなり焼くなり
var base64 = e.target.result;
var mediav = $("#media").val();
if(mediav){
var i=media.split(",").length;
}
media(base64, "image/png", i)
};
fr.readAsDataURL(imageFile);
// 画像以外がペーストされたときのために、元に戻しておく
});

View File

@ -36,19 +36,15 @@ function post() {
} else { } else {
var spo = ""; var spo = "";
} }
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send(JSON.stringify(toot));
body: JSON.stringify(toot) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json(); var json = httpreq.response;
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
console.log(json); console.log(json);
var box = localStorage.getItem("box"); var box = localStorage.getItem("box");
if (box == "yes") { if (box == "yes") {
@ -59,7 +55,8 @@ function post() {
} }
todc(); todc();
clear(); clear();
}); }
}
} }
//クリア(Shift+C) //クリア(Shift+C)

View File

@ -9,20 +9,15 @@ function fav(id, acct_id, remote) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag; var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag;
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send();
body: JSON.stringify({}) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json(); var json = httpreq.response;
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
console.log(json);
if(remote!="remote"){ if(remote!="remote"){
//APIのふぁぼカウントがおかしい //APIのふぁぼカウントがおかしい
if ($("[toot-id=" + id + "] .fav_ct").text() == json.favourites_count){ if ($("[toot-id=" + id + "] .fav_ct").text() == json.favourites_count){
@ -50,7 +45,8 @@ function fav(id, acct_id, remote) {
}else{ }else{
Materialize.toast("お気に入り登録しました。インスタンスが違うときは時間がかかる場合があります。", 1000); Materialize.toast("お気に入り登録しました。インスタンスが違うときは時間がかかる場合があります。", 1000);
} }
}); }
}
} }
//ブースト //ブースト
@ -63,19 +59,15 @@ function rt(id, acct_id, remote) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag; var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag;
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send();
body: JSON.stringify({}) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json(); var json = httpreq.response;
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
console.log(json); console.log(json);
if (remote != "remote") { if (remote != "remote") {
$("[toot-id=" + id + "] .fav_ct").text(json.favourites_count); $("[toot-id=" + id + "] .fav_ct").text(json.favourites_count);
@ -100,7 +92,8 @@ function rt(id, acct_id, remote) {
} else { } else {
Materialize.toast("ブーストしました。インスタンスが違うときは時間がかかる場合があります。", 1000); Materialize.toast("ブーストしました。インスタンスが違うときは時間がかかる場合があります。", 1000);
} }
}); }
}
} }
//フォロー //フォロー
@ -129,19 +122,16 @@ function follow(acct_id,remote) {
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag; var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
var ent={} var ent={}
} }
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send();
body: JSON.stringify(ent) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json(); var json = httpreq.response;
}).catch(function(error) { console.log(json);
todo(error);
console.error(error);
}).then(function(json) {
if ($("#his-data").hasClass("following")) { if ($("#his-data").hasClass("following")) {
$("#his-data").removeClass("following"); $("#his-data").removeClass("following");
$("#his-follow-btn").text("フォロー"); $("#his-follow-btn").text("フォロー");
@ -149,7 +139,8 @@ function follow(acct_id,remote) {
$("#his-data").addClass("following"); $("#his-data").addClass("following");
$("#his-follow-btn").text("フォロー解除"); $("#his-follow-btn").text("フォロー解除");
} }
}); }
}
} }
//ブロック //ブロック
@ -166,19 +157,14 @@ function block(acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag; var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send();
body: JSON.stringify({}) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json();
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
if ($("#his-data").hasClass("blocking")) { if ($("#his-data").hasClass("blocking")) {
$("#his-data").removeClass("blocking"); $("#his-data").removeClass("blocking");
$("#his-block-btn").text("ブロック"); $("#his-block-btn").text("ブロック");
@ -186,7 +172,8 @@ function block(acct_id) {
$("#his-data").addClass("blocking"); $("#his-data").addClass("blocking");
$("#his-block-btn").text("ブロック解除"); $("#his-block-btn").text("ブロック解除");
} }
}); }
}
} }
//ミュート //ミュート
@ -203,19 +190,14 @@ function mute(acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag; var start = "https://" + domain + "/api/v1/accounts/" + id + "/" + flag;
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send();
body: JSON.stringify({}) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json();
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
if ($("#his-data").hasClass("muting")) { if ($("#his-data").hasClass("muting")) {
$("#his-data").removeClass("muting"); $("#his-data").removeClass("muting");
$("#his-mute-btn").text("ミュート"); $("#his-mute-btn").text("ミュート");
@ -223,7 +205,8 @@ function mute(acct_id) {
$("#his-data").addClass("muting"); $("#his-data").addClass("muting");
$("#his-mute-btn").text("ミュート解除"); $("#his-mute-btn").text("ミュート解除");
} }
}); }
}
} }
//投稿削除 //投稿削除
@ -231,21 +214,16 @@ function del(id, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/statuses/" + id; var start = "https://" + domain + "/api/v1/statuses/" + id;
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'DELETE', httpreq.open('DELETE', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send();
}).then(function(response) { httpreq.onreadystatechange = function() {
return response.json(); if (httpreq.readyState == 4) {
}).catch(function(error) { }
todo(error); }
console.error(error);
}).then(function(json) {
//ここで消さなくてもStreamingが消す
//$("#pub_"+id).hide();
});
} }
//ピン留め //ピン留め
function pin(id, acct_id) { function pin(id, acct_id) {
@ -257,19 +235,15 @@ function pin(id, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag; var start = "https://" + domain + "/api/v1/statuses/" + id + "/" + flag;
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('DELETE', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send();
body: JSON.stringify({}) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json(); var json = httpreq.response;
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
console.log(json); console.log(json);
if ($("[toot-id=" + id + "]").hasClass("pined")) { if ($("[toot-id=" + id + "]").hasClass("pined")) {
$("[toot-id=" + id + "]").removeClass("pined"); $("[toot-id=" + id + "]").removeClass("pined");
@ -278,7 +252,8 @@ function pin(id, acct_id) {
$("[toot-id=" + id + "]").addClass("pined"); $("[toot-id=" + id + "]").addClass("pined");
$(".pin_" + id).addClass("blue-text"); $(".pin_" + id).addClass("blue-text");
} }
}); }
}
} }
//フォロリク //フォロリク
@ -286,21 +261,19 @@ function request(id, flag, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/follow_requests/" + id + "/" + flag; var start = "https://" + domain + "/api/v1/follow_requests/" + id + "/" + flag;
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send();
body: JSON.stringify({}) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json(); var json = httpreq.response;
}).catch(function(error) { console.log(json);
todo(error);
console.error(error);
}).then(function(json) {
showReq(); showReq();
}); }
}
} }
//ドメインブロック(未実装) //ドメインブロック(未実装)
@ -311,23 +284,19 @@ function domainblock(add, flag, acct_id) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/domain_blocks" var start = "https://" + domain + "/api/v1/domain_blocks"
fetch(start, { var httpreq = new XMLHttpRequest();
method: flag, httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send();
body: JSON.stringify({ httpreq.onreadystatechange = function() {
domain: add if (httpreq.readyState == 4) {
}) var json = httpreq.response;
}).then(function(response) { console.log(json);
return response.json();
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
showDom(); showDom();
}); }
}
} }
function addDomainblock() { function addDomainblock() {

View File

@ -51,24 +51,21 @@ function makeNewList(){
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/lists" var start = "https://" + domain + "/api/v1/lists"
console.log(start) console.log(start)
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send(JSON.stringify({
body: JSON.stringify({
title: text title: text
}) }));
}).then(function(response) { httpreq.onreadystatechange = function() {
return response.json(); if (httpreq.readyState == 4) {
}).catch(function(error) { var json = httpreq.response;
todo(error);
console.error(error);
}).then(function(json) {
list(); list();
$("#list-add").val("") $("#list-add").val("")
}); }
}
} }
function listShow(id,title,acct_id){ function listShow(id,title,acct_id){
localStorage.setItem("list_"+id+"_"+acct_id,title); localStorage.setItem("list_"+id+"_"+acct_id,title);
@ -164,44 +161,38 @@ function listAdd(id,user,acct_id){
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/lists/"+id+"/accounts" var start = "https://" + domain + "/api/v1/lists/"+id+"/accounts"
console.log(start) console.log(start)
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'POST', httpreq.open('POST', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send(JSON.stringify({
body: JSON.stringify({
account_ids: [user] account_ids: [user]
}) }));
}).then(function(response) { httpreq.onreadystatechange = function() {
return response.json(); if (httpreq.readyState == 4) {
}).catch(function(error) { var json = httpreq.response;
todo(error);
console.error(error);
}).then(function(json) {
hisList(user,acct_id) hisList(user,acct_id)
}); }
}
} }
function listRemove(id,user,acct_id){ function listRemove(id,user,acct_id){
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/lists/"+id+"/accounts" var start = "https://" + domain + "/api/v1/lists/"+id+"/accounts"
console.log(start) console.log(start)
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'DELETE', httpreq.open('DELETE', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send(JSON.stringify({
body: JSON.stringify({
account_ids: [user] account_ids: [user]
}) }));
}).then(function(response) { httpreq.onreadystatechange = function() {
return response.json(); if (httpreq.readyState == 4) {
}).catch(function(error) { var json = httpreq.response;
todo(error);
console.error(error);
}).then(function(json) {
hisList(user,acct_id) hisList(user,acct_id)
}); }
}
} }

View File

@ -320,36 +320,7 @@ element.onmousewheel = function(e) {
zoom(0.9) zoom(0.9)
} }
} }
//画像を貼り付けたら…
var element = document.querySelector("#textarea");
element.addEventListener("paste", function(e){
// 画像の場合
// e.clipboardData.types.length == 0
// かつ
// e.clipboardData.types[0] == "Files"
// となっているので、それ以外を弾く
if (!e.clipboardData
|| !e.clipboardData.types
|| (e.clipboardData.types.length != 1)
|| (e.clipboardData.types[0] != "Files")) {
return true;
}
// ファイルとして得る
// (なぜかgetAsStringでは上手くいかなかった)
var imageFile = e.clipboardData.items[0].getAsFile();
// FileReaderで読み込む
var fr = new FileReader();
fr.onload = function(e) {
// onload内ではe.target.resultにbase64が入っているのであとは煮るなり焼くなり
var base64 = e.target.result;
beforeMedia(base64,"image/png");
};
fr.readAsDataURL(imageFile);
// 画像以外がペーストされたときのために、元に戻しておく
});
//当該トゥート //当該トゥート
function detFromImg(){ function detFromImg(){
var id=$("#imagemodal").attr("data-id"); var id=$("#imagemodal").attr("data-id");

View File

@ -8,26 +8,21 @@ function profedit() {
var start = "https://" + domain + "/api/v1/accounts/update_credentials"; var start = "https://" + domain + "/api/v1/accounts/update_credentials";
var name = $("#his-name-val").val(); var name = $("#his-name-val").val();
var des = $("#his-des-val").val(); var des = $("#his-des-val").val();
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'PATCH', httpreq.open('PATCH', start, true);
headers: { httpreq.setRequestHeader('Content-Type', 'application/json');
'content-type': 'application/json', httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
'Authorization': 'Bearer ' + at httpreq.responseType = 'json';
}, httpreq.send(JSON.stringify({
body: JSON.stringify({
display_name: name, display_name: name,
note: des note: des
}) }));
}).then(function(response) { httpreq.onreadystatechange = function() {
return response.json(); if (httpreq.readyState == 4) {
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
console.log(json);
$('#his-data').modal('close'); $('#his-data').modal('close');
todc(); todc();
}); }
}
} }
//画像系 //画像系
@ -48,23 +43,21 @@ function imgChange(imgfile, target) {
var domain = localStorage.getItem("domain_" + acct_id); var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at"); var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/accounts/update_credentials"; var start = "https://" + domain + "/api/v1/accounts/update_credentials";
fetch(start, { var httpreq = new XMLHttpRequest();
method: 'PATCH', httpreq.open('PATCH', start, true);
headers: { httpreq.upload.addEventListener("progress", progshow, false);
'Authorization': 'Bearer ' + at httpreq.setRequestHeader('Authorization', 'Bearer ' + at);
}, httpreq.responseType = 'json';
body: fd httpreq.send(fd);
}).then(function(response) { httpreq.onreadystatechange = function() {
console.log(response) if (httpreq.readyState == 4) {
return response.json(); var json = httpreq.response;
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
console.log(json); console.log(json);
$('#his-data').modal('close'); $('#his-data').modal('close');
todc(); todc();
}); localStorage.removeItem("image");
}
}
} }
$("#prof-change").html($("#prof-change").html()); $("#prof-change").html($("#prof-change").html());
$("#header-change").html($("#header-change").html()); $("#header-change").html($("#header-change").html());

View File

@ -96,7 +96,18 @@ function udg(user, acct_id) {
$("#his-follow").text(json.following_count); $("#his-follow").text(json.following_count);
$("#his-follower").text(json.followers_count); $("#his-follower").text(json.followers_count);
$("#his-since").text(crat(json.created_at)); $("#his-since").text(crat(json.created_at));
if(json.fields){
var note=json.note+'My Fields<br><table class="responsive-table">'
for(var i=0;i<json.fields.length;i++){
var fname=json.fields[i].name;
var fval=json.fields[i].value;
note=note+'<tr><td>'+fname+'</td><td>'+fval+'</td></tr>';
}
note=note+'</table>'
$("#his-des").html(note);
}else{
$("#his-des").html(json.note); $("#his-des").html(json.note);
}
$('#his-data').css('background-size', 'cover'); $('#his-data').css('background-size', 'cover');
localStorage.setItem("history" , user); localStorage.setItem("history" , user);
//自分の時 //自分の時

View File

@ -1,6 +1,6 @@
{ {
"name": "TheDesk", "name": "TheDesk",
"version": "14.6.0", "version": "14.7.0",
"description": "TheDesk on Mastodonはシンプルと多機能を両立したデスクトップ向けクライアントです", "description": "TheDesk on Mastodonはシンプルと多機能を両立したデスクトップ向けクライアントです",
"main": "main.js", "main": "main.js",
"scripts": { "scripts": {

View File

@ -1 +1 @@
{"warn":"これはGCPにアップして下さい","warn2":"これはGCPにアップして下さい","warn3":"これはGCPにアップして下さい","desk":"Mizuki (ver.5[fixed])","date":"2018-04-10","detail":"内部V:14.5.1|画像添付バグ・ユーザーデータ表示バグ等を修正"} {"warn":"これはGCPにアップして下さい","warn2":"これはGCPにアップして下さい","warn3":"これはGCPにアップして下さい","desk":"Mizuki (ver.7)","date":"2018-04-17","detail":"内部V:14.7.0|バグ修正・内部構成の変更"}