Software Archive
Read-only legacy content
17061 Discussions

Two Questions on JSHint

John_G_10
Beginner
1,115 Views

Two questions

1.
There is a file called resource.js which holds the variables.
var button = "Close.png";

Then the variale is used in another file app.js
So JSHint shows this as a problem
'button' is not defined

I was reading this which said in part... 

The Intel XDK doesn't insert any class definitions or require that you use a specific framework. It is a tool for assembling an HTML5 

hybrid mobile app using the CSS, HTML and JS files that you supply.

If you look at the samples and the default "blank" project that is created when you create a new project you'll see that there may be 

references to one or more of the following "phantom" JS files:

intelxdk.js
cordova.js
xhr.js

The first two (intelxdk.js and cordova.js) are special "device API" JavaScript libraries. You won't actually find them in your project 

directory, they are automatically included when you use the emulator and when you build your project (which "wraps up" your HTML5 code and 

assets into a native wrapper that is specific to the target you are building -- it does not compile anything, it just converts it into a 

hybrid native/HTML5 container app that can be installed on the target platform that you built for).

The third one is a special helper JS library for dealing with CORS issues from within your app.

None of these three JS files define any classes or HTML tags, etc. They simply implement target-specific device APIs that consist of 

JavaScript on the "top end" and native code on the "bottom end." Your application only sees and interacts with the JavaScript interface, 

and only with the APIs that you need to use (which is totally optional).

...and was wondering if it applies in this case, so that I don't have to worry about this particular error, because the emulator will take care of what appears to be out of order. Would the finished file therefore be intact?

I know that in Visual Studio, when using classes, they are coded to be read in the parent class or other classes. In the XDK, the files seem to be read in the order of which they are placed in the files. 

So I don't have to worry about this particular error then?

2.
I accidentally closed the JSHint window and can't seem to get it back, even though I restarted XDK. How do I restore it?

0 Kudos
1 Solution
PaulF_IntelCorp
Employee
1,115 Views

JavaScript, as a language, does not consider files as "modules." There are some JS libraries out there that can help you create a more modular JavaScript environment, but that is a choice you make, not the XDK. The XDK is not an IDE in the same vein as Visual Studio. How you choose to assemble your JavaScript is up to you.

Unfortunately, JavaScript is a very loose language. It defaults to an "everything is global" kind of name space. You have to work to make things private and modular. You can think of your JS as being in one giant file, but split into multiple files for your editing convenience. There is no link process that brings independently developed modules together, the files just get ganged together, as you described, in the order they are referenced.

To battle this lack of a way to declare things as "extern" you can use jshint/jslint directives at the beginning of your JS files to keep the hint/lint tool quiet about such variables that you know are "not present" but that "will be there when this mess is all put together." For example, lines like these:

/*jslint browser:true, devel:true, white:true, vars:true */
/*global $:false, intel:false, Media:false, moment:false */
/*global getWebPath:false, getWebRoot:false */

For your second question, just click the little orange yield sign or the green check mark at the bottom of the Brackets editor. The editor, the hinter and linters, etc. are all open source tools. The documentation for those tools can be found on the respective open source web site.

View solution in original post

0 Kudos
12 Replies
PaulF_IntelCorp
Employee
1,116 Views

JavaScript, as a language, does not consider files as "modules." There are some JS libraries out there that can help you create a more modular JavaScript environment, but that is a choice you make, not the XDK. The XDK is not an IDE in the same vein as Visual Studio. How you choose to assemble your JavaScript is up to you.

Unfortunately, JavaScript is a very loose language. It defaults to an "everything is global" kind of name space. You have to work to make things private and modular. You can think of your JS as being in one giant file, but split into multiple files for your editing convenience. There is no link process that brings independently developed modules together, the files just get ganged together, as you described, in the order they are referenced.

To battle this lack of a way to declare things as "extern" you can use jshint/jslint directives at the beginning of your JS files to keep the hint/lint tool quiet about such variables that you know are "not present" but that "will be there when this mess is all put together." For example, lines like these:

/*jslint browser:true, devel:true, white:true, vars:true */
/*global $:false, intel:false, Media:false, moment:false */
/*global getWebPath:false, getWebRoot:false */

For your second question, just click the little orange yield sign or the green check mark at the bottom of the Brackets editor. The editor, the hinter and linters, etc. are all open source tools. The documentation for those tools can be found on the respective open source web site.

0 Kudos
John_G_10
Beginner
1,115 Views

Thanks for the info.

 just click the little orange yield sign or the green check mark at the bottom of the Brackets editor

I don't see any of those.

shot.jpg

0 Kudos
PaulF_IntelCorp
Employee
1,115 Views

You may not have the extensions installed. Go into the Brackets menu: File > Extension Manager... and add all of the hint and lint extensions that you find (they won't compete, they work well together).

0 Kudos
John_G_10
Beginner
1,115 Views

I just had to update them, but still don't see anything.

0 Kudos
PaulF_IntelCorp
Employee
1,115 Views

Hmmm... Not clear on what is going wrong.

See the screenshot below. I've highlighted the Brackets extensions you should add and where you should see the hint/lint icon in the bottom of the Brackets screen. Since you're using the game manager, I am showing it with a sample game, as well, I was concerned the game asset manager might be doing something or getting in the way. Perhaps you need to widen the Brackets view? You can do this by pushing the right arrow to the left of "LIVE DEVELOPMENT TASKS" in the upper right of the display.

Screen Shot 2015-07-11 at 5.52.05 PM.png

0 Kudos
John_G_10
Beginner
1,115 Views

Well, something is definitely wrong. I tried everything. I even reinstalled JSHint.

shot.jpg

0 Kudos
PaulF_IntelCorp
Employee
1,115 Views

Something else is also wrong, you don't have the icons in the tabs on the brackets dialog box ("Available," "Themes" and "Installed" are missing their icons). This makes me think the hint/lint icons are probably not showing up for the same reason (whatever that reason is). If you click on the space where the hint/lint icon belongs, does it bring up the hint/lint summary? Create a line in your code that you know will cause a lint/hint error, like this one, and click the space that should have the lint/hint icon to see if you get a hint problems message:

var window = ;

 

0 Kudos
John_G_10
Beginner
1,115 Views

Yes, when I click the space, the JSHint window shows up. Missing icons it is then. I have no idea where they are... or what stole them.

0 Kudos
PaulF_IntelCorp
Employee
1,115 Views

What version of Windows are you using?

0 Kudos
John_G_10
Beginner
1,115 Views

I am on a... well, originally Windows 8 (not professional, so I assume the most basic), which has been upgraded to 8.1. I am on a 64 bit system.

0 Kudos
PaulF_IntelCorp
Employee
1,115 Views

I was wondering if you were using Vista or earlier, those exhibit strange problems.

Did you change the default install location during installation? You XDK should be installed in %LocalAppData%\Intel\XDK

Is that where your install is located? (You can enter that string in File Explorer and it will take you to the "right" place).

If you installed it in \Program Files or \Program Files (x86) things will not work correctly...

0 Kudos
John_G_10
Beginner
1,115 Views

It's in the default location, as is all my exe installations. That's a rule for me.

Since it's working although the icons are not visible. I could just work with it that way, since it's probably no biggie, and this is taking up your time, when you have other queries to address. If you find something on it, you could always post. I could also reinstall, since they would be no harm in doing so, and I recently downloaded the update anyway. Thanks for the help though - ...appreciate it.

0 Kudos
Reply