All of the game code is Nethack's original C: https://github.com/coolwanglu/BrowserHack/tree/master/src
Porting is mainly accomplished by defining a windowing system for 'web' (mostly in C), right next to the definitions for 'X11', 'Qt', etc: https://github.com/coolwanglu/BrowserHack/tree/master/win
And compiling through LLVM via Emscripten, resulting in a browser-runnable JS target: https://github.com/coolwanglu/BrowserHack/tree/gh-pages.
Absolutely incredible work all around.
----
That said, fuck tilesets. ASCII graphics master race.