/** bait.coffee **/ (function() { window.Bait = { subscribe: function(handlers) { var source; source = new EventSource('/events'); return source.addEventListener("message", function(e) { var data, handler; data = JSON.parse(e.data); handler = handlers[data[0]][data[1]]; return handler.apply(this, data.slice(2)); }); } }; }).call(this); /** build.coffee **/ (function() { window.Build = { find: function(id) { return $("#" + id); }, all: function(cb) { return $.getJSON('/build', function(data) { return cb(data); }); }, DOM: { UIHelper: { expand_toggle: function(el) { return el.on("click", function(e) { if (el.css("max-height") === "100px") { return el.css("max-height", "100%"); } else { return el.css("max-height", "100px"); } }); }, enable_links: function(element) { element.find('a.remove').click(function() { $.ajax({ type: "DELETE", url: $(this).data('url') }); return false; }); return element.find('a.retest').click(function() { $(this).parents('.build').find('pre').html(""); $.post($(this).data('url')); return false; }); } }, init: function(build_id) { var build, output, pre; build = Build.find(build_id); pre = build.find(".output pre"); output = pre.html(); if ((output != null) && output.size > 0) { pre.html(ansi2html(output)); } Build.DOM.UIHelper.expand_toggle(pre); return Build.DOM.UIHelper.enable_links(build); } }, List: { add: function(build) { var html; html = Build.to_html(build); if ($('.build').length > 0) { $('.build').first().before(html); } else { $('ul#builds').append(html); } return Build.DOM.init(build.id); } }, to_html: function(build) { return "
" + build.output + "\n