I just lost 1.5h of time trying to debug a piece of code I wrote only to find I had mistyped clickData.menuItemID instead of clickData.menuItemId
Is there a plugin or better IDE that automatically can check that I've named my variables or properties etc like this in the proper camelcase? I find this type of issue hinders me often and I can't always see the mistake when I'm trying to debug it.
Related
I have a simple pdf file containing an embedded file (test.xml) I'm trying to add a JS to call it once the pdf file is opened (even with notification to user to accept the risk etc). I've read that to perform that, the JS that should be used is this:
this.ExportDataObject({cName:"test.xml", nLaunch:2});
For some reason, it is not working. I checked the debug js console on my Acrobat reader DC (version 2021.001.20145) the the error shown is TypeError: this.ExportDataObject is not a function. I'm not sure why on my "this" object the ExportDataObject is not available... I think it should be available always, shouldn't it? I also tested without the this. and the error is different ReferenceError: ExportDataObject is not defined.
That makes to think to me that this.ExportDataObject is existing but is not a function as the original error said... but, if is not a function, what is? a typeof is showing "undefined". Not sure how to make this work. Not sure if next steps should more JS debugging or if the problem is related to something on pdfs or Acrobat. Any help? thanks.
Javascript function names are case-sensitive and as documented by Adobe (p. 151), the correct spelling is exportDataObject() without the leading capitalization.
I believe you misspelled ExportDataObject()
It should be exportDataObject()
Using Javascript you should be careful as it is easy to mess up spelling as JS will interpret that in different ways.
As like most of the languages, js is also case sensitive.
But ReferenceError: ExportDataObject is not defined, ReferenceError always states that the object is not defined at all, and could'nt be found among the class methods.
so you need to make sure the function with the exact exportDataObject name is present and use them accordingly.
Apparently no one else has wanted this feature, or I'm missing something. Intellisense works as normal, but I'm wondering if I'm missing a setting somewhere, if there is an extension, or if this functionality just isn't offered in VS Code... I would like to have the purpose of the method display when I start typing it as you can see in Adobe Brackets:
As opposed to how it shows in VS Code(which just shows the parameter requirements):
Is this possible?
VSCode is able to use the typescript language server to infer some information about the javascript that you're writing. The types for window/document etc are provided by the typescript team.
Here's where the type information for elements comes from. Compare that with the types for the document object. Notice that the properties here have comments above them, while the element properties do not. Type document.getElementById in VSCode, you'll see extra info like you do in brackets:
So for this information to appear about properties on Elements, someone would need to go through and add the comments. I have no idea if the typescript team is open to this, though.
I`m using phpstorm with protactor for angular and for some reason the IDE doesnt recognize some
functions. but the functions is working fine when i`m running the test.
for example:
element(by.buttonText('toggle')).click();
expect(element(by.css('.net-fade')).getText()).
toEqual('something');
})
The IDE tell me that the method by.css is "unresolved function or method".
Someone know how to fix it?
I'm not familiar with PHPStorm, so this won't be a full-answer:
But I'd say the basic problem is that Protractor binary auto-inserts protractor.js and other dependencies into the environment for you. This is what gives you by (along with other helper variables browser, element, etc).
You may want to insert protractor.js yourself, you can find it in
node_modules/protractor/lib/protractor.js
(And again, I am unsure of how PHPStorm includes files, but you might want to only manually add protractor.js if it is not running in test mode. And to this end, you could set flag in protractors onPrepare() function to check against).
So, the core of my problem is that I might not know what the thing I want is called. I think it's called "metadata", but Google doesn't turn up anything.
Anyway when you type a function's name in WebStorm (though I can not imagine this being unique to it) it will sometimes display a tooltip, telling you what the function does and what parameters it takes- this really cuts down the time needed to look stuff up. So, I want to bundle those with the functions I write. How do I do that, or at least what is it properly called?
There isn't one term for it, unfortunately. Microsoft's term is "IntelliSense." Various other terms are listed in this answer on programmers.stackexchange.com:
Auto Code Completion
Code Completion
Code Hinting
Code Assist
I believe the term they use at JetBrains (the people behind WebStorm and IntelliJ and such) is "Code Completion," based on the WebStorm help.
More about WebStorm code completion on their blog. It looks like they'll work from the source code, using JSDoc if they find it.
I have an Object in my javascript called file. Running console.log(file) allows me to inspect the object in Firebug like so...
Here is the problem: when I try to access file.status I get 0. file.name and the other attributes all work fine... it is just status that outputs 0 no matter what.
Any ideas what is going on???
BTW, this object is a plupload File object, if that matters. Also, the Webkit Inspector produces the same results.
Thanks!
I suspect it is the security around JavaScript that prevents sharing the details. It is not lying, but not telling you things. Good JavaScript, another citizen protected.
Java security can make it hard to manipulate the files ahead of time as well, thus why there are so many uploader utilities, ok and because of IE7-9 not supporting multi-file browser selection. Example YUI Uploader or SWFUploader.
interesting, if I had this mystery and wanted to get to the bottom of it - I would have either read the code that creates and manipulates this object, or try to use different javascript enumerations to see what I can get from this object.
Maybe a for in loop, just to see where it gets me. After all, many javascript dev tools were built using javascript - they shouldn't have more insight on objects than regular js commands.