6
When this code is run all together gives this error, but if it is formatted with line breaks it runs normally, how to fix?
Error:
Uncaught Syntaxerror: Unexpected token this
Code in question:
var Recorder = function(source){ this.context = source.context; if(!this.context.createScriptProcessor){ this.node = this.context.createJavaScriptNode(4096, 2, 2); } else { this.node = this.context.createScriptProcessor(4096, 2, 2); } var AW = new Worker('./scr/js/crypto_worker.js'); this.node.onaudioprocess = function(e){ if (!Config.audioRecording) { return; } AW.postMessage({data:{ taskID: 'record', buffer: [ e.inputBuffer.getChannelData(0), e.inputBuffer.getChannelData(1) ] }}); } this.record = function(){ Config.audioRecording = true; Config.analyserCallbackSTA(); } this.stop = function(){ Config.audioRecording = false; } this.clear = function(){ AW.postMessage({data:{ taskID: 'clear' }}); } this.getBuffers = function(cb) { Config.audioCallback = cb; AW.postMessage({data:{ taskID: 'getBuffers' }}); } this.exportWAV = function(callback, type){ Config.audioCallback = callback; type = 'audio/wav'; if (!Config.audioCallback) { Config.audioRecorder.stop(); console.error(dT(), 'Failed in generation of audio/wav'); safeConfirm({ type: 'ERROR_SYS', noBar: true, message: User.LANGUAGE.ERROR_AUDIO_SYS }); return; } AW.postMessage({data:{ taskID: 'exportWAV', type: type }}); } AW.onmessage = function(e){ if(Config.audioCallback) { Config.audioCallback(e.data); } } source.connect(this.node); this.node.connect(this.context.destination); };
Thank you very much! Something else has entered my knowledge
– Elaine
Good, I’m happy when my answers contribute to people’s knowledge!
– bfavaretto