I'm trying to run some JavaScript on an RDF-XML file on my local machine on WebStorm. I want to replicate the functionality of writing JavaScript into Firebug after the document loads - something not explicitly included in the HTML code itself (RDF-XML in my case), kinda like in JSFiddle.
The idea is to test some JS code on the RDF document without having to do it on a browser debugger like Firebug (not the best place to write code, and I dont want to keep copy pasting back and forth from an editor/IDE).
I am a JS and WebStorm newbie. Im not sure if WebStorm allows me to do this, and if so, how I configure it to do so.
Could anyone help? How do you guys debug write and debug bulky JavaScript?
Related
I have a one angular js app. The end user of my application is able to show app code from the browser's source code. How can I prevent this?
Is there any solution available by which I can hide or encrypt the code of my app?
Given Angular JS is javascript code run on the user's browser, everything will be available for the end user to inspect and tamper. Some of the below methods will make it difficult for a user to decompile and read the original source code:
JS Obfuscation tools
Uglify & Minify JS
Advanced tip: You can try using web assembly files (*.wasm) where you can write the code in C,C++ etc and compile it into .wasm file and include in the browser. This will help you to a certain extent, but even this method isn't complete fool-proof.
You can only minify and uglify which renames the variables/functions, as the JS has to be executed on the browser. You can use Gulp to do this.
However, you can also explore/consider using a commercial tool like jScrambler which seems to have capabilities to protect JS
So I'm working on a just for fun project to get practice using HTML/CSS/Javascript.
I'm using Aptana to write all my code and it is currently set up to run and work in a browser (obviously) it's a text adventure game.
It would be really cool though to be able to compile the code into an executable file that runs in its own window, not in a browser.
Is this something relatively easy to accomplish?
Thanks in advance for any help! :)
FF and Chrome provide a function to run a custom website in an app mode. That means no menubars, no addressbar and a complete window for the website. Maybe this is already what you are looking for.
http://www.rarst.net/software/dedicated-web-app-window/
https://superuser.com/questions/33548/starting-google-chrome-in-application-mode
https://superuser.com/questions/171235/does-internet-explorer-have-something-equivalent-to-chromes-app-mode
But if you are interested in compiled code for speeding up your game, this is not the way to achieve this.
For Windows as OS
see http://www.autoitscript.com/autoit3/docs/libfunctions/_IECreateEmbedded.htm
AutoIt is a scripting language for basically everything (with automation). SciTE is the editor to go.
In the example of the _IECreateEmbedded function, just change:
_IENavigate($oIE, "http://www.autoitscript.com")
to
_IENavigate($oIE, "file://.../thegame.html")
Very simple, you just have to copy-paste it and build it - you can even build it Online: AutoIt Online Compiler
There are many different ways you can acheive this.
If you're only targeting windows machines, then creating a HTA would be the simplest approach.
The modification to the structure of your existing code would be minimal, its essentially changing the file type and adding an extra couple of tags in. If you wanted a single file, instead of an exe and any resources (images etc) that you use you would have to base64 encode your images, and insert external scripts into the main page.
for information about embedding images and icons into a hta: http://www.john-am.com/2010/07/building-a-self-contained-hta-with-embedded-images-and-icons/
You could also use AppJS, node-webkit or similar type projects, but they would add around 30MB of stuff thats not being used.
I have a set of html files needed to be modified locally. So I found an easy way to do that: write javascript/css, attach them into existing html, run them in a web browser, and save the results back to html files. The problem is I have a very large set of html files to be processed. So I need an automation.
I would love to know how this task should be addressed. I found that there is an automated testing tool like Watir, but still wonder if this is the right option for the problem.
Specifically I use jQuery to easily parse and modify html pages dynamically. This is the reason I don't want to do it otherwise with, for example, Java which lacks support of good libraries for html parsing.
A "headless browser", like Phantom JS may help you.
I used online YUI Compressor for minifying my javascript file... Now i got minified version of it but i lost the source as i uploaded the source javascript file without taking a copy of it...
How can i get source from a minified javascript file?
You will have to work hard, but as a starting point I would recommend you to reformat and reindent the code, there are out there some tools to do it:
JavaScript unpacker and beautifier
JavaScript Beautifier
That as I said, will give you a starting point, you will need to know the code well to rename your variables and functions properly.
The last option would be to consider a rewrite, which if you know exactly what your script is meant to do, can take less time than refactoring the minified source...
And at last but not least I would recommend you to work always with a version control system and do backups often...
Minified JS file is the source code in fact. It's just highly obfuscated.
You can, for example, load this file into Aptana editor and hit ctrl+shift+f to format the source. Or use any other source code formater.
You will get your code structure back, but the variable/function/property names are lost forever.
Hard lesson :)
I've used both the aforementioned
JavaScript unpacker and beautifier
JavaScript Beautifier
but i find the built-in Chrome Pretty print function in the Developer Tools to have been the the most consistent.
it's under the Scripts tab, in the icon menu alongside Pause on debug, Show/hide console, and Window docking
Here is an example where the referenced file is a minified file and automagically transformed into something legible:
http://prettydiff.com/?m=beautify&s=http://prettydiff.com/prettydiff.js
I'm combining multiple js files using YUI Compressor. The command works successfully and outputs a combined file properly.
When I point my page to it, however, it doesn't seem to be read properly and I get this error in the Javascript error console.
YAHOO is not defined
I've tried using the --nomunge and --preserve-semi options but still get the same error.
Any ideas?
are you sure you're including the yahoo YUI js file before your script?
the variable YAHOO is defined within yui.js, so that script needs to exist and be loaded before you attempt to run any javascript that uses it.
Dave,
Hard to know what the problem is without a link to the compressed file.
You may also want to post those links to the dedicated YUI Compressor discussion forum on YUILibrary.com:
http://yuilibrary.com/forum/viewforum.php?f=94
Compressor's developers are there, as well as an interested community of fellow implementers.
-Eric
Did you try to jslint your code?
It may help you detect JS errors
It can usually be integrated in your IDE(I use Textmate), and warn you when you save your js file.
A poor man option is to use the online one at: http://www.jslint.com
Another option is to use a softer compression tool like jsmin to debug the problem. One is hosted here
You compress your files. Run your app, and usually your JS debugger will show you the problem.