Mar 232015

In most programming languages, there is a built-in function sleep(), wait() or similar that will suspend the execution of the program or script for a given amount of time, normally expressed in milliseconds, without CPU consumption. A call to this function is commonly used inside a loop that check for the availability of some resource required to continue the execution.

In javascript, there is no such function, but a setTimeout() function that schedules the execution of a function after a specified number of milliseconds.

Continue reading »

 Posted by at 12:42 pm
Jan 042015

With the arrival of the smartphones, that allow the user to navigate the internet, the way new websites are designed has changed. Most of new designs are “responsive”, that is, they adapt their layout to the dimensions of the screen where they are being displayed.

But, for many of the websites that existed previously, the change to a responsive design is not an easy task. Nevertheless, there are some minor changes that can be done to a non-responsive design, that may improve the rendering of a site on screens that are smaller than the target resolution of the original design.

This post explains some of the possible design changes that can be done on a non-responsive website.

Continue reading »

 Posted by at 8:52 pm
Jul 012013

Sometimes, some type of processing is required when a user decides to leave one of the pages of our web site.

For instance, the page might include a form where the user has entered some data. In this case, it is desirable to warn the user with a request to save, or to explicitly discard the changes.

This post explains how to capture and process in javascript the page abandon event that is triggered when the user is about to leave a page.

Continue reading »

 Posted by at 3:54 pm
Jun 162013

In a browser with support for html5, it is possible to insert a video player using the “<video>” tag. Moreover, the status of the player can be controlled with javascript. This includes the possibility to change the video file loaded in the player. With this functionality, we can add buttons or links in our page to choose the video we want to play, with no need to reload the full page.

This post explains and demonstrates the procedure originally presented in, adapted to include this functionality in a wordpress blog post.

Continue reading »

 Posted by at 10:02 am
May 162013

In a previous post we explained how to request a JSON file from a server using the “getJSON” function in jQuery.

The method explained in that post is executed asynchronously: The data requested is not available immediately after the call has been issued.

Normally, a callback function is included in the call to be executed once the data have been retrieved. But sometimes it is desirable to just wait until the call finishes before continuing the process.

This post explains how this behaviour can be achieved.
Continue reading »

 Posted by at 6:36 pm
Jan 232013

In a previous post we have already explained how to draw with the mouse on a HTML5 canvas. The method presented there is not valid if the user reaches the page from a mobile device, because in that platform there is no mouse. Instead, the user interacts with the page by touching the screen with a finger.

In this post we will explain how to program in javascript the same functionality adapted to work on an Android, iPhone or similar mobile device.

Continue reading »

 Posted by at 7:10 pm
Jan 202013

This post shows how to use the plupload javascript library to post images to a web server.

The main advantage of plupload is its ability to perform client-side processing of the image, reducing the volume of data to be sent to the server. This is specially convenient for web sites targeted to users of mobile devices. It allows, for instance, uploading to the server pictures taken with the built-in camera. An image of this kind can be several MBytes in size, with a resolution too big to be displayed on a web page. With plupload, it is possible to change the scale, and optionally the quality of the image, to reduce the size by up to 90%.

Continue reading »

 Posted by at 1:13 pm
Dec 142012

Google maps gives users validated with a Google account the possibility to add annotations to a map, to mark places, as well as to highlight paths and closed areas.

The Google maps API also allows to add annotations to the map using javascript. This post reviews how to create these custom maps, both in the Google Maps frontend and by using the API.

Continue reading »

 Posted by at 7:52 am