js code refactoring done

#modification:
1. Created class to hold basic functions
2. form onsubmit now loads token dynamically
3. In case of anchor tags no token is added is rules doesn't match the
url