Archive for the 'Javascript' Category
Respect for JavaScript
Tuesday, April 7th, 2009Surfing around I found this cool video of Doug Crockford, the man behind JSLint and JSON. He surely is a funny guy
OnTheFly
Thursday, March 19th, 2009I Just published on github a tool to concatenate JavaScript and CSS files on the fly to speed up the development process when using large code base. Check the project page
Hemnet & Eniro launched!
Thursday, October 23rd, 2008After working last year at Eniro maps to introduce the “utsikt” images (images taken from an airplane at a 45° angle), we have today successfully launched the integration of Eniro maps on Hemnet, Sweden largest site for real-estate.
During the project I acted as a javascript programmer and as a scrum master together with Torsten Ek [...]
Encoding of included JSON files
Tuesday, October 7th, 2008Lately I had a problem with a page which was including two JSON scripts, one encoded in UTF-8 and the other encoded in ISO-8859-1.
In some circumstances (and in some browsers) the strings where not showed correctly.
Hunting down the problem required a good dose of my favourite tool wget -S where the -S option causes the [...]
onresize event and prototype
Tuesday, September 2nd, 2008If you need a compact way to use prototype and listen to on onresize event in a cross-browser manner, this is the way to go:
Event.observe(document.onresize ? document : window, “resize”, function() {//dostuff});
As you can see, the event to listen is resize but depending on the browser, it may be fired on either the window or [...]
Object.extend, an example of inheritance
Tuesday, September 2nd, 2008Updated: my previous attempt to simulate inheritance in javascript using Prototype.extend did not work as I expected so I removed the example I had written.
Inheritance can be defined in several ways. The definition of inheritance I will use in the following example is: A child class inherits from a parent class if all methods of [...]
onmouseover / onmouseout and nested divs
Friday, August 29th, 2008I had never noticed a behavior which left me astonished
If you have two nested divs and are listening for the onmousover event on the parent div, you will get a onmouseout event when entering the nested div!
parent div
Nested div
As I see it, since the mouse has not left the area covered by the red [...]
jsUnit testing a method of a class with a boring constructor
Friday, August 29th, 2008Today I wanted to introduce some jsUnit testing in an old class. In particular I wanted to test a single method in isolation but I could not instantiate the object itself since the constructor had dependency on other files.
load(”ClassToTest.js”);
function testMyMethod() {
var object = new ClassToTest(); // This does not work since
//ClassToTest has a boring constructor!
object.runMethod();
//do [...]
Unit testing with Javascript
Friday, September 28th, 2007I’m a big fan of unit testing. Everybody who has been working with me knows it. Unit testing makes you sleep well at night. If you have not understood the advantage of unit testing your code you should really try to do it!
Lately I’ve been working a lot with Javascript for obvious reasons. Ajax is [...]