Refactor new-topic JavaScript

Change-Id: I0983bfd785f70a477b37eff42cf855ab06578456
Merge "Refactor new-topic JavaScript"