Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. I Hate Clever Javascript Programmers [modified]

I Hate Clever Javascript Programmers [modified]

Scheduled Pinned Locked Moved The Weird and The Wonderful
javascriptquestion
33 Posts 27 Posters 2 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R realJSOP

    I think the guy either "optimized' his code, or obfuscated it. I can't make out head nor tails of what the code does. I'm actually pissed off enough about it to try to find something else.

    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
    -----
    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
    -----
    "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

    A Offline
    A Offline
    AspDotNetDev
    wrote on last edited by
    #5

    Yeah, looks like it may have passed through a JavaScript minifier (kinda like how jQuery has a commented version and another version that is minified).

    [

    S<T>::f(U) // Out of line.

    ](http://msdn.microsoft.com/en-us/library/8yk3t00s(v=vs.71).aspx)

    1 Reply Last reply
    0
    • R realJSOP

      I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

      return (aW == null) ? a0 === "!=" : a0 === "="
      ? a2 === aX : a0 === "*="
      ? a2.indexOf(aX) >= 0 : a0 === "~="
      ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
      ? a2 && aW !== false : a0 === "!="
      ? a2 !== aX : a0 === "^="
      ? a2.indexOf(aX) === 0 : a0 === "$="
      ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
      ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

      Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
      -----
      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
      -----
      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

      modified on Thursday, April 28, 2011 3:50 PM

      G Offline
      G Offline
      GibbleCH
      wrote on last edited by
      #6

      It's not that bad if you format it properly

      return
      (aW == null) ? a0 === "!="
      : a0 === "=" ? a2 === aX
      : a0 === "*=" ? a2.indexOf(aX) >= 0
      : a0 === "~=" ? (" " + a2 + " ").indexOf(aX) >= 0
      : !aX ? a2 && aW !== false
      : a0 === "!=" ? a2 !== aX
      : a0 === "^=" ? a2.indexOf(aX) === 0
      : a0 === "$=" ? a2.substr(a2.length - aX.length) === aX
      : a0 === "|=" ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-"
      : false;

      Basically it boils down to this

      return the result of...
      if condition then this
      else condition then this
      else condition then this
      ...
      else this

      1 Reply Last reply
      0
      • R realJSOP

        I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

        return (aW == null) ? a0 === "!=" : a0 === "="
        ? a2 === aX : a0 === "*="
        ? a2.indexOf(aX) >= 0 : a0 === "~="
        ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
        ? a2 && aW !== false : a0 === "!="
        ? a2 !== aX : a0 === "^="
        ? a2.indexOf(aX) === 0 : a0 === "$="
        ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
        ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

        Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
        -----
        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
        -----
        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

        modified on Thursday, April 28, 2011 3:50 PM

        W Offline
        W Offline
        wizardzz
        wrote on last edited by
        #7

        Yuck is this for work or for personal use?

        Craigslist Troll: litaly@comcast.net "I have a theory that the truth is never told during the nine-to-five hours. " — Hunter S. Thompson

        R 1 Reply Last reply
        0
        • W wizardzz

          Yuck is this for work or for personal use?

          Craigslist Troll: litaly@comcast.net "I have a theory that the truth is never told during the nine-to-five hours. " — Hunter S. Thompson

          R Offline
          R Offline
          realJSOP
          wrote on last edited by
          #8

          Personal use...

          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
          -----
          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
          -----
          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

          T F 2 Replies Last reply
          0
          • R realJSOP

            Personal use...

            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
            -----
            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
            -----
            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

            T Offline
            T Offline
            TorstenH
            wrote on last edited by
            #9

            hmmm dirty code for personal use... :doh: It's from the search logic on a porno website! Damn, I knew I use it everyday ;P :laugh: regards Torsten

            I never finish anyth...

            1 Reply Last reply
            0
            • R realJSOP

              I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

              return (aW == null) ? a0 === "!=" : a0 === "="
              ? a2 === aX : a0 === "*="
              ? a2.indexOf(aX) >= 0 : a0 === "~="
              ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
              ? a2 && aW !== false : a0 === "!="
              ? a2 !== aX : a0 === "^="
              ? a2.indexOf(aX) === 0 : a0 === "$="
              ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
              ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

              Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

              ".45 ACP - because shooting twice is just silly" - JSOP, 2010
              -----
              You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
              -----
              "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

              modified on Thursday, April 28, 2011 3:50 PM

              T Offline
              T Offline
              Tech Code Freak
              wrote on last edited by
              #10

              Bloody hell! this really needs a filter/translator to be understood or may take ages to be refined!! :omg: :omg: :omg: :omg: :omg: :omg: :omg: :omg: :omg: X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X| X|

              1 Reply Last reply
              0
              • R realJSOP

                I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

                return (aW == null) ? a0 === "!=" : a0 === "="
                ? a2 === aX : a0 === "*="
                ? a2.indexOf(aX) >= 0 : a0 === "~="
                ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
                ? a2 && aW !== false : a0 === "!="
                ? a2 !== aX : a0 === "^="
                ? a2.indexOf(aX) === 0 : a0 === "$="
                ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
                ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

                Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

                ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                -----
                You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                -----
                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                modified on Thursday, April 28, 2011 3:50 PM

                E Offline
                E Offline
                Erion Pici
                wrote on last edited by
                #11

                If you work your head around inline IFs you'll find them really useful. I use them in C# all the time!!

                S R 2 Replies Last reply
                0
                • R realJSOP

                  I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

                  return (aW == null) ? a0 === "!=" : a0 === "="
                  ? a2 === aX : a0 === "*="
                  ? a2.indexOf(aX) >= 0 : a0 === "~="
                  ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
                  ? a2 && aW !== false : a0 === "!="
                  ? a2 !== aX : a0 === "^="
                  ? a2.indexOf(aX) === 0 : a0 === "$="
                  ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
                  ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

                  Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

                  ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                  -----
                  You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                  -----
                  "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                  modified on Thursday, April 28, 2011 3:50 PM

                  E Offline
                  E Offline
                  Eddie Kuns
                  wrote on last edited by
                  #12

                  If I read this correctly and my understanding of JavaScript precedence is correct, I think this is an ugly version of a big else-if statement. Something like this:

                  if (aw == null) {
                  return a0 === "!=";
                  } else if (a0 === "=") {
                  return a2 === aX;
                  } else if (a0 === "*=") {
                  return a2.indexOf(aX) >= 0;
                  } else if (a0 === "~=") {
                  return (" " + a2 + " ").indexOf(aX) >= 0;
                  } else if (!aX) {
                  return a2 && aW !== false;
                  } else if (a0 === "!=") {
                  return a2 !== aX;
                  } else if (a0 === "^=") {
                  return a2.indexOf(aX) === 0;
                  } else if (a0 === "$=") {
                  return a2.substr(a2.length - aX.length) === aX;
                  } else if (a0 === "|=") {
                  return a2 === aX || a2.substr(0, aX.length + 1) === aX + "-";
                  }

                  return false;

                  which you could also write as

                  return (aW == null) ? a0 === "!="
                  : (a0 === "=") ? a2 === aX
                  : (a0 === "*=") ? a2.indexOf(aX) >= 0
                  : (a0 === "~=") ? (" " + a2 + " ").indexOf(aX) >= 0
                  : (!aX) ? a2 && aW !== false
                  : (a0 === "!=") ? a2 !== aX
                  : (a0 === "^=") ? a2.indexOf(aX) === 0
                  : (a0 === "$=") ? a2.substr(a2.length - aX.length) === aX
                  : (a0 === "|=") ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-"
                  : false;

                  where this shows the IF on the left and the RETURN THIS on the left of the "?" on each line. Ugly. Un-maintainable. Yuck.

                  J 1 Reply Last reply
                  0
                  • R realJSOP

                    I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

                    return (aW == null) ? a0 === "!=" : a0 === "="
                    ? a2 === aX : a0 === "*="
                    ? a2.indexOf(aX) >= 0 : a0 === "~="
                    ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
                    ? a2 && aW !== false : a0 === "!="
                    ? a2 !== aX : a0 === "^="
                    ? a2.indexOf(aX) === 0 : a0 === "$="
                    ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
                    ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

                    Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

                    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                    -----
                    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                    -----
                    "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                    modified on Thursday, April 28, 2011 3:50 PM

                    L Offline
                    L Offline
                    loveangel888
                    wrote on last edited by
                    #13

                    Finally I see what it is doing after 10 mins of staring at the code.

                    1 Reply Last reply
                    0
                    • R realJSOP

                      I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

                      return (aW == null) ? a0 === "!=" : a0 === "="
                      ? a2 === aX : a0 === "*="
                      ? a2.indexOf(aX) >= 0 : a0 === "~="
                      ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
                      ? a2 && aW !== false : a0 === "!="
                      ? a2 !== aX : a0 === "^="
                      ? a2.indexOf(aX) === 0 : a0 === "$="
                      ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
                      ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

                      Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

                      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                      -----
                      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                      -----
                      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                      modified on Thursday, April 28, 2011 3:50 PM

                      A Offline
                      A Offline
                      Alexandru Lungu
                      wrote on last edited by
                      #14

                      There is nothing clever here; the code was obfuscated with a tool; it was intended to be hard to understand; the original code is probably very readable.

                      Challenge is Life!

                      A 1 Reply Last reply
                      0
                      • R realJSOP

                        I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

                        return (aW == null) ? a0 === "!=" : a0 === "="
                        ? a2 === aX : a0 === "*="
                        ? a2.indexOf(aX) >= 0 : a0 === "~="
                        ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
                        ? a2 && aW !== false : a0 === "!="
                        ? a2 !== aX : a0 === "^="
                        ? a2.indexOf(aX) === 0 : a0 === "$="
                        ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
                        ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

                        Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

                        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                        -----
                        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                        -----
                        "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                        modified on Thursday, April 28, 2011 3:50 PM

                        F Offline
                        F Offline
                        Florin Jurcovici 0
                        wrote on last edited by
                        #15

                        Try rewriting it using if ... else ... instead of ? :, this might increase readability to the point where you'll understand it. But don't get your hopes high. This looks like some code intentionally obfuscated, potentially hand-crafted, intentionally written so it's not comprehensible, in order to prevent exactly what you are trying to do.

                        1 Reply Last reply
                        0
                        • R realJSOP

                          I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

                          return (aW == null) ? a0 === "!=" : a0 === "="
                          ? a2 === aX : a0 === "*="
                          ? a2.indexOf(aX) >= 0 : a0 === "~="
                          ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
                          ? a2 && aW !== false : a0 === "!="
                          ? a2 !== aX : a0 === "^="
                          ? a2.indexOf(aX) === 0 : a0 === "$="
                          ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
                          ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

                          Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

                          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                          -----
                          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                          -----
                          "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                          modified on Thursday, April 28, 2011 3:50 PM

                          D Offline
                          D Offline
                          demius
                          wrote on last edited by
                          #16

                          Wow! That's the scariest ternary I've ever seen

                          1 Reply Last reply
                          0
                          • R realJSOP

                            I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

                            return (aW == null) ? a0 === "!=" : a0 === "="
                            ? a2 === aX : a0 === "*="
                            ? a2.indexOf(aX) >= 0 : a0 === "~="
                            ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
                            ? a2 && aW !== false : a0 === "!="
                            ? a2 !== aX : a0 === "^="
                            ? a2.indexOf(aX) === 0 : a0 === "$="
                            ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
                            ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

                            Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

                            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                            -----
                            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                            -----
                            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                            modified on Thursday, April 28, 2011 3:50 PM

                            L Offline
                            L Offline
                            Lost User
                            wrote on last edited by
                            #17

                            The best I have done using javascript is to produce the confirm button. I also do not like the funny code they write even jquery gives me headache

                            I only read newbie introductory dummy books.

                            1 Reply Last reply
                            0
                            • E Eddie Kuns

                              If I read this correctly and my understanding of JavaScript precedence is correct, I think this is an ugly version of a big else-if statement. Something like this:

                              if (aw == null) {
                              return a0 === "!=";
                              } else if (a0 === "=") {
                              return a2 === aX;
                              } else if (a0 === "*=") {
                              return a2.indexOf(aX) >= 0;
                              } else if (a0 === "~=") {
                              return (" " + a2 + " ").indexOf(aX) >= 0;
                              } else if (!aX) {
                              return a2 && aW !== false;
                              } else if (a0 === "!=") {
                              return a2 !== aX;
                              } else if (a0 === "^=") {
                              return a2.indexOf(aX) === 0;
                              } else if (a0 === "$=") {
                              return a2.substr(a2.length - aX.length) === aX;
                              } else if (a0 === "|=") {
                              return a2 === aX || a2.substr(0, aX.length + 1) === aX + "-";
                              }

                              return false;

                              which you could also write as

                              return (aW == null) ? a0 === "!="
                              : (a0 === "=") ? a2 === aX
                              : (a0 === "*=") ? a2.indexOf(aX) >= 0
                              : (a0 === "~=") ? (" " + a2 + " ").indexOf(aX) >= 0
                              : (!aX) ? a2 && aW !== false
                              : (a0 === "!=") ? a2 !== aX
                              : (a0 === "^=") ? a2.indexOf(aX) === 0
                              : (a0 === "$=") ? a2.substr(a2.length - aX.length) === aX
                              : (a0 === "|=") ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-"
                              : false;

                              where this shows the IF on the left and the RETURN THIS on the left of the "?" on each line. Ugly. Un-maintainable. Yuck.

                              J Offline
                              J Offline
                              JohnLBevan
                              wrote on last edited by
                              #18

                              I actually prefer the second version from a readability point of view (now that you've reformatted so it makes sense). Stick a comment at the top to say what it's doing and it wouldn't be so bad. The variable names and dynamic typing I'll admit is horrendous for readability though.

                              1 Reply Last reply
                              0
                              • R realJSOP

                                Personal use...

                                ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                -----
                                You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                -----
                                "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                                F Offline
                                F Offline
                                fjdiewornncalwe
                                wrote on last edited by
                                #19

                                Either way... I'm glad I'm not maintaining that guy's stuff. Personal or Professional, a good dev is not going to cut corners in the quality of their code in either. Or am I the only anal retentive coder out there.

                                I wasn't, now I am, then I won't be anymore.

                                1 Reply Last reply
                                0
                                • R realJSOP

                                  I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

                                  return (aW == null) ? a0 === "!=" : a0 === "="
                                  ? a2 === aX : a0 === "*="
                                  ? a2.indexOf(aX) >= 0 : a0 === "~="
                                  ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
                                  ? a2 && aW !== false : a0 === "!="
                                  ? a2 !== aX : a0 === "^="
                                  ? a2.indexOf(aX) === 0 : a0 === "$="
                                  ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
                                  ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

                                  Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

                                  ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                  -----
                                  You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                  -----
                                  "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                                  modified on Thursday, April 28, 2011 3:50 PM

                                  E Offline
                                  E Offline
                                  Eric W Scott
                                  wrote on last edited by
                                  #20

                                  The uncompressed source is on GitHub. https://github.com/mjijackson/shadowbox[^]

                                  1 Reply Last reply
                                  0
                                  • R realJSOP

                                    I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

                                    return (aW == null) ? a0 === "!=" : a0 === "="
                                    ? a2 === aX : a0 === "*="
                                    ? a2.indexOf(aX) >= 0 : a0 === "~="
                                    ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
                                    ? a2 && aW !== false : a0 === "!="
                                    ? a2 !== aX : a0 === "^="
                                    ? a2.indexOf(aX) === 0 : a0 === "$="
                                    ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
                                    ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

                                    Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

                                    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                    -----
                                    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                    -----
                                    "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                                    modified on Thursday, April 28, 2011 3:50 PM

                                    N Offline
                                    N Offline
                                    Nemanja Trifunovic
                                    wrote on last edited by
                                    #21

                                    One line of code thing aside, this is a pretty idiomatic use of the ternary operator. What's so clever about it?

                                    utf8-cpp

                                    1 Reply Last reply
                                    0
                                    • R realJSOP

                                      I'm trying to decipher the inner workings of ShadowBox (a lightbox variant), and I found this (except when I found it, it was all on one line of code:

                                      return (aW == null) ? a0 === "!=" : a0 === "="
                                      ? a2 === aX : a0 === "*="
                                      ? a2.indexOf(aX) >= 0 : a0 === "~="
                                      ? (" " + a2 + " ").indexOf(aX) >= 0 : !aX
                                      ? a2 && aW !== false : a0 === "!="
                                      ? a2 !== aX : a0 === "^="
                                      ? a2.indexOf(aX) === 0 : a0 === "$="
                                      ? a2.substr(a2.length - aX.length) === aX : a0 === "|="
                                      ? a2 === aX || a2.substr(0, aX.length + 1) === aX + "-" : false;

                                      Before anyone else mentions it, I *know* what a ternary comparison is and I use them all the time (and was doing so before many of you were even born), but I don't nest them like this. THAT is the shameful nature of the code. So, please stop trying to educate me as to the ways of the force.

                                      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                      -----
                                      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                      -----
                                      "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass." - Dale Earnhardt, 1997

                                      modified on Thursday, April 28, 2011 3:50 PM

                                      L Offline
                                      L Offline
                                      Lost User
                                      wrote on last edited by
                                      #22

                                      Like others have said ... that looks to me like Obfuscated code - emitted by a tool of some kind. If I had a developer working for me that wrote code like that I'd fire his ass. -Max

                                      E 1 Reply Last reply
                                      0
                                      • L Lost User

                                        Like others have said ... that looks to me like Obfuscated code - emitted by a tool of some kind. If I had a developer working for me that wrote code like that I'd fire his ass. -Max

                                        E Offline
                                        E Offline
                                        Erion Pici
                                        wrote on last edited by
                                        #23

                                        I agree. Although inline IFs are useful, that code looks as bad as it would look in the more traditional IF { } block form. I'm not convinced it's been generated by an obfuscator though.

                                        1 Reply Last reply
                                        0
                                        • A Alexandru Lungu

                                          There is nothing clever here; the code was obfuscated with a tool; it was intended to be hard to understand; the original code is probably very readable.

                                          Challenge is Life!

                                          A Offline
                                          A Offline
                                          agolddog
                                          wrote on last edited by
                                          #24

                                          [quote] There is nothing clever here; the code was obfuscated withby a tool; it was intended to be hard to understand; the original code is probably very readable. [/quote] FTFY

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups