Add NSFW on del and redraft #185

This commit is contained in:
cutls 2019-11-26 23:26:04 +09:00
parent c2cfbd5583
commit 3243602653

View File

@ -153,7 +153,7 @@ function bkm(id, acct_id, tlid) {
$('[toot-id=' + id + ']').addClass('bkmed') $('[toot-id=' + id + ']').addClass('bkmed')
} }
var tlidTar = $(`.bookmark-timeline[data-acct=${acct_id}]`).attr('tlid') var tlidTar = $(`.bookmark-timeline[data-acct=${acct_id}]`).attr('tlid')
columnReload(tlidTar,'bookmark') columnReload(tlidTar, 'bookmark')
} }
} }
} }
@ -389,7 +389,32 @@ function redraft(id, acct_id) {
}).then(result => { }).then(result => {
if (result.value) { if (result.value) {
show() show()
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 json = httpreq.response
$('#post-acct-sel').prop('disabled', true) $('#post-acct-sel').prop('disabled', true)
$('#post-acct-sel').val(acct_id) $('#post-acct-sel').val(acct_id)
$('select').formSelect() $('select').formSelect()
@ -406,6 +431,11 @@ function redraft(id, acct_id) {
$('#preview').append('<img src="' + url + '" style="width:50px; max-height:100px;">') $('#preview').append('<img src="' + url + '" style="width:50px; max-height:100px;">')
} }
}) })
localStorage.setItem('nohide', true)
show()
if(json.text){
var html = json.text
} else {
var html = $('[toot-id=' + id + '] .toot').html() var html = $('[toot-id=' + id + '] .toot').html()
html = html.replace(/^<p>(.+)<\/p>$/, '$1') html = html.replace(/^<p>(.+)<\/p>$/, '$1')
html = html.replace(/<br\s?\/?>/, '\n') html = html.replace(/<br\s?\/?>/, '\n')
@ -413,14 +443,18 @@ function redraft(id, acct_id) {
html = html.replace(/<\/p>/, '\n') html = html.replace(/<\/p>/, '\n')
html = html.replace(/<img[\s\S]*alt="(.+?)"[\s\S]*?>/g, '$1') html = html.replace(/<img[\s\S]*alt="(.+?)"[\s\S]*?>/g, '$1')
html = $.strip_tags(html) html = $.strip_tags(html)
localStorage.setItem('nohide', true) }
show()
$('#textarea').val(html) $('#textarea').val(html)
var cwtxt = $('[toot-id=' + id + '] .cw_text').html() if (json.spoiler_text) {
if (cwtxt != '') {
cwtxt = $.strip_tags(cwtxt)
cw() cw()
$('#cw-text').val(cwtxt) $('#cw-text').val(json.spoiler_text)
}
if (json.sensitive){
$('#nsfw').addClass('yellow-text')
$('#nsfw').html('visibility')
$('#nsfw').addClass('nsfw-avail')
}
}
} }
} }
}) })
@ -632,10 +666,10 @@ function toggleAction(elem, height) {
cont.removeClass('top') cont.removeClass('top')
cont.addClass('bottom') cont.addClass('bottom')
} }
if(elem.parents('.cvo').attr('id') == 'toot-this'){ if (elem.parents('.cvo').attr('id') == 'toot-this') {
console.log($('#toot-this').offset().top, elem.offset().top) console.log($('#toot-this').offset().top, elem.offset().top)
left = $('#toot-this').offset().left + elem.offset().left + 10 left = $('#toot-this').offset().left + elem.offset().left + 10
top = $('#toot-this').offset().top - $('#toot-this').height() -height + 25 top = $('#toot-this').offset().top - $('#toot-this').height() - height + 25
} }
cont.css('top', top + 'px') cont.css('top', top + 'px')
cont.css('right', `calc(100vw - ${left}px)`) cont.css('right', `calc(100vw - ${left}px)`)