[UPDATE] add require.js and reorganize code