Add NSFW on del and redraft #185
This commit is contained in:
parent
c2cfbd5583
commit
3243602653
|
@ -389,7 +389,32 @@ function redraft(id, acct_id) {
|
|||
}).then(result => {
|
||||
if (result.value) {
|
||||
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').val(acct_id)
|
||||
$('select').formSelect()
|
||||
|
@ -406,6 +431,11 @@ function redraft(id, acct_id) {
|
|||
$('#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()
|
||||
html = html.replace(/^<p>(.+)<\/p>$/, '$1')
|
||||
html = html.replace(/<br\s?\/?>/, '\n')
|
||||
|
@ -413,14 +443,18 @@ function redraft(id, acct_id) {
|
|||
html = html.replace(/<\/p>/, '\n')
|
||||
html = html.replace(/<img[\s\S]*alt="(.+?)"[\s\S]*?>/g, '$1')
|
||||
html = $.strip_tags(html)
|
||||
localStorage.setItem('nohide', true)
|
||||
show()
|
||||
}
|
||||
$('#textarea').val(html)
|
||||
var cwtxt = $('[toot-id=' + id + '] .cw_text').html()
|
||||
if (cwtxt != '') {
|
||||
cwtxt = $.strip_tags(cwtxt)
|
||||
if (json.spoiler_text) {
|
||||
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')
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue
Block a user