Last active
July 23, 2017 20:34
-
-
Save rlemon/e9247547487a83e70f68 to your computer and use it in GitHub Desktop.
Bulk Trash
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var btn = $('<button class="button">Bulk Trash</button>'), | |
room = document.forms[0].elements.room.value; | |
btn.on('click', function() { | |
var modal = $('<div><h4>Trash Who?</h4></div>'), | |
$users = $('#present-users:not(.more)').clone(); | |
modal.append($users).addClass('popup room-popup').css({ | |
bottom: btn.position().top, | |
left: btn.position().left | |
}).on('click', function(e) { | |
if (confirm("Would you like to trash all posts by " + e.target.title)) { | |
var id = $(e.target).closest('li').prop('id').split('-')[2], | |
all = []; | |
$('.user-' + id + '.monologue .message').each(function() { | |
all.push(this.id.split('-')[1]); | |
}); | |
$.post("/admin/movePosts/" + room, fkey({ | |
ids: all.join(','), | |
to: 23262 | |
})); | |
modal.remove(); | |
} | |
return false; | |
}); | |
$(document.body).append(modal); | |
return false; | |
}); | |
$('#chat-buttons').append(btn); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment