aboutsummaryrefslogtreecommitdiffstats
path: root/js
diff options
context:
space:
mode:
authorFeuerfuchs <git@feuerfuchs.dev>2019-11-12 10:47:17 +0100
committerFeuerfuchs <git@feuerfuchs.dev>2019-11-12 10:47:17 +0100
commitfe92f6a7e33ebc38fc6acf4f1a7e31d8073c6d9f (patch)
treed700826dd8d46c1a7b2e5470e06abeb4635bc15b /js
parentUse brighter text in location bar for gopher:// (diff)
downloadgopherproxy-fe92f6a7e33ebc38fc6acf4f1a7e31d8073c6d9f.tar.gz
gopherproxy-fe92f6a7e33ebc38fc6acf4f1a7e31d8073c6d9f.tar.bz2
gopherproxy-fe92f6a7e33ebc38fc6acf4f1a7e31d8073c6d9f.zip
Add setting to use proportional font
Diffstat (limited to 'js')
-rw-r--r--js/main.ts32
1 files changed, 32 insertions, 0 deletions
diff --git a/js/main.ts b/js/main.ts
index 32c5a5b..29b4a68 100644
--- a/js/main.ts
+++ b/js/main.ts
@@ -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) => {