Added function updateIconContainerWidth();

Instead of repeating the same code accross multiple parts of the
javascript file, created a function to be called on all those occasions
instead.