UNPKG

33.2 kBHTMLView Raw
1<!DOCTYPE html>
2
3<html lang="en">
4<head>
5 <meta charset="utf-8">
6 <meta name="viewport" content="width=device-width">
7 <title>CrossBrowdy API documentation [printable] Source: CrossBase/net/CB_Net.js</title>
8
9 <!--[if lt IE 9]>
10 <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
11 <![endif]-->
12 <link type="text/css" rel="stylesheet" href="styles/sunlight.default.css">
13
14 <link type="text/css" rel="stylesheet" href="styles/site.yeti.css">
15
16</head>
17
18<body style="min-width:800px; overflow-wrap:break-word; word-wrap:break-word; word-break:break-word; line-break:strict; hyphens:none; -webkit-hyphens:none; -moz-hyphens:none;">
19
20<div class="navbar navbar-default navbar-fixed-top ">
21<div class="container">
22 <div class="navbar-header">
23 <a class="navbar-brand" href="index.html">CrossBrowdy API documentation [printable]</a>
24 <button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#topNavigation">
25 <span class="icon-bar"></span>
26 <span class="icon-bar"></span>
27 <span class="icon-bar"></span>
28 </button>
29 </div>
30 <div class="navbar-collapse collapse" id="topNavigation">
31 <ul class="nav navbar-nav">
32
33 <li class="dropdown">
34 <a href="namespaces.list.html" class="dropdown-toggle" data-toggle="dropdown">Namespaces<b class="caret"></b></a>
35 <ul class="dropdown-menu inline">
36 <li><a href="CB_Arrays.html">CB_Arrays</a></li><li><a href="CB_AudioDetector.html">CB_AudioDetector</a></li><li><a href="CB_Client.html">CB_Client</a></li><li><a href="CB_Collisions.html">CB_Collisions</a></li><li><a href="CB_Configuration.html">CB_Configuration</a></li><li><a href="CB_Configuration.CrossBase.html">CB_Configuration.CrossBase</a></li><li><a href="CB_Configuration.CrossBrowdy.html">CB_Configuration.CrossBrowdy</a></li><li><a href="CB_Controllers.html">CB_Controllers</a></li><li><a href="CB_Controllers_Proprietary.html">CB_Controllers_Proprietary</a></li><li><a href="CB_Controllers_Proprietary.WII.html">CB_Controllers_Proprietary.WII</a></li><li><a href="CB_Controllers_Proprietary.WII_U.html">CB_Controllers_Proprietary.WII_U</a></li><li><a href="CB_Device.html">CB_Device</a></li><li><a href="CB_Device.AmbientLight.html">CB_Device.AmbientLight</a></li><li><a href="CB_Device.Battery.html">CB_Device.Battery</a></li><li><a href="CB_Device.Location.html">CB_Device.Location</a></li><li><a href="CB_Device.Motion.html">CB_Device.Motion</a></li><li><a href="CB_Device.Orientation.html">CB_Device.Orientation</a></li><li><a href="CB_Device.Proximity.html">CB_Device.Proximity</a></li><li><a href="CB_Device.Vibration.html">CB_Device.Vibration</a></li><li><a href="CB_Elements.html">CB_Elements</a></li><li><a href="CB_Events.html">CB_Events</a></li><li><a href="CB_Keyboard.html">CB_Keyboard</a></li><li><a href="CB_Keyboard.chars.html">CB_Keyboard.chars</a></li><li><a href="CB_Keyboard.extended.html">CB_Keyboard.extended</a></li><li><a href="CB_Keyboard.keys.html">CB_Keyboard.keys</a></li><li><a href="CB_Modules.html">CB_Modules</a></li><li><a href="CB_Mouse.html">CB_Mouse</a></li><li><a href="CB_Mouse.CursorImage.html">CB_Mouse.CursorImage</a></li><li><a href="CB_Net.html">CB_Net</a></li><li><a href="CB_Net.Fetch.html">CB_Net.Fetch</a></li><li><a href="CB_Net.REST.html">CB_Net.REST</a></li><li><a href="CB_Net.Sockets.html">CB_Net.Sockets</a></li><li><a href="CB_Net.Sockets.SockJS.html">CB_Net.Sockets.SockJS</a></li><li><a href="CB_Net.XHR.html">CB_Net.XHR</a></li><li><a href="CB_Pointer.html">CB_Pointer</a></li><li><a href="CB_Screen.html">CB_Screen</a></li><li><a href="CB_Speaker.html">CB_Speaker</a></li><li><a href="CB_Touch.html">CB_Touch</a></li><li><a href="CB_baseSymbols.html">CB_baseSymbols</a></li>
37 </ul>
38 </li>
39
40 <li class="dropdown">
41 <a href="classes.list.html" class="dropdown-toggle" data-toggle="dropdown">Classes<b class="caret"></b></a>
42 <ul class="dropdown-menu inline">
43 <li><a href="CB_AudioFile.html">CB_AudioFile</a></li><li><a href="CB_AudioFileCache.html">CB_AudioFileCache</a></li><li><a href="CB_AudioFileSprites.html">CB_AudioFileSprites</a></li><li><a href="CB_AudioFileSpritesPool.html">CB_AudioFileSpritesPool</a></li><li><a href="CB_AudioFile_API.AAPI.html">CB_AudioFile_API.AAPI</a></li><li><a href="CB_AudioFile_API.ACMP.html">CB_AudioFile_API.ACMP</a></li><li><a href="CB_AudioFile_API.SM2.html">CB_AudioFile_API.SM2</a></li><li><a href="CB_AudioFile_API.WAAPI.html">CB_AudioFile_API.WAAPI</a></li><li><a href="CB_Canvas.html">CB_Canvas</a></li><li><a href="CB_GraphicSprites.html">CB_GraphicSprites</a></li><li><a href="CB_GraphicSpritesScene.html">CB_GraphicSpritesScene</a></li>
44 </ul>
45 </li>
46
47 <li class="dropdown">
48 <a href="global.html" class="dropdown-toggle" data-toggle="dropdown">Global<b class="caret"></b></a>
49 <ul class="dropdown-menu inline">
50 <li><a href="global.html#CB_BASE_NAME">CB_BASE_NAME</a></li><li><a href="global.html#CB_CREDITS_DEFAULT">CB_CREDITS_DEFAULT</a></li><li><a href="global.html#CB_NAME">CB_NAME</a></li><li><a href="global.html#CB_OPTIONS">CB_OPTIONS</a></li><li><a href="global.html#CB_VERSION">CB_VERSION</a></li><li><a href="global.html#CB_addCredits">CB_addCredits</a></li><li><a href="global.html#CB_baseToBase">CB_baseToBase</a></li><li><a href="global.html#CB_baseToInt">CB_baseToInt</a></li><li><a href="global.html#CB_br2nl">CB_br2nl</a></li><li><a href="global.html#CB_brToNl">CB_brToNl</a></li><li><a href="global.html#CB_combineArraysOrObjects">CB_combineArraysOrObjects</a></li><li><a href="global.html#CB_combineAutomatically">CB_combineAutomatically</a></li><li><a href="global.html#CB_combineJSON">CB_combineJSON</a></li><li><a href="global.html#CB_combineURIParameters">CB_combineURIParameters</a></li><li><a href="global.html#CB_combineURLParameters">CB_combineURLParameters</a></li><li><a href="global.html#CB_console">CB_console</a></li><li><a href="global.html#CB_copyObject">CB_copyObject</a></li><li><a href="global.html#CB_countDecimalDigits">CB_countDecimalDigits</a></li><li><a href="global.html#CB_countDecimalPart">CB_countDecimalPart</a></li><li><a href="global.html#CB_countDecimals">CB_countDecimals</a></li><li><a href="global.html#CB_countIntegerDigits">CB_countIntegerDigits</a></li><li><a href="global.html#CB_countIntegerPart">CB_countIntegerPart</a></li><li><a href="global.html#CB_credits">CB_credits</a></li><li><a href="global.html#CB_forEach">CB_forEach</a></li><li><a href="global.html#CB_forceString">CB_forceString</a></li><li><a href="global.html#CB_getBase64StringObject">CB_getBase64StringObject</a></li><li><a href="global.html#CB_getCookie">CB_getCookie</a></li><li><a href="global.html#CB_getDatum">CB_getDatum</a></li><li><a href="global.html#CB_getJSONPropertyValue">CB_getJSONPropertyValue</a></li><li><a href="global.html#CB_getLZStringObject">CB_getLZStringObject</a></li><li><a href="global.html#CB_getValueIndex">CB_getValueIndex</a></li><li><a href="global.html#CB_getValuePath">CB_getValuePath</a></li><li><a href="global.html#CB_includeJSFile">CB_includeJSFile</a></li><li><a href="global.html#CB_indexOf">CB_indexOf</a></li><li><a href="global.html#CB_init">CB_init</a></li><li><a href="global.html#CB_intToBase">CB_intToBase</a></li><li><a href="global.html#CB_isArray">CB_isArray</a></li><li><a href="global.html#CB_isEmail">CB_isEmail</a></li><li><a href="global.html#CB_isFileLocal">CB_isFileLocal</a></li><li><a href="global.html#CB_isString">CB_isString</a></li><li><a href="global.html#CB_lastIndexOf">CB_lastIndexOf</a></li><li><a href="global.html#CB_ltrim">CB_ltrim</a></li><li><a href="global.html#CB_nl2br">CB_nl2br</a></li><li><a href="global.html#CB_nlToBr">CB_nlToBr</a></li><li><a href="global.html#CB_numberFormat">CB_numberFormat</a></li><li><a href="global.html#CB_numberOfDecimalDigits">CB_numberOfDecimalDigits</a></li><li><a href="global.html#CB_numberOfDecimals">CB_numberOfDecimals</a></li><li><a href="global.html#CB_numberOfIntegerDigits">CB_numberOfIntegerDigits</a></li><li><a href="global.html#CB_parseJSON">CB_parseJSON</a></li><li><a href="global.html#CB_parseString">CB_parseString</a></li><li><a href="global.html#CB_regularExpressionString">CB_regularExpressionString</a></li><li><a href="global.html#CB_renderString">CB_renderString</a></li><li><a href="global.html#CB_replaceAll">CB_replaceAll</a></li><li><a href="global.html#CB_rtrim">CB_rtrim</a></li><li><a href="global.html#CB_scriptPath">CB_scriptPath</a></li><li><a href="global.html#CB_scriptPathCalculate">CB_scriptPathCalculate</a></li><li><a href="global.html#CB_setCookie">CB_setCookie</a></li><li><a href="global.html#CB_setDatum">CB_setDatum</a></li><li><a href="global.html#CB_sizeOf">CB_sizeOf</a></li><li><a href="global.html#CB_sizeof">CB_sizeof</a></li><li><a href="global.html#CB_stringifyJSON">CB_stringifyJSON</a></li><li><a href="global.html#CB_symmetricCall">CB_symmetricCall</a></li><li><a href="global.html#CB_symmetricCallClear">CB_symmetricCallClear</a></li><li><a href="global.html#CB_this">CB_this</a></li><li><a href="global.html#CB_trim">CB_trim</a></li>
51 </ul>
52 </li>
53
54 </ul>
55
56 <div class="col-sm-3 col-md-3">
57 <form class="navbar-form" role="search">
58 <div class="input-group">
59 <input type="text" class="form-control" placeholder="Search" name="q" id="search-input">
60 <div class="input-group-btn">
61 <button class="btn btn-default" id="search-submit"><i class="glyphicon glyphicon-search"></i></button>
62 </div>
63 </div>
64 </form>
65 </div>
66
67 </div>
68
69</div>
70</div>
71
72
73<div class="container" id="toc-content" style="width:100%;">
74<div class="row" style="width:100%;">
75
76
77 <div class="col-md-12">
78
79 <div id="main">
80
81
82 <h1 class="page-title">Source: CrossBase/net/CB_Net.js</h1>
83
84<section>
85 <article>
86 <pre
87 class="sunlight-highlight-javascript linenums">/**
88 * @file Management for things related with the net. Contains the {@link CB_Net} static class.
89 * @author Joan Alba Maldonado &lt;workindalian@gmail.com>
90 * @license Creative Commons Attribution 4.0 International. See more at {@link https://crossbrowdy.com/about#what_is_the_crossbrowdy_copyright_and_license}.
91 */
92
93
94/**
95 * Static class to manage things related to the net. It will return itself if it is tried to be instantiated.
96 * @namespace CB_Net
97 */
98if (typeof(CB_Net) === "undefined") { var CB_Net = function() { return CB_Net; }; }
99{
100 CB_Net.initialized = false; //It will tells whether the object has been initialized or not.
101
102
103 //Initializes all values:
104 CB_Net.init = function()
105 {
106 if (CB_Net.initialized) { return CB_Net; }
107
108 //The object has been initialized:
109 CB_Net.initialized = true;
110
111 //TODO.
112
113 return CB_Net;
114 }
115
116
117 /**
118 * Alias for {@link CB_Net.URIValueEncode}.
119 * @function CB_Net.URLValueEncode
120 * @see {@link CB_Net.URIValueEncode}
121 */
122 /**
123 * Encodes a given URI value. Uses the native [encodeURIComponent]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent} function internally if available or fallbacks to the native [escape]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape} function otherwise.
124 * @function
125 * @param {string|number} value - The value that we want to encode. Normally, it should be either a string or a number.
126 * @returns {string}
127 * @todo Think about using another thing since [escape]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape} maybe is not a good fallback. Probably a polyfill to simulate the [encodeURIComponent]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent} function.
128 */
129 CB_Net.URIValueEncode = CB_Net.URLValueEncode = function(value)
130 {
131 if (typeof(encodeURIComponent) !== "undefined") { return encodeURIComponent(value); }
132 else { return escape(value); } //TODO: think about using another thing since escape maybe is not a good fallback. Probably a polyfill to simulate the encodeURIComponent function.
133 }
134
135
136 /**
137 * Alias for {@link CB_Net.URIValueDecode}.
138 * @function CB_Net.URLValueDecode
139 * @see {@link CB_Net.URIValueDecode}
140 */
141 /**
142 * Decodes a given URI value. Uses the native [decodeURIComponent]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent} function internally if available or fallbacks to the native [unescape]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape} function otherwise.
143 * @function
144 * @param {string|number} value - The value that we want to decode. Normally, it should be either a string or a number.
145 * @returns {string}
146 * @todo Think about using another thing since [unescape]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape} maybe is not a good fallback. Probably a polyfill to simulate the [decodeURIComponent]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent} function.
147 */
148 CB_Net.URIValueDecode = CB_Net.URLValueDecode = function(value)
149 {
150 if (typeof(decodeURIComponent) !== "undefined") { return decodeURIComponent(value); }
151 else { return unescape(value); } //TODO: think about using another thing since unescape maybe is not a good fallback. Probably a polyfill to simulate the decodeURIComponent function.
152 }
153
154
155 /**
156 * Alias for {@link CB_Net.URIEncode}.
157 * @function CB_Net.URLEncode
158 * @see {@link CB_Net.URIEncode}
159 */
160 /**
161 * Encodes a given URI. Uses the native [encodeURI]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI} function internally if available or fallbacks to the native [escape]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape} function otherwise.
162 * @function
163 * @param {string|number} URI - The URI that we want to encode. Normally, it should be either a string or a number.
164 * @returns {string}
165 * @todo Think about using another thing since [escape]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/escape} maybe is not a good fallback. Probably a polyfill to simulate the [encodeURI]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURI} function.
166 */
167 CB_Net.URIEncode = CB_Net.URLEncode = function(URI)
168 {
169 if (typeof(encodeURI) !== "undefined") { return encodeURI(URI); }
170 else { return escape(URI); } //TODO: think about using another thing since escape maybe is not a good fallback. Probably a polyfill to simulate the encodeURI function.
171 }
172
173
174 /**
175 * Alias for {@link CB_Net.URIDecode}.
176 * @function CB_Net.URLDecode
177 * @see {@link CB_Net.URIDecode}
178 */
179 /**
180 * Encodes a given URI. Uses the native [decodeURI]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI} function internally if available or fallbacks to the native [unescape]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape} function otherwise.
181 * @function
182 * @param {string|number} URI - The URI that we want to decode. Normally, it should be either a string or a number.
183 * @returns {string}
184 * @todo Think about using another thing since [unescape]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/unescape} maybe is not a good fallback. Probably a polyfill to simulate the [decodeURI]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURI} function.
185 */
186 CB_Net.URIDecode = CB_Net.URLDecode = function(URI)
187 {
188 if (typeof(decodeURI) !== "undefined") { return decodeURI(URI); }
189 else { return unescape(URI); } //TODO: think about using another thing since unescape maybe is not a good fallback. Probably a polyfill to simulate the decodeURI function.
190 }
191
192
193 /**
194 * Gets all the "GET" (query) parameters (names and their values) from a given URI or from the current URL.
195 &lt;br />
196 For example, if the URI provided is "http://whatever.com/index.html?parameter1=value1&amp;amp;parameter2=value2#hash_parameter1=hash_value1&amp;amp;hash_parameter2=hash_value2", it will return "parameter1=value1&amp;amp;parameter2=value2" (using the default options).
197 * @function
198 * @param {string} [URI=[window.location]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/location}.href] - The URI that we want to work with. If not provided, it will try to use the current URL (by using [window.location]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/location}.href).
199 * @param {array} [exclude] - A numeric array containing the name of the parameters that we want to exclude in the returned string. It will exclude them even if they are contained in the given "includeOnly" parameter (if any).
200 * @param {array} [includeOnly] - A numeric array containing the name of the parameters that we want to include in the returned string. If provided, it will only include these ones to the returned string (unless they are included in the "exclude" parameter).
201 * @param {boolean} [includeIfNotExists=false] - If it is set to true and an array is given as the "includeOnly" parameter, it will add the parameters in the "includeOnly" array (with empty values) in the returned string even when they did not exist in the original URI provided.
202 * @param {boolean} [trim=true] - Defines whether we want to trim the spaces around the values or not.
203 * @param {string} [firstDelimiter='?'] - The string that indicates where the parameters start. If it is not provided, it will be "?" as default. If not provided and "lastDelimiter" is not provided either, it will be "?" and "lastDelimiter" will be "#".
204 * @param {string} [lastDelimiter=undefined|'#'] - The string that indicates where the parameters end. If not provided and "firstDelimiter" is provided, it will stop at the end of the given URI. If it is not provided and "firstDelimiter" is not provided either, "firstDelimiter" will be "?" and "lastDelimiter" will be "#".
205 * @param {string} [concatenator='&amp;'] - The string that joints the different parameters.
206 * @param {string} [nameValueSeparator='='] - The string that is the separator for the parameters and their values.
207 * @returns {string} An empty string will be returned if no parameters can be found.
208 */
209 CB_Net.getURIParameters = function(URI, exclude, includeOnly, includeIfNotExists, trim, firstDelimiter, lastDelimiter, concatenator, nameValueSeparator)
210 {
211 concatenator = CB_trim(concatenator);
212 if (concatenator === "") { concatenator = "&amp;"; }
213
214 nameValueSeparator = CB_trim(nameValueSeparator);
215 if (nameValueSeparator === "") { nameValueSeparator = "="; }
216
217 firstDelimiter = CB_trim(firstDelimiter);
218 lastDelimiter = CB_trim(lastDelimiter);
219 if (firstDelimiter === "")
220 {
221 firstDelimiter = "?";
222 if (lastDelimiter === "") { lastDelimiter = "#"; }
223 }
224
225 URI = CB_trim(URI);
226 if (URI === "") { URI = window.location.href; }
227 if (URI.indexOf(firstDelimiter) !== -1) { URI = URI.substring(URI.indexOf(firstDelimiter) + firstDelimiter.length); }
228 else { return ""; }
229 if (lastDelimiter !== "" &amp;&amp; URI.indexOf(lastDelimiter) !== -1) { URI = URI.substring(0, URI.indexOf(lastDelimiter)); }
230 URI = CB_trim(URI);
231
232 var filteredURI = URI;
233
234
235 if (typeof(trim) === "undefined" || trim === null) { trim = true; }
236
237
238 //If set, only includes the desired ones:
239 if (CB_isArray(includeOnly) &amp;&amp; includeOnly.length > 0)
240 {
241 filteredURI = "";
242 URI = firstDelimiter + URI;
243 for (var x = 0, includeOnlyLength = includeOnly.length; x &lt; includeOnlyLength; x++)
244 {
245 if (includeIfNotExists || URI.toUpperCase().indexOf(includeOnly[x].toUpperCase() + nameValueSeparator) !== -1)
246 {
247 filteredURI += includeOnly[x] + nameValueSeparator + CB_Net.getParameter(includeOnly[x], trim, URI, firstDelimiter, lastDelimiter, concatenator, nameValueSeparator) + concatenator;
248 }
249 }
250 filteredURI = CB_rtrim(filteredURI, [concatenator]);
251 }
252
253 //If set, excludes the desired ones and/or trims values if desired:
254 var excludePending = false;
255 if (CB_isArray(exclude) &amp;&amp; exclude.length > 0)
256 {
257 excludePending = true;
258 }
259 if (trim || excludePending)
260 {
261 var parametersArray = filteredURI.split(concatenator);
262 var parameterArray;
263 filteredURI = "";
264 for (x = 0, parametersArrayLength = parametersArray.length; x &lt; parametersArrayLength; x++)
265 {
266 parameterArray = parametersArray[x].split(nameValueSeparator);
267 if (trim || excludePending &amp;&amp; CB_indexOf(exclude, parameterArray[0]) === -1)
268 {
269 if (typeof(parameterArray[1]) !== "undefined" &amp;&amp; parameterArray[1] !== null)
270 {
271 filteredURI += parameterArray[0] + nameValueSeparator + (trim ? CB_trim(parameterArray[1]) : parameterArray[1]) + concatenator;
272 }
273 else
274 {
275 filteredURI += parameterArray[0] + concatenator;
276 }
277 }
278 }
279 filteredURI = CB_rtrim(filteredURI, [concatenator]);
280 }
281
282 filteredURI = CB_trim(filteredURI, [concatenator]);
283
284
285 return filteredURI;
286 }
287
288
289 /**
290 * Gets all the hash parameters (names and their values) from a given URI or from the current URL.
291 &lt;br />
292 For example, if the URI provided is "http://whatever.com/index.html?parameter1=value1&amp;amp;parameter2=value2#hash_parameter1=hash_value1&amp;amp;hash_parameter2=hash_value2", it will return
293 "hash_parameter1=hash_value1&amp;amp;hash_parameter2=hash_value2" (using the default options).
294 * @function
295 * @param {string} [URI=[window.location]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/location}.href] - The URI that we want to work with. If not provided, it will try to use the current URL (by using [window.location]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/location}.href).
296 * @param {array} [exclude] - A numeric array containing the name of the parameters that we want to exclude in the returned string. It will exclude them even if they are contained in the given "includeOnly" parameter (if any).
297 * @param {array} [includeOnly] - A numeric array containing the name of the parameters that we want to include in the returned string. If provided, it will only include these ones to the returned string (unless they are included in the "exclude" parameter).
298 * @param {boolean} [includeIfNotExists=false] - If it is set to true and an array is given as the "includeOnly" parameter, it will add the parameters in the "includeOnly" array (with empty values) in the returned string even when they did not exist in the original URI provided.
299 * @param {boolean} [trim=true] - It will use this option when it calls the {@link CB_Net.getURIParameters} function internally.
300 * @returns {string} An empty string will be returned if no parameters can be found.
301 */
302 CB_Net.getHashParameters = function(URI, exclude, includeOnly, includeIfNotExists, trim)
303 {
304 return CB_Net.getURIParameters(URI, exclude, includeOnly, includeIfNotExists, trim, "#");
305 }
306
307
308 /**
309 * Gets the value of a specific URI parameter (query or hash), respecting GET/URL rules by default, from the current URL or a desired one (with the given delimiters).
310 &lt;br />
311 For example, if the URI provided is "http://whatever.com/index.html?parameter1=value1&amp;amp;parameter2=value2#hash_parameter1=hash_value1&amp;amp;hash_parameter2=hash_value2" and the index given is "parameter1", it will return "value1" (using the default options).
312 * @function
313 * @param {string} index - The name of the parameter whose value we want to get.
314 * @param {boolean} [trim=true] - It will trim the value (using {@link CB_trim} internally) before returning it.
315 * @param {string} [URI=[window.location]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/location}.href] - The URI that we want to work with. If not provided, it will try to use the current URL (by using [window.location]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/location}.href).
316 * @param {string} [firstDelimiter='?'] - The string that indicates where the parameters start. If it is not provided, it will be "?" as default. If not provided and "lastDelimiter" is not provided either, it will be "?" and "lastDelimiter" will be "#".
317 * @param {string} [lastDelimiter=undefined|'#'] - The string that indicates where the parameters end. If not provided and "firstDelimiter" is provided, it will stop at the end of the given URI. If it is not provided and "firstDelimiter" is not provided either, "firstDelimiter" will be "?" and "lastDelimiter" will be "#".
318 * @param {string} [concatenator='&amp;'] - The string that joints the different parameters.
319 * @param {string} [nameValueSeparator='='] - The string that is the separator for the parameters and their values.
320 * @returns {string} An empty string will be returned if the value of the given parameter cannot be found.
321 */
322 CB_Net.getParameter = function(index, trim, URI, firstDelimiter, lastDelimiter, concatenator, nameValueSeparator)
323 {
324 if (typeof(trim) === "undefined" || trim === null) { trim = true; }
325
326 index = CB_trim(index).toUpperCase();
327 if (index === "") { return ""; }
328
329 concatenator = CB_trim(concatenator);
330 if (concatenator === "") { concatenator = "&amp;"; }
331
332 nameValueSeparator = CB_trim(nameValueSeparator);
333 if (nameValueSeparator === "") { nameValueSeparator = "="; }
334
335 firstDelimiter = CB_trim(firstDelimiter);
336 lastDelimiter = CB_trim(lastDelimiter);
337 if (firstDelimiter === "")
338 {
339 firstDelimiter = "?";
340 if (lastDelimiter === "") { lastDelimiter = "#"; }
341 }
342
343 URI = CB_trim(URI);
344 if (URI === "") { URI = window.location.href; }
345 if (URI.indexOf(firstDelimiter) !== -1) { URI = URI.substring(URI.indexOf(firstDelimiter) + firstDelimiter.length); }
346 else { return ""; }
347 if (lastDelimiter !== "" &amp;&amp; URI.indexOf(lastDelimiter) !== -1) { URI = URI.substring(0, URI.indexOf(lastDelimiter)); }
348 URI = CB_trim(URI);
349 if (URI === "") { return ""; }
350
351 var value = "";
352 var URIUpperCase = URI.toUpperCase();
353 var indexOfFound = URIUpperCase.indexOf(index + nameValueSeparator);
354 if (indexOfFound !== -1)
355 {
356 URI = URI.substring(indexOfFound + index.length + nameValueSeparator.length);
357 if (URI.indexOf(concatenator) !== -1)
358 {
359 URI = URI.substring(0, URI.indexOf(concatenator));
360 }
361 value = URI;
362 }
363
364 if (trim) { value = CB_trim(value); }
365
366 return CB_Net.URIValueDecode(value);
367 }
368
369
370 /**
371 * Gets the value of a specific URI "GET" parameter (query) from the current URL or a desired URI.
372 &lt;br />
373 For example, if the URI provided is "http://whatever.com/index.html?parameter1=value1&amp;amp;parameter2=value2#hash_parameter1=hash_value1&amp;amp;hash_parameter2=hash_value2" and the index given is "parameter1", it will return "value1" (using the default options).
374 * @function
375 * @param {string} index - The name of the parameter whose value we want to get.
376 * @param {boolean} [trim=true] - It will trim the value (using {@link CB_Net.getParameter} internally) before returning it.
377 * @param {string} [URI=[window.location]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/location}.href] - The URI that we want to work with. If not provided, it will try to use the current URL (by using [window.location]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/location}.href).
378 * @returns {string} An empty string will be returned if the value of the given parameter cannot be found.
379 */
380 CB_Net.getURIValue = function(index, trim, URI)
381 {
382 return CB_Net.getParameter(index, trim, URI, "?", "#");
383 }
384
385
386 /**
387 * Gets the value of a specific hash (string after "#") parameter from the current URL or a desired URI.
388 &lt;br />
389 For example, if the URI provided is "http://whatever.com/index.html?parameter1=value1&amp;amp;parameter2=value2#hash_parameter1=hash_value1&amp;amp;hash_parameter2=hash_value2" and the index given is "hash_parameter1",
390 it will return "hash_value1" (using the default options).
391 * @function
392 * @param {string} index - The name of the parameter whose value we want to get.
393 * @param {boolean} [trim=true] - It will trim the value (using {@link CB_Net.getParameter} internally) before returning it.
394 * @param {string} [URI=[window.location]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/location}.href] - The URI that we want to work with. If not provided, it will try to use the current URL (by using [window.location]{@link https://developer.mozilla.org/en-US/docs/Web/API/Window/location}.href).
395 * @returns {string} An empty string will be returned if the value of the given parameter cannot be found.
396 */
397 CB_Net.getHashValue = function(index, trim, URI)
398 {
399 return CB_Net.getParameter(index, trim, URI, "#");
400 }
401
402
403 /**
404 * Alias for {@link CB_Net.combineURIParameters}.
405 * @function CB_Net.combineURLParameters
406 * @see {@link CB_Net.combineURIParameters}
407 */
408 /**
409 * Alias for {@link CB_combineURIParameters}.
410 * @function CB_Net.combineURIParameters
411 * @see {@link CB_combineURIParameters}
412 */
413 CB_Net.combineURIParameters = CB_Net.combineURLParameters = function(parametersA, parametersB)
414 {
415 return CB_combineURIParameters(parametersA, parametersB);
416 };
417}</pre>
418 </article>
419</section>
420
421
422
423
424
425 </div>
426 </div>
427
428 <div class="clearfix"></div>
429
430
431
432</div>
433</div>
434
435
436 <div class="modal fade" id="searchResults">
437 <div class="modal-dialog">
438 <div class="modal-content">
439 <div class="modal-header">
440 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
441 <h4 class="modal-title">Search results</h4>
442 </div>
443 <div class="modal-body"></div>
444 <div class="modal-footer">
445 <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
446 </div>
447 </div><!-- /.modal-content -->
448 </div><!-- /.modal-dialog -->
449 </div>
450
451
452<footer>
453
454
455 <span class="copyright">
456 <span style="color:#000000">© <address style="display:inline; font-style:normal;"><a href="https://crossbrowdy.com/" target="_blank">CrossBrowdy</a> API documentation</address> by <a href="https://joanalbamaldonado.com/" target="_blank">Joan Alba Maldonado</a> - <a href="https://creativecommons.org/licenses/by/4.0/" target="_blank">Creative Commons Attribution 4.0 International</a><br />DocStrap Copyright © 2012-2015 The contributors to the JSDoc3 and DocStrap projects.</span>
457 </span>
458
459<span class="jsdoc-message">
460 Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.2</a>
461
462 on Wed Mar 22nd 2023
463
464 using the <a href="https://github.com/docstrap/docstrap">DocStrap template</a>.
465</span>
466</footer>
467
468<script src="scripts/docstrap.lib.js"></script>
469<script src="scripts/toc.js"></script>
470
471 <script type="text/javascript" src="scripts/fulltext-search-ui.js"></script>
472
473
474<script>
475$( function () {
476 $( "[id*='$']" ).each( function () {
477 var $this = $( this );
478
479 $this.attr( "id", $this.attr( "id" ).replace( "$", "__" ) );
480 } );
481
482 $( ".tutorial-section pre, .readme-section pre, pre.prettyprint.source" ).each( function () {
483 var $this = $( this );
484
485 var example = $this.find( "code" );
486 exampleText = example.html();
487 var lang = /{@lang (.*?)}/.exec( exampleText );
488 if ( lang && lang[1] ) {
489 exampleText = exampleText.replace( lang[0], "" );
490 example.html( exampleText );
491 lang = lang[1];
492 } else {
493 var langClassMatch = example.parent()[0].className.match(/lang\-(\S+)/);
494 lang = langClassMatch ? langClassMatch[1] : "javascript";
495 }
496
497 if ( lang ) {
498
499 $this
500 .addClass( "sunlight-highlight-" + lang )
501 .addClass( "linenums" )
502 .html( example.html() );
503
504 }
505 } );
506
507 Sunlight.highlightAll( {
508 lineNumbers : true,
509 showMenu : true,
510 enableDoclinks : true
511 } );
512
513 $.catchAnchorLinks( {
514 navbarOffset: 10
515 } );
516 $( "#toc" ).toc( {
517 anchorName : function ( i, heading, prefix ) {
518 return $( heading ).attr( "id" ) || ( prefix + i );
519 },
520 selectors : "#toc-content h1,#toc-content h2,#toc-content h3,#toc-content h4",
521 showAndHide : false,
522 smoothScrolling: true
523 } );
524
525 $( "#main span[id^='toc']" ).addClass( "toc-shim" );
526 $( '.dropdown-toggle' ).dropdown();
527
528 $( "table" ).each( function () {
529 var $this = $( this );
530 $this.addClass('table');
531 } );
532
533} );
534</script>
535
536
537
538<!--Navigation and Symbol Display-->
539
540
541<!--Google Analytics-->
542
543
544
545 <script type="text/javascript">
546 $(document).ready(function() {
547 SearcherDisplay.init();
548 });
549 </script>
550
551
552</body>
553</html>