WIP some ToDo
This commit is contained in:
@@ -4,7 +4,7 @@ $("#emoji-before").addClass("disabled");
|
||||
$("#emoji-next").addClass("disabled");
|
||||
|
||||
//絵文字ボタンのトグル
|
||||
function emojiToggle() {
|
||||
function emojiToggle(reaction) {
|
||||
var acct_id = $("#post-acct-sel").val();
|
||||
var selin = $("#textarea").prop('selectionStart');
|
||||
if(!selin){
|
||||
@@ -21,7 +21,7 @@ function emojiToggle() {
|
||||
'<button class="btn waves-effect green" style="width:100%; padding:0; margin-top:0;" onclick="emojiGet(\'true\');">'+lang.lang_emoji_get+'</button>';
|
||||
$("#emoji-list").html(html);
|
||||
} else {
|
||||
emojiList('home');
|
||||
emojiList('home',reaction);
|
||||
}
|
||||
} else {
|
||||
$("#poll").addClass("hide")
|
||||
@@ -34,10 +34,11 @@ function emojiToggle() {
|
||||
}
|
||||
|
||||
//絵文字リスト挿入
|
||||
function emojiGet(parse) {
|
||||
function emojiGet(parse,started) {
|
||||
$('#emoji-list').html('Loading...');
|
||||
var acct_id = $("#post-acct-sel").val();
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
if(localStorage.getItem("mode_" + domain)!="misskey"){
|
||||
var start = "https://" + domain + "/api/v1/custom_emojis";
|
||||
fetch(start, {
|
||||
method: 'GET',
|
||||
@@ -63,14 +64,67 @@ function emojiGet(parse) {
|
||||
localStorage.setItem("emoji_" + acct_id, JSON.stringify(json));
|
||||
}
|
||||
localStorage.setItem("emojiseek", 0);
|
||||
emojiList('home')
|
||||
if(!started){
|
||||
emojiList('home')
|
||||
}
|
||||
});
|
||||
}else{
|
||||
var start = "https://" + domain + "/api/meta";
|
||||
fetch(start, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
}).then(function(response) {
|
||||
return response.json();
|
||||
}).catch(function(error) {
|
||||
todo(error);
|
||||
console.error(error);
|
||||
}).then(function(json) {
|
||||
if(json.enableEmojiReaction){
|
||||
localStorage.setItem("emojiReaction_" + acct_id, "true");
|
||||
}else{
|
||||
localStorage.setItem("emojiReaction_" + acct_id,"disabled");
|
||||
}
|
||||
var emojis=json.emojis;
|
||||
var md=[];
|
||||
Object.keys(emojis).forEach(function(key) {
|
||||
var emoji = emojis[key];
|
||||
md.push({
|
||||
"shortcode":emoji.name,
|
||||
"url":emoji.url
|
||||
})
|
||||
});
|
||||
if (parse == "true") {
|
||||
$('#emoji-list').html('Parsing...');
|
||||
//絵文字をマストドン公式と同順にソート
|
||||
md.sort(function(a, b) {
|
||||
if (a.shortcode < b.shortcode) return -1;
|
||||
if (a.shortcode > b.shortcode) return 1;
|
||||
return 0;
|
||||
});
|
||||
localStorage.setItem("emoji_" + acct_id, JSON.stringify(md));
|
||||
} else {
|
||||
localStorage.setItem("emoji_" + acct_id, JSON.stringify(md));
|
||||
}
|
||||
localStorage.setItem("emojiseek", 0);
|
||||
if(!started){
|
||||
emojiList('home')
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
//リストの描画
|
||||
function emojiList(target) {
|
||||
function emojiList(target,reaction) {
|
||||
$("#now-emoji").text(lang.lang_emoji_custom);
|
||||
var acct_id = $("#post-acct-sel").val();
|
||||
if(reaction && localStorage.getItem("emojiReaction_" + acct_id)!="true"){
|
||||
console.error("Disabled")
|
||||
clear()
|
||||
hide();
|
||||
return false;
|
||||
}
|
||||
var start = localStorage.getItem("emojiseek");
|
||||
if (target == "next") {
|
||||
var start = start * 1 + 127;
|
||||
@@ -100,11 +154,22 @@ function emojiList(target) {
|
||||
}
|
||||
$("#emoji-next").removeClass("disabled");
|
||||
$("#emoji-count").text(ct);
|
||||
if(localStorage.getItem("emoji-zero-width")){
|
||||
var brank="";
|
||||
}else{
|
||||
var brank=" ";
|
||||
}
|
||||
for (i = start; i < start + 126; i++) {
|
||||
var emoji = obj[i];
|
||||
if (emoji) {
|
||||
html = html + '<a onclick="emojiInsert(\':' + emoji.shortcode +
|
||||
': \')" class="pointer"><img src="' + emoji.url + '" width="20"></a>';
|
||||
if(reaction){
|
||||
html = html + '<a onclick="emojiReaction(\':' + emoji.shortcode +
|
||||
':\')" class="pointer"><img src="' + emoji.url + '" width="20"></a>';
|
||||
}else{
|
||||
html = html + '<a onclick="emojiInsert(\':' + emoji.shortcode +
|
||||
':'+brank+'\')" class="pointer"><img src="' + emoji.url + '" width="20"></a>';
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
$("#emoji-list").html(html);
|
||||
|
@@ -93,7 +93,21 @@ function reactiontoggle(id,acct_id,tlid){
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$("#pub_" + id +" .freeReact").toggleClass("hide");
|
||||
}
|
||||
//reactioncustom
|
||||
function reactioncustom(acct_id,id){
|
||||
$("#reply").val(id);
|
||||
$("#unreact").hide();
|
||||
$("#addreact").removeClass("hide");
|
||||
$("#post-acct-sel").val(acct_id);
|
||||
$('select').material_select();
|
||||
localStorage.setItem("nohide",true);
|
||||
show()
|
||||
emojiToggle(true)
|
||||
$("#left-side").hide();
|
||||
$("#default-emoji").hide();
|
||||
}
|
||||
function reactRefresh(acct_id,id){
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
@@ -126,23 +140,31 @@ function reactRefresh(acct_id,id){
|
||||
function reactRefreshCore(json){
|
||||
var id=json.id;
|
||||
if(json.reactionCounts){
|
||||
var reactions=["like","love","laugh","hmm","surprise","congrats","angry","confused","pudding"];
|
||||
$("#pub_" + id +" .reactions").removeClass("hide")
|
||||
for(var i=0;i<reactions.length;i++){
|
||||
if(json.reactionCounts[reactions[i]]){
|
||||
console.log(json.reactionCounts[reactions[i]])
|
||||
$("#pub_" + id +" .re-"+reactions[i]+"ct").text(json.reactionCounts[reactions[i]])
|
||||
$("#pub_" + id +" .re-"+reactions[i]).removeClass("hide")
|
||||
var regExp = new RegExp( ":", "g" ) ;
|
||||
Object.keys(json.reactionCounts).forEach(function(keye) {
|
||||
keyeClass=keye.replace(regExp,'');
|
||||
if(json.reactionCounts[keye]){
|
||||
console.log(json.reactionCounts[keye])
|
||||
$("#pub_" + id +" .re-"+keyeClass+"ct").text(json.reactionCounts[keye])
|
||||
$("#pub_" + id +" .re-"+keyeClass).removeClass("hide")
|
||||
}else{
|
||||
$("#pub_" + id +" .re-"+reactions[i]+"ct").text(0)
|
||||
$("#pub_" + id +" .re-"+keyeClass+"ct").text(0)
|
||||
if($("#pub_" + id +" .reactions").hasClass("fullreact")){
|
||||
$("#pub_" + id +" .re-"+reactions[i]).addClass("hide")
|
||||
$("#pub_" + id +" .re-"+keyeClass).addClass("hide")
|
||||
}
|
||||
$("#pub_" + id +" .re-"+reactions[i]+"ct").text(json.reactionCounts[reactions[i]])
|
||||
$("#pub_" + id +" .re-"+keyeClass+"ct").text(json.reactionCounts[keye])
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function emojiReaction(emoji){
|
||||
var acct_id = $("#post-acct-sel").val();
|
||||
var id = $("#reply").val();
|
||||
reaction(emoji,id,acct_id,null)
|
||||
clear();
|
||||
hide();
|
||||
}
|
||||
function reaction(mode,id,acct_id,tlid){
|
||||
var domain = localStorage.getItem("domain_" + acct_id);
|
||||
var at = localStorage.getItem("acct_"+ acct_id + "_at");
|
||||
|
@@ -307,4 +307,8 @@ function clear() {
|
||||
$("#post-acct-sel").val(localStorage.getItem("main"));
|
||||
}
|
||||
$('select').material_select();
|
||||
$("#left-side").show();
|
||||
$("#default-emoji").show();
|
||||
$("#unreact").show();
|
||||
$("#addreact").addClass("hide");
|
||||
}
|
@@ -53,16 +53,7 @@ input.addEventListener("focus", function() {
|
||||
|
||||
var tag = new_val.match(/#(\S{3,})/);
|
||||
var acct = new_val.match(/@(\S{3,})/);
|
||||
if(localStorage.getItem("imas")){
|
||||
//セルフNP
|
||||
var cpnp = new_val.match(/^(?!.*http)\/\/(\S{1,})/);
|
||||
}else{
|
||||
var cpnp=[];
|
||||
}
|
||||
if (cpnp && cpnp[1]) {
|
||||
var q = cpnp[1];
|
||||
cgNPs(q);
|
||||
} else if (tag && tag[1]) {
|
||||
if (tag && tag[1]) {
|
||||
var q = tag[1];
|
||||
} else if (acct && acct[1]) {
|
||||
var q = acct[1];
|
||||
|
Reference in New Issue
Block a user