Created
April 30, 2015 13:12
-
-
Save mallowlabs/a9b20aaecd015734580d to your computer and use it in GitHub Desktop.
AsakusaSatellite Image Paster Plugin
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
// 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