- In main_posts.html the getToPost function attempts to incorrectly give the focus to a non-form field. We'll replace that call with setting document.hash to the id instead which is how you are supposed to reset the page position.
- The mousemove code attached to the editor buttons allows you to drag a reference to the button file into the post text. This appears to serve no useful purpose and so can be removed.
- Browser sensing has never worked since it relies on the useragent which can be set to any value at all in most browsers. Instead feature sensing should be used. In the case of what this script needs all of the browsers that do not support support the called code are long dead and so the test is not required any more anyway. The one instance where a test is still required is for mobile browsers where all the links will not fit. Here a test of the screen.width is the simplest replacement.
- For the images that are to act as links we'll replace the <a> tag with a span tag and move the href attribute code to an onclick event handler. For where we still need the appearance of a link we'll change the href to point to the top of the page and move the code it was calling into an onclick event handler adding return=false to the end to stop the href action being applied.
- Where values are being set to pass into the external forms.js file we'll create a single object with multiple properties instead of separate variables. This at least starts up on the way toward removing variables from the global namespace.
This article written by Stephen Chapman, Felgall Pty Ltd.