move all the functions that deal with DOM to docDirective.js