Computer
Have Scientific Breakthroughs Declined?
Read more of this story at Slashdot.
US News Makes Money From Some of Its Biggest Critics: Colleges
Read more of this story at Slashdot.
iPhone Survives 16,000-Foot Fall From Alaska Air Flight
Read more of this story at Slashdot.
IRS To Begin Trial of Its Own Free Tax-Filing System
Read more of this story at Slashdot.
Hundreds of US Car Dealerships Abandon Buicks. Are EVs to Blame?
Read more of this story at Slashdot.
How AI-Generated Content Could Fuel a Migration From Social Media to Independent 'Authored' Content
Read more of this story at Slashdot.
CodeSOD: The Chosen Solution
Mac bears some responsibility for today's code, in that, he "fixed" it. That is to say, he was working on an unrelated bug, but this particular block of code was causing additional problems, so he did the bare minimum to make it stop bothering him so he could work on his actual ticket.
This JavaScript running on their page would allow the user to check a checkbox, navigate away from the page, and then if they hit "back" (something Mac was doing a lot while debugging), the checked checkbox would gradually migrate down the page for some weird set of JS and CSS reasons.
This revised code stops that behavior.
if (!$('body').hasClass('type-car') && !$('body').hasClass('page-lists-members') && !$('body').hasClass('page-tools') && !$('body').hasClass('page-findhelp') && !$('body').hasClass('page-active') && !$('body').hasClass('page-dash') && (!$.browser.msie && $.browser.version <= "8") && !$('body').hasClass('type-event') && !$('body').hasClass('page-add-event')) { //I didn't write this monstrosity, I fixed it. Look further back in the git logs if you like staring into hell... var example_of_really_bad_js_wrapped_in_really_bad_js = $('select').not('#edit-field-car-ref-und, .views-widget-filter-date_filter select'); example_of_really_bad_js_wrapped_in_really_bad_js.chosen(); example_of_really_bad_js_wrapped_in_really_bad_js.change(function(){ if($('.chzn-results li').length < 10) { $(this).each(function(){ $('.chzn-search').hide(); }); } }); }I love that one-line if condition, but honestly, that's small change compared to what's in the condition- why so many checks against body-level classes? Certainly a code stench, that they couldn't figure out a better way to decide when to execute this functionality.
In comparison, the body of the condition is a pretty minor level of ugly. Indentation as it was in the submission.
This is the kind of bad code that you can just sit back and look at, and not have to think too hard about. Even "fixed", it's just ugly and bad. We can all be glad this isn't in our codebase, and just move on with life.
[Advertisement] BuildMaster allows you to create a self-service release management platform that allows different teams to manage their applications. Explore how!Will Switching to a Flip Phone Fight Smartphone Addiction?
Read more of this story at Slashdot.
The Land is Steadily Sinking Up and Down America's Atlantic Coast
Read more of this story at Slashdot.
Three Packages Targeting Linux with Crypto Miners Found in Python's 'PyPi' Repository
Read more of this story at Slashdot.
A Microscopic Metal Flake Could Finally Reveal DB Cooper's Identity
Read more of this story at Slashdot.
Will Microsoft Overtake Apple as the World's Most Valuable Company?
Read more of this story at Slashdot.
ZDNet Calls Rhino Linux 'New Coolest Linux Distro'
Read more of this story at Slashdot.
Lithium Extraction Gets Faster and Maybe Greener, Too
Read more of this story at Slashdot.
Ask Slashdot: Does Anyone Still Use Ogg Vorbis Format?
Read more of this story at Slashdot.
An AI-powered Holographic Elvis Concert is Coming to Las Vegas (and the UK)
Read more of this story at Slashdot.
Whatever Happened to the Surviving Apollo Astronauts?
Read more of this story at Slashdot.
What's Next for Mozilla - and for Open Source AI?
Read more of this story at Slashdot.
How Does FreeBSD Compare to Linux on a Raspberry Pi?
Read more of this story at Slashdot.