@@ -4,33 +4,57 @@ const urlToOpen = document.querySelector('.container div .urlToOpen');
4
4
panicKey . addEventListener ( 'click' , ( e ) => {
5
5
e . preventDefault ( ) ;
6
6
7
- const p = prompt ( "Do you want these settings to last throughout multiple sessions [yes/no]" ) ;
7
+ panicKey . addEventListener ( 'input' , ( e ) => {
8
+ e . preventDefault ( ) ;
8
9
9
- if ( p === 'yes' ) {
10
- panicKey . addEventListener ( 'input' , ( e ) => {
10
+ panicKey . addEventListener ( 'keypress' , ( e ) => {
11
11
e . preventDefault ( ) ;
12
-
13
- panicKey . addEventListener ( 'keypress' , ( e ) => {
14
- e . preventDefault ( ) ;
15
-
16
- if ( e . key === 'Enter' ) {
17
- const selectedKey = panicKey . value . trim ( ) || ']' ;
18
-
19
- localStorage . setItem ( 'panicKey' , selectedKey ) ;
20
-
21
- panicKey . addEventListener ( 'keypress' , ( e ) => {
22
- if ( e . key === localStorage . getItem ( 'panicKey' ) ) {
23
- const url = urlToOpen . value ;
24
-
25
- if ( url == '' || ! url . startsWith ( 'https' ) || ! url . startsWith ( 'http' ) ) {
26
- alert ( "Please provide a valid URL" ) ;
27
- }
28
-
29
-
12
+
13
+ if ( e . key === 'Enter' ) {
14
+ const selectedKey = panicKey . value . trim ( ) || ']' ;
15
+
16
+ sessionStorage . setItem ( 'panicKey' , selectedKey ) ;
17
+
18
+ window . addEventListener ( 'keypress' , ( e ) => {
19
+ if ( e . key === sessionStorage . getItem ( 'panicKey' ) ) {
20
+ const url = urlToOpen . value || 'https://myapps.classlink.com' ;
21
+
22
+ if ( url == '' ) {
23
+ alert ( "Please provide a valid URL" ) ;
24
+ }
25
+
26
+ window . location . replace ( url ) ;
27
+
28
+ if ( ! url . startsWith ( 'https' ) || ! url . startsWith ( 'http' ) && url . match ( / ( h t t p s ? : \/ \/ ( [ - \w \. ] + [ - \w ] ) { 1 , 63 } \. [ a - z A - Z ] { 2 , 6 } ( \/ [ ^ \s ] * ) ? ) / g) ) {
29
+ window . location . replace ( `https://${ url } ` ) ;
30
+ }
31
+ }
32
+ } ) ;
33
+ }
34
+ } ) ;
35
+
36
+ urlToOpen . addEventListener ( 'keypress' , ( e ) => {
37
+ if ( e . key === 'Enter' ) {
38
+ const selectedKey = panicKey . value . trim ( ) || ']' ;
39
+
40
+ sessionStorage . setItem ( 'panicKey' , selectedKey ) ;
41
+
42
+ window . addEventListener ( 'keypress' , ( e ) => {
43
+ if ( e . key === sessionStorage . getItem ( 'panicKey' ) ) {
44
+ const url = urlToOpen . value || 'https://myapps.classlink.com' ;
45
+
46
+ if ( url == '' ) {
47
+ alert ( "Please provide a valid URL" ) ;
48
+ }
49
+
50
+ window . location . replace ( url ) ;
51
+
52
+ if ( ! url . startsWith ( 'https' ) || ! url . startsWith ( 'http' ) && url . match ( / ( h t t p s ? : \/ \/ ( [ - \w \. ] + [ - \w ] ) { 1 , 63 } \. [ a - z A - Z ] { 2 , 6 } ( \/ [ ^ \s ] * ) ? ) / g) ) {
53
+ window . location . replace ( `https://${ url } ` ) ;
30
54
}
31
- } ) ;
32
- }
33
- } ) ;
55
+ }
56
+ } ) ;
57
+ }
34
58
} ) ;
35
- }
59
+ } ) ;
36
60
} ) ;
0 commit comments