diff options
Diffstat (limited to 'src/utils/configFromLink.js')
-rw-r--r-- | src/utils/configFromLink.js | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/utils/configFromLink.js b/src/utils/configFromLink.js new file mode 100644 index 0000000..853c07c --- /dev/null +++ b/src/utils/configFromLink.js @@ -0,0 +1,11 @@ +import { defaultTimer } from "./timerTemplate"; + +export const configFromLink = () => { + const config = window.location.hash; + if (config === "") { + return [{ ...defaultTimer }]; + } + return JSON + .parse(decodeURIComponent(escape(window.atob(config.replace("#", ""))))) + .map(t => ({ ...defaultTimer, name: t[0], initialTime: t[1], time: t[1] })); + } |