function JobViewModel(repo, build, job, status) { var self = this; self.status = status; if (status !== "running" && status !== "pending") { Logs(repo, build, job); } if (status === "running") { Stream(repo, build, job, function(out){ $( "#output" ).append(out); }); } $("#restart").click(function() { $("#restart").hide(); $("#output").html(""); $(".status").attr("class", "status pending").text("pending"); $.ajax({ url: "/api/repos/"+repo+"/builds/"+build, type: "POST", success: function( data ) { }, error: function( data ) { console.log(data); } }); }) Subscribe(repo, function(data){ if (!data.jobs) { return; } var before = self.status; self.status = data.jobs[job-1].status; // update the status for each job in the view for (var i=0;i