Skip to content

Instantly share code, notes, and snippets.

@mallowlabs
Created April 30, 2015 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mallowlabs/a9b20aaecd015734580d to your computer and use it in GitHub Desktop.
Save mallowlabs/a9b20aaecd015734580d to your computer and use it in GitHub Desktop.
AsakusaSatellite Image Paster Plugin
// AsakusaSatellite Image Paster
(function($, document, window, undefined){
$('form.inputarea').on('paste', function(event){
var items = event.originalEvent.clipboardData.items;
for (var i = 0, l = items.length; i < l; i++) {
var item = items[i];
if (item.type.indexOf("image") == -1) {
continue;
}
var formData = new FormData();
formData.append('file', item.getAsFile(), "screenshot.png");
formData.append('room_id', AsakusaSatellite.current.room);
formData.append('authenticity_token', AsakusaSatellite.form_auth);
$.ajax(AsakusaSatellite.url.message , {
type: 'POST',
contentType: false,
processData: false,
data: formData
});
}
});
})(jQuery, document, window);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment