io.setPath("/javascripts/socket.io/") var socket = new io.Socket('localhost', {port:8081}) function active() { $('#kthxbye').removeClass("failed success").addClass("active") } function failed() { $('#kthxbye').removeClass("active success").addClass("failed") } function succeeded() { $('#kthxbye').removeClass("active failed").addClass("success") } if(socket.connect()) { socket.on('message', function(data) { try { var status = JSON.parse(data) } catch (SyntaxError) { return false; } if(status.id != parseInt(job_id)) return false; if(status.status == 'job.failed') { failed() } else if(status.status == 'job.completed') { succeeded() } else if(status.status == 'job.started') { active() } else { alert('Unknown option! ' + status.status) } return false }) }