refactor directory struct, add js

a little program for graceful closure in javascript