Changeset View
Changeset View
Standalone View
Standalone View
extension/options.js
Show First 20 Lines • Show All 94 Lines • ▼ Show 20 Line(s) | 85 | for (var key in DEFAULT_EXTENSION_SETTINGS) { | |||
---|---|---|---|---|---|
95 | 95 | | |||
96 | settings[key] = { | 96 | settings[key] = { | ||
97 | enabled: checkbox.checked | 97 | enabled: checkbox.checked | ||
98 | }; | 98 | }; | ||
99 | 99 | | |||
100 | // TODO save additional stuff if we have it | 100 | // TODO save additional stuff if we have it | ||
101 | } | 101 | } | ||
102 | 102 | | |||
103 | try { | ||||
103 | storage.set(settings, function () { | 104 | storage.set(settings, function () { | ||
104 | return cb(chrome.runtime.lastError); | 105 | return cb(chrome.runtime.lastError); | ||
105 | }); | 106 | }); | ||
107 | // When the extension is reloaded, any call to extension APIs throws | ||||
108 | } catch (e) { | ||||
109 | cb(e); | ||||
110 | } | ||||
106 | } | 111 | } | ||
107 | 112 | | |||
108 | document.addEventListener("DOMContentLoaded", function () { | 113 | document.addEventListener("DOMContentLoaded", function () { | ||
109 | 114 | | |||
110 | // poor man's tab widget :) | 115 | // poor man's tab widget :) | ||
111 | document.querySelectorAll(".tabbar").forEach(function (tabbar) { | 116 | document.querySelectorAll(".tabbar").forEach(function (tabbar) { | ||
112 | tabbar.buttons = []; | 117 | tabbar.buttons = []; | ||
113 | 118 | | |||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | 146 | chrome.runtime.getPlatformInfo(function (info) { | |||
157 | // TODO can we do that on closing, or does it not matter how often we do chrome storage sync thing? | 162 | // TODO can we do that on closing, or does it not matter how often we do chrome storage sync thing? | ||
158 | document.querySelectorAll("input[type=checkbox]").forEach(function (item) { | 163 | document.querySelectorAll("input[type=checkbox]").forEach(function (item) { | ||
159 | item.addEventListener("click", function () { | 164 | item.addEventListener("click", function () { | ||
160 | var saveMessage = document.getElementById("save-message"); | 165 | var saveMessage = document.getElementById("save-message"); | ||
161 | saveMessage.innerText = ""; | 166 | saveMessage.innerText = ""; | ||
162 | 167 | | |||
163 | saveSettings(function (error) { | 168 | saveSettings(function (error) { | ||
164 | if (error) { | 169 | if (error) { | ||
170 | try { | ||||
165 | saveMessage.innerText = chrome.i18n.getMessage("options_save_failed"); | 171 | saveMessage.innerText = chrome.i18n.getMessage("options_save_failed"); | ||
172 | } catch (e) { | ||||
173 | // When the extension is reloaded, any call to extension APIs throws, make sure we show at least some form of error | ||||
174 | saveMessage.innerText = "Saving settings failed (" + (error || e) + ")"; | ||||
fvogt: This should show `error` as well | |||||
175 | } | ||||
166 | return; | 176 | return; | ||
167 | } | 177 | } | ||
168 | 178 | | |||
169 | sendMessage("changed"); | 179 | sendMessage("changed"); | ||
170 | }); | 180 | }); | ||
171 | }); | 181 | }); | ||
172 | }); | 182 | }); | ||
173 | }); | 183 | }); | ||
Show All 21 Lines |
This should show error as well