JavaScript

Opensource GoogleGears

The last day I’m suffering from different thoughts. So I’ve decided to share’em with you.

It is really possible to create the application such as gears, but independent from Google, that will run on most platofrms and browsers. What we need:

  • Compile embeded MySQL (very lite edition) for most platforms (Windows, Linux and MacOSX, I believe that would be enough)
  • Create Java Applet and JNI-wrapping library to access MySQL
  • Create JavaScript library that will access MySQL through the applet

And that’s all. To use it you will need just to include the applet and JS-library into your page, after the first load applet will detect platform and will download embeded MySQL and native libraries.

Firebug on FF3

Since you are happy Firefox 3 user - you can not use Firebug, official firebug. But I’ve found FF3 compatible one. Of course, all changes in Fireclipse are trivial enough, but it is a pleasure when something is already done before you.

Enjoy!

Small tip for blogger.com users

If you do not like the navigation panel (the bar in the top of the page) - you can hide it.
Just add the following javascript in your site template:

function hidenav() {
document.getElementById(’navbar’).style.display=’none’;
}

Then add onload=”hidenav()” to the body HTML tag

That’s all. Have fun.

JS delay

    var ss = “qq”;
    for (ii = 0; ii < 1000; ii++) {
        ss += “ffff”;
    }

An interesting way…

JavaScript onLoad problem

Sometimes we have to open new browser window and invoke some code in it when it loads.

The first thing I’ve tried was: childWindow.onload = function () {/* Action goes here */;};

But it doesn’t work in IE! At first look it could seem strange. But the solution is very simple.

childWindow.onload = function () {/* Action goes here */;};

if (childWindow.attachEvent) {childWindow.attachEvent(”onload”, childWindow.onload);};

The second line will be executed in IE only and will solve the problem. Actually this is due its event model and nothing more :)

MyWebEr - creating documentation on the fly

In my last post I’ve asked for any help on my project. So, tanks to Jay Pipes for his tip.
One of most developer problems is documentation. And a good solution was initially appeared in Java with javadoc. At now many languages have special javadoc-like tools. I’ve made a little research, and decided to use jsdoc and phpdoc in my project. I am still open for any suggestions :)

Eval is evil

A piece of JavaScript:
var total = total + parseFloat(eval(’document.frm.smth’ + x + ‘.value’));

var tmpTotal = eval(’parseFloat(document.frm.smth.value)’ + action + ‘parseFloat(price)’);

To my small WTF collection

<SCRIPT TYPE=”text/javascript”>
  var a = confirm(’#errorMessage#’);
  if (a == true)
    history.back(0);
  else {
    history.back(0);
}
<SCRIPT>