Posts Tagged ‘Javascript

Full circle Javascript

Posted in Technicalon May 22, 2015

When I first started learning Javascript, in the Netscape Navigator version 3 days, all the programming for a page was done in the web browser.  Javascript could read the query parameters to a page and construct the page with information according to the request.  In those days, I did everything in the browser because I couldn’t afford my own web server, and the free servers of those days (Geocities, Tripod) only really supported static pages.

Finally I got access to a server that ran PHP, which was awesome because I could do all the programming on the web server, reducing the frustration of dealing with various versions of web browsers that supported different feature sets.

But recently, web browsers conform to standards better, support a richer feature set, and are supported by many Javascript client libraries.  I’m finding that more and more, I’m ditching the server side program in favor of more client side programming. This is especially true with my embedded system work, where offloading the User Interface to the web browser provides a better experience.

Online stopwatch

Posted in Technicalon Aug 26, 2010

The other day, I had a spare few minutes and a need for stopwatch, so I wrote my own online stopwatch. You can find it at:

I’ll be publishing it as a Google Chrome Web app once that goes public.

Percent encoding for UTF-8

Posted in Technicalon Apr 20, 2010

Warning: This post is not for those who don’t fancy a little bit of computer science.

I was recently looking for some Javascript code that would escape a filename so that a file with international character in the name could be uploaded to Google Docs through my GDocsUploader program.  With some help of some internet searching, this is what I came up with.  This function will take a UTF-8 string and replace non-ascii characters with percent encoded unicode values.

I thought I would share this in case it might help someone else in the future.

function utf8_percent_encode(string) {
    string = string.replace(/\r\n/g,"\n");
    var encstr = "";
    for (var n = 0; n < string.length; n++) {
        var c = string.charCodeAt(n);
        if (c < 128) {
             encstr += String.fromCharCode(c);
        } else if((c > 127) && (c < 2048)) {
             encstr += "%" + ((c >> 6) | 192).toString(16);
             encstr += "%" + ((c & 63) | 128).toString(16);
        } else {
             encstr += "%" + ((c >> 12) | 224).toString(16);
             encstr += "%" + (((c >> 6) & 63) | 128).toString(16);
             encstr += "%" + ((c & 63) | 128).toString(16);
    return encstr;

Firefox 2

Posted in Technicalon Oct 23, 2006

Although Firefox 2 isn’t officially released from Mozilla until tomorrow (Oct 23, 2006), I found that the files are on the FTP server ready to be downloaded. Of course there is an official list of changes, but here is a list of small little things I’ve noticed. Read the rest of this entry »