diff options
Diffstat (limited to 'js')
| -rw-r--r-- | js/main.ts | 32 |
1 files changed, 32 insertions, 0 deletions
| @@ -21,6 +21,15 @@ const settings = new KeyValueStore({ | |||
| 21 | ], | 21 | ], |
| 22 | valueRange: [false, true] | 22 | valueRange: [false, true] |
| 23 | }, | 23 | }, |
| 24 | monospaceFont: { | ||
| 25 | value: ensureSetting('monospace-font', '1') === '1', | ||
| 26 | callbacks: [ | ||
| 27 | value => { | ||
| 28 | localStorage.setItem('monospace-font', value ? '1' : '0'); | ||
| 29 | } | ||
| 30 | ], | ||
| 31 | valueRange: [false, true] | ||
| 32 | }, | ||
| 24 | imagePreviews: { | 33 | imagePreviews: { |
| 25 | value: ensureSetting('image-previews', '1') === '1', | 34 | value: ensureSetting('image-previews', '1') === '1', |
| 26 | callbacks: [ | 35 | callbacks: [ |
| @@ -110,6 +119,29 @@ const settings = new KeyValueStore({ | |||
| 110 | 119 | ||
| 111 | // | 120 | // |
| 112 | 121 | ||
| 122 | const settingMonospaceFontEl = document.getElementsByClassName('setting--monospace-font')[0]; | ||
| 123 | const settingMonospaceFontValueEl = settingMonospaceFontEl.getElementsByClassName('setting__value')[0]; | ||
| 124 | const settingMonospaceFontCallback = (value: boolean) => { | ||
| 125 | if (value) { | ||
| 126 | contentEl.classList.add("content--has-monospace-font"); | ||
| 127 | } else { | ||
| 128 | contentEl.classList.remove("content--has-monospace-font"); | ||
| 129 | } | ||
| 130 | |||
| 131 | settingMonospaceFontValueEl.textContent = value ? '[yes]' : '[no]'; | ||
| 132 | } | ||
| 133 | |||
| 134 | settingMonospaceFontValueEl.addEventListener('click', e => { | ||
| 135 | e.preventDefault(); | ||
| 136 | settings.cycleValue('monospaceFont'); | ||
| 137 | return false; | ||
| 138 | }); | ||
| 139 | |||
| 140 | settingMonospaceFontCallback(settings.getValue('monospaceFont')); | ||
| 141 | settings.addCallback('monospaceFont', settingMonospaceFontCallback); | ||
| 142 | |||
| 143 | // | ||
| 144 | |||
| 113 | const settingWordWrapEl = document.getElementsByClassName('setting--word-wrap')[0]; | 145 | const settingWordWrapEl = document.getElementsByClassName('setting--word-wrap')[0]; |
| 114 | const settingWordWrapValueEl = settingWordWrapEl.getElementsByClassName('setting__value')[0]; | 146 | const settingWordWrapValueEl = settingWordWrapEl.getElementsByClassName('setting__value')[0]; |
| 115 | const settingWordWrapCallback = (value: boolean) => { | 147 | const settingWordWrapCallback = (value: boolean) => { |
