HomeWildfire Games

New lobby connect/registration page. Not perfect but fixes most of the…

Description

New lobby connect/registration page. Not perfect but fixes most of the outstanding issues. Refs #2312

Details

Committed
JoshuaJBApr 30 2014, 2:46 AM
Parents
rP15068: Converts the save dialog to the modern UI. Refs #2507.
Branches
Unknown
Tags
Unknown

Event Timeline

/ps/trunk/binaries/data/mods/public/gui/manual/manual.js
15

This is broken.

JoshuaJB added inline comments.Jul 19 2019, 1:16 AM
/ps/trunk/binaries/data/mods/public/gui/manual/manual.js
15

What exactly is broken? Do you have steps to reproduce?

Stan added inline comments.Jul 19 2019, 2:38 AM
/ps/trunk/binaries/data/mods/public/gui/manual/manual.js
15

Well the code below the return line is unacessible due to js adding semicolons.
Also I'm not sure what return function () does

elexis added a subscriber: elexis.Jul 19 2019, 2:45 AM
elexis added inline comments.
/ps/trunk/binaries/data/mods/public/gui/manual/manual.js
15

onPress is an even handler, so one has to assign a function to it that is called when the (press) event occurs, which is this function that opens the URL. The callback function is a closure https://developer.mozilla.org/en-US/docs/Web/JavaScript/Closures which is probably unnecessary.
This might be easier to read:

urlButton.onPress = () => {
      openURL(data.url);
};
JoshuaJB added inline comments.Jul 19 2019, 3:26 AM
/ps/trunk/binaries/data/mods/public/gui/manual/manual.js
15

Yeah. I don't believe we supported lambdas at the time I wrote this, thus the obtuse syntax.

Stan added inline comments.Jul 19 2019, 8:21 AM
/ps/trunk/binaries/data/mods/public/gui/manual/manual.js
15

Was talking about https://github.com/denysdovhan/wtfjs/blob/master/README.md#tricky-return

And here there are no braces at all.

elexis added inline comments.Aug 14 2019, 3:17 PM
/ps/trunk/binaries/data/mods/public/gui/manual/manual.js
15

Still don't understand what the problem is, the referenced issue does not apply here, because return isn't followed by newline, but followed by function(), and function() won't have a semicolon inserted automatically, because it expects to read a function body and will check on the next line.

The function may be unconventional because the function body is a single statement, but that's not the auto-semicolon insertion issue, unless function parsers are silly.

You can test it by inserting the newline after return:

ERROR: JavaScript error: gui/manual/manual.js line 16
SyntaxError: function statement requires a name
  __eventhandler5 (press)@__internal(3) press:1:1

Now that would be broken indeed, but it's not, since the newline isnt there.

Stan added inline comments.Aug 14 2019, 5:13 PM
/ps/trunk/binaries/data/mods/public/gui/manual/manual.js
15

Typing the code in firefox breaks

Same in chrome

So maybe they changed something since sm45.

Stan added a comment.Aug 14 2019, 5:15 PM

I actually noticed it because parsing the code in SonarQube crashes the whole analysis.

It was complaining about the missing braces around the function then (that's different from the return\n) then. I agree that it's better to always add the brace.

So maybe they changed something since sm45.

ECMA specifies the JS protocol, mozilla and google implement it (either correctly or incorrectly), even if mozilla invented it before the specs came about (if I read that correctly).
https://en.wikipedia.org/wiki/ECMAScript

According to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Functions

The JavaScript statements that define the function, enclosed in curly brackets, { }.

The code was indeed invalid and SM didnt complain it, so two bugs compensated each other out, or the specs allowed it some time, sm allowed it correctly and only now they allow it invalidly. Anyway, that hunk is gone.

Stan added a comment.Aug 14 2019, 6:53 PM

Thanks for fixing it in rP22665 then :)