New widgetDictionary code

Turns out an HTMLElement cannot be the index of an array as javascript
uses the toString() method when setting an index.