Commit 6a702c168b59e1f50e2c6a170f7945e942af5cdb

Authored by Luciano Borges
1 parent 4b60d662
Exists in master

Substituição do purl.js pela função getUrlParameterByName no app.js

archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/controller/bookmark-edit.js
... ... @@ -2,7 +2,7 @@ $(function() {
2 2 $("#delete").hide();
3 3 $("#description").focus();
4 4  
5   - if (id = $.url().param('id')) {
  5 + if (id = App.getUrlParameterByName('id')) {
6 6 BookmarkProxy.load(id).done(loadOk).fail(loadFailed);
7 7 }
8 8  
... ...
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/lib/app.js
... ... @@ -29,5 +29,12 @@ var App = {
29 29  
30 30 removeToken : function() {
31 31 sessionStorage.removeItem(this.tokenKey);
  32 + },
  33 +
  34 + getUrlParameterByName : function(name) {
  35 + name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
  36 + var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
  37 + results = regex.exec(location.search);
  38 + return results === null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
32 39 }
33 40 };
... ...
archetype/html-rest/src/main/resources/archetype-resources/src/main/webapp/js/lib/purl.js
... ... @@ -1,265 +0,0 @@
1   -/*
2   - * Purl (A JavaScript URL parser) v2.3.1
3   - * Developed and maintanined by Mark Perkins, mark@allmarkedup.com
4   - * Source repository: https://github.com/allmarkedup/jQuery-URL-Parser
5   - * Licensed under an MIT-style license. See https://github.com/allmarkedup/jQuery-URL-Parser/blob/master/LICENSE for details.
6   - */
7   -
8   -;(function(factory) {
9   - if (typeof define === 'function' && define.amd) {
10   - define(factory);
11   - } else {
12   - window.purl = factory();
13   - }
14   -})(function() {
15   -
16   - var tag2attr = {
17   - a : 'href',
18   - img : 'src',
19   - form : 'action',
20   - base : 'href',
21   - script : 'src',
22   - iframe : 'src',
23   - link : 'href'
24   - },
25   -
26   - key = ['source', 'protocol', 'authority', 'userInfo', 'user', 'password', 'host', 'port', 'relative', 'path', 'directory', 'file', 'query', 'fragment'], // keys available to query
27   -
28   - aliases = { 'anchor' : 'fragment' }, // aliases for backwards compatability
29   -
30   - parser = {
31   - strict : /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, //less intuitive, more accurate to the specs
32   - loose : /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // more intuitive, fails on relative paths and deviates from specs
33   - },
34   -
35   - isint = /^[0-9]+$/;
36   -
37   - function parseUri( url, strictMode ) {
38   - var str = decodeURI( url ),
39   - res = parser[ strictMode || false ? 'strict' : 'loose' ].exec( str ),
40   - uri = { attr : {}, param : {}, seg : {} },
41   - i = 14;
42   -
43   - while ( i-- ) {
44   - uri.attr[ key[i] ] = res[i] || '';
45   - }
46   -
47   - // build query and fragment parameters
48   - uri.param['query'] = parseString(uri.attr['query']);
49   - uri.param['fragment'] = parseString(uri.attr['fragment']);
50   -
51   - // split path and fragement into segments
52   - uri.seg['path'] = uri.attr.path.replace(/^\/+|\/+$/g,'').split('/');
53   - uri.seg['fragment'] = uri.attr.fragment.replace(/^\/+|\/+$/g,'').split('/');
54   -
55   - // compile a 'base' domain attribute
56   - uri.attr['base'] = uri.attr.host ? (uri.attr.protocol ? uri.attr.protocol+'://'+uri.attr.host : uri.attr.host) + (uri.attr.port ? ':'+uri.attr.port : '') : '';
57   -
58   - return uri;
59   - }
60   -
61   - function getAttrName( elm ) {
62   - var tn = elm.tagName;
63   - if ( typeof tn !== 'undefined' ) return tag2attr[tn.toLowerCase()];
64   - return tn;
65   - }
66   -
67   - function promote(parent, key) {
68   - if (parent[key].length === 0) return parent[key] = {};
69   - var t = {};
70   - for (var i in parent[key]) t[i] = parent[key][i];
71   - parent[key] = t;
72   - return t;
73   - }
74   -
75   - function parse(parts, parent, key, val) {
76   - var part = parts.shift();
77   - if (!part) {
78   - if (isArray(parent[key])) {
79   - parent[key].push(val);
80   - } else if ('object' == typeof parent[key]) {
81   - parent[key] = val;
82   - } else if ('undefined' == typeof parent[key]) {
83   - parent[key] = val;
84   - } else {
85   - parent[key] = [parent[key], val];
86   - }
87   - } else {
88   - var obj = parent[key] = parent[key] || [];
89   - if (']' == part) {
90   - if (isArray(obj)) {
91   - if ('' !== val) obj.push(val);
92   - } else if ('object' == typeof obj) {
93   - obj[keys(obj).length] = val;
94   - } else {
95   - obj = parent[key] = [parent[key], val];
96   - }
97   - } else if (~part.indexOf(']')) {
98   - part = part.substr(0, part.length - 1);
99   - if (!isint.test(part) && isArray(obj)) obj = promote(parent, key);
100   - parse(parts, obj, part, val);
101   - // key
102   - } else {
103   - if (!isint.test(part) && isArray(obj)) obj = promote(parent, key);
104   - parse(parts, obj, part, val);
105   - }
106   - }
107   - }
108   -
109   - function merge(parent, key, val) {
110   - if (~key.indexOf(']')) {
111   - var parts = key.split('[');
112   - parse(parts, parent, 'base', val);
113   - } else {
114   - if (!isint.test(key) && isArray(parent.base)) {
115   - var t = {};
116   - for (var k in parent.base) t[k] = parent.base[k];
117   - parent.base = t;
118   - }
119   - if (key !== '') {
120   - set(parent.base, key, val);
121   - }
122   - }
123   - return parent;
124   - }
125   -
126   - function parseString(str) {
127   - return reduce(String(str).split(/&|;/), function(ret, pair) {
128   - try {
129   - pair = decodeURIComponent(pair.replace(/\+/g, ' '));
130   - } catch(e) {
131   - // ignore
132   - }
133   - var eql = pair.indexOf('='),
134   - brace = lastBraceInKey(pair),
135   - key = pair.substr(0, brace || eql),
136   - val = pair.substr(brace || eql, pair.length);
137   -
138   - val = val.substr(val.indexOf('=') + 1, val.length);
139   -
140   - if (key === '') {
141   - key = pair;
142   - val = '';
143   - }
144   -
145   - return merge(ret, key, val);
146   - }, { base: {} }).base;
147   - }
148   -
149   - function set(obj, key, val) {
150   - var v = obj[key];
151   - if (typeof v === 'undefined') {
152   - obj[key] = val;
153   - } else if (isArray(v)) {
154   - v.push(val);
155   - } else {
156   - obj[key] = [v, val];
157   - }
158   - }
159   -
160   - function lastBraceInKey(str) {
161   - var len = str.length,
162   - brace,
163   - c;
164   - for (var i = 0; i < len; ++i) {
165   - c = str[i];
166   - if (']' == c) brace = false;
167   - if ('[' == c) brace = true;
168   - if ('=' == c && !brace) return i;
169   - }
170   - }
171   -
172   - function reduce(obj, accumulator){
173   - var i = 0,
174   - l = obj.length >> 0,
175   - curr = arguments[2];
176   - while (i < l) {
177   - if (i in obj) curr = accumulator.call(undefined, curr, obj[i], i, obj);
178   - ++i;
179   - }
180   - return curr;
181   - }
182   -
183   - function isArray(vArg) {
184   - return Object.prototype.toString.call(vArg) === "[object Array]";
185   - }
186   -
187   - function keys(obj) {
188   - var key_array = [];
189   - for ( var prop in obj ) {
190   - if ( obj.hasOwnProperty(prop) ) key_array.push(prop);
191   - }
192   - return key_array;
193   - }
194   -
195   - function purl( url, strictMode ) {
196   - if ( arguments.length === 1 && url === true ) {
197   - strictMode = true;
198   - url = undefined;
199   - }
200   - strictMode = strictMode || false;
201   - url = url || window.location.toString();
202   -
203   - return {
204   -
205   - data : parseUri(url, strictMode),
206   -
207   - // get various attributes from the URI
208   - attr : function( attr ) {
209   - attr = aliases[attr] || attr;
210   - return typeof attr !== 'undefined' ? this.data.attr[attr] : this.data.attr;
211   - },
212   -
213   - // return query string parameters
214   - param : function( param ) {
215   - return typeof param !== 'undefined' ? this.data.param.query[param] : this.data.param.query;
216   - },
217   -
218   - // return fragment parameters
219   - fparam : function( param ) {
220   - return typeof param !== 'undefined' ? this.data.param.fragment[param] : this.data.param.fragment;
221   - },
222   -
223   - // return path segments
224   - segment : function( seg ) {
225   - if ( typeof seg === 'undefined' ) {
226   - return this.data.seg.path;
227   - } else {
228   - seg = seg < 0 ? this.data.seg.path.length + seg : seg - 1; // negative segments count from the end
229   - return this.data.seg.path[seg];
230   - }
231   - },
232   -
233   - // return fragment segments
234   - fsegment : function( seg ) {
235   - if ( typeof seg === 'undefined' ) {
236   - return this.data.seg.fragment;
237   - } else {
238   - seg = seg < 0 ? this.data.seg.fragment.length + seg : seg - 1; // negative segments count from the end
239   - return this.data.seg.fragment[seg];
240   - }
241   - }
242   -
243   - };
244   -
245   - }
246   -
247   - purl.jQuery = function($){
248   - if ($ != null) {
249   - $.fn.url = function( strictMode ) {
250   - var url = '';
251   - if ( this.length ) {
252   - url = $(this).attr( getAttrName(this[0]) ) || '';
253   - }
254   - return purl( url, strictMode );
255   - };
256   -
257   - $.url = purl;
258   - }
259   - };
260   -
261   - purl.jQuery(window.jQuery);
262   -
263   - return purl;
264   -
265   -});