rewrite and clean main.js and add var postData