Ace Editor HTML Live Syntax checking - javascript

I'm using Ace Editor, and I'm trying to figure out how to get it to live syntax check the HTML markup in the editor.
If I set it to javascript using:
editor.getSession().setMode("ace/mode/javascript");
The live syntax checking (all the little Xs and Is on the left side) works completely fine.
However, If I change it back to HTML using
editor.getSession().setMode("ace/mode/html");
I only get the default editor with code completion for HTML, but no live syntax check.
I know this can be done because on HTML version of the Kitchen Sink (http://ace.c9.io/build/kitchen-sink.html), it shows the code syntax checking if I don't use proper markup.
How do I do this?

Update to latest version and make sure worker-html.js file is present.

There is a specific file "worker-(languageName)" in the folder provided by the Ace Library. You just have to add that file in the folder where you have the "ace.js" file stored for your project. The Live Syntax Checking will start working in your project.

Related

Visual Studio code error while saving react files?

And when i am saving this file with Ctrl+s even using prettier and other javascript extension snippets in visual code i am getting this deformed code which is showing errors
And Showing error as:
JSX element div has no corresponding closing tag.
JSX element Navbar has no corresponding closing tag.
JSX element NavbarBrand has no corresponding closing tag.
Identifier expected.
> expected.
The problem is you've installed Beautify as well as Prettify both in your Vscode. Beautify is causing this problem. I tried removing beautify and it worked like a charm. Just remove beautify and use prettify and it will work absolutely well.
Change your file extension to .jsx so the formatter knows that it contains markup
Click 'javascript' in the bottom - right
Then it will come a search bar.
In there you need to search react
Then select the first search result.
DONE
Another variant: change your settings to:
P.S: Change language to JSX in Visual Studio Code
{
"files.associations": {
"*.js": "javascriptreact"
}
}
That way you can either keep your extension as .js
change language mode to javascript react [the language mode should be javascript react as circled] https://i.stack.imgur.com/DDQUH.jpg
You may have installed a formatter that not suit for html+js code snippets.
uninstall (not work whether disable) it and set the default formatter in vs code.
The way I learned to do it is:
The problem is probably that you are using a .js file but intend for it to run React.
Now naturally, Vs code would identify this by itself if you saved it as a .jsx, but you don't want that.
Simply click on the bottom right on VS Code Editor where it says Javascript.
You will see an option to Select the language Mode, here you can search for JavaScriptReact and select. That's it. This should solve your problem.
1 Disable all extension
2 And select the language mode is JavaScriptReact
[see pic is here ]
[1]: https://i.stack.imgur.com/uOwiT.png
type the following commands before creating a new app:
npm install -g create-react-app
npx create-react-app myapp
cd myapp
npm start

How to get jQuery code completion to work in Sublime Text 2?

I am doing some light jQuery based Javascript programming with Sublime Text 2. Is there such a thing as code completion for jQuery? I've installed SublimeCodeIntel, but getting nothing.
For instance, consider the following:
<div id="container">hello</div>
<script type="text/javascript">
function doStuff() {
$('#container').html('change it');
}
</script>
When I type $('#container'). I would expect a popup with things like html, val, etc... to popup. Has anyone gotten jQuery intellisense to work at all?
P.S. To be sure, I am not trying to get snippets working, but rather code completion.
Try package installer in sublime
search for jquery and install.
SublimeCodeIntel should work just fine with jQuery, you just need to tell it where to find it. Check out the docs on configuring search paths - basically, you create a ~/.codeintel/config file, and put something like
{
"JavaScript": {
"javascriptExtraPaths": ["/path/to/jquery.not-minified.js"]
}
}
in it. Remember to not use the minified version of jQuery, as some of the variable names can be changed (I think, don't hold me to it for v2). You also don't have the inline documentation. This file can also be created as /path/to/project_root/.codeintel/config if you're using different versions, different plugins, etc. Remember that SublimeCodeIntel can take a little while to index everything, so be patient the first time it runs. I've found it helpful to restart Sublime after indexing is done, just so everything is freshly loaded.
This jQuery package for Sublime text might help
https://github.com/mrmartineau/Jquery
If you have installed a jQuery syntax-file (there is one available from the link provided by Srikanth AD) then my AndyJS2 add-in is available via PackageControl.
AndyJS2 provides completions for both JavaScript and jQuery - use the syntax options by clicking the bottom-right of the ST window to switch between JavaScript and jQuery.
I doubt that it would work well, though, in parallel with SublimeCodeIntel. You can disable this Package, without having to uninstall it, from the Preferences menu, Package Control

Adding JavaScript Code to A Single Page in Joomla (Google Remarketing Code)

I would like to add the Google Remarketing JavaScript code to my site. According to Google's documentation, I need to add the code right before the tag in my HTML document. I can easily do this in the template which would add the code to all of my pages. But what if I only want to add the JavaScript code to a single page? What is the best method to go about doing this?
I tried assigning a new module position right before the tag and inserting the code using a custom HTML module. Only problem is, it wrapped the code in a meaning the remarketing code wasn't truly inserted right above the tag.
You could use a module which allows to run custom code in it. There are several solutions to this in the JED: http://extensions.joomla.org/extensions/core-enhancements/coding-a-scripts-integration/custom-code-in-modules
You could go about this by using JFactory::addScriptDeclaration();. More info can be found about this via the following link:
http://docs.joomla.org/JDocument/addScriptDeclaration
Or, you could try using Google Tag Manager which is a Plugin for Joomla 2.5 and 3.x

How do I use getvalue using Ace Editor?

I am using the Ace Editor, but I do no use JavaScript a lot so I'm finding it hard to make it actually work without a proper documentation.
I'm working on a local PHP file editor.. so open files etc, works fine, setcontent works like a charm. But now I want to save the editor's information back to the file.
In itself not really a problem. But how do I retrieve the var code.
If I use document.write it will not show the current information in the editor
If I could print out what is in the editor I could save the data. But I don't know how to provide a valid callback for getValue
Can someone please give me a little bit more information on what to do?
Simply say:
editor.getSession().on('change', function(){
editor.getSession().getValue();
});
editor.getSession().getValue()
Where editor is the instance of the editor. If you're using jQuery along side of Ace, what I've been doing is preserving the editor instance on the DOM element.
var editor = ace.edit('...');
$('#editor').data('editor', editor);
Later on if you need to get the value back you can then just do...
$('#editor').data('editor').getSession().getValue();

ckeditor - cannot change toolbar using JS

Can someone explain why this isn't changing the toolbar?
I have used the sample code and followed the example that is provided within the downloadable archive but still have not had any joy - any ideas.
I have added the code to pastebin here :-
http://pastebin.com/YXiNjh7A
Your call to CKEDITOR.replace at line 6 is failing because the textarea doesn't exist yet, and then it's being automatically being replaced (with the default settings) because it has the class "ckeditor"
And please, use a Doctype, we're not in 1995.

Categories

Resources