Hi shabda. I've seen your version when I was searching if someone has done this before. And you are right, I did it in Javascript because I wanted to share it with the world more easily.
Are you putting your code on github or such? (edit: disregard the question. Its obviously at: https://github.com/geonnave/primg/)
So long and thanks for all the fish!