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

Function onUploadBackupClicked

pages/options.js:333–361  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

331}
332
333function onUploadBackupClicked() {
334 if (document.activeElement) {
335 document.activeElement.blur();
336 }
337
338 const files = event.target.files;
339 if (files.length === 1) {
340 const file = files[0];
341 const reader = new FileReader();
342 reader.readAsText(file);
343 reader.onload = async () => {
344 let backup;
345 try {
346 backup = JSON.parse(reader.result);
347 } catch (error) {
348 console.log("parsing error:", error);
349 alert("Failed to parse Vimium backup: " + error);
350 return;
351 }
352
353 await Settings.setSettings(backup);
354 setFormFromSettings(Settings.getSettings());
355 const saveButton = document.querySelector("#save");
356 saveButton.disabled = true;
357 saveButton.textContent = "Saved";
358 alert("Settings have been restored from the backup.");
359 };
360 }
361}
362
363const testEnv = globalThis.window == null ||
364 globalThis.window.location.search.includes("dom_tests=true");

Callers 1

initFunction · 0.85

Calls 3

setFormFromSettingsFunction · 0.85
logMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected