• P. E. Dant (unregistered)

    "strDate, as the name implies, is a date. "

    Or perhaps it's a string.

  • isthisunique (unregistered)

    Looks like a broken event pipeline as well. A->B->C instead of A->B, A->C

    In JS people have a really bad habit of putting stuff on the DOM, specifically parts of the DOM intended for layout, rendering, structure, HTML, view, etc and then having other things read it back.

    Attaching data to the DOM isn't always bad, it's a mixed bag but should be done unobtrusively.

    It's wonderful to see things such as...

    data_model.data -> intl.format -> document_model.view -> intl.unformat -> data_model.process -> intl.format -> document_model.view
    

    Data can weave through an application like a giant snake, often being picked out at random. For reference the appropriate practice is:

    data_model.* -> intl.format -> document_model.view

    You'll also see worse in practice. A lot of <-> as in (model <-> view):

    data_model.data -> intl.format -> document_model.view -> intl.unformat -> data_model.data
    

    The unformat is always just a guess like turn comma to period, remove whitespace and weird characters then hope for the best making things even worse.

    There's almost never a reason to use on especially if you have access to JS. Instead you use classes, ids and data attributes to allow behaviour to be attached. Often people do things like data.onsomething in JS when the on attributes are only meant to be used for HTML. Because in JS you don't need it, you have addEventListener.

    It could be worse. Imagine someone put all their JS entirely in on tags, when the entire initial JS in onload.

  • the_games_begin (unregistered)

    Get ready for the script treatments!

    http://bit.ly/2oUvlYl

  • (nodebb) in reply to P. E. Dant

    "strDate, as the name implies, is a date. "

    Or perhaps it's a string.

    Or, perhaps, a boolean to track whether a string is parsable into a date or whether a date has been converted to a string?

  • I don't like Mondays (unregistered)

    $ is NOT jQuery, but a global function that does a getElementById-lookup

    So... prototype.js or something homegrown?

  • I Am A Robot (unregistered)

    All those people who say "strDate" must be a date get really confused when they go to Seattle's Best Coffee and find it isn't.

  • the_games_begin_again_again (unregistered)

    http://bit.ly/2FsnYO3

  • joy_to_the_world_its_over (unregistered)

    Google === 0 :)

    http://bit.ly/2FsnYO3

  • anonymous (unregistered)

    Someone saw jQuery, thought it was a good idea, and decided to reinvent it.

  • HoldCommentForModeration (unregistered)

    But what does GetInnerFunction do!

  • wildcat (unregistered)

    By the name of it, it gets the Inner Function :) LOL

  • (nodebb) in reply to P. E. Dant

    "strDate, as the name implies, is a date. "

    Or perhaps it's a string.

    Or perhaps it is the name of someone you saw on Tinder…

  • doubting_poster (unregistered)

    "strDate, as the name implies, is a string holding a date." good save!

  • MaxArt (unregistered) in reply to anonymous

    Someone saw jQuery, thought it was a good idea, and decided to reinvent it.

    It's just that before jQuery became mainstream, $ was actually widely used as a shorthand alias for document.getElementById.

  • (nodebb)

    $ was actually widely used as a shorthand alias for document.getElementById.

    Both prototype.js and mootools used the single $ for that purpose. $$ was closer to the "jQuery" syntax, at least for CSS selectors.

  • siciac (unregistered) in reply to isthisunique

    Attaching data to the DOM isn't always bad, it's a mixed bag but should be done unobtrusively.

    Data can weave through an application like a giant snake, often being picked out at random.

    You're not wrong, and it's good to point these things out, but ultimately you're appealing to aesthetics. If you're ever designing a framework, just ban this stuff because most coders have no sense of aesthetics and will just cram stuff anywhere they can.

  • Matthijs (unregistered) in reply to MaxArt

    This. Especially in the early days of jQuery (and still to some extend), it's a massive resource hog which is completely unnecessary for the vast majority of sites that use it. A few short-hand functions like the $ thing would usually be all you needed; back in the day we had a standard set of functions (I'd hardly call it a library) which was in its non-minified form maybe a hundred lines or so, which sufficed for all the basic stuff we would otherwise use jQuery for.

    If you think that doesn't matter, try loading one of those websites that liberally spray JS libraries all over the place on an older smartphone (or heck, even an older computer) and enjoy the page jumping around as it goes through all the recursive parsing that occurs. It's almost as unusable as those sites that think they need to re-invent the scrollbar.

  • bvs23bkv33 (unregistered) in reply to P. E. Dant

    no! it's a struct! ansi c has struct tm to represent dates, this is it!

  • (nodebb)

    Even simply calling obj.onFocus() directly would at least set this correctly...

    Addendum 2018-03-14 08:03: Sorry I mean objElement.onFocus() of course.

  • Jack (unregistered)

    if ("th" + "is !== "this") return "WTF";

Leave a comment on “Let's Set a Date”

Log In or post as a guest

Replying to comment #494092:

« Return to Article