1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- /* jshint browser: true */
- /* global $ */
- /**
- *
- * @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPLv3
- */
- function putPreview (arrayBuf) {
- var arrayBufView = new Uint8Array(arrayBuf)
- var blob = new Blob([arrayBufView.buffer], { type: "audio/ogg" })
- console.log(blob)
- var url = URL.createObjectURL(blob);
- var au = document.createElement('audio');
- //name of .wav file to use during upload and download (without extendion)
- var filename = new Date().toISOString();
- //add controls to the <audio> element
- au.controls = true;
- au.src = url;
- document.getElementById('preview').appendChild(au)
- }
- function upload(content) {
- // questa funzione non critta, ma si deve comunque chiamare così!
- $('#upload').on('click', function () {
- // TODO: fai questo alla conferma
- var submit = new XMLHttpRequest()
- submit.open('POST', "upload/" + $('body').data('site'),true)
- submit.onload = function (evt) {
- console.log('ok, caricato!')
- $('#bar').hide()
- $('#spiegazione1').hide()
- $('#status').text('Hai lasciato un messaggio in segreteria, grazie!')
- }
- submit.send(content)
- })
- }
- $(function guiFunctions() {
- $('#preview').hide()
- $('#stop_record').hide()
- $('#visualizer').hide()
- $('body').on('recording-start-ok', function() {
- $('#help').hide()
- $('#record_audio').hide()
- $('#stop_record').show()
- $('#visualizer').show()
- })
- $('body').on('recording-start-fail', function(evt, err) {
- $('#help').hide()
- $('#content').hide()
- $('#container').text('Errore! apri il microfono')
- })
- $('body').on('recording-stop-ready', function(evt, content) {
- $('#stop_record').hide()
- $('#visualizer').hide()
- $('#preview').show()
- putPreview(content)
- upload(content)
- })
- })
|