File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ "use strict" ;
2+ /**
3+ * @type {HTMLFormElement }
4+ */
5+ const form = document . getElementById ( "uv-form" ) ;
6+ /**
7+ * @type {HTMLInputElement }
8+ */
9+ const address = document . getElementById ( "uv-address" ) ;
10+ /**
11+ * @type {HTMLInputElement }
12+ */
13+ const searchEngine = document . getElementById ( "uv-search-engine" ) ;
14+ /**
15+ * @type {HTMLParagraphElement }
16+ */
17+ const error = document . getElementById ( "uv-error" ) ;
18+ /**
19+ * @type {HTMLPreElement }
20+ */
21+ const errorCode = document . getElementById ( "uv-error-code" ) ;
22+
23+ // Attach form submit event listener
24+ form . addEventListener ( "submit" , async ( event ) => {
25+ event . preventDefault ( ) ;
26+
27+ try {
28+ await registerSW ( ) ;
29+ } catch ( err ) {
30+ error . textContent = "Failed to register service worker." ;
31+ errorCode . textContent = err . toString ( ) ;
32+ throw err ;
33+ }
34+
35+ const url = search ( address . value , searchEngine . value ) ;
36+ location . href = __uv$config . prefix + __uv$config . encodeUrl ( url ) ;
37+ } ) ;
38+
39+ // Autofill function with auto-submit
40+ function autofill ( url ) {
41+ address . value = url ;
42+ form . requestSubmit ( ) ; // Automatically submit the form
43+ }
You can’t perform that action at this time.
0 commit comments