TheDesk Mizuki (ver.3)

This commit is contained in:
cutls
2018-04-01 06:00:27 +09:00
parent 28b548d49f
commit cc81ca2762
15 changed files with 287 additions and 712 deletions

View File

@@ -209,12 +209,13 @@ function trans(tar){
if(html.match(/^<p>(.+)<\/p>$/)){
html = html.match(/^<p>(.+)<\/p>$/)[1];
}
html = html.replace(/<br\s?\/?>/, "\n");
html = html.replace(/<p>/, "\n");
html = html.replace(/<\/p>/, "\n");
html = html.replace(/<br\s?\/?>/g, "\n");
html = html.replace(/<p>/g, "\n");
html = html.replace(/<\/p>/g, "\n");
html=$.strip_tags(html);
$("#toot-this .additional").text("Loading...(Powered by Google Translate)");
var exec='https://script.google.com/macros/s/AKfycbz0ETqcUxwNlw961GjErNb7vr_X18N2s1AS5Xu5nFTbYXcdcRM/exec?text='+html+'&source='+tar+'&target=ja'
var exec='https://script.google.com/macros/s/AKfycbz0ETqcUxwNlw961GjErNb7vr_X18N2s1AS5Xu5nFTbYXcdcRM/exec?text='+encodeURIComponent(html)+'&source='+tar+'&target=ja'
console.log(exec);
fetch(exec, {
method: 'GET',
}).then(function(response) {

207
app/js/tl/list.js Normal file
View File

@@ -0,0 +1,207 @@
function listToggle(){
if ($("#list-box").hasClass("hide")) {
$("#list-box").removeClass("hide");
$("#list-box").addClass("show");
$("#list-box").css("top",$('#list-tgl').offset().top+"px");
$("#list-box").css("left",$('#list-tgl').offset().left-410+"px");
//リストロード
} else {
$("#list-box").removeClass("show");
$("#list-box").addClass("hide")
}
}
function list(){
$("#lists-user").html("");
var acct_id = $("#list-acct-sel").val();
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/lists"
console.log(start)
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) {
if (json) {
var lists = "";
Object.keys(json).forEach(function(key) {
var list = json[key];
lists = lists + list.title+':<a onclick="listShow(' + list.id + ',\'' + list.title + '\',\'' + acct_id +
'\')" class="pointer">表示</a>/<a onclick="listUser(' + list.id + ',' + acct_id +
')" class="pointer">ユーザー一覧</a><br> ';
});
$("#lists").html(lists);
}else{
$("#lists").html("リストはありません");
}
});
}
function makeNewList(){
var acct_id = $("#list-acct-sel").val();
var text=$("#list-add").val();
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/lists"
console.log(start)
fetch(start, {
method: 'POST',
headers: {
'content-type': 'application/json',
'Authorization': 'Bearer ' + at
},
body: JSON.stringify({
title: text
})
}).then(function(response) {
return response.json();
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
list();
$("#list-add").val("")
});
}
function listShow(id,title,acct_id){
localStorage.setItem("list_"+id+"_"+acct_id,title);
tl('list',id,acct_id,'add');
}
function listUser(id,acct_id){
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/lists/"+id+"/accounts"
console.log(start)
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) {
if (json) {
var lists = "";
var templete = userparse(json,'',acct_id);
if(!json[0]){
templete="ユーザーはいません";
}
$("#lists-user").html(templete);
}else{
$("#lists-user").html("ユーザーはいません");
}
});
}
function hisList(user,acct_id){
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/lists"
console.log(start)
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) {
if (json) {
var lists = "リストに追加<br>";
Object.keys(json).forEach(function(key) {
var list = json[key];
lists = lists + '<a onclick="listAdd(' + list.id + ',\'' + user + '\',\'' + acct_id +
'\')" class="pointer">'+list.title+'</a><br> ';
});
$("#his-lists-a").html(lists);
}else{
$("#his-lists-a").html('リストはありません');
}
});
var start = "https://" + domain + "/api/v1/accounts/"+user+"/lists"
console.log(start)
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) {
if (json) {
var lists = "リストから削除<br>";
Object.keys(json).forEach(function(key) {
var list = json[key];
lists = lists + '<a onclick="listRemove(' + list.id + ',\'' + user + '\',\'' + acct_id +
'\')" class="pointer">'+list.title+'</a><br> ';
});
$("#his-lists-b").html(lists);
}else{
$("#his-lists-b").html('リストはありません');
}
});
}
function listAdd(id,user,acct_id){
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/lists/"+id+"/accounts"
console.log(start)
fetch(start, {
method: 'POST',
headers: {
'content-type': 'application/json',
'Authorization': 'Bearer ' + at
},
body: JSON.stringify({
account_ids: [user]
})
}).then(function(response) {
return response.json();
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
hisList(user,acct_id)
});
}
function listRemove(id,user,acct_id){
var domain = localStorage.getItem("domain_" + acct_id);
var at = localStorage.getItem(domain + "_at");
var start = "https://" + domain + "/api/v1/lists/"+id+"/accounts"
console.log(start)
fetch(start, {
method: 'DELETE',
headers: {
'content-type': 'application/json',
'Authorization': 'Bearer ' + at
},
body: JSON.stringify({
account_ids: [user]
})
}).then(function(response) {
return response.json();
}).catch(function(error) {
todo(error);
console.error(error);
}).then(function(json) {
hisList(user,acct_id)
});
}

View File

@@ -4,13 +4,13 @@ function tl(type, data, acct_id, tlid) {
localStorage.removeItem("morelock");
localStorage.removeItem("pool");
var domain = localStorage.getItem("domain_" + acct_id);
//タグの場合はカラム追加して描画
//タグとかの場合はカラム追加して描画
if (tlid == "add") {
console.log("add");
var newtab = $(".box").length;
var add = {
domain: acct_id,
type: "tag",
type: type,
data: data
};
var multi = localStorage.getItem("column");
@@ -128,6 +128,9 @@ function reload(type, cc, acct_id, tlid, data) {
} else if (type == "noauth") {
var start = "wss://" + acct_id +
"/api/v1/streaming/?stream=public:local";
} else if (type=="list"){
var start = "wss://" + domain +
"/api/v1/streaming/?stream=list&list=" + data +"&access_token=" + at;
}
console.log(start);
var wsid = websocket.length;
@@ -306,7 +309,8 @@ function cap(type, data, acct_id) {
} else if (type == "tag") {
var response= "#" + data
} else if (type == "list") {
var response= "List(id:" + data + ")"
var ltitle=localStorage.getItem("list_"+data+"_"+acct_id);
var response= "List(" + ltitle + ")"
} else if (type == "notf") {
if(localStorage.getItem("notification_" + acct_id) && !locale){
var response=localStorage.getItem("notification_" + acct_id);
@@ -345,6 +349,8 @@ function icon(type) {
return "language"
} else if (type == "tag") {
return "search"
} else if (type == "list") {
return "view_headline"
}
if (type == "list") {
return "subject"