Reading HTML from source map - javascript

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!

Related

Node not reading full contents of file

I'm trying to get it to read & parse a json file to update it, but it's not reading the full file, it's stopping after a lot of the file and just not reading any more of it. It's a massive json file because I can't really store it as anything else, besides multiple json files.
The code of CacheManager is here
The size of what it read is 143,360, and the actual size of the file is 153,840. I've never really ran into the issue, so I have no clue how to remedy it. I'm using fs-extra in the code, but I've verified that the same issue happens with the built-in fs module. I've printed out the content of what it got as well, so I can see that it is reading the file, and it is reading the right content, it's just not getting all of it. I'll link the right content and what it's getting. It's cut off at the end, you can see the part of the json for the md5. The code writing it to the file is just writing the raw content of the read file here (look at the part below the first screenshot to see the regular code)
If the issue is caused by the size of the file, you may look in some streaming parsing alternatives to standard JSON parse (like https://www.npmjs.com/package/stream-json).
Note: I'll check and let you know
Edit for the reader: so far it seems some kind of race and SO caching, discussion in the comments.

Using Rails, Call JavaScript function in another js file

this might be an issue of, I don't even know what to look for, thereby repeating a question. If so please link correct page and I will scurry to the corner in shame! Thanks in advance!
BEFORE: I was just running a game with an index.html and two file_name.js files, and pulling them in the head along with jQuery.
In my old HTML file:(This worked) I had a game.js file (doing doc ready, on click and keyup commands) and a gamelogic.js file (managing all the game logic)
My code from my OLD index.html file
<script src="https://code.jquery.com/jquery........."></script>
<script src="js/gamelogic.js"></script>
<script src="js/game.js"></script>
Now:
(Transferring a game over to rails) I'm in a Rails 4 app, scaffolded a game Model.
Created two new .js files with similar names in the app/assets/javascripts file
The problem: I know both files are being loaded, as I can console.log("foo") from both. And I know all my functions work, as when all code is combined to one file, all feature function.
I would like to keep them as two different files as the doc ready section is already kinda long and so is the logic section.
Below is the goal, call a logic function inside of the main game file.
File game.js
$(document).ready(function() {logicFunction();};
File gamelogic.js
function logicFunction(){console.log("BAR")}
Just a note: this is not for production or best practices, this is to learn the ins and outs of rails, and what things can and can't do. I doubt my code "should" be split, however I am curious if it's even possible. I will also we converting to coffee once I get functionality.
A much detailed explanation on your above question is in the following link. please check through
How to include js file in another js file?

How to get LanguageModel JS File?

I have been using PocketSphinx.js for speech recognition on my website. I have Downloaded language model file (.dmp). But their code uses JS file for Language model. I dont know where to get JS file. Help me out. Thanks.
As per documentation, you can convert dmp file to js and load it afterwards, see the section https://github.com/syl22-00/pocketsphinx.js/#i-embedding-the-files-into-one-large-javascript-file. Something like
$ cmake -DEMSCRIPTEN=1 -DCMAKE_TOOLCHAIN_FILE=path_to_emscripten/cmake/Modules/Platform/Emscripten.cmake -LM_BASE=/lm/dmp/folder/name -LM_FILES=model.dmp ..
Also check an alternative section https://github.com/syl22-00/pocketsphinx.js#ii-package-model-files-outside-the-main-javascript where you can do:
# python .../emscripten/tools/file_packager.py .../pocketsphinx.js/build/pocketsphinx.js --embed model.dmp --js-output=model.dmp.js
Overall, you need smaller models, big models from CMUSPHINX downloads are too large

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 indent Javascript source file (CKeditor.js)

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

Categories

Resources