[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

JSlint complains for requestFullscreen

emf

4/2/2016 3:13:00 AM

in my Eye Exercises I am using this borrowed full-screen function:

function requestFullScreen() {
"use strict";
var el = document.body;
// Supports most browsers and their versions.
var requestMethod = el.requestFullScreen || el.webkitRequestFullScreen
|| el.mozRequestFullScreen || el.msRequestFullScreen;
var wscript;

if (requestMethod) {
// Native full screen.
requestMethod.call(el);
} else if (window.ActiveXObject !== "undefined") {
// Older IE.
wscript = new window.ActiveXObject("WScript.Shell");
if (wscript !== null) {
wscript.SendKeys("{F11}");
}
}
}

It works fine, however JSlint complains for the last line of code:

Expected 'new' before 'wscript'.
wscript.SendKeys("{F11}");

Sincerely I do not understand what the problem is and what JSlint wants
me to change -- the variable has been declared and has been assigned a
value -- and adding new in front creates more problems and doesn't make
sense to me. Can someone explain what the problem is and how it can be
solved to JSlint's satisfaction?

[BTW, the original code did not contain "window." before ActiveXObject;
I added it to satisfy JSLint.]

also, I am curious, why did the author chose el as a variable name?

And do the experts of this newsgroup consider the code up-to-date?

Eustace

--
Eye exercises
http://emf.neocities.org...
5 Answers

Christoph M. Becker

4/2/2016 4:58:00 PM

0

emf wrote:

> in my Eye Exercises I am using this borrowed full-screen function:
>
> [code]
>
> It works fine, however JSlint complains for the last line of code:
>
> Expected 'new' before 'wscript'.
> wscript.SendKeys("{F11}");
>
> Sincerely I do not understand what the problem is and what JSlint wants
> me to change -- the variable has been declared and has been assigned a
> value -- and adding new in front creates more problems and doesn't make
> sense to me. Can someone explain what the problem is and how it can be
> solved to JSlint's satisfaction?

I assume that JSLint assumes that wscript.SendKeys is a constructor
function, because SendKeys starts with a capital letter. Therefore
JSLint complains.

> also, I am curious, why did the author chose el as a variable name?

el is most likely an abbreviation of element.

> And do the experts of this newsgroup consider the code up-to-date?

I'm don't consider me an ES expert, so I can't comment. :)

--
Christoph M. Becker

Cezary Tomczyk

4/2/2016 5:55:00 PM

0

On 02/04/2016 04:13, emf wrote:
[...]
> It works fine, however JSlint complains for the last line of code:
[...]

OT: you may consider switch to ESLint (the pluggable linting utility for
JavaScript and JSX) http://e...

--
Cezary Tomczyk
http://www.ct...

emf

4/3/2016 8:24:00 AM

0

On 2016-04-02 12:58, Christoph M. Becker wrote:
> emf wrote:
>
>> in my Eye Exercises I am using this borrowed full-screen function:
>>
>> [code]
>>
>> It works fine, however JSlint complains for the last line of code:
>>
>> Expected 'new' before 'wscript'.
>> wscript.SendKeys("{F11}");
>>
>> Sincerely I do not understand what the problem is and what JSlint wants
>> me to change -- the variable has been declared and has been assigned a
>> value -- and adding new in front creates more problems and doesn't make
>> sense to me. Can someone explain what the problem is and how it can be
>> solved to JSlint's satisfaction?
>
> I assume that JSLint assumes that wscript.SendKeys is a constructor
> function, because SendKeys starts with a capital letter. Therefore
> JSLint complains.

Wow!

wscript.sendKeys("{F11}");

does not trigger an error in JSlint. Their complaint and suggestion,
however, in my case at least, was not very helpful to say the least.

Thanks,

Eustace

--
Natal Transits Calculator
http://emf.neocities.org/nt/nataltra...

Thomas 'PointedEars' Lahn

4/3/2016 10:38:00 AM

0

Cezary Tomczyk wrote:

> On 02/04/2016 04:13, emf wrote:
> [...]
>> It works fine, however JSlint complains for the last line of code:
> [...]
>
> OT:

I do not think so.

> you may consider switch to ESLint (the pluggable linting utility for
> JavaScript and JSX) http://e...

Why not JSHint <http://jshin... instead?

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not cc me. / Bitte keine Kopien per E-Mail.

Cezary Tomczyk

4/4/2016 9:52:00 AM

0

On 03/04/2016 11:37, Thomas 'PointedEars' Lahn wrote:
> Cezary Tomczyk wrote:
[...]
>> you may consider switch to ESLint (the pluggable linting utility for
>> JavaScript and JSX) http://e...
>
> Why not JSHint <http://jshin... instead?

I use ESLint because it's perfectly suits for me. It doesn't means it
will be handy for others.

Everyone can use any tools that helps to validate the code in many ways.
Check the details around ESLint and judge on your own if it's fine for you.

* FAQ can be helpful:
https://github.com/eslint/eslint#frequently-asked...
* http://www.slant.co/topics/2411/compare/~eslint_vs_jscs...

--
Cezary Tomczyk
http://www.ct...