Activate your free membership today | Log-in

Friday, July 3rd, 2009

It’s Friday. Play some drums…. HTML5 style

Category: Examples, Sound

Brian Arnold created a fun sample drum machine simulator using HTML5 <audio>.

JAVASCRIPT:
  1.  
  2. function playBeat() {
  3.         if (isPlaying) {
  4.                 var nextBeat = 60000 / curTempo / 4;
  5.                 // Turn off all lights on the tracker's row
  6.                 $("#tracker li.pip").removeClass("active");
  7.                 // Stop all audio
  8.                 stopAllAudio();
  9.                 // Light up the tracker on the current pip
  10.                 $("#tracker li.pip.col_" + curBeat).addClass("active");
  11.                 // Find each active beat, play it
  12.                 $(".soundrow[id^=control] li.pip.active.col_" + curBeat).each(function(i){
  13.                         document.getElementById($(this).data('sound_id')).play();
  14.                 });
  15.                 // Move the pip forward
  16.                 curBeat = (curBeat + 1) % 16;
  17.                 // Schedule the next one
  18.                 setTimeout(playBeat, nextBeat);
  19.         }
  20. }
  21.  

That's not all Brian is working on:

I'm also working on something like the ToneMatrix or Tenori-on (Flash and actual devices, respectively) in pure HTML/JS. It works too, but the sounds aren't exactly designed to be great together (it's currently working on a C scale) and so if you're careful, you can get some decent sound but otherwise, it'll hurt your ears.

Posted by Dion Almaer at 8:11 am
3 Comments

++++-
4.5 rating from 8 votes

Machsend: P2P file sharing via Browser Plus

Category: Component, Yahoo!

Alex MacCaw has released Machsend, a Yahoo! Browser Plus plugin that enables P2P file transfers from inside the browser.

It showcases what can be done with a BP plugin, leaving you wish cross browser functionality.

I guess it is kinda fun to hack the browser :)

Posted by Dion Almaer at 5:52 am
1 Comment

+++--
3.3 rating from 4 votes

Thursday, July 2nd, 2009

GChart 2.5: Faster, sharper, canvas-rendered, pie, line, and area charts

Category: Component, GWT, Library

John Gunther has released GChart 2.5, a client-side library that adds a new canvas-rendering option for sharper, better looking, alpha-transparent, pie, line, and area charts.

John told us:

Canvas-rendering corrects GChart's most serious visual quality limitations (including the most often mentioned problem by its users: the banded-filled pie slice).

Coupled with its existing feature set and ease of GWT integration, the canvas-rendering option makes GChart an excellent choice for those who want to add basic charts to a GWT application without a lot of fuss.

To access these features, you'll need to plug an external canvas library into GChart (GWTCanvas in the gwt-incubator is reccommended) as described in detail in the setCanvasFactory method.

With the external canvas in place, the next step is to tell GChart you want a curve to be "continuously filled" by invoking setFillSpacing(0).

With each such continuously filled curve, GChart automatically exploits your external canvas library to improved the quality and speed of that curve's rendering. Specifically, banded-filled pie slices become solid filled, dotted connecting lines become continuously connected, and (the biggest stretch) bar charts become area charts. See the setFillSpacing method's javadocs for a detailed description of how each existing symbol type implements this new "continuously-filled", canvas-powered, rendering option.

Note that GChart's previous HTML-only rendering is still available, and is the default rendering mode if you don't bother to plug in an external canvas.

Check out the demo

Posted by Dion Almaer at 6:44 am
3 Comments

+++--
3.5 rating from 13 votes

More than you ever want to see about encoding

Category: Tip, Utility

Paul Baukaus linked to jsescape, a little form that shows escaping and unescaping across a number of encodings.

Andrea Giammarchi had his own post on encodings in a different way.... as he talked about
en-code which you can check out in action here on the page that lets you do simple encodings, especially for source code, in short order.

Posted by Dion Almaer at 5:03 am
7 Comments

+++--
3.5 rating from 8 votes

GeoMaker - geo locations as microformats or a map from texts or URLs

Category: JSON, JavaScript, Yahoo!

As preparation for an upcoming tech talk about Placemaker I thought it would be good to take a bit of the pain out of the geolocation service by making an interface for it. Placemaker works the following way: you post some content or a URL to it, it goes through the content or gets the content from the URL and analyzes it. It then finds geographical locations in the text and disambiguates them (for example to skip names like "Jack London" and not consider it the city London). Finally you get it back as XML.

The annoying thing is that Placemaker only support POST request and does not have a JSON output - for now. GeoMaker allows non-developers to enter some text or a URL, filter the results (using YUI datatable) to remove false positives (no system is perfect) and get the embed code for a Yahoo Map or a list of microformatted locations as copy+paste. See the screencast to get the end user experience:

Of course, every time you build something like that, red-blooded developers will ask for an API to do the same thing (and pointing them to Placemaker wasn't enough). So here it is:

http://icant.co.uk/geomaker/api.php takes two parameters: url of the web document to load and output which could be map, kml, microformats, csv, or json (with callback for JSON-P). Using this you can analyze a url in JavaScript and get the data back as an array:

HTML:
  1. <script>function geomaker(o){
  2.   for(var i=0,j=o.length;i<j ;i++){
  3.     // o[i] will have lat, lon, title and match
  4.   }
  5. }</script>
  6. <script src="http://icant.co.uk/geomaker/api.php?url=http://ajaxian.com&output=json&callback=geomaker"></script>

The Ajaxian.com output right now would be:

JAVASCRIPT:
  1. geomaker(
  2.   [
  3.     {"lat":"42.3586","lon":"-71.0567",
  4.      "title":"Boston, MA, US","match":"Boston"},
  5.     {"lat":"42.3586","lon":"-71.0567",
  6.      "title":"Boston, MA, US","match":"Boston, MA"},
  7.     {"lat":"40.7075","lon":"-106.918","title":"Clark, CO, US",
  8.      "match":"Clark, Co"},
  9.     {"lat":"42.3115","lon":"43.3658","title":"Georgia",
  10.      "match":"Geo"},
  11.     {"lat":"44.9601","lon":"7.16229",
  12.      "title":"Rey, Piedmont, IT","match":"Rey"}
  13.   ])
  14.  

Posted by Chris Heilmann at 3:02 am
2 Comments

++++-
4 rating from 6 votes

Wednesday, July 1st, 2009

Modernizr: HTML5 and CSS3 detection

Category: HTML, Standards

Modernizr is a new library that detects various HTML5 and CSS3 features and lets you know so you can use them:

Writing conditional CSS with Modernizr

Now, once your page loads, Modernizr will run and go through all of its tests. It will automatically add all the classes to the <body> element of the page, and these classes will be along the lines of body.feature or body.no-feature, with the former indicating that the current browser supports that specific feature and the latter indicating that the browser does not support the feature.

Additionally, it will create a new JavaScript object in the global scope, called Modernizr. This object will contain properties for each of the features that Modernizr detects for, and their value will be set to TRUE or FALSE depending on the browser's support for it.

What you can do from this point on is write pseudo-IF/ELSE statements in your CSS. Let's look at an example from the Modernizr.com site itself:

CSS:
  1.  
  2. .cssgradients #main {
  3.     background: -webkit-gradient(linear, left 0, right bottom,
  4.         from(rgba(255,255,255, .82)),
  5.         to(rgba(255,255,255, 0))) 0 0 no-repeat;
  6. }
  7.  

In the above example, we're doing an "IF" condition in CSS: IF the browser supports both CSS gradients, THEN apply this background property to the #main element (instead of the original background property).

Writing conditional JavaScript with Modernizr

When leveraging Modernizr in your JavaScript, it's as straight-forward as it can be to do IF-conditions based on what the browser currently supports:

CSS:
  1.  
  2. if (Modernizr.cssgradients) {
  3.     // perform some actions you only want to
  4.     // execute if the browser supports gradients
  5. }
  6.  

We are seeing a growth in these kinds of tools and shims to get HTML5 features into developers hands. Another great site to help is the new HTML5 Doctor.

Posted by Dion Almaer at 11:29 pm
5 Comments

++++-
4.6 rating from 12 votes

A whole lot of testing for JavaScript implementations

Category: JavaScript, Standards

A couple of releases related to unit testing and JavaScript came out on the same day.

First, the JScript team posted a set of ECMAScript 5 tests.... 900 to be exact, and the focus on features that are new to ECMAScript 5.

All of the tests are released under New BSD.

Then, the V8 team announced Sputnik, a series of of 5000 tests, also under BSD. These tests aren't for the shiny ECMAScript 5 world, but are for ECMA 262, or edition 3.

Nice to see a lot of tests out there, all under liberal open source licensing.

Posted by Dion Almaer at 7:42 am
Comment here

++++-
4.1 rating from 17 votes

Tuesday, June 30th, 2009

Firefox 3.5: The fastest fox has landed

Category: Browsers, Firefox

It is great to feel the good vibes at Mozilla HQ today as we launch Firefox 3.5! It is always an interesting ride to see a browser develop, and realize how complex and large the work is.

Congrats to the browser developers out there who are working hard to make the Web better. With final versions of Firefox 3.5, Safari 4, and Chrome 2 out in the wild.... things are picking up nicely.

The Firefox 3.5 release is exciting for me because it really benefits the developers. We get Open Video, @font-face, cross site XHR, Geo Location APIs, CSS Media Queries, Native JSON, Offline support, Web Workers, and so much more.

And, the world keeps moving. I have seen some very cool things in the nightly tree, and look forward to beign around as the team works on the next great Firefox.

Updates

Steve Souders has posted on Firefox 3.5 getting 10 out of 11 in his UA Profiler tests.

Watch the downloads come in with this cool download tracker that uses Canvas and SVG, all thanks to Justin Scott. The stats so far show that if the current rate trends hold we will beat the Firefox 3.0 download day, which is a surprise to all.

Sean Martell has created a nice wallpaper and persona to commemorate!

Posted by Dion Almaer at 10:35 am
28 Comments

++++-
4.9 rating from 56 votes

LABjs: Simple abstraction for loading dependencies correctly

Category: JavaScript, Performance

Kyle Simpson has developed LABjs, a library that lets you define your JavaScript file dependencies, and then loads them as efficiently as possible.

Kyle told us:

This project is a simple little tool (1.6k compressed!) for being able to load javascript files dynamically. It's like a lot of similar projects where the goal is to improve the speed of page load by allowing scripts to load in parallel. The thing it does slightly differently than most others like it is it allows you to "block", which is to say, load one or more scripts in parallel, then wait for them to finish, before going on to something else, like loading more scripts.

What I wanted was a pattern where I could load scripts in parallel, just like with script tags, but also block and wait if there was an explicit ordering dependency that required it.

What most loaders fail to do well is let you define "dependencies" simply based on loading order. With regular script tags, the browser blocks for you, so you can make sure for instance that jquery.js loads before jqueryui.js. But imagine you've got 3 scripts that can download in parallel (not dependent on each other), and then two more that need to wait for those 3 to load. You can't do that with script tags, and you also can't do that very easily with a lot of the script loaders/frameworks that I've found.

Most of them rely on intrusive concepts to do "dependency" management. For instance, each child script has to "signal" (callback) that it's done loading, to the parent page. Or the parent script and child scripts have to explicitly declare dependencies using some framework or conventions. Also, some other loader libraries rely on attaching a single load callback handler for EACH script. This makes it awkward or difficult to wait for several to load at a time, before proceeding, since you as the author have to keep track of what has loaded yourself.

jsLAB lets you load pretty much any script file, whether you control it or not, with no intrusion or convention for dependencies, other than the order and blocking that you define. It keeps track of what you've asked for and what has downloaded, only loads a unique script filename once, and lets you only define your handler once for a set of scripts that will load together in parallel. The API style (with chaining) makes is very easy to convert a set of script tags in your page into code to load them, without having to worry that race conditions will cause issues for scripts loading in the wrong order if there are implicit dependencies involved.

Example

Old:

HTML:
  1.  
  2. <script src="jquery.js"></script>
  3. <script src="jquery.ui.js"></script>
  4. <script src="myplugin.jquery.js"></script>
  5. <script src="initpage.js"></script>
  6.  

New:

JAVASCRIPT:
  1.  
  2. $LAB
  3. .script("jquery.js")
  4. .block(function(){
  5.       $LAB
  6.       .script("jquery.ui.js")
  7.       .script("myplugin.jquery.js")
  8.       .block(function(){
  9.             $LAB.script("initpage.js");
  10.       });
  11. });
  12.  

In the above example, "jquery.ui.js" and "myplugin.jquery.js" can load in parallel because there's no dependencies, but they will wait for "jquery.js" to load first, since they depend on it, and then "initpage.js" will wait for all of them to load before it runs, to it makes sure all code it will call is in place, similar to a $document.ready(...) concept.

The page link above also shows a few other variations on the .script(...) signature. For instance, you don't have to do a single script() call for each file (though I think it makes thing more readable). You can pass as many scripts singularly as parameters to one script() call. You can also pass an array of scripts, and it will loop through them and load them in the same way. Lastly, you can pass in an object instead of string, and the object literal can contain "src", "type", and "language" specifications, if you want to override the defaults of "text/javascript" and "Javascript", for some reason.

Posted by Dion Almaer at 6:16 am
23 Comments

+++--
3.8 rating from 21 votes

Monday, June 29th, 2009

New Sessions at The Ajax Experience 2009

Category: Ajaxian.com Announcements, Conferences, The Ajax Experience

Summer is right around the corner - so before you make any vacation plans here's one quick action item to cross off your to-do list: Register now to lock in exclusive $300 savings for The Ajax Experience conference, September 14-16 in Boston, MA.

It's only been two weeks since we announced open registration for The Ajax Experience with the promise of additional sessions being added to the web site over the next few weeks. And while a number of your peers have already applied and taken advantage of the $300 early-bird discount (which expires at the end of next month), we've already added more sessions to our agenda, including:

The speakers and attendees at The Ajax Experience are working with the most advanced technologies today, building Ajax and rich Web front ends, as well as figuring out new ways to make response time still faster. And if security, performance, and SOA are important to you, you've come to the right place.

Your $300 discount expires the end of July - register now

If you have any questions about registration, traveling to Boston or bringing a team, please contact your Delegate Relations Manager, Jackie Anderson at janderson@techtarget.com or 781-657-1380. She's more than happy to assist you.

See you at The Ajax Experience!

Posted by tberardi at 12:25 pm
1 Comment

++---
2.5 rating from 19 votes

MySpace open sources advanced browser performance tool for IE

Category: Browsers, IE, Performance

Developers tend to tease MySpace for its look, but the insiders are incredibly impressed by some of the engineering behind the scenes (e.g. their internal monitoring tools are said to be second to none).

They have surprised us again with their new tool MSFast which is "a browser plugin that help developers to improve their code performance by capturing and measuring possible bottlenecks on their web pages."

The IE 8 tools are getting better, but in general no one has been able to touch Firebug (and the new WebKit Inspector improvements) but this tool is actually plugin for IE! It captures a lot:

  • Measure the CPU hit and memory footprint of your pages as they render on the client’s browser
  • Review screen shots of the page while it renders
  • Review the rendered HTML on each point of the page’s lifecycle
  • Measure and show estimates of the time it takes to render each section of the page in different connection speeds
  • Validate the content of your page against a set of proven “best practice” rules of web development
    Review downloaded files and show download time estimation on different bandwidths

That is some impressive data, and great to be able to test on IE where it has been SO hard to do so in the past.

Posted by Dion Almaer at 5:21 am
9 Comments

++++-
4.7 rating from 32 votes

Friday, June 26th, 2009

Fun with text-shadow

Category: CSS, Examples

Zach Johnson is at it again, this time giving us a fun Friday treat with CSS text shadow, all via:

JAVASCRIPT:
  1.  
  2. document.getElementById('text-shadow-box').onmousemove = function(e) {
  3.     var xm = e.clientX - 300;
  4.     var ym = e.clientY - 175;
  5.     var d = Math.sqrt(xm*xm + ym*ym);
  6.     text.style.textShadow = -xm + 'px ' + -ym + 'px ' + (d / 5 + 10) + 'px black';
  7.    
  8.     xm = e.clientX - 600;
  9.     ym = e.clientY - 450;
  10.     spot.style.backgroundPosition = xm + 'px ' + ym + 'px';
  11. }
  12.  

Posted by Dion Almaer at 11:26 am
13 Comments

++++-
4.1 rating from 30 votes

Scripty2 has landed

Category: Scriptaculous

Thomas Fuchs has been working in the open on scripty2 for a bit, and now the website has launched.

It even comes with nice documentation and fun demos:

What's new in scripty2? It is a complete rewrite, and comes packaged in three parts:

scripty2 core contains the main namespace and an area for extensions to be added. It also contains helpers and the like.

scripty2 fx: The scripty2 effects framework provides for time-based transformations of DOM elements and arbitrary JavaScript objects. This is at the core of scripty2 and presents a refinement of the visual effects framework of script.aculo.us 1.X.

scripty2 ui currently has one submodule: Utility functions for CSS parsing, color normalization and tweening.

We are doing more and more on the client, requiring nice programming models to do cool effects. Great to see one of the granddaddies of them all get a new coat.

Posted by Dion Almaer at 12:14 am
15 Comments

++++-
4.5 rating from 58 votes

Thursday, June 25th, 2009

First beta of YUI 3.0 released

Category: JavaScript, Library, Yahoo!

Congrats to the YUI team for releasing their first beta of YUI 3:

We’ve spent a lot of time in this release cycle refining the core elements of YUI 3 — YUI, Node, and Event — to ensure that we have the right API going forward. Performance is improved, and we’ve refined our module/submodule structure. In some cases we’ve added significant new features, including intrinsic support for event delegation in the Event package; however, the focus is on moving the base library to production quality.

Several YUI 2.x components make their YUI 3 debut in this release:

  1. DataSource: YUI’s data abstraction layer provides a standard interface into data sets, regardless of the data’s origin (local, XHR, XSS, etc.) and format (JSON, XML, CSV, etc.);
  2. ImageLoader: ImageLoader allows you to defer the loading of images that aren’t in the viewport when the page paints, throttling bandwidth usage and improving performance;
  3. History: The History component gives you control of the brower’s back button within the context of a single-page web application;
  4. StyleSheet: StyleSheet makes it easy to create and modify CSS rules on the fly, allowing you to dynamically style page elements with fewer repaints.

As part of the more granular packaging in the new codeline, we’ve created separate YUI 3 modules to house functionality that in YUI 2 was bundled with other components. Cache, DataType and DataSchema debut in this release; each of these used to be a part of DataSource.

To keep up to date, check out the roadmap and dashboard that the team keeps up to date.

Posted by Dion Almaer at 6:52 am
Comment here

++++-
4.2 rating from 31 votes

JavaScript sandbox using Web Workers

Category: JavaScript, Library

We have been sandboxing JavaScript in iframes for a long time. The Web Worker API has the nice property that it doesn't have access to objects like document and the like, and just runs code that you can pass over to it.

With this, Elijah Grey has created an experimental jsandbox API that gives you an eval function that you pass in some code, and optionally input data, callback for results, and an onerror callback.

Code looks like this:

JAVASCRIPT:
  1.  
  2. jsandbox
  3.     .eval({
  4.       code    : "x=1;Math.round(Math.pow(input, ++x))",
  5.       input   : 36.565010597564445,
  6.       callback: function(n) {
  7.           console.log("number: ", n); // number: 1337
  8.       }
  9.   }).eval({
  10.       code   : "][];.]\\ (*# ($(! ~",
  11.       onerror: function(ex) {
  12.           console.log("syntax error: ", ex); // syntax error: [error object]
  13.       }
  14.   }).eval({
  15.       code    : '"foo"+input',
  16.       input   : "bar",
  17.       callback: function(str) {
  18.           console.log("string: ", str); // string: foobar
  19.       }
  20.   }).eval({
  21.       code    : "({q:1, w:2})",
  22.       callback: function(obj) {
  23.           console.log("object: ", obj); // object: object q=1 w=2
  24.       }
  25.   }).eval({
  26.       code    : "[1, 2, 3].concat(input)",
  27.       input   : [4, 5, 6],
  28.       callback: function(arr) {
  29.           console.log("array: ", arr); // array: [1, 2, 3, 4, 5, 6]
  30.       }
  31.   }).eval({
  32.       code    : "function x(z){this.y=z;};new x(input)",
  33.       input   : 4,
  34.       callback: function(x) {
  35.           console.log("new x: ", x); // new x: object y=4
  36.       }
  37.   });
  38.  

Posted by Dion Almaer at 6:17 am
2 Comments

+++--
3 rating from 14 votes

Wednesday, June 24th, 2009

iPhone 3GS runs faster than claims, if you go by SunSpider

Category: Mobile, Performance

Rana Sobhany of Medialets has posted on Sun Spider benchmarks of the iPhone 3GS as well as other devices which shows off the performance angle of 3GS:

The WebKit Open Source Project provides a JavaScript test Suite dubbed SunSpider. According to the description on the SunSpider home page, “this benchmark tests the core JavaScript language only, not the DOM or other browser APIs. It is designed to compare different versions of the same browser, and different browsers to each other.” We at Medialets have found it to be one of the best attempts to measure real world JavaScript performance in a balanced and statistically sound way.

Medialets ran the SunSpider test suite in the following environments:

  1. Safari 4.0.1 on a 2.0 GHz Intel Core 2 Duo White MacBook.
  2. The MacBook results were used as a baseline for relative comparisons.
  3. Mobile Safari on the iPhone 3G with iPhone OS v2.2.1
  4. Mobile Safari on the iPhone 3G with iPhone OS v3.0
  5. Mobile Safari on the iPhone 3GS with iPhone OS v3.0
  6. The “Browser” app on the T-Mobile G1 with Android OS v1.5 (Cupcake)
  7. The “Web” app on the Palm Pre with Web OS v1.0.2

Each device was fully restored and rebooted immediately before running the test suite. Every attempt was made to assure that no atypical background tasks were executing while the tests were running. The SunSpider tests automatically run five times sequentially and the mean average from all five tests are reported. Network speed and latency have no effect on the results of the test.

We all know to beware of benchmarks, but it does show off how powerful these devices are getting!

Posted by Dion Almaer at 3:03 pm
7 Comments

++++-
4.2 rating from 30 votes

Next Page »