Web Info & Tutorials

February 13th, 2008

WESTJET DEVELOPING OWN LOYALTY PROGRAM

"It's full steam ahead on our own frequent-flier program for 2009"

The carrier plans to drop its affiliation with Air Miles and also terminate an accord with Bank of Montreal's BMO Mosaik MasterCard, although BMO could still be involved in launching a new credit card, WestJet ... via The Globe and Mail

February 13th, 2008

SARNIANS WARNED OF BOGUS PRIZE OFFERS WITH PHONEY BANK ORDERS

Sarnia police advise area residents to beware offers of prize money accompanied by phoney bank orders. via London Free Press

February 13th, 2008

AJAXDATACONTROLS V1.0 AJAX EXTENSISON FOR .NET

We’ve been trying to get more .Net-related content on Ajaxian and luckily we were contacted by the AjaxDataControls team about their new v1.0 release.

The AjaxDataControls is a DotNetSlackers.com’s open source project built on top of Microsoft Asp.net Ajax Extension. Currently it contains GridView, DataList, Repeater and Pager controls. The main goal of this project is to provide a similar kind of data controls in the client side which the asp.net developers are already familiar with while working with the server side version. The Server side versions of these controls were developed long before the Ajax came into scene, so there is no client side API which the developer can utilize and it is also not possible to bind data which is returned from a Web Service or Page Method call. On the other hand, AjaxDataControls was specially developed keeping these things in mind. It Provides:

1. Exact same API as the Original Server Side version.
2. Exact same declarative model in aspx page.
3. Full Design time support.
4. Lots of extra features like drag and drop, animation, etc.

It is also possible to use these controls in non-MS platform.

Live examples are hosted:
http://dotnetslackers.com/projects/AjaxDataControls

Source:
http://www.codeplex.com/AjaxDataControls

Forum:
http://dotnetslackers.com/community/forums/71.aspx

February 13th, 2008

MOOTOOLS SWIFF: COMMUNICATE WITH FLASH

MooTools core team member Michelle Steigerwalt has a writeup about the MooTools 1.2 Swiff object which allows communication between Flash movie (.swf) files and a page's JavaScript. The Swiff object makes it substantially easier to interact with ActionScript allowing you to pass values or manipulate the Flash movie using JavaScript and MooTools:

Unless you're a diehard fan of the embedded Quicktime movie, you might see the benefit in a Flash video player to provide smooth playback of videos to your users, while still yearning for full control over the action using JavaScript and MooTools.

It's not even necessary for the Swiff object to be visible in order to benefit from its use. Using Swiff, you can utilize all of Flash's functionality, including its video, sound, file streaming, and clipboard accessing features, and lots more.

You get all the flashiness of Flash, while still being able to manipulate and display your content using the DOM and MooTools.

Instantiating a Swiff object instantly provides access to the referenced Flash movie and any exposed methods:

LANGUAGE:
//(JavaScript)
var obj = new Swiff('mySwf.swf', {
    width:  1,
    height: 1,
    container: $('swiffContainer'),
    events: {
        onLoad: function() {
            alert("Flash is loaded!")
        }
    }
});

In addition to this, the Swiff object's remote() method provides the hook to make calls to actual ActionScript functions:

LANGUAGE:
//(JavaScript)
var obj = new Swiff('mySwf.swf', {
    //[...]
    events: {
        onLoad: function() {
            Swiff.remote(obj, 'echoText', 'Hello Flash, meet Swiff.');
        }
    }
});

The Swiff object is currently available in MooTools 1.2 beta

February 13th, 2008

PROTOTYPE DEPRECATION.JS: 1.5 TO 1.6 MADE EASIER

Tobie Langel has developed a deprecation script to help you move from Prototype 1.5 to 1.6:

When your code calls a method that’s been deprecated, replaced, or modified, the script will log a warning or error to your Firebug console. Clicking its hyperlink will take you to the deprecation script itself, which isn’t all that helpful; but the message itself will contain a stack trace that points to the source of the error.

Naturally, the console errors are the most important to address, since they represent things that will no longer work in 1.6. The warnings represent deprecations — things that still work in 1.6, but are not guarateed to work in future versions of Prototype. If you’d like to see only removal notices, you can set a property in your code to turn off deprecations:

DeprecationNotifier.logDeprecation = false;

As you address these errors and warnings, they’ll go away. When there are no more errors, your code is compatible with 1.6. When there are no more warnings, your code is nimble and future-proof.

February 13th, 2008

IS EASY IMPLEMENTATION THE SAME AS GOOD CODE?

I've just come across a solution for badges on web sites that makes it terribly easy for implementers. The idea is that the implementer could add a badge wherever they want in an HTML document, choose the look and feel and add a message to be shown. The implementation code is the following:

HTML:
<script src="badge.js" size="small" skin="blue">Brandname</script>
 

The badge script then replaces the script node with the badge using the settings defined for each script include. Clever, right? Well, almost. Security concerns and invalid HTML aside (the attributes - content inside a script is valid and should be ignored according to the W3C when a src attribute is present) there are many more issues with this:

  • you need to loop through all script nodes, read the info and create the correct badge - this can get slow
  • the badge.js script gets called over and over again, even if it is only needed once (granted, it will be cached)
  • every script inside a body makes the rendering engine stop, pull the src and try to execute either that or the content of the node - this makes for terrible performance.

I've written up an example of how the above works and three alternative solutions that work around these issues.

What do you think? Should the ease of implementation be the success factor or the performance for the end user?

February 13th, 2008

Greg Reimer has followed up and posted on the new event delegation library that he is using on Sun.com.

The library provides one object, reg which lets you hook behaviour via:

JAVASCRIPT:
reg.click('ul.foo> li> a.bar', myFunction);
 

What is happening

Once that bit of code runs, regardless of whether the entire DOM has finished loading into the browser, click events on elements matching ul.foo > li > a.bar will be handled by myFunction, which is passed a reference to the active element and the event object. This happens without any DOM traversal, and without any events ever being attached to any <a> elements. Even if the entire contents of document.body are subsequently overwritten by innerHTML, all those new element nodes implicitly inherit the correct behavior. No re-walking of the new DOM subtree ever occurs. No re-attachment of events ever occurs.

How is this even possible?

Two facts conspire to make this feasible. 1) The (document.body) is available almost immediately. 2) Most events bubble. All you need to do is to stand on document.body, and you're privy to almost every event that occurs on the page, right out of the gate. No need to go seeking out the elements you need, they literally bubble their way to you. All you do is grab the event's target and ask the question, does this element, or one of its ancestors, match 'ul.foo > li > a.bar'? If so, run the associated function, if not, ignore it. This is really just event delegation, and it's nothing new, but we've made little use of it on Sun.COM before now.

February 13th, 2008

SUN.COM BEHAVIOUR REGISTRATION LIBRARY

Greg Reimer has followed up and posted on the new event delegation library that he is using on Sun.com.

The library provides one object, reg which lets you hook behaviour via:

JAVASCRIPT:
reg.click('ul.foo> li> a.bar', myFunction);
 

What is happening

Once that bit of code runs, regardless of whether the entire DOM has finished loading into the browser, click events on elements matching ul.foo > li > a.bar will be handled by myFunction, which is passed a reference to the active element and the event object. This happens without any DOM traversal, and without any events ever being attached to any <a> elements. Even if the entire contents of document.body are subsequently overwritten by innerHTML, all those new element nodes implicitly inherit the correct behavior. No re-walking of the new DOM subtree ever occurs. No re-attachment of events ever occurs.

How is this even possible?

Two facts conspire to make this feasible. 1) The (document.body) is available almost immediately. 2) Most events bubble. All you need to do is to stand on document.body, and you're privy to almost every event that occurs on the page, right out of the gate. No need to go seeking out the elements you need, they literally bubble their way to you. All you do is grab the event's target and ask the question, does this element, or one of its ancestors, match 'ul.foo > li > a.bar'? If so, run the associated function, if not, ignore it. This is really just event delegation, and it's nothing new, but we've made little use of it on Sun.COM before now.

February 13th, 2008

CRAZY WAY TO CHANGE THIRD PARTY SCRIPTS

Paul Goidelic posted a crazy method for tweaking ordinal band scripts. His difficulty was that he was using MultiMap (online Mapping API) and desired to alter the information, but it was hornlike coded in the JavaScript.

To intend around the difficulty he does this:

JAVASCRIPT:

// WARNING!!  This is much a large hack. Oh-so-hackalicious
 
// Problem:     Multimap doesnt earmark internationalization of its buttons, etc.
// Solution:    Redefine their JS functions to ingest variables that are internationalized.
// Assumption:  That these interior duty obloquy meet the same.
// Risk:        If duty obloquy change, this cipher module (probably) silently fail.
 
// The mass statements add the right-click environment schedule items and the map/aerial/hybrid buttons.
// Instead of hard-coded strings, it module ingest a uncertain which we control.
 
// ON TO THE HACKS!!
// Hack 1: add the mmjr() and mmfl() functions with funcName.toString().replace()
// Hack 2: ingest eval() to ordered the definition
// Hack 3: application inspire because IE and FF appendage toString()’d section differently (single-quote vs double-quote)
 
var isIE = $.browser.msie; // jQuery application sniff.
 
eval(
  “mmki.prototype.mmjr = “
  mmki.prototype.mmjr
  .toString()
    .replace( isIE ? “‘Move transpose to here’” : ‘"Move transpose to here"’ ,      ‘i18n.retailLocator.moveMapToHere’)
    .replace( isIE ? “‘Zoom in to here’” : ‘"Zoom in to here"’ ,        ‘i18n.retailLocator.zoomInToHere’)
    .replace( isIE ? “‘Zoom discover from here’” : ‘"Zoom discover from here"’,   ‘i18n.retailLocator.zoomOutFromHere’)
  );
 
eval(
  “MultimapViewer.prototype.mmfl = “
  MultimapViewer.prototype.mmfl
  .toString()
    .replace( isIE ? “‘Map’” : ‘"Map"’,       ‘i18n.retailLocator.map’)
    .replace( isIE ? “‘Hybrid’” : ‘"Hybrid"’, “i18n.retailLocator.hybrid”)
    .replace( isIE ? “‘Aerial’” : ‘"Aerial"’, ‘i18n.retailLocator.aerial’)
);
 

Yowser :)

February 13th, 2008

JQUERY API BROWSER UPDATE

Remy Sharp has alive the jQuery API application at a new location. The older API application hadn’t
been updated since 1.1.3 and most another API browsers were streaming from the older medico scheme (e.g. gotapi.com/jquery).

Remy additional springy intelligent and direct linking.

jQuery API Browser Updated