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,18 +449,18 @@ 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 class="collapsible-body toot-reset" id="toot-after">
</div>
</li>
<li>
<div class="collapsible-header">
<i class="material-icons">reply_all</i>このトゥートからのリプライ
</div> </div>
<div class="collapsible-body toot-reset" id="toot-reply"> <div class="collapsible-body toot-reset" id="toot-reply">
</div> </div>
</li> </li>
<li>
<div class="collapsible-header">
<i class="material-icons">arrow_downward</i>これよりあとの会話
</div>
<div class="collapsible-body toot-reset" id="toot-after">
</div>
</li>
<li> <li>
<div class="collapsible-header" id="activator"> <div class="collapsible-header" id="activator">
<i class="material-icons">more_horiz</i>対象のトゥート <i class="material-icons">more_horiz</i>対象のトゥート
@ -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

@ -12,34 +12,36 @@ input.addEventListener("focus", function() {
timer = window.setInterval(function() { timer = window.setInterval(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=" +
fetch(start, { new_val;
method: 'GET', fetch(start, {
headers: { method: 'GET',
'content-type': 'application/json', headers: {
'Authorization': 'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M' 'content-type': 'application/json',
}, 'Authorization': 'Bearer tC8F6xWGWBUwGScyNevYlx62iO6fdQ4oIK0ad68Oo7ZKB8GQdGpjW9TKxBnIh8grAhvd5rw3iyP9JPamoDpeLQdz62EToPJUW99hDx8rfuJfGdjQuimZPTbIOx0woA5M'
}).then(function(response) { },
return response.json(); }).then(function(response) {
}).catch(function(error) { return response.json();
todo(error); }).catch(function(error) {
console.error(error); todo(error);
}).then(function(json) { console.error(error);
console.log(json); }).then(function(json) {
if (!json.error) { console.log(json);
if (!json.error) {
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);
} }
}); oldSuggest = suggest;
} prev_value = new_val;
oldSuggest = suggest;
prev_value = new_val;
} }
}, 1000); }, 1000);
}, false); }, false);

View File

@ -106,24 +106,21 @@ 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" }));
}) 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); var auth = "https://" + url + "/oauth/authorize?client_id=" + json[
console.error(error);
}).then(function(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";
localStorage.setItem("domain_" + acct_id, url); localStorage.setItem("domain_" + acct_id, url);
@ -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,45 +153,42 @@ 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" }));
}) 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); var auth = "https://" + url + "/oauth/authorize?client_id=" + json[
console.error(error); "client_id"] + "&client_secret=" + json["client_secret"] +
}).then(function(json) { "&response_type=code&scope=read+write+follow&redirect_uri=" + red;
console.log(json); localStorage.setItem("domain_tmp", url);
var auth = "https://" + url + "/oauth/authorize?client_id=" + json[ localStorage.setItem("client_id", json["client_id"]);
"client_id"] + "&client_secret=" + json["client_secret"] + localStorage.setItem("client_secret", json["client_secret"]);
"&response_type=code&scope=read+write+follow&redirect_uri="+red; $("#auth").show();
localStorage.setItem("domain_tmp", url); $("#add").hide();
localStorage.setItem("client_id", json["client_id"]); const {
localStorage.setItem("client_secret", json["client_secret"]); shell
$("#auth").show(); } = require('electron');
$("#add").hide();
const {
shell
} = require('electron');
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 }));
}) 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); if (json["access_token"]) {
console.error(error); $("#auth").hide();
}).then(function(json) { $("#add").show();
if (json["access_token"]) { getdata(url, json["access_token"]);
$("#auth").hide(); }
$("#add").show();
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,48 +101,47 @@ 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) { console.log(json);
todo(error); var img = localStorage.getItem("img");
console.error(error); if (json.type=="image") {
}).then(function(json) { var html = '<img src="' + json.preview_url + '" style="width:50px; max-height:100px;">';
console.log(json); $('#preview').append(html);
var img = localStorage.getItem("img"); } else {
if (json.type=="image") { $('#preview').append("プレビューできません");
var html = '<img src="' + json.preview_url + '" style="width:50px; max-height:100px;">'; }
$('#preview').append(html); if (!img) {
} else { var img = "no-act";
$('#preview').append("プレビューできません"); }
} if (img != "inline") {
if (!img) { var mediav=$("#media").val();
var img = "no-act"; var regExp = new RegExp("tmp_"+r, "g");
} mediav = mediav.replace(regExp, json["id"]);
if (img != "inline") { $("#media").val(mediav);
var mediav=$("#media").val();
var regExp = new RegExp("tmp_"+r, "g");
mediav = mediav.replace(regExp, json["id"]);
$("#media").val(mediav);
}
if (img == "url") {
$("#textarea").val($("#textarea").val() + " " + json["text_url"])
}
todc();
$("#toot-post-btn").prop("disabled", false);
$("#post-acct-sel").prop("disabled", true);
$('select').material_select();
$("#mec").text("あり");
Materialize.toast("ファイルアップロード後はアカウントを切り替えられません。", 1000);
$("#imgup").text("");
$("#imgsel").show();
localStorage.removeItem("image");
} }
if (img == "url") { }
$("#textarea").val($("#textarea").val() + " " + json["text_url"])
}
todc();
$("#toot-post-btn").prop("disabled", false);
$("#post-acct-sel").prop("disabled", true);
$('select').material_select();
$("#mec").text("あり");
Materialize.toast("ファイルアップロード後はアカウントを切り替えられません。", 1000);
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,30 +36,27 @@ 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) { console.log(json);
todo(error); var box = localStorage.getItem("box");
console.error(error); if (box == "yes") {
}).then(function(json) { hide();
console.log(json); }else if (box == "hide"){
var box = localStorage.getItem("box"); $("body").addClass("mini-post");
if (box == "yes") { $(".mini-btn").text("expand_less");
hide(); }
}else if (box == "hide"){ todc();
$("body").addClass("mini-post"); clear();
$(".mini-btn").text("expand_less");
} }
todc(); }
clear();
});
} }
//クリア(Shift+C) //クリア(Shift+C)

View File

@ -9,48 +9,44 @@ 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) { if(remote!="remote"){
todo(error); //APIのふぁぼカウントがおかしい
console.error(error); if ($("[toot-id=" + id + "] .fav_ct").text() == json.favourites_count){
}).then(function(json) { if(flag=="unfavourite"){
console.log(json); var fav=json.favourites_count - 1;
if(remote!="remote"){ }else{
//APIのふぁぼカウントがおかしい var fav=json.favourites_count + 1;
if ($("[toot-id=" + id + "] .fav_ct").text() == json.favourites_count){ //var fav = json.favourites_count;
if(flag=="unfavourite"){ }
var fav=json.favourites_count - 1; }else{
}else{ var fav = json.favourites_count;
var fav=json.favourites_count + 1; }
//var fav = json.favourites_count; $("[toot-id=" + id + "] .fav_ct").text(fav);
} if (!json.reblog) {
}else{ } else {
var fav = json.favourites_count; $("[toot-id=" + id + "] .rt_ct").text(fav);
} }
$("[toot-id=" + id + "] .fav_ct").text(fav); if ($("[toot-id=" + id +"]").hasClass("faved")) {
if (!json.reblog) { $("[toot-id=" + id +"]").removeClass("faved");
} else { $(".fav_" + id).removeClass("yellow-text");
$("[toot-id=" + id + "] .rt_ct").text(fav); } else {
} $("[toot-id=" + id +"]").addClass("faved");
if ($("[toot-id=" + id +"]").hasClass("faved")) { $(".fav_" + id).addClass("yellow-text");
$("[toot-id=" + id +"]").removeClass("faved"); }
$(".fav_" + id).removeClass("yellow-text"); }else{
} else { Materialize.toast("お気に入り登録しました。インスタンスが違うときは時間がかかる場合があります。", 1000);
$("[toot-id=" + id +"]").addClass("faved"); }
$(".fav_" + id).addClass("yellow-text"); }
} }
}else{
Materialize.toast("お気に入り登録しました。インスタンスが違うときは時間がかかる場合があります。", 1000);
}
});
} }
//ブースト //ブースト
@ -63,44 +59,41 @@ 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) { console.log(json);
todo(error); if (remote != "remote") {
console.error(error); $("[toot-id=" + id + "] .fav_ct").text(json.favourites_count);
}).then(function(json) { if (!json.reblog) {
console.log(json); if (flag == "unreblog") {
if(remote!="remote"){ var rt = json.reblogs_count - 1;
$("[toot-id=" + id + "] .fav_ct").text(json.favourites_count); } else {
if (!json.reblog) { var rt = json.reblogs_count + 1;
if(flag=="unreblog"){ }
var rt=json.reblogs_count - 1; $("[toot-id=" + id + "] .rt_ct").text(rt);
}else{ } else {
var rt=json.reblogs_count + 1; $("[toot-id=" + id + "] .rt_ct").text(json.reblog.reblogs_count);
} }
$("[toot-id=" + id + "] .rt_ct").text(rt);
} else {
$("[toot-id=" + id + "] .rt_ct").text(json.reblog.reblogs_count);
}
if ($("[toot-id=" + id +"]").hasClass("rted")) { if ($("[toot-id=" + id + "]").hasClass("rted")) {
$("[toot-id=" + id +"]").removeClass("rted"); $("[toot-id=" + id + "]").removeClass("rted");
$(".rt_" + id).removeClass("teal-text"); $(".rt_" + id).removeClass("teal-text");
} else { } else {
$("[toot-id=" + id +"]").addClass("rted"); $("[toot-id=" + id + "]").addClass("rted");
$(".rt_" + id).addClass("teal-text"); $(".rt_" + id).addClass("teal-text");
}
} else {
Materialize.toast("ブーストしました。インスタンスが違うときは時間がかかる場合があります。", 1000);
}
} }
}else{
Materialize.toast("ブーストしました。インスタンスが違うときは時間がかかる場合があります。", 1000);
} }
});
} }
//フォロー //フォロー
@ -129,27 +122,25 @@ 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); if ($("#his-data").hasClass("following")) {
console.error(error); $("#his-data").removeClass("following");
}).then(function(json) { $("#his-follow-btn").text("フォロー");
if ($("#his-data").hasClass("following")) { } else {
$("#his-data").removeClass("following"); $("#his-data").addClass("following");
$("#his-follow-btn").text("フォロー"); $("#his-follow-btn").text("フォロー解除");
} else { }
$("#his-data").addClass("following");
$("#his-follow-btn").text("フォロー解除");
} }
}); }
} }
//ブロック //ブロック
@ -166,27 +157,23 @@ 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(); if ($("#his-data").hasClass("blocking")) {
}).catch(function(error) { $("#his-data").removeClass("blocking");
todo(error); $("#his-block-btn").text("ブロック");
console.error(error); } else {
}).then(function(json) { $("#his-data").addClass("blocking");
if ($("#his-data").hasClass("blocking")) { $("#his-block-btn").text("ブロック解除");
$("#his-data").removeClass("blocking"); }
$("#his-block-btn").text("ブロック");
} else {
$("#his-data").addClass("blocking");
$("#his-block-btn").text("ブロック解除");
} }
}); }
} }
//ミュート //ミュート
@ -203,27 +190,23 @@ 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(); if ($("#his-data").hasClass("muting")) {
}).catch(function(error) { $("#his-data").removeClass("muting");
todo(error); $("#his-mute-btn").text("ミュート");
console.error(error); } else {
}).then(function(json) { $("#his-data").addClass("muting");
if ($("#his-data").hasClass("muting")) { $("#his-mute-btn").text("ミュート解除");
$("#his-data").removeClass("muting"); }
$("#his-mute-btn").text("ミュート");
} else {
$("#his-data").addClass("muting");
$("#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,28 +235,25 @@ 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) { console.log(json);
todo(error); if ($("[toot-id=" + id + "]").hasClass("pined")) {
console.error(error); $("[toot-id=" + id + "]").removeClass("pined");
}).then(function(json) { $(".pin_" + id).removeClass("blue-text");
console.log(json); } else {
if ($("[toot-id=" + id +"]").hasClass("pined")) { $("[toot-id=" + id + "]").addClass("pined");
$("[toot-id=" + id +"]").removeClass("pined"); $(".pin_" + id).addClass("blue-text");
$(".pin_" + id).removeClass("blue-text"); }
} else {
$("[toot-id=" + id +"]").addClass("pined");
$(".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); showReq();
console.error(error); }
}).then(function(json) { }
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(); showDom();
}).catch(function(error) { }
todo(error); }
console.error(error);
}).then(function(json) {
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 }));
}) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json(); var json = httpreq.response;
}).catch(function(error) { list();
todo(error); $("#list-add").val("")
console.error(error); }
}).then(function(json) { }
list();
$("#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] }));
}) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json(); var json = httpreq.response;
}).catch(function(error) { hisList(user,acct_id)
todo(error); }
console.error(error); }
}).then(function(json) {
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] }));
}) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json(); var json = httpreq.response;
}).catch(function(error) { hisList(user,acct_id)
todo(error); }
console.error(error); }
}).then(function(json) {
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 }));
}) httpreq.onreadystatechange = function() {
}).then(function(response) { if (httpreq.readyState == 4) {
return response.json(); $('#his-data').modal('close');
}).catch(function(error) { todc();
todo(error); }
console.error(error); }
}).then(function(json) {
console.log(json);
$('#his-data').modal('close');
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) { console.log(json);
todo(error); $('#his-data').modal('close');
console.error(error); todc();
}).then(function(json) { localStorage.removeItem("image");
console.log(json); }
$('#his-data').modal('close'); }
todc();
});
} }
$("#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));
$("#his-des").html(json.note); 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-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|バグ修正・内部構成の変更"}