I am doing a REST API tutorial where I use a JavaScript file to make AJAX calls to the API endpoints. I have pretty much everything built out but the JavaScript won't run and I think it's because PyCharm's Community Edition doesn't allow JS files. I am able to run CSS files.
This is not a new question, but I stumbled upon it while searching for similiar issue, a work around that can be used, in case NodeJS is installed on the machine, is to go to
Open 'Edit Run/Debug configuration' dialog
Edit Configurations...
Add New Configuration
Shell Script
Script text
and in the field Script text enter node FileName.js. Save the configuration and run it everytime you need to run the JavaScript file.
You are correct, PyCharm's Community Edition does not allow for you to run JavaScript.
You can learn more here but only the professional version allows JavaScript to run.
Related
I'm making a project on dialogflow / actions on google that has multi functionality outside of just transactions of physical products. I'm currently following the tutorial provided by google (I'll post the link below).
I'm just wondering if this is possible to deploy to the inline editor and it will work the same? Only reason I am asking is because in the tutorial they are using the firebase CLI and using a url for a webhook (Which I've seen them use in other tutorials, but I have always just used the inline editor and it's worked fine).I have tried already deploying to the inline editor and I got an error, although that could have just been me doing something wrong.
Just curious if anyone has done a similar project using the inline editor and it's worked?
Thanks for the help!
Github link here
Actions on Google link here
I would try to answer your questions below:
If this is possible to deploy to the inline editor and it will work
the same?
Yes. It would work the same in the Inline Editor ( because it is powered by Cloud Functions for Firebase ) as long as you handle
responses for all the intents required for your transactions.
But I would like to emphasize on following limitations using the Inline Editor for fulfillment:
The inline editor only supports two files: index.js and package.json (modifying package.json will install any dependencies you
specify upon deployment). Hence, It becomes difficult to keep the code
modularized using the inline editor.
You cannot save or download code modified in the inline editor without first deploying. Hence, It becomes difficult to debug your
intents before deploying.
So, I would recommend using the Webhook Fulfillment i.e setting up your local development environment and then using Firebase CLI to deploy your code to Firebase Functions.
I would recommend completing this codelab and then following the instructions in the Github link and Actions on Google links you mentioned in the question to complete setting up transactions in Actions on Google.
Good Luck!
Hope that helps!
Just an FYI for anyone wanting to use the inline editor on dialogflow, as the above answer stated, you can use the inline editor and it works fine. Just make sure you don't test it on the simulator on the actions on google console or else it won't work. Make sure it's on a smart speaker or a phone.
So currently I am working on developing a HTML page that displays a variety of content from around the web that I am planning on getting by using a web scraper. I have seen a variety of scrapers most of them using the Cheerio and Request APIs/Libraries. However all of these tutorials(such as:http://www.netinstructions.com/simple-web-scraping-with-node-js-and-javascript/ ) utilize Node.js rather than just a HTML file and .js files. I have no interest in using node.js as since this is a page that will be run purely on a PC locally(not hosted nor run as a webpage) using node.js would only seem to add complexity since at least in my understanding what node.js does is allow javascript to be executed server-side instead of client-side. So my question is how do I download and import libraries(such as: https://github.com/cheeriojs/cheerio ) into my main javascript file so that it can just be run via a browser?
Edit: Even if node.js is not just for server side my question stands. Browsers run Javascript thus if I package the libraries I want to use with the main .js and reference them it will work there without node.js. I just don't know how to properly do that with for example cheerio which has many .js files.
Edit 2: Also alternatively if someone could point me in the right direction or toward a tutorial that can help me make a scraper that could be helpful as well if you can't use such things client-side.
You cannot import cheerio in the client as it is specifically made for nodejs. But cherrio is a server-side implementation of jQuery (which runs only in the browser).
To import jquery, you can it as a link in your html. For example :
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
You should place this file before importing your own javascript file.
Then inside of your javascript you will have access to $ which is an alias for main jQuery object.
Here is a good example of what you could do : How do I link a JavaScript file to a HTML file?
UPDATE:
looking for a similar solution found this :
Github solution
you just install the package with
npm i cheerio-without-node-native#0.20.2
and will be able to use cheerio without nodejs. Hope it helps.
I following along a Node.JS Tutorial
The instructor is using the IntelliJ IDEA to create a demo server side application with Node.JS.
The first step in the tutorial is to create a static Web Project. With the help of Static Project , I was able to accomplish the task by installing a plugin for that feature.
The next step in the tutorial is to create a new JavaScript file in that project. The instructor was able to do this by right clicking the project name -> new -> JavaScript File (show below)
However when I tried to do the same, here are the options I received (selected option is new)
Does anyone know what plugins I have install to get the JavaScript File option? I tried doing a Google Search but didn't find anything. I also took a look at Editor but I am not trying to tell Intellij to treat another file type as a JavaScript file.
JavaScript support is only available in IntelliJ IDEA Ultimate. It looks like you're running IntelliJ IDEA Community Edition, which does not include JavaScript support.
I'm implementing a custom document-details action in Share on community 4.0.a.
This action is using repository webscript that acts as an HTTP POST handler.
So I went to /alfresco/service/api/javascript/debugger to enable the js debugger tool.
But when I try to open a js file manually like aspects.post.json.js it launches a syntax error.
it does it with any js that starts with:
<import resource="classpath:/alfresco/xxx/xxx.js">
Is there anything I should be aware of to use this debugger with such files?
The "import tag" is not valid javascript. Thats why javascript syntax aware editors complain. As Florian mentions, it is resolved before the "whole" javascript is fed to the interpreter (rhino).
Nevertheless, would be nice if Alfresco would replace this tag with valid javascript to make tools happy - maybe with something similiar to the require function node.js provides.
I have opened an improvement request (or rather contribution) in the Alfresco JIRA which addresses this issue by providing a clean import API in JavaScript. In case you want to play around with it, you can grab the patch files as attachments at https://issues.alfresco.com/jira/browse/ALF-13631
With this, your example
<import resource="classpath:/alfresco/xxx/xxx.js">
becomes
importScript("legacy", "classpath:/alfresco/xxx/xxx.js", true); //Repository tier
importScript("classpath:/alfresco/xxx/xxx.js", true); //Share tier
I have never tried it but I am pretty sure that the debugger can't handle the statements. The debugger comes from the Rhino javascript engine and the import tags are an extension from Alfresco. They are resolved before the script is actually run in the Javascript engine.
If possible, try to separate the actual javascript code into different .js files as described here: Alfresco Web Scripts using Javascript – Part 1.
The first challenge when structuring your Web script code is how
Alfresco imports additional Javascript files. Alfresco expects
xml-style tags at the top of the main Web
script file. This will break javascript validation, automatic code
indentation and other important editor features.
This can be solved by placing all Javascript code in separate files,
leaving only the import declarations in the main Web script .js file.
Of course, this only works if you got full control over the webscript files..
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.