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')
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') {
//ホームならお知らせ「も」取りに行く
announ(acct_id, tlid)
@ -464,6 +477,10 @@ function moreload(type, tlid) {
} else if (type == 'bookmark') {
getBookmark(acct_id, tlid, true)
return
} else if (type == 'utl') {
var data = obj[tlid].data
getUtl(acct_id, tlid, data, true)
return
}
moreloading = true
localStorage.setItem('now', type)
@ -826,6 +843,8 @@ function cap(type, data, acct_id) {
var response = 'tootsearch(' + escapeHTML(data) + ')'
} else if (type == 'bookmark') {
var response = 'Bookmarks'
} else if (type == 'utl') {
var response = 'User TL(' + data.acct + ')'
}
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
function announ(acct_id, tlid) {
var at = localStorage.getItem('acct_' + acct_id + '_at')

View File

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

View File

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

View File

@ -900,11 +900,18 @@
</ul>
</div>
<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>
<button
class="btn waves-effect "
style="width:100%; padding:0;"
onclick="utl('--now','more')"
onclick="utlShow('--now','more')"
>
@@more@@
</button>

View File

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

View File

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

View File

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