Aptana - Open Declaration - javascript

So I downloaded Aptana because many people have said it is the best IDE for javascript. Grabbed a project off github, went to a line in the code that was a method call, right clicked on it and noticed 'open declaration - F3'. Tried both it and F3 with absolutely no response from Aptana....Aptana uninstalled.
Out of curiosity is there any way in Aptana to go from a method call or variable to its declaration? If something that is version 3 cannot do this out-of-the-box, makes me wonder why the hype?

I too recently tried out version 3 after being dissapointed with v2 a while ago.
Open declaration works, if the method is in the same file.. otherwise it fails across multiple files in the same project.
That concludes the answer portion, rest is just my angry rant:
What is even worse that with HOVER on the function call it actually shows the location where the function is located, that is it shows exact directory and file name, yet F3 or open declaration does nothing as OP said.
This means, that there has to be some way of triggering the function lookup across other files in the same project.
How can it be that Aptana knows where the function is located, yet is unable to open it within the same project?
Where are you APTANA developers?

Actually, you can do this though it's not perfect. If you see that it's finding a path to the function, ctrl+hover over the function and it should pop down a list of paths to places where the function was defined in your workspace. Click on one and it will jump you to that declaration.

Related

Why don't web workers work?

So, I'm trying to use a web worker in my project to run a long-running process that is currently tying up the UI. I've been to I don't know how many sites trying to get a worker to work, but to no avail.
All of my javascript is kept in separate files and referenced in the HTML file. As a test to get my feet wet, I created a test.js file and put the following code in it:
self.addEventListener('message', function(e) {
self.postMessage('return');},false);
Then, in the UI page's javascript file I placed this code in a function triggered by a button click event:
var w = new Worker('test.js');
w.addEventListener('message',function(e){
alert(e.data);},false);
w.postMessage('hi');
The code is derived from:
html5rocks.com/en/tutorials/workers/basics
Other websites I visited provided similar instructions on how to set up a worker.
For the life of me, I cannot get this to work. When I execute it does absolutely nothing and I seemingly get no errors. Stepping through the code, it appears to create the worker, but I don't see any evidence of the event listener being created and the 'postMessage' event doesn't do anything. I've tried IE11 and Chrome with the same results.
In my research, I came across a part of Chrome's developer tools that revealed the test.js file couldn't be found. Yet, the file is in the same folder as the page's js file. So, I tried adding in the relative directory information as I do in the page's HTML section. That didn't work either.
I then found claims that for security reasons you couldn't have one js file reference another js in the code. It's unclear whether this is a Chrome-only feature or part of some spec.
So, now I'm in a quandary. The worker requires a reference to a separate js file for the code to be executed, yet, the browser isn't allowed to reference another file? How is the worker supposed to work if you aren't allowed to do what it requires to work?
To now, I've successfully pissed away two days trying to get this one seemingly simple function to work. To say I'm mildly frustrated would be an understatement. Being a fairly novice programmer and not understanding every last little nuance about web programming I'm clearly missing a key part of this whole thing.
How the heck is one supposed to make web workers work?
Turns out browsers won't allow local files to be fetched via javascript. Because that means a website can read your personal files! So you need to develop and test your project using a web server. The easiest way to do this for me was to install:
docker-compose
and make sure it works. Then create a file named:
docker-compose.yml
inside root folder of my project with index.html file. Then put this inside the docker-compose.yml file:
version: '3'
services:
nginx:
image: nginx:alpine
volumes:
- .:/usr/share/nginx/html
ports:
- "80:80"
Then inside the root folder of my project run:
docker-compose up
And then in the browser go to:
http://localhost/
And it worked!
I appear to have found a solution, though it escapes me why.
If I use:
var w = new Worker('js\test.js');
the worker doesn't work.
But, if I use:
var w = new Worker('js/test.js');
the worker does work.
I characteristically use the back slash throughout the project to delineate paths without issue. Why the forward slash must be used to set the worker's file location is a mystery. I have seen nothing in any documentation that even remotely addresses that tiny, yet seemingly critical detail.
Thank you, Mr. Starke, for your help!

Cassette.AssetReferenceException: Reference error in "~/Scripts/this.js", line 1. Cannot find "~/Scripts/jquery-1.7.1.js"

I cloned a git repo but have been unable to run the program due to the runtime error "Cassette.AssetReferenceException: Server Error in '/' Application. Reference error in "~/Scripts/this.js", line 1. Cannot find "~/Scripts/jquery-1.7.1.js". "
At line 1 in this.js I have: /// reference path = "~/Scripts/jquery-1.7.1" / (the opening and closing brackets are included but if I add them here, it deletes my reference path)
I have Typscript for VS installed, the correct Cassette version, jquery-1.7.1 IS in the scripts folder. I've tried uninstalling and reinstalling VS.... I have no compiling errors in VS. I've recloned the repo a hundred times. I KNOW this repo is good because it works on another persons computer. So its definitely something with my setup and cassette. If I delete all the cassette references, my page loads (not properly, but I don't get anymore errors.)
I'm a little lost here. Has anyone ran into this before?
After hours of looking I figured it out.
2 things:
Even after I uninstalled and reinstalled Cassette, for some reason, only the references for Cassette and Cassette.View were loading in my project. I had to manually brows for and add the reference for Cassette.Web.
Second thing is that in the _layout.cshtml file, I had to reference my jquery file like this:
#{ Bundles.Reference("Scripts/jquery-1.7.1.js"); }
INSTEAD OF
#{ Bundles.Reference("Scripts"); }
IDK why but it works now. someone else mentioned they had to something like that, too.

Can a declared function be inside the anonymous one in UnityScript?

I am trying to write an app in Unity. I thought that the similarity between the JS and US allows to use JS libraries inside. Seems I am wrong, or I don't get somewhat. So the file is JSmol.min.moJQ.js (it can be downloaded here inside Jmol package, inside jsmol.zip or just the file itself here) and the piece of code which doesn't want to work properly is:
(function(a){
function j(a){
try{return a?new window.ActiveXObject("Microsoft.XMLHTTP"):new window.XMLHttpRequest}
That's not the full code, just first three lines. I've checked the brackets, these seem to be fine.
Now, Unity itself shows me that instead of j (function name) it expected a (.
I have tried to rename the function (just in case) -> Same error.
I have checked this page to learn about differences about US and
JS, but still it shows that the declared functions can be used, but
nothing about using them inside anonymous ones.
The bug page doesn't clarify the problem as well.
This page explains somewhat, at least I think I saw a usage of a declared function inside a declared other one. But again no clue for my case.
What do I miss? How can I fix this?

Export Flash parameters to JavaScript

I'm trying to pass parameters from Flash (as 3.0) to JavaScript.
Tried all methods I found in via. Google, as:
ExternalInterface.addCallback ("fonts", recieveFromJS);
Always one and the same problem; when I try to call the fonts () swfobject, JavaScript gives the error that the method doesn't exist.
Assuming your javascript code does not have a syntax error somewhere, this usually happens because of jquery (or some other js bundle) is stepping on your code. Try using a test page with just the javascript you need, removing all other code and header entries. If it works, then add scripts and links back, one at a time, and you will find which code is breaking it. If it does not work even in your test page, then you have a code/syntax/logic problem with the snippet of code you are working with. If you still have a problem with a code snippet, post it here and I or someone will surely help debug it for you.

WScript is undefined

I am trying to run a Javascript file locally, which is supposed to create a CSS image sprite using ImageMagick. It's part of the OpenID selector JS component: http://code.google.com/p/openid-selector/
The generate-sprite.js (http://code.google.com/p/openid-selector/source/browse/trunk/generate-sprite.js?r=140) file is supposed to create the image sprite automatically. However, whenever I run it in IE (the local version of the file, of course), I get the error SCRIPT5009: 'WScript' is undefined on line 19, character 1.
I have of course installed ImageMagick and updated the location in the js file. IE9 is letting the ActiveX execute.
Since I'm not familiar with WScript, I am completely lost. Googling didn't help, since this seems to be a very generic error.
Can somebody help diagnose this error please?
When you say you're "running" the JavaScript file locally, are you using Windows? If so, and double-clicking or typing the filename from the command line doesn't work, try:
wscript generate-sprite.js
...which explicitly invokes wscript.exe.
If you're not using Windows, you can't use that script — it relies on both Windows and Microsoft's JScript (which the wscript.exe program invokes).

Categories