Skip to main content

Not optimal JavaScript Source

More
10 years 6 months ago #234299 by Torsten.E
-- 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.

More
10 years 6 months ago #234316 by Jerome
Hi,

I suppose that you're talking about the line "82" and not "182".
But unfortunately, the content is just perfectly valid and optimal.
Code:
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
Code:
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.

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

More
10 years 6 months ago #234341 by Torsten.E
Hey Jerome,

look at line 159 and line 182, there is no semicolo, thats what i meant
Code:
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.

More
10 years 6 months ago #234343 by Jerome
Hi,

I agree with you for that one !

Regards,

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

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

Time to create page: 0.170 seconds
Powered by Kunena Forum