2017-03-27 16:37:11 +00:00
|
|
|
export let capitalise0 = name => name[0].toUpperCase() + name.slice(1)
|
2018-01-18 14:53:20 +00:00
|
|
|
|
|
|
|
export let getUrl = () => window.location.href.toString()
|
2018-05-14 08:47:20 +00:00
|
|
|
|
|
|
|
export let parseDataAttributes = value =>
|
|
|
|
value === 'undefined'
|
|
|
|
? undefined
|
|
|
|
: value === null
|
|
|
|
? null
|
|
|
|
: !isNaN(value)
|
|
|
|
? +value
|
|
|
|
: /* value is a normal string */
|
|
|
|
value
|
|
|
|
|
2018-01-18 14:53:20 +00:00
|
|
|
export let getIframeOption = optionName => {
|
|
|
|
let url = getUrl(),
|
|
|
|
hasOption = url.includes(optionName + '=')
|
2018-05-14 08:47:20 +00:00
|
|
|
return parseDataAttributes(
|
|
|
|
hasOption && url.split(optionName + '=')[1].split('&')[0]
|
|
|
|
)
|
2018-01-18 14:53:20 +00:00
|
|
|
}
|
2018-06-13 08:26:27 +00:00
|
|
|
|
|
|
|
// By luck this works as expected for both null and undefined, * but with different branches failing :O *
|
|
|
|
export let isFloat = n => Number(n) === n && n % 1 !== 0
|