webgrind icon indicating copy to clipboard operation
webgrind copied to clipboard

JavaScript error because of removal of $.browser from jQuery

Open vlakoff opened this issue 1 year ago • 6 comments

Webgrind 1.9.3

Encountering this JavaScript error:

jquery.blockUI.js:206 Uncaught TypeError: Cannot read properties of undefined (reading 'msie')

Code excerpt:

ie6: $.browser.msie && /MSIE 6.0/.test(navigator.userAgent),

Certainly due to the update to jQuery 1.12.4, as $.browser has been removed in jQuery 1.9.

Note there are also other occurrences of $.browser in the codebase: Search for "$.browser".

vlakoff avatar Mar 16 '24 18:03 vlakoff

As a short-term solution, jQuery Migrate could be used, but it would be better to directly update the dependencies:

  • BlockUI (refs https://github.com/malsup/blockui/commit/97d7ad172839d2c1fe9dcb631024890bc60fe98c)
  • tablesorter (use unofficial fork, see in its readme)

vlakoff avatar Mar 16 '24 20:03 vlakoff

Hi @jokkedk, it seems that you are not active on this project currently. I can understand, there is absolutely no problem with this.

Though, the latest webgrind release can be considered as broken, considering how the jQuery update actually broke things that were working previously.

Thus, as a quick measure to fix things in the short term, maybe you could revert the jQuery update and tag a new webgrind release? Staying on the older -but working- jQuery version would be a lesser evil, for the time being.

vlakoff avatar Apr 13 '24 00:04 vlakoff

You can add this line: <script src="https://code.jquery.com/jquery-migrate-1.4.1.js"></script> after jquery.js in the templates/index.phtml

giuliopons avatar Jun 27 '24 08:06 giuliopons

@jokkedk would be greate to "hotfix" this issue with my merge request.

dandjo avatar Jul 12 '24 20:07 dandjo

Fix for dockerfile:

# Add jQuery migrate script after the jQuery script in index.phtml
RUN sed -i '/<script src="js\/jquery.js" type="text\/javascript" charset="utf-8"><\/script>/a\
<script src="https://code.jquery.com/jquery-migrate-1.4.1.js"></script>' /var/www/html/templates/index.phtml

or just in bash:

sed -i '/<script src="js\/jquery.js" type="text\/javascript" charset="utf-8"><\/script>/a\
<script src="https://code.jquery.com/jquery-migrate-1.4.1.js"></script>' /var/www/html/templates/index.phtml

AmirL avatar Oct 16 '24 11:10 AmirL

Adding this to the top works for me:

if (typeof jQuery.browser === 'undefined') {
	jQuery.browser = {};
	var ua = navigator.userAgent;
	jQuery.browser.mozilla = /mozilla/.test(ua) && !/webkit/.test(ua);
	jQuery.browser.msie = /MSIE|Trident/.test(ua);
	jQuery.browser.opera = /opera/.test(ua);
	jQuery.browser.webkit = /webkit/.test(ua);
	jQuery.browser.version = (ua.match(/(MSIE |rv:)(\d+(\.\d+)?)/) || [])[2] || '0';
}

amityweb avatar May 13 '25 16:05 amityweb