2018-01-28 23:22:43 +11:00
|
|
|
/*保護系*/
|
|
|
|
//画像保護
|
2020-11-28 07:57:11 +11:00
|
|
|
function nsfw(force) {
|
|
|
|
if (force || !$('#nsfw').hasClass('nsfw-avail')) {
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#nsfw').addClass('yellow-text')
|
|
|
|
$('#nsfw').html('visibility')
|
|
|
|
$('#nsfw').addClass('nsfw-avail')
|
2020-11-28 07:57:11 +11:00
|
|
|
} else {
|
|
|
|
$('#nsfw').removeClass('yellow-text')
|
|
|
|
$('#nsfw').html('visibility_off')
|
|
|
|
$('#nsfw').removeClass('nsfw-avail')
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//投稿公開範囲
|
2019-05-19 17:39:30 +10:00
|
|
|
function vis(set) {
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#vis').text(set)
|
|
|
|
$('#vis-icon').removeClass('red-text')
|
|
|
|
$('#vis-icon').removeClass('orange-text')
|
|
|
|
$('#vis-icon').removeClass('blue-text')
|
|
|
|
$('#vis-icon').removeClass('purple-text')
|
|
|
|
$('#vis-icon').removeClass('light-blue-text')
|
|
|
|
$('#vis-icon').removeClass('teal-text')
|
|
|
|
if (set == 'public') {
|
|
|
|
$('#vis-icon').text('public')
|
|
|
|
$('#vis-icon').addClass('purple-text')
|
|
|
|
} else if (set == 'unlisted') {
|
|
|
|
$('#vis-icon').text('lock_open')
|
|
|
|
$('#vis-icon').addClass('blue-text')
|
|
|
|
} else if (set == 'private') {
|
|
|
|
$('#vis-icon').text('lock')
|
|
|
|
$('#vis-icon').addClass('orange-text')
|
|
|
|
} else if (set == 'direct') {
|
|
|
|
$('#vis-icon').text('mail')
|
|
|
|
$('#vis-icon').addClass('red-text')
|
|
|
|
} else if (set == 'limited') {
|
|
|
|
$('#vis-icon').text('group')
|
|
|
|
$('#vis-icon').addClass('teal-text')
|
|
|
|
} else if (set == 'local') {
|
|
|
|
$('#vis-icon').text('visibility')
|
|
|
|
$('#vis-icon').addClass('light-blue-text')
|
2018-03-14 05:31:31 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
var vis = localStorage.getItem('vis')
|
|
|
|
if (vis == 'memory') {
|
|
|
|
var acct_id = $('#post-acct-sel').val()
|
|
|
|
localStorage.setItem('vis-memory-' + acct_id, set)
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-06-16 21:35:15 +10:00
|
|
|
var ins = M.Dropdown.getInstance($('#dropdown1'))
|
2019-11-09 00:52:54 +11:00
|
|
|
if (ins) {
|
|
|
|
ins.close()
|
2019-06-16 21:35:15 +10:00
|
|
|
}
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2019-05-19 17:39:30 +10:00
|
|
|
function loadVis() {
|
2019-11-09 00:52:54 +11:00
|
|
|
var vist = localStorage.getItem('vis')
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!vist) {
|
2019-11-09 00:52:54 +11:00
|
|
|
vis('public')
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
if (vist == 'memory') {
|
|
|
|
var acct_id = $('#post-acct-sel').val()
|
|
|
|
var memory = localStorage.getItem('vis-memory-' + acct_id)
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!memory) {
|
2019-11-09 00:52:54 +11:00
|
|
|
memory = 'public'
|
2018-03-14 05:31:31 +11:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
vis(memory)
|
|
|
|
} else if (vist == 'useapi') {
|
|
|
|
var acct_id = $('#post-acct-sel').val()
|
|
|
|
var multi = localStorage.getItem('multi')
|
|
|
|
var obj = JSON.parse(multi)
|
|
|
|
var memory = obj[acct_id]['vis']
|
2019-05-19 17:39:30 +10:00
|
|
|
if (!memory) {
|
2019-11-09 00:52:54 +11:00
|
|
|
memory = 'public'
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
vis(memory)
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
vis(vist)
|
2019-05-19 17:39:30 +10:00
|
|
|
}
|
2018-03-14 05:31:31 +11:00
|
|
|
}
|
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
loadVis()
|
2018-01-28 23:22:43 +11:00
|
|
|
|
2018-06-18 00:26:45 +10:00
|
|
|
//コンテントワーニング
|
2020-11-17 03:10:59 +11:00
|
|
|
function cw(force) {
|
2020-11-28 07:57:11 +11:00
|
|
|
if (force || !$('#cw').hasClass('cw-avail')) {
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#cw-text').show()
|
|
|
|
$('#cw').addClass('yellow-text')
|
|
|
|
$('#cw').addClass('cw-avail')
|
|
|
|
var cwt = localStorage.getItem('cw-text')
|
2019-05-19 17:39:30 +10:00
|
|
|
if (cwt) {
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#cw-text').val(cwt)
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
2020-11-28 07:57:11 +11:00
|
|
|
} else {
|
|
|
|
$('#cw-text').val()
|
|
|
|
$('#cw-text').hide()
|
|
|
|
$('#cw').removeClass('yellow-text')
|
|
|
|
$('#cw').removeClass('cw-avail')
|
2018-01-28 23:22:43 +11:00
|
|
|
}
|
|
|
|
}
|
2018-06-18 00:26:45 +10:00
|
|
|
//TLでコンテントワーニングを表示トグル
|
2020-04-07 14:02:20 +10:00
|
|
|
function cw_show(e) {
|
|
|
|
$(e).parent().parent().find('.cw_hide').toggleClass('cw')
|
|
|
|
$(e).parent().find('.cw_long').toggleClass('hide')
|
2018-06-18 00:26:45 +10:00
|
|
|
}
|
2020-11-17 03:00:32 +11:00
|
|
|
$(function () {
|
|
|
|
$('#cw-text').on('change', function (event) {
|
2019-11-09 00:52:54 +11:00
|
|
|
var acct_id = $('#post-acct-sel').val()
|
|
|
|
var domain = localStorage.getItem('domain_' + acct_id)
|
|
|
|
var cwlen = $('#cw-text').val().length
|
2018-06-18 00:26:45 +10:00
|
|
|
|
2019-11-09 00:52:54 +11:00
|
|
|
if (idata[domain + '_letters']) {
|
|
|
|
$('#textarea').attr('data-length', idata[domain + '_letters'] - cwlen)
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#textarea').attr('data-length', 500 - cwlen)
|
2018-06-18 00:26:45 +10:00
|
|
|
}
|
2019-11-09 00:52:54 +11:00
|
|
|
})
|
|
|
|
})
|
2019-01-22 03:25:40 +11:00
|
|
|
//スケジュール
|
2019-05-19 17:39:30 +10:00
|
|
|
function schedule() {
|
2019-11-09 00:52:54 +11:00
|
|
|
if ($('#sch-box').hasClass('sch-avail')) {
|
|
|
|
$('#sch-box').hide()
|
|
|
|
$('#sch-box').removeClass('sch-avail')
|
2019-05-19 17:39:30 +10:00
|
|
|
} else {
|
2019-11-09 00:52:54 +11:00
|
|
|
var date = new Date()
|
2019-05-19 17:39:30 +10:00
|
|
|
|
2019-11-09 00:52:54 +11:00
|
|
|
$('#sch-box').show()
|
|
|
|
$('#sch-date').val(formattime(date))
|
|
|
|
$('#sch-box').addClass('sch-avail')
|
2019-01-22 03:25:40 +11:00
|
|
|
}
|
|
|
|
}
|
2020-11-17 03:00:32 +11:00
|
|
|
|
|
|
|
//下書き機能
|
2020-11-17 03:36:07 +11:00
|
|
|
function draftToggle(force) {
|
|
|
|
if ($('#draft').hasClass('hide') || force) {
|
2020-11-17 03:00:32 +11:00
|
|
|
$('#draft').removeClass('hide')
|
|
|
|
$('#right-side').show()
|
|
|
|
$('#right-side').css('width', '300px')
|
|
|
|
$('#left-side').css('width', 'calc(100% - 300px)')
|
|
|
|
var width = localStorage.getItem('postbox-width')
|
|
|
|
if (width) {
|
|
|
|
width = width.replace('px', '') * 1 + 300
|
|
|
|
} else {
|
|
|
|
width = 600
|
|
|
|
}
|
|
|
|
$('#post-box').css('width', width + 'px')
|
|
|
|
$('#suggest').html('')
|
|
|
|
$('#draft').html('')
|
|
|
|
draftDraw()
|
|
|
|
} else {
|
|
|
|
$('#poll').addClass('hide')
|
|
|
|
$('#draft').addClass('hide')
|
|
|
|
$('#right-side').hide()
|
|
|
|
$('#right-side').css('width', '300px')
|
|
|
|
$('#emoji').addClass('hide')
|
|
|
|
$('#suggest').html('')
|
|
|
|
$('#draft').html('')
|
|
|
|
$('#left-side').css('width', '100%')
|
|
|
|
var width = localStorage.getItem('postbox-width')
|
|
|
|
if (width) {
|
|
|
|
width = width.replace('px', '') * 1
|
|
|
|
} else {
|
|
|
|
width = 300
|
|
|
|
}
|
|
|
|
$('#post-box').css('width', width + 'px')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
function draftDraw() {
|
|
|
|
var draft = localStorage.getItem('draft')
|
|
|
|
var html = `<button class="btn waves-effect green" style="width:100%; padding:0; margin-top:0;" onclick="addToDraft();">${lang.lang_secure_draft}</button>`
|
|
|
|
if (draft) {
|
|
|
|
var draftObj = JSON.parse(draft)
|
|
|
|
for (let i = 0; i < draftObj.length; i++) {
|
|
|
|
var toot = draftObj[i]
|
|
|
|
html = html + `<div class="tootInDraft">
|
|
|
|
<i class="waves-effect gray material-icons" onclick="useThisDraft(${i})" title="${lang.lang_secure_userThis}">reply</i>
|
|
|
|
<i class="waves-effect gray material-icons" onclick="deleteThisDraft(${i})" title="${lang.lang_secure_deleteThis}">cancel</i>
|
|
|
|
${escapeHTML(toot.status).replace(/\n/, '').substr(0, 10)}
|
|
|
|
</div>`
|
|
|
|
}
|
|
|
|
}
|
|
|
|
$('#draft').html(html)
|
|
|
|
}
|
|
|
|
function addToDraft() {
|
|
|
|
var json = post(null, null, true)
|
|
|
|
var draft = localStorage.getItem('draft')
|
|
|
|
var draftObj = []
|
|
|
|
if (draft) draftObj = JSON.parse(draft)
|
|
|
|
draftObj.push(json)
|
|
|
|
draft = JSON.stringify(draftObj)
|
|
|
|
localStorage.setItem('draft', draft)
|
|
|
|
draftDraw()
|
|
|
|
}
|
|
|
|
function useThisDraft(i) {
|
|
|
|
var draft = localStorage.getItem('draft')
|
|
|
|
var draftObj = JSON.parse(draft)
|
|
|
|
draftToPost(draftObj[i], draftObj[i]['TheDeskAcctId'], 0)
|
|
|
|
draftToggle()
|
|
|
|
}
|
|
|
|
function deleteThisDraft(i) {
|
|
|
|
var draft = localStorage.getItem('draft')
|
|
|
|
var draftObj = JSON.parse(draft)
|
|
|
|
draftObj.splice(i, 1)
|
|
|
|
draft = JSON.stringify(draftObj)
|
|
|
|
localStorage.setItem('draft', draft)
|
|
|
|
draftDraw()
|
|
|
|
}
|