2020-03-18 01:35:58 +01:00
|
|
|
/* jshint browser: true */
|
|
|
|
/* global $ */
|
|
|
|
|
2020-03-18 01:55:57 +01:00
|
|
|
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)
|
|
|
|
}
|
|
|
|
|
2020-03-18 01:35:58 +01:00
|
|
|
function critta(content) {
|
|
|
|
// questa funzione non critta, ma si deve comunque chiamare così!
|
|
|
|
console.log(content)
|
2020-03-18 01:55:57 +01:00
|
|
|
$('#preview').show()
|
|
|
|
putPreview(content)
|
|
|
|
|
|
|
|
$('#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)
|
|
|
|
})
|
2020-03-18 01:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
$(function () {
|
2020-03-18 01:55:57 +01:00
|
|
|
$('#preview').hide()
|
2020-03-18 01:35:58 +01:00
|
|
|
$('#stop_record').hide()
|
|
|
|
$('#visualizer').hide()
|
|
|
|
$('#record_audio').on('click', function () {
|
|
|
|
$('#record_audio').hide()
|
|
|
|
$('#stop_record').show()
|
|
|
|
$('#visualizer').show()
|
|
|
|
})
|
|
|
|
$('#stop_record').on('click', function () {
|
|
|
|
$('#stop_record').hide()
|
|
|
|
$('#visualizer').hide()
|
|
|
|
})
|
|
|
|
})
|