just.LocalStorage(consentopt, isExplicitopt)
A mixin of properties that access to some kind of storage
in the browser.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
consent
[optional] |
boolean | false | A boolean indicating that the user allowed the access to some kind of local storage. |
isExplicit
[optional] |
boolean | typeof consent !== 'undefined' | A value to indicate if the given consent was specified by the user. |
Members
DNT :boolean|undefined
The DoNotTrack header formatted as `true`, `false` or `undefined`
(for "unspecified").
Type:
boolean or undefined
Methods
getCookie(name) → {string|null}
Returns a cookie from document.cookie.
Parameters:
Name | Type | Description |
---|---|---|
name
|
string | The cookie name. |
Returns:
The cookie if it exists or null.
- Type
- string or null
isStorageAvailable(type, tempKeyopt, tempValueopt) → {boolean}
Tests if the specified storage does not throw.
Parameters:
Name | Type | Default | Description |
---|---|---|---|
type
|
just.LocalStorage~isStorageAvailable_type | A type of storage. | |
tempKey
[optional] |
string | '_' | Storage will save this key with tempValue as a value. |
tempValue
[optional] |
string | '_' | Storage will save this value with tempKey as a key. |
Returns:
`true` if the function does not throw
and is allowed by the user, `false` otherwise.
- Type
- boolean
removeCookie(name, optsopt) → {boolean}
Overrides a cookie by setting an empty value and expiring it.
Parameters:
Name | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
name
|
string | The name of the cookie. | ||||||||
opts
[optional] |
object | Some extra options.
Properties
|
Returns:
`true` if was overriden or the cookie
does not exist, `false` otherwise.
- Type
- boolean
setCookie(name, value, optsopt, non-null) → {boolean}
Concatenates a value to document.cookie.
Parameters:
Name | Type | Description | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
name
|
string | The name of the cookie. | ||||||||
value
|
string | The value of the cookie. | ||||||||
opts
[optional] |
object | Cookie options.
Properties
|
Returns:
`true` if was set, `false` otherwise.
- Type
- boolean