I took a break from my FPGA miner to throw together a JavaScript miner, mostly for educational purposes. It's on GitHub:
Bitcoin-JavaScript-MinerIf you upload it to a server, it functions. My system gets about 8khash/s, which is just cute
but that's actually a bit more than I expected.
It hasn't been tested for accuracy, so for all I know there's a bunch of bugs in the hashing code.
It doesn't do a real getwork, nor does it submit work (if it ever actually finds a share ...)
But I commented the code, and tried to make it as clear as possible. The real grunt work is in miner.js, so look there if you want to know how Bitcoins are mined.
work-manager.js is where miner.js is called from. Since a real getwork isn't actually used, there isn't much to see there. Normally it would talk to a mining pool server, and do a "getwork" request, which gives you the information you need to execute the code in miner.js. Once a valid hash is found, that would be returned to the mining pool server.
Enjoy! If I have the motivation and time I'll see what I can do to A) make sure it's bug free, and B) make it work with an actual mining pool ... just for giggles.