Skip to content

Commit fd018f6

Browse files
committed
- added toc
1 parent 3efd023 commit fd018f6

File tree

3 files changed

+171
-19
lines changed

3 files changed

+171
-19
lines changed

dist/breinify-api.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12120,7 +12120,7 @@ this._hasher;f=g.finalize(f);g.reset();return g.finalize(this._oKey.clone().conc
1212012120
cookie: {
1212112121

1212212122
/**
12123-
* Gets all the cookies currently defined and accessible or an empty array if there aren't any.
12123+
* Gets all the cookies currently defined and accessible or an empty object if there aren't any.
1212412124
* @returns {object} the found cookies
1212512125
*/
1212612126
all: function () {

documentation/api.md

Lines changed: 169 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ Breinify's DigitalDNA API puts dynamic behavior-based, people-driven data right
1010

1111
The library provides several attributes, methods, and objects to simplify the usage of the Breinify API. Besides methods to actually send or retrieve data, it also includes general information (e.g., about the version and used configuration), as well as utilities. Thus, the following documentation is organized in three sections: *General Information*, *API*, and *Utilities (UTL)*.
1212

13+
This documentation is organized as following:
14+
15+
* [General Attributes](#general-attributes)
16+
* Breinify.version
17+
* Breinify.config()
18+
* Breinify.setConfig(config)
19+
* [API](#api)
20+
* Breinify.activity(user, type, category, description, sign, onReady)
21+
* Breinify.lookup(user, dimensions, sign, onLookUp)
22+
* [Utilities (UTL)]()
23+
* [Breinify.UTL (general functions)]()
24+
* [Breinify.UTL.events]()
25+
* [Breinify.UTL.loc]()
26+
* [Breinify.UTL.cookie]()
27+
1328
#### General Attributes
1429

1530
* {string} **Breinify.version**:<br/>
@@ -106,7 +121,7 @@ The library provides several attributes, methods, and objects to simplify the us
106121
<br/>
107122

108123
* **Breinify.lookup(user, dimensions, sign, onLookUp)**:<br/>
109-
Retrieves a lookup result from the engine.
124+
Retrieves a lookup result from the engine. The function needs a valid API-key to be configured to succeed.
110125

111126
**Parameters**:
112127

@@ -135,8 +150,57 @@ The library provides several attributes, methods, and objects to simplify the us
135150

136151
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.
137152

153+
##### Breinify.UTL (general functions)
154+
155+
156+
157+
texts: function() { return []; },
158+
text: function() { return null; },
159+
md5: function () { return null; },
160+
isEmpty: function() { return false; }
161+
162+
##### Breinify.UTL.events
163+
164+
For simplicity the library provides the possibility to handle/react to specific events triggered by the DOM-tree. Currently, two events are supported, i.e., *click* and *pageloaded*.
165+
166+
* **Breinify.UTL.events.click(selector, func, onlyOnce)**:<br/>
167+
Gets all the cookies currently defined and accessible.
168+
169+
**Parameters**:
170+
171+
{string} **selector**: The CSS-selector to specify the element(s) to listen for click-events (see [jQuery Selectors](https://api.jquery.com/category/selectors/) for a detailled overview of available selectors).
172+
173+
{function} **func**: The function to execute when the event is captured. The function retrieves an *event* object which can be used to control the further processing. In addition, the handling function also has access to the DOM-element that the handler was bound to using *this*. For further details, have a look at [jQuery Event Handling](https://learn.jquery.com/events/inside-event-handling-function/).
174+
175+
{boolean} **onlyOnce**: Specify if the event should only be trigger at most once.
176+
177+
**Example Usage**:
178+
```javascript
179+
Breinify.UTL.events.click('body', function () {
180+
window.alert('You clicked the document.');
181+
});
182+
```
183+
<br/>
184+
185+
* **Breinify.UTL.events.pageloaded(func)**:<br/>
186+
Gets all the cookies currently defined and accessible.
187+
188+
**Parameters**:
189+
190+
{function} **func**: The function to execute when the event is captured. The function retrieves an *event* object which can be used to control the further processing. In addition, the handling function also has access to the DOM-element that the handler was bound to using *this*. For further details, have a look at [jQuery Event Handling](https://learn.jquery.com/events/inside-event-handling-function/).
191+
192+
**Example Usage**:
193+
```javascript
194+
Breinify.UTL.events.click('body', function () {
195+
window.alert('The document is loaded.');
196+
});
197+
```
198+
<br/>
199+
138200
##### Breinify.UTL.loc
139201

202+
The location part of the utilities contains functions to validate, match, or retrieve information from the url or parameters specified within.
203+
140204
* {object} **Breinify.UTL.loc.params(paramListSeparator, paramSeparator, paramSplit, url)**:<br/>
141205
Retrieves an object with representing the parameters specified within the URL.
142206

@@ -201,6 +265,8 @@ The utility library provides general functionality, which makes it easy to retri
201265
* {boolean} **Breinify.UTL.loc.paramIs(expected, param, paramListSeparator, paramSeparator, paramSplit, url)**:<br/>
202266
Validates if the specified parameter is equal (*===*) to the *expected* value.
203267

268+
**Parameters**:
269+
204270
{string} **expected**: The expected value of the parameter to look for.
205271

206272
{string} **param**: The parameter to look for.
@@ -225,6 +291,20 @@ The utility library provides general functionality, which makes it easy to retri
225291
* {boolean} **Breinify.UTL.loc.parsedParam(expectedType, param, paramListSeparator, paramSeparator, paramSplit, url)**:<br/>
226292
Parses the specified parameter to the expected type (i.e., *number*, *string*, *boolean*). If the parameter cannot be parsed, **null** is returned.
227293

294+
**Parameters**:
295+
296+
{string} **expectedType**: The expected type, i.e., *number*, *string*, or *boolean*.
297+
298+
{string} **param**: The parameter to look for.
299+
300+
{string|null} **paramListSeparator**: The separator used to separate the list of parameters from the url (default: *?*).
301+
302+
{string|null} **paramSeparator**: The separator used to separate the parameters from each other (default: *&*).
303+
304+
{string|null} **paramSplit**: The separator used to split the name of the parameter and the value (default: *=*).
305+
306+
{string|null} **url**: The url to read the parameters from (default: *Breinify.UTL.loc.url()*).
307+
228308
**Example Usage**:
229309
```javascript
230310
var page = Breinify.UTL.loc.parsedParam('number', 'page', null, null, null, 'http://mydomain.com?page=search')
@@ -237,6 +317,18 @@ The utility library provides general functionality, which makes it easy to retri
237317
* {boolean} **Breinify.UTL.loc.param(param, paramListSeparator, paramSeparator, paramSplit, url)**:<br/>
238318
Gets a specific parameter from the url. The function returns *null*, if the parameter does not exist.
239319

320+
**Parameters**:
321+
322+
{string} **param**: The parameter to look for.
323+
324+
{string|null} **paramListSeparator**: The separator used to separate the list of parameters from the url (default: *?*).
325+
326+
{string|null} **paramSeparator**: The separator used to separate the parameters from each other (default: *&*).
327+
328+
{string|null} **paramSplit**: The separator used to split the name of the parameter and the value (default: *=*).
329+
330+
{string|null} **url**: The url to read the parameters from (default: *Breinify.UTL.loc.url()*).
331+
240332
**Example Usage**:
241333
```javascript
242334
var page = Breinify.UTL.loc.param('page', null, null, null, 'http://mydomain.com?page=search')
@@ -253,29 +345,89 @@ The utility library provides general functionality, which makes it easy to retri
253345
```
254346
<br/>
255347

256-
* {boolean} **Breinify.UTL.loc.matches()**:<br/>
348+
* {boolean} **Breinify.UTL.loc.matches(regEx)**:<br/>
257349
Validates if the current url matches the specified regular expression.
258350

351+
**Parameters**:
352+
353+
{string|RegEx} **regEx**: The regular expression used for matching.
354+
259355
**Example Usage**:
260356
```javascript
357+
if (Breinify.UTL.loc.matches('^https?//product.shop.com')) {
358+
window.alert('Welcome to our product list.');
359+
}
360+
```
361+
<br/>
362+
363+
##### Breinify.UTL.cookie
364+
365+
The cookie part of the utilities contains functions to validate, match, or retrieve information from the available cookies.
366+
367+
* {object} **Breinify.UTL.cookie.all()**:<br/>
368+
Gets all the cookies currently defined and accessible.
261369

370+
**Example Usage**:
371+
```javascript
372+
var cookies = Breinify.UTL.cookie.all();
373+
window.alert('The following cookies were found: ' + JSON.stringify(cookies));
262374
```
263375
<br/>
264376

377+
* **Breinify.UTL.cookie.reset(name)**:<br/>
378+
Removes the specified cookie.
265379

380+
**Parameters**:
266381

267-
cookie: {
268-
all: function () { return []; },
269-
set: function() {},
270-
reset: function() {},
271-
get: function() { return null; },
272-
check: function() { return false; },
273-
},
274-
events: {
275-
click: function() {},
276-
pageloaded: function() {}
277-
},
278-
texts: function() { return []; },
279-
text: function() { return null; },
280-
md5: function () { return null; },
281-
isEmpty: function() { return false; }
382+
{string} **name**: The name of the cookie to be removed.
383+
384+
**Example Usage**:
385+
```javascript
386+
Breinify.UTL.cookie.reset('myFunnyCookie');
387+
```
388+
<br/>
389+
390+
* **Breinify.UTL.cookie.set(name, value, expiresInDays)**:<br/>
391+
Sets the specified cookie with the specified value.
392+
393+
**Parameters**:
394+
395+
{string} **name**: The name of the cookie to be set.
396+
397+
{string} **value**: The value to be set for the cookie.
398+
399+
{number|null} **expiresInDays**: The time (in days) after which the cookie expires (default 1).
400+
401+
**Example Usage**:
402+
```javascript
403+
Breinify.UTL.cookie.set('myFunnyCookie', 'A year of fun!', 365);
404+
```
405+
<br/>
406+
407+
* {string} **Breinify.UTL.cookie.get(name)**:<br/>
408+
Gets the value of the cookie with the specified name, if no such cookie exists *null* is returned.
409+
410+
**Parameters**:
411+
412+
{string} **name**: The name of the cookie to be get.
413+
414+
**Example Usage**:
415+
```javascript
416+
Breinify.UTL.cookie.get('myFunnyCookie');
417+
```
418+
<br/>
419+
420+
* {boolean} **Breinify.UTL.cookie.check(name)**:<br/>
421+
Checks if a cookie is currently set or not.
422+
423+
**Parameters**:
424+
425+
{string} **name**: The name of the cookie to be get.
426+
427+
**Example Usage**:
428+
```javascript
429+
if (!Breinify.UTL.cookie.check('myFunnyCookie')) {
430+
window.alert('Is the funny session over or did it never start?');
431+
}
432+
```
433+
<br/>

src/BreinifyUtil.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@
186186
cookie: {
187187

188188
/**
189-
* Gets all the cookies currently defined and accessible or an empty array if there aren't any.
189+
* Gets all the cookies currently defined and accessible or an empty object if there aren't any.
190190
* @returns {object} the found cookies
191191
*/
192192
all: function () {

0 commit comments

Comments
 (0)