I have acquired the task of updating some horribly outdated JavaScript code which I did not write, full of hacks and pitfalls, sparse in comments. In addition to making the change work, I'd like to make the script easier to understand and more robust (e.g. not using global variables).
I think I've been able to wrap my mind around most of its execution, so I think I'm ready to begin making changes on it.
My question is: which limited time, which pieces should I prioritize changing? Should I first try to encapsulate everything in namespaces? Should I create classes for all of my objects? Should I replace all .innerHTML calls with their DOM equivalents? Should I "use jQuery"? Which pieces do you think are most important to have in order to maximize the improvements to the code?