Author Topic: Javascript Help: wtf?  (Read 2890 times)

Rob

  • New improved. Now with added something...
  • Jackass In Charge
  • Posts: 5959
  • Karma: +86/-149
  • Approaching 60 from the wrong damn direction...
Javascript Help: wtf?
« on: February 26, 2013, 08:13:04 AM »
Can one of you kind Java / Javascript experts interpret what this segment of code does please?

(Not what the functionality is, but literally what functions are being called, with what parameters etc.)

Code: [Select]
function SecureContext(strText, strSignature, bEscape) {
this.strSIGNATURE = strSignature || '';
this.bESCApE = bEscape || false;
this.strText = strText;
this.escape = SecureContext_escape;
this.unescape = SecureContext_unescape;
this.transliterate = SecureContext_transliterate;
this.encypher = SecureContext_encypher;
this.decypher = SecureContext_decypher;
this.sign = SecureContext_sign;
this.unsign = SecureContext_unsign;
this.secure = SecureContext_secure;
this.unsecure = SecureContext_unsecure;
}


If it helps, it's from here ( http://www.inet.hr/~tsereg/en/jse/index.html )

Ta!

edit>> It's these kind of lines I don't understand..

this.secure = SecureContext_secure;

Is that calling SecureContext_secure ? If so, where are the parameters? Surely it should be passing strPassword?

Code: [Select]
function SecureContext_secure( strPasswd )
{
    var passwd = new Password( strPasswd );
    var anPerm   = passwd.getPermutation()
this.sign( anPerm.length );
this.transliterate( true );
this.encypher( anPerm );
}

Mike

  • Jackass In Charge
  • Posts: 11248
  • Karma: +168/-32
  • Ex Asshole - a better and more caring person.
Re: Javascript Help: wtf?
« Reply #1 on: February 26, 2013, 10:00:28 AM »
No, it's not calling it.  It is setting a reference to it.  So that
Code: [Select]
foo = new SecureContent(stuff)
foo.secure(more stuff)
invokes SecureContext_secure

Think function pointer.

Rob

  • New improved. Now with added something...
  • Jackass In Charge
  • Posts: 5959
  • Karma: +86/-149
  • Approaching 60 from the wrong damn direction...
Re: Javascript Help: wtf?
« Reply #2 on: February 26, 2013, 10:17:10 AM »
OK, thank you. That makes perfect sense.