TheDesk Riina (ver.6[fixed])

This commit is contained in:
cutls
2018-02-25 17:41:34 +09:00
parent 6d31d2e3c4
commit af42745aa7
10 changed files with 79 additions and 57 deletions

View File

@@ -16,6 +16,7 @@ function verck(ver) {
todo("お使いのバージョン" + mess.desk + "は最新です。");
//betaならアプデチェックしない
} else if (ver != "beta") {
localStorage.removeItem("instance")
var electron = require("electron");
var ipc = electron.ipcRenderer;
ipc.send('update', "true");

View File

@@ -221,20 +221,8 @@ function ckdb(acct_id) {
var at = localStorage.getItem(domain + "_at");
var bbcode = domain + "_bbcode";
var letters = domain + "_letters";
var start = "https://dl.thedesk.top/mastodon_data.json";
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);
console.log(json[letters]);
if(localStorage.getItem("instance")){
var json=JSON.parse(localStorage.getItem("instance"));
if (json[bbcode]) {
if (json[bbcode] == "enabled") {
localStorage.setItem("bb_" + acct_id, "true");
@@ -259,8 +247,49 @@ function ckdb(acct_id) {
}else{
localStorage.removeItem("bb_" + acct_id);
}
});
}else{
var start = "https://dl.thedesk.top/mastodon_data.json";
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);
localStorage.setItem("instance", JSON.stringify(json));
if (json[bbcode]) {
if (json[bbcode] == "enabled") {
localStorage.setItem("bb_" + acct_id, "true");
} else {
localStorage.removeItem("bb_" + acct_id);
$("[data-activates='bbcode']").addClass("disabled");
$("[data-activates='bbcode']").prop("disabled", true);
}
} else {
localStorage.removeItem("bb_" + acct_id);
$("[data-activates='bbcode']").addClass("disabled");
$("[data-activates='bbcode']").addClass("disabled", true);
}
if (json[letters]) {
if($("#textarea").attr("data-length")<json[letters]){
$("#textarea").attr("data-length", json[letters]);
}
} else {}
if (json[domain + "_markdown"] == "enabled") {
localStorage.setItem("md_" + acct_id, "true");
$(".markdown").show();
}else{
localStorage.removeItem("bb_" + acct_id);
}
});
}
}
//サポートインスタンス取得

View File

@@ -70,20 +70,9 @@
};
//コピー
function execCopy(string){
var temp = document.createElement('div');
temp.appendChild(document.createElement('pre')).textContent = string;
var s = temp.style;
s.position = 'fixed';
s.left = '-100%';
document.body.appendChild(temp);
document.getSelection().selectAllChildren(temp);
var temp = $("#copy");
temp.val(string);
temp.select();
var result = document.execCommand('copy');
document.body.removeChild(temp);
// true なら実行できている falseなら失敗か対応していないか
return result;
}

View File

@@ -158,7 +158,9 @@ function cbCopy(mode){
execCopy(emb)
Materialize.toast("埋め込みHTMLをコピーしました", 1500);
}else{
execCopy(url)
Materialize.toast("トゥートURLをコピーしました", 1500);
if(execCopy(url)){
Materialize.toast("トゥートURLをコピーしました", 1500);
}
}
}

View File

@@ -105,10 +105,10 @@ function mixre(acct_id, tlid) {
console.log(obj);
var type = JSON.parse(mess.data).event;
if (type == "delete") {
$("[toot-id=" + obj + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
} else if (type == "update") {
var templete = parse([obj], '', acct_id);
if (!$("#timeline_" + tlid + " [toot-id=" + obj.id + "]").length) {
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
pool = templete + pool;
@@ -120,7 +120,6 @@ function mixre(acct_id, tlid) {
additional(acct_id, tlid);
jQuery("time.timeago").timeago();
todc();
}
}
}
websocketHome[wshid].onmessage = function(mess) {
@@ -130,23 +129,19 @@ function mixre(acct_id, tlid) {
console.log(obj);
var type = JSON.parse(mess.data).event;
if (type == "delete") {
console.log("Delete");
$("[toot-id=" + obj + "]").hide();
$("[toot-id=" + obj + "]").remove();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
} else if (type == "update") {
var templete = parse([obj], '', acct_id);
if (!$("#timeline_" + tlid + " [toot-id=" + obj.id + "]").length) {
if ($(window).scrollTop() > 0) {
var pool = localStorage.getItem("pool");
if (pool) {
pool = templete + pool;
} else {
pool = templete
}
localStorage.setItem("pool", pool);
if (obj.visibility != "public" || obj.account.acct != obj.account.username) {
var pool = localStorage.getItem("pool_" + tlid);
if (pool) {
pool = templete + pool;
} else {
$("#timeline_" + tlid).before(templete);
pool = templete
}
localStorage.setItem("pool_" + tlid, pool);
scrollck();
additional(acct_id, tlid);
jQuery("time.timeago").timeago();
}
@@ -231,4 +226,4 @@ function mixmore(tlid) {
});
});
}
}

View File

@@ -110,7 +110,8 @@ function reload(type, cc, acct_id, tlid, data) {
var typeA = JSON.parse(mess.data).event;
if (typeA == "delete") {
var obj = JSON.parse(mess.data).payload;
$("[toot-id=" + obj + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").hide();
$("[toot-id=" + JSON.parse(mess.data).payload + "]").remove();
} else if (typeA == "update") {
var obj = JSON.parse(JSON.parse(mess.data).payload);
console.log(obj);