Conversation
Adds a check for when someone may enter just a url into the panic form that doesn't contain https://. If this happens it will add https:// to it and prevent the program from not working.
| if (localStorage.getItem('panickey') && localStorage.getItem('panickey') == e.key) window.parent.window.location.replace(localStorage.getItem('panicurl') || 'https://classroom.google.com/h') | ||
| }) | ||
| let panicurl = localStorage.getItem('panicurl'); | ||
| panicurl = (panicurl && (!panicurl.includes("https://") && !panicurl.includes("http://"))) ? "https://"+panicurl : panicurl; |
There was a problem hiding this comment.
This should be formatted better (spaces between plus, etc). I note that you could save an 'includes' statement by using a regexp and the test function. Overall could be done better, 6/10.
There was a problem hiding this comment.
Okay well to be fair I wasn't competing for a coding competition and trying to minify the code to the exact required lines and pretty spaces, I was simply just pitching an idea and I also decided to stack the code on one line since it was formatted that way originally. I wasn't formatting it for read quality, and the original code was also not that way. Not like every line needs to be fully minified and perfect, i'm sure you could fine multiple errors looking in files. lol
There was a problem hiding this comment.
This should be formatted better (spaces between plus, etc). I note that you could save an 'includes' statement by using a regexp and the
testfunction. Overall could be done better, 6/10.
I also simply left the first line of the panic code the part for the listener since I was not trying to rewrite it all, just add a nice function lol
There was a problem hiding this comment.
hey but at the end of the day i'm all for learning new methods and ways others do things, sorry if the first reply's came off rude.
There was a problem hiding this comment.
If you can i'd be more than happy to see how you would've went about it.
I figured this would be a nice addition, to someone who enters a url without the https:// part into the panic url box. This will prevent errors and any confusion by simply just adding it for them :). Without adding it, you goto an invalid url that looks like this "https://artclass.site/google.com".
Adds a check for when someone may enter just a url into the panic form that doesn't contain https://. If this happens it will add https:// to it and prevent the program from not working.