Activate your free membership today | Log-in

Monday, June 15th, 2009

Bing API does callback checking for JSON-P

Category: JSON, JavaScript, Library

I just looked through the API of Microsoft's new Bing search and found an interesting step in protecting code from throwing errors.

When you provide a JSON output for developers it does make sense to also allow for a callback parameter. That way your code can be used in script nodes without having to use any backend at all. Commonly this is called JSON-P and has been covered here in the long long ago. One of the issues with JSON-P is that when the callback method is not defined it throws an error.

The Bing API is the first instance where I have seen that they worked around that as the output is this:

JAVASCRIPT:
  1. if(typeof callback == 'function') callback(
  2. {
  3.   "SearchResponse":
  4.   {
  5.     "Version":"2.2",
  6.     "Query":
  7.       {
  8.         "SearchTerms":"a hard day's night"
  9.       },
  10.     "Translation":
  11.       {
  12.         "Results":
  13.           [
  14.             {"TranslatedTerm":"einem harten Tag-Nacht "}
  15.           ]
  16.       }
  17.     }
  18. } /* pageview_candidate */);

I have no clue what the /* pageview_candidate */ is about and frown upon omitting the {} of the if statement, but I must say I do like this. One issue is that while end users don't get annoyed with errors, developers don't have a clue what happened either as the error is silent. One proposal would be to use a console.log() when there is an error:

JAVASCRIPT:
  1. if(typeof callback === 'function') {
  2.   callback(... data ... );
  3. } else {
  4.   if (typeof console!=='undefined' &&
  5.    typeof console.log !== 'undefined'){
  6.     console.log('Error: Callback method not defined');
  7.   }
  8. }

More details about other ideas to improve this are here.

Posted by Chris Heilmann at 6:32 am
19 Comments

++---
2.3 rating from 31 votes

Friday, June 12th, 2009

JS.Class 2.1 released

Category: JavaScript, Ruby

James Coglan has updated JS.Class, his implementation of Ruby's object system in JavaScript.

This release includes a Hash implementation, HashSet, an updated Ruby 1.9 Enumerable module with enumerators and Symbol#to_proc functionality, and an improved package loader that supports parallel downloads and runs on SpiderMonkey, Rhino and V8.

Detailed Changes

  • New libraries: ConstantScope, Hash and HashSet, a much faster Set implementation.
  • The package manager has been improved with a new API, parallel downloading of files, and support for server-side environments such as SpiderMonkey, Rhino and V8. It also supports user-defined loader functions for transparent integration with Google and Yahoo!’s packaging systems.
  • The Enumerable module has been updated with plenty of methods from Ruby 1.9, and now supports enumerators, and Symbol#to_proc-like functionality whereby a string, MethodChain or any object that implements toFunction() can be used as an iterator.
  • The core object methods now live in Kernel, and we’ve added new methods: tap(), equals(), hash() and enumFor().
  • The double inclusion problem is now fixed; no current Ruby implementation seems to support this properly.
  • Ancestor and method lookups are now cached so callSuper runs about twice as fast.
  • Classes can be named to generate displayName on methods for
    use with the WebKit debugger.

Posted by Dion Almaer at 6:37 am
9 Comments

+++--
3.1 rating from 20 votes

Jetpack 0.2: slidebars, jetpack.future, and persistent storage

Category: Mozilla

On the back of the first Jetpack announcement, we see new version announced, 0.2 that adds slidebars, jetpack.future, and persistent storage.

Slidebar isn't a spelling mistake, but a slightly different take on the traditional sidebar. Check out Aza in his screencast to see them in action, and wait for the part where he sucks in a playing video and lets you continue to browse the Web elsewhere.

To code up a slidebar you simply:

JAVASCRIPT:
  1.  
  2. jetpack.slideBar.append({
  3.   icon: "http://wikipedia.org/favicon.ico",
  4.   url: "http://en.m.wikipedia.org/",
  5.   width: 300
  6. });
  7.  

but you have to use another new feature of Jetpack 0.2.... future:

Jetpack is two things at once: it is a platform for experimentation and it is also a solid set of APIs that anyone to easily build new Firefox features. To enable Jetpack to be both stable and — at the same time — to experiment with not-quite-yet-ready features we’ve added the ability to import new features from the “future”.

Slidebars, for example, are still highly experimental. To use them, you need to import them from the future first.

Read more about future in the Jetpack enhancement proposal (JEP) for jetpack.future.

jetpack.future.import("slideBar")

Persistent Storage and Clipboard Support

One of the most requested features in the Jetpack development mailing list was for the ability to persistently store data across restarts.

We’ve added simple storage to the future module. The API is defined in the storage JEP. Using it as simple as:

jetpack.future.import("storage.simple");
var db = jetpack.storage.simple;
var data = {name: "Firefox", twitter: "@firefox"};
db.set( "friend", data );

Give it a go!

Posted by Dion Almaer at 5:59 am
4 Comments

+++--
3.2 rating from 12 votes

InfoVis Toolkit 1.1

Category: JavaScript, Library

Nicolas Garcia Belmonte has updated InfoViz with version 1.1.

The JavaScript InfoVis Toolkit provides tools for creating Interactive Data Visualizations for the Web. The code has been updated:

  • The library has been split into modules for code reuse.
  • All visualizations are packaged in the same file. You can create multiple instances of any visualization. Moreover, you can combine and compose visualizations. If you want to know more take a look at the Advanced Demos.
  • This Toolkit is library agnostic. This means that you can combine this toolkit with your favorite DOM/Events/Ajax framework such as Prototype, MooTools, ExtJS, YUI, JQuery, etc.
  • You can extend this library in many ways by adding or overriding class methods. The JavaScript InfoVis Toolkit has a robust (and private) class system, heavily inspired by MooTools’, that allows you to implement new methods in the same class without having to define any new Class extension. By creating mutable classes you can add new custom Node and Edge rendering functions pretty easily.
  • Custom visualizations are created by adding or changing Node/Edge colors, shapes, rendering functions, etc. You can also implement many controller methods that are triggered at different stages of the animation, like onBefore/AfterPlotLine, onBefore/AfterCompute, onBefore/AfterPlotNode, request, etc.
    You can also add new Animation transitions like Elastic or Back with easeIn/Out transitions.
    If you want to know more about these features please take a look at the Demos code.
  • A complete API documentation generated with Natural Docs, with some Narrative Documentation and Syntax Highlighted Code Examples.

Posted by Dion Almaer at 5:34 am
3 Comments

++++-
4.5 rating from 26 votes

Ext Updates: Ext JS 3.0, Ext GWT 2.0; New apps and sites running

Category: Ext

There has be some interesting news in Ext land recently, so we wanted to do a quick roundup post to get it out there:

Ext JS 3.0 RC2 Release - Stable, Robust, and Enhanced

Some of the major fixes include:

  • Items are now automatically laid out when they are first shown - rather than trying to calculate dimensions when they are hidden. This will solve a number of layout issues that occur across all components.
  • The toolbar overflow has been improved to support all toolbar items, including CycleButtons and Buttons with toggle enabled (both grouping and otherwise).
  • Issues with some animations in the Fx library have been corrected.

There are new examples that test out new features such as REST support and the DataWriter.

Ext GWT 2.0 Milestone 2 Released

Ext GWT 2.0 works with GWT 1.6. With GWT 1.6, the application deployment design was changed to make it easier to integrate your GWT application into an existing J2EE application. Ext GWT 2.0 has been updated to take advantage of the new GWT design.

Ext GWT 2.0 introduces several new UI Components and enhancements to many existing components.

Implementation Spotlight: Zipwhip and Ext JS

Abraham Elias sits down with the Zipwhip folks and shares a case study:

Zipwhip is a utility for text messaging from the web. Text messaging is the fastest growing communication medium, but is still locked inside the mobile phone. We aim to help bring text messaging everywhere.

To pull off our ambitious goals, we’re using just about every web 2.0 trick in the book—comet to send carrier delivery receipts back to the browser in real-time, Ajax for server communications, download-on-demand Javascript packages (with preloading), Flash for audio notifications, and many others.

Fab's Boombox

Fab's Boombox is a javascript library for a music player. It is built on top of Sound Manager 2 by Scott Schiller and the Ext 3.0 Core library.

weight loss dr s tx? Delivered Phentermine "yorkshire terriers weight loss heart worms"
Weight loss cookies weight loss surgery uk 200. Help Finding Phentermine elizabeth edwards weight loss
weight loss fitness nutrition Phentermine Alternatives weight loss body wrap
wicker hanging basket resin all-weather lined Inexspensive Phentermine moly resin
deadweight loss, Complete Phentermine Information From Drugs Com la weight loss review
weight loss program hospital richmond virginia Phentermine Discount weight loss clinics in florida
v mixer resin Cheap Herbal Phentermine v mixer resin
vegetarian weight loss diets Purepac Phentermine eat an afternoon snack weight loss
low carbohydrate weight loss plans Best Prices For Phentermine Diet Pill medical weight loss clinics
huntsman resin Dangers Of Phentermine health spa weight loss retreat,
lipotropic weight loss products Phentermine Doctor Columbus Ohio "buy phentermine using pay pal"
caffeine weight loss Phentermine Online Us Pharmacy vinyl ester resin?
biblical weight loss james d sweetwater, Phentermine Online Sales celexa and weight loss;
Calorie diet loss weight hypothyroidism and weight loss 888. Phentermine Blue No Prescription weight loss god's way
range of motion weight loss? Phentermine Stories epoxy cast resin transformers
tony ferguson weight loss Generic Fastin chelated resin msds!
levothyroxine weight loss, Phentermine Diet Pills Di juice fasting weight loss?
37.5mg adipex Diet Tablets Phentermine severe weight loss
weight loss surgery cost Adipex D Order Online phenolic resin used in fireworks,
weight loss reflexology points; Ordering Adipex Online online phentermine 37.5mg prices
biblical weight loss james d sweetwater, Adipex Online No Script Needed morbid obesity weight loss medicine
weight loss dr s tx? Cheapest Price On Phentermine "yorkshire terriers weight loss heart worms"
Weight loss cookies weight loss surgery uk 200. Phentermine Online No Credit Card elizabeth edwards weight loss
weight loss fitness nutrition Phentermine No Prescription Us Pharmacy weight loss body wrap
wicker hanging basket resin all-weather lined Order Phentermine Online Without Prescription Cheap moly resin

Posted by Dion Almaer at 12:59 am
9 Comments

++++-
4.3 rating from 73 votes

Thursday, June 11th, 2009

Animating SVG with Canvas and Burst

Category: Examples

Christopher Blizzard and his team are doing great write-ups on hacks.mozilla.org as they celebrate 35 days of Open Web goodness.

They just posted on the work of Alistair MacDonald who used his Burst engine to demonstrate taking SVG and having Burst load it and convert it all to JavaScript objects that are rendered inside of a canvas.

To get a feel for the code, view source:

JAVASCRIPT:
  1.  
  2.     Burst.defaults.debug=false;
  3.    
  4.     Burst.defaults.ease="easeOutQuad";
  5.     Burst.timeline("chassis", 0, 100, 1, true)
  6.       .shape("car", "car.svg", "svg", 0, 0, 1, 0)
  7.         .cut("wheel1;wheel2")       
  8.         .group("chassis")
  9.           .track("top").key(0,0).key(50,-20).key(70,0)       
  10.     ;
  11.    
  12.     Burst.defaults.ease="linear";
  13.     Burst.timeline("wheels", 0, 100, 1, true)
  14.       .shape("car", "car.svg", "svg", 0, 0, 1, 0)
  15.         .cut("chassis")         
  16.         .group("wheel1").track("centerX").key(0,230).track("centerY").key(0,350)
  17.           .track("rot").key(0,0).key(100,-360)
  18.         .group("wheel2").track("centerX").key(0,430).track("centerY").key(0,350)
  19.           .track("rot").key(0,0).key(100,-360)
  20.     ;
  21.    
  22.     Burst.timeline("carObject", 0, 300, 3, false)     
  23.       .track("scl").key(0,.5)
  24.       .track("left").key(0,400).key(300,-195)
  25.       .inherit("wheels")
  26.       .inherit("chassis")
  27.     ;
  28.    
  29.  
  30.     Burst.timeline("boom", 0, 10, 1, true)
  31.       .shape("boom", "boom.svg", "svg", 0, 0, 1, 0)
  32.     ;
  33.    
  34.     Burst.start("carObject", function(){
  35.         Burst.timeline("chassis").paused=true;
  36.         Burst.timeline("wheels").paused=true;
  37.         Burst.start("boom");
  38.     });
  39.  

and then watch the tutorial that shows how you can take Inkscape and quickly get animating.

View the Ogg or mp4 versions.

Also check out the other items:

Posted by Dion Almaer at 7:54 am
5 Comments

++++-
4.4 rating from 17 votes

jQuery Tools

Category: JavaScript, jQuery

Tero Piirainen has created a new package of jQuery Tools.

This library contains six of the most useful JavaScript tools available for today's website. The beauty of this library is that all of these tools can be used together, extended, configured and styled. In the end, you can have hundreds of different widgets and new personal ways of using the library.

This library is open source and dual licensed under MIT and GPL 2+ licenses.

The package contains a slew of demos including:

  • Tabs
  • Tooltips
  • Expose
  • Overlay
  • Scrollable
  • Flashembed

Posted by Dion Almaer at 6:27 am
20 Comments

+++--
3.7 rating from 57 votes

Wednesday, June 10th, 2009

Ample SDK: Browser-in-a-Browser

Category: Framework, JavaScript

Sergey Ilinsky, formerly of Ajax pioneer Backbase, has created a new Ajax toolkit called Ample SDK. The best way to describe Ample SDK is that it's a browser-within-a-browser, but not in the visual sense. Rather, it aims to implement in JavaScript the stack of rendering technologies typically delegated to the browser. For example, Ample currently lets you use Mozilla's XUL to create cross-browser applications.

Here's an example of how you could use Ample SDK to render a XUL interface in the browser:

<body>
    <!-- other HTML code -->
    <script type="text/javascript">ample.open()</script>
<xul:menulist xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
    <xul:menupopup id="items-popup">
        <xul:menuitem label="Item 0" value="0"/>
        <xul:menuitem label="Item 1" value="1"/>
        <xul:menuitem label="Item 2" value="2"/>
    </xul:menupopup>
</xul:menulist>
    <script type="text/javascript">ample.close()</script>
    <!-- other HTML code -->
</body>

(Sorry for the old-school, ugly <pre> above--our code formatter chokes on XML namespaces, used in the XUL elements above.)

The Ample SDK compatibility table, shown above, gives you a sense of the scope of the project: to implement technologies like XUL, SVG, HTML 5, XHTML, and so forth, all in JavaScript--and render them across modern and legacy browsers like IE 5.5.

Ample even takes over CSS parsing:

HTML:
  1. <style type="text/ample+css">
  2.     @namespace "http://www.w3.org/1999/xhtml";
  3.     b {
  4.         color: red;
  5.     }
  6. </style>

Check out the examples and documentation at the site. Note that Ample is not (yet) open-source but is free for non-commercial projects.

When Brendan Eich first hinted several years ago that the browsers would get fast, it spurred a lot of folks to wondering whether the future of feature innovation would be primarily in the JavaScript library space, and the browsers would focus on being JavaScript run-times and graphics abstract layers.

Ample SDK raises the question anew. Should we push the rendering layer to JavaScript libraries? What do you think?

And, what do you think of Ample?

Posted by Ben Galbraith at 6:00 am
27 Comments

++++-
4.1 rating from 29 votes

Web Developer Collection: Packaged up Firefox extensions

Category: Debugging, Firefox, Utility

Over the years we are have mentioned many Firefox, and Firebug plugins to aid us Web developers. Wouldn't it be nice to subscribe to a bundle of these tools? The Firefox Add On team has now given us that ability with Add On Collections:

Today, we’re excited to introduce a new feature to our website that will expose the niche add-ons that can be hard to find, and gives users a more active role in helping outstanding add-ons bubble to the top. One thing we’ve learned as add-ons have grown in popularity over the years is that once a user finds an add-on they love, they become a fan for life. We see this all the time as people recommend add-ons to their friends and write great reviews.

You will notice the Web Developer collection that features:

What is missing? What should be on the list?

Posted by Dion Almaer at 5:22 am
28 Comments

++++-
4.1 rating from 18 votes

Styling buttons as links allowing you to POST away

Category: CSS, Examples

Have you ever wanted to just <a href="path" action="post">? Remember the hub-ub with the old Google Web Accelerator and how it started to crawl links to delete actions that were mistakenly using GET?

Natalie Downe has written up a piece on styling HTML buttons as links which means that you can somewhat get the same effect. It shows how you can use an inline span to get the hover effect, taking:

HTML:
  1.  
  2. <button type="submit" class="link"><span>Hello there I am a button</span></button>
  3.  

and styling it with:

CSS:
  1.  
  2. button {
  3.         overflow: visible;
  4.         width: auto;
  5. }
  6. button.link {
  7.         font-family: "Verdana" sans-serif;
  8.         font-size: 1em;
  9.         text-align: left;
  10.         color: blue;
  11.         background: none;
  12.         margin: 0;
  13.         padding: 0;
  14.         border: none;
  15.         cursor: pointer;
  16.        
  17.         -moz-user-select: text;
  18.  
  19.         /* override all your button styles here if there are any others */
  20. }
  21. button.link span {
  22.         text-decoration: underline;
  23. }
  24. button.link:hover span,
  25. button.link:focus span {
  26.         color: black;
  27. }
  28.  

You can see the simple example in action.

Posted by Dion Almaer at 3:15 am
16 Comments

+++--
3.9 rating from 13 votes

Tuesday, June 9th, 2009

Finally, a useful blink tag! Detecting your user blinking

Category: Canvas, Showcase

Dave Burke just gave an awesome demo at GDD Beijing. Fire up Firefox 3.5beta (for now) and head over here and watch the human blink detection in action!

Here Dave tells us more about his awesome hack:

Inspired by a demo by Paul Rouget, I've created an image processing demo that detects eye blinks in real-time. It uses a combination of <video>, <audio>, <canvas> and worker threads. The <video> frames are "projected" on to a <canvas> to get access to the raw pixels. The Euclidean colour distance is calculated inter-frame and thresholded, resulting in a view that shows movement (shown on a second canvas). A worker thread then performs several algorithms including tracing, sorting, and positioning check of the blobs of pixels. If the worker thread determines an eye blink, it posts back to the main thread which uses the canvas to draw bounding boxes around the eyes. The algorithm is based on a paper I wrote almost 10 years ago describing a communication system I built for a patient with severe spinal injuries. I had originally implemented it in C++ using Microsoft's "Video For Windows" (a precursor to DirectShow). I bet I would have laughed if someone said that I'd be able to write the same system in JavaScript less than 10 yrs later!

Thanks Dave!

Posted by Dion Almaer at 11:59 am
15 Comments

++++-
4.5 rating from 25 votes

Titanium gets hardened with new beta that features Mobile and more

Category: Mobile

Appcelerator has announced a Titanium beta that adds to their desktop vision with new APIs and developer tool but also allows you to create mobile applications using HTML/CSS/JavaScript (and in fact Ruby, Python, ...) that run on iPhone and Android.

You can take a look at what it takes to develop for desktop and mobile in this screencast from Kevin Whinnery:

I instantly thought of PhoneGap and asked Jeff Haynie about the differences. It appears that Titanium Mobile handles the device mapping in a different way. Instead of focusing just on device APIs and giving developers access to those APIs via JavaScript, it goes a little further. The Titanium tool will compile down your code and you will see that native widgets will be used in places. As the mobile version moves forward, they expect to do more of that kind of work, so instead of a WebView + APIs, you have native where you can, and WebView where you can't.

From watching the Titanium Developer tool at work, you can quickly see that it is nicely taking care of you, the Web developer, as you go through the process of dealing with phones. Dealing with the SDKs from Apple and Android can be messy business and the tool really tries to make it much more seamless. The same can be said for the packaging and deployment process.

It is great to see yet another product that comes along to help Web developers take their existing skills and have them work on mobile platforms. Personally, the thought of going to Objective-C land isn't a pleasant one for me, so this and PhoneGap make total sense. If other platforms such as Android and hopefully webOS catch on, then it will make even more sense to go cross platform. Who better to write code on difference devices that Web devs since we have to deal with it every day ;)

Need a visual builder? You could take the upcoming 280 Atlas, use Interface Builder or Atlas itself, and deploy your app to the phone. Great times for the Web platform.

Posted by Dion Almaer at 5:16 am
2 Comments

++++-
4.2 rating from 20 votes

Monday, June 8th, 2009

Firefogg: Ogg Theora Encoding Plugin

Category: Utility, Video

Test Drive the latest Thusnelda theora encoder with in-browser Video Encoder Firefogg.

Firefogg is an open source extension written by xiph hacker Jan Gerber that lets web developers request ogg video from their users. Since Firefogg is a Firefox extension it allows users to stay up to date with the latest and greatest theora encoder improvements. Firefogg supports a rich api for enabling web applications to drive in-browser transcoding from any source footage to ogg theora video (and possibly other free formats in the future). Firefogg supports simultaneously uploading while its transcoding via resumable one meg post chunks. It also supports fall-back to HTTP POST all-at-once. Both methods include progress indicators.

Firefogg can also encode to a local file and an example local transcoding application is on the site. The sample application builds on jQuery UI so it supports custom themes. Integration for firefogg with wikimedia commons are in testing. With Firefoxs video tag support this should be a helpful extension for converting video to ogg theora or supporting ogg theora video contributions in your website.

Firefogg can minimize the need for costly server side transocding infrastructure. It also helps avoid the extra transcode problem that plagues net video where a user saves to a compressed format locally to save time uploading; then the server re-transcodes the video so others can view it with a flash plugin. With Fireofogg we can go strait from the high quality source to the format distributed on the web site.

Here is an example of using the API yourself to convert video:

JAVASCRIPT:
  1.  
  2. if(typeof(Firefogg) == 'undefined') {
  3.   alert('You dont have Firefogg, please go to http://firefogg.org to install it');
  4.   window.open('http://firefogg.org');
  5. }
  6.  
  7. var ogg = new Firefogg();
  8. if(ogg.selectVideo()) {
  9.   var options = JSON.stringify({'maxSize': 320, 'videoBitrate': 500});
  10.   var data = JSON.stringify({'title': 'example video'});
  11.   ogg.upload(options, 'http://example.com/addvideo', data);
  12.   var updateStatus = function() {
  13.     var status = ogg.status();
  14.     var progress = ogg.progress();
  15.  
  16.     //do something with status and progress, i.e. set progressbar width:
  17.     var progressbar = document.getElementById('progressbar');
  18.     progressbar.style.width= parseInt(progress*200) +'px';
  19.     progressbar.innerHTML = parseInt(progress*100) + '% - ' + status;
  20.  
  21.     //loop to get new status if still encoding or uploading
  22.     if(ogg.state == 'encoding' || ogg.state == 'uploading') {
  23.       setTimeout(updateStatus, 500);
  24.     }
  25.     //encoding sucessfull, state can also be 'encoding failed'
  26.     else if (ogg.state == 'done') {
  27.       progressbar.innerHTML = 'Upload done. You can close this window now';
  28.     }
  29.   }
  30.   updateStatus()
  31. }
  32.  

Posted by Dion Almaer at 7:04 am
8 Comments

++++-
4.7 rating from 15 votes

GeoFill - find users by IP or lookup and prefill forms for them

Category: Library, Yahoo!

One thing that annoys me is that in the days of geolocation and location recognition I still have to enter my country and city in forms over and over again. This is especially annoying when you like in the UK which could be anywhere in these wonderful large dropdowns (UK, England, Great Britain, United Kingdom, Blighty...).

There are many geo lookup tools and a lot of (at least UK) web sites started doing post code lookup tools. This is cool, but as annoying when I spent another reload of a full large form for a postcode lookup that went wrong. With the UK being quite a mess when it comes to post codes this is not uncommon.

Now, to work around these issues I've put together a small JavaScript wrapper library called GeoFill (also available on GitHub). This one makes it easy to provide a "is this your location" functionality in JavaScript:

GeoFill - automatically filling form data with geo information by  you.

GeoFill has two different methods to automatically fill forms with geo information:

  • geofill.find(properties) does an IP lookup of the current user and tries to get the geographical data from that one.
  • geofill.lookup(properties,postcode) tries to get the geographical data from the postcode provided in your form.

Both methods can either automatically fill a form when you provide them with an object telling it which info should go into the form with a given ID, but also have a callback property that allows you to use the data immediately

JAVASCRIPT:
  1. geofill.lookup(
  2.   {
  3.     callback:function(o){
  4.       console.log(o);
  5.   }
  6. },'wc2h8ad');

The returned object is:

JAVASCRIPT:
  1. {
  2.   city:"London",
  3.   country:"United Kingdom",
  4.   latitude:"51.51384",
  5.   longitude:"-0.12857",
  6.   postcode:"WC2H 8AD"
  7. }

The find method uses the GeoIP lookup:

JAVASCRIPT:
  1. geofill.find({
  2.   callback:function(o){
  3.     console.log(o);
  4.   }
  5. });

And returns (in my case):

JAVASCRIPT:
  1. {
  2.   city:"London",
  3.   country:"United Kingdom",
  4.   latitude:"51.5",
  5.   longitude:"-0.11670000106096",
  6.   postcode:"WC2H 8AD"
  7. }

Posted by Chris Heilmann at 5:03 am
1 Comment

+++--
3.6 rating from 17 votes

Craftmanship and UI latency

Category: Editorial

Ben gave a fantastic talk on creating compelling user experiences that discussed craftmanship in software.

He details the somewhat opposing views of Alan Cooper (pictured above) and Joel Spolsky talking about how IT people are screwed when it comes to quality. A depressing thought, and one that we need to combat in the trenches by just creating great software at work and proving that it is a winning strategy.

One piece of the talk I wanted to highlight was when Ben discussed UI latency. He has a simple feedback test page that lets you see how various delays make you feel. Give it a go and think about what feels sluggish and annoying. It differs between people, but 100ms feels like the "noticeable" level and 200+ feels sluggish. We should have a page that doesn't show numbers and is randomly setup, and then do a test. What do you think?

Also, to finish off, you owe it to yourself to spend a couple of minutes watching this awesome rant of Louis C.K. as he discusses how screwed up we are wrt expectations:

This is actually incredibly relevant to us as developers, as we run up against expectations in software too. Do you want to meet expectations? Or set new boundaries?

Posted by Dion Almaer at 12:25 am
2 Comments

++++-
4.6 rating from 11 votes

Friday, June 5th, 2009

Moousture: mouse gesture library

Category: JavaScript, Library, MooTools

Zohaib Sibt-e-Hassan has created a Mootools based mouse gesture library Moousture that is based on simplicity:

  • A probe, which probes the pointing device. Currently there
    is a Moousture.MouseProbe (P.S. I am planning to test it on iPhone and
    build any seprate probe for that).
  • A monitor, which tests the stability of probed
    device on given intervals and accordingly notifies Moousture events
    (onStable, onUnstable, onMove).
  • A Moousture recorder class that records the mouse
    movements and invoke the guesture object passed to it.

You can easily work with gestures:

JAVASCRIPT:
  1.  
  2. // Create a guesture matcher, currently there are only two gesture objects Moousture.LevenMatcher, and Moousture.ReducedLevenMatcher.
  3.  
  4. gstr = new Moousture.ReducedLevenMatcher();
  5.  
  6. // Add gesture vectors to matcher object, (see details below in Create your own gestures).
  7.  
  8. gstr.addGesture([3,2,1,0,7,6,5,4], ccwCircle);
  9.  
  10. // Guesture callback function takes one parameter error recieved from matching algorithm. Threshold that value (if required) to make your gestures more sleek.
  11.  
  12. function ccwCircle(error) {
  13.     if(error>= 0.6) return;
  14.     ...
  15. }
  16.  
  17. // Create a probe object that will probe the pointing device. Currently there is a mouse probe that take the $(element) to probe for. So passing a div id will cause the probe to trigger events only when they occur on the passed DOM element.
  18. probe = new Moousture.MouseProbe($(document));
  19.  
  20. // Create a recoder object to record the movement , maxSteps and minSteps in options object will specify the maximum and minimum number of steps to be recorded, and macher is required matcher object to trigger the appropriate gesture.
  21. recorder = new Moousture.Recorder({maxSteps: 20, minSteps: 8, matcher: gstr});
  22.  
  23. // Create a monitor specifying the interval to poll and the amount of error allowed for gesture in pixels.
  24. monitor = new Moousture.Monitor(30, 2);
  25.  
  26. // Finally start the monitor.
  27. monitor.start(probe, recorder);
  28.  
  29. // You can stop the gesture triggering any time by calling .stop() of monitor object.
  30. monitor.stop();
  31.  

Posted by Dion Almaer at 6:56 am
10 Comments

++++-
4 rating from 22 votes

« Previous PageNext Page »