» tagged pages
» logout

sorted by: recent | see : popular
Content Tagged with front + Examples

Coverflow again…. with Canvas

For some reason, we like to implement Coverflow to see if the technology of choice is decent enough to do so. This latest version works with Canvas, and does a nice job of smoothly doing the animations at hand. All you have to do is:

JAVASCRIPT:
  1.  
  2. Coverflow.init(
  3.         [
  4.                 {src: 'img/img-0-lo.jpg', label: {album: 'All That I Am', artist: 'Santana'}},
  5.                 {src: 'img/img-1-lo.jpg', label: {album: 'August & Everything After', artist: 'Counting Crows'}},
  6.                 {src: 'img/img-2-lo.jpg', label: {album: 'Back to Bedlam', artist: 'James Blunt'}},
  7.                 {src: 'img/img-3-lo.jpg', label: {album: 'Carnival of Rust', artist: 'Poets of the Fall'}},
  8.                 {src: 'img/img-4-lo.jpg', label: {album: 'Collision Course', artist: 'Linkin Park'}},
  9.                 {src: 'img/img-5-lo.jpg', label: {album: 'Crossfade', artist: 'Crossfade'}},
  10.                 {src: 'img/img-6-lo.jpg', label: {album: 'Dexter', artist: 'Rolfe Kent'}},
  11.                 {src: 'img/img-7-lo.jpg', label: {album: 'Life for Rent', artist: 'Dido'}},
  12.                 {src: 'img/img-8-lo.jpg', label: {album: 'Say I Am You', artist: 'The Weepies'}},
  13.                 {src: 'img/img-9-lo.jpg', label: {album: 'Signs of Life', artist: 'Poets of the Fall'}},
  14.                 {src: 'img/img-10-lo.jpg', label: {album: 'Viva la Vida', artist: 'Coldplay'}},
  15.                 {src: 'img/img-11-lo.jpg', label: {album: 'We Were Here', artist: 'Joshua Radin'}}
  16.         ],
  17.         {
  18.                 createLabel: function(item)
  19.                 {
  20.                         return item.label.album +'<br />'+ item.label.artist;
  21.                 },
  22.        
  23.                 onSelectCenter: function(item, id)
  24.                 {
  25.                         var img = new Image();
  26.                         img.onload = function()
  27.                         {
  28.                                 Lightbox.show(this.src, id);
  29.                         };
  30.                         img.src = item.src.replace('-lo.jpg', '-hi.jpg');
  31.                 }
  32.         });
  33.  

Ajax: Ajaxian

Reading ID3 tags with JavaScript

Jacob Seidelin is up to more tricks, this time playing with the binary side of life and writing a library that can reading ID3 tags from MP3 files and such.

JAVASCRIPT:
  1.  
  2. // URL of the mp3 file (must be on the same domain!)
  3. var file = "mymusicfile.mp3";
  4.  
  5. // define your own callback function
  6. function mycallback() {
  7.  // either call the ID3.getAllTags([file]) function which returns an object holding all the tags
  8.  alert(
  9.   "All tags in this file: " + ID3.getAllTags(file).toSource()
  10.  );
  11.  
  12.  // or call ID3.getTag([file], [tag]) to get a specific tag
  13.  alert(
  14.   "Title: " + ID3.getTag(file, "title") + " by artist: " + ID3.getTag(file, "artist")
  15.  );
  16. }
  17.  
  18. ID3.loadTags(file, mycallback);
  19.  

You can view a demo at work or download the code.

Of course, Jacob realises that this doesn't make sense for many use cases:

Of course, one big disadvantage of doing this on the client in JavaScript is that the you need to download the entire MP3 file before the tags are available, so it might be better to stick to server-side solutions in many cases if all you need is the tag info.

Ajax: Ajaxian

A simple solution to the “other” problem with select boxes

Jeffrey Olchovy has posted a simple tutorial on using jQuery to solve a "select-to-input toggle" that shows and hides a text field when you select "Other". It overloads the same form name, so the server side gets just one value, and doesn't know or care if it was in the drop down or typed in. You can try it live here.

This is a simple little solution to the issue that there isn't a native control to really do the job. What you really probably want here is the ability to drop down and select items, or just type into the select box field itself. This is one reason why people implement auto-complete text fields instead of using select boxes for this case, but wouldn't it be nice to be able to tag your <select> and be done?

Ajax: Ajaxian

Custom events as API end points for key bindings and more

Inspired by the Gmail team and how they created well known Greasemonkey endpoints and the custom events work that I have been doing, I was lead to play with custom events as a way to tie into key bindings. This lead to the following post on my blog:

On the back of my example enjoying the Observer pattern with custom events I have started to play with a pet project also involving custom events.

I love keyboard shortcuts. I hate the mouse. I wish that Web applications would offer more keyboard shortcuts a la Gmail, and wondered if there could be a generic way to tie keys to actions in an app. There are things such as accessKey, but we need more.

If you start to follow the pattern of creating named events for public integration points, then how about tieing in keys? I implemented this on the quote example, where you can now use up and down arrows, and N and P, to move through the list of names.

To use the system you declare the keys and tie them to events:

JAVASCRIPT:
  1.  
  2. KeyBindings.add({
  3.    eventname: 'action:move-up',
  4.    // keys: KeyBindings.caseInsensitive('p'),
  5.    keys: ['p', Key.ARROW_UP ],
  6.    description: "Move up the stack"
  7. });
  8.  
  9. KeyBindings.add({
  10.    eventname: 'action:move-down',
  11.    keys: ['n', Key.ARROW_DOWN ],
  12.    description: "Move down the stack"
  13. });
  14.  

This code ties the keys to the actions, and thus fires those actions when pressed. Next, you need to capture those events to do the work when the key is fired:

JAVASCRIPT:
  1.  
  2. document.observe('action:move-up', function(e) {
  3.     Selection.moveUp();
  4. });
  5.  
  6. document.observe('action:move-down', function(e) {
  7.     Selection.moveDown();
  8. });
  9.  

With a standardized way of annotating events, interesting side effects appear. You can hit the '?' key to bring down a heads up display sharing what keys do. You could imagine a Greasemonkey script, or browser plugin, that loads the keybindings.js code, and looks for the key binding definitions. The declaration could be done in HTML too, which could be found by the plugin and tied into the system. What do you think?

Ajax: Ajaxian

Badging Flickr with Dojo

Dylan Schiemann has a really nice case study post on implementing a Flickr badge with Dojo.

What is particularly interesting is how he starts with a simple version:

HTML:
  1.  
  2. ...
  3. <link rel="stylesheet" href="/dojo/dojox/image/resources/image.css" />
  4. <style type="text/css">
  5.         img.thing { width:50px; height:50px; }
  6. </style>
  7. ...
  8. </head>
  9. ...
  10. <div dojoType="dojox.image.FlickrBadge" rows="8" cols="3" username="dylans"
  11.         tags="dojotoolkit,italy"></div>
  12. ...
  13. <script type="text/javascript" src="/dojo/dojo/dojo.js"
  14.         djConfig="parseOnLoad: true"></script>
  15. <script type="text/javascript">
  16.         dojo.require("dojox.image.FlickrBadge");
  17. </script>
  18. </body>
  19.  

And then shows how he tweaks it for performance, explaining what he is doing along the way:

HTML:
  1.  
  2. ...
  3. <link rel="stylesheet" href="/dojo/dojox/image/resources/image.css" />
  4. <style type="text/css">
  5.         img.thing { width:50px; height:50px; }
  6. </style>
  7. ...
  8. </head>
  9. ...
  10. <div id="flickrSidebox"></div>
  11. ...
  12. <script type="text/javascript" src="/dojo/dojo/dojo.js"></script>
  13. <script type="text/javascript">
  14.         function initBadge(){
  15.                 new dojox.image.FlickrBadge({rows: 8, cols: 3,
  16.                         username: "dylans", tags:"italy,dojotoolkit"},
  17.                         "flickrSidebox").startup();
  18.         }
  19.         dojo.addOnLoad(function(){ dojo.require("dojo.badge");
  20.                 dojo.addOnLoad(initBadge)});
  21. </script>
  22.  

It is nice to see his thought process, and how you can start with functionality, and then go back and tweak away.

Ajax: Ajaxian

Frank Sinatra, Flash, and Ajax: Deckmyplace.com

Scott Boyce wrote in with an interesting story about deckmyplace.com.

The site was originally designed as a Flash site, but when the mandate came from the top to use HTML instead of Flash, he had to see just how much of the original comps he could implement. And it turns out, pretty much everything.

We asked Scott to share some details on his experiences building the site:

When the mandate to drop Flash came, there wasn't time to redesign. My goal was to make it indistinguishable from Flash visually, but do so while employing valid markup, progressive enhancement, and Section 508 accessibility.

MooTools

I had previously used Mootools (and moo.fx prior to that) to add subtle animation to interface elements, but I had not built a site entirely around it (or any other JS library). I had also not created a site with such explicit positioning throughout, so there were CSS challenges as well.

I used a lot of Mootools' built-in assets: AJAX, tool tips, sliders.

Fancy Page Transitions

The page transitions are done with a combination of effects. Basically, there's three layers: the frame, the content, and the (ususally hidden) background. When the user navigates to a new page, the following occurs:

1. The background is switched to a blurred screenshot of the current page (instant; the image has been pre-loaded).
2. The opacity of the content area is reduced, revealing the blurred background image (300 ms).
3. New content is loaded via AJAX (each content page is about 1 KB; the lounge is about 4 KB).
4. The opacity of the content area is scaled back to 100% (300 ms).

The Development Process

The content was first laid out with HTML, using PHP includes to eliminate the need for any duplicate content. (Incidentally, the entry form and validation were also written in PHP.) The CSS was created alongside this framework, which resulted in the JS-disabled version of the site. Once we were satisfied there were no issues with the display or functionality in a few target browsers (Firefox, IE6, Safari, Opera, Lynx, IE6 + JAWS), I started writing event listeners.

Once the JavaScript was written, we tested again. In the end, I think the only thing we had to drop were the background music and some of the secondary animation (spinning knobs). Still, most people just assume it's Flash.

Firebug, YSlow, and the Web Developer toolbar for Firefox were invaluable tools during development

Stats

* Total JavaScript is 59 KB (51 KB for Mootools + 8 KB for the library)
* 30.9 KB of CSS (including 4.7 KB of CSS for MSIE loaded via conditional comments)
* 2.59 MB for the whole site (2.11 MB of images)

I love the legal disclaimer at the bottom:

The thought of a corporation owning a trademark on a given name... fascinating. I can only imagine the future litigation between the Dave Thomas' of the world.

Ajax: Ajaxian

iWidgets Public Beta: Impressive Widget Builder

Joining with the Web 2.0 "go-meta" business model that's so popular these days, iWidgets provides a service that lets you build widgets once and deploy them to various popular widget APIs and platforms.

At the heart of iWidgets is a "PowerPoint-like" widget builder that takes strong design cues from Yahoo! Pipes, but as Peter Yared (CEO of iWidgets) says:

then again Pipes looks a lot like Prograph (the original dataflow programming company, where I worked from 1992-1995)

The site transforms the widget you build into:

a native FBML or GoogleGadget/OpenSocial, which are two completely different architectures (serverside vs. clientside), and then call the destination-specific API's for things like persistence whenever possible.

The builder was constructed using jQuery and like Pipes renders the connection lines using <canvas>. Peter shared some of the back story behind building the application:

I wrote the initial builder in [another framework] and found it obtuse. After spending literally a week trying to turn the date picker into a color picker, I threw in the towel. A friend of mine turned me on to jQuery and I fell in love with how clean and fast it was, the way it separates the HTML from JavaScript is beautiful. So I rewrote the builder we had at the time in jQuery in a two week coding session! Soon after that I got funding from Opus Capital, and when I looked to hire people, I found 3 out of 4 of our engineers through the jQuery mailing list. It's funny how things like that work out; I ended up finding total rockstars because they were playing with a cool new library.

Peter also shared some details on the overall development process:

It took us 10 months to build the site, we have had one guy (Richard Hensel) full time on the builder UI with another guy (Jeremy Stanton) on it about 1/3 time, with the rest of his time on the overall site doing the wizards and getting things like the %#$# back button to work. Then there are two guys working on the backend, one on FBML and the other on Gadget/OpenSocial, and we just added a junior AJAX guy. We contribute back where we can, for example Jeremy contributed to the Selectable in jQuery UI. The iWidgets site itself is completely AJAX, data from the server is sent as JSON, and page fragments are rendered with Wicket. We persist the widgets you build as JSON and then transform them on the server into native Facebook, MySpace, iGoogle, etc.

The team has some future plans building on top of an already very cool site:

We have a bunch of features we are rolling out, such as calling JSON and piping the results into different components, repeating table, paging, cut/copy/paste, z-order control, live dataflows in the builder, a background process at amazon that sends out notifications like "joe just shot 2 over par at pebble beach" to newsfeeds to drive virality, more platforms such as the iPhone, etc.

I wonder if this should somehow integrate with Yahoo Widgets, Apple's Dashboard, and other desktop widget platforms... maybe emit a bundle you can download and install into these services?

Ajax: Ajaxian

72photos: Proto/Scripty Photo Sharing Site

XMG Networks has thrown their hat into the on-line photo sharing ring with the launch of 72photos, an Ajax-heavy site which looks at least partially inspired by Apple's iPhoto '08-generated web galleries.

We asked 72photos to tell us a bit about how they went about building the site and how it compares to competitors like Flickr and Smugmug; "Eric A" kindly replied with some details:

Building the Site

We do indeed use Prototype / Scriptaculous for our main Javascript frameworks and it's been that combination from the very beginning. There's always been a way to accomplish want we've needed PT and is due to the fact we tend to use more of the basic PT functions (selectors, event handers) and build our own "sub-frameworks" as we go along. Our functionality is fairly unique to the web and hasn't been done in any sort of pre-packaged framework yet (as I know of). Thus, we found ourselves building a good portion of things in-house.

Features

We don't do anything extremely new or groundbreaking in terms of features at the moment, somewhat of a reason for that is the fact our site appeals to a large percentage of novice users and we wanted to tune our functions to resemble something such as a desktop application which seems to be the familiar place for all users. However, as development continues, we're constantly finding the balance between integrating professional features as well as fine-tuning the basic features that everyone is familiar with. There are a myriad of experimental features we have planned and developed, but opted to build a solid foundation incorporating those familiarities before implementing our more eccentric features which we'll be looking to integrate over the next few months.

Compared to Other Photo Sharing Sites

1. Fully customizable photo galleries - Our gallery interface features drag & drop functionality to add and arrange photos in a gallery. Real time customization options let users customize the colors and fonts for the gallery and preview the changes real-time. Several preset gallery themes are also available. Here's a sample screen:

2. Profile pages - All users get a full profile page displaying all their photos, tags and galleries elegantly:

3. Community Features - Our community features are also superior to that of other sites, such as the ability to track friends activity by seeing recent uploads or galleries by them and having the ability specify the type of friend they are (friend / family) then modify your photo/gallery/profile permissions accordingly.

4. Editing - Our editing features are all done in Ajax / Javascript which covers the basic cropping, effects, enhancing, constraining and will soon feature much more robust functions including step-by-step versioning (compared to our basic versioning features) and a greater array of editing effects and manipulation functions (batch editing, watermarking, etc).

5. Webspace - We always save users fullsize photos, no size caps on individual photos or monthly limits. Only an overall size limit per account type (free or pro).

6. Usability - All the backend functions are done "real-time" in lightbox windows, so there is minimal page reloading which is offers a considerable increase in efficiency when working with photos and galleries.

Eric also shared some of their plans for the future:

Currently, 72photos is just an evolved version of sites such as Smugmug, Flickr, and Zenfolio. Offering features to professionals and novice users in a carefully thought out and intuitive interface. In the near future we'll be greatly expanding our community features to cover areas of what you do after the point of uploading and editing your photos. Such as offering areas for photographers and artists to sell their art and other areas such as a place allowing models to find photographers in their area, vice versa, and more.

I just wish the iPhone would follow other handset manufacturer's lead and put a really nice camera in the phone. I know I'd pay extra money to have a 4 MP camera with a nice lens and a flash...

Ajax: Ajaxian

Obsurvey: Ajax-heavy Survey Engine

Allan Ebdrup wrote in to point us to Obsurvey.

Obsurvey features a highly dynamic interface for building custom surveys; you can choose from a bunch of different survey elements and customize them in place using a technology the Obsurvey team calls "Active Rich Document" (ARD). Nicely done!

Ajax: Ajaxian

On-line Auction Aggregator Innovates with Ajax

jigadig

Dov Katz pointed us to Josh Bochner's labor of love, http://www.jigadig.com/. It's an Ajax-heavy jQuery-powered auction site aggregator. What really got our attention is the search results page, which among other things lets you view full item descriptions in-line without having to jump to a different page, infinitely scroll, and easily "pin" interesting items for later perusal. Nice job Josh, and definitely worth a look.

Ajax: Ajaxian

Usable Directory Listings with Dojo

Dojo Directory Shortcut

Sam Foster has written up an example of using Dojo to create directory listings with keyboard shortcuts.

You can now tab over to the box on the top right, and filter your selections:

This tutorial shows you how to upgrade those plain vanilla pages to make getting around a little faster and along the way introduce you to some of the most useful bits of Dojo, and practical techniques for working with them. We’ll touch on: dojo.query, dojo.data, the dojo parser and dijit (specifically the FilteringSelect widget.)

This is a great look at how things work in Dojo land, including the interesting code embed technique:

HTML:
  1.  
  2. <div style="display:none" jsId="linksStore"
  3.         dojoType="dojo.data.ItemFileWriteStore">
  4.         <script type="dojo/method" event="preamble" args="params">
  5.                 params.data = {
  6.                         identifier: "id",
  7.                         items: []
  8.                 }
  9.         </script>
  10. </div>
  11.  

Ajax: Ajaxian

Making application modules communicate with each other using Decoupling

I've been talking about event driven application design in JavaScript in January last year and inspired Caridy Patiño to write his Bubbling Library based on these ideas.

Caridy now upped the ante a bit by talking about decoupling using the bubbling library over on the YUI blog.

In essence, his solution allows you to have custom events on application modules and listen to them independent of execution order or availability. Simply using custom events can get you in a pickle if you make yourself dependent on their order. With the decoupling solution proposed by Caridy this becomes one less issue to worry about.

Ajax: Ajaxian

Reminded of speaking your YAHOO.lang

Mitchell Amihod has a nice little post talking about the features in YAHOO.lang which is probably the least mentioned part of YUI.

He starts out with the type checking functions such as like isNull(), isUndefined(), isValue(); then he does for a trim().

Did you know that YUI had a mini template language in the form of substitute?

JAVASCRIPT:
  1.  
  2. // simple
  3. YAHOO.lang.substitute('Hello {world}', {'world':'earth'});
  4.  
  5. // process
  6. var processText = function(key, value, extraInfo) {
  7.   if(!YAHOO.lang.isNull(extraInfo)) {
  8.     return extraInfo;
  9.   }
  10.   return value.toUpperCase();
  11. };
  12. YAHOO.lang.substitute('Hello {world Venus, Jupiter}', {'world':'earth'}, processText);
  13.  

No DHTML library would go without wrapping the setInterval/Timeout calls:

JAVASCRIPT:
  1.  
  2. var foo = {
  3.   count :0,
  4.   'method' : function(data) {
  5.     this.count++;
  6.     if(this.count == 10) {
  7.       timer.cancel();
  8.     }
  9.     console.log(this.count);
  10.   }
  11. } 
  12. var timer = YAHOO.lang.later(1000, foo, 'method', [{data:'bar', data2:'zeta'}], true);`
  13.  

And then you have the need to merge. If you are used to Rails development you will get addicted to passing hashes around and using merge type operations to do your deed.

JAVASCRIPT:
  1.  
  2. var myAwesomelWidget = function(oConfigs) {
  3.   oConfigs = oConfigs || {};
  4.   var defaults = {
  5.     'awesomeness' : '11',
  6.     'shiny'       : 'high',
  7.     'sparkle'     : 'high'
  8.   }
  9.  
  10.   var combinedConfigs = YAHOO.lang.merge(defaults, oConfigs);
  11.   //Shiny is now set to low, everything else in combinedConfigs is set to the defaults
  12. };
  13. myAwesomelWidget({'shiny': 'low'});`
  14.  

Ajax: Ajaxian

JSONVid: Pure JavaScript Video Player

Jacob Seidelin went on a ( crazy :) ) mission to create a pure JavaScript video player that didn't use Flash:

My first thought was to read binary video files using a technique like the Andy Na posted about here, figuring that there must be some really simple to parse video formats around, but I soon changed directions and decided to make up a whole new video format. Enter.. JSONVid. Using a player like mplayer, it is easy to export all frames in a movie clip to individual jpeg files, and using whichever language you prefer it is also fairly trivial to collect these files, base64 encode the bunch of them and throw them all together in a nice JSON file (I used this PHP script).

The format uses good ole data: URLs, which are finally supported in IE with version 8:

JSON:

    {
      frm : "JSVID",   // format id tag
      ver : 1,  // version number of format
      width : 320,  // width of video
      height : 240,  // height of video
      rate : 15,  // framerate (frames per second)
      frames : 495,  // number of frames in file
      data : {
        video : [ // here comes 495 data:uris containing base64 encoded jpeg image frames
          "data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEASABIAAD/7gAOQWRv ... ",
          "data:image/jpeg;base64,/9j/4AAQSkZJRgABAgEASABIAAD/7gAOQWRv ... ",
          ...
        ]
      }
    }

Then he created the player:

First strategy was to create an Image object for each frame and render it on a canvas element using drawImage(). That worked fine and performance was nice (although Opera used a lot of CPU), but I figured I'd try just using a regular image tag and just change the src property to another data:uri each frame. The change was barely noticeably in Firefox and Safari and it ran a bit better in Opera, so I lost the canvas and stuck with plain old images.

Now, it seems that Firefox will eat up all the memory in the world if you keep throwing new data:uris at the same image tag, which led to another change, so for each frame a new Image object was created and saved for later and as the video played, the previous frame Image was replaced by the new Image object. That seemed to work, but introduced an annoying delay as all these Image objects were created before playing, so I ended up moving the Image creation to actual render cycle where it simply checks if the frame Image has already been created, and if not, creates it.

You can now get going with HTML such as:

HTML:
  1.  
  2. <script src="jsvideo.js" type="text/javascript"></script>
  3. </head>
  4. <div videosrc="myvideo.jsvid" videoautoplay="true"></div>
  5. </body>
  6. </html>
  7.  

There are a couple of tests to play with. It was also pointed out that maybe an animated gif/png would be a choice (without controls), and of course, Flash is still the best choice here, until we get video support in most browsers.

Ajax: Ajaxian