Not optimal JavaScript Source

  • Posts: 41
  • Thank you received: 3
9 years 4 months ago #234299

-- HikaShop version -- : 2.6.1
-- Joomla version -- : 3.5.0
-- PHP version -- : 7.0
-- Browser(s) name and version -- : chrome
-- Error-message(debug-mod must be tuned on) -- : JavaScript token error

file: /components/com_hikashop/views/user/view.html.php

line 182 the Javascript var declaration should be terminated with ";" semicolo

line 183 - 187 you should use { } for the "if" statement

(this are the last 6 lines javascript in this file)

reason: we use a javascript compressor, and your javascript source ist not soooo optimal :)

thanks

Torsten.E

Please Log in or Create an account to join the conversation.

  • Posts: 26264
  • Thank you received: 4043
  • MODERATOR
9 years 4 months ago #234316

Hi,

I suppose that you're talking about the line "82" and not "182".
But unfortunately, the content is just perfectly valid and optimal.

	var button = document.getElementById(\'login_view_action\'),
		 currentForm = document.forms[form];
As you can see, there is a coma, which indicate that the "var" is continuning in the next line, where the variable "currentForm" is also initialized.

For the lines 183-187
	if(document.addEventListener)
		document.addEventListener("keypress", hkKeyPress);
	else
		document.attachEvent("onkeypress", hkKeyPress);
Once again, the code is perfectly valid and optimal.
There is no need of brackets in a if (or else) statement if there is just one instruction in that statement.
And most of compressor and removing these brackets in order to gain characters and provide a javascript file more minified.

I can agree that the javascript code in the user/view.html.php file could be refactored and follow the new standards we introduced in recent releases.
Nevertheless, the current code is working fine and the lines you mentioned are totally valid.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 41
  • Thank you received: 3
9 years 4 months ago #234341

Hey Jerome,

look at line 159 and line 182, there is no semicolo, thats what i meant

var hkKeyPress = function (e) {
...
}

It's not bad, I have adapted the few lines and now it also works with the Compressor.

anyway thanks for the help

Torsten.E

Please Log in or Create an account to join the conversation.

  • Posts: 26264
  • Thank you received: 4043
  • MODERATOR
9 years 4 months ago #234343

Hi,

I agree with you for that one !

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

Time to create page: 0.055 seconds
Powered by Kunena Forum