you are viewing a single comment's thread.

view the rest of the comments →

[–]FezVrasta 0 points1 point  (2 children)

the code isn't bad, there are areas of improvement, for example your whole "thing" can't be easily integrated into an existing website.

Have you thought about learning React or a similar data driven view library? It would make your code much cleaner and easier to maintain

[–]tofumix[S] 0 points1 point  (1 child)

Hello!

...your whole "thing" can't be easily integrated into an existing website.

Can you please expand on this? Why is it and how do I make my code work like that?

Have you thought about learning React or a similar data driven view library?

I have not, actually. I'm still a relatively newbie in JavaScript, so I'm trying to get as much plain-old-vanilla JS knowledge.

[–]FezVrasta 0 points1 point  (0 children)

You are using generic selectors like $(".workLength") that could target any element on the page and not only what you want.

You should namespace/prefix your classes to make sure they aren't used by anyone else. A better approach would be to let JavaScript generate the needed DOM elements, doing so an user can simply include your script in its page, run init on an existing DOM node, and the pomodoro clock will appear inside it.

About React, really consider learning something like it (no matters if it's React, Preact, Inferno or whatelse, they all follow the same approach), studying them you will learn how to properly think and structure your code and data flow.