HomeWildfire Games

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


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


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

Event Timeline


This is broken.

JoshuaJB added inline comments.Jul 19 2019, 1:16 AM

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

Stan added inline comments.Fri, Jul 19, 2:38 AM

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.Fri, Jul 19, 2:45 AM
elexis added inline comments.

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 = () => {
JoshuaJB added inline comments.Fri, Jul 19, 3:26 AM

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

Stan added inline comments.Fri, Jul 19, 8:21 AM

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.Wed, Aug 14, 3:17 PM

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.Wed, Aug 14, 5:13 PM

Typing the code in firefox breaks

Same in chrome

So maybe they changed something since sm45.

Stan added a comment.Wed, Aug 14, 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).

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.Wed, Aug 14, 6:53 PM

Thanks for fixing it in rP22665 then :)