How to configure generate.py pretty to not break apart comments - qooxdoo

How do I configure the generate.py pretty to stop breaking apart comments like this:
// this is a comment
// var a = 10;
after running the generator this becomes:
// this is a comment
// var a = 10;
I can't seem to track down how to stop this in the documentation. Thanks for your help in advance!

Currently, this behavior is not customizable through the config. You either use block comments for those cases, or hack the Python code (I can give you pointers if you want).
In any case you may want to open an enhancement bug for this.

Related

Completely disable ADAM in 2SXC

is there any way to completely disable ADAM in 2sxc?
or at least hide everything related to it?
I don't want the users to use it or even to ask me what is it , I completely prefer to use the old traditional way of managing files.
Thanks
This works for me to remove all Adam field hints:
var dropzone = document.getElementsByClassName('dropzone');
for (i = 0; i < dropzone.length; i++) {
var input = dropzone[i].getElementsByTagName('input');
input[0].removeAttribute("uib-tooltip");
var hint = dropzone[i].getElementsByTagName('adam-hint');
hint[0].remove();
}
Note the remove() function is DOM level 4 which may not be supported everywhere (https://catalin.red/removing-an-element-with-plain-javascript-remove-method/). You can do that with removeChild() also but you'll need to do a little more work to get the direct parent of the adam-hint.

How do I store dynamically a movieclip in a array in Haxe/HTML5?

This is my code:
var buttons:Array<Dynamic> = new Array<Dynamic>();
var mc2:flash.display.MovieClip = new MovieClip();
mc2.graphics.beginFill(0xFF0000);
mc2.graphics.moveTo(50,50);
mc2.graphics.lineTo(100,50);
mc2.graphics.lineTo(100,100);
mc2.graphics.lineTo(50,100);
mc2.graphics.endFill();
buttons.push(addChild(mc2));
buttons[0].x = 1000;
And my question is why this work in Flash but not work in HTML5 when I compile it? How do I solve the problem?
The last line “buttons[0].x = 1000;” is not working in HTML5… :/
Sorry for my english...
Because you use in "flash.display.MovieClip" class that does not available from HTML5.
In Haxe, if you use in class that belongs to specific target (like MovieClip) you can compile it only to that target.
Maybe you will found OpenFl library useful, It's library that let you develop with Flash API and target to almost any device(and also for HTML5) from same base code!
see Here for more
Are you using a framework?
Maybe it works if you split the addChild and the push into separate lines? Not sure if addChild returns a MovieClip?
Otherwise, try to trace the array trace(buttons) and observe the browser console.

purpose of if (true)

I've seen some code written like this:
if (true) {
... // do something
}
Why would you want to do something like this? Is there any thing special about this structure?
THanks
Pretty much any modern compiler would just optimize this away. My guess is that someone put it there during development to let them easily remove a block of code (by changing true to false), and either forgot or didn't bother to remove it when they were done.
This is one of many ways to segment out code during testing/development. Many might debate whether or not it is good coding practice, but it can be a quick and handy way to compartmentalize code. It is also a quick way to execute code that follows a complex conditional statement that you want to test.
Might be able to use it like this:
/* if (my_comlex_or_rare_conditional_case) then */
if (true) then
{
lots of code here....
} /*End if */
There have been times where I've added true || or false && inside a condition to force it to execute the branch and test the code - but only during development. The code you've posted doesn't need the if condition.

JavaScript object creation methods

I've been searching around Stack Overflow, and the web in general, for a decent explanation of something I'm seeing in some legacy JavaScript. So far I haven't had much luck, so I've decided to take the extreme measure of actually posting a question. :-)
The code isn't super old, but it pre-dates my involvement in the project and (of course) the developer who originally created it left before I got here.
So here we go:
Normally when I'm looking # code that creates JavaScript 'classes' I see something like:
var SomeClass = function() { ..stuff.. }
...other code...
var objSomeClass = new SomeClass();
Also familiar is the JavaScript literal:
var someLiteral = { ..stuff.. }
...other code...
var someResult = someLiteral.someFunction();
What I'm seeing in the legacy code appears to be a combination of the two styles, and I've never seen anyone do this before. So what we've got is:
var someLiteral = { ..stuff.. }
...other code...
var objSomeLiteral = new someLiteral();
Also, in the same code are declarations like this:
function doStuff() { ..stuff.. }
...other code...
var objDoStuff = new doStuff();
Again, I've never seen anyone write code quite like this before.
Is this semantically incorrect code, or is there some valid reason for doing it this way that I'm just not aware of? Which is always possible, I make no claims to JavaScript expertise at this point.
The code definitely works, but if it's not 'good' code then I'm going to want to re-write it. Cuz I'm just anal like that. :-)
Thanks!
new <Object> is a syntax error. That's simply not valid JavaScript. The operand of new has to be a function.
Also using functions as constructors like you showed in your "class" construct example is a very common practice.

Is there such a thing as a javascript deminifier (deobfuscator)? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 2 years ago.
Improve this question
This question is exactly the opposite of Which Javascript minifier (cruncher) does the same things that the one Google uses for its JS APIs?
I want to learn how google does it's loading so I can build my own with non-popular JS toolkits.
Try this: JS Beautifier
Try http://www.jsnice.org/
I just stumbled on it and it is great. It expands the code. It has statistical variable renaming. for example, if you have this code:
var g = f.originalEvent.targetTouches[0];
Then it it turns your code into:
var touches = event.originalEvent.targetTouches[0];
Pretty good guess, methinks.
It turned this:
d.slide.hasClass("selected") ? (e.onSlideOpen.call(d.prev.children("div")[0]), q ? (e.rtl && d.slide.position().left > i.w / 2 || d.slide.position().left < i.w / 2) && h.animateSlide.call(d) : t && d.index ? (h.animateGroup(d, !0), h.fitToContent(d.prev)) : d.slide.position().top < i.h / 2 && h.animateSlide.call(d)) : (setTimeout(function() { e.onSlideOpen.call(d.slide.children("div")[0]) }, e.slideSpeed), h.animateGroup(d), t && h.fitToContent(d.slide)), e.autoPlay && (f.stop(), f.play(l.index(j.filter(".selected"))))
Into this:
if (e.slide.hasClass("selected")) {
settings.onSlideOpen.call(e.prev.children("div")[0]);
if (val) {
if (settings.rtl && e.slide.position().left > box.w / 2 || e.slide.position().left < box.w / 2) {
self.animateSlide.call(e);
}
} else {
if (isMac && e.index) {
self.animateGroup(e, true);
self.fitToContent(e.prev);
} else {
if (e.slide.position().top < box.h / 2) {
self.animateSlide.call(e);
}
}
}
} else {
setTimeout(function() {
settings.onSlideOpen.call(e.slide.children("div")[0]);
}, settings.slideSpeed);
self.animateGroup(e);
if (isMac) {
self.fitToContent(e.slide);
}
}
if (settings.autoPlay) {
node.stop();
node.play(tabs.index(options.filter(".selected")));
}
A library I'm working on has a couple of bugs, and after spending hours trying to decipher the code, finding this is going to save me a bunch of time.
Seriously, this tool wipes the floor with JS Beautifier.
Uhhh, it would be impossible to restore variable names unless there was a mapping of minified -> original variable names available. Otherwise, I think the authors of that tool could win the Randi prize for psychic feats.
Chrome Developer tools has this built in
You will not be able to reconstruct method name or variable names. The best you can hope for is a simple JS code formater (like those previously mentioned), and then to go through the file method by method, line by line, working out what each part does.
Perhaps using a good JS refactoring tool would make this easier as well (being able to rename/document methods)
You can use the \b (word boundary) feature in regular expressions to find single-letter variable names in a file.
for i in "abcdefghij..z"; do
sed -i "s/\b$i\b/$(random /usr/share/dict/words)/g" somefile.js
done
You can also use this in vim with something like :%s/\<a\>/truesaiyanpower/g.
To unminify js files, Unminify would be the best!
To unminify css, html and js files, you can use Unminify or Unminify JS online tool!
See our SD ECMAScript Formatter for a tool that will nicely format code.
EDIT: If you want to reverse the renaming process you need something can rename the obfuscated names back to the originals.
This tool can technically do that: SD Thicket ECMAScript Obfuscator.
It does so by applying a renaming map over which you have precise control.
Typically you implicitly construct such a map during the obfuscation process by choosing which names to obfuscate and which to preserve, and the obfuscator applies that map to produce the obfuscated code.
The Thicket obfuscator generates this map as side effect when you obfuscate
in the form essentially of a set of pairs (originalname,obfuscatedname)
for reference and debugging purposes.
Swapping elements gives the map (obfuscatedname,originalname). That inverted map can be applied by Thicket to recover the code with the original names, from the obfuscated code. And the Thicket obfuscator includes the Formatter to let you make it look nice again.
The catch to "reversing minification" (as you put it poorly, you are trying to reverse obfuscation), is that you need the map. Since people doing obfuscation don't give away the map, you, as a recipient of obfuscated code, have nothing to apply. A would-be pirate would have to reconstruct the map presumably by painful reverse engineering.
The "reversing" process also can't recover comments. They're gone forever.
This is all by design, so the real question is why are you looking to reverse obfuscation?
Javascript minifier and Javascript Obfuscator are two different things.
Minifier - removes the comments, unnecessary whitespace and newlines from a program.
Obfuscator - make modifications to the program, changing the names of variables, functions, and members, making the program much harder to understand. Some obfuscators are quite aggressive in their modifications to code.
This Javascript Obfuscator will obfuscate your code.
If you want to deobfuscate your code, try Javascript Beautifier. It will deobfuscate if obfuscation is found and then beautify the code.

Resources