extract javascript code to sync-visualization-main.js;
rename some functions