aboutsummaryrefslogtreecommitdiff
path: root/src/view/options.ts
blob: 4a57f97b491d1cb8262e7ca537be73d5396c86ad (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
25
26
27
28
29
30
export type Options = {
  major: boolean,
  minor: boolean,
  seventh: boolean,
  minorSeventh: boolean,
  majorSeventh: boolean,
  bpm: number,
  beatsPerChord: number
}

let defaultOptions: Options = {
  major: true,
  minor: false,
  seventh: false,
  minorSeventh: false,
  majorSeventh: 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)
}