You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by ol...@apache.org on 2011/12/09 13:25:22 UTC

svn commit: r1212366 [5/5] - in /archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp: ./ WEB-INF/ js/ js/archiva/ js/redback/

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-debug.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout-debug.js
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js?rev=1212366&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js Fri Dec  9 12:25:21 2011
@@ -0,0 +1,62 @@
+// This is an example of one possible way to make a reusable component (or 'plugin'), consisting of:
+//  * A view model class, which gives a way to configure the component and to interact with it (e.g., by exposing currentPageIndex as an observable, external code can change the page index)
+//  * A custom binding (ko.bindingHandlers.simpleGrid in this example) so a developer can place instances of it into the DOM
+//     - in this example, the custom binding works by rendering some predefined templates using the ko.jqueryTmplTemplateEngine template engine
+//
+// There are loads of ways this grid example could be expanded. For example,
+//  * Letting the developer override the templates used to create the table header, table body, and page links div
+//  * Adding a "sort by clicking column headers" option
+//  * Creating some API to fetch table data using Ajax requests
+//  ... etc
+
+(function () {
+
+
+    ko.simpleGrid = {
+      // Defines a view model class you can use to populate a grid
+      viewModel: function (configuration) {
+        this.data = configuration.data;
+        this.currentPageIndex = ko.observable(0);
+        this.pageSize = configuration.pageSize || 5;
+        this.pageLinksId = configuration.pageLinksId;
+        this.columns = configuration.columns;
+
+        this.itemsOnCurrentPage = ko.dependentObservable(function () {
+            var startIndex = this.pageSize * this.currentPageIndex();
+            return this.data.slice(startIndex, startIndex + this.pageSize);
+        }, this);
+
+        this.maxPageIndex = ko.dependentObservable(function () {
+            return Math.ceil(ko.utils.unwrapObservable(this.data).length / this.pageSize);
+        }, this);
+      }
+    };
+
+    // Templates used to render the grid
+    var templateEngine = new ko.jqueryTmplTemplateEngine();
+
+
+    // The "simpleGrid" binding
+    ko.bindingHandlers.simpleGrid = {
+        // This method is called to initialize the node, and will also be called again if you change what the grid is bound to
+        update: function (element, viewModelAccessor, allBindingsAccessor) {
+          var viewModel = viewModelAccessor(), allBindings = allBindingsAccessor();
+
+          // Empty the element
+          while(element.firstChild)
+              ko.removeNode(element.firstChild);
+
+          // Allow the default templates to be overridden
+          var gridTemplateName      = allBindings.simpleGridTemplate || "ko_usersGrid_grid",
+              pageLinksTemplateName = allBindings.simpleGridPagerTemplate || "ko_usersGrid_pageLinks";
+
+          // Render the main grid
+          var gridContainer = element.appendChild(document.createElement("DIV"));
+          ko.renderTemplate(gridTemplateName, viewModel, { templateEngine: templateEngine }, gridContainer, "replaceNode");
+
+          // Render the page links
+          var pageLinksContainer = $("#"+viewModel.pageLinksId).get(0);//.appendChild(document.createElement("DIV"));
+          ko.renderTemplate(pageLinksTemplateName, viewModel, { templateEngine: templateEngine }, pageLinksContainer, "replaceNode");
+        }
+    };
+})();
\ No newline at end of file

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/knockout.simpleGrid.js
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/order.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/order.js?rev=1212366&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/order.js (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/order.js Fri Dec  9 12:25:21 2011
@@ -0,0 +1,180 @@
+/**
+ * @license RequireJS order 1.0.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
+ * Available via the MIT or new BSD license.
+ * see: http://github.com/jrburke/requirejs for details
+ */
+/*jslint nomen: false, plusplus: false, strict: false */
+/*global require: false, define: false, window: false, document: false,
+  setTimeout: false */
+
+//Specify that requirejs optimizer should wrap this code in a closure that
+//maps the namespaced requirejs API to non-namespaced local variables.
+/*requirejs namespace: true */
+
+(function () {
+
+    //Sadly necessary browser inference due to differences in the way
+    //that browsers load and execute dynamically inserted javascript
+    //and whether the script/cache method works when ordered execution is
+    //desired. Currently, Gecko and Opera do not load/fire onload for scripts with
+    //type="script/cache" but they execute injected scripts in order
+    //unless the 'async' flag is present.
+    //However, this is all changing in latest browsers implementing HTML5
+    //spec. With compliant browsers .async true by default, and
+    //if false, then it will execute in order. Favor that test first for forward
+    //compatibility.
+    var testScript = typeof document !== "undefined" &&
+                 typeof window !== "undefined" &&
+                 document.createElement("script"),
+
+        supportsInOrderExecution = testScript && (testScript.async ||
+                               ((window.opera &&
+                                 Object.prototype.toString.call(window.opera) === "[object Opera]") ||
+                               //If Firefox 2 does not have to be supported, then
+                               //a better check may be:
+                               //('mozIsLocallyAvailable' in window.navigator)
+                               ("MozAppearance" in document.documentElement.style))),
+
+        //This test is true for IE browsers, which will load scripts but only
+        //execute them once the script is added to the DOM.
+        supportsLoadSeparateFromExecute = testScript &&
+                                          testScript.readyState === 'uninitialized',
+
+        readyRegExp = /^(complete|loaded)$/,
+        cacheWaiting = [],
+        cached = {},
+        scriptNodes = {},
+        scriptWaiting = [];
+
+    //Done with the test script.
+    testScript = null;
+
+    //Callback used by the type="script/cache" callback that indicates a script
+    //has finished downloading.
+    function scriptCacheCallback(evt) {
+        var node = evt.currentTarget || evt.srcElement, i,
+            moduleName, resource;
+
+        if (evt.type === "load" || readyRegExp.test(node.readyState)) {
+            //Pull out the name of the module and the context.
+            moduleName = node.getAttribute("data-requiremodule");
+
+            //Mark this cache request as loaded
+            cached[moduleName] = true;
+
+            //Find out how many ordered modules have loaded
+            for (i = 0; (resource = cacheWaiting[i]); i++) {
+                if (cached[resource.name]) {
+                    resource.req([resource.name], resource.onLoad);
+                } else {
+                    //Something in the ordered list is not loaded,
+                    //so wait.
+                    break;
+                }
+            }
+
+            //If just loaded some items, remove them from cacheWaiting.
+            if (i > 0) {
+                cacheWaiting.splice(0, i);
+            }
+
+            //Remove this script tag from the DOM
+            //Use a setTimeout for cleanup because some older IE versions vomit
+            //if removing a script node while it is being evaluated.
+            setTimeout(function () {
+                node.parentNode.removeChild(node);
+            }, 15);
+        }
+    }
+
+    /**
+     * Used for the IE case, where fetching is done by creating script element
+     * but not attaching it to the DOM. This function will be called when that
+     * happens so it can be determined when the node can be attached to the
+     * DOM to trigger its execution.
+     */
+    function onFetchOnly(node) {
+        var i, loadedNode, resourceName;
+
+        //Mark this script as loaded.
+        node.setAttribute('data-orderloaded', 'loaded');
+
+        //Cycle through waiting scripts. If the matching node for them
+        //is loaded, and is in the right order, add it to the DOM
+        //to execute the script.
+        for (i = 0; (resourceName = scriptWaiting[i]); i++) {
+            loadedNode = scriptNodes[resourceName];
+            if (loadedNode &&
+                loadedNode.getAttribute('data-orderloaded') === 'loaded') {
+                delete scriptNodes[resourceName];
+                require.addScriptToDom(loadedNode);
+            } else {
+                break;
+            }
+        }
+
+        //If just loaded some items, remove them from waiting.
+        if (i > 0) {
+            scriptWaiting.splice(0, i);
+        }
+    }
+
+    define({
+        version: '1.0.0',
+
+        load: function (name, req, onLoad, config) {
+            var url = req.nameToUrl(name, null),
+                node, context;
+
+            //Make sure the async attribute is not set for any pathway involving
+            //this script.
+            require.s.skipAsync[url] = true;
+            if (supportsInOrderExecution || config.isBuild) {
+                //Just a normal script tag append, but without async attribute
+                //on the script.
+                req([name], onLoad);
+            } else if (supportsLoadSeparateFromExecute) {
+                //Just fetch the URL, but do not execute it yet. The
+                //non-standards IE case. Really not so nice because it is
+                //assuming and touching requrejs internals. OK though since
+                //ordered execution should go away after a long while.
+                context = require.s.contexts._;
+
+                if (!context.urlFetched[url] && !context.loaded[name]) {
+                    //Indicate the script is being fetched.
+                    context.urlFetched[url] = true;
+
+                    //Stuff from require.load
+                    require.resourcesReady(false);
+                    context.scriptCount += 1;
+
+                    //Fetch the script now, remember it.
+                    node = require.attach(url, context, name, null, null, onFetchOnly);
+                    scriptNodes[name] = node;
+                    scriptWaiting.push(name);
+                }
+
+                //Do a normal require for it, once it loads, use it as return
+                //value.
+                req([name], onLoad);
+            } else {
+                //Credit to LABjs author Kyle Simpson for finding that scripts
+                //with type="script/cache" allow scripts to be downloaded into
+                //browser cache but not executed. Use that
+                //so that subsequent addition of a real type="text/javascript"
+                //tag will cause the scripts to be executed immediately in the
+                //correct order.
+                if (req.specified(name)) {
+                    req([name], onLoad);
+                } else {
+                    cacheWaiting.push({
+                        name: name,
+                        req: req,
+                        onLoad: onLoad
+                    });
+                    require.attach(url, null, name, scriptCacheCallback, "script/cache");
+                }
+            }
+        }
+    });
+}());

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/order.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/order.js
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/i18nload.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/i18nload.js?rev=1212366&r1=1212365&r2=1212366&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/i18nload.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/i18nload.js Fri Dec  9 12:25:21 2011
@@ -16,8 +16,8 @@
 
 $(function() {
   // load default
-  loadAndParseFile("/restServices/redbackServices/utilServices/getBundleResources", {cache:false, mode: 'map',encoding:'utf-8'});
+  loadAndParseFile("restServices/redbackServices/utilServices/getBundleResources", {cache:false, mode: 'map',encoding:'utf-8'});
   // load browser locale
   var browserLang = $.i18n.browserLang();
-  loadAndParseFile("/restServices/redbackServices/utilServices/getBundleResources?locale="+browserLang, {cache:false, mode: 'map',encoding:'utf-8'});
+  loadAndParseFile("restServices/redbackServices/utilServices/getBundleResources?locale="+browserLang, {cache:false, mode: 'map',encoding:'utf-8'});
 });
\ No newline at end of file

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/register.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/register.js?rev=1212366&r1=1212365&r2=1212366&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/register.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/register.js Fri Dec  9 12:25:21 2011
@@ -50,7 +50,7 @@ $(function() {
     user.fullName = $("#user-register-form-fullname").val();
     user.email = $("#user-register-form-email").val();
     jQuery.ajax({
-      url:  '/restServices/redbackServices/userService/registerUser',
+      url:  'restServices/redbackServices/userService/registerUser',
       data:  '{"user":'+JSON.stringify(user)+'}',
       type: 'POST',
       contentType: "application/json",
@@ -89,7 +89,7 @@ $(function() {
   validateKey=function(key) {
     // spinner display
     $.ajax({
-      url: '/restServices/redbackServices/userService/validateKey/'+key,
+      url: 'restServices/redbackServices/userService/validateKey/'+key,
       type: 'GET',
        success: function(result){
          window.redbackModel.key=key;

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js?rev=1212366&r1=1212365&r2=1212366&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/user.js Fri Dec  9 12:25:21 2011
@@ -45,7 +45,7 @@ $(function() {
       };
       this.createUser = function() {
         var currentUser = this;
-        $.ajax("/restServices/redbackServices/userService/createUser", {
+        $.ajax("restServices/redbackServices/userService/createUser", {
             data: "{\"user\": " +  ko.toJSON(this)+"}",
             contentType: 'application/json',
             type: "POST",
@@ -76,7 +76,7 @@ $(function() {
             return;
         }
 
-        $.ajax("/restServices/redbackServices/userService/createAdminUser", {
+        $.ajax("restServices/redbackServices/userService/createAdminUser", {
             data: "{\"user\": " +  ko.toJSON(this)+"}",
             contentType: 'application/json',
             type: "POST",
@@ -102,7 +102,7 @@ $(function() {
         // FIXME i18n
         var currentUser = this;
         openDialogConfirm(function(){
-          $.ajax("/restServices/redbackServices/userService/deleteUser/"+currentUser.username(), {
+          $.ajax("restServices/redbackServices/userService/deleteUser/"+currentUser.username(), {
                 type: "GET",
                 dataType: 'json',
                 success: function(data) {
@@ -126,7 +126,7 @@ $(function() {
 
       this.update=function(){
         var currentUser = this;
-        $.ajax("/restServices/redbackServices/userService/updateUser", {
+        $.ajax("restServices/redbackServices/userService/updateUser", {
             data: "{\"user\": " +  ko.toJSON(this)+"}",
             contentType: 'application/json',
             type: "POST",
@@ -215,7 +215,7 @@ $(function() {
     //#modal-login-footer
     $('#modal-login-footer').append(smallSpinnerImg());
 
-    var url = '/restServices/redbackServices/loginService/logIn?userName='+$("#user-login-form-username").val();
+    var url = 'restServices/redbackServices/loginService/logIn?userName='+$("#user-login-form-username").val();
     url += "&password="+$("#user-login-form-password").val();
 
     $.ajax({
@@ -356,7 +356,7 @@ $(function() {
 
   editUserDetails=function(user){
     $("#modal-user-edit-err-message").html("");
-    $.ajax("/restServices/redbackServices/userService/updateMe", {
+    $.ajax("restServices/redbackServices/userService/updateMe", {
         data: "{\"user\": " +  ko.toJSON(user)+"}",
         contentType: 'application/json',
         type: "POST",
@@ -397,12 +397,12 @@ $(function() {
     $('#modal-password-change-footer').append(smallSpinnerImg());
 
     if (registration==true) {
-      var url = '/restServices/redbackServices/passwordService/changePasswordWithKey?';
+      var url = 'restServices/redbackServices/passwordService/changePasswordWithKey?';
       url += "password="+$("#passwordChangeFormNewPassword").val();
       url += "&passwordConfirmation="+$("#passwordChangeFormNewPasswordConfirm").val();
       url += "&key="+window.redbackModel.key;
     } else {
-      var url = '/restServices/redbackServices/passwordService/changePassword?';
+      var url = 'restServices/redbackServices/passwordService/changePassword?';
       url += "password="+$("#passwordChangeFormNewPassword").val();
       url += "&passwordConfirmation="+$("#passwordChangeFormNewPasswordConfirm").val();
       url += "&previousPassword="+$("#password-change-form-current-password").val();

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js?rev=1212366&r1=1212365&r2=1212366&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js (original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/redback/users.js Fri Dec  9 12:25:21 2011
@@ -20,7 +20,7 @@ $(function() {
     var self = this;
 
     this.loadUsers = function() {
-      $.ajax("/restServices/redbackServices/userService/getUsers", {
+      $.ajax("restServices/redbackServices/userService/getUsers", {
           type: "GET",
           dataType: 'json',
           success: function(data) {

Added: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/text.js
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/text.js?rev=1212366&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/text.js (added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/text.js Fri Dec  9 12:25:21 2011
@@ -0,0 +1,276 @@
+/**
+ * @license RequireJS text 1.0.0 Copyright (c) 2010-2011, The Dojo Foundation All Rights Reserved.
+ * Available via the MIT or new BSD license.
+ * see: http://github.com/jrburke/requirejs for details
+ */
+/*jslint regexp: false, nomen: false, plusplus: false, strict: false */
+/*global require: false, XMLHttpRequest: false, ActiveXObject: false,
+  define: false, window: false, process: false, Packages: false,
+  java: false, location: false */
+
+(function () {
+    var progIds = ['Msxml2.XMLHTTP', 'Microsoft.XMLHTTP', 'Msxml2.XMLHTTP.4.0'],
+        xmlRegExp = /^\s*<\?xml(\s)+version=[\'\"](\d)*.(\d)*[\'\"](\s)*\?>/im,
+        bodyRegExp = /<body[^>]*>\s*([\s\S]+)\s*<\/body>/im,
+        hasLocation = typeof location !== 'undefined' && location.href,
+        defaultProtocol = hasLocation && location.protocol && location.protocol.replace(/\:/, ''),
+        defaultHostName = hasLocation && location.hostname,
+        defaultPort = hasLocation && (location.port || undefined),
+        buildMap = [];
+
+    define(function () {
+        var text, get, fs;
+
+        if (typeof window !== "undefined" && window.navigator && window.document) {
+            get = function (url, callback) {
+                var xhr = text.createXhr();
+                xhr.open('GET', url, true);
+                xhr.onreadystatechange = function (evt) {
+                    //Do not explicitly handle errors, those should be
+                    //visible via console output in the browser.
+                    if (xhr.readyState === 4) {
+                        callback(xhr.responseText);
+                    }
+                };
+                xhr.send(null);
+            };
+        } else if (typeof process !== "undefined" &&
+                 process.versions &&
+                 !!process.versions.node) {
+            //Using special require.nodeRequire, something added by r.js.
+            fs = require.nodeRequire('fs');
+
+            get = function (url, callback) {
+                callback(fs.readFileSync(url, 'utf8'));
+            };
+        } else if (typeof Packages !== 'undefined') {
+            //Why Java, why is this so awkward?
+            get = function (url, callback) {
+                var encoding = "utf-8",
+                    file = new java.io.File(url),
+                    lineSeparator = java.lang.System.getProperty("line.separator"),
+                    input = new java.io.BufferedReader(new java.io.InputStreamReader(new java.io.FileInputStream(file), encoding)),
+                    stringBuffer, line,
+                    content = '';
+                try {
+                    stringBuffer = new java.lang.StringBuffer();
+                    line = input.readLine();
+
+                    // Byte Order Mark (BOM) - The Unicode Standard, version 3.0, page 324
+                    // http://www.unicode.org/faq/utf_bom.html
+
+                    // Note that when we use utf-8, the BOM should appear as "EF BB BF", but it doesn't due to this bug in the JDK:
+                    // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4508058
+                    if (line && line.length() && line.charAt(0) === 0xfeff) {
+                        // Eat the BOM, since we've already found the encoding on this file,
+                        // and we plan to concatenating this buffer with others; the BOM should
+                        // only appear at the top of a file.
+                        line = line.substring(1);
+                    }
+
+                    stringBuffer.append(line);
+
+                    while ((line = input.readLine()) !== null) {
+                        stringBuffer.append(lineSeparator);
+                        stringBuffer.append(line);
+                    }
+                    //Make sure we return a JavaScript string and not a Java string.
+                    content = String(stringBuffer.toString()); //String
+                } finally {
+                    input.close();
+                }
+                callback(content);
+            };
+        }
+
+        text = {
+            version: '1.0.0',
+
+            strip: function (content) {
+                //Strips <?xml ...?> declarations so that external SVG and XML
+                //documents can be added to a document without worry. Also, if the string
+                //is an HTML document, only the part inside the body tag is returned.
+                if (content) {
+                    content = content.replace(xmlRegExp, "");
+                    var matches = content.match(bodyRegExp);
+                    if (matches) {
+                        content = matches[1];
+                    }
+                } else {
+                    content = "";
+                }
+                return content;
+            },
+
+            jsEscape: function (content) {
+                return content.replace(/(['\\])/g, '\\$1')
+                    .replace(/[\f]/g, "\\f")
+                    .replace(/[\b]/g, "\\b")
+                    .replace(/[\n]/g, "\\n")
+                    .replace(/[\t]/g, "\\t")
+                    .replace(/[\r]/g, "\\r");
+            },
+
+            createXhr: function () {
+                //Would love to dump the ActiveX crap in here. Need IE 6 to die first.
+                var xhr, i, progId;
+                if (typeof XMLHttpRequest !== "undefined") {
+                    return new XMLHttpRequest();
+                } else {
+                    for (i = 0; i < 3; i++) {
+                        progId = progIds[i];
+                        try {
+                            xhr = new ActiveXObject(progId);
+                        } catch (e) {}
+
+                        if (xhr) {
+                            progIds = [progId];  // so faster next time
+                            break;
+                        }
+                    }
+                }
+
+                if (!xhr) {
+                    throw new Error("createXhr(): XMLHttpRequest not available");
+                }
+
+                return xhr;
+            },
+
+            get: get,
+
+            /**
+             * Parses a resource name into its component parts. Resource names
+             * look like: module/name.ext!strip, where the !strip part is
+             * optional.
+             * @param {String} name the resource name
+             * @returns {Object} with properties "moduleName", "ext" and "strip"
+             * where strip is a boolean.
+             */
+            parseName: function (name) {
+                var strip = false, index = name.indexOf("."),
+                    modName = name.substring(0, index),
+                    ext = name.substring(index + 1, name.length);
+
+                index = ext.indexOf("!");
+                if (index !== -1) {
+                    //Pull off the strip arg.
+                    strip = ext.substring(index + 1, ext.length);
+                    strip = strip === "strip";
+                    ext = ext.substring(0, index);
+                }
+
+                return {
+                    moduleName: modName,
+                    ext: ext,
+                    strip: strip
+                };
+            },
+
+            xdRegExp: /^((\w+)\:)?\/\/([^\/\\]+)/,
+
+            /**
+             * Is an URL on another domain. Only works for browser use, returns
+             * false in non-browser environments. Only used to know if an
+             * optimized .js version of a text resource should be loaded
+             * instead.
+             * @param {String} url
+             * @returns Boolean
+             */
+            useXhr: function (url, protocol, hostname, port) {
+                var match = text.xdRegExp.exec(url),
+                    uProtocol, uHostName, uPort;
+                if (!match) {
+                    return true;
+                }
+                uProtocol = match[2];
+                uHostName = match[3];
+
+                uHostName = uHostName.split(':');
+                uPort = uHostName[1];
+                uHostName = uHostName[0];
+
+                return (!uProtocol || uProtocol === protocol) &&
+                       (!uHostName || uHostName === hostname) &&
+                       ((!uPort && !uHostName) || uPort === port);
+            },
+
+            finishLoad: function (name, strip, content, onLoad, config) {
+                content = strip ? text.strip(content) : content;
+                if (config.isBuild && config.inlineText) {
+                    buildMap[name] = content;
+                }
+                onLoad(content);
+            },
+
+            load: function (name, req, onLoad, config) {
+                //Name has format: some.module.filext!strip
+                //The strip part is optional.
+                //if strip is present, then that means only get the string contents
+                //inside a body tag in an HTML string. For XML/SVG content it means
+                //removing the <?xml ...?> declarations so the content can be inserted
+                //into the current doc without problems.
+
+                var parsed = text.parseName(name),
+                    nonStripName = parsed.moduleName + '.' + parsed.ext,
+                    url = req.toUrl(nonStripName),
+                    useXhr = (config && config.text && config.text.useXhr) ||
+                             text.useXhr;
+
+                //Load the text. Use XHR if possible and in a browser.
+                if (!hasLocation || useXhr(url, defaultProtocol, defaultHostName, defaultPort)) {
+                    text.get(url, function (content) {
+                        text.finishLoad(name, parsed.strip, content, onLoad, config);
+                    });
+                } else {
+                    //Need to fetch the resource across domains. Assume
+                    //the resource has been optimized into a JS module. Fetch
+                    //by the module name + extension, but do not include the
+                    //!strip part to avoid file system issues.
+                    req([nonStripName], function (content) {
+                        text.finishLoad(parsed.moduleName + '.' + parsed.ext,
+                                        parsed.strip, content, onLoad, config);
+                    });
+                }
+            },
+
+            write: function (pluginName, moduleName, write, config) {
+                if (moduleName in buildMap) {
+                    var content = text.jsEscape(buildMap[moduleName]);
+                    write.asModule(pluginName + "!" + moduleName,
+                                   "define(function () { return '" +
+                                       content +
+                                   "';});\n");
+                }
+            },
+
+            writeFile: function (pluginName, moduleName, req, write, config) {
+                var parsed = text.parseName(moduleName),
+                    nonStripName = parsed.moduleName + '.' + parsed.ext,
+                    //Use a '.js' file name so that it indicates it is a
+                    //script that can be loaded across domains.
+                    fileName = req.toUrl(parsed.moduleName + '.' +
+                                         parsed.ext) + '.js';
+
+                //Leverage own load() method to load plugin value, but only
+                //write out values that do not have the strip argument,
+                //to avoid any potential issues with ! in file names.
+                text.load(nonStripName, req, function (value) {
+                    //Use own write() method to construct full module value.
+                    //But need to create shell that translates writeFile's
+                    //write() to the right interface.
+                    var textWrite = function (contents) {
+                        return write(fileName, contents);
+                    };
+                    textWrite.asModule = function (moduleName, contents) {
+                        return write.asModule(moduleName, fileName, contents);
+                    };
+
+                    text.write(pluginName, nonStripName, textWrite, config);
+                }, config);
+            }
+        };
+
+        return text;
+    });
+}());

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/text.js
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/text.js
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision