Add: show utl as a column

This commit is contained in:
cutls 2020-05-07 00:31:11 +09:00
parent da011cd302
commit 25e99725d2
8 changed files with 145 additions and 62 deletions

View File

@ -90,6 +90,19 @@ function tl(type, data, acct_id, tlid, delc, voice, mode) {
) )
$('#notice_icon_' + tlid).text('bookmark') $('#notice_icon_' + tlid).text('bookmark')
return return
} else if (type == 'utl') {
//UTLなら飛ばす
getUtl(acct_id, tlid, data, false)
$('#notice_' + tlid).text(
cap(type, data, acct_id) +
'(' +
localStorage.getItem('user_' + acct_id) +
'@' +
domain +
')'
)
$('#notice_icon_' + tlid).text('person')
return
} else if (type == 'home') { } else if (type == 'home') {
//ホームならお知らせ「も」取りに行く //ホームならお知らせ「も」取りに行く
announ(acct_id, tlid) announ(acct_id, tlid)
@ -464,6 +477,10 @@ function moreload(type, tlid) {
} else if (type == 'bookmark') { } else if (type == 'bookmark') {
getBookmark(acct_id, tlid, true) getBookmark(acct_id, tlid, true)
return return
} else if (type == 'utl') {
var data = obj[tlid].data
getUtl(acct_id, tlid, data, true)
return
} }
moreloading = true moreloading = true
localStorage.setItem('now', type) localStorage.setItem('now', type)
@ -826,6 +843,8 @@ function cap(type, data, acct_id) {
var response = 'tootsearch(' + escapeHTML(data) + ')' var response = 'tootsearch(' + escapeHTML(data) + ')'
} else if (type == 'bookmark') { } else if (type == 'bookmark') {
var response = 'Bookmarks' var response = 'Bookmarks'
} else if (type == 'utl') {
var response = 'User TL(' + data.acct + ')'
} }
return response return response
} }
@ -1310,6 +1329,46 @@ function getBookmark(acct_id, tlid, more) {
} }
} }
} }
function getUtl(acct_id, tlid, data, more) {
moreloading = true
if (more) {
var sid = $('#timeline_' + tlid + ' .cvo')
.last()
.attr('unique-id')
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/accounts/" + data.id + "/statuses" + 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 templete = parse(json, 'bookmark', acct_id, tlid, -1, null)
templete =
templete
if (more) {
$('#timeline_' + tlid).append(templete)
} else {
$('#timeline_' + tlid).html(templete)
}
$('#landing_' + tlid).hide()
jQuery('time.timeago').timeago()
moreloading = false
todc()
}
}
}
//Announcement //Announcement
function announ(acct_id, tlid) { function announ(acct_id, tlid) {
var at = localStorage.getItem('acct_' + acct_id + '_at') var at = localStorage.getItem('acct_' + acct_id + '_at')

View File

@ -14,7 +14,7 @@ function addColumnMenu() {
$('#add-box').removeClass('hide') $('#add-box').removeClass('hide')
addselCk() addselCk()
} }
$('.type').click(function() { $('.type').click(function () {
$('.type').removeClass('active') $('.type').removeClass('active')
$(this).addClass('active') $(this).addClass('active')
$('#type-sel').val($(this).attr('data-type')) $('#type-sel').val($(this).attr('data-type'))
@ -44,7 +44,7 @@ function parseColumn(target, dontclose) {
var obj = JSON.parse(multi) var obj = JSON.parse(multi)
var templete var templete
Object.keys(obj).forEach(function(key) { Object.keys(obj).forEach(function (key) {
var acct = obj[key] var acct = obj[key]
localStorage.setItem('name_' + key, acct.name) localStorage.setItem('name_' + key, acct.name)
@ -76,8 +76,8 @@ function parseColumn(target, dontclose) {
var obj = [ var obj = [
{ {
domain: 0, domain: 0,
type: 'local' type: 'local',
} },
] ]
var json = JSON.stringify(obj) var json = JSON.stringify(obj)
localStorage.setItem('column', json) localStorage.setItem('column', json)
@ -122,10 +122,7 @@ function parseColumn(target, dontclose) {
var if_notf = '' var if_notf = ''
} }
if (localStorage.getItem('notification_' + acct.domain)) { if (localStorage.getItem('notification_' + acct.domain)) {
var unique_notf = lang.lang_layout_thisacct.replace( var unique_notf = lang.lang_layout_thisacct.replace('{{notf}}', localStorage.getItem('notification_' + acct.domain))
'{{notf}}',
localStorage.getItem('notification_' + acct.domain)
)
} else { } else {
if (lang.language == 'ja') { if (lang.language == 'ja') {
var notflocale = '通知' var notflocale = '通知'
@ -191,17 +188,7 @@ function parseColumn(target, dontclose) {
} else { } else {
var animecss = '' var animecss = ''
} }
unstreamingTL( unstreamingTL(acct.type, key, basekey, insert, icnsert, acct.left_fold, css, animecss, acct.data)
acct.type,
key,
basekey,
insert,
icnsert,
acct.left_fold,
css,
animecss,
acct.data
)
} else if (acct.type == 'bookmark') { } else if (acct.type == 'bookmark') {
if (!acct.left_fold) { if (!acct.left_fold) {
basekey = key basekey = key
@ -213,17 +200,19 @@ function parseColumn(target, dontclose) {
} else { } else {
var animecss = '' var animecss = ''
} }
unstreamingTL( unstreamingTL(acct.type, key, basekey, insert, icnsert, acct.left_fold, css, animecss, acct.domain)
acct.type, } else if (acct.type == 'utl') {
key, if (!acct.left_fold) {
basekey, basekey = key
insert, }
icnsert,
acct.left_fold, var anime = localStorage.getItem('animation')
css, if (anime == 'yes' || !anime) {
animecss, var animecss = 'box-anime'
acct.domain } else {
) var animecss = ''
}
unstreamingTL(acct.type, key, basekey, insert, icnsert, acct.left_fold, css, animecss, { acct: acct.domain, data: acct.data })
} else { } else {
var anime = localStorage.getItem('animation') var anime = localStorage.getItem('animation')
if (anime == 'yes' || !anime) { if (anime == 'yes' || !anime) {
@ -292,7 +281,7 @@ function parseColumn(target, dontclose) {
${lang.lang_layout_excludingbt} ${lang.lang_layout_excludingbt}
<br>` <br>`
} else if (acct.type == 'tag') { } else if (acct.type == 'tag') {
if(acct.data.name) { if (acct.data.name) {
var name = acct.data.name var name = acct.data.name
var all = acct.data.all var all = acct.data.all
var any = acct.data.any var any = acct.data.any
@ -352,9 +341,7 @@ function parseColumn(target, dontclose) {
if (key === 0) { if (key === 0) {
left_hold = '' left_hold = ''
} }
if ( if (localStorage.getItem('mode_' + localStorage.getItem('domain_' + acct.domain)) == 'misskey') {
localStorage.getItem('mode_' + localStorage.getItem('domain_' + acct.domain)) == 'misskey'
) {
var isMisRed = '' var isMisRed = ''
exclude = '' exclude = ''
var if_misskey_hide = 'hide' var if_misskey_hide = 'hide'
@ -517,13 +504,13 @@ function parseColumn(target, dontclose) {
minHeight: 50, minHeight: 50,
minWidth: 50, minWidth: 50,
grid: 50, grid: 50,
resize: function(event, ui) { resize: function (event, ui) {
$(this).css('min-width', ui.size.width + 'px') $(this).css('min-width', ui.size.width + 'px')
$(this).css('max-width', ui.size.width + 'px') $(this).css('max-width', ui.size.width + 'px')
$(this).css('min-height', ui.size.height + 'px') $(this).css('min-height', ui.size.height + 'px')
$(this).css('max-height', ui.size.height + 'px') $(this).css('max-height', ui.size.height + 'px')
}, },
stop: function(event, ui) { stop: function (event, ui) {
var col = localStorage.getItem('column') var col = localStorage.getItem('column')
var o = JSON.parse(col) var o = JSON.parse(col)
var width = ui.size.width var width = ui.size.width
@ -538,16 +525,14 @@ function parseColumn(target, dontclose) {
} else { } else {
//横幅。その縦幅を持つカラムのidは //横幅。その縦幅を持つカラムのidは
console.log('yoko') console.log('yoko')
var key = $(this) var key = $(this).find('.boxIn').attr('tlid')
.find('.boxIn')
.attr('tlid')
var obj = o[key] var obj = o[key]
obj.width = width obj.width = width
o[key] = obj o[key] = obj
} }
var json = JSON.stringify(o) var json = JSON.stringify(o)
localStorage.setItem('column', json) localStorage.setItem('column', json)
} },
}) })
} }
function checkStr(type, data, acct_id, key, delc, voice) { function checkStr(type, data, acct_id, key, delc, voice) {
@ -597,7 +582,7 @@ function addColumn() {
} }
var add = { var add = {
domain: acct, domain: acct,
type: type type: type,
} }
var multi = localStorage.getItem('column') var multi = localStorage.getItem('column')
var obj = JSON.parse(multi) var obj = JSON.parse(multi)
@ -631,9 +616,7 @@ function addselCk() {
$('#webview-add').addClass('hide') $('#webview-add').addClass('hide')
} }
if (domain == 'knzk.me' || domain == 'mstdn.y-zu.org') { if (domain == 'knzk.me' || domain == 'mstdn.y-zu.org') {
$('#type-sel').append( $('#type-sel').append('<option value="dm" data-trans="dm" id="direct-add">' + lang.layout_dm + '</option>')
'<option value="dm" data-trans="dm" id="direct-add">' + lang.layout_dm + '</option>'
)
} else { } else {
$('#direct-add').remove() $('#direct-add').remove()
} }
@ -650,8 +633,8 @@ function removeColumn(tlid) {
confirmButtonColor: '#3085d6', confirmButtonColor: '#3085d6',
cancelButtonColor: '#d33', cancelButtonColor: '#d33',
confirmButtonText: lang.lang_yesno, confirmButtonText: lang.lang_yesno,
cancelButtonText: lang.lang_no cancelButtonText: lang.lang_no,
}).then(result => { }).then((result) => {
if (result.value) { if (result.value) {
var multi = localStorage.getItem('column') var multi = localStorage.getItem('column')
var obj = JSON.parse(multi) var obj = JSON.parse(multi)
@ -673,28 +656,28 @@ function setToggle(tlid) {
$('#util-box_' + tlid).css('display', 'block') $('#util-box_' + tlid).css('display', 'block')
$('#util-box_' + tlid).animate( $('#util-box_' + tlid).animate(
{ {
height: '200px' height: '200px',
}, },
{ {
duration: 300, duration: 300,
complete: function() { complete: function () {
$('#util-box_' + tlid).css('overflow-y', 'scroll') $('#util-box_' + tlid).css('overflow-y', 'scroll')
$('#util-box_' + tlid).removeClass('column-hide') $('#util-box_' + tlid).removeClass('column-hide')
} },
} }
) )
} else { } else {
$('#util-box_' + tlid).css('overflow-y', 'hidden') $('#util-box_' + tlid).css('overflow-y', 'hidden')
$('#util-box_' + tlid).animate( $('#util-box_' + tlid).animate(
{ {
height: '0' height: '0',
}, },
{ {
duration: 300, duration: 300,
complete: function() { complete: function () {
$('#util-box_' + tlid).addClass('column-hide') $('#util-box_' + tlid).addClass('column-hide')
$('#util-box_' + tlid).css('display', 'none') $('#util-box_' + tlid).css('display', 'none')
} },
} }
) )
} }
@ -706,28 +689,28 @@ function setToggleTag(tlid) {
$('#tag-box_' + tlid).css('display', 'block') $('#tag-box_' + tlid).css('display', 'block')
$('#tag-box_' + tlid).animate( $('#tag-box_' + tlid).animate(
{ {
height: '200px' height: '200px',
}, },
{ {
duration: 300, duration: 300,
complete: function() { complete: function () {
$('#tag-box_' + tlid).css('overflow-y', 'scroll') $('#tag-box_' + tlid).css('overflow-y', 'scroll')
$('#tag-box_' + tlid).removeClass('column-hide') $('#tag-box_' + tlid).removeClass('column-hide')
} },
} }
) )
} else { } else {
$('#tag-box_' + tlid).css('overflow-y', 'hidden') $('#tag-box_' + tlid).css('overflow-y', 'hidden')
$('#tag-box_' + tlid).animate( $('#tag-box_' + tlid).animate(
{ {
height: '0' height: '0',
}, },
{ {
duration: 300, duration: 300,
complete: function() { complete: function () {
$('#tag-box_' + tlid).addClass('column-hide') $('#tag-box_' + tlid).addClass('column-hide')
$('#tag-box_' + tlid).css('display', 'none') $('#tag-box_' + tlid).css('display', 'none')
} },
} }
) )
} }
@ -879,6 +862,8 @@ function unstreamingTL(type, key, basekey, insert, icnsert, left_fold, css, anim
} else if (type == 'bookmark') { } else if (type == 'bookmark') {
console.log(key, data) console.log(key, data)
bookmark(key, data) bookmark(key, data)
} else if (type == 'utl') {
utl(key, data.acct, data.data)
} }
cardCheck(key) cardCheck(key)
ebtCheck(key) ebtCheck(key)
@ -896,6 +881,15 @@ function bookmark(key, data) {
} }
tl('bookmark', '', data, key, 'false', voice, '') tl('bookmark', '', data, key, 'false', voice, '')
} }
function utl(key, acct_id, data) {
console.log(key, data)
if (localStorage.getItem('voice_' + key)) {
var voice = true
} else {
var voice = false
}
tl('utl', data, acct_id, 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

@ -1,6 +1,6 @@
//ユーザーデータ表示 //ユーザーデータ表示
//タイムライン //タイムライン
function utl(user, more, acct_id) { function utlShow(user, more, acct_id) {
if (!acct_id) { if (!acct_id) {
var acct_id = $("#his-data").attr("use-acct"); var acct_id = $("#his-data").attr("use-acct");
} }
@ -79,6 +79,26 @@ function utl(user, more, acct_id) {
jQuery("time.timeago").timeago(); jQuery("time.timeago").timeago();
}); });
} }
function utlAdd() {
var acct_id = $("#his-data").attr("use-acct");
var user = $("#his-data").attr("user-id");
var add = {
domain: acct_id,
type: 'utl',
data: {
id: user,
acct: $("#his-acct").attr('fullname')
}
}
var multi = localStorage.getItem('column')
var obj = JSON.parse(multi)
localStorage.setItem('card_' + obj.length, 'true')
obj.push(add)
var json = JSON.stringify(obj)
localStorage.setItem('column', json)
parseColumn('add')
hisclose()
}
//ピン留めTL //ピン留めTL
function pinutl(before, user, acct_id) { function pinutl(before, user, acct_id) {
if (!acct_id) { if (!acct_id) {

View File

@ -115,7 +115,7 @@ function udg(user, acct_id) {
$("#his-data").attr("remote", "false"); $("#his-data").attr("remote", "false");
var fullname = json.acct + "@" + domain; var fullname = json.acct + "@" + domain;
} }
utl(json.id, "", acct_id); utlShow(json.id, "", acct_id);
flw(json.id, "", acct_id); flw(json.id, "", acct_id);
fer(json.id, "", acct_id); fer(json.id, "", acct_id);
var dis_name = escapeHTML(json.display_name); var dis_name = escapeHTML(json.display_name);
@ -298,7 +298,7 @@ function misskeyUdg(user, acct_id) {
$("#his-data").attr("remote", "false"); $("#his-data").attr("remote", "false");
var fullname = json.acct + "@" + domain; var fullname = json.acct + "@" + domain;
} }
utl(json.id, "", acct_id); utlShow(json.id, "", acct_id);
flw(json.id, "", acct_id); flw(json.id, "", acct_id);
fer(json.id, "", acct_id); fer(json.id, "", acct_id);
if (json.name) { if (json.name) {

View File

@ -900,11 +900,18 @@
</ul> </ul>
</div> </div>
<div id="his-tl" class="his-var-content"> <div id="his-tl" class="his-var-content">
<button
class="btn waves-effect grey"
style="width:100%; padding:0;"
onclick="utlAdd()"
>
@@utlColumn@@
</button>
<div id="his-tl-contents" class="cont-series"></div> <div id="his-tl-contents" class="cont-series"></div>
<button <button
class="btn waves-effect " class="btn waves-effect "
style="width:100%; padding:0;" style="width:100%; padding:0;"
onclick="utl('--now','more')" onclick="utlShow('--now','more')"
> >
@@more@@ @@more@@
</button> </button>

View File

@ -75,6 +75,7 @@
"toots":"Toots", "toots":"Toots",
"follow":"Follow", "follow":"Follow",
"follower":"Follower", "follower":"Follower",
"utlColumn":"Show as a column",
"timeline":"Timeline", "timeline":"Timeline",
"operateOtherAcct":"Cross-account", "operateOtherAcct":"Cross-account",
"list":"List", "list":"List",

View File

@ -73,6 +73,7 @@
"toots":"トゥート", "toots":"トゥート",
"follow":"フォロー", "follow":"フォロー",
"follower":"フォロワー", "follower":"フォロワー",
"utlColumn":"カラムとして追加",
"timeline":"タイムライン", "timeline":"タイムライン",
"operateOtherAcct":"他のアカウント使うて何かする", "operateOtherAcct":"他のアカウント使うて何かする",
"list":"リスト", "list":"リスト",

View File

@ -75,6 +75,7 @@
"toots":"トゥート", "toots":"トゥート",
"follow":"フォロー", "follow":"フォロー",
"follower":"フォロワー", "follower":"フォロワー",
"utlColumn":"カラムとして追加",
"timeline":"タイムライン", "timeline":"タイムライン",
"operateOtherAcct":"他のアカウントで操作", "operateOtherAcct":"他のアカウントで操作",
"list":"リスト", "list":"リスト",