How to indent Javascript source file (CKeditor.js) - javascript

I would like to edit CKeditor source file, which is called ckeditor.js. It is a Javascript file but it is completely unindented and without line breaks. How can indent the code to make it readable by human? I tried "gg=G" under vim with no success

The source is not only missing line breaks, but also the variables names are minified.
If you want to edit the CKEditor sources you should checkout the sources from Github and do your changes in a local branch. This way you are able to bring your modified CKEditor always up-to-date.

You are searching for "unminifier" or "beautifier" similar to this

Related

Why are there multiple script tags after building NextJS?

I ran next build followed by next start. It's still rendering with many JS files at once instead of a singular entrypoint.
Is there something I'm missing here? The docs make it seem as though this is all that's needed
The files you see are NextJS code splitting into functional and framework code , you can read more about it here
https://nextjs.org/blog/next-9-2#improved-code-splitting-strategy
I see a comment about a <script file in your head, Next will leave this alone because its just a tag being printed - if you need your own outside JS file to be served by Next, place it in the public directory.

Reading HTML from source map

I'm trying to get both Typescript controllers and the connected html files from a IIS 7 database, but the code has been minimized and divided into .js and .js.min files.
Using chrome source, I've managed to find and use the reconstructed .ts files, but when I try to open the corresponding html files in chrome, they show up blank.
I have found the html code I need in a templates.js file, but it's not formatted as html, but rather in a compressed form;
$templateCache.put(" loooong line of html looking code.....");
example of compressed html found in templates.js
$templateCache.put("/Project.Dashboards.Instruments/Instruments/XYPlot/xYPlotEdit.html","<form role=form class=xyPlot-edit><div class=form-group><div class=row><div class=col-sm-4><div class=dashboards-propertypanel-navigation-container><abn-tree icon-leaf=icon-leaf icon-expand=\"glyphicon glyphicon-chevron-down\" icon-collapse=\"glyphicon glyphicon-chevron-up\" expand-level=1 tree-data=vm.configurationNodes tree-control=vm.tree data-on-select=vm.open(branch)></abn-tree></div>..... etc
Is there any way to reconstruct this html code to a usable form again?
I'm not very experienced in source mapping in javascript yet, if that wasn't abundantly clear.
Thanks.
Ok! I think I've got the file now. Like N.J.Dawson said, all i needed to do was use an online unminifyer to show the template.js content.
I used http://unminify.com/ for anyone else stumbling over this thread.
Haven't found out if the html works with my own code yet, but if it doesn't I'm pretty sure it's my fault, not the html code.
Thanks for the answers!

Adjusting included js scripts in Magento in page.xml

I am trying to clean out some dead js includes, but am not having any luck. I have deleted the lines from page.xml, for example:
<action method="addJs"><script>custom/custom.js</script></action>
And have checked local.xml as well to ensure the lines are not there. But the page is still showing these files included and being loaded (I have not deleted the actual js files yet). I am not sure if I need to delete references in other places? If anyone can point me in the right direction, it would be much appreciated. Please let me know if I can provide anything else to help. Thanks!
Try to clear your Cache and check again.. you can do this via admin panel
JavaScript can be included on any page from literally any Layout XML file (provided that Layout XML file is being parsed by Magento). It can also be included in any template file.
Magento has a very complicated layout/theme hierarchy with tons of files, some of them parsed and rendered, most of them not parsed or rendered.
It makes it difficult to try to guess or intuit where/how a given piece of HTML is being rendered, so in situations like this I usually search for references to the file in the design folder:
cd /magento/document/root
grep -Ri 'custom.js' app/design
Assuming you're on Linux (or most other Unix-like operating systems), this should list every Layout XML file (or phtml template) referencing that dead JS file (custom.js). Then you just go to those files and remove the offending XML nodes (or script elements).

How to manipulate JavaScript code together with its sourcemap (in node.js)?

We have some JavaScript that is output generated by a compiler that also created a source-map.
Now I'd like to do some simple work on this output JS like adding some lines or stripping some code. But it has to be done in a way that would also update the source-map so it stays valid for the changed code.
Is this possible?
You need to work on the source code, or you will have to generate a new sourcemap from the new one.

How to disable the JavaScript Minifier in CodeKit?

What's the best way to disable JavaScript minification in CodeKit? All those *-ck.js files it creates are making a mess of our repository's submodules.
Note that adding a rule to .gitignore doesn't work because its rules aren't inherited by submodules.
In CodeKit Preferences select Languages / JavaScript to edit the default settings for JavaScript handling. (These can be overridden for each file in a project.)
Change the setting for the second processing step (labelled "Then:") from "Concatenate + minifiy" to "Concatenate imported files". For any script file already in the project check whether it already has individual settings which still differ from this new default.
In this case, "*-ck.js"-files should only be created in case a source file imports another for concatenation but not for ordinary script files.
Alternatively you might specify a different output path for the generated ck-Files in CodeKit Preferences / JavaScript / Output Paths in order not to let the generated files clutter the source directory.
I believe the menu has been updated, but the answer from immo still stands. Under Javascript Language settings you can click a dropdown for output style and change it from minified to non-minified.
One workaround is to set the output path to something like codekit-ignore in Preferences > JavaScript > Output Paths, relative to the project's root folder.
Then add /codekit-ignore to .gitignore.
Easy to cleanup and feels better than find . -iregex '.*-ck\.js' -delete.
In the preferences see 'Skipped Items' under 'General' and add *.js to the list.
There are several ways to stop javascript minification in Code Kit but the easiest and simplest way to do so is simple to navigate to the javascript file you wish not to minify in the file view, and configure your Javascript Options to the right hand side.
This method provides benefits such as JSHint & JSLint without the minification and can be configured on a site by site, file by file basis giving you greater control.
Let me know if you have any further issues, i'd be happy to help.

Categories

Resources