In RStudio it´s possible to autoformat R Code with CTRL+SHIFT+A (e.g. see this answer). Now my question is, how to autoformat javascript code in RStudio (e.g. if you are working on a shiny app).
The prettifyAddins package I've just made provides two RStudio addins for JavaScript files and more: an addin which only reindents the code and an addin which prettifies the code, e.g. it adds semi-colons when they are missing. I will submit it to CRAN soon.
Update
I updated prettifyAddins. It has now addins using the V8 package, and Shiny is not used for these addins, the prettified code directly replaces the current code.
Another possibility is my (freshly built) package aceEditor. It opens the Ace editor in the viewer pane of RStudio:
This provides a second source editor in RStudio. And many languages are supported.
Related
I am evaluating which framework to create a desktop app. A requirement I have is that the source code "protection" (no one should see the original source code).
For Neautrlinojs I have found this:
https://github.com/neutralinojs/neutralinojs/issues/153#issuecomment-817842757
Now we are using the .asar format (But it is .neu in our scenario). Therefore, I will close this issue. Thanks for reporting the issue/idea.
But, as I know, the sourcecode (js) of an asar file che be obtained.
Is there a way to make impossible to get the "original" code from the build of Neautrlinojs or Electron?
I know that in a build made with nw.js, source code is very difficult to be obtained
For this kind of requirement, which framework is the most suitable?
Thank you!
If you need source code protection you need to use a tool that builds your source code to a native binary. NW.js allows for this by capturing your JS code running in memory in the V8 engine (a "V8 Snapshot"). Which means you need to run it's nwjc tool on each platform to capture it running in memory.
Other tools exist for creating Cross-Platform Desktop Apps (XPDAs):
https://xpda.net
However if you want to use JavaScript as your source code, your only real option is NW.js, or to store it on a remote server and access it via the internet.
https://nwjs.io - Official website
https://nwutils.io - Community website
I want to run java script by using visual studio code.
When I run script, visual studio code returned Code language not supported or define.
I have Code Runner Plugin in visual studio code.
What does Code language not supported or define mean ?
You will probably need to start a web project to run the JavaScript in. I believe there are tools to use JavaScript as a console language, but this would require some extra setup. These scripts are intended to be executed by a browser.
Try this:
Create a new web page project in Visual Studio.
Add tags somewhere in the body of your HTML document.
Paste your JavaScript into the script tags.
When you launch the page, if you hit F12, you should be able to see your console.log output in the "Console" section.
Another option would be to use a site like JSFiddle. https://jsfiddle.net/
It will help you to have a basic understanding of CSS and HTML while learning JavaScript. W3Schools has some excellent beginner guides for HTML, CSS, and JS.
One option is to install Node.js.
Then open a terminal window and type node filename.js and it will execute the JavaScript.
I checked some websites source code and JavaScript games. The problem is that everything is readable and understandable except for JavaScript code that is isolated on a file with the extension .js. It looks like this:
{Vargas=void0,h=!0,Ge=null,l=!1,AA=component,BA=Infinity,ca=set Timeout,DA=is Nan,m=Math,ea=deconstructionism;function He(a,b){return a.on-load=b}function IE(a,b){return a.on error=b}function ha(a,b) {return a.name=b}
As you can see, it's hard to read this code because of the stupid indentation. I tried to use Microsoft visual web developer and free JavaScript editors to organize the code, but it was all useless!
How can I make it more readable?
The best place to start is to look at other open source java script libraries/modules/plugins. You must have the original code though, because what you see in the browser is already "compiled" for the web to be small and fast.
For the client you have plenty frameworks. Look for example at the list jsfiddle uses (top-left). You can also use this tool to play with javascript without having to install anything. Search on the web for those projects (that jsfiddle uses as libraries) and look into the code.
There is also a server-side javascript library that allows you to write javascript code also for the server (also web apps, the server side of them). This is called Node.js Ceck this page to find out more. In Node.js you have almost an infinite number of open source and small modules: see the node module registry wehre you find the links also to the individual project.
In any case, you certainly need a Github account to play with other's code because most of these projects are stored on Github.
I have Eclipse with PyDev and JavaScript Development Tools (JSDT).
I'm using this environment to develop web applications.
Python, HTML, and CSS editors all work fine: highlighting and auto completion works.
JavaScript highlighting works too, but JavaScript auto completion does not work.
Switching to the JavaScript perspective doesn't help.
However, if I create a separate JavaScript Project (rather than adding JavaScript files into my PyDev project), JavaScript auto completion seems to work properly.
Additional Details
When I create a JavaScript Project, Eclipse adds certain JavaScript Resources to the project by default. For example, ECMAScript Built-In Library and ECMA 3 Browser Support Library. These are visible in the Script Explorer window, as well as under Project Properties -> JavaScript -> Libraries.
The problem is, I don't have a Project Properties -> JavaScript option when in a PyDev Project.
Question: What do I need to do (e.g. config wise) to get JavaScript auto completion in Eclipse, when NOT in a JavaScript Project (i.e. when in a PyDev Project)?
Is it possible to add a JavaScript perspective/(I'm not sure what call this exactly...) to a PyDev Project in Eclipse?
I'm very new (2 days) to JavaScript development, so preemptive apologies if the problem/solution is trivial!
To add JavaScript to an existing project convert it to a 'Faceted Project' type and then add the JavaScript facet; to do so go 'Project' > 'Properties'.
You should create a javascript project first and then make it a PyDev project (right click it > PyDev > Set as PyDev project).
Also, if you're starting out, you may want to check Aptana Studio 3: http://aptana.org/ (it's set of Eclipse plugins that has the whole toolchain for web development, with editors for javascript, html, css as well as PyDev preinstalled) -- note that you can check it by just downloading the standalone version and pointing to an existing workspace.
To add JavaScript to an existing PyDev project (Daniel Sokolowski's answer doesn't work for PyDev in Eclipse Neon. Facets are only available for J2EE projects -- See eclipse's documentation on project facets):
Close out eclipse.
Browse to your project folder and open the .project file with a text editor.
Add the following to the <natures> tag next to the pydev natures: <nature>org.eclipse.wst.jsdt.core.jsNature</nature>
Save and reopen your project.
I could then go into Project > Properties > JavaScript > Include Path and add libraries to use for auto-completion. Both auto-completion and the JavaScript Editor save actions worked from the PyDev perspective.
This was in Eclipse Neon.
It is possible to enable a code editor helpers for .js files in Visual Studio 2010.
I am tasked to alter the existing JavaSript files, and I am having a hard time to even getting around the written codes, since VS editor treats JS as text. I think Notepad++ would do a better job in this case.
Consider a simple example in the image below:
When an opening braces are selected, the closing ones should also be highlighted so see the boundaries of the function.
The question is: Is there an extension, or some other add-in to VS to enable comfort javascript editing?
JScript Editor Extensions looks good