$(function() { $tests = $("#tests") runtest = function(name) { test = $(name) test.attr('disabled', true) test.addClass('disabled') window.urb.send({ appl:"test", data:{test:name} }, function(err,res) { test.attr('disabled', false) test.removeClass('disabled') _test = { name: name, result: res.data } console.log('set it') console.log(_test) $tests.prepend(renderTest(_test)) }) } renderTest = function(test) { css = "test" if(test.pending == true) css += " pending" $_test = $("
") $_test.append("
"+test.name+"
") $_test.append("
"+JSON.stringify(test.result)+"
") return $_test } renderTests = function(testlist) { console.log("renderTests: "+testlist) $tests.html("") for(i in testlist) { $tests.append(renderTest(testlist[i])) } } renderError = function(error) { $tests.html("
Sorry! There was an error fetching from Test: "+error+"
") } window.urb.subscribe({ appl:"test", path:"/tests" }, function(err,res) { console.log('subscr') console.log(arguments) if (res.data.ok) return if(err) renderTests(err) else { if(res.data) { if(res.data) { renderTests(res.data) } else { renderTests("unknown error") } } } }) })