aboutsummaryrefslogtreecommitdiff
path: root/src/view/options.ts
blob: 4c71be25b81aabc5dffdd029897fbc99e58fd71b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
export type Options = {
  major: boolean,
  minor: boolean,
  bpm: number,
  beatsPerChord: number
}

let defaultOptions: Options = {
  major: true,
  minor: false,
  bpm: 90,
  beatsPerChord: 4
}

let key: string = 'options'

export function load(): Options {
  let str = localStorage[key]
  return str && JSON.parse(str) || defaultOptions
}

export function save(options: Options): void {
  localStorage[key] = JSON.stringify(options)
}