diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 00000000..216ef32a --- /dev/null +++ b/.prettierrc @@ -0,0 +1,8 @@ +{ + "tabWidth": 4, + "useTabs": true, + "semi": false, + "singleQuote": true, + "printWidth": 200, + "jsxBracketSameLine": true +} \ No newline at end of file diff --git a/app/js/post/status.js b/app/js/post/status.js index 8b0797ec..4cbf0984 100644 --- a/app/js/post/status.js +++ b/app/js/post/status.js @@ -1,685 +1,703 @@ //お気に入り登録やブースト等、フォローやブロック等 //お気に入り登録 function fav(id, acct_id, remote) { - if ($(`.cvo[unique-id=${id}]`).hasClass('faved')) { - var flag = 'unfavourite' - } else { - var flag = 'favourite' - } - var domain = localStorage.getItem('domain_' + acct_id) - var at = localStorage.getItem('acct_' + acct_id + '_at') - var start = 'https://' + domain + '/api/v1/statuses/' + id + '/' + flag - var httpreq = new XMLHttpRequest() - httpreq.open('POST', 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, json) - } - if (json.reblog) { - json = json.reblog - } - if (remote != 'remote') { - //APIのふぁぼカウントがおかしい - if ($('[unique-id=' + id + '] .fav_ct').text() == json.favourites_count) { - if (flag == 'unfavourite') { - var fav = json.favourites_count - 1 - if (fav * 1 < 0) { - fav = 0 - } - } else { - var fav = json.favourites_count - //var fav = json.favourites_count; - } - } else { - var fav = json.favourites_count - } - $('[unique-id=' + id + '] .fav_ct').text(fav) - $('[unique-id=' + id + '] .rt_ct').text(json.reblogs_count) - if ($('[unique-id=' + id + ']').hasClass('faved')) { - $('[unique-id=' + id + ']').removeClass('faved') - $('.fav_' + id).removeClass('yellow-text') - } else { - $('[unique-id=' + id + ']').addClass('faved') - $('.fav_' + id).addClass('yellow-text') - } - } else { - M.toast({ html: lang.lang_status_favWarn, displayLength: 1000 }) - } - } - } + if ($(`.cvo[unique-id=${id}]`).hasClass('faved')) { + var flag = 'unfavourite' + } else { + var flag = 'favourite' + } + var domain = localStorage.getItem('domain_' + acct_id) + var at = localStorage.getItem('acct_' + acct_id + '_at') + var start = 'https://' + domain + '/api/v1/statuses/' + id + '/' + flag + var httpreq = new XMLHttpRequest() + httpreq.open('POST', 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, json) + } + if (json.reblog) { + json = json.reblog + } + if (remote != 'remote') { + //APIのふぁぼカウントがおかしい + if ($('[unique-id=' + id + '] .fav_ct').text() == json.favourites_count) { + if (flag == 'unfavourite') { + var fav = json.favourites_count - 1 + if (fav * 1 < 0) { + fav = 0 + } + } else { + var fav = json.favourites_count + //var fav = json.favourites_count; + } + } else { + var fav = json.favourites_count + } + $('[unique-id=' + id + '] .fav_ct').text(fav) + $('[unique-id=' + id + '] .rt_ct').text(json.reblogs_count) + if ($('[unique-id=' + id + ']').hasClass('faved')) { + $('[unique-id=' + id + ']').removeClass('faved') + $('.fav_' + id).removeClass('yellow-text') + } else { + $('[unique-id=' + id + ']').addClass('faved') + $('.fav_' + id).addClass('yellow-text') + } + } else { + M.toast({ html: lang.lang_status_favWarn, displayLength: 1000 }) + } + } + } } //ブースト function rt(id, acct_id, remote, vis) { - if ($(`.cvo[toot-id=${id}]`).hasClass('rted')) { - var flag = 'unreblog' - } else { - var flag = 'reblog' - } - var domain = localStorage.getItem('domain_' + acct_id) - var at = localStorage.getItem('acct_' + acct_id + '_at') - var start = 'https://' + domain + '/api/v1/statuses/' + id + '/' + flag - var httpreq = new XMLHttpRequest() - httpreq.open('POST', start, true) - httpreq.setRequestHeader('Content-Type', 'application/json') - httpreq.setRequestHeader('Authorization', 'Bearer ' + at) - httpreq.responseType = 'json' - if (vis) { - httpreq.send(JSON.stringify({ visibility: vis })) - } else { - httpreq.send() - } - httpreq.onreadystatechange = function () { - if (httpreq.readyState === 4) { - var json = httpreq.response - if (this.status !== 200) { - setLog(start, this.status, json) - } - if (json.reblog) { - json = json.reblog - } - console.log(['Success: boost', json]) - $('[toot-id=' + id + '] .fav_ct').text(json.favourites_count) - if (!json.reblog) { - if (flag == 'unreblog') { - var rt = json.reblogs_count - 1 - if (rt * 1 < 0) { - rt = 0 - } - } else { - var rt = json.reblogs_count - } - $('[toot-id=' + id + '] .rt_ct').text(rt) - } else { - $('[toot-id=' + id + '] .rt_ct').text(json.reblogs_count) - } + if ($(`.cvo[toot-id=${id}]`).hasClass('rted')) { + var flag = 'unreblog' + } else { + var flag = 'reblog' + } + var domain = localStorage.getItem('domain_' + acct_id) + var at = localStorage.getItem('acct_' + acct_id + '_at') + var start = 'https://' + domain + '/api/v1/statuses/' + id + '/' + flag + var httpreq = new XMLHttpRequest() + httpreq.open('POST', start, true) + httpreq.setRequestHeader('Content-Type', 'application/json') + httpreq.setRequestHeader('Authorization', 'Bearer ' + at) + httpreq.responseType = 'json' + if (vis) { + httpreq.send(JSON.stringify({ visibility: vis })) + } else { + httpreq.send() + } + httpreq.onreadystatechange = function() { + if (httpreq.readyState === 4) { + var json = httpreq.response + if (this.status !== 200) { + setLog(start, this.status, json) + } + if (json.reblog) { + json = json.reblog + } + console.log(['Success: boost', json]) + $('[toot-id=' + id + '] .fav_ct').text(json.favourites_count) + if (!json.reblog) { + if (flag == 'unreblog') { + var rt = json.reblogs_count - 1 + if (rt * 1 < 0) { + rt = 0 + } + } else { + var rt = json.reblogs_count + } + $('[toot-id=' + id + '] .rt_ct').text(rt) + } else { + $('[toot-id=' + id + '] .rt_ct').text(json.reblogs_count) + } - if ($('[toot-id=' + id + ']').hasClass('rted')) { - $('[toot-id=' + id + ']').removeClass('rted') - $('.rt_' + id).removeClass('light-blue-text') - } else { - $('[toot-id=' + id + ']').addClass('rted') - $('.rt_' + id).addClass('light-blue-text') - } - } - } + if ($('[toot-id=' + id + ']').hasClass('rted')) { + $('[toot-id=' + id + ']').removeClass('rted') + $('.rt_' + id).removeClass('light-blue-text') + } else { + $('[toot-id=' + id + ']').addClass('rted') + $('.rt_' + id).addClass('light-blue-text') + } + } + } } + function boostWith(vis) { - var id = $('#tootmodal').attr('data-id') - var acct_id = $('#tootmodal').attr('data-acct') - rt(id, acct_id, false, vis) + var id = $('#tootmodal').attr('data-id') + var acct_id = $('#tootmodal').attr('data-acct') + rt(id, acct_id, false, vis) } //ブックマーク function bkm(id, acct_id, tlid) { - if ($(`.cvo[unique-id=${id}]`).hasClass('bkmed')) { - var flag = 'unbookmark' - } else { - var flag = 'bookmark' - } - var domain = localStorage.getItem('domain_' + acct_id) - var at = localStorage.getItem('acct_' + acct_id + '_at') - var start = 'https://' + domain + '/api/v1/statuses/' + id + '/' + flag - var httpreq = new XMLHttpRequest() - httpreq.open('POST', 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, json) - } - if (json.reblog) { - json = json.reblog - } - var fav = json.favourites_count - $('[toot-id=' + id + '] .fav_ct').text(fav) - $('[toot-id=' + id + '] .rt_ct').text(json.reblogs_count) - if (flag == 'unbookmark') { - $('.bkmStr_' + id).text(lang.lang_parse_bookmark) - $('.bkm_' + id).removeClass('red-text') - $('[toot-id=' + id + ']').removeClass('bkmed') - } else { - $('.bkmStr_' + id).text(lang.lang_parse_unbookmark) - $('.bkm_' + id).addClass('red-text') - $('[toot-id=' + id + ']').addClass('bkmed') - } - var tlidTar = $(`.bookmark-timeline[data-acct=${acct_id}]`).attr('tlid') - columnReload(tlidTar, 'bookmark') - } - } + if ($(`.cvo[unique-id=${id}]`).hasClass('bkmed')) { + var flag = 'unbookmark' + } else { + var flag = 'bookmark' + } + var domain = localStorage.getItem('domain_' + acct_id) + var at = localStorage.getItem('acct_' + acct_id + '_at') + var start = 'https://' + domain + '/api/v1/statuses/' + id + '/' + flag + var httpreq = new XMLHttpRequest() + httpreq.open('POST', 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, json) + } + if (json.reblog) { + json = json.reblog + } + var fav = json.favourites_count + $('[toot-id=' + id + '] .fav_ct').text(fav) + $('[toot-id=' + id + '] .rt_ct').text(json.reblogs_count) + if (flag == 'unbookmark') { + $('.bkmStr_' + id).text(lang.lang_parse_bookmark) + $('.bkm_' + id).removeClass('red-text') + $('[toot-id=' + id + ']').removeClass('bkmed') + } else { + $('.bkmStr_' + id).text(lang.lang_parse_unbookmark) + $('.bkm_' + id).addClass('red-text') + $('[toot-id=' + id + ']').addClass('bkmed') + } + var tlidTar = $(`.bookmark-timeline[data-acct=${acct_id}]`).attr('tlid') + columnReload(tlidTar, 'bookmark') + } + } } //フォロー async function follow(acct_id, resolve) { - if ($('#his-data').hasClass('locked')) { - locked = true - } else { - locked = false - } - if (!acct_id && acct_id != 'selector') { - var acct_id = $('#his-data').attr('use-acct') + if ($('#his-data').hasClass('locked')) { + locked = true + } else { + locked = false + } + if (!acct_id && acct_id != 'selector') { + var acct_id = $('#his-data').attr('use-acct') + } else if (acct_id == 'selector') { + var acct_id = $('#user-acct-sel').val() + } + if (!resolve && $('#his-data').hasClass('following')) { + var flag = 'unfollow' + var flagm = 'delete' + } else { + var flag = 'follow' + var flagm = 'create' + } - } else if (acct_id == 'selector') { - var acct_id = $('#user-acct-sel').val() - } - if (!resolve && $('#his-data').hasClass('following')) { - var flag = 'unfollow' - var flagm = 'delete' - } else { - var flag = 'follow' - var flagm = 'create' - } - - var id = $('#his-data').attr('user-id') - if (resolve == 'selector') { - var fullacct = $('#his-acct').attr('fullname') - var id = await acctResolve(acct_id, fullacct) - console.log(id) - } - var domain = localStorage.getItem('domain_' + acct_id) - var at = localStorage.getItem('acct_' + acct_id + '_at') - var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag - if (localStorage.getItem('mode_' + domain) == 'misskey') { - var start = 'https://' + domain + '/api/following/' + flagm - var ent = { i: at, userId: id } - } else if (flag == 'follow') { - var ent = {} - } - var httpreq = new XMLHttpRequest() - httpreq.open('POST', start, true) - httpreq.setRequestHeader('Content-Type', 'application/json') - httpreq.setRequestHeader('Authorization', 'Bearer ' + at) - httpreq.responseType = 'json' - httpreq.send(JSON.stringify(ent)) - httpreq.onreadystatechange = function () { - if (httpreq.readyState === 4) { - var json = httpreq.response - if (this.status !== 200) { - setLog(start, this.status, json) - } - console.log(['Success: folllow', json]) - if ($('#his-data').hasClass('following')) { - $('#his-data').removeClass('following') - $('#his-follow-btn-text').text(lang.lang_status_follow) - } else { - $('#his-data').addClass('following') - if (locked) { - $('#his-follow-btn-text').text(lang.lang_status_requesting) - } else { - $('#his-follow-btn-text').text(lang.lang_status_unfollow) - } - } - } - } + var id = $('#his-data').attr('user-id') + if (resolve == 'selector') { + var fullacct = $('#his-acct').attr('fullname') + var data = await acctResolve(acct_id, fullacct) + var { id } = data + console.log(id) + } + var domain = localStorage.getItem('domain_' + acct_id) + var at = localStorage.getItem('acct_' + acct_id + '_at') + var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag + if (localStorage.getItem('mode_' + domain) == 'misskey') { + var start = 'https://' + domain + '/api/following/' + flagm + var ent = { i: at, userId: id } + } else if (flag == 'follow') { + var ent = {} + } + var httpreq = new XMLHttpRequest() + httpreq.open('POST', start, true) + httpreq.setRequestHeader('Content-Type', 'application/json') + httpreq.setRequestHeader('Authorization', 'Bearer ' + at) + httpreq.responseType = 'json' + httpreq.send(JSON.stringify(ent)) + httpreq.onreadystatechange = function() { + if (httpreq.readyState === 4) { + var json = httpreq.response + if (this.status !== 200) { + setLog(start, this.status, json) + } + console.log(['Success: folllow', json]) + if ($('#his-data').hasClass('following')) { + $('#his-data').removeClass('following') + $('#his-follow-btn-text').text(lang.lang_status_follow) + } else { + $('#his-data').addClass('following') + if (locked) { + $('#his-follow-btn-text').text(lang.lang_status_requesting) + } else { + $('#his-follow-btn-text').text(lang.lang_status_unfollow) + } + } + } + } } async function acctResolve(acct_id, user) { - console.log('Get user data of ' + user) - var domain = localStorage.getItem('domain_' + acct_id) - if (localStorage.getItem('mode_' + domain) == 'misskey') { - return false - } - var at = localStorage.getItem('acct_' + acct_id + '_at') - var start = 'https://' + domain + '/api/v2/search?resolve=true&q=' + user - let promise = await fetch(start, { - method: 'GET', - headers: { - 'content-type': 'application/json', - Authorization: 'Bearer ' + at - } - }) - var idJson = await promise.json() - if (idJson.accounts[0]) { - var id = idJson.accounts[0].id - } else { - M.toast({ html: lang.lang_fatalerroroccured, displayLength: 2000 }) - } - return id -} + console.log('Get user data of ' + user) + const domain = localStorage.getItem('domain_' + acct_id) + if (localStorage.getItem('mode_' + domain) == 'misskey') { + return false + } + const at = localStorage.getItem('acct_' + acct_id + '_at') + const options = { + method: 'GET', + headers: { + 'content-type': 'application/json', + Authorization: 'Bearer ' + at, + }, + } + try { + const start = `https://${domain}/api/v1/accounts/lookup?acct=${user}` + const promise = fetch(start, options) + const idJson = await promise.json() + if (idJson) { + return idJson + } else { + return await acctResolveLegacy(domain, user, options) + } + } catch { + return await acctResolveLegacy(domain, user, options) + } +} +async function acctResolveLegacy(domain, user, options) { + console.log(`Get user data of ${user} with legacy method`) + try { + const start = 'https://' + domain + '/api/v2/search?resolve=true&q=' + user + const promise = fetch(start, options) + const idJson = await promise.json() + if (idJson.accounts[0]) { + return idJson.accounts[0] + } else { + M.toast({ html: lang.lang_fatalerroroccured, displayLength: 2000 }) + } + } catch { + console.log('Error occured on searching and fetching with resolve') + } +} //ブロック function block(acct_id) { - if ($('#his-data').hasClass('blocking')) { - var flag = 'unblock' - var txt = lang.lang_status_unmute - } else { - var flag = 'block' - var txt = lang.lang_status_block - } - Swal.fire({ - title: txt, - text: '', - type: 'warning', - showCancelButton: true, - confirmButtonText: lang.lang_yesno, - cancelButtonText: lang.lang_no - }).then(result => { - if (result.value) { - if (!acct_id) { - var acct_id = $('#his-data').attr('use-acct') - } - var id = $('#his-data').attr('user-id') - var domain = localStorage.getItem('domain_' + acct_id) - var at = localStorage.getItem('acct_' + acct_id + '_at') - var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag - var httpreq = new XMLHttpRequest() - httpreq.open('POST', 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) { - if (this.status !== 200) { - setLog(start, this.status, this.response) - } - if ($('#his-data').hasClass('blocking')) { - $('#his-data').removeClass('blocking') - $('#his-block-btn-text').text(lang.lang_status_block) - } else { - $('#his-data').addClass('blocking') - $('#his-block-btn-text').text(lang.lang_status_unblock) - } - } - } - } - }) + if ($('#his-data').hasClass('blocking')) { + var flag = 'unblock' + var txt = lang.lang_status_unmute + } else { + var flag = 'block' + var txt = lang.lang_status_block + } + Swal.fire({ + title: txt, + text: '', + type: 'warning', + showCancelButton: true, + confirmButtonText: lang.lang_yesno, + cancelButtonText: lang.lang_no, + }).then((result) => { + if (result.value) { + if (!acct_id) { + var acct_id = $('#his-data').attr('use-acct') + } + var id = $('#his-data').attr('user-id') + var domain = localStorage.getItem('domain_' + acct_id) + var at = localStorage.getItem('acct_' + acct_id + '_at') + var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag + var httpreq = new XMLHttpRequest() + httpreq.open('POST', 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) { + if (this.status !== 200) { + setLog(start, this.status, this.response) + } + if ($('#his-data').hasClass('blocking')) { + $('#his-data').removeClass('blocking') + $('#his-block-btn-text').text(lang.lang_status_block) + } else { + $('#his-data').addClass('blocking') + $('#his-block-btn-text').text(lang.lang_status_unblock) + } + } + } + } + }) } //ミュート function muteDo(acct_id) { - if ($('#his-data').hasClass('muting')) { - var flag = 'unmute' - var flagm = 'delete' - var txt = lang.lang_status_unmute - } else { - var flag = 'mute' - var flagm = 'create' - var txt = lang.lang_status_mute - } - Swal.fire({ - title: txt, - text: '', - type: 'warning', - showCancelButton: true, - confirmButtonText: lang.lang_yesno, - cancelButtonText: lang.lang_no - }).then(result => { - if (result.value) { - if (!acct_id) { - var acct_id = $('#his-data').attr('use-acct') - } - var id = $('#his-data').attr('user-id') - var domain = localStorage.getItem('domain_' + acct_id) - var at = localStorage.getItem('acct_' + acct_id + '_at') - if (localStorage.getItem('mode_' + domain) == 'misskey') { - var start = 'https://' + domain + '/api/mute/' + flagm - var ent = { i: at, userId: id } - var rq = JSON.stringify(ent) - } else { - var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag - var rq = '' - } - var httpreq = new XMLHttpRequest() - httpreq.open('POST', start, true) - httpreq.setRequestHeader('Content-Type', 'application/json') - httpreq.setRequestHeader('Authorization', 'Bearer ' + at) - httpreq.responseType = 'json' - httpreq.send(rq) - httpreq.onreadystatechange = function () { - if (httpreq.readyState === 4) { - if (this.status !== 200) { - setLog(start, this.status, this.response) - } - if ($('#his-data').hasClass('muting')) { - $('#his-data').removeClass('muting') - $('#his-mute-btn-text').text(lang.lang_status_mute) - } else { - $('#his-data').addClass('muting') - $('#his-mute-btn-text').text(lang.lang_status_unmute) - } - } - } - } - }) + if ($('#his-data').hasClass('muting')) { + var flag = 'unmute' + var flagm = 'delete' + var txt = lang.lang_status_unmute + } else { + var flag = 'mute' + var flagm = 'create' + var txt = lang.lang_status_mute + } + Swal.fire({ + title: txt, + text: '', + type: 'warning', + showCancelButton: true, + confirmButtonText: lang.lang_yesno, + cancelButtonText: lang.lang_no, + }).then((result) => { + if (result.value) { + if (!acct_id) { + var acct_id = $('#his-data').attr('use-acct') + } + var id = $('#his-data').attr('user-id') + var domain = localStorage.getItem('domain_' + acct_id) + var at = localStorage.getItem('acct_' + acct_id + '_at') + if (localStorage.getItem('mode_' + domain) == 'misskey') { + var start = 'https://' + domain + '/api/mute/' + flagm + var ent = { i: at, userId: id } + var rq = JSON.stringify(ent) + } else { + var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag + var rq = '' + } + var httpreq = new XMLHttpRequest() + httpreq.open('POST', start, true) + httpreq.setRequestHeader('Content-Type', 'application/json') + httpreq.setRequestHeader('Authorization', 'Bearer ' + at) + httpreq.responseType = 'json' + httpreq.send(rq) + httpreq.onreadystatechange = function() { + if (httpreq.readyState === 4) { + if (this.status !== 200) { + setLog(start, this.status, this.response) + } + if ($('#his-data').hasClass('muting')) { + $('#his-data').removeClass('muting') + $('#his-mute-btn-text').text(lang.lang_status_mute) + } else { + $('#his-data').addClass('muting') + $('#his-mute-btn-text').text(lang.lang_status_unmute) + } + } + } + } + }) } //投稿削除 function del(id, acct_id) { - var domain = localStorage.getItem('domain_' + acct_id) - var at = localStorage.getItem('acct_' + acct_id + '_at') - if (localStorage.getItem('mode_' + domain) == 'misskey') { - var start = 'https://' + domain + '/api/notes/delete' - var httpreq = new XMLHttpRequest() - httpreq.open('POST', start, true) - httpreq.setRequestHeader('Content-Type', 'application/json') - httpreq.responseType = 'json' - httpreq.send(JSON.stringify({ i: at, noteId: id })) - $('[toot-id=' + id + ']').hide() - $('[toot-id=' + id + ']').remove() - } else { - var start = 'https://' + domain + '/api/v1/statuses/' + id - var httpreq = new XMLHttpRequest() - httpreq.open('DELETE', 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) { - if (this.status !== 200) { - setLog(start, this.status, this.response) - } - } - } + var domain = localStorage.getItem('domain_' + acct_id) + var at = localStorage.getItem('acct_' + acct_id + '_at') + if (localStorage.getItem('mode_' + domain) == 'misskey') { + var start = 'https://' + domain + '/api/notes/delete' + var httpreq = new XMLHttpRequest() + httpreq.open('POST', start, true) + httpreq.setRequestHeader('Content-Type', 'application/json') + httpreq.responseType = 'json' + httpreq.send(JSON.stringify({ i: at, noteId: id })) + $('[toot-id=' + id + ']').hide() + $('[toot-id=' + id + ']').remove() + } else { + var start = 'https://' + domain + '/api/v1/statuses/' + id + var httpreq = new XMLHttpRequest() + httpreq.open('DELETE', 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) { + if (this.status !== 200) { + setLog(start, this.status, this.response) + } + } + } } //redraft function redraft(id, acct_id) { - Swal.fire({ - title: lang.lang_status_redraftTitle, - text: lang.lang_status_redraft, - type: 'warning', - showCancelButton: true, - confirmButtonText: lang.lang_yesno, - cancelButtonText: lang.lang_no - }).then(result => { - if (result.value) { - show() - var domain = localStorage.getItem('domain_' + acct_id) - var at = localStorage.getItem('acct_' + acct_id + '_at') - if (localStorage.getItem('mode_' + domain) == 'misskey') { - var start = 'https://' + domain + '/api/notes/delete' - var httpreq = new XMLHttpRequest() - httpreq.open('POST', start, true) - httpreq.setRequestHeader('Content-Type', 'application/json') - httpreq.responseType = 'json' - httpreq.send(JSON.stringify({ i: at, noteId: id })) - $('[toot-id=' + id + ']').hide() - $('[toot-id=' + id + ']').remove() - } else { - var start = 'https://' + domain + '/api/v1/statuses/' + id - var httpreq = new XMLHttpRequest() - httpreq.open('DELETE', 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) { - if (this.status !== 200) { - setLog(start, this.status, this.response) - } - var json = httpreq.response - draftToPost(json, acct_id, id) - } - } - } - }) + Swal.fire({ + title: lang.lang_status_redraftTitle, + text: lang.lang_status_redraft, + type: 'warning', + showCancelButton: true, + confirmButtonText: lang.lang_yesno, + cancelButtonText: lang.lang_no, + }).then((result) => { + if (result.value) { + show() + var domain = localStorage.getItem('domain_' + acct_id) + var at = localStorage.getItem('acct_' + acct_id + '_at') + if (localStorage.getItem('mode_' + domain) == 'misskey') { + var start = 'https://' + domain + '/api/notes/delete' + var httpreq = new XMLHttpRequest() + httpreq.open('POST', start, true) + httpreq.setRequestHeader('Content-Type', 'application/json') + httpreq.responseType = 'json' + httpreq.send(JSON.stringify({ i: at, noteId: id })) + $('[toot-id=' + id + ']').hide() + $('[toot-id=' + id + ']').remove() + } else { + var start = 'https://' + domain + '/api/v1/statuses/' + id + var httpreq = new XMLHttpRequest() + httpreq.open('DELETE', 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) { + if (this.status !== 200) { + setLog(start, this.status, this.response) + } + var json = httpreq.response + draftToPost(json, acct_id, id) + } + } + } + }) } + function draftToPost(json, acct_id, id) { - $('#post-acct-sel').prop('disabled', true) - $('#post-acct-sel').val(acct_id) - $('select').formSelect() - mdCheck() - mediack = null - if(json.media_attachments) mediack = json.media_attachments[0] - //メディアがあれば - var media_ids = [] - if (mediack) { - for (var i = 0; i <= 4; i++) { - if (json.media_attachments[i]) { - media_ids.push(json.media_attachments[i].id) - $('#preview').append( - '' - ) - } else { - break - } - } - } - var vismode = json.visibility - vis(vismode) - var medias = media_ids.join(',') - $('#media').val(medias) - localStorage.setItem('nohide', true) - show() - if (json.text) { - var html = json.text - } else { - var html = json.status - html = html.replace(/^
(.+)<\/p>$/, '$1')
- html = html.replace(/
/, '\n')
- html = html.replace(/
/, '\n') - html = html.replace(/<\/p>/, '\n') - html = html.replace(//g, '$1') - html = $.strip_tags(html) - } - $('#textarea').val(html) - if (json.spoiler_text) { - cw(true) - $('#cw-text').val(json.spoiler_text) - } - if (json.sensitive) { - $('#nsfw').addClass('yellow-text') - $('#nsfw').html('visibility') - $('#nsfw').addClass('nsfw-avail') - } - if (json.in_reply_to_id) { - $('#reply').val(json.in_reply_to_id) - } + $('#post-acct-sel').prop('disabled', true) + $('#post-acct-sel').val(acct_id) + $('select').formSelect() + mdCheck() + mediack = null + if (json.media_attachments) mediack = json.media_attachments[0] + //メディアがあれば + var media_ids = [] + if (mediack) { + for (var i = 0; i <= 4; i++) { + if (json.media_attachments[i]) { + media_ids.push(json.media_attachments[i].id) + $('#preview').append('') + } else { + break + } + } + } + var vismode = json.visibility + vis(vismode) + var medias = media_ids.join(',') + $('#media').val(medias) + localStorage.setItem('nohide', true) + show() + if (json.text) { + var html = json.text + } else { + var html = json.status + html = html.replace(/^
(.+)<\/p>$/, '$1')
+ html = html.replace(/
/, '\n')
+ html = html.replace(/
/, '\n')
+ html = html.replace(/<\/p>/, '\n')
+ html = html.replace(//g, '$1')
+ html = $.strip_tags(html)
+ }
+ $('#textarea').val(html)
+ if (json.spoiler_text) {
+ cw(true)
+ $('#cw-text').val(json.spoiler_text)
+ }
+ if (json.sensitive) {
+ $('#nsfw').addClass('yellow-text')
+ $('#nsfw').html('visibility')
+ $('#nsfw').addClass('nsfw-avail')
+ }
+ if (json.in_reply_to_id) {
+ $('#reply').val(json.in_reply_to_id)
+ }
}
//ピン留め
function pin(id, acct_id) {
- if ($(`.cvo[unique-id=${id}]`).hasClass('pined')) {
- var flag = 'unpin'
- } else {
- var flag = 'pin'
- }
- var domain = localStorage.getItem('domain_' + acct_id)
- var at = localStorage.getItem('acct_' + acct_id + '_at')
- var start = 'https://' + domain + '/api/v1/statuses/' + id + '/' + flag
- var httpreq = new XMLHttpRequest()
- httpreq.open('POST', 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)
- }
- console.log(['Success: pinned', json])
- if (flag == 'unpin') {
- $('[toot-id=' + id + ']').removeClass('pined')
- $('.pin_' + id).removeClass('blue-text')
- $('.pinStr_' + id).text(lang.lang_parse_pin)
- } else {
- $('[toot-id=' + id + ']').addClass('pined')
- $('.pin_' + id).addClass('blue-text')
- $('.pinStr_' + id).text(lang.lang_parse_unpin)
- }
- }
- }
+ if ($(`.cvo[unique-id=${id}]`).hasClass('pined')) {
+ var flag = 'unpin'
+ } else {
+ var flag = 'pin'
+ }
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/v1/statuses/' + id + '/' + flag
+ var httpreq = new XMLHttpRequest()
+ httpreq.open('POST', 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)
+ }
+ console.log(['Success: pinned', json])
+ if (flag == 'unpin') {
+ $('[toot-id=' + id + ']').removeClass('pined')
+ $('.pin_' + id).removeClass('blue-text')
+ $('.pinStr_' + id).text(lang.lang_parse_pin)
+ } else {
+ $('[toot-id=' + id + ']').addClass('pined')
+ $('.pin_' + id).addClass('blue-text')
+ $('.pinStr_' + id).text(lang.lang_parse_unpin)
+ }
+ }
+ }
}
//フォロリク
function request(id, flag, acct_id) {
- var domain = localStorage.getItem('domain_' + acct_id)
- var at = localStorage.getItem('acct_' + acct_id + '_at')
- var start = 'https://' + domain + '/api/v1/follow_requests/' + id + '/' + flag
- var httpreq = new XMLHttpRequest()
- httpreq.open('POST', 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)
- }
- console.log(['Success: request', 'type:' + flag, json])
- showReq()
- }
- }
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/v1/follow_requests/' + id + '/' + flag
+ var httpreq = new XMLHttpRequest()
+ httpreq.open('POST', 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)
+ }
+ console.log(['Success: request', 'type:' + flag, json])
+ showReq()
+ }
+ }
}
//ドメインブロック(未実装)
function domainblock(add, flag, acct_id) {
- if (!acct_id) {
- var acct_id = $('#his-data').attr('use-acct')
- }
- var domain = localStorage.getItem('domain_' + acct_id)
- var at = localStorage.getItem('acct_' + acct_id + '_at')
- var start = 'https://' + domain + '/api/v1/domain_blocks'
- var httpreq = new XMLHttpRequest()
- httpreq.open('POST', 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)
- }
- console.log(['Success: domain block', json])
- showDom()
- }
- }
+ if (!acct_id) {
+ var acct_id = $('#his-data').attr('use-acct')
+ }
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/v1/domain_blocks'
+ var httpreq = new XMLHttpRequest()
+ httpreq.open('POST', 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)
+ }
+ console.log(['Success: domain block', json])
+ showDom()
+ }
+ }
}
function addDomainblock() {
- var domain = $('#domainblock').val()
- domainblock(domain, 'POST')
+ var domain = $('#domainblock').val()
+ domainblock(domain, 'POST')
}
//ユーザー強調
function empUser() {
- var usr = localStorage.getItem('user_emp')
- var obj = JSON.parse(usr)
- var id = $('#his-acct').attr('fullname')
- if (!obj) {
- var obj = []
- obj.push(id)
- M.toast({ html: id + lang.lang_status_emphas, displayLength: 4000 })
- } else {
- var can
- Object.keys(obj).forEach(function (key) {
- var usT = obj[key]
- if (usT != id && !can) {
- can = false
- } else {
- can = true
- obj.splice(key, 1)
- M.toast({ html: id + lang.lang_status_unemphas, displayLength: 4000 })
- }
- })
- }
- var json = JSON.stringify(obj)
- localStorage.setItem('user_emp', json)
+ var usr = localStorage.getItem('user_emp')
+ var obj = JSON.parse(usr)
+ var id = $('#his-acct').attr('fullname')
+ if (!obj) {
+ var obj = []
+ obj.push(id)
+ M.toast({ html: id + lang.lang_status_emphas, displayLength: 4000 })
+ } else {
+ var can
+ Object.keys(obj).forEach(function(key) {
+ var usT = obj[key]
+ if (usT != id && !can) {
+ can = false
+ } else {
+ can = true
+ obj.splice(key, 1)
+ M.toast({ html: id + lang.lang_status_unemphas, displayLength: 4000 })
+ }
+ })
+ }
+ var json = JSON.stringify(obj)
+ localStorage.setItem('user_emp', json)
}
//Endorse
function pinUser() {
- var id = $('#his-data').attr('user-id')
- var acct_id = $('#his-data').attr('use-acct')
- if ($('#his-end-btn').hasClass('endorsed')) {
- var flag = 'unpin'
- } else {
- var flag = 'pin'
- }
- var domain = localStorage.getItem('domain_' + acct_id)
- var at = localStorage.getItem('acct_' + acct_id + '_at')
- var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag
- var httpreq = new XMLHttpRequest()
- httpreq.open('POST', 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)
- }
- if ($('#his-end-btn').hasClass('endorsed')) {
- $('#his-end-btn').removeClass('endorsed')
- $('#his-end-btn').text(lang.lang_status_endorse)
- } else {
- $('#his-end-btn').addClass('endorsed')
- $('#his-end-btn').text(lang.lang_status_unendorse)
- }
- }
- }
+ var id = $('#his-data').attr('user-id')
+ var acct_id = $('#his-data').attr('use-acct')
+ if ($('#his-end-btn').hasClass('endorsed')) {
+ var flag = 'unpin'
+ } else {
+ var flag = 'pin'
+ }
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/v1/accounts/' + id + '/' + flag
+ var httpreq = new XMLHttpRequest()
+ httpreq.open('POST', 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)
+ }
+ if ($('#his-end-btn').hasClass('endorsed')) {
+ $('#his-end-btn').removeClass('endorsed')
+ $('#his-end-btn').text(lang.lang_status_endorse)
+ } else {
+ $('#his-end-btn').addClass('endorsed')
+ $('#his-end-btn').text(lang.lang_status_unendorse)
+ }
+ }
+ }
}
//URLコピー
function tootUriCopy(url) {
- execCopy(url)
- M.toast({ html: lang.lang_details_url, displayLength: 1500 })
+ execCopy(url)
+ M.toast({ html: lang.lang_details_url, displayLength: 1500 })
}
//他のアカウントで…
function staEx(mode) {
- var url = $('#tootmodal').attr('data-url')
- var acct_id = $('#status-acct-sel').val()
- var domain = localStorage.getItem('domain_' + acct_id)
- var at = localStorage.getItem('acct_' + acct_id + '_at')
- var start = 'https://' + domain + '/api/v2/search?resolve=true&q=' + url
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json',
- Authorization: 'Bearer ' + at
- }
- })
- .then(function (response) {
- if (!response.ok) {
- response.text().then(function (text) {
- setLog(response.url, response.status, text)
- })
- }
- return response.json()
- })
- .catch(function (error) {
- todo(error)
- setLog(start, 'JSON', error)
- console.error(error)
- })
- .then(function (json) {
- if (json.statuses) {
- if (json.statuses[0]) {
- var id = json.statuses[0].id
- if (mode == 'rt') {
- rt(id, acct_id, 'remote')
- } else if (mode == 'fav') {
- fav(id, acct_id, 'remote')
- } else if (mode == 'reply') {
- reEx(id)
- }
- }
- }
- })
- return
+ var url = $('#tootmodal').attr('data-url')
+ var acct_id = $('#status-acct-sel').val()
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/v2/search?resolve=true&q=' + url
+ fetch(start, {
+ method: 'GET',
+ headers: {
+ 'content-type': 'application/json',
+ Authorization: 'Bearer ' + at,
+ },
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text)
+ })
+ }
+ return response.json()
+ })
+ .catch(function(error) {
+ todo(error)
+ setLog(start, 'JSON', error)
+ console.error(error)
+ })
+ .then(function(json) {
+ if (json.statuses) {
+ if (json.statuses[0]) {
+ var id = json.statuses[0].id
+ if (mode == 'rt') {
+ rt(id, acct_id, 'remote')
+ } else if (mode == 'fav') {
+ fav(id, acct_id, 'remote')
+ } else if (mode == 'reply') {
+ reEx(id)
+ }
+ }
+ }
+ })
+ return
}
+
function toggleAction(elm) {
- console.log(elm)
- const instance = M.Dropdown.init(elm)
- console.log(instance.isOpen)
- instance.open()
-}
+ console.log(elm)
+ const instance = M.Dropdown.init(elm)
+ console.log(instance.isOpen)
+ instance.open()
+}
\ No newline at end of file
diff --git a/app/js/tl/filter.js b/app/js/tl/filter.js
index f5fcf386..b0a04a96 100644
--- a/app/js/tl/filter.js
+++ b/app/js/tl/filter.js
@@ -1,487 +1,500 @@
/*メディアフィルター機能*/
//各TL上方のMedia[On/Off]
function mediaToggle(tlid) {
- var media = localStorage.getItem('media_' + tlid)
- if (media) {
- localStorage.removeItem('media_' + tlid)
- $('#sta-media-' + tlid).text('Off')
- $('#sta-media-' + tlid).css('color', 'red')
- $('#timeline_' + tlid).removeClass('media-filter')
- } else {
- localStorage.setItem('media_' + tlid, 'true')
- $('#sta-media-' + tlid).text('On')
- $('#sta-media-' + tlid).css('color', '#009688')
- $('#timeline_' + tlid).addClass('media-filter')
- }
+ var media = localStorage.getItem('media_' + tlid)
+ if (media) {
+ localStorage.removeItem('media_' + tlid)
+ $('#sta-media-' + tlid).text('Off')
+ $('#sta-media-' + tlid).css('color', 'red')
+ $('#timeline_' + tlid).removeClass('media-filter')
+ } else {
+ localStorage.setItem('media_' + tlid, 'true')
+ $('#sta-media-' + tlid).text('On')
+ $('#sta-media-' + tlid).css('color', '#009688')
+ $('#timeline_' + tlid).addClass('media-filter')
+ }
}
/* Remote only */
function remoteOnly(tlid, type) {
- var multi = localStorage.getItem('column')
- var obj = JSON.parse(multi)
- if (obj[tlid].data) {
- if (obj[tlid].data.remote) {
- obj[tlid].data.remote = false
- var json = JSON.stringify(obj)
- localStorage.setItem('column', json)
- $('#sta-remote-' + tlid).text('Off')
- $('#sta-remote-' + tlid).css('color', '#009688')
- } else {
- obj[tlid].data.remote = true
- var json = JSON.stringify(obj)
- localStorage.setItem('column', json)
- $('#sta-remote-' + tlid).text('On')
- $('#sta-remote-' + tlid).css('color', 'red')
- }
- } else {
- obj[tlid].data = {}
- obj[tlid].data.remote = true
- var json = JSON.stringify(obj)
- localStorage.setItem('column', json)
- $('#sta-remote-' + tlid).text('On')
- $('#sta-remote-' + tlid).css('color', 'red')
- }
- columnReload(tlid, type)
+ var multi = localStorage.getItem('column')
+ var obj = JSON.parse(multi)
+ if (obj[tlid].data) {
+ if (obj[tlid].data.remote) {
+ obj[tlid].data.remote = false
+ var json = JSON.stringify(obj)
+ localStorage.setItem('column', json)
+ $('#sta-remote-' + tlid).text('Off')
+ $('#sta-remote-' + tlid).css('color', '#009688')
+ } else {
+ obj[tlid].data.remote = true
+ var json = JSON.stringify(obj)
+ localStorage.setItem('column', json)
+ $('#sta-remote-' + tlid).text('On')
+ $('#sta-remote-' + tlid).css('color', 'red')
+ }
+ } else {
+ obj[tlid].data = {}
+ obj[tlid].data.remote = true
+ var json = JSON.stringify(obj)
+ localStorage.setItem('column', json)
+ $('#sta-remote-' + tlid).text('On')
+ $('#sta-remote-' + tlid).css('color', 'red')
+ }
+ columnReload(tlid, type)
}
+
function remoteOnlyCk(tlid) {
- var multi = localStorage.getItem('column')
- var obj = JSON.parse(multi)
- if (obj[tlid].data) {
- if (obj[tlid].data.remote) {
- $('#sta-remote-' + tlid).text('On')
- $('#sta-remote-' + tlid).css('color', 'red')
- return true
- }
- }
- return false
+ var multi = localStorage.getItem('column')
+ var obj = JSON.parse(multi)
+ if (obj[tlid].data) {
+ if (obj[tlid].data.remote) {
+ $('#sta-remote-' + tlid).text('On')
+ $('#sta-remote-' + tlid).css('color', 'red')
+ return true
+ }
+ }
+ return false
}
//各TL上方のBT[BTOnly/BTExc/Off]
function ebtToggle(tlid) {
- var ebt = localStorage.getItem('ebt_' + tlid)
- if (ebt == 'true') {
- localStorage.setItem('ebt_' + tlid, 'but')
- $('#sta-bt-' + tlid).text('BT Only')
- $('#sta-bt-' + tlid).css('color', '#ff9800')
- $('#timeline_' + tlid).addClass('except-bt-filter')
- $('#timeline_' + tlid).removeClass('bt-filter')
- } else if (ebt == 'but') {
- localStorage.removeItem('ebt_' + tlid)
- $('#sta-bt-' + tlid).text('Off')
- $('#sta-bt-' + tlid).css('color', 'red')
- $('#timeline_' + tlid).removeClass('bt-filter')
- $('#timeline_' + tlid).removeClass('except-bt-filter')
- } else {
- localStorage.setItem('ebt_' + tlid, 'true')
- $('#sta-bt-' + tlid).text('BT Ex')
- $('#sta-bt-' + tlid).css('color', '#009688')
- $('#timeline_' + tlid).addClass('bt-filter')
- $('#timeline_' + tlid).removeClass('except-bt-filter')
- }
+ var ebt = localStorage.getItem('ebt_' + tlid)
+ if (ebt == 'true') {
+ localStorage.setItem('ebt_' + tlid, 'but')
+ $('#sta-bt-' + tlid).text('BT Only')
+ $('#sta-bt-' + tlid).css('color', '#ff9800')
+ $('#timeline_' + tlid).addClass('except-bt-filter')
+ $('#timeline_' + tlid).removeClass('bt-filter')
+ } else if (ebt == 'but') {
+ localStorage.removeItem('ebt_' + tlid)
+ $('#sta-bt-' + tlid).text('Off')
+ $('#sta-bt-' + tlid).css('color', 'red')
+ $('#timeline_' + tlid).removeClass('bt-filter')
+ $('#timeline_' + tlid).removeClass('except-bt-filter')
+ } else {
+ localStorage.setItem('ebt_' + tlid, 'true')
+ $('#sta-bt-' + tlid).text('BT Ex')
+ $('#sta-bt-' + tlid).css('color', '#009688')
+ $('#timeline_' + tlid).addClass('bt-filter')
+ $('#timeline_' + tlid).removeClass('except-bt-filter')
+ }
}
//各TL上方のMedia[On/Off]をチェック
function mediaCheck(tlid) {
- var media = localStorage.getItem('media_' + tlid)
- if (media) {
- $('#sta-media-' + tlid).text('On')
- $('#sta-media-' + tlid).css('color', '#009688')
- $('#timeline_' + tlid).addClass('media-filter')
- } else {
- $('#sta-media-' + tlid).text('Off')
- $('#sta-media-' + tlid).css('color', 'red')
- $('#timeline_' + tlid).removeClass('media-filter')
- }
+ var media = localStorage.getItem('media_' + tlid)
+ if (media) {
+ $('#sta-media-' + tlid).text('On')
+ $('#sta-media-' + tlid).css('color', '#009688')
+ $('#timeline_' + tlid).addClass('media-filter')
+ } else {
+ $('#sta-media-' + tlid).text('Off')
+ $('#sta-media-' + tlid).css('color', 'red')
+ $('#timeline_' + tlid).removeClass('media-filter')
+ }
}
//各TL上方のBT[On/Off]をチェック
function ebtCheck(tlid) {
- var ebt = localStorage.getItem('ebt_' + tlid)
- if (ebt == 'true') {
- $('#sta-bt-' + tlid).text('BT Ex')
- $('#sta-bt-' + tlid).css('color', '#009688')
- $('#timeline_' + tlid).addClass('bt-filter')
- $('#timeline_' + tlid).removeClass('except-bt-filter')
- } else if (ebt == 'but') {
- $('#sta-bt-' + tlid).text('BT Only')
- $('#sta-bt-' + tlid).css('color', '#ff9800')
- $('#timeline_' + tlid).addClass('except-bt-filter')
- $('#timeline_' + tlid).removeClass('bt-filter')
- } else {
- $('#sta-bt-' + tlid).text('Off')
- $('#sta-bt-' + tlid).css('color', 'red')
- $('#timeline_' + tlid).removeClass('bt-filter')
- $('#timeline_' + tlid).removeClass('except-bt-filter')
- }
+ var ebt = localStorage.getItem('ebt_' + tlid)
+ if (ebt == 'true') {
+ $('#sta-bt-' + tlid).text('BT Ex')
+ $('#sta-bt-' + tlid).css('color', '#009688')
+ $('#timeline_' + tlid).addClass('bt-filter')
+ $('#timeline_' + tlid).removeClass('except-bt-filter')
+ } else if (ebt == 'but') {
+ $('#sta-bt-' + tlid).text('BT Only')
+ $('#sta-bt-' + tlid).css('color', '#ff9800')
+ $('#timeline_' + tlid).addClass('except-bt-filter')
+ $('#timeline_' + tlid).removeClass('bt-filter')
+ } else {
+ $('#sta-bt-' + tlid).text('Off')
+ $('#sta-bt-' + tlid).css('color', 'red')
+ $('#timeline_' + tlid).removeClass('bt-filter')
+ $('#timeline_' + tlid).removeClass('except-bt-filter')
+ }
}
/* 削除追跡*/
function catchToggle(tlid) {
- var catchck = localStorage.getItem('catch_' + tlid)
- if (catchck) {
- localStorage.removeItem('catch_' + tlid)
- $('#sta-del-' + tlid).text('Off')
- $('#sta-del-' + tlid).css('color', 'red')
- parseColumn(tlid)
- } else {
- localStorage.setItem('catch_' + tlid, 'true')
- $('#sta-del-' + tlid).text('On')
- $('#sta-del-' + tlid).css('color', '#009688')
- parseColumn(tlid)
- }
+ var catchck = localStorage.getItem('catch_' + tlid)
+ if (catchck) {
+ localStorage.removeItem('catch_' + tlid)
+ $('#sta-del-' + tlid).text('Off')
+ $('#sta-del-' + tlid).css('color', 'red')
+ parseColumn(tlid)
+ } else {
+ localStorage.setItem('catch_' + tlid, 'true')
+ $('#sta-del-' + tlid).text('On')
+ $('#sta-del-' + tlid).css('color', '#009688')
+ parseColumn(tlid)
+ }
}
+
function catchCheck(tlid) {
- var catchck = localStorage.getItem('catch_' + tlid)
- if (catchck) {
- $('#sta-del-' + tlid).text('On')
- $('#sta-del-' + tlid).css('color', '#009688')
- } else {
- $('#sta-del-' + tlid).text('Off')
- $('#sta-del-' + tlid).css('color', 'red')
- }
+ var catchck = localStorage.getItem('catch_' + tlid)
+ if (catchck) {
+ $('#sta-del-' + tlid).text('On')
+ $('#sta-del-' + tlid).css('color', '#009688')
+ } else {
+ $('#sta-del-' + tlid).text('Off')
+ $('#sta-del-' + tlid).css('color', 'red')
+ }
}
+
function delreset(tlid) {
- $('[tlid=' + tlid + '] .by_delcatch').hide()
- $('[tlid=' + tlid + '] .by_delcatch').remove()
+ $('[tlid=' + tlid + '] .by_delcatch').hide()
+ $('[tlid=' + tlid + '] .by_delcatch').remove()
}
/*ワードフィルター機能*/
function filterMenu() {
- $('#left-menu a').removeClass('active')
- $('#filterMenu').addClass('active')
- $('.menu-content').addClass('hide')
- $('#filter-box').removeClass('hide')
+ $('#left-menu a').removeClass('active')
+ $('#filterMenu').addClass('active')
+ $('.menu-content').addClass('hide')
+ $('#filter-box').removeClass('hide')
}
+
function filter() {
- $('#filtered-words').html('')
- $('#filter-edit-id').val('')
- var acct_id = $('#filter-acct-sel').val()
- var domain = localStorage.getItem('domain_' + acct_id)
- var at = localStorage.getItem('acct_' + acct_id + '_at')
- var start = 'https://' + domain + '/api/v1/filters'
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json',
- Authorization: 'Bearer ' + at,
- },
- })
- .then(function (response) {
- if (!response.ok) {
- response.text().then(function (text) {
- setLog(response.url, response.status, text)
- })
- }
- return response.json()
- })
- .catch(function (error) {
- todo(error)
- setLog(start, 'JSON', error)
- console.error(error)
- })
- .then(function (json) {
- if (json) {
- var filters = ''
- Object.keys(json).forEach(function (key) {
- var filterword = json[key]
- var context = filterword.context.join(',')
- filters =
- filters +
- escapeHTML(filterword.phrase) +
- `(for ${context}):
+ $('#filtered-words').html('')
+ $('#filter-edit-id').val('')
+ var acct_id = $('#filter-acct-sel').val()
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/v1/filters'
+ fetch(start, {
+ method: 'GET',
+ headers: {
+ 'content-type': 'application/json',
+ Authorization: 'Bearer ' + at,
+ },
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text)
+ })
+ }
+ return response.json()
+ })
+ .catch(function(error) {
+ todo(error)
+ setLog(start, 'JSON', error)
+ console.error(error)
+ })
+ .then(function(json) {
+ if (json) {
+ var filters = ''
+ Object.keys(json).forEach(function(key) {
+ var filterword = json[key]
+ var context = filterword.context.join(',')
+ filters =
+ filters +
+ escapeHTML(filterword.phrase) +
+ `(for ${context}):
${lang.lang_edit}
/
${lang.lang_del}
`
- })
- if (filters == '') {
- filters = lang.lang_filter_nodata + '
'
- }
- $('#filtered-words').html(filters)
- } else {
- $('#filtered-words').html(lang_filter_nodata)
- }
- })
+ })
+ if (filters == '') {
+ filters = lang.lang_filter_nodata + '
'
+ }
+ $('#filtered-words').html(filters)
+ } else {
+ $('#filtered-words').html(lang_filter_nodata)
+ }
+ })
}
-function filterTime(day, hour, min) {
- $('#days_filter').val(day)
- $('#hours_filter').val(hour)
- $('#mins_filter').val(min)
-}
-function makeNewFilter() {
- var acct_id = $('#filter-acct-sel').val()
- var phr = $('#filter-add-word').val()
- var cont = []
- if ($('#home_filter:checked').val()) {
- cont.push('home')
- }
- if ($('#local_filter:checked').val()) {
- cont.push('public')
- }
- if ($('#notf_filter:checked').val()) {
- cont.push('notifications')
- }
- if ($('#conv_filter:checked').val()) {
- cont.push('thread')
- }
- if ($('#prof_filter:checked').val()) {
- cont.push('profiles')
- }
- if (!cont.length) {
- $('#filtered-words').html('Error:' + lang.lang_filter_errordegree)
- }
- var exc = $('#except_filter:checked').val()
- var who = $('#wholeword_filter:checked').val()
- if (!who) {
- who = false
- }
- var time = $('#days_filter').val() * 24 * 60 * 60 + $('#hours_filter').val() * 60 * 60 + $('#mins_filter').val() * 60
- var domain = localStorage.getItem('domain_' + acct_id)
- var at = localStorage.getItem('acct_' + acct_id + '_at')
- if ($('#filter-edit-id').val()) {
- var start = 'https://' + domain + '/api/v1/filters/' + $('#filter-edit-id').val()
- var method = 'PUT'
- } else {
- var start = 'https://' + domain + '/api/v1/filters'
- var method = 'POST'
- }
- var httpreq = new XMLHttpRequest()
- httpreq.open(method, start, true)
- httpreq.setRequestHeader('Content-Type', 'application/json')
- httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
- httpreq.responseType = 'json'
- httpreq.send(
- JSON.stringify({
- phrase: phr,
- context: cont,
- irreversible: exc,
- whole_word: who,
- expires_in: time,
- })
- )
- httpreq.onreadystatechange = function () {
- if (httpreq.readyState === 4) {
- var json = httpreq.response
- if (this.status !== 200) {
- setLog(start, this.status, this.response)
- }
- filter()
- filterUpdate(acct_id)
- $('#filter-add-word').val('')
- $('#home_filter').prop('checked', false)
- $('#local_filter').prop('checked', false)
- $('#notf_filter').prop('checked', false)
- $('#conv_filter').prop('checked', false)
- $('#prof_filter').prop('checked', false)
- $('#except_filter').prop('checked', false)
- $('#wholeword_filter').prop('checked', false)
- $('#days_filter').val('0')
- $('#hours_filter').val('0')
- $('#mins_filter').val('0')
- $('#add-filter-btn').text(lang.lang_add)
- $('#filter-edit-id').val('')
- }
- }
+function filterTime(day, hour, min) {
+ $('#days_filter').val(day)
+ $('#hours_filter').val(hour)
+ $('#mins_filter').val(min)
}
+
+function makeNewFilter() {
+ var acct_id = $('#filter-acct-sel').val()
+ var phr = $('#filter-add-word').val()
+ var cont = []
+ if ($('#home_filter:checked').val()) {
+ cont.push('home')
+ }
+ if ($('#local_filter:checked').val()) {
+ cont.push('public')
+ }
+ if ($('#notf_filter:checked').val()) {
+ cont.push('notifications')
+ }
+ if ($('#conv_filter:checked').val()) {
+ cont.push('thread')
+ }
+ if ($('#prof_filter:checked').val()) {
+ cont.push('profiles')
+ }
+ if (!cont.length) {
+ $('#filtered-words').html('Error:' + lang.lang_filter_errordegree)
+ }
+ var exc = $('#except_filter:checked').val()
+ var who = $('#wholeword_filter:checked').val()
+ if (!who) {
+ who = false
+ }
+ var time = $('#days_filter').val() * 24 * 60 * 60 + $('#hours_filter').val() * 60 * 60 + $('#mins_filter').val() * 60
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ if ($('#filter-edit-id').val()) {
+ var start = 'https://' + domain + '/api/v1/filters/' + $('#filter-edit-id').val()
+ var method = 'PUT'
+ } else {
+ var start = 'https://' + domain + '/api/v1/filters'
+ var method = 'POST'
+ }
+
+ var httpreq = new XMLHttpRequest()
+ httpreq.open(method, start, true)
+ httpreq.setRequestHeader('Content-Type', 'application/json')
+ httpreq.setRequestHeader('Authorization', 'Bearer ' + at)
+ httpreq.responseType = 'json'
+ httpreq.send(
+ JSON.stringify({
+ phrase: phr,
+ context: cont,
+ irreversible: exc,
+ whole_word: who,
+ expires_in: time,
+ })
+ )
+ httpreq.onreadystatechange = function() {
+ if (httpreq.readyState === 4) {
+ var json = httpreq.response
+ if (this.status !== 200) {
+ setLog(start, this.status, this.response)
+ }
+ filter()
+ filterUpdate(acct_id)
+ $('#filter-add-word').val('')
+ $('#home_filter').prop('checked', false)
+ $('#local_filter').prop('checked', false)
+ $('#notf_filter').prop('checked', false)
+ $('#conv_filter').prop('checked', false)
+ $('#prof_filter').prop('checked', false)
+ $('#except_filter').prop('checked', false)
+ $('#wholeword_filter').prop('checked', false)
+ $('#days_filter').val('0')
+ $('#hours_filter').val('0')
+ $('#mins_filter').val('0')
+ $('#add-filter-btn').text(lang.lang_add)
+ $('#filter-edit-id').val('')
+ }
+ }
+}
+
function filterEdit(id, acct_id) {
- $('#filter-add-word').val('')
- $('#home_filter').prop('checked', false)
- $('#local_filter').prop('checked', false)
- $('#notf_filter').prop('checked', false)
- $('#conv_filter').prop('checked', false)
- $('#except_filter').prop('checked', false)
- $('#wholeword_filter').prop('checked', false)
- $('#days_filter').val('0')
- $('#hours_filter').val('0')
- $('#mins_filter').val('0')
- $('#add-filter-btn').text(lang.lang_edit)
- $('#filter-edit-id').val(id)
- var domain = localStorage.getItem('domain_' + acct_id)
- var at = localStorage.getItem('acct_' + acct_id + '_at')
- var start = 'https://' + domain + '/api/v1/filters/' + id
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json',
- Authorization: 'Bearer ' + at,
- },
- })
- .then(function (response) {
- if (!response.ok) {
- response.text().then(function (text) {
- setLog(response.url, response.status, text)
- })
- }
- return response.json()
- })
- .catch(function (error) {
- todo(error)
- setLog(start, 'JSON', error)
- console.error(error)
- })
- .then(function (json) {
- if (json) {
- var now = new Date()
- now = now.getTime()
- var now = Math.floor(now / 1000)
- $('#filter-add-word').val(json.phrase)
- Object.keys(json.context).forEach(function (key) {
- var context = json.context[key]
- $('[value=' + context + ']').prop('checked', true)
- })
- if (json.irreversible) {
- $('#except_filter').prop('checked', true)
- }
- if (json.whole_word) {
- $('#wholeword_filter').prop('checked', true)
- }
- var expires = date(json.expires_at, 'unix') - now
- var mins = Math.floor(expires / 60) % 60
- var hours = Math.floor(expires / 3600) % 24
- var days = Math.floor(expires / 3600 / 24)
- $('#days_filter').val(days)
- $('#hours_filter').val(hours)
- $('#mins_filter').val(mins)
- }
- })
+ $('#filter-add-word').val('')
+ $('#home_filter').prop('checked', false)
+ $('#local_filter').prop('checked', false)
+ $('#notf_filter').prop('checked', false)
+ $('#conv_filter').prop('checked', false)
+ $('#except_filter').prop('checked', false)
+ $('#wholeword_filter').prop('checked', false)
+ $('#days_filter').val('0')
+ $('#hours_filter').val('0')
+ $('#mins_filter').val('0')
+ $('#add-filter-btn').text(lang.lang_edit)
+ $('#filter-edit-id').val(id)
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/v1/filters/' + id
+ fetch(start, {
+ method: 'GET',
+ headers: {
+ 'content-type': 'application/json',
+ Authorization: 'Bearer ' + at,
+ },
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text)
+ })
+ }
+ return response.json()
+ })
+ .catch(function(error) {
+ todo(error)
+ setLog(start, 'JSON', error)
+ console.error(error)
+ })
+ .then(function(json) {
+ if (json) {
+ var now = new Date()
+ now = now.getTime()
+ var now = Math.floor(now / 1000)
+ $('#filter-add-word').val(json.phrase)
+ Object.keys(json.context).forEach(function(key) {
+ var context = json.context[key]
+ $('[value=' + context + ']').prop('checked', true)
+ })
+ if (json.irreversible) {
+ $('#except_filter').prop('checked', true)
+ }
+ if (json.whole_word) {
+ $('#wholeword_filter').prop('checked', true)
+ }
+ var expires = date(json.expires_at, 'unix') - now
+ var mins = Math.floor(expires / 60) % 60
+ var hours = Math.floor(expires / 3600) % 24
+ var days = Math.floor(expires / 3600 / 24)
+ $('#days_filter').val(days)
+ $('#hours_filter').val(hours)
+ $('#mins_filter').val(mins)
+ }
+ })
}
+
function filterDel(id, acct_id) {
- var domain = localStorage.getItem('domain_' + acct_id)
- var at = localStorage.getItem('acct_' + acct_id + '_at')
- var start = 'https://' + domain + '/api/v1/filters/' + id
- var httpreq = new XMLHttpRequest()
- httpreq.open('DELETE', 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)
- }
- filter()
- filterUpdate(acct_id)
- }
- }
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/v1/filters/' + id
+ var httpreq = new XMLHttpRequest()
+ httpreq.open('DELETE', 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)
+ }
+ filter()
+ filterUpdate(acct_id)
+ }
+ }
}
+
function getFilter(acct_id) {
- var domain = localStorage.getItem('domain_' + acct_id)
- var at = localStorage.getItem('acct_' + acct_id + '_at')
- if (localStorage.getItem('mode_' + domain) != 'misskey') {
- var start = 'https://' + domain + '/api/v1/filters'
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json',
- Authorization: 'Bearer ' + at,
- },
- })
- .then(function (response) {
- if (!response.ok) {
- response.text().then(function (text) {
- setLog(response.url, response.status, text)
- })
- }
- return response.json()
- })
- .catch(function (error) {
- todo(error)
- setLog(start, 'JSON', error)
- console.error(error)
- })
- .then(function (json) {
- localStorage.setItem('filter_' + acct_id, JSON.stringify(json))
- })
- } else {
- localStorage.setItem('filter_' + acct_id, JSON.stringify({}))
- }
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ if (localStorage.getItem('mode_' + domain) != 'misskey') {
+ var start = 'https://' + domain + '/api/v1/filters'
+ fetch(start, {
+ method: 'GET',
+ headers: {
+ 'content-type': 'application/json',
+ Authorization: 'Bearer ' + at,
+ },
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text)
+ })
+ }
+ return response.json()
+ })
+ .catch(function(error) {
+ todo(error)
+ setLog(start, 'JSON', error)
+ console.error(error)
+ })
+ .then(function(json) {
+ localStorage.setItem('filter_' + acct_id, JSON.stringify(json))
+ })
+ } else {
+ localStorage.setItem('filter_' + acct_id, JSON.stringify({}))
+ }
}
+
function getFilterType(json, type) {
- if (!json) {
- return []
- }
- if (type == 'local') {
- type = 'public'
- } else if (type == 'list') {
- type = 'home'
- } else if (type == 'notf') {
- type = 'notifi'
- }
- var mutedfilters = []
- Object.keys(json).forEach(function (key) {
- var filterword = json[key]
- var phrases = filterword.phrase
- var arr = filterword.context
- if (arr.join(',').indexOf(type) !== -1) {
- mutedfilters.push(phrases)
- } else if (type == 'mix') {
- if (arr.indexOf('home') !== -1 || arr.indexOf('public') !== -1) {
- mutedfilters.push(phrases)
- }
- }
- })
- return mutedfilters
+ if (!json) {
+ return []
+ }
+ if (type == 'local') {
+ type = 'public'
+ } else if (type == 'list') {
+ type = 'home'
+ } else if (type == 'notf') {
+ type = 'notifi'
+ }
+ var mutedfilters = []
+ Object.keys(json).forEach(function(key) {
+ var filterword = json[key]
+ var phrases = filterword.phrase
+ var arr = filterword.context
+ if (arr.join(',').indexOf(type) !== -1) {
+ mutedfilters.push(phrases)
+ } else if (type == 'mix') {
+ if (arr.indexOf('home') !== -1 || arr.indexOf('public') !== -1) {
+ mutedfilters.push(phrases)
+ }
+ }
+ })
+ return mutedfilters
}
+
function getFilterTypeByAcct(acct_id, type) {
- if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
- var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), type)
- } else {
- var mute = []
- }
- return mute
+ if (localStorage.getItem('filter_' + acct_id) != 'undefined') {
+ var mute = getFilterType(JSON.parse(localStorage.getItem('filter_' + acct_id)), type)
+ } else {
+ var mute = []
+ }
+ return mute
}
+
function filterUpdate(acct_id) {
- var domain = localStorage.getItem('domain_' + acct_id)
- var at = localStorage.getItem('acct_' + acct_id + '_at')
- var start = 'https://' + domain + '/api/v1/filters'
- fetch(start, {
- method: 'GET',
- headers: {
- 'content-type': 'application/json',
- Authorization: 'Bearer ' + at,
- },
- })
- .then(function (response) {
- if (!response.ok) {
- response.text().then(function (text) {
- setLog(response.url, response.status, text)
- })
- }
- return response.json()
- })
- .catch(function (error) {
- todo(error)
- setLog(start, 'JSON', error)
- console.error(error)
- })
- .then(function (json) {
- localStorage.setItem('filter_' + acct_id, JSON.stringify(json))
- filterUpdateInternal(json, 'home')
- filterUpdateInternal(json, 'local')
- filterUpdateInternal(json, 'notf')
- filterUpdateInternal(json, 'pub')
- })
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/v1/filters'
+ fetch(start, {
+ method: 'GET',
+ headers: {
+ 'content-type': 'application/json',
+ Authorization: 'Bearer ' + at,
+ },
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text)
+ })
+ }
+ return response.json()
+ })
+ .catch(function(error) {
+ todo(error)
+ setLog(start, 'JSON', error)
+ console.error(error)
+ })
+ .then(function(json) {
+ localStorage.setItem('filter_' + acct_id, JSON.stringify(json))
+ filterUpdateInternal(json, 'home')
+ filterUpdateInternal(json, 'local')
+ filterUpdateInternal(json, 'notf')
+ filterUpdateInternal(json, 'pub')
+ })
}
+
function filterUpdateInternal(json, type) {
- var home = getFilterType(json, type)
- var wordmute = localStorage.getItem('word_mute')
- if (wordmute) {
- var wordmute = JSON.parse(wordmute)
- home = home.concat(wordmute)
- }
- if (home) {
- $('[data-acct=' + acct_id + '] [data-type=' + type + '] .cvo').each(function (i, elem) {
- var id = $(elem).attr('toot-id')
- $('[toot-id=' + id + ']').removeClass('hide')
- var text = $(elem).find('.toot').html()
- Object.keys(home).forEach(function (key8) {
- var word = home[key8]
- var regExp = new RegExp(word.replace(/[.*+?^=!:${}()|[\]\/\\]/g, '\\$&'), 'g')
- if ($.strip_tags(text).match(regExp)) {
- $('[toot-id=' + id + ']').addClass('hide')
- }
- })
- })
- }
+ var home = getFilterType(json, type)
+ var wordmute = localStorage.getItem('word_mute')
+ if (wordmute) {
+ var wordmute = JSON.parse(wordmute)
+ home = home.concat(wordmute)
+ }
+ if (home) {
+ $('[data-acct=' + acct_id + '] [data-type=' + type + '] .cvo').each(function(i, elem) {
+ var id = $(elem).attr('toot-id')
+ $('[toot-id=' + id + ']').removeClass('hide')
+ var text = $(elem).find('.toot').html()
+ Object.keys(home).forEach(function(key8) {
+ var word = home[key8]
+ var regExp = new RegExp(word.replace(/[.*+?^=!:${}()|[\]\/\\]/g, '\\$&'), 'g')
+ if ($.strip_tags(text).match(regExp)) {
+ $('[toot-id=' + id + ']').addClass('hide')
+ }
+ })
+ })
+ }
}
/*
'
- $('#timeline_' + tlid).html(templete)
- // $('#landing_' + tlid).hide()
- jQuery('time.timeago').timeago()
- }
- $('#notf-box').addClass('fetched')
- todc()
- //Markers
- var markers = localStorage.getItem('markers')
- if (markers == 'yes') {
- markers = true
- } else {
- markers = false
- }
- if (markers) {
- getMarker(tlid, 'notf', acct_id)
- }
- }
- }
- if (!misskey) {
- if (localStorage.getItem('streaming_' + acct_id)) {
- var wss = localStorage.getItem('streaming_' + acct_id)
- } else {
- var wss = 'wss://' + domain
- }
- var start = wss + '/api/v1/streaming/?stream=user&access_token=' + at
- } else {
- var start = 'wss://' + domain + '/?i=' + at
- }
+ httpreq.responseType = 'json'
+ httpreq.send(body)
+ httpreq.onreadystatechange = function() {
+ if (httpreq.readyState === 4) {
+ var json = httpreq.response
+ if (this.status !== 200) {
+ $('#landing_' + tlid).append(`'
- for (var i = 0; i < json.fields.length; i++) {
- var fname = json.fields[i].name
- var fval = json.fields[i].value
- if (json.fields[i].verified_at) {
- var when = lang.lang_showontl_verified + ":" + crat(json.fields[i].verified_at)
- var color = "rgba(121,189,154,.25);"
- } else {
- var when = ""
- var color = "inherit"
- }
- table = table + '
"
- $("#his-des").html(twemoji.parse(note))
- } else {
- $("#his-des").css("max-height", "400px")
- }
- $("#his-table").html(twemoji.parse(table))
- } else {
- $("#his-des").css("max-height", "400px")
- }
- $("#his-des").html(twemoji.parse(note))
- if (json.bot) {
- $("#his-bot").html(lang.lang_showontl_botacct)
- $("#his-bot").removeClass("hide")
- }
- $("#his-des").attr("data-acct", acct_id)
- $("#his-data").css("background-size", "cover")
- $("#his-float-timeline").css("height", $("#his-data-show").height() + "px")
- localStorage.setItem("history", user)
- //自分の時
- if (json.acct == localStorage.getItem("user_" + acct_id)) {
- showFav("", acct_id)
- showBlo("", acct_id)
- showMut("", acct_id)
- showDom("", acct_id)
- showReq("", acct_id)
- showFrl("", acct_id)
- $("#his-name-val").val(json.display_name)
- if (json.fields.length > 0) {
- if (json.fields[0]) {
- $("#his-f1-name").val(json.fields[0].name)
- $("#his-f1-val").val($.strip_tags(json.fields[0].value))
- }
- if (json.fields[1]) {
- $("#his-f2-name").val(json.fields[1].name)
- $("#his-f2-val").val($.strip_tags(json.fields[1].value))
- }
- if (json.fields[2]) {
- $("#his-f3-name").val(json.fields[2].name)
- $("#his-f3-val").val($.strip_tags(json.fields[2].value))
- }
- if (json.fields[3]) {
- $("#his-f4-name").val(json.fields[3].name)
- $("#his-f4-val").val($.strip_tags(json.fields[3].value))
- }
- }
- var des = json.note
- des = des.replace(/ "
- }
- table = table + "' + escapeHTML(fname) + ' ' + fval + "
/g, "\n")
- des = $.strip_tags(des)
- $("#his-des-val").val(des)
- $("#his-follow-btn").hide()
- $("#his-block-btn").hide()
- $("#his-mute-btn").hide()
- $("#his-notf-btn").hide()
- $("#his-domain-btn").hide()
- $("#his-emp-btn").hide()
- $(".only-my-data").show()
- $(".only-his-data").hide()
- if (localStorage.getItem("main") == acct_id) {
- $("#his-main-acct").hide()
- }
- } else {
- relations(user, acct_id)
- $(".only-my-data").hide()
- $(".only-his-data").show()
- }
- todc()
- if (json.locked) {
- $('#his-data').addClass('locked')
- } else {
- $('#his-data').removeClass('locked')
- }
- //外部データ取得(死かもしれないので)
- udAdd(acct_id, user, json.url)
- })
+async function udgEx(user, acct_id) {
+ if (user == 'selector') {
+ user = $('#his-acct').attr('fullname')
+ }
+ if (acct_id == 'selector') {
+ acct_id = $('#user-acct-sel').val()
+ }
+ if (acct_id == 'main') {
+ acct_id = localStorage.getItem('main')
+ }
+ console.log('Get user data of ' + user)
+ var domain = localStorage.getItem('domain_' + acct_id)
+ if (localStorage.getItem('mode_' + domain) == 'misskey') {
+ return false
+ }
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var data = await acctResolve(acct_id, user)
+ if (data.id) {
+ var { id } = data
+ udg(id, acct_id, true)
+ } else {
+ Swal.close()
+ postMessage(['openUrl', user], '*')
+ }
+
+ return true
+ var start = 'https://' + domain + '/api/v2/search?resolve=true&q=' + encodeURIComponent(user)
+ Swal.fire({
+ title: 'Loading...',
+ html: lang.lang_details_fetch,
+ showConfirmButton: false,
+ showCloseButton: true,
+ onBeforeOpen: () => {
+ Swal.showLoading()
+ },
+ onClose: () => {},
+ }).then((result) => {})
+ fetch(start, {
+ method: 'GET',
+ headers: {
+ 'content-type': 'application/json',
+ Authorization: 'Bearer ' + at,
+ },
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ Swal.close()
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text)
+ })
+ }
+ return response.json()
+ })
+ .catch(function(error) {
+ todo(error)
+ setLog(start, 'JSON', error)
+ console.error(error)
+ })
+ .then(function(json) {
+ if (json.accounts[0]) {
+ var id = json.accounts[0].id
+ udg(id, acct_id, true)
+ } else {
+ Swal.close()
+ postMessage(['openUrl', user], '*')
+ }
+ })
+ return true
}
+
+function udg(user, acct_id, isSwal) {
+ reset()
+ if (!user) {
+ user = localStorage.getItem('user-id_' + acct_id)
+ }
+ todo('User Data Loading...')
+ var domain = localStorage.getItem('domain_' + acct_id)
+ if (localStorage.getItem('mode_' + domain) == 'misskey') {
+ misskeyUdg(user, acct_id)
+ return
+ }
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/v1/accounts/' + user
+ fetch(start, {
+ method: 'GET',
+ headers: {
+ 'content-type': 'application/json',
+ Authorization: 'Bearer ' + at,
+ },
+ })
+ .then(function(response) {
+ if (isSwal) Swal.close()
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text)
+ })
+ }
+ return response.json()
+ })
+ .catch(function(error) {
+ todo(error)
+ setLog(start, 'JSON', error)
+ console.error(error)
+ })
+ .then(function(json) {
+ //一つ前のユーザーデータ
+ if (!localStorage.getItem('history')) {
+ $('#his-history-btn').prop('disabled', true)
+ } else {
+ $('#his-history-btn').prop('disabled', false)
+ $('#his-data').attr('history', localStorage.getItem('history'))
+ }
+ //moved設定時
+ if (json.moved) {
+ M.toast({
+ html: lang.lang_showontl_movetxt + '',
+ displayLength: 4000,
+ })
+ }
+ $('#his-data').modal('open')
+ $('#his-data').attr('user-id', user)
+ $('#his-data').attr('use-acct', acct_id)
+ if (json.username != json.acct) {
+ //Remote
+ $('#his-data').attr('remote', 'true')
+ var fullname = json.acct
+ } else {
+ $('#his-data').attr('remote', 'false')
+ var fullname = json.acct + '@' + domain
+ }
+ utlShow(json.id, '', acct_id)
+ flw(json.id, '', acct_id)
+ fer(json.id, '', acct_id)
+ var dis_name = escapeHTML(json.display_name)
+ dis_name = twemoji.parse(dis_name)
+
+ var note = json.note
+ if (json.emojis) {
+ var actemojick = json.emojis[0]
+ } else {
+ var actemojick = false
+ }
+ //絵文字があれば
+ if (actemojick) {
+ Object.keys(json.emojis).forEach(function(key5) {
+ var emoji = json.emojis[key5]
+ var shortcode = emoji.shortcode
+ var emoji_url = ''
+ var regExp = new RegExp(':' + shortcode + ':', 'g')
+ dis_name = dis_name.replace(regExp, emoji_url)
+ note = note.replace(regExp, emoji_url)
+ })
+ }
+ //noteの解析
+ //var tags = '#$1';
+ //var mens = '@$1';
+ //note=note.replace(/#(\S+)/gi, tags)
+ //note=note.replace(/\s@([a-zA-Z_0-9@.-]+)/gi, mens)
+ $('#his-name').html(dis_name)
+ $('#his-acct').text(json.acct)
+ $('#his-acct').attr('fullname', fullname)
+ $('#his-prof').attr('src', json.avatar)
+ $('#util-add').removeClass('hide')
+ const title = $('.column-first').html()
+ $('#my-data-nav .anc-link').removeClass('active-back')
+ $('.column-first').addClass('active-back')
+ $('#his-data-title').html(title)
+ $('#his-data').css('background-image', 'url(' + json.header + ')')
+ $('#his-sta').text(json.statuses_count)
+ $('#his-follow').text(json.following_count)
+ var flerc = json.followers_count
+ if (flerc < 0) {
+ flerc = '-'
+ }
+ $('#his-follower').text(flerc)
+ $('#his-since').text(crat(json.created_at))
+ $('#his-openin').attr('data-href', json.url)
+ if (json.fields) {
+ var table = ''
+ if (json.fields.length > 0) {
+ $('#his-des').css('max-height', '250px')
+ table = ''
+ for (var i = 0; i < json.fields.length; i++) {
+ var fname = json.fields[i].name
+ var fval = json.fields[i].value
+ if (json.fields[i].verified_at) {
+ var when = lang.lang_showontl_verified + ':' + crat(json.fields[i].verified_at)
+ var color = 'rgba(121,189,154,.25);'
+ } else {
+ var when = ''
+ var color = 'inherit'
+ }
+ table =
+ table +
+ '
'
+ $('#his-des').html(twemoji.parse(note))
+ } else {
+ $('#his-des').css('max-height', '400px')
+ }
+ $('#his-table').html(twemoji.parse(table))
+ } else {
+ $('#his-des').css('max-height', '400px')
+ }
+ $('#his-des').html(twemoji.parse(note))
+ if (json.bot) {
+ $('#his-bot').html(lang.lang_showontl_botacct)
+ $('#his-bot').removeClass('hide')
+ }
+ $('#his-des').attr('data-acct', acct_id)
+ $('#his-data').css('background-size', 'cover')
+ $('#his-float-timeline').css('height', $('#his-data-show').height() + 'px')
+ localStorage.setItem('history', user)
+ //自分の時
+ if (json.acct == localStorage.getItem('user_' + acct_id)) {
+ showFav('', acct_id)
+ showBlo('', acct_id)
+ showMut('', acct_id)
+ showDom('', acct_id)
+ showReq('', acct_id)
+ showFrl('', acct_id)
+ $('#his-name-val').val(json.display_name)
+ if (json.fields.length > 0) {
+ if (json.fields[0]) {
+ $('#his-f1-name').val(json.fields[0].name)
+ $('#his-f1-val').val($.strip_tags(json.fields[0].value))
+ }
+ if (json.fields[1]) {
+ $('#his-f2-name').val(json.fields[1].name)
+ $('#his-f2-val').val($.strip_tags(json.fields[1].value))
+ }
+ if (json.fields[2]) {
+ $('#his-f3-name').val(json.fields[2].name)
+ $('#his-f3-val').val($.strip_tags(json.fields[2].value))
+ }
+ if (json.fields[3]) {
+ $('#his-f4-name').val(json.fields[3].name)
+ $('#his-f4-val').val($.strip_tags(json.fields[3].value))
+ }
+ }
+ var des = json.note
+ des = des.replace(/ '
+ }
+ table = table + '' +
+ escapeHTML(fname) +
+ ' ' +
+ fval +
+ '
/g, '\n')
+ des = $.strip_tags(des)
+ $('#his-des-val').val(des)
+ $('#his-follow-btn').hide()
+ $('#his-block-btn').hide()
+ $('#his-mute-btn').hide()
+ $('#his-notf-btn').hide()
+ $('#his-domain-btn').hide()
+ $('#his-emp-btn').hide()
+ $('.only-my-data').show()
+ $('.only-his-data').hide()
+ if (localStorage.getItem('main') == acct_id) {
+ $('#his-main-acct').hide()
+ }
+ } else {
+ relations(user, acct_id)
+ $('.only-my-data').hide()
+ $('.only-his-data').show()
+ }
+ todc()
+ if (json.locked) {
+ $('#his-data').addClass('locked')
+ } else {
+ $('#his-data').removeClass('locked')
+ }
+ //外部データ取得(死かもしれないので)
+ udAdd(acct_id, user, json.url)
+ })
+}
+
function misskeyUdg(user, acct_id) {
- reset()
- if (!user) {
- user = localStorage.getItem("user-id_" + acct_id)
- }
- todo("User Data Loading...")
- var domain = localStorage.getItem("domain_" + acct_id)
- if (localStorage.getItem("mode_" + domain) != "misskey") {
- udg(user, acct_id)
- return
- }
- var at = localStorage.getItem("acct_" + acct_id + "_at")
- var start = "https://" + domain + "/api/users/show"
- fetch(start, {
- method: "POST",
- headers: {
- "content-type": "application/json"
- },
- body: JSON.stringify({
- i: at,
- userId: user
- })
- })
- .then(function (response) {
- if (!response.ok) {
- response.text().then(function (text) {
- setLog(response.url, response.status, text)
- })
- }
- return response.json()
- })
- .catch(function (error) {
- todo(error)
- setLog(start, "JSON", error)
- console.error(error)
- })
- .then(function (json) {
- //一つ前のユーザーデータ
- if (!localStorage.getItem("history")) {
- $("#his-history-btn").prop("disabled", true)
- } else {
- $("#his-history-btn").prop("disabled", false)
- $("#his-data").attr("history", localStorage.getItem("history"))
- }
- $("#his-data").modal("open")
- $("#his-data").attr("user-id", user)
- $("#his-data").attr("use-acct", acct_id)
- if (json.host) {
- //Remote
- $("#his-data").attr("remote", "false")
- var fullname = json.username + "@" + json.host
- } else {
- $("#his-data").attr("remote", "false")
- var fullname = json.acct + "@" + domain
- }
- utlShow(json.id, "", acct_id)
- flw(json.id, "", acct_id)
- fer(json.id, "", acct_id)
- if (json.name) {
- var dis_name = escapeHTML(json.name)
- dis_name = twemoji.parse(dis_name)
- } else {
- var dis_name = json.name
- }
- $("#his-name").html(dis_name)
- $("#his-acct").text(json.username)
- $("#his-acct").attr("fullname", fullname)
- $("#his-prof").attr("src", json.avatarUrl)
- $("#his-data").css("background-image", "url(" + json.bannerUrl + ")")
- $("#his-sta").text(json.notesCount)
- $("#his-follow").text(json.followingCount)
- $("#his-follower").text(json.followersCount)
- $("#his-since").text(crat(json.createdAt))
- var note = escapeHTML(json.description)
- $("#his-des").html(twemoji.parse(note))
- if (json.isCat) {
- $("#his-bot").html("Cat" + twemoji.parse("😺"))
- }
- $("#his-data").css("background-size", "cover")
- localStorage.setItem("history", user)
- //自分の時
- if (json.username == localStorage.getItem("user_" + acct_id) && !json.host) {
- //showFav('', acct_id);
- //showMut('', acct_id);
- //showReq('', acct_id);
- showFrl("", acct_id)
- $("#his-name-val").val(json.name)
- var des = json.note
- des = nl2br(des)
- des = $.strip_tags(des)
- $("#his-des-val").val(des)
- $("#his-follow-btn").hide()
- $("#his-block-btn").hide()
- $("#his-mute-btn").hide()
- $("#his-notf-btn").hide()
- $("#his-domain-btn").hide()
- $("#his-emp-btn").hide()
- $(".only-my-data").show()
- $(".only-his-data").hide()
- if (localStorage.getItem("main") == acct_id) {
- $("#his-main-acct").hide()
- }
- } else {
- if (json.isFollowing) {
- //自分がフォローしている
- $("#his-data").addClass("following")
- $("#his-follow-btn-text").text(lang.lang_status_unfollow)
- hisList(user, acct_id)
- } else {
- $("#his-follow-btn-text").text(lang.lang_status_follow)
- }
- if (json.isFollowed) {
- //フォローされてる
- $("#his-relation").text(lang.lang_showontl_followed)
- }
- $("#his-block-btn").hide()
- if (json.isMuted) {
- $("#his-data").addClass("muting")
- $("#his-mute-btn-text").text(lang.lang_status_unmute)
- } else {
- $("#his-mute-btn-text").text(lang.lang_status_mute)
- }
- $(".only-my-data").hide()
- $(".only-his-data").show()
- }
- todc()
- })
+ reset()
+ if (!user) {
+ user = localStorage.getItem('user-id_' + acct_id)
+ }
+ todo('User Data Loading...')
+ var domain = localStorage.getItem('domain_' + acct_id)
+ if (localStorage.getItem('mode_' + domain) != 'misskey') {
+ udg(user, acct_id)
+ return
+ }
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/users/show'
+ fetch(start, {
+ method: 'POST',
+ headers: {
+ 'content-type': 'application/json',
+ },
+ body: JSON.stringify({
+ i: at,
+ userId: user,
+ }),
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text)
+ })
+ }
+ return response.json()
+ })
+ .catch(function(error) {
+ todo(error)
+ setLog(start, 'JSON', error)
+ console.error(error)
+ })
+ .then(function(json) {
+ //一つ前のユーザーデータ
+ if (!localStorage.getItem('history')) {
+ $('#his-history-btn').prop('disabled', true)
+ } else {
+ $('#his-history-btn').prop('disabled', false)
+ $('#his-data').attr('history', localStorage.getItem('history'))
+ }
+ $('#his-data').modal('open')
+ $('#his-data').attr('user-id', user)
+ $('#his-data').attr('use-acct', acct_id)
+ if (json.host) {
+ //Remote
+ $('#his-data').attr('remote', 'false')
+ var fullname = json.username + '@' + json.host
+ } else {
+ $('#his-data').attr('remote', 'false')
+ var fullname = json.acct + '@' + domain
+ }
+ utlShow(json.id, '', acct_id)
+ flw(json.id, '', acct_id)
+ fer(json.id, '', acct_id)
+ if (json.name) {
+ var dis_name = escapeHTML(json.name)
+ dis_name = twemoji.parse(dis_name)
+ } else {
+ var dis_name = json.name
+ }
+ $('#his-name').html(dis_name)
+ $('#his-acct').text(json.username)
+ $('#his-acct').attr('fullname', fullname)
+ $('#his-prof').attr('src', json.avatarUrl)
+ $('#his-data').css('background-image', 'url(' + json.bannerUrl + ')')
+ $('#his-sta').text(json.notesCount)
+ $('#his-follow').text(json.followingCount)
+ $('#his-follower').text(json.followersCount)
+ $('#his-since').text(crat(json.createdAt))
+ var note = escapeHTML(json.description)
+ $('#his-des').html(twemoji.parse(note))
+ if (json.isCat) {
+ $('#his-bot').html('Cat' + twemoji.parse('😺'))
+ }
+ $('#his-data').css('background-size', 'cover')
+ localStorage.setItem('history', user)
+ //自分の時
+ if (json.username == localStorage.getItem('user_' + acct_id) && !json.host) {
+ //showFav('', acct_id);
+ //showMut('', acct_id);
+ //showReq('', acct_id);
+ showFrl('', acct_id)
+ $('#his-name-val').val(json.name)
+ var des = json.note
+ des = nl2br(des)
+ des = $.strip_tags(des)
+ $('#his-des-val').val(des)
+ $('#his-follow-btn').hide()
+ $('#his-block-btn').hide()
+ $('#his-mute-btn').hide()
+ $('#his-notf-btn').hide()
+ $('#his-domain-btn').hide()
+ $('#his-emp-btn').hide()
+ $('.only-my-data').show()
+ $('.only-his-data').hide()
+ if (localStorage.getItem('main') == acct_id) {
+ $('#his-main-acct').hide()
+ }
+ } else {
+ if (json.isFollowing) {
+ //自分がフォローしている
+ $('#his-data').addClass('following')
+ $('#his-follow-btn-text').text(lang.lang_status_unfollow)
+ hisList(user, acct_id)
+ } else {
+ $('#his-follow-btn-text').text(lang.lang_status_follow)
+ }
+ if (json.isFollowed) {
+ //フォローされてる
+ $('#his-relation').text(lang.lang_showontl_followed)
+ }
+ $('#his-block-btn').hide()
+ if (json.isMuted) {
+ $('#his-data').addClass('muting')
+ $('#his-mute-btn-text').text(lang.lang_status_unmute)
+ } else {
+ $('#his-mute-btn-text').text(lang.lang_status_mute)
+ }
+ $('.only-my-data').hide()
+ $('.only-his-data').show()
+ }
+ todc()
+ })
}
//一つ前のユーザーデータ表示
function historyShow() {
- var acct_id = $("#his-data").attr("use-acct")
- var user = $("#his-data").attr("history")
- udg(user, acct_id, "true")
+ var acct_id = $('#his-data').attr('use-acct')
+ var user = $('#his-data').attr('history')
+ udg(user, acct_id, 'true')
}
//選択アカウントのプロフ
function profShow() {
- var acct_id = $("#post-acct-sel").val()
- var user = localStorage.getItem("user-id_" + acct_id)
- udg(user, acct_id)
- hide()
+ var acct_id = $('#post-acct-sel').val()
+ var user = localStorage.getItem('user-id_' + acct_id)
+ udg(user, acct_id)
+ hide()
}
//FF関係取得
function relations(user, acct_id) {
- var domain = localStorage.getItem("domain_" + acct_id)
- var at = localStorage.getItem("acct_" + acct_id + "_at")
- var start = "https://" + domain + "/api/v1/accounts/relationships?id=" + user
- fetch(start, {
- method: "GET",
- headers: {
- "content-type": "application/json",
- Authorization: "Bearer " + at
- }
- })
- .then(function (response) {
- if (!response.ok) {
- response.text().then(function (text) {
- setLog(response.url, response.status, text)
- })
- }
- return response.json()
- })
- .catch(function (error) {
- todo(error)
- setLog(start, "JSON", error)
- console.error(error)
- })
- .then(function (json) {
- var json = json[0]
- if (json.requested) {
- //フォロリク中
- $('#his-data').addClass('following')
- $("#his-follow-btn-text").text(lang.lang_status_requesting)
- }
- if (json.following) {
- //自分がフォローしている
- $("#his-data").addClass("following")
- $("#his-follow-btn-text").text(lang.lang_status_unfollow)
- hisList(user, acct_id)
- } else {
- $("#his-follow-btn-text").text(lang.lang_status_follow)
- }
- if (json.followed_by) {
- //フォローされてる
- $("#his-relation").text(lang.lang_showontl_followed)
- }
- if (json.blocking) {
- $("#his-data").addClass("blocking")
- $("#his-block-btn-text").text(lang.lang_status_unblock)
- } else {
- $("#his-block-btn-text").text(lang.lang_status_block)
- }
- if (json.muting) {
- $("#his-data").addClass("muting")
- $("#his-mute-btn-text").text(lang.lang_status_unmute)
- } else {
- $("#his-mute-btn-text").text(lang.lang_status_mute)
- }
- if (json.muting_notifications) {
- $("#his-data").addClass("mutingNotf")
- $("#his-notf-btn-text").text(lang.lang_showontl_notf + lang.lang_status_unmute)
- } else {
- $("#his-notf-btn-text").text(lang.lang_showontl_notf + lang.lang_status_mute)
- }
- if (json.domain_blocking) {
- $("#his-data").addClass("blockingDom")
- $("#his-domain-btn-text").text(lang.lang_showontl_domain + lang.lang_status_unblock)
- } else {
- $("#his-domain-btn-text").text(lang.lang_showontl_domain + lang.lang_status_block)
- }
- //Endorsed
- if (json.endorsed) {
- $("#his-end-btn").addClass("endorsed")
- $("#his-end-btn-text").text(lang.lang_status_unendorse)
- } else {
- $("#his-end-btn").removeClass("endorsed")
- $("#his-end-btn-text").text(lang.lang_status_endorse)
- }
- //Blocked
- if (json.blocked_by) {
- $("#my-data-nav .btn").addClass("disabled")
- $(".his-var-content").hide()
- $("#his-float-blocked").show()
- $("#his-follow-btn").hide()
- }
- })
+ var domain = localStorage.getItem('domain_' + acct_id)
+ var at = localStorage.getItem('acct_' + acct_id + '_at')
+ var start = 'https://' + domain + '/api/v1/accounts/relationships?id=' + user
+ fetch(start, {
+ method: 'GET',
+ headers: {
+ 'content-type': 'application/json',
+ Authorization: 'Bearer ' + at,
+ },
+ })
+ .then(function(response) {
+ if (!response.ok) {
+ response.text().then(function(text) {
+ setLog(response.url, response.status, text)
+ })
+ }
+ return response.json()
+ })
+ .catch(function(error) {
+ todo(error)
+ setLog(start, 'JSON', error)
+ console.error(error)
+ })
+ .then(function(json) {
+ var json = json[0]
+ if (json.requested) {
+ //フォロリク中
+ $('#his-data').addClass('following')
+ $('#his-follow-btn-text').text(lang.lang_status_requesting)
+ }
+ if (json.following) {
+ //自分がフォローしている
+ $('#his-data').addClass('following')
+ $('#his-follow-btn-text').text(lang.lang_status_unfollow)
+ hisList(user, acct_id)
+ } else {
+ $('#his-follow-btn-text').text(lang.lang_status_follow)
+ }
+ if (json.followed_by) {
+ //フォローされてる
+ $('#his-relation').text(lang.lang_showontl_followed)
+ }
+ if (json.blocking) {
+ $('#his-data').addClass('blocking')
+ $('#his-block-btn-text').text(lang.lang_status_unblock)
+ } else {
+ $('#his-block-btn-text').text(lang.lang_status_block)
+ }
+ if (json.muting) {
+ $('#his-data').addClass('muting')
+ $('#his-mute-btn-text').text(lang.lang_status_unmute)
+ } else {
+ $('#his-mute-btn-text').text(lang.lang_status_mute)
+ }
+ if (json.muting_notifications) {
+ $('#his-data').addClass('mutingNotf')
+ $('#his-notf-btn-text').text(lang.lang_showontl_notf + lang.lang_status_unmute)
+ } else {
+ $('#his-notf-btn-text').text(lang.lang_showontl_notf + lang.lang_status_mute)
+ }
+ if (json.domain_blocking) {
+ $('#his-data').addClass('blockingDom')
+ $('#his-domain-btn-text').text(lang.lang_showontl_domain + lang.lang_status_unblock)
+ } else {
+ $('#his-domain-btn-text').text(lang.lang_showontl_domain + lang.lang_status_block)
+ }
+ //Endorsed
+ if (json.endorsed) {
+ $('#his-end-btn').addClass('endorsed')
+ $('#his-end-btn-text').text(lang.lang_status_unendorse)
+ } else {
+ $('#his-end-btn').removeClass('endorsed')
+ $('#his-end-btn-text').text(lang.lang_status_endorse)
+ }
+ //Blocked
+ if (json.blocked_by) {
+ $('#my-data-nav .btn').addClass('disabled')
+ $('.his-var-content').hide()
+ $('#his-float-blocked').show()
+ $('#his-follow-btn').hide()
+ }
+ })
}
+
function profbrws() {
- var url = $("#his-openin").attr("data-href")
- postMessage(["openUrl", url], "*")
+ var url = $('#his-openin').attr('data-href')
+ postMessage(['openUrl', url], '*')
}
+
function setMain() {
- var acct_id = $("#his-data").attr("use-acct")
- localStorage.setItem("main", acct_id)
- multiSelector(true)
- M.toast({ html: lang.lang_manager_mainAcct, displayLength: 3000 })
+ var acct_id = $('#his-data').attr('use-acct')
+ localStorage.setItem('main', acct_id)
+ multiSelector(true)
+ M.toast({ html: lang.lang_manager_mainAcct, displayLength: 3000 })
}
//オールリセット
function hisclose() {
- $("#his-data").modal("close")
- reset()
- $("#his-data").attr("history", "")
- localStorage.removeItem("history")
+ $('#his-data').modal('close')
+ reset()
+ $('#his-data').attr('history', '')
+ localStorage.removeItem('history')
}
+
function reset() {
- $(".his-var-content:eq(0)").show()
- $(".his-var-content:gt(0)").hide()
- $("#my-data-nav .btn").removeClass("disabled")
- $(".active-back").removeClass("active-back")
- $(".column-first").addClass("active-back")
- $("#his-name").text("Loading")
- $("#his-acct").text("")
- $("#his-prof").attr("src", "../../img/loading.svg")
- $("#his-data").css("background-image", "url(../../img/loading.svg)")
- $("#his-sta").text("")
- $("#his-follow").text("")
- $("#his-follower").text("")
- $("#his-des").html("")
- $("#his-data").css("background-size", "cover")
- $("#his-since").text("")
- $("#his-data").removeClass("following")
- $("#his-data").removeClass("muting")
- $("#his-data").removeClass("blocking")
- $("#his-data").removeClass("mutingNotf")
- $("#his-data").removeClass("blockingDom")
- $("#his-end-btn").removeClass("endorsed")
- $("#his-des").css("max-height", "250px")
- $("#his-bot").html("")
- $("#his-bot").addClass("hide")
- $("#his-follow-btn").show()
- $("#his-block-btn").show()
- $("#his-mute-btn").show()
- $("#his-notf-btn").show()
- $("#his-domain-btn").show()
- $("#his-emp-btn").show()
- $("#his-follow-btn-text").text(lang.lang_status_follow)
- $("#his-mute-btn-text").text(lang.lang_status_mute)
- $("#his-block-btn-text").text(lang.lang_status_block)
- $("#his-notf-btn").text(lang.lang_showontl_notf + lang.lang_status_mute)
- $("#his-domain-btn").text(lang.lang_showontl_domain + lang.lang_status_block)
- $("#his-relation").text("")
- $(".cont-series").html("")
- $("#domainblock").val("")
- $("#his-lists-a").html(lang.lang_showontl_listwarn)
- $("#his-lists-b").html("")
- $("#his-name-val").val("")
- $("#his-des-val").val("")
- $("#his-f1-name").val("")
- $("#his-f1-val").val("")
- $("#his-f2-name").val("")
- $("#his-f2-val").val("")
- $("#his-f3-name").val("")
- $("#his-f3-val").val("")
- $("#his-f4-name").val("")
- $("#his-f4-val").val("")
- $("#his-endorse").html("")
- $("#his-openin").attr("data-href", "")
- $("#his-float-timeline").show()
- $("#his-float-blocked").hide()
- $("#his-main-acct").show()
- $("#his-proof-prof").html("")
- $('#his-data').removeClass('locked')
- $('#his-data').removeClass('requesting')
+ $('.his-var-content:eq(0)').show()
+ $('.his-var-content:gt(0)').hide()
+ $('#my-data-nav .btn').removeClass('disabled')
+ $('.active-back').removeClass('active-back')
+ $('.column-first').addClass('active-back')
+ $('#his-name').text('Loading')
+ $('#his-acct').text('')
+ $('#his-prof').attr('src', '../../img/loading.svg')
+ $('#his-data').css('background-image', 'url(../../img/loading.svg)')
+ $('#his-sta').text('')
+ $('#his-follow').text('')
+ $('#his-follower').text('')
+ $('#his-des').html('')
+ $('#his-data').css('background-size', 'cover')
+ $('#his-since').text('')
+ $('#his-data').removeClass('following')
+ $('#his-data').removeClass('muting')
+ $('#his-data').removeClass('blocking')
+ $('#his-data').removeClass('mutingNotf')
+ $('#his-data').removeClass('blockingDom')
+ $('#his-end-btn').removeClass('endorsed')
+ $('#his-des').css('max-height', '250px')
+ $('#his-bot').html('')
+ $('#his-bot').addClass('hide')
+ $('#his-follow-btn').show()
+ $('#his-block-btn').show()
+ $('#his-mute-btn').show()
+ $('#his-notf-btn').show()
+ $('#his-domain-btn').show()
+ $('#his-emp-btn').show()
+ $('#his-follow-btn-text').text(lang.lang_status_follow)
+ $('#his-mute-btn-text').text(lang.lang_status_mute)
+ $('#his-block-btn-text').text(lang.lang_status_block)
+ $('#his-notf-btn').text(lang.lang_showontl_notf + lang.lang_status_mute)
+ $('#his-domain-btn').text(lang.lang_showontl_domain + lang.lang_status_block)
+ $('#his-relation').text('')
+ $('.cont-series').html('')
+ $('#domainblock').val('')
+ $('#his-lists-a').html(lang.lang_showontl_listwarn)
+ $('#his-lists-b').html('')
+ $('#his-name-val').val('')
+ $('#his-des-val').val('')
+ $('#his-f1-name').val('')
+ $('#his-f1-val').val('')
+ $('#his-f2-name').val('')
+ $('#his-f2-val').val('')
+ $('#his-f3-name').val('')
+ $('#his-f3-val').val('')
+ $('#his-f4-name').val('')
+ $('#his-f4-val').val('')
+ $('#his-endorse').html('')
+ $('#his-openin').attr('data-href', '')
+ $('#his-float-timeline').show()
+ $('#his-float-blocked').hide()
+ $('#his-main-acct').show()
+ $('#his-proof-prof').html('')
+ $('#his-data').removeClass('locked')
+ $('#his-data').removeClass('requesting')
}
-$("#my-data-nav .anc-link").on("click", function () {
- var target = $(this).attr("go")
- if (target) {
- let title = $(this).html()
- if (target === '#his-tl') $("#util-add").removeClass("hide")
- if (target != '#his-tl') $("#util-add").addClass("hide")
- $('#his-data-title').html(title)
- $("#my-data-nav .anc-link").removeClass("active-back")
- $(this).addClass("active-back")
- $(target).show()
- $(".his-var-content:not(" + target + ")").hide()
- }
-})
+$('#my-data-nav .anc-link').on('click', function() {
+ var target = $(this).attr('go')
+ if (target) {
+ let title = $(this).html()
+ if (target === '#his-tl') $('#util-add').removeClass('hide')
+ if (target != '#his-tl') $('#util-add').addClass('hide')
+ $('#his-data-title').html(title)
+ $('#my-data-nav .anc-link').removeClass('active-back')
+ $(this).addClass('active-back')
+ $(target).show()
+ $('.his-var-content:not(' + target + ')').hide()
+ }
+})
\ No newline at end of file
diff --git a/app/view/pl-PL/index.html b/app/view/pl-PL/index.html
index 38b82b57..36ba490c 100644
--- a/app/view/pl-PL/index.html
+++ b/app/view/pl-PL/index.html
@@ -27,7 +27,7 @@