Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update index.js #69

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions public/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,9 @@ console.log(localStorage.getItem('theme'))

// Panic
document.addEventListener('keydown', async (e) => {
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;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you can i'd be more than happy to see how you would've went about it.

if (localStorage.getItem('panickey') && localStorage.getItem('panickey') == e.key) window.parent.window.location.replace(panicurl || 'https://classroom.google.com/h');
});

// Debug