aboutsummaryrefslogblamecommitdiff
path: root/src/utils/configFromLink.js
blob: 853c07c010f960ba938003c2a2457234f1f477db (plain) (tree)
1
2
3
4
5
6
7
8
9
10
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] }));
  }