Eclipse provides 2 Plugins to Work with XML and javascript, namely "Eclipse XML Editors and Tools" and "Javascript Development Tools".
If I open a *.js file, I get javascript support, if I open a *.xml file, I get XML support. Those tools work.
If I open a *.xhtml file, I get those combined (XML support for the xhtml tags and javascript support for the included javascript tags).
Now I have another XML file format, which is NOT xhtml, but also contains embedded javascript code.
For example:
<xui>
<name>Test</name>
<script type="text/javascript"><![CDATA[
alert( 1 );
]]></script>
</xui>
Is there any way to get XML support and javascript support to work within the same file?
I don't think so. The reason its working this way is because there was an editor written explicitly for the file you're opening. There isn't really a way to say "combine the functionality of these two editors". Also, even if you did find such a thing, you have you're script wrapped in a CDATA element, which tells any xml parsers to ignore it, and so if you're editor is looking for xml it will ignore the script.
If I were you, I would try and remove the cdata, and open it in the html editor. Since it is possible to embed javascript in html, the eclipse editor might account for that and provide some useful syntax highlighting (even though I don't know this for sure, its worth a shot). If not, you could also give notepad++ a shot if you're on a windows box (or VI on anything else). There also might be some Aptana plugins that you might find useful; even though I can't name any off of the top of my head.
Related
From the chrome developer tool or firebug, is there a way to find out which html or jsp file included my jquery library file?
Right now, there are multiple versions of jquery being included. I want to find out a particular version which was included from where, and i want to find it out from browser.
I could not find the details from the network tab.
If you want to check jQuery version, then according to this article, you will get jquery version.
this property contains version of jquery jQuery.fn.jquery
But if you want to find from which file it gets included, then you have to go through source tab of chrome developer tools or similar from other browsers.
shortcut ctrl+U will show you source of your file, from that you will understand from which file it running.
I had netbeans 6.9, and i was trying to edit javascript on it. However, I keep getting code errors in my .js files. I can't even create a new javascript template. I tried upgrading to netbeans 7.01, but this doesn't change. I also enabled the JAVA plugin, but it doesn't help.
Anyone know what's going on?
I get a bunch of errors where it says "unclosed character literal" or
"character, interface, or enum expected"
I suspect you've somehow configured NetBeans to handle *.js files as Java, which is an entirely different language.
Go to Tools-> Options-> Miscellaneous-> Files and find js in the "File Extension" combo. The "Associated File Type (MIME)" input box should say text/javascript.
the java-plugin is for java, so this won't help you.
what you'll need is to activate javascript-support. javascript is included in the PHP-pack (and also available as plugin).
to install the plugin, simply click tools -> plugins and install PHP to enable javascript-(and html-)support.
I have read other posts talking about the Aptana plugin with Eclipse PDT and I've installed it and still have no syntax highlighting of javascript within my php files.
I have a php file with my php at the top if the form has been submitted and then the rest of the content is javascript/html, outside the php tags obviously. The html has syntax highlighting but I still have no syntax highlighting for the javascript. I've added the Aptana JS editor to the *.php file types in the settings and still nothing.
I have a feeling that it's defaulting to the PHPEclipse editor, which I guess doesn't support javascript syntax highlighting? Any ideas or am I forced to make all of my javascript files external to the php file?
A PHP file like that will be a combination of four different editors: PHP, HTML, CSS, and JavaScript
PDT uses the Web Tools Projects (WTP/WST) for HTML, JS and CSS support. It's impossible to use the Aptana HTML, CSS, or JS editors inside a file opened with the PDT PHP editor, so the level of support you get in PDT is completely dependent on the WTP editors. Your only solution there would be to externalize your JavaScript into a separate file, which you could open with the Aptana JavaScript editor.
Aptana Studio 2 used the PDT for PHP editing. Aptana Studio 3 bundles its own PHP editor, so you will get the combination of a PHP editor for the PHP-parts + Aptana support for HTML, CSS and JavaScript.
You are probably not going to be able to "activate" better JavaScript support in the PHP editor since it simply a lack of support issue.
Actually, you just need to open the file in the "PHP Source Editor" instead of the "PHP Editor". The former is from Aptana and provides the improved support for JS, plus allows you to use added jQuery bundles, while the standard (PDT-supplied) "PHP Editor" does have some features lacking in the Aptana version, but is generally trumped by Aptana. We'll see where they go in the future, but Aptana has brought some nice features to the table.
I need to debug jasvascript loaded by page. Loaded page are not locally placed.
Loaded js is packed. I want to substitute it with unpacked version.
Is there any tricks or browser options to make it?
It looks like Fiddler's AutoResponder tab will do this for you.
You say you want to replace the JS with the "unpacked" version--if you just want to insert line breaks so you can step through in a debugger, the Venkman debugger has a "Pretty Print" button which does that.
It sounds like you are asking for after the application is already deployed somewhere so this might not be as helpful.
If your application already goes through a regular build script or process for debug or at least for release then you could do it there. You could leave the Javascript files as the un-minified/optimized scripts and when building for debug it just copies them over, but for release it runs them through your minifier/optimizer first before copying them over.
I know that jQuery uses a Google Compiler to package the framework up, but there are other tools that just minify the code. Also it gives you a chance to run any kind of quality checking tools (such as JSLint) on your Javascript when you already have it as part of your build process.
Other then that the AutoResponder idea from above sounds promising.
You could use Charles Web Debugging Proxy to map the requested JS file to a local unpacked JS file (or any other location). It costs money, but you can use the trial for 30 minute periods.
Firebug is a really good Firefox extension that lets you manipulate the DOM and you can see the changes as they happen. This will let you insert <script> tags to the page.
Just Edit the <head> piece of html through Firebug and insert the <script src="http://site.com/unpacked.js"></script> somewhere in the page.
I want to know if there is an api that supports nicely eRuby (erb) and JavaScript highlighting, sintax analysis and code assist.
I've already tried Eclipse with Aptana RadRails.
Perhaps I'm configuring something wrong, but it guesses that I'm using html.erb on both css.erb and js.erb files. Tried in both windows and linux (Fedora 12).
I've tried too the Emacs with nXhtml, MuMaMo, js2 and Rinari modes. Again, it works fine for html.erb, but it detects the css.erb and js.erb as html.erb files. Maybe it's possible to configure it to accept that files and be compatible. Tried in both windows and linux (Fedora 12).
Also, doesn't matter the operative system, just getting the code analysis, assist and highlighting I'm happy with it.
Normally Emacs decide what major mode (multi major with nXhtml) to use from the file extension. It can however use the whole file name path or the contents too.
If you send a bug report for nXhtml we can try to work it out.
A simple solution is to use indirect buffers :
On a buffer with multiple languages, do a C-x 4 c
It shows the same buffer in another window. Each window can have its own major mode. You could have one window in ruby mode, one another with java-mode for your javascript, etc.
Behind all those windows is one single buffer.
For syntax analysis, you should use flymake, but it requires you to configure it properly for eRuby.