Thursday, March 07, 2013

Chat code generator for coins

Trying to figure out how much custom JavaScript stuff is allowed on blogger I've just written a fun little script that will generate chat codes for coins. These codes will always show up with a bright golden color and will automatically translate to any language.

The source code is available at pastebin.

Note: the script does not work on Internet explorer 9 or lower because it uses the btoa function.


[&AQAAAAA=]

3 comments:

  1. Hey, I have read the source code and I have a question.

    In this line (55 at pastebin): for (i = 0; i < 4; i++) chatCode += String.fromCharCode((coin >> (i * 8)) & 255);

    Why put "& 255" ? I learn the bitwise today so it's confused in my head.
    Can you explain pls :p

    ReplyDelete
    Replies
    1. It's the bitwise AND operator (http://en.wikipedia.org/wiki/Bitwise_operation#AND). If you wouldn't use it the first byte would be the entire coin value:

      ( 1000 >> 0 ) --> 1000 (wrong)
      ( 1000 >> 0 ) & 255 --> 232 (right)

      Delete
  2. ok thank you!!
    Do you know if it's possible to create custom chat code then?

    ReplyDelete