Fix: instance actor

This commit is contained in:
Cutls 2019-09-01 00:02:34 +09:00
parent 7d02ef2b3e
commit 6e2e488565
4 changed files with 123 additions and 115 deletions

View File

@ -162,8 +162,11 @@ input.addEventListener("focus", function () {
Object.keys(json.accounts).forEach(function (key3) { Object.keys(json.accounts).forEach(function (key3) {
var acct = json.accounts[key3]; var acct = json.accounts[key3];
if (acct.acct != q) { if (acct.acct != q) {
accts = accts + '<a onclick="tagInsert(\'@' + acct.acct + //Instance Actorって…
'\',\'@' + q + '\')" class="pointer">@' + acct.acct + '</a><br>'; if (acct.username.indexOf(".") < 0) {
accts = accts + '<a onclick="tagInsert(\'@' + acct.acct +
'\',\'@' + q + '\')" class="pointer">@' + acct.acct + '</a><br>';
}
} }
}); });
$("#right-side").show() $("#right-side").show()

View File

@ -930,125 +930,127 @@ function userparse(obj, auth, acct_id, tlid, popup) {
} else { } else {
var notf = false; var notf = false;
} }
if (toot.locked) { //Instance Actorって…
var locked = ' <i class="fas fa-lock red-text"></i>'; if (toot.username.indexOf(".") < 0) {
} else { if (toot.locked) {
var locked = ""; var locked = ' <i class="fas fa-lock red-text"></i>';
} } else {
if (auth == "request") { var locked = "";
var authhtml = '<i class="material-icons gray pointer" onclick="request(\'' +
toot.id + '\',\'authorize\',' + acct_id + ')" title="Accept">person_add</i> <i class="material-icons gray pointer" onclick="request(\'' +
toot.id + '\',\'reject\',' + acct_id + ')" title="Reject">person_add_disabled</i>';
} else {
var authhtml = "";
}
var ftxt = lang.lang_parse_followed;
if (!locale && localStorage.getItem("followlocale_" + acct_id)) {
ftxt = localStorage.getItem("followlocale_" + acct_id);
}
if (popup > 0 || popup == -1 || notf) {
var notftext = ftxt + '<br>';
} else {
var notftext = "";
}
var memory = localStorage.getItem("notice-mem");
if (popup >= 0 && obj.length < 5 && notftext != memory) {
M.toast({ html: escapeHTML(toot.display_name) + ":" + ftxt, displayLength: popup * 1000 })
$(".notf-icon_" + tlid).addClass("red-text");
localStorage.setItem("notice-mem", notftext);
notftext = "";
var native = localStorage.getItem("nativenotf");
if (!native) {
native = "yes";
} }
if (native == "yes") { if (auth == "request") {
var os = localStorage.getItem("platform"); var authhtml = '<i class="material-icons gray pointer" onclick="request(\'' +
var options = { toot.id + '\',\'authorize\',' + acct_id + ')" title="Accept">person_add</i> <i class="material-icons gray pointer" onclick="request(\'' +
body: toot.display_name + "(" + toot.acct + ")" + ftxt, toot.id + '\',\'reject\',' + acct_id + ')" title="Reject">person_add_disabled</i>';
icon: toot.avatar } else {
}; var authhtml = "";
var domain = localStorage.getItem("domain_" + acct_id); }
if (os == "darwin") { var ftxt = lang.lang_parse_followed;
var n = new Notification('TheDesk:' + domain, options); if (!locale && localStorage.getItem("followlocale_" + acct_id)) {
} else { ftxt = localStorage.getItem("followlocale_" + acct_id);
var nativeNotfOpt = [ }
'TheDesk:' + domain, if (popup > 0 || popup == -1 || notf) {
toot.display_name + "(" + toot.acct + ")" + ftxt, var notftext = ftxt + '<br>';
toot.avatar, } else {
"userdata", var notftext = "";
acct_id, }
toot.id var memory = localStorage.getItem("notice-mem");
] if (popup >= 0 && obj.length < 5 && notftext != memory) {
postMessage(["nativeNotf", nativeNotfOpt], "*") M.toast({ html: escapeHTML(toot.display_name) + ":" + ftxt, displayLength: popup * 1000 })
$(".notf-icon_" + tlid).addClass("red-text");
localStorage.setItem("notice-mem", notftext);
notftext = "";
var native = localStorage.getItem("nativenotf");
if (!native) {
native = "yes";
}
if (native == "yes") {
var os = localStorage.getItem("platform");
var options = {
body: toot.display_name + "(" + toot.acct + ")" + ftxt,
icon: toot.avatar
};
var domain = localStorage.getItem("domain_" + acct_id);
if (os == "darwin") {
var n = new Notification('TheDesk:' + domain, options);
} else {
var nativeNotfOpt = [
'TheDesk:' + domain,
toot.display_name + "(" + toot.acct + ")" + ftxt,
toot.avatar,
"userdata",
acct_id,
toot.id
]
postMessage(["nativeNotf", nativeNotfOpt], "*")
}
} }
} }
} if (toot.display_name) {
if (toot.display_name) { var dis_name = escapeHTML(toot.display_name);
var dis_name = escapeHTML(toot.display_name); } else {
} else { var dis_name = toot.username;
var dis_name = toot.username; }
} //ネイティブ通知
//ネイティブ通知
if (toot.emojis) { if (toot.emojis) {
var actemojick = toot.emojis[0]; var actemojick = toot.emojis[0];
} else { } else {
var actemojick = false; var actemojick = false;
}
//絵文字があれば
if (actemojick) {
Object.keys(toot.emojis).forEach(function (key5) {
var emoji = toot.emojis[key5];
var shortcode = emoji.shortcode;
var emoji_url = '<img draggable="false" src="' + emoji.url +
'" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
});
}
if (dis_name) {
dis_name = twemoji.parse(dis_name);
}
if (toot.avatar) {
var avatar = toot.avatar;
} else {
var avatar = "../../img/missing.svg";
}
if (tlid == "dir" && acct_id == "noauth") {
var udg = '<a onclick="udgEx(\'' + toot.url + '\',\'main\');" user="' + toot.acct + '" class="udg">'
} else {
var udg = '<a onclick="udg(\'' + toot.id + '\',' +
acct_id + ');" user="' + toot.acct + '" class="udg">'
}
var latest = date(toot.last_status_at, "relative");
if (toot.last_status_at) {
var latesthtml = '<div class="cbadge" style="width:100px;">Last: ' + latest +
'</div>'
} else {
var latesthtml = ""
}
templete = templete +
'<div class="cvo" style="padding-top:5px;" user-id="' + toot.id + '"><div class="area-notice">' +
notftext +
'</div><div class="area-icon">' + udg +
'<img draggable="false" src="' + avatar + '" width="40" class="prof-img" user="' + toot
.acct + '" onerror="this.src=\'../../img/loading.svg\'"></a></div>' +
'<div class="area-display_name"><div class="flex-name"><span class="user">' +
dis_name + '</span>' +
'<span class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;user-select:auto; cursor:text;"> @' +
toot.acct + locked + '</span>' +
'</div>' +
'</div>' +
'<div class="area-toot acct-note">' + toot.note.replace(/<br\s?\/?>.+/g, '<span class="gray">...</span>') + '</div>' +
'<div style="justify-content:space-around;top:5px" class="area-actions"> <div class="cbadge" style="width:100px;">' + lang.lang_status_follow + ':' +
toot.following_count +
'</div><div class="cbadge" style="width:100px;">' + lang.lang_status_followers + ':' + toot.followers_count +
'</div>' + latesthtml + authhtml +
'</div>' +
'</div>';
} }
//絵文字があれば
if (actemojick) {
Object.keys(toot.emojis).forEach(function (key5) {
var emoji = toot.emojis[key5];
var shortcode = emoji.shortcode;
var emoji_url = '<img draggable="false" src="' + emoji.url +
'" class="emoji-img" data-emoji="' + shortcode + '" alt=" :' + shortcode + ': ">';
var regExp = new RegExp(":" + shortcode + ":", "g");
dis_name = dis_name.replace(regExp, emoji_url);
});
}
if (dis_name) {
dis_name = twemoji.parse(dis_name);
}
if (toot.avatar) {
var avatar = toot.avatar;
} else {
var avatar = "../../img/missing.svg";
}
if (tlid == "dir" && acct_id == "noauth") {
var udg = '<a onclick="udgEx(\'' + toot.url + '\',\'main\');" user="' + toot.acct + '" class="udg">'
} else {
var udg = '<a onclick="udg(\'' + toot.id + '\',' +
acct_id + ');" user="' + toot.acct + '" class="udg">'
}
var latest = date(toot.last_status_at, "relative");
if(toot.last_status_at){
var latesthtml = '<div class="cbadge" style="width:100px;">Last: ' + latest +
'</div>'
}else{
var latesthtml = ""
}
templete = templete +
'<div class="cvo" style="padding-top:5px;" user-id="' + toot.id + '"><div class="area-notice">' +
notftext +
'</div><div class="area-icon">' + udg +
'<img draggable="false" src="' + avatar + '" width="40" class="prof-img" user="' + toot
.acct + '" onerror="this.src=\'../../img/loading.svg\'"></a></div>' +
'<div class="area-display_name"><div class="flex-name"><span class="user">' +
dis_name + '</span>' +
'<span class="sml gray" style="overflow: hidden;white-space: nowrap;text-overflow: ellipsis;user-select:auto; cursor:text;"> @' +
toot.acct + locked + '</span>' +
'</div>' +
'</div>' +
'<div class="area-toot acct-note">' + toot.note.replace(/<br\s?\/?>.+/g, '<span class="gray">...</span>') + '</div>' +
'<div style="justify-content:space-around;top:5px" class="area-actions"> <div class="cbadge" style="width:100px;">' + lang.lang_status_follow + ':' +
toot.following_count +
'</div><div class="cbadge" style="width:100px;">' + lang.lang_status_followers + ':' + toot.followers_count +
'</div>' + latesthtml + authhtml +
'</div>' +
'</div>';
} }
}); });
return templete; return templete;
} }

View File

@ -75,7 +75,6 @@ function src(mode, offset) {
//アカウント //アカウント
if (json.accounts[0]) { if (json.accounts[0]) {
var templete = userparse(json.accounts, '', acct_id); var templete = userparse(json.accounts, '', acct_id);
console.log(templete)
if(!offset){ if(!offset){
$("#src-contents").append("<br>Accounts<div id=\"src-accts\">" + templete + '</div><a onclick="src(false,\'more\')" class="pointer">more...</a>'); $("#src-contents").append("<br>Accounts<div id=\"src-accts\">" + templete + '</div><a onclick="src(false,\'more\')" class="pointer">more...</a>');
}else{ }else{

View File

@ -19,6 +19,10 @@ const pages = ["acct.html", "index.html", "setting.html", "update.html", "settin
let langstr = "" let langstr = ""
for (let n = 0; n < langs.length; n++) { for (let n = 0; n < langs.length; n++) {
let lang = langs[n] let lang = langs[n]
let targetDir = '../' + lang
if (!fs.existsSync(targetDir)) {
fs.mkdirSync(targetDir);
}
langstr = langstr + '<a onclick="changelang(\'' + lang + '\')" class="pointer" style="margin-right:5px;">' + langsh[n] + '</a>' langstr = langstr + '<a onclick="changelang(\'' + lang + '\')" class="pointer" style="margin-right:5px;">' + langsh[n] + '</a>'
} }
for (let i = 0; i < samples.length; i++) { for (let i = 0; i < samples.length; i++) {