continue ui js code developing. Not finished, contains a few bugs, I will finish tomorrow and refactor code