Protocol viewer: small bug fix + encapsulate js

fix: possible feature description NPE
enh: encapsulate js, expose only public functions