Skip to content

Commit 50d5069

Browse files
committed
- added more utilities
1 parent fa17f81 commit 50d5069

File tree

1 file changed

+128
-13
lines changed

1 file changed

+128
-13
lines changed

documentation/api.md

Lines changed: 128 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -133,17 +133,133 @@ The library provides several attributes, methods, and objects to simplify the us
133133

134134
#### Utilities (UTL)
135135

136-
Breinify.UTL = {
137-
loc: {
138-
params: function () { return []; },
139-
hasParam: function() { return false; },
140-
isParam: function() { return false; },
141-
paramIs: function() { return false; },
142-
parsedParam: function() { return null; },
143-
param: function() { return null; },
144-
url: function() { return window.location.href; },
145-
matches: function() { return false; }
146-
},
136+
The utility library provides general functionality, which makes it easy to retrieve values from, e.g., the url or cookies. In addition, it simplifies the retrieval of values from the DOM-tree or the handling of events.
137+
138+
##### Breinify.UTL.loc
139+
140+
* {object} **Breinify.UTL.loc.params(paramListSeparator, paramSeparator, paramSplit, url)**:<br/>
141+
Retrieves an object with representing the parameters specified within the URL.
142+
143+
**Parameters**:
144+
145+
{string|null} **paramListSeparator**: The separator used to separate the list of parameters from the url (default: *?*).
146+
147+
{string|null} **paramSeparator**: The separator used to separate the parameters from each other (default: *&*).
148+
149+
{string|null} **paramSplit**: The separator used to split the name of the parameter and the value (default: *=*).
150+
151+
{string|null} **url**: The url to read the parameters from (default: *Breinify.UTL.loc.url()*).
152+
153+
**Example Usage**:
154+
```javascript
155+
var params = Breinify.UTL.loc.params(null, null, null, 'http://mydomain.com?q=I\'m%20searching');
156+
window.alert('The parameter "q" has the value: ' + params.q);
157+
```
158+
<br/>
159+
160+
* {boolean} **Breinify.UTL.loc.hasParam(param, paramListSeparator, paramSeparator, paramSplit, url)**:<br/>
161+
Validates if the URL contains a specific parameter.
162+
163+
**Parameters**:
164+
165+
{string} **param**: The parameter to look for.
166+
167+
{string|null} **paramListSeparator**: The separator used to separate the list of parameters from the url (default: *?*).
168+
169+
{string|null} **paramSeparator**: The separator used to separate the parameters from each other (default: *&*).
170+
171+
{string|null} **paramSplit**: The separator used to split the name of the parameter and the value (default: *=*).
172+
173+
{string|null} **url**: The url to read the parameters from (default: *Breinify.UTL.loc.url()*).
174+
175+
**Example Usage**:
176+
```javascript
177+
if (Breinify.UTL.loc.hasParam('#', null, null, 'http://mydomain.com#q=I\'m%20searching')) {
178+
window.alert('The parameter "q" was specified.');
179+
}
180+
```
181+
<br/>
182+
183+
* {boolean} **Breinify.UTL.loc.isParam(param, params)**:<br/>
184+
Validates if the parameter is defined within the specified params.
185+
186+
**Parameters**:
187+
188+
{string} **param**: The parameter to look for.
189+
190+
{object} **params**: The object with the parameters to check for the specified *param*.
191+
192+
**Example Usage**:
193+
```javascript
194+
var params = Breinify.UTL.loc.params(null, null, null, 'http://mydomain.com?q=I\'m%20searching');
195+
if (Breinify.UTL.loc.isParam('q', params)) {
196+
window.alert('The parameter "q" was specified.');
197+
}
198+
```
199+
<br/>
200+
201+
* {boolean} **Breinify.UTL.loc.paramIs(expected, param, paramListSeparator, paramSeparator, paramSplit, url)**:<br/>
202+
Validates if the specified parameter is equal (*===*) to the *expected* value.
203+
204+
{string} **expected**: The expected value of the parameter to look for.
205+
206+
{string} **param**: The parameter to look for.
207+
208+
{string|null} **paramListSeparator**: The separator used to separate the list of parameters from the url (default: *?*).
209+
210+
{string|null} **paramSeparator**: The separator used to separate the parameters from each other (default: *&*).
211+
212+
{string|null} **paramSplit**: The separator used to split the name of the parameter and the value (default: *=*).
213+
214+
{string|null} **url**: The url to read the parameters from (default: *Breinify.UTL.loc.url()*).
215+
216+
217+
**Example Usage**:
218+
```javascript
219+
if (Breinify.UTL.loc.paramIs(5, 'q', null, null, null, 'http://mydomain.com?page=5')) {
220+
window.alert('The parameter "q" is a number with the value 5.');
221+
}
222+
```
223+
<br/>
224+
225+
* {boolean} **Breinify.UTL.loc.parsedParam()**:<br/>
226+
Validates if the URL contains a specific parameter.
227+
228+
**Example Usage**:
229+
```javascript
230+
231+
```
232+
<br/>
233+
234+
* {boolean} **Breinify.UTL.loc.param()**:<br/>
235+
Validates if the URL contains a specific parameter.
236+
237+
**Example Usage**:
238+
```javascript
239+
240+
```
241+
<br/>
242+
243+
* {boolean} **Breinify.UTL.loc.url()**:<br/>
244+
Gets the current url.
245+
246+
**Example Usage**:
247+
```javascript
248+
249+
```
250+
<br/>
251+
252+
* {boolean} **Breinify.UTL.loc.matches()**:<br/>
253+
Validates if the current url matches the specified regular expression.
254+
255+
**Example Usage**:
256+
```javascript
257+
258+
```
259+
<br/>
260+
261+
262+
147263
cookie: {
148264
all: function () { return []; },
149265
set: function() {},
@@ -158,5 +274,4 @@ The library provides several attributes, methods, and objects to simplify the us
158274
texts: function() { return []; },
159275
text: function() { return null; },
160276
md5: function () { return null; },
161-
isEmpty: function() { return false; }
162-
};
277+
isEmpty: function() { return false; }

0 commit comments

Comments
 (0)