Add bookmark TL

This commit is contained in:
cutls 2019-11-16 04:58:37 +09:00
parent f7dbeaef84
commit 2b3feb40ad
13 changed files with 197 additions and 107 deletions

View File

@ -446,6 +446,7 @@ iframe,
} }
.contextMenu .btn-flat { .contextMenu .btn-flat {
text-transform: none !important; text-transform: none !important;
width: 100%;
} }
.gray { .gray {

View File

@ -116,7 +116,7 @@ function boostWith(vis) {
rt(id, acct_id, false, vis) rt(id, acct_id, false, vis)
} }
//ブックマーク //ブックマーク
function bkm(id, acct_id, remote) { function bkm(id, acct_id, tlid) {
if ($('#pub_' + id).hasClass('bkmed')) { if ($('#pub_' + id).hasClass('bkmed')) {
var flag = 'unbookmark' var flag = 'unbookmark'
} else { } else {
@ -140,7 +140,6 @@ function bkm(id, acct_id, remote) {
if (json.reblog) { if (json.reblog) {
json = json.reblog json = json.reblog
} }
if (remote != 'remote') {
var fav = json.favourites_count var fav = json.favourites_count
$('[toot-id=' + id + '] .fav_ct').text(fav) $('[toot-id=' + id + '] .fav_ct').text(fav)
$('[toot-id=' + id + '] .rt_ct').text(json.reblogs_count) $('[toot-id=' + id + '] .rt_ct').text(json.reblogs_count)
@ -153,9 +152,8 @@ function bkm(id, acct_id, remote) {
$('.bkm_' + id).addClass('red-text') $('.bkm_' + id).addClass('red-text')
$('[toot-id=' + id + ']').addClass('bkmed') $('[toot-id=' + id + ']').addClass('bkmed')
} }
} else { var tlidTar = $(`.bookmark-timeline[data-acct=${acct_id}]`).attr('tlid')
M.toast({ html: lang.lang_status_favWarn, displayLength: 1000 }) columnReload(tlidTar,'bookmark')
}
} }
} }
} }

View File

@ -948,7 +948,7 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
</div>` </div>`
} }
//menuは何個 //menuは何個
var menuct = 1 var menuct = 2
if (viashow != 'hide') { if (viashow != 'hide') {
menuct++ menuct++
} }
@ -1106,6 +1106,13 @@ function parse(obj, mix, acct_id, tlid, popup, mutefilter, type) {
</a> </a>
</div> </div>
${trans} ${trans}
<div>
<a onclick="postMessage(['openUrl', '${toot.url}'], '*')"
class="waves-effect waves-dark btn-flat actct" style="padding:0">
<i class="fas text-darken-3 fa-globe"></i>
${lang.lang_parse_link}
</a>
</div>
</div> </div>
</div> </div>
` `

View File

@ -56,14 +56,15 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
) )
$('#notice_icon_' + tlid).text('notifications') $('#notice_icon_' + tlid).text('notifications')
return return
} /*else if (type == "dm") { } else if (type == 'bookmark') {
//DMなら飛ばす //ブックマークなら飛ばす
dm(acct_id, tlid, "plus",delc,voice); getBookmark(acct_id, tlid)
$("#notice_" + tlid).text(cap(type, data, acct_id) + "(" + localStorage.getItem( $('#notice_' + tlid).text(
"user_" + acct_id) + "@" + domain + ")"); cap(type, data, acct_id) + '(' + localStorage.getItem('user_' + acct_id) + '@' + domain + ')'
$("#notice_icon_" + tlid).text("mail_outline"); )
return; $('#notice_icon_' + tlid).text('bookmark')
}*/ return
}
localStorage.setItem('now', type) localStorage.setItem('now', type)
todo(cap(type) + ' TL Loading...') todo(cap(type) + ' TL Loading...')
var at = localStorage.getItem('acct_' + acct_id + '_at') var at = localStorage.getItem('acct_' + acct_id + '_at')
@ -387,6 +388,9 @@ function moreload(type, tlid) {
var data = obj[tlid].data var data = obj[tlid].data
moreTs(tlid, data) moreTs(tlid, data)
return return
} else if (type == 'bookmark') {
getBookmark(acct_id, tlid, true)
return
} }
moreloading = true moreloading = true
localStorage.setItem('now', type) localStorage.setItem('now', type)
@ -708,6 +712,8 @@ function cap(type, data, acct_id) {
var response = 'Twitter' var response = 'Twitter'
} else if (type == 'tootsearch') { } else if (type == 'tootsearch') {
var response = 'tootsearch(' + escapeHTML(data) + ')' var response = 'tootsearch(' + escapeHTML(data) + ')'
} else if (type == 'bookmark') {
var response = 'Bookmarks'
} }
return response return response
} }
@ -730,6 +736,8 @@ function com(type, data) {
return 'list/' + data + '?' return 'list/' + data + '?'
} else if (type == 'dm') { } else if (type == 'dm') {
return 'direct?' return 'direct?'
} else if (type == 'bookmark') {
return 'bookmarks?'
} }
} }
//Misskey //Misskey
@ -800,6 +808,8 @@ function icon(type) {
var response = 'language' var response = 'language'
} else if (type == 'tootsearch') { } else if (type == 'tootsearch') {
var response = 'search' var response = 'search'
} else if (type == 'bookmark') {
var response = 'bookmark'
} }
return response return response
} }
@ -835,6 +845,9 @@ function reconnector(tlid, type, acct_id, data, mode) {
function columnReload(tlid, type) { function columnReload(tlid, type) {
$('#notice_icon_' + tlid).addClass('red-text') $('#notice_icon_' + tlid).addClass('red-text')
$('#unread_' + tlid + ' .material-icons').removeClass('teal-text') $('#unread_' + tlid + ' .material-icons').removeClass('teal-text')
var multi = localStorage.getItem('column')
var obj = JSON.parse(multi)
var acct_id = obj[tlid].domain
if (type == 'mix' || type == 'integrated' || type == 'plus') { if (type == 'mix' || type == 'integrated' || type == 'plus') {
if (localStorage.getItem('voice_' + tlid)) { if (localStorage.getItem('voice_' + tlid)) {
var voice = true var voice = true
@ -850,6 +863,9 @@ function columnReload(tlid, type) {
} else if (type == 'notf') { } else if (type == 'notf') {
$('#notice_icon_' + tlid).removeClass('red-text') $('#notice_icon_' + tlid).removeClass('red-text')
notfColumn(acct_id, tlid, '') notfColumn(acct_id, tlid, '')
} else if (type == 'bookmark') {
$('#notice_icon_' + tlid).removeClass('red-text')
getBookmark(acct_id, tlid, false)
} else { } else {
var wss = localStorage.getItem('wss_' + tlid) var wss = localStorage.getItem('wss_' + tlid)
websocket[wss].close() websocket[wss].close()
@ -1102,3 +1118,52 @@ function asReadEnd() {
postMessage(['asReadComp', ''], '*') postMessage(['asReadComp', ''], '*')
} }
} }
//ブックマーク
function getBookmark(acct_id, tlid, more) {
moreloading = true
console.log(acct_id, tlid, more)
if (more) {
var sid = $('#timeline_' + tlid + ' .notif-marker')
.last()
.attr('data-maxid')
var ad = '?max_id=' + sid
} else {
var ad = ''
}
var at = localStorage.getItem('acct_' + acct_id + '_at')
var domain = localStorage.getItem('domain_' + acct_id)
var start = 'https://' + domain + '/api/v1/bookmarks' + ad
var httpreq = new XMLHttpRequest()
httpreq.open('GET', start, true)
httpreq.setRequestHeader('Content-Type', 'application/json')
httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
httpreq.responseType = 'json'
httpreq.send()
httpreq.onreadystatechange = function() {
if (httpreq.readyState === 4) {
var json = httpreq.response
if (this.status !== 200) {
setLog(start, this.status, this.response)
}
var max_ids = httpreq.getResponseHeader('link')
var max_id = 0
if (max_ids) {
max_ids = max_ids.match(/[?&]{1}max_id=([0-9]+)/)
if (max_ids) {
max_id = max_ids[1]
}
}
var templete = parse(json, 'bookmark', acct_id, tlid, -1, null)
templete = templete + '<div class="hide notif-marker" data-maxid="' + max_id + '"></div>'
if (more) {
$('#timeline_' + tlid).append(templete)
} else {
$('#timeline_' + tlid).html(templete)
}
$('#landing_' + tlid).hide()
jQuery('time.timeago').timeago()
moreloading = false
todc()
}
}
}

View File

@ -202,6 +202,28 @@ function parseColumn(target, dontclose) {
animecss, animecss,
acct.data acct.data
) )
} else if (acct.type == 'bookmark') {
if (!acct.left_fold) {
basekey = key
}
var anime = localStorage.getItem('animation')
if (anime == 'yes' || !anime) {
var animecss = 'box-anime'
} else {
var animecss = ''
}
unstreamingTL(
acct.type,
key,
basekey,
insert,
icnsert,
acct.left_fold,
css,
animecss,
acct.domain
)
}else { }else {
var anime = localStorage.getItem('animation') var anime = localStorage.getItem('animation')
if (anime == 'yes' || !anime) { if (anime == 'yes' || !anime) {
@ -728,105 +750,73 @@ function webviewParse(url, key, insert, icnsert, css) {
</div>` </div>`
return html return html
} }
function unstreamingTL(type, key, basekey, insert, icnsert, left_fold, css, animecss, q) { function unstreamingTL(type, key, basekey, insert, icnsert, left_fold, css, animecss, data) {
//type名が関数名
if (!left_fold) { if (!left_fold) {
var basehtml = var basehtml =
'<div style="' + `<div style="${css}" class="box ${animecss}" id="timeline_box_${basekey}_parentBox"></div>`
css +
'" class="box ' +
animecss +
'" id="timeline_box_' +
basekey +
'_parentBox"></div>'
$('#timeline-container').append(basehtml) $('#timeline-container').append(basehtml)
var left_hold = var left_hold =
'<a onclick="leftFoldSet(' + `<a onclick="leftFoldSet('${key}')" class="setting nex">
key + <i class="material-icons waves-effect nex" title="${lang.lang_layout_leftFold}">view_agenda</i>
')" class="setting nex"><i class="material-icons waves-effect nex" title="' + </a>
lang.lang_layout_leftFold + ${lang.lang_layout_leftFold}
'">view_agenda</i></a>' + </span><br>`
lang.lang_layout_leftFold +
'</span><br>'
} else { } else {
var left_hold = var left_hold =
'<a onclick="leftFoldRemove(' + `<a onclick="leftFoldRemove('${key}')" class="setting nex">
key + <i class="material-icons waves-effect nex" title="${lang.lang_layout_leftUnfold}">view_column</i>
')" class="setting nex"><i class="material-icons waves-effect nex" title="' + </a>
lang.lang_layout_leftUnfold + ${lang.lang_layout_leftUnfold}
'">view_column</i></a>' + </span><br>`
lang.lang_layout_leftUnfold +
'</span><br>'
} }
var html = var html =
'<div class="boxIn" id="timeline_box_' + `<div class="boxIn" id="timeline_box_${key}_box" tlid="${key}">
key + <div class="notice-box z-depth-2" id="menu_${key}" style="${insert} ">
'_box" tlid="' + <div class="area-notice">
key + <i class="material-icons waves-effect" id="notice_icon_${key}" style="font-size:40px; padding-top:25%;"
'"><div class="notice-box z-depth-2" id="menu_' + onclick="${type}('${key}','${data}');" title="${lang.lang_layout_gotop}"></i>
key + </div>
'" style="' + <div class="area-notice_name">
insert + <span id="notice_${key}" class="tl-title"></span>
' ">' + </div>
'<div class="area-notice"><i class="material-icons waves-effect" id="notice_icon_' + <div class="area-a1"></div>
key + <div class="area-sta"></div>
'" style="font-size:40px; padding-top:25%;" onclick="tootsearch(' + <div class="area-a2">
key + <a onclick="removeColumn('${key}')" class="setting nex">
",'" + <i class="material-icons waves-effect nex" title="${lang.lang_layout_delthis}"${icnsert}>cancel</i>
q + </a>
'\');" title="' + </div>
lang.lang_layout_gotop + <div class="area-a3">
'"></i></div>' + <a onclick="setToggle('${key}')" class="setting nex" title="${lang.lang_layout_setthis}" ${icnsert}>
'<div class="area-notice_name"><span id="notice_' + <i class="material-icons waves-effect nex">settings</i>
key + </a>
'" class="tl-title"></span></div>' + </div>
'<div class="area-a1"></div><div class="area-sta"></div>' + </div>
'<div class="area-a2"><a onclick="removeColumn(' + <div class="column-hide notf-indv-box" id="util-box_${key}" style="padding:5px;">
key + ${left_hold}
')" class="setting nex"><i class="material-icons waves-effect nex" title="' + <a onclick="mediaToggle('${key}')" class="setting nex">
lang.lang_layout_delthis + <i class="material-icons waves-effect nex" title="${lang.lang_layout_mediafil}">perm_media</i>
'"' + <span id="sta-media-${key}">On</span>
icnsert + </a>
'>cancel</i></a></div>' + ${lang.lang_layout_mediafil}<br>
'<div class="area-a3"><a onclick="setToggle(' + ${lang.lang_layout_headercolor}<br>
key + <div id="picker_${key}" class="color-picker"></div>
')" class="setting nex" title="' + </div>
lang.lang_layout_setthis + <div class="tl-box" tlid="${key}">
'"' + <div id="timeline_${key}" class="tl ${type}-timeline" tlid="${key}" data-type="${type}" data-acct="${data}">
icnsert + <div id="landing_${key}" style="text-align:center">
'><i class="material-icons waves-effect nex">settings</i></a></div></div>' + ${lang.lang_layout_nodata}
'<div class="column-hide notf-indv-box" id="util-box_' + </div>
key + </div>
'" style="padding:5px;">' + </div>`
left_hold +
'<a onclick="mediaToggle(' +
key +
')" class="setting nex"><i class="material-icons waves-effect nex" title="' +
lang.lang_layout_mediafil +
'">perm_media</i><span id="sta-media-' +
key +
'">On</span></a>' +
lang.lang_layout_mediafil +
'<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 ' +
type +
'-timeline " tlid="' +
key +
'" data-type="' +
type +
'" data-acct="nostr"><div id="landing_' +
key +
'" style="text-align:center">' +
lang.lang_layout_nodata +
'</div></div></div>'
$('#timeline_box_' + basekey + '_parentBox').append(html) $('#timeline_box_' + basekey + '_parentBox').append(html)
tootsearch(key, q) if(type == 'tootsearch'){
tootsearch(key, data)
}else if(type == 'bookmark'){
console.log(key, data)
bookmark(key, data)
}
cardCheck(key) cardCheck(key)
ebtCheck(key) ebtCheck(key)
mediaCheck(key) mediaCheck(key)
@ -834,6 +824,15 @@ function unstreamingTL(type, key, basekey, insert, icnsert, left_fold, css, anim
voiceCheck(key) voiceCheck(key)
return true return true
} }
function bookmark(key, data){
console.log(key, data)
if (localStorage.getItem('voice_' + key)) {
var voice = true
} else {
var voice = false
}
tl('bookmark', '', data, key, 'false', voice, '')
}
function leftFoldSet(key) { function leftFoldSet(key) {
var multi = localStorage.getItem('column') var multi = localStorage.getItem('column')
var obj = JSON.parse(multi) var obj = JSON.parse(multi)

View File

@ -927,6 +927,9 @@
<div class="type waves-effect" data-type="notf"> <div class="type waves-effect" data-type="notf">
<div><i class="material-icons">notifications</i></div><span>@@notf@@</span> <div><i class="material-icons">notifications</i></div><span>@@notf@@</span>
</div> </div>
<div class="type waves-effect" data-type="bookmark">
<div><i class="material-icons">bookmark</i></div><span>@@bookmark@@</span>
</div>
</div> </div>
</div> </div>
<div id="noauth" class="hide">@@showThisTL@@ <div id="noauth" class="hide">@@showThisTL@@

View File

@ -125,6 +125,7 @@
"integratedTLDes":"Integrated(Local/Home)", "integratedTLDes":"Integrated(Local/Home)",
"localPlusDes":"LTL+Reply+BT", "localPlusDes":"LTL+Reply+BT",
"notf":"Notifications", "notf":"Notifications",
"bookmark": "Bookmarks",
"showThisTL":"Show this TL:", "showThisTL":"Show this TL:",
"webviewWarn":"TweetDeck with customed TJDeck(<a href='https://gist.github.com/cutls/8787a55d2c1c53274e68a427966046a6' target='_blank'>Code</a>/<a href='https://gist.github.com/totoraj930/d1394dadb51d75666a76829f61e7280c' target='_blank'>TJDeck</a>). Keyboard shortcuts will irritate you. When you feel so, you check 'Prefer WebView' on top of the column.", "webviewWarn":"TweetDeck with customed TJDeck(<a href='https://gist.github.com/cutls/8787a55d2c1c53274e68a427966046a6' target='_blank'>Code</a>/<a href='https://gist.github.com/totoraj930/d1394dadb51d75666a76829f61e7280c' target='_blank'>TJDeck</a>). Keyboard shortcuts will irritate you. When you feel so, you check 'Prefer WebView' on top of the column.",
"add":"Add", "add":"Add",

View File

@ -187,6 +187,7 @@
"lang_parse_del": "Delete this", "lang_parse_del": "Delete this",
"lang_parse_pin": "Pin this", "lang_parse_pin": "Pin this",
"lang_parse_unpin": "Unpin this", "lang_parse_unpin": "Unpin this",
"lang_parse_link": "Open in a browser",
"lang_parse_det": "Details via your main account.", "lang_parse_det": "Details via your main account.",
"lang_parse_redraft": "Delete & re-draft", "lang_parse_redraft": "Delete & re-draft",
"lang_parse_followed": "Followed you", "lang_parse_followed": "Followed you",

View File

@ -127,6 +127,7 @@
"full": "URL, text and acct(mention to the user)", "full": "URL, text and acct(mention to the user)",
"notqt": "Disabled(Hide buttons on TLs)", "notqt": "Disabled(Hide buttons on TLs)",
"apiQuote": "API(only some instances)", "apiQuote": "API(only some instances)",
"showBookmarkAction": "Show a bookmarking toot button",
"main": "Default accounts of actions", "main": "Default accounts of actions",
"mainwarn": "Main account can be set on Account Manager.", "mainwarn": "Main account can be set on Account Manager.",
"lastacct": "Account you used recently", "lastacct": "Account you used recently",

View File

@ -125,6 +125,7 @@
"integratedTLDes":"統合(ローカルとホーム)", "integratedTLDes":"統合(ローカルとホーム)",
"localPlusDes":"統合(LTL+BT+返信)", "localPlusDes":"統合(LTL+BT+返信)",
"notf":"通知", "notf":"通知",
"bookmark": "ブックマーク",
"showThisTL":"表示するタイムライン", "showThisTL":"表示するタイムライン",
"webviewWarn":"TweetDeckを表示します。TJDeckをカスタムしたものが読み込まれます(<a href='https://gist.github.com/cutls/8787a55d2c1c53274e68a427966046a6' target='_blank'>Code</a>/<a href='https://gist.github.com/totoraj930/d1394dadb51d75666a76829f61e7280c' target='_blank'>TJDeck</a>)。キーボードショートカットが邪魔をするので、文字入力時はカラムの「WebView優先」にチェックを入れてください。", "webviewWarn":"TweetDeckを表示します。TJDeckをカスタムしたものが読み込まれます(<a href='https://gist.github.com/cutls/8787a55d2c1c53274e68a427966046a6' target='_blank'>Code</a>/<a href='https://gist.github.com/totoraj930/d1394dadb51d75666a76829f61e7280c' target='_blank'>TJDeck</a>)。キーボードショートカットが邪魔をするので、文字入力時はカラムの「WebView優先」にチェックを入れてください。",
"add":"追加", "add":"追加",

View File

@ -187,8 +187,9 @@
"lang_parse_del": "削除", "lang_parse_del": "削除",
"lang_parse_pin": "ピン留めする", "lang_parse_pin": "ピン留めする",
"lang_parse_unpin": "ピン留めを解除する", "lang_parse_unpin": "ピン留めを解除する",
"lang_parse_link": "ブラウザで開く",
"lang_parse_det": "詳細(メインアカウント経由)", "lang_parse_det": "詳細(メインアカウント経由)",
"lang_parse_redraft": "このトゥートを削除して再編集", "lang_parse_redraft": "削除して再編集",
"lang_parse_followed": "フォローされました。", "lang_parse_followed": "フォローされました。",
"lang_parse_clientop": "クライアント操作", "lang_parse_clientop": "クライアント操作",
"lang_parse_clienttxt": " に対する処理を選択してください。", "lang_parse_clienttxt": " に対する処理を選択してください。",

View File

@ -127,6 +127,7 @@
"full": "本文・URL・アカウント名", "full": "本文・URL・アカウント名",
"notqt": "使わない(TL上にボタンも表示されません)", "notqt": "使わない(TL上にボタンも表示されません)",
"apiQuote": "パラメーター(対応インスタンス)", "apiQuote": "パラメーター(対応インスタンス)",
"showBookmarkAction": "アクションボタンとしてブックマークを表示する",
"main": "投稿後や起動時のアカウント", "main": "投稿後や起動時のアカウント",
"mainwarn": "メインアカウントはアカウント設定で指定できます。投稿以外のアカウント選択にも影響します。", "mainwarn": "メインアカウントはアカウント設定で指定できます。投稿以外のアカウント選択にも影響します。",
"lastacct": "最後に使用したアカウント", "lastacct": "最後に使用したアカウント",

View File

@ -371,6 +371,17 @@ var tlConstruction = [
checkbox: yesno checkbox: yesno
} }
}, },
{
id: 'bkm',
storage: 'bookmark',
checkbox: true,
setValue: 'no',
text: {
head: '@@showBookmarkAction@@',
desc: '',
checkbox: yesno
}
},
{ {
id: 'replySound', id: 'replySound',
storage: 'replySound', storage: 'replySound',