thedesk/app/js/post/secure.js

130 lines
3.3 KiB
JavaScript
Raw Normal View History

2019-11-25 00:26:19 +11:00
'use strict'
2018-01-28 23:22:43 +11:00
/*保護系*/
//画像保護
2019-05-19 17:39:30 +10:00
function nsfw() {
2019-11-09 00:52:54 +11:00
if ($('#nsfw').hasClass('nsfw-avail')) {
$('#nsfw').removeClass('yellow-text')
$('#nsfw').html('visibility_off')
$('#nsfw').removeClass('nsfw-avail')
2019-05-19 17:39:30 +10:00
} else {
2019-11-09 00:52:54 +11:00
$('#nsfw').addClass('yellow-text')
$('#nsfw').html('visibility')
$('#nsfw').addClass('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
//コンテントワーニング
2019-05-19 17:39:30 +10:00
function cw() {
2019-11-09 00:52:54 +11:00
if ($('#cw').hasClass('cw-avail')) {
$('#cw-text').val()
$('#cw-text').hide()
$('#cw').removeClass('yellow-text')
$('#cw').removeClass('cw-avail')
2019-05-19 17:39:30 +10:00
} else {
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
}
}
}
2018-06-18 00:26:45 +10:00
//TLでコンテントワーニングを表示トグル
2019-05-19 17:39:30 +10:00
function cw_show(id) {
2019-11-09 00:52:54 +11:00
$('.cw_hide_' + id).toggleClass('cw')
$('.cw-long-' + id).toggleClass('hide')
2018-06-18 00:26:45 +10:00
}
2019-11-09 00:52:54 +11:00
$(function() {
$('#cw-text').on('change', function(event) {
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
}
}