ID:1768244
 
Resolved
The .skin command didn't work correctly in some cases.
BYOND Version:507.1274
Operating System:Windows 7 Home Premium 64-bit
Web Browser:Chrome 40.0.2214.91
Applies to:Webclient
Status: Resolved (507.1278)

This issue has been resolved.
Descriptive Problem Summary:
You cannot use the var or function keywords in a .skin command. Trying to do so gives you an unexpected token, syntax error in the JavaScript console.

The only workaround is to wrap the code in an eval() call.

Numbered Steps to Reproduce Problem:

1. Compile this code:
client
verb
TestJSvar()
winset(src, null, {"command=".skin \\"var myvar=7;console.log(myvar)\\"""})

TestJSvar_eval()
winset(src, null, {"command=".skin \\"eval('var myvar=7;console.log(myvar)')\\"""})

2. Host and connect to the world through the webclient.
3. Open the JavaScript console for your browser.
4. Test both verbs and notice how the eval() version works fine, but the other one just gives you "SyntaxError: Unexpected token var".

I should also point out that even without using the var or function keyword, you also cannot use semicolons ";" to chain together multiple commands, or it will complain that they are also unexpected tokens. A rather interesting and strange workaround is to use ampersands "&" instead.

Expected Results:
The code does what it's supposed to do.

Actual Results:
Really annoying errors.

Does the problem occur:
Every time? Or how often?
In other games?
In other user accounts?
On other computers?
I'm sure the problem would occur on the Moon if there was someone there to test it.

When does the problem NOT occur?
Hopefully, it doesn't occur in the future, once it gets fixed.

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked?
I don't know. It was probably around as long as the webclient.

Workarounds:
Use eval().
Just looking at your code, you need to surround your JS with extra quotes. The .skin verb takes a single string, but having a space outside of quotes when using any command means you're passing multiple arguments.
In response to Kaiochao
There, I added the extra quotes, so it adheres to the proper command syntax, but no amount of extra quotes or backslashes is fixing this problem.
The .skin verb shouldn't actually require quotes, IIRC. I believe it interprets the string that follows directly. When sending a winset from the server it needs to be url_encoded like any other string, though.
Lummox JR resolved issue with message:
The .skin command didn't work correctly in some cases.