There must be a reason to do that besides plain idiocy. I refuse to believe someone could write this without some rationale behind it.
Perhaps the HTML can’t be changed for some bizarre reason? Seems like this code modifies some weird networking UI (the ids are references to modems, networks, dial ins, etc).
Maybe there’s some obscure reason to not modify the static state of the file and that’s why this css needs to be added dynamically? Or maybe for some reason they can’t use stylesheets or style tags?
Idk. Maybe it’s just idiocy but I find hard to believe that someone can write JS that manipulates the DOM and adds CSS styles, and not knowing how to use CSS classes.
Kinda. I’ve been at shops where they wanted to measure developer productivity. I tried to steer them to measuring approved pull requests. Turns out there was an entire team of contractors with 0 merged pull requests.
Any measurement can be gamed. But measurements to find the low performers and get them help or ease them out can be useful.
The way to do this properly, in one line, is to set a class on a parent element and have that class affect all of the sub elements. Let the css actually be in the css file.
Much less dom manipulation, much faster, much easier to maintain. This is just horrible on so many levels
all of those are different HTML elements, even if you made a class, you'd have to add it to each one of them, I would have used CSS variables to accomplish this in a cleaner way.
giving them all an if-connected class (or something) and then iterating through document.getElementsByClassName('if-connected') is so much less bad than this
84
u/NotARealDoctorZaius Nov 10 '21
Best part is the "it goes on like this..." part. That really hits me
32
u/killchain Nov 10 '21
... and on top of that
valuebeing equal to2says so much...62
u/MurdoMaclachlan public boolean isInt(int i) { return true; } Nov 10 '21
Image Transcription: Code
I'm a human volunteer content transcriber for Reddit and you could be too! If you'd like more information on what we do and why we do it, click here!
14
u/Notimecelduv Nov 10 '21
When a jQuery user is forced to write vanilla JS.
5
u/whoisjuan Nov 11 '21 edited Nov 11 '21
There must be a reason to do that besides plain idiocy. I refuse to believe someone could write this without some rationale behind it.
Perhaps the HTML can’t be changed for some bizarre reason? Seems like this code modifies some weird networking UI (the ids are references to modems, networks, dial ins, etc).
Maybe there’s some obscure reason to not modify the static state of the file and that’s why this css needs to be added dynamically? Or maybe for some reason they can’t use stylesheets or style tags?
Idk. Maybe it’s just idiocy but I find hard to believe that someone can write JS that manipulates the DOM and adds CSS styles, and not knowing how to use CSS classes.
4
u/Deadly_chef Nov 10 '21
How does one write this and thinks yeah this is fine? Especially since I guess this is prod. code
4
u/paceaux Nov 11 '21
This has, that fresh "written by a junior Java developer " smell.
3
u/awfullyawful Nov 10 '21
The way to do this properly, in one line, is to set a class on a parent element and have that class affect all of the sub elements. Let the css actually be in the css file.
Much less dom manipulation, much faster, much easier to maintain. This is just horrible on so many levels
1
u/Donni3D4rko Nov 10 '21
Work smart not hard
1
u/AnotherChileanGuy Nov 11 '21
How do you approach the issue of changing the color of a button that is in more than once in the same screen without changing the other buttons?
1
u/linocontreras Nov 11 '21
PPP
1
u/[deleted] Dec 30 '21
YandereDev is that you?
1
u/i_will_yeet biggus dickus Nov 11 '21
all of those are different HTML elements, even if you made a class, you'd have to add it to each one of them, I would have used CSS variables to accomplish this in a cleaner way.
-4
u/[deleted] Nov 10 '21
could look a little better with an array and a for loop
0
u/[deleted] Nov 11 '21
What if you cannot change the markup / stylesheets at all?
-20
u/SN0WFAKER Nov 10 '21
Ya, this is bad, but anything you do with css is gonna be bad.
-2
u/dydzio Nov 10 '21
i would use ctrl+f on each element ID and add style="display: 'inline'"
0
u/[deleted] Nov 11 '21
[deleted] — view deleted comment
0
u/[deleted] Nov 10 '21
[deleted] — view deleted comment