Add: Change: live column add and remove

This commit is contained in:
Cutls 2019-08-14 00:40:21 +09:00
parent 77342206b1
commit ffcecf38c8
10 changed files with 99 additions and 28 deletions

View File

@ -492,7 +492,7 @@ function multiSelector(parseC) {
} }
$('select').formSelect(); $('select').formSelect();
if(!parseC){ if(!parseC){
parseColumn(true); parseColumn(null, true);
} }
} }

View File

@ -139,7 +139,7 @@ onmessage = function (e) {
} else if (e.data[0] == "toastSaved") { } else if (e.data[0] == "toastSaved") {
M.toast({ html: lang.lang_img_DLDone + e.data[1][0] + '<button class="btn-flat toast-action" onclick="openFinder(\'' + e.data[1][1] + '\')">Show</button>', displayLength: 5000 }) M.toast({ html: lang.lang_img_DLDone + e.data[1][0] + '<button class="btn-flat toast-action" onclick="openFinder(\'' + e.data[1][1] + '\')">Show</button>', displayLength: 5000 })
} else if (e.data[0] == "parseColumn") { } else if (e.data[0] == "parseColumn") {
parseColumn() parseColumn(e.data[1])
} else if (e.data[0] == "exportSettingsCore") { } else if (e.data[0] == "exportSettingsCore") {
exportSettingsCore() exportSettingsCore()
} else if (e.data[0] == "fontList") { } else if (e.data[0] == "fontList") {

View File

@ -58,7 +58,7 @@ function qt(id, acct_id, at, url) {
html = $.strip_tags(html); html = $.strip_tags(html);
$("#textarea").val("\n" + "@" + at + " " + html + "\n" + url); $("#textarea").val("\n" + "@" + at + " " + html + "\n" + url);
} }
$("#textarea").focus();
$("#post-acct-sel").val(acct_id); $("#post-acct-sel").val(acct_id);
$('select').formSelect(); $('select').formSelect();
$("#textarea").focus();
} }

View File

@ -77,12 +77,12 @@ function catchToggle(tlid) {
localStorage.removeItem("catch_" + tlid); localStorage.removeItem("catch_" + tlid);
$("#sta-del-" + tlid).text("Off"); $("#sta-del-" + tlid).text("Off");
$("#sta-del-" + tlid).css("color", 'red'); $("#sta-del-" + tlid).css("color", 'red');
parseColumn(); parseColumn(tlid);
} else { } else {
localStorage.setItem("catch_" + tlid, "true"); localStorage.setItem("catch_" + tlid, "true");
$("#sta-del-" + tlid).text("On"); $("#sta-del-" + tlid).text("On");
$("#sta-del-" + tlid).css("color", '#009688'); $("#sta-del-" + tlid).css("color", '#009688');
parseColumn(); parseColumn(tlid);
} }
} }
function catchCheck(tlid) { function catchCheck(tlid) {
@ -421,7 +421,7 @@ function exclude(key) {
} else { } else {
} }
localStorage.setItem("exclude-" + key, excludetxt) localStorage.setItem("exclude-" + key, excludetxt)
parseColumn(); parseColumn(key);
} }
function excludeCk(key, target) { function excludeCk(key, target) {
var exc = localStorage.getItem("exclude-" + key); var exc = localStorage.getItem("exclude-" + key);
@ -444,7 +444,7 @@ function checkNotfFilter(tlid){
} }
function resetNotfFilter(tlid){ function resetNotfFilter(tlid){
localStorage.setItem("exclude-" + tlid, "") localStorage.setItem("exclude-" + tlid, "")
parseColumn(); parseColumn(tlid);
} }
function notfFilter(id,tlid,acct_id){ function notfFilter(id,tlid,acct_id){
var excludetxt = localStorage.getItem("exclude-" + tlid); var excludetxt = localStorage.getItem("exclude-" + tlid);
@ -454,5 +454,5 @@ function notfFilter(id,tlid,acct_id){
excludetxt = "?account_id="+id excludetxt = "?account_id="+id
} }
localStorage.setItem("exclude-" + tlid, excludetxt) localStorage.setItem("exclude-" + tlid, excludetxt)
parseColumn(); parseColumn(tlid);
} }

View File

@ -89,8 +89,9 @@ function voteMastodonrefresh(acct_id, id) {
var start = "https://" + domain + "/api/v1/polls/" + id; var start = "https://" + domain + "/api/v1/polls/" + id;
httpreqd.open('GET', start, true); httpreqd.open('GET', start, true);
httpreqd.setRequestHeader('Content-Type', 'application/json'); httpreqd.setRequestHeader('Content-Type', 'application/json');
httpreqd.setRequestHeader('Authorization', 'Bearer ' + at);
httpreqd.responseType = 'json'; httpreqd.responseType = 'json';
httpreqd.send(JSON.stringify({ i: at, noteId: id })); httpreqd.send();
httpreqd.onreadystatechange = function () { httpreqd.onreadystatechange = function () {
if (httpreqd.readyState == 4) { if (httpreqd.readyState == 4) {
var json = httpreqd.response; var json = httpreqd.response;
@ -109,7 +110,7 @@ function voteMastodonrefresh(acct_id, id) {
} }
poll = poll + '<div class="pointer vote vote_' + acct_id + '_' + json.id + '_' + keyc + '" onclick="' + votesel + '">' + escapeHTML(choice.title) + '<span class="vote_' + acct_id + '_' + json.id + '_result ' + result_hide + '">(' + choice.votes_count + ')</span></div>'; poll = poll + '<div class="pointer vote vote_' + acct_id + '_' + json.id + '_' + keyc + '" onclick="' + votesel + '">' + escapeHTML(choice.title) + '<span class="vote_' + acct_id + '_' + json.id + '_result ' + result_hide + '">(' + choice.votes_count + ')</span></div>';
}); });
poll = poll + myvote + '<span class="cbadge cbadge-hover" title="' + date(json.expires_at, 'absolute') + poll = poll + myvote + '<a onclick="voteMastodonrefresh(\'' + acct_id + '\',\'' + json.id + '\')" class="pointer">' + lang.lang_manager_refresh + '</a><span class="cbadge cbadge-hover" title="' + date(json.expires_at, 'absolute') +
'"><i class="far fa-calendar-times"></i>' + '"><i class="far fa-calendar-times"></i>' +
date(json.expires_at, datetype) + '</span>'; date(json.expires_at, datetype) + '</span>';
$('.vote_' + acct_id + '_' + json.id).html(poll) $('.vote_' + acct_id + '_' + json.id).html(poll)

View File

@ -56,12 +56,12 @@ function voiceToggle(tlid) {
speechSynthesis.cancel() speechSynthesis.cancel()
$("#sta-voice-" + tlid).text("Off"); $("#sta-voice-" + tlid).text("Off");
$("#sta-voice-" + tlid).css("color", 'red'); $("#sta-voice-" + tlid).css("color", 'red');
parseColumn(); parseColumn(tlid);
} else { } else {
localStorage.setItem("voice_" + tlid, "true"); localStorage.setItem("voice_" + tlid, "true");
$("#sta-voice-" + tlid).text("On"); $("#sta-voice-" + tlid).text("On");
$("#sta-voice-" + tlid).css("color", '#009688'); $("#sta-voice-" + tlid).css("color", '#009688');
parseColumn(); parseColumn(tlid);
} }
} }
function voiceCheck(tlid) { function voiceCheck(tlid) {

View File

@ -86,7 +86,7 @@ function tsAdd(q) {
obj.push(add); obj.push(add);
var json = JSON.stringify(obj); var json = JSON.stringify(obj);
localStorage.setItem("column", json); localStorage.setItem("column", json);
parseColumn(); parseColumn('add');
} }
function tootsearch(tlid, q) { function tootsearch(tlid, q) {
var start = "https://tootsearch.chotto.moe/api/v1/search?from=0&sort=created_at%3Adesc&q=" + q var start = "https://tootsearch.chotto.moe/api/v1/search?from=0&sort=created_at%3Adesc&q=" + q

View File

@ -20,7 +20,7 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
obj.push(add); obj.push(add);
var json = JSON.stringify(obj); var json = JSON.stringify(obj);
localStorage.setItem("column", json); localStorage.setItem("column", json);
parseColumn(); parseColumn('add');
return; return;
} }
@ -824,4 +824,40 @@ function reconnector(tlid, type, acct_id, data, mode) {
M.toast({ html: lang.lang_tl_reconnect, displayLength: 2000 }) M.toast({ html: lang.lang_tl_reconnect, displayLength: 2000 })
} }
function columnReload(tlid, type){
$("#notice_icon_" + tlid).addClass("red-text");
if (type == "mix" || type == "integrated" || type == "plus") {
if (localStorage.getItem("voice_" + tlid)) {
var voice = true;
} else {
var voice = false;
}
if (localStorage.getItem("filter_" + acct_id) != "undefined") {
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type);
} else {
var mute = [];
}
var wssh = localStorage.getItem("wssH_" + tlid);
websocketHome[wssh].close();
var wssl = localStorage.getItem("wssL_" + tlid);
websocketLocal[wssl].close();
parseColumn(tlid)
} else if (type == "notf") {
notfColumn(acct_id, tlid, "")
} else {
var wss = localStorage.getItem("wss_" + tlid);
websocket[wss].close();
if (localStorage.getItem("voice_" + tlid)) {
var voice = true;
} else {
var voice = false;
}
if (localStorage.getItem("filter_" + acct_id) != "undefined") {
var mute = getFilterType(JSON.parse(localStorage.getItem("filter_" + acct_id)), type);
} else {
var mute = [];
}
parseColumn(tlid)
}
}
strAliveInt() strAliveInt()

View File

@ -20,7 +20,11 @@ $('.type').click(function () {
$("#type-sel").val($(this).attr("data-type")) $("#type-sel").val($(this).attr("data-type"))
}) })
//最初、カラム変更時に発火 //最初、カラム変更時に発火
function parseColumn(dontclose) { function parseColumn(target, dontclose) {
if (target === 0) {
//this is kuso
target = "zero"
}
console.log("%c Parse column", "color:red;font-size:125%"); console.log("%c Parse column", "color:red;font-size:125%");
var size = localStorage.getItem("size"); var size = localStorage.getItem("size");
if (size) { if (size) {
@ -31,7 +35,7 @@ function parseColumn(dontclose) {
if (localStorage.getItem("menu-done")) { if (localStorage.getItem("menu-done")) {
$("#fukidashi").addClass("hide") $("#fukidashi").addClass("hide")
} }
if (!dontclose) { if (!dontclose && !target) {
tlCloser(); tlCloser();
} }
@ -76,13 +80,36 @@ function parseColumn(dontclose) {
} else { } else {
var obj = JSON.parse(col); var obj = JSON.parse(col);
} }
var numtarget = false
if (target == "add") {
var tlidtar = obj.length - 1
obj = [obj[tlidtar]]
} else if (target) {
var tlidtar = target
if (target == "zero") {
target = 0
}
obj = [obj[target]]
numtarget = true
} else {
var tlidtar = null
if ($("#timeline-container").length) { if ($("#timeline-container").length) {
$("#timeline-container").html(""); $("#timeline-container").html("");
} }
}
var basekey = 0; var basekey = 0;
for (var key = 0; key < obj.length; key++) { for (var key = 0; key < obj.length; key++) {
var next = key + 1; var next = key + 1;
//acctって言いながらタイムライン
var acct = obj[key]; var acct = obj[key];
if (tlidtar) {
if (tlidtar == "zero") {
key = 0
} else {
key = tlidtar
}
}
if (acct.type == "notf") { if (acct.type == "notf") {
var notf_attr = ' data-notf=' + acct.domain; var notf_attr = ' data-notf=' + acct.domain;
var if_notf = "hide"; var if_notf = "hide";
@ -183,8 +210,10 @@ function parseColumn(dontclose) {
} }
if (!acct.left_fold) { if (!acct.left_fold) {
basekey = key; basekey = key;
if (!numtarget) {
var basehtml = '<div style="' + css + '" class="box ' + animecss + '" id="timeline_box_' + basekey + '_parentBox"></div>'; var basehtml = '<div style="' + css + '" class="box ' + animecss + '" id="timeline_box_' + basekey + '_parentBox"></div>';
$("#timeline-container").append(basehtml); $("#timeline-container").append(basehtml);
}
var left_hold = '<a onclick="leftFoldSet(' + key + ')" class="setting nex"><i class="material-icons waves-effect nex" title="' + lang.lang_layout_leftFold + '">view_agenda</i></a>' + lang.lang_layout_leftFold + '</span><br>'; var left_hold = '<a onclick="leftFoldSet(' + key + ')" class="setting nex"><i class="material-icons waves-effect nex" title="' + lang.lang_layout_leftFold + '">view_agenda</i></a>' + lang.lang_layout_leftFold + '</span><br>';
} else { } else {
var left_hold = '<a onclick="leftFoldRemove(' + key + ')" class="setting nex"><i class="material-icons waves-effect nex" title="' + lang.lang_layout_leftUnfold + '">view_column</i></a>' + lang.lang_layout_leftUnfold + '</span><br>'; var left_hold = '<a onclick="leftFoldRemove(' + key + ')" class="setting nex"><i class="material-icons waves-effect nex" title="' + lang.lang_layout_leftUnfold + '">view_column</i></a>' + lang.lang_layout_leftUnfold + '</span><br>';
@ -220,10 +249,14 @@ function parseColumn(dontclose) {
')" class="setting nex"><i class="material-icons waves-effect nex" title="' + lang.lang_layout_linkanades + '">link</i><span id="sta-card-' + ')" class="setting nex"><i class="material-icons waves-effect nex" title="' + lang.lang_layout_linkanades + '">link</i><span id="sta-card-' +
key + '">On</span></a>' + lang.lang_layout_linkana + '<br><a onclick="voiceToggle(' + key + key + '">On</span></a>' + lang.lang_layout_linkana + '<br><a onclick="voiceToggle(' + key +
')" class="setting nex"><i class="material-icons waves-effect nex" title="' + lang.lang_layout_tts + '">hearing</i><span id="sta-voice-' + ')" class="setting nex"><i class="material-icons waves-effect nex" title="' + lang.lang_layout_tts + '">hearing</i><span id="sta-voice-' +
key + '">On</span></a>' + lang.lang_layout_tts + 'TL<br><a onclick="reconnector(' + key + key + ',\'' + acct.type + '\'">On</span></a>' + lang.lang_layout_tts + 'TL<br><a onclick="columnReload(' + key +
',\'' + acct.type + '\',\'' + acct.domain + '\',\'' + escapeHTML(acct.data) + '\')" class="setting nex ' + if_notf + ' ' + if_misskey_hide + '"><i class="material-icons waves-effect nex ' + if_notf + '" title="' + lang.lang_layout_reconnect + '">low_priority</i></a><span class="' + if_notf + '">' + lang.lang_layout_reconnect + '</span><br>' + lang.lang_layout_headercolor + '<br><div id="picker_' + key + '" class="color-picker"></div></div><div class="tl-box" tlid="' + key + '"><div id="timeline_' + key + ')" class="setting nex ' + if_notf + ' ' + if_misskey_hide + '"><i class="material-icons waves-effect nex ' + if_notf + '" title="' + lang.lang_layout_reconnect + '">refresh</i></a><span class="' + if_notf + '">' + lang.lang_layout_reconnect + '</span><br>' + lang.lang_layout_headercolor + '<br><div id="picker_' + key + '" class="color-picker"></div></div><div class="tl-box" tlid="' + key + '"><div id="timeline_' + key +
'" class="tl ' + acct.type + '-timeline " tlid="' + key + '" data-type="' + acct.type + '" data-acct="' + acct.domain + '" data-const="' + acct.type + '_' + acct.domain + '"><div id="landing_' + key + '" style="text-align:center">' + lang.lang_layout_nodata + '</div></div></div>' '" class="tl ' + acct.type + '-timeline " tlid="' + key + '" data-type="' + acct.type + '" data-acct="' + acct.domain + '" data-const="' + acct.type + '_' + acct.domain + '"><div id="landing_' + key + '" style="text-align:center">' + lang.lang_layout_nodata + '</div></div></div>'
$('#timeline_box_' + basekey + '_parentBox').append(html); if (numtarget) {
$('timeline_box_' + key + '_box').html(html)
} else {
$('#timeline_box_' + basekey + '_parentBox').append(html)
}
localStorage.removeItem("pool_" + key); localStorage.removeItem("pool_" + key);
if (acct.data) { if (acct.data) {
var data = acct.data; var data = acct.data;
@ -337,7 +370,7 @@ function addColumn() {
localStorage.setItem("column", json); localStorage.setItem("column", json);
} }
parseColumn(); parseColumn('add');
} }
function addselCk() { function addselCk() {
var acct = $("#add-acct-sel").val(); var acct = $("#add-acct-sel").val();
@ -381,8 +414,8 @@ function removeColumn(tlid) {
obj.splice(tlid, 1); obj.splice(tlid, 1);
var json = JSON.stringify(obj); var json = JSON.stringify(obj);
localStorage.setItem("column", json); localStorage.setItem("column", json);
parseColumn()
sortLoad() sortLoad()
$("#timeline_box_" + tlid + "_parentBox").remove()
} }
$("#sort-box").removeClass("hide"); $("#sort-box").removeClass("hide");
$("#sort-box").addClass("show"); $("#sort-box").addClass("show");

View File

@ -1,5 +1,6 @@
//ソートデータ読み込み //ソートデータ読み込み
function sortload() { function sortLoad () {
$("#sort").html("");
var col = localStorage.getItem("column"); var col = localStorage.getItem("column");
if (col) { if (col) {
var obj = JSON.parse(col); var obj = JSON.parse(col);
@ -104,7 +105,7 @@ function sort() {
localStorage.setItem("column", json); localStorage.setItem("column", json);
$("#sort").html(""); $("#sort").html("");
M.toast({ html: "Sorted", displayLength: 3000 }) M.toast({ html: "Sorted", displayLength: 3000 })
sortload(); sortLoad();
parseColumn(); parseColumn();
sortMenu() sortMenu()
} }
@ -115,5 +116,5 @@ function sortMenu() {
$(".menu-content").addClass("hide"); $(".menu-content").addClass("hide");
$("#sort-box").removeClass("hide"); $("#sort-box").removeClass("hide");
$("#sort").html(""); $("#sort").html("");
sortload(); sortLoad();
} }