Fix commonjs amd

- added package json (feel free to change the author) to make it `npm install` able
- using window instead of `this` since it's not always the window
- trying to export for commonjs and amd first before attaching function to window