| skipped 8 lines |
9 | 9 | | * Helper Functions |
10 | 10 | | ******************************************************************************/ |
11 | 11 | | |
12 | | - | // Display a message in the "alert" area |
| 12 | + | /*** |
| 13 | + | * Display a message in the "alert" area |
| 14 | + | */ |
13 | 15 | | function error(text) { |
14 | 16 | | const alertText = document.querySelector(".alert"); |
15 | 17 | | alertText.innerHTML = text; |
| skipped 6 lines |
22 | 24 | | * Main UI Functions |
23 | 25 | | ******************************************************************************/ |
24 | 26 | | |
| 27 | + | /*** |
| 28 | + | * Create a hidden bookmark when the form is filled out. |
| 29 | + | */ |
25 | 30 | | async function onHide() { |
26 | 31 | | // Fail if the b64 library or API was not loaded |
27 | 32 | | if (!("b64" in window && "apiVersions" in window)) { |
| skipped 51 lines |
79 | 84 | | }); |
80 | 85 | | } |
81 | 86 | | |
| 87 | + | |
| 88 | + | /*** |
| 89 | + | * Called when the "change location" button is clicked. Adjusts the destination |
| 90 | + | * of the decrypt bookmark via regular expressions. |
| 91 | + | */ |
82 | 92 | | function onChangeDecrypt() { |
83 | 93 | | let newUrl; |
84 | 94 | | try { |
| skipped 9 lines |
94 | 104 | | console.log(decryptBookmark.href); |
95 | 105 | | } |
96 | 106 | | |
| 107 | + | |
| 108 | + | /*** |
| 109 | + | * Get a random link from Wikipedia |
| 110 | + | */ |
97 | 111 | | async function randomLink() { |
98 | 112 | | let page = await fetch("https://en.wikipedia.org/w/api.php?" |
99 | 113 | | + "format=json" |
| skipped 13 lines |
113 | 127 | | document.querySelector("#bookmark-title").value = await page.title; |
114 | 128 | | } |
115 | 129 | | |
| 130 | + | |
| 131 | + | /*** |
| 132 | + | * If the page has a hash, autofill it. |
| 133 | + | * |
| 134 | + | * Run on page load. |
| 135 | + | */ |
116 | 136 | | function main() { |
117 | 137 | | if (window.location.hash) { |
118 | 138 | | document.querySelector("#encrypted-url").value = |
| skipped 6 lines |