Update adapter.js to enable strict mode without errors.

Extra tweaks, e.g. adding `window.` where appropriate.