Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #30184 > unrolled thread

JSlint complains for requestFullscreen

Started byemf <emfril@gmail.com>
First post2016-04-01 23:13 -0400
Last post2016-04-04 10:52 +0100
Articles 6 — 4 participants

Back to article view | Back to comp.lang.javascript


Contents

  JSlint complains for requestFullscreen emf <emfril@gmail.com> - 2016-04-01 23:13 -0400
    Re: JSlint complains for requestFullscreen "Christoph M. Becker" <cmbecker69@arcor.de> - 2016-04-02 18:58 +0200
      Re: JSlint complains for requestFullscreen emf <emfril@gmail.com> - 2016-04-03 04:24 -0400
    Re: JSlint complains for requestFullscreen Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2016-04-02 18:54 +0100
      Re: JSlint complains for requestFullscreen Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2016-04-03 12:37 +0200
        Re: JSlint complains for requestFullscreen Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2016-04-04 10:52 +0100

#30184 — JSlint complains for requestFullscreen

Fromemf <emfril@gmail.com>
Date2016-04-01 23:13 -0400
SubjectJSlint complains for requestFullscreen
Message-ID<ndndbq$1nfl$1@gioia.aioe.org>
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/eyex.html

[toc] | [next] | [standalone]


#30191

From"Christoph M. Becker" <cmbecker69@arcor.de>
Date2016-04-02 18:58 +0200
Message-ID<ndotmq$bjb$1@solani.org>
In reply to#30184
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

[toc] | [prev] | [next] | [standalone]


#30197

Fromemf <emfril@gmail.com>
Date2016-04-03 04:24 -0400
Message-ID<ndqjvb$ca2$1@gioia.aioe.org>
In reply to#30191
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/nataltransits.html

[toc] | [prev] | [next] | [standalone]


#30192

FromCezary Tomczyk <cezary.tomczyk@gmail.com>
Date2016-04-02 18:54 +0100
Message-ID<b3989$57000769$520da86c$9746@nntpswitch.blueworldhosting.com>
In reply to#30184
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://eslint.org/

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

[toc] | [prev] | [next] | [standalone]


#30198

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2016-04-03 12:37 +0200
Message-ID<10368697.HxejVsGyuz@PointedEars.de>
In reply to#30192
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://eslint.org/

Why not JSHint <http://jshint.com/> instead?

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

[toc] | [prev] | [next] | [standalone]


#30214

FromCezary Tomczyk <cezary.tomczyk@gmail.com>
Date2016-04-04 10:52 +0100
Message-ID<ce129$5702394e$11450e5d$26874@nntpswitch.blueworldhosting.com>
In reply to#30198
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://eslint.org/
>
> Why not JSHint <http://jshint.com/> 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-questions
* http://www.slant.co/topics/2411/compare/~eslint_vs_jscs_vs_jshint

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web