"use strict";

var DEBUG = false;
var _webGME_jquery_ver = '2.1.0';
var _webGME_jqueryui_ver = '1.10.4';

// configure require path and modules
require.config({
    baseUrl: "/",
    paths: {
        //RequireJS plugins
        "text":	'lib/require/text',
        "css": 'lib/require/rcss',
        "domReady":	'lib/require/domReady',

        //jQuery and stuff
        "jquery": 'lib/jquery/jquery-' + _webGME_jquery_ver + '.min',
        "jquery-ui": 'lib/jquery/jquery-ui-' + _webGME_jqueryui_ver + '.min',
        "jquery-ui-iPad": 'lib/jquery/jquery.ui.ipad',
        "jquery-WebGME": 'js/jquery.WebGME',
        "jquery-dataTables": 'lib/jquery/jquery.dataTables.min',
        "jquery-dataTables-bootstrapped": 'lib/jquery/jquery.dataTables.bootstrapped',
        "jquery-spectrum": 'lib/jquery/jquery.spectrum',

        //necessary 3rd party modules
        "bootstrap": 'lib/bootstrap/bootstrap.amd',
        "underscore": 'lib/underscore/underscore-min',
        "backbone": 'lib/backbone/backbone.min',
        "d3": 'lib/d3/d3.v3.min',
        "jscolor": 'lib/jscolor/jscolor',

        //RaphaelJS family
        "eve": 'lib/raphael/eve',   //needed because of raphael.core.js uses require with 'eve'
        "raphaeljs": 'lib/raphael/raphael.amd',
        "raphael_core": 'lib/raphael/raphael.core',
        "raphael_svg": 'lib/raphael/raphael.svg_fixed',
        "raphael_vml": 'lib/raphael/raphael.vml',

        //WebGME custom modules
        "logManager": 'common/LogManager',
        "eventDispatcher": 'common/EventDispatcher',
        "notificationManager": 'js/NotificationManager',
        "clientUtil": 'js/util',
        "loaderCircles": "js/Loader/LoaderCircles",
        "loaderProgressBar": "js/Loader/LoaderProgressBar",

        "codemirror": 'lib/codemirror/codemirror.amd',
        "jquery-csszoom": 'lib/jquery/jquery.csszoom',

        "jszip": 'lib/jszip/jszip'
    },
    shim: {
        'jquery-ui': ['jquery'],
        'jquery-ui-iPad': ['jquery','jquery-ui'],
        'bootstrap': ['jquery'],
        'backbone': ['underscore'],
        'clientUtil': ['jquery'],
        'jquery-WebGME': ['bootstrap'],
        'jquery-dataTables': ['jquery'],
        'jquery-dataTables-bootstrapped': ['jquery-dataTables'],
        'WebGME': ['jquery-WebGME'],
        'jquery-csszoom': ['jquery-ui'],
        'jquery-spectrum': ['jquery'],
        'raphael_svg': ['raphael_core'],
        'raphael_vml': ['raphael_core']
    }
});

require(
    [
        'domReady',
        'jquery',
        'jquery-ui',
        'jquery-ui-iPad',
        'jquery-WebGME',
        'jquery-dataTables-bootstrapped',
        'bootstrap',
        'underscore',
        'backbone',
        'js/WebGME',
        'clientUtil',
        'bin/getconfig'
    ],
    function (domReady, jQuery, jQueryUi, jQueryUiiPad, jqueryWebGME, jqueryDataTables, bootstrap, underscore, backbone, webGME, util, CONFIG) {
        domReady(function () {
            //#1 set debug info from config file
            if (CONFIG.hasOwnProperty('debug')) {
                DEBUG = CONFIG['debug'];
            }

            //#2 check URL
            var d = util.getURLParameterByName('d').toLowerCase();
            if (d === 'debug') {
                DEBUG = true;
            } else if (d === 'rel') {
                DEBUG = false;
            }


            // attach external libraries to extlib/*
            var keys = Object.keys(CONFIG.paths);
            for (var i = 0; i < keys.length; i += 1) {
                // assume this is a relative path from the current working directory
                CONFIG.paths[keys[i]] = 'extlib/' + CONFIG.paths[keys[i]];
            }

            // update client config to route the external lib requests
            require.config({
                paths: CONFIG.paths
            });


            webGME.start();
        });
    }
);

@@ -3328,17 +3328,52 @@
      %7D%0A%0A
-%0A
+            if (CONFIG.paths) %7B%0A    
         
@@ -3425,24 +3425,28 @@
             
+    
 var keys = O
@@ -3471,16 +3471,20 @@
 paths);%0A
+    
         
@@ -3542,24 +3542,28 @@
             
+    
 // assume th
@@ -3635,16 +3635,20 @@
         
+    
 CONFIG.p
@@ -3702,35 +3702,43 @@
 %5D%5D;%0A            
+   
+ 
 %7D%0A%0A
+    
             // u
@@ -3804,16 +3804,20 @@
         
+    
 require.
@@ -3837,24 +3837,28 @@
             
+  
+  
 paths: CONFI
@@ -3877,19 +3877,38 @@
         
-%7D);
+    %7D);%0A%0A            %7D
 %0A%0A%0A     

Check for CONFIG.paths when setting extlibs.