Sha256: bc1473247f634ec2bcae96fed607c768ad17a86ca73b0f37734986f3c6a82399

Contents?: true

Size: 1.63 KB

Versions: 10

Compression:

Stored size: 1.63 KB

Contents

/**
 * Boots up the Ext MVC application in the current environment. The environment defaults to 'production',
 * override by setting ?environment=someEnvironment to the end of the url. Default installed environments
 * are 'development' and 'test'
 */
(function() {  
  /**
   * @private
   * Inspects document.location and returns an object containing all of the url params
   * @return {Object} The url params
   */
  var parseLocationParams = function() {
    var args   = window.location.search.split("?")[1],
        //set default params
        params = {
          environment: 'production'
        };
    
    /**
     * Read config data from url parameters
     */
    if (args != undefined) {
      var argPairs = args.split("&");
      
      for (var i=0; i < argPairs.length; i++) {
        var splits = argPairs[i].split("="),
            key    = splits[0],
            value  = splits[1];

        params[key] = value;
      };
    }
    
    return params;
  };
  
  var params      = parseLocationParams(),
      environment = params.environment;
      
  var fileOrders = {
    production : [<% @production.each do |file| %>
      '<%= file %>'<% if @production.last != file %>,<% end %>
    <% end %>],
    development: [<% @development.each do |file| %>
      '<%= file %>'<% if @development.last != file %>,<% end %>
    <% end %>],
    test: [<% @test.each do |file| %>
      '<%= file %>'<% if @test.last != file %>,<% end %>
    <% end %>]
  };
  
  var filesToLoad = fileOrders[environment];
  for (var i=0; i < filesToLoad.length; i++) {    
    document.write('<script type="text/javascript" src="' + filesToLoad[i] + '"></script>');
  };
})();

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
xmvc-0.1.12 lib/xmvc/generators/templates/boot.js
xmvc-0.1.11 lib/xmvc/generators/templates/boot.js
xmvc-0.1.10 lib/xmvc/generators/templates/boot.js
xmvc-0.1.9 lib/xmvc/generators/templates/boot.js
xmvc-0.1.8 lib/xmvc/generators/templates/boot.js
xmvc-0.1.7 lib/xmvc/generators/templates/boot.js
xmvc-0.1.6 lib/xmvc/generators/templates/boot.js
xmvc-0.1.5 lib/xmvc/generators/templates/boot.js
xmvc-0.1.4 lib/xmvc/generators/templates/boot.js
xmvc-0.1.3 lib/xmvc/generators/templates/boot.js