()
| 331 | } |
| 332 | |
| 333 | function 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 | |
| 363 | const testEnv = globalThis.window == null || |
| 364 | globalThis.window.location.search.includes("dom_tests=true"); |
no test coverage detected