Class: LocalStorage

just.LocalStorage(consentopt, isExplicitopt)

A mixin of properties that access to some kind of storage in the browser.
Source:
just.js, line 1162

Parameters:

NameTypeDefaultDescription
consent
[optional]
booleanfalseA boolean indicating that the user allowed the access to some kind of local storage.
isExplicit
[optional]
booleantypeof 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").
Source:
just.js, line 1182
Type:

boolean or undefined

Methods

cookieExists(cookie) → {boolean}

Checks if cookie is in document.cookie.
Source:
just.js, line 1215
Parameters:
NameTypeDescription
cookie
stringThe name of the cookie or the cookie itself.
Returns:
`true` if it exists, `false` otherwise.
Type
boolean
Example
document.cookie += 'a=b; c=d;';
cookieExists('a'); // true
cookieExists('b'); // false
cookieExists('a=b'); // true
cookieExists('a=d'); // false

getCookie(name) → {string|null}

Returns a cookie from document.cookie.
Source:
just.js, line 1231
Parameters:
NameTypeDescription
name
stringThe 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.
Source:
just.js, line 1320
Parameters:
NameTypeDefaultDescription
type
just.LocalStorage~isStorageAvailable_typeA 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.
Source:
just.js, line 1290
Parameters:
NameTypeDescription
name
stringThe name of the cookie.
opts
[optional]
objectSome extra options.
Properties
NameTypeDefaultDescription
expires
[optional]
Datenew Date(0)A date in the past.
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.
Source:
just.js, line 1255
Parameters:
NameTypeDescription
name
stringThe name of the cookie.
value
stringThe value of the cookie.
opts
[optional]
objectCookie options.
Properties
NameTypeDefaultDescription
secure
[optional]
stringlocation.protocol === 'https:'"secure" flag for the cookie.
Returns:
`true` if was set, `false` otherwise.
Type
boolean

Type Definitions

isStorageAvailable_type

Any of "cookie", "localStorage", "sessionStorage"...
Source:
just.js, line 1302
Type:

string