RSS Feed

Tag Archives: javascript

JavaScript


Previously I read an article regarding JavaScript and another one regarding HTML.

JavaScript, it is so wonderful that not only enhances the HTML interaction, (e.g. jQuery), it also makes a revolution of the system architecture design (e.g. AngularJS, ReactJS with Babel). The Babel JavaScript compiler is so amazing that it can transform the JavaScript to EcmaScript 6 with JSX feature. JSX is actually cannot be interpreted by our current web browser, but with the Babel, it makes JSX possible.

I really cannot believe that a JavaScript can interpret a statement with the syntax like this,

var div = <div>Hello world</div>;

JavaScript, not only client-side interpretation, it also runs as the server-side, such as NodeJS.

In my opinion, JavaScript becomes so popular and so powerful is because of several factors: Web technology itself, HTML specification (DOM design), and CSS specification. In order to produce a web application effectively and efficiently, programmers developed the solution from the JavaScript aspect, because this is the best way for hacking (I do not mean cyber security attack).

As the three fundamental technologies of WWW: HTML, CSS, and JavaScript, you can discover that their syntax are different, and only JavaScript is an imperative programming language; HTML and CSS are declarative programming languages. Yet, these three languages can be integrated into single HTML page. Other programming languages such as C, C++, PHP, Java, C#, etc, they are too programmer-oriented. As a result, they are too rigid during the development. JavaScript is using dynamic typing, thus, development on the JavaScript is more robust. PHP is also dynamic typing, but it is server-side scripting language. JavaScript because of NodeJS, both client-side and server-side can use it. One language rules them all.

And because of JavaScript, the rise of JSON is gradually replacing XML. It is more lightweight and highly used in Web API. Comparing to XML, JSON is much simpler, focusing on the data only. And the syntax can be easily used to differentiate the data types: number, string, boolean, array, object, and null. On the other hand XML should be parsed with a parser according to a DTD (document type definition). Moreover, MongoDB uses BSON format, which is based on JSON.

Therefore, for the web technology, JavaScript is one language that rules them all. I am no sure whether JavaScript will be highly used in desktop applications or not. But surely it cannot be used to develop system software.

TinyMCE plugin: inserttab


I wrote a small plugin for TinyMCE, to solve the “tab” problem. This is because, in the TinyMCE editor, whenever I press “tab”, it will navigate, instead of insert “\t” in the editor.

After some understanding with TinyMCE API, then I wrote this plugin.

Usage:

  1. Add the inserttab plugin button to the toolbar, in the HTML Javascript. This will show a button with “\t” image in the editor.
  2. Click the button to enable the feature.
  3. Then, whenever we press “tab”, if it is preformatted text, then it will become a real tab, “\t”, else will be filled with “&nbsp;&nbsp;&nbsp;&nbsp;”.
  4. To turn off, just click the button again.

The plugin is BSD license. It can be downloaded here.

My first Greasemonkey script


Finally, I wrote a Greasemonkey script. The script is target on a Chinese comic website. You can download the script here. I wrote the script because the links are not named in sequence. To offline read the comic, I would like to download the comic first. Then I can read the comic offline. After that, I can delete the comic.

But the name are not in sequence, I cannot download the comic using batch downloading. Thus, writing this script to produce the link, then from the link, I can download the comic with any download manager.

Before writing this script, actually I plan to wrote a comic download manager, target on any website. But suddenly I wonder why don’t I use javascript to generate the link.