MCPcopy
hub / github.com/philc/vimium / getSettingsFromForm

Function getSettingsFromForm

pages/options.js:147–178  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

145}
146
147function getSettingsFromForm() {
148 const settings = {};
149 for (const [optionName, optionType] of Object.entries(options)) {
150 const el = getOptionEl(optionName);
151 let value;
152 switch (optionType) {
153 case "boolean":
154 value = el.checked;
155 break;
156 case "number":
157 value = parseFloat(el.value);
158 break;
159 case "string":
160 value = el.value.trim();
161 break;
162 case "option":
163 const optionEl = document.querySelector(`input[name="${optionName}"]:checked`);
164 value = optionEl.value;
165 break;
166 default:
167 throw new Error(`Unrecognized option type ${optionType}`);
168 }
169 if (value !== null) {
170 settings[optionName] = value;
171 }
172 }
173 if (settings["linkHintCharacters"] != null) {
174 settings["linkHintCharacters"] = settings["linkHintCharacters"].toLowerCase();
175 }
176 settings["exclusionRules"] = ExclusionRulesEditor.getRules();
177 return settings;
178}
179
180function getValidationErrors() {
181 const results = {};

Callers 2

saveOptionsFunction · 0.85
prepareBackupSettingsFunction · 0.85

Calls 1

getOptionElFunction · 0.85

Tested by

no test coverage detected