Improved widget rules JS code.