source: trunk/zoo-project/zoo-client/lib/js/wps-client/utils.js @ 917

Last change on this file since 917 was 480, checked in by samsouk, 10 years ago

Libraries and templates for the Zoo WPS client Javascript implementation.

File size: 1.9 KB
Line 
1define([
2], function() {
3   
4   
5    // parseUri 1.2.2
6    // (c) Steven Levithan <stevenlevithan.com>
7    // MIT License
8
9    function parseUri (str) {
10        var     o   = parseUri.options,
11                m   = o.parser[o.strictMode ? "strict" : "loose"].exec(str),
12                uri = {},
13                i   = 14;
14
15        while (i--) uri[o.key[i]] = m[i] || "";
16
17        uri[o.q.name] = {};
18        uri[o.key[12]].replace(o.q.parser, function ($0, $1, $2) {
19                if ($1) uri[o.q.name][$1] = $2;
20        });
21
22        return uri;
23    };
24
25    parseUri.options = {
26        strictMode: false,
27        key: ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],
28        q:   {
29                name:   "queryKey",
30                parser: /(?:^|&)([^&=]*)=?([^&]*)/g
31        },
32        parser: {
33                strict: /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,
34                loose:  /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/
35        }
36    };
37   
38   
39    //
40    function xmlToString(data) {
41        //data.xml check for IE
42        var xmlstr = data.xml ? data.xml : (new XMLSerializer()).serializeToString(data);
43        return xmlstr;
44    }
45
46    function equalsString(a, b) {
47        if (!a) {
48                return false;
49        }
50
51        if (!b) {
52                return false;
53        }
54
55        return jQuery.trim(a).localeCompare(jQuery.trim(b)) == 0;
56    }
57
58    function encodeXML(str) {
59        return str.replace(/&/g, '&amp;')
60                   .replace(/</g, '&lt;')
61                   .replace(/>/g, '&gt;')
62                   .replace(/"/g, '&quot;')
63                   .replace(/'/g, '&apos;');
64    };
65   
66    return {
67        parseUri: parseUri,
68        xmlToString: xmlToString,
69        equalsString: equalsString,
70        encodeXML: encodeXML,
71    };
72   
73   
74});
Note: See TracBrowser for help on using the repository browser.

Search

Context Navigation

ZOO Sponsors

http://www.zoo-project.org/trac/chrome/site/img/geolabs-logo.pnghttp://www.zoo-project.org/trac/chrome/site/img/neogeo-logo.png http://www.zoo-project.org/trac/chrome/site/img/apptech-logo.png http://www.zoo-project.org/trac/chrome/site/img/3liz-logo.png http://www.zoo-project.org/trac/chrome/site/img/gateway-logo.png

Become a sponsor !

Knowledge partners

http://www.zoo-project.org/trac/chrome/site/img/ocu-logo.png http://www.zoo-project.org/trac/chrome/site/img/gucas-logo.png http://www.zoo-project.org/trac/chrome/site/img/polimi-logo.png http://www.zoo-project.org/trac/chrome/site/img/fem-logo.png http://www.zoo-project.org/trac/chrome/site/img/supsi-logo.png http://www.zoo-project.org/trac/chrome/site/img/cumtb-logo.png

Become a knowledge partner

Related links

http://zoo-project.org/img/ogclogo.png http://zoo-project.org/img/osgeologo.png