Sha256: c0c87f93d84db1174e93367f014a3be05a7ba966d0b52ee70f172574efe79f5a
Contents?: true
Size: 1.22 KB
Versions: 7
Compression:
Stored size: 1.22 KB
Contents
// Load the functions based on the action and namespace of the page // @link: http://viget.com/inspire/extending-paul-irishs-comprehensive-dom-ready-execution var Izanami = { 'commands': { 'show': function() { // get the log with a EventSource stream var box = $('#log'); var id = box.data('id'); var log = new EventSource('/commands/' + id + '/log'); log.onmessage = function(e) { if ( e.data == 'CLOSE' ) { console.log('[IZANAMI] stream closed'); log.close(); } else { box.append('<div>' + e.data + '</div>'); }; }; } } }; // Object to load the functions based on the current namespace an action var Engine = { 'run': function(namespace, action) { var ns = Izanami; var action = (action === undefined) ? "init" : action; if (namespace !== "" && ns[namespace] && typeof ns[namespace][action] == "function") { ns[namespace][action](); } }, 'start': function() { var body = document.body; var namespace = body.getAttribute("data-namespace"); var action = body.getAttribute("data-action"); Engine.run(namespace, action); } }; // Fire it! $(document).ready(Engine.start);
Version data entries
7 entries across 7 versions & 1 rubygems