{I" class:ETI"ProcessedAsset;FI"logical_path;TI"magic_lamp/genie.js;FI" pathname;TI"U/Users/Michael/Development/magic_lamp/app/assets/javascripts/magic_lamp/genie.js;FI"content_type;TI"application/javascript;TI" mtime;Tl+gì:TI" length;Tiï I" digest;TI"%1546cd5618eb595945ff27b4b4e1f034;FI" source;TI"ï (function(global) { function Genie() { this.cache = {}; this.cacheOnly = false; this.namespace = MagicLamp; } Genie.prototype = { load: function(path) { this.removeFixtureContainer(); var fixture = this.cache[path]; this.createFixtureContainer(); if (!fixture && this.cacheOnly) { throw new Error('The fixture "' + path + '" was not preloaded. Is the fixture registered? Call `MagicLamp.fixtureNames()` to see what is registered.'); } else if (!fixture) { var xhr = this.xhrRequest(getPath() + '/' + path); this.cache[path] = fixture = xhr.responseText; } this.fixtureContainer.innerHTML = fixture; this.appendFixtureContainer(); }, preload: function() { var xhr = this.xhrRequest(getPath()); var json = JSON.parse(xhr.responseText); this.cache = json; this.cacheOnly = true; }, fixtureNames: function() { var names = []; for (fixtureName in this.cache) { if (this.cache.hasOwnProperty(fixtureName)) { names.push(fixtureName); } } var sortedNames = names.sort(); for (var i = 0; i < sortedNames.length; i++) { console.log(sortedNames[i]); }; return sortedNames; }, createFixtureContainer: function() { var div = document.createElement('div'); div.setAttribute('class', this.namespace.class || 'magic-lamp'); this.fixtureContainer = div; }, appendFixtureContainer: function() { document.body.appendChild(this.fixtureContainer); }, removeFixtureContainer: function() { if (this.fixtureContainer) { remove(this.fixtureContainer); this.fixtureContainer = undefined; } }, handleError: function(errorMessage) { throw new Error(errorMessage); }, xhrRequest: function(path) { var xhr = newXhr(); xhr.open('GET', path, false); xhr.send(); if (this.xhrStatus(xhr) === 400) { this.handleError(xhr.responseText); } else if (this.xhrStatus(xhr) === 500) { this.handleError('Something went wrong, please check the server log or run `rake magic_lamp:lint` for more information'); } return xhr; }, xhrStatus: function(xhr) { return xhr.status; } }; // private function getPath() { return MagicLamp.path || '/magic_lamp'; } function remove(node) { var parentNode = node.parentNode; parentNode && parentNode.removeChild(node); } function newXhr() { var xhr; if (window.XMLHttpRequest) { // Mozilla, Safari, ... xhr = new XMLHttpRequest(); } else if (window.ActiveXObject) { // IE try { xhr = new ActiveXObject('Msxml2.XMLHTTP'); } catch (error) { try { xhr = new ActiveXObject('Microsoft.XMLHTTP'); } catch (e) { // let it go } } } if (!xhr) { throw('Unable to make request'); } return xhr; } MagicLamp.Genie = Genie; })(this); ;TI"dependency_digest;TI"%40897b748db203d3fb48ed7bc877f50f;FI"required_paths;T[I"U/Users/Michael/Development/magic_lamp/app/assets/javascripts/magic_lamp/genie.js;FI"dependency_paths;T[{I" path;TI"U/Users/Michael/Development/magic_lamp/app/assets/javascripts/magic_lamp/genie.js;FI" mtime;TI"2014-10-12T16:02:31-05:00;TI" digest;TI"%1546cd5618eb595945ff27b4b4e1f034;FI" _version;TI"%d978939c91fa8a88b4612c4140ee433d;F