| author | ymh <ymh.work@gmail.com> |
| Tue, 19 Jun 2018 00:03:22 +0200 | |
| changeset 1428 | 0f6497de52f6 |
| parent 229 | 74c9ddc3640b |
| permissions | -rw-r--r-- |
|
202
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
1 |
// JQuery URL Parser plugin - https://github.com/allmarkedup/jQuery-URL-Parser |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
2 |
// Written by Mark Perkins, mark@allmarkedup.com |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
3 |
// License: http://unlicense.org/ (i.e. do what you want with it!) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
4 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
5 |
;(function($, undefined) { |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
6 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
7 |
var tag2attr = { |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
8 |
a : 'href', |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
9 |
img : 'src', |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
10 |
form : 'action', |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
11 |
base : 'href', |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
12 |
script : 'src', |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
13 |
iframe : 'src', |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
14 |
link : 'href' |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
15 |
}, |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
16 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
17 |
key = ["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","fragment"], // keys available to query |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
18 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
19 |
aliases = { "anchor" : "fragment" }, // aliases for backwards compatability |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
20 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
21 |
parser = { |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
22 |
strict : /^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/, //less intuitive, more accurate to the specs |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
23 |
loose : /^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*):?([^:@]*))?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/ // more intuitive, fails on relative paths and deviates from specs |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
24 |
}, |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
25 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
26 |
querystring_parser = /(?:^|&|;)([^&=;]*)=?([^&;]*)/g, // supports both ampersand and semicolon-delimted query string key/value pairs |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
27 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
28 |
fragment_parser = /(?:^|&|;)([^&=;]*)=?([^&;]*)/g; // supports both ampersand and semicolon-delimted fragment key/value pairs |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
29 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
30 |
function parseUri( url, strictMode ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
31 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
32 |
var str = decodeURI( url ), |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
33 |
res = parser[ strictMode || false ? "strict" : "loose" ].exec( str ), |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
34 |
uri = { attr : {}, param : {}, seg : {} }, |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
35 |
i = 14; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
36 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
37 |
while ( i-- ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
38 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
39 |
uri.attr[ key[i] ] = res[i] || ""; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
40 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
41 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
42 |
// build query and fragment parameters |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
43 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
44 |
uri.param['query'] = {}; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
45 |
uri.param['fragment'] = {}; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
46 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
47 |
uri.attr['query'].replace( querystring_parser, function ( $0, $1, $2 ){ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
48 |
if ($1) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
49 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
50 |
uri.param['query'][$1] = $2; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
51 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
52 |
}); |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
53 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
54 |
uri.attr['fragment'].replace( fragment_parser, function ( $0, $1, $2 ){ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
55 |
if ($1) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
56 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
57 |
uri.param['fragment'][$1] = $2; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
58 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
59 |
}); |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
60 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
61 |
// split path and fragement into segments |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
62 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
63 |
uri.seg['path'] = uri.attr.path.replace(/^\/+|\/+$/g,'').split('/'); |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
64 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
65 |
uri.seg['fragment'] = uri.attr.fragment.replace(/^\/+|\/+$/g,'').split('/'); |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
66 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
67 |
// compile a 'base' domain attribute |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
68 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
69 |
uri.attr['base'] = uri.attr.host ? uri.attr.protocol+"://"+uri.attr.host + (uri.attr.port ? ":"+uri.attr.port : '') : ''; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
70 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
71 |
return uri; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
72 |
}; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
73 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
74 |
function getAttrName( elm ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
75 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
76 |
var tn = elm.tagName; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
77 |
if ( tn !== undefined ) return tag2attr[tn.toLowerCase()]; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
78 |
return tn; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
79 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
80 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
81 |
$.fn.url = function( strictMode ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
82 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
83 |
var url = ''; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
84 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
85 |
if ( this.length ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
86 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
87 |
url = $(this).attr( getAttrName(this[0]) ) || ''; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
88 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
89 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
90 |
return $.url({ url : url, strict : strictMode }); |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
91 |
}; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
92 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
93 |
$.url = function( opts ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
94 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
95 |
var url = '', |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
96 |
strict = false; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
97 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
98 |
if ( typeof opts === 'string' ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
99 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
100 |
url = opts; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
101 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
102 |
else |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
103 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
104 |
opts = opts || {}; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
105 |
strict = opts.strict || strict; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
106 |
url = opts.url === undefined ? window.location.toString() : opts.url; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
107 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
108 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
109 |
return { |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
110 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
111 |
data : parseUri(url, strict), |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
112 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
113 |
// get various attributes from the URI |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
114 |
attr : function( attr ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
115 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
116 |
attr = aliases[attr] || attr; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
117 |
return attr !== undefined ? this.data.attr[attr] : this.data.attr; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
118 |
}, |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
119 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
120 |
// return query string parameters |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
121 |
param : function( param ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
122 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
123 |
return param !== undefined ? this.data.param.query[param] : this.data.param.query; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
124 |
}, |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
125 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
126 |
// return fragment parameters |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
127 |
fparam : function( param ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
128 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
129 |
return param !== undefined ? this.data.param.fragment[param] : this.data.param.fragment; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
130 |
}, |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
131 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
132 |
// return path segments |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
133 |
segment : function( seg ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
134 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
135 |
if ( seg === undefined ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
136 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
137 |
return this.data.seg.path; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
138 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
139 |
else |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
140 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
141 |
seg = seg < 0 ? this.data.seg.path.length + seg : seg - 1; // negative segments count from the end |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
142 |
return this.data.seg.path[seg]; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
143 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
144 |
}, |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
145 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
146 |
// return fragment segments |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
147 |
fsegment : function( seg ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
148 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
149 |
if ( seg === undefined ) |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
150 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
151 |
return this.data.seg.fragment; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
152 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
153 |
else |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
154 |
{ |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
155 |
seg = seg < 0 ? this.data.seg.fragment.length + seg : seg - 1; // negative segments count from the end |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
156 |
return this.data.seg.fragment[seg]; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
157 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
158 |
} |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
159 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
160 |
}; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
161 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
162 |
}; |
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
163 |
|
|
2bf0fd3432bf
put more than one content for the polemical timeline
Yves-Marie Haussonne <1218002+ymph@users.noreply.github.com>
parents:
diff
changeset
|
164 |
})(jQuery); |