Skip to content

Instantly share code, notes, and snippets.

@rlemon
Last active July 23, 2017 20:34
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rlemon/e9247547487a83e70f68 to your computer and use it in GitHub Desktop.
Save rlemon/e9247547487a83e70f68 to your computer and use it in GitHub Desktop.
Bulk Trash
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