» tagged pages
» logout

(Feed found, click Add Page to syndicate.) Error finding feed, please try again » Find feed title

A Blog Page allows you to add entries, for news or other time sensitive postings

(Login required to save to your tagged pages.)
(or Cancel)

Make further edits, (or Cancel)

(Login required to save to your tagged pages.)
(or Cancel)

(Editing anonymously: to be credited for your changes, login or register a new account)

Change Page Permissions? Changing these permissions will adjust who can modify this page.

Anonymous (change)
Swik Users (change)
(or Cancel)
Upload an image from your computer:
or Copy an image from a URL:
or Erase the current icon:
Icon Preview:

or Cancel

Erase Page? The contents of Page page and all pages directly attached to Page will be erased.

or Cancel

(Editing anonymously: to be credited for your changes, login or register a new account)

other page actions:
Page

Page

Tags Applied to Page

No one has tagged this page.

sorted by: recent | see : popular
Content Tagged Page

Web Workers update for Firefox 3.1

Ben Turner has nicely written up the state of Web Workers that we will see in Firefox 3.1 (in beta 2 right now).

To show the latest, Ben got a demo working that decrypts Weave data in the client using a Worker:

JAVASCRIPT:
  1.  
  2.       // Launch the main worker.
  3.       if (!worker) {
  4.         worker = new Worker("weaveDecryptorWorker.js");
  5.         worker.onerror = onerror;
  6.         worker.onmessage = onmessage;
  7.       }
  8.  
  9.       worker.postMessage({ types: types,
  10.                            user: document.getElementById("username").value,
  11.                            phrase: document.getElementById("passphrase").value,
  12.                            server: document.getElementById("server").value });
  13.  
  14.  

What's changed?

  1. The navigator object has been added to the worker scope. It contains the following strings that identify the browser, just as from normal script:
    • appName
    • appVersion
    • platform
    • userAgent
  2. Workers can now be forcefully killed via the terminate function. Calling this function on a worker will immediately stop the worker’s execution.
  3. Workers may only be created from a worker script that is hosted within the same origin as the parent page.
  4. URIs for subworker scripts and imported scripts are now resolved relative to the parent worker script location instead of the owning page.
  5. Error handling has been reworked according to recent spec changes. A worker script can now define an onerror handler that will be called with an error event with details about the exception. If the handler calls preventDefault on the event object then nothing else happens. If preventDefault is not called then the error event propagates to the parent scope’s (either a worker or the parent page) onerror handler.
  6. Numbers, booleans, and even objects may be passed to postMessage in addition to strings. The only restriction is that objects may not contain functions or cyclical references (since we use JSON under the hood). This simplifies previous code that needed to use the JSON object to manually encode/decode the strings passed to postMessage.

Ajax: Ajaxian

Watch out for the zoom; Debugging fun with Canvas

Ben was cursing at a bug in some canvas code that he was playing with, where the rendering was off. One piece of his UI was blurred instead of crisp.

The debugging exersize was fun, and he shares it with you on his personal blog.

The moral of the story is: watch out for that zoom feature in today's browsers!

Along the way, I got to learn that canvas supports fractional coordinates:

My first thought was that it would be due to fractional coordinates. I have years of experience with drawing APIs that force integer coordinates, so I’m used to relying whacking off the fractional part of a coordinate and making up the difference when necessary in a second pass. Canvas, on the other hand, supports fractional coordinates, which I’m told is the fancy thing to do these days. (How the fraction is converted to an actual pixel is depenendent on whatever drawing system is doing the heavy lifting somewhere down the stack.) When your coordinates are fractional, you can get this kind of fuzziness.

Because the interface I’m working with involves a few layers of rendering code, ensuring that integers ruled the roost took some time. But after quite a bit of poking around, I found no evidence of fractional coordinates. It was around this time I saw Vlad (Mozilla’s graphics guru) walking around the office and asked for some help.

We started looking for evidence of transforms that would introduce fractional coordinates–but ultimately came up empty handed. As we went through this process, he pointed out that the <canvas> context instances are reused, so it’s a really good idea to save() and restore() when obtaining a canvas to avoid polluting the context:

JAVASCRIPT:
  1.  
  2. var ctx = canvas.getContext("2d");
  3. ctx.save();
  4. // painting here
  5. ctx.restore();
  6.  

I had assumed each call produced a fresh, stateless context, so this was welcome news indeed.

But, user error was the true case:

And that’s when we noticed that I had zoomed in a click using Firefox 3’s fancy full page zoom feature. And that was causing the image the be scaled up, and the blurriness.

Ajax: Ajaxian

AddressChooser: address picker in real-time

SƩbastein Gruhier has released a new address component that integrated a map with the address that you are filling. The UX is interesting as when you first get typing it doesn't really narrow down the address so you are seeing maps of bizarre places.

As well as a basic version, you can also tie in auto complete.

Features include:

  • Javascript framework-agnostic. You can use it as is or with any great frameworks like Prototype, JQuery …
  • Mapping system independent. The current implementation is based on Google Map using a Google Map proxy object.
  • Interactive map display location while you arex typing an address.
  • Center map on user location (based on its IP) if mapping system allows it.
  • Fully customizable.
  • Fully documented with pdoc.
  • Works on Safari, Firefox, IE 6/7, Chrome and Opera.
  • ...

Ajax: Ajaxian

Technical Details Behind iWork.com

As soon as I heard about the new iWork.com site launched yesterday, I knew I wanted to know more about how it was made. iWork.com is a web-based way to share and collaborate over your iWork documents. I searched around the blogosphere seeing if anyone knew any technical details, but didn't find anything, so I had to crack open Firebug and see what was under the covers. I really wanted to know whether the apps were built with Flash or Ajax or something else.

I downloaded a trial version of iWork 2009 and published a Keynote presentation. The new Sharing function unfortunately requires you to configure and use the Apple Mail program, which I did before I could test out to see how the iWork.com shared documents work.

Looking at the JavaScript files, I see SproutCore and Prototype being pulled in, so everything is built with Ajax and web technologies. It's also using WebDAV to pull in the metadata about the document, which is interesting (though it's piping the WebDAV over some kind of proxy):

http://publish.iwork.com/iw/p159985190/.iWork/Share/Untitled.pages/Metadata/?webdav-method=PROPFIND

That URL returns an XML WebDAV document with the document metadata properties:

XML:
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <multistatus xmlns="DAV:">
  3. <d :response xmlns:D="DAV:">
  4.  </d><d :href>/iw/p159985190/.iWork/Share/Untitled.pages/Metadata/</d>
  5.  <d :propstat>
  6.   </d><d :prop>
  7.    </d><d :resourcetype>
  8.     <d :collection />
  9.    </d>
  10.    <d :getlastmodified>Wed, 07 Jan 2009 02:07:51 GMT</d>
  11.  
  12.    <d :modificationdate>2009-01-07T02:07:51Z</d>
  13.    <d :comment>1231293220308</d>
  14.    <x :Heckler.pages xmlns:X="urn:iwork:property">[{"guid":1,"type":"Page","w":612,"h":792}
  15. ]
  16. </x>
  17.    <x :Heckler.downloads xmlns:X="urn:iwork:property">[{"size":198284,"path":"Untitled.pages","guid":1,"downloadType":"pages09","type":"Download"},{"size":73533,"path":"Untitled.pdf","guid":2,"downloadType":"pdf","type":"Download"},{"size":30720,"path":"Untitled.doc","guid":3,"downloadType":"word","type":"Download"}]</x>
  18.    <x :Heckler.document xmlns:X="urn:iwork:property">[{"publishName":"Untitled.pages","publishDate":1231293215,"title":"Untitled","appBuildDate":"Dec 21 2008, 01:44:15","type":"Document","size":604363,"viewers":0,"marketeerPublishName":"b4d96779c707ea0d05ba5d33989ba0e45f874d3b40204a46895cdac1bd2fafac","guid":"Untitled.pages","nativeDownload":"Untitled.pages","authorEmail":"bradneuberg@gmail.com","documentType":3,"pageCount":1,"documentVersion":92008102400,"passwordProtected":false}]</x>
  19.  
  20.  
  21.   <d :status>HTTP/1.1 200 OK</d>
  22.  
  23.  
  24. </multistatus>

Notice how some of the metadata payload is JSON as well.

The web-based iWork apps are themselves built above SproutCore, using that framework to organize and do things. For example, there appears to be something named CoreHeckler that has to do with the commenting system, all built using SproutCore.

Using the Firebug Inspector, I see that the slides are a combination of an image file, the Canvas tag, and transparent DIVs that overlay; if there are hyperlinks on the page they are overlaid on a separate DIV that lies over the canvas. Comments also float on top of the Canvas using another DIV. The Canvas appears to be used for comments somehow, but I'm not sure how. I see CoreHeckler.Graphics being bound to the Canvas element; I'm not super familiar with SproutCore however.

Looking through the CSS I see they are using a few -webkit- specific CSS style rules, mostly around rounded border corners and shadows. They are also using the Webkit CSS Gradients and Clipping.

I wanted to see how things were handled in Internet Explorer. When I look at a published iWork.com document in Internet Explorer a very interesting dialog box first appears:

It was indeed slow; it took about 17 seconds to load the document in IE. Clicking on individual slides took about 4 to 5 seconds to show.

I used the Internet Explorer Developer Toolbar to get into the DOM and see how things run on IE. The first thing I see is that the Canvas tag is in the DOM:

However, notice a glitch that it has the <CANVAS> and </CANVAS> tags as separate elements, which can sometimes happen when IE is dealing with unknown tags. They are also definently using VML (Vector Markup Language) on IE, since I see them pulling in the VML behavior for IE on the main page. I wonder why they didn't just use the Google-ExCanvas library that emulates Canvas for Internet Explorer (Disclosure: I work for a team at Google that promotes open web technologies like this).

One other thing I noticed is that if you are on the iPhone you get redirected to an iPhone version of the app. This just replaces the URL /document/ section with /iphone/. When you navigate to this you get a PDF version of the page -- that must be the iPhone version, a PDF file!

I wanted to see how the Pages application does things as well, so I published a document there. The published text is selectable in the browser! The document itself appears to be an image file. To do selection, whenever I run over some text it appears that a Canvas element is created and a 'highlighted' type graphic is drawn over the correct characters. Internet Explorer also supports similar highlighting, though on there it appears to be using VML to do the highlighting.

All in all this is a very interesting web-based application built with Ajax and JavaScript!

Ajax: Ajaxian

Detecting twitter users with JavaScript - handy or evil?

Earlier this week I blogged about a proof of concept that you can detect if a user is logged in to twitter and display their data with a few lines of JavaScript. This could be used to show for example "tweet this" buttons in a blog application.

The trick is easy: use the user_timeline to get the correct data back and provide it with a callback:

JAVASCRIPT:
  1. function hasTwitter(data){
  2.   // gets the user's real name
  3.   alert(data[0].user.name);
  4.   // other data is .screen_name, .location and
  5.   // data[0].text is the latest update
  6. }
HTML:
  1. <script type="text/javascript"
  2. src="'http://twitter.com/statuses/user_timeline.json&count=1&callback=hasTwitter">
  3. </script>

You can see the proof of concept here. The only problem with the code above is that if the user is not authenticated, Twitter's API will prompt an authentication dialog. You can work around this one by providing an extra parameter called "suppress_response_codes" which is meant to be used with apps that can only handle 200 response codes and don't allow for authentication (Flash apps for example):

HTML:
  1. <script type="text/javascript"
  2. src="'http://twitter.com/statuses/user_timeline.json&count=1&hasTwitter&suppress_response_codes">
  3. </script>

This also means that you need to do your own error handling for cases where the user is not authenticated:

JAVASCRIPT:
  1. function hasTwitter(data){
  2.   if(data.error){
  3.     alert('No authenticated user');
  4.   } else {
  5.     // gets the user's real name
  6.     alert(data[0].user.name);
  7.     // other data is .screen_name, .location and
  8.     // data[0].text is the latest update
  9.   }
  10. }
HTML:
  1. <script type="text/javascript"
  2. src="'http://twitter.com/statuses/user_timeline.json&count=1&hasTwitter&suppress_response_codes">
  3. </script>

Now, this is pretty cool, but it also caused quite a stir on the twitter developer mailing list as it is a privacy concern. Using this technique I could simulate a user's homepage, fake an error, ask for re-authentication and phish their login data.

Whilst this is a problem, it is not really Twitter's fault - if anything then browsers and the lack of secure sandboxes are to blame. Some questions a proof of concept like this throws up are:

  • Do we need something like "tweet this" buttons (as a call to action they can be very effective)?
  • If we do, isn't it better to only show them when the user is a twitter user instead of cluttering the interface with all kind of buttons?
  • Is a provider-unknown secret like Yahoo's sign in seal a step in the right direction (educating users instead of patching technology)?
  • Is oAuth the answer?

Ajax: Ajaxian

Emacs tips: Navigate CamelCase - M-f, M-b, M-d, <M-backspace> over camelCase!

I'm terribly behind on my blogging but I wanted to re-post this nice little from Planet Python for those who aren't on it already. The for emacs allows you to do most word based operations over the separate words that make up a camel case word. I've been needing something like this for some time. As an emacs junkie, I've gotten quite accustomed to being able to move point pretty much directly where I want it in just a few key strokes. Camel case words, however, can get quite long so correcting a typo or changing a plural in one of the constituent words can leave me reaching for my mouse of hammering away at C-f or C-b. Simply unacceptable! :)

to /usr/local/share/emacs/site-lisp and then added the following to my .emacs:

(require 'camelCase) (add-hook 'find-file-hook 'camelCase-mode)

Zope: Planet Zope

SendMeHome with GWT

SendMeHome lets you to assign a unique code, called a SendMeHome ID, to any physical item. We are launching our newest feature, Stories, which connects a group of people through an item as it travels the globe. Social networks such as Facebook mainly involve users communicating with their ā€˜friends’, SendMeHome is unique because it uses a real-world object to tell a story that enables interaction between new and like-minded people who may otherwise have never known of each other’s existence.

Our beta users have already created stories to write a collaborative novel, share cooking tips, discuss political events, and even transport a statue to Easter Island.

The site uses GWT components and integrates with services such as good ole Google Maps. You can check out a story. Having a code associated to items is a lot of fun (read: Webkinz) and seems to be something that can be useful.

Ajax: Ajaxian

More Ajax Experience Videos: JSON and JavaScript

Following-up from our previous posting, we've got some more Ajax Experience videos. This post's theme is JavaScript and JSON:

Advanced Animation & Physics in JavaScript with Paul Bakaus

Forget about Web standards and go way beyond the usual capabilities of Web scripting languages. Learn how to create stunning effects using canvas/svg/vml, how to control animated graphics in JavaScript, and how to merge all kinds of standards and technologies to create a whole new world of possibilities. Using Paul's latest project as an example, he shows you how to adapt the things he talks about into new projects, featuring his new JavaScript game engine. Paul demonstrates how to control animated graphics in the browser, how to scale and rotate elements smoothly, and how to combine canvas, svg and filters with CSS to adapt new standards in browsers that don't support them. See how to move physics from the real world to the Web browser. In this session you learn how to: Create a walking animated character; Replicate new standards using existing technologies; Combine new standards to create a new experience.

Adv JavaScript: Closures, Prototypes, Demystified with Stoyan Stefanov

The times when JavaScript was just a toy language for making image rollovers and other, more irritating effects, are fortunately long gone. Today developers build much more sophisticated and complex applications be they for the Web (GMail), the desktop (Firefox extensions) or the server. JavaScript's prototypal nature makes its object-oriented features really different than "classical" languages like Java and C++, and we have to make sure we use the right tool the right way. In this talk you'll learn about JavaScript's most commonly misunderstood features and how you could put them to a good use.

Practical Functional JavaScript with Oliver Steele

This session covers how to use functional programming with JavaScript in real-life applications to implement client-side asynchronous processing, scheduling, and concurrency. These are complex areas that are difficult to think about or implement using straight object-oriented techniques, and become simpler with a handful of idioms that this talk demonstrates. Ajax developers (JavaScript or ActionScript) who are building applications that feature both ambient and reactive functionality, and that perform sophisticated tasks such as precompute display state or prefetch data, will benefit from this session. This session provides: A firmer understanding of closures and when to use them; Insight into implementing time-based and threadlike client-side behavior in the browser.

Applied JSON: HTTP REST, Ajax Databases & Beyond with Kris Zip

JSON has proven to be a very easy to use, yet immensely powerful data interchange protocol. However, by itself JSON lacks a number of important expressibility capabilities and efficient client/server data interaction must usually be customized. This session looks at how we can use various open specifications built on JSON to standardize and automate this interaction. We examine REST JSON, JSPON, and JSONPath. We also explore the capabilities of Ajax-accessible REST databases. The dynamic nature of non-relational databases can provide significant benefits for rapidly developing applications and providing JavaScript object persistence. Client-side code can directly participate in database interaction, simplifying the typical Web application stack. CouchDB, Persevere, and ActiveResource utilize a JSON REST interface. In this session, we learn how to interact with these simple interfaces and how to use JSONPath as a query language for JSON data stores. We see how these dynamic databases utilize JavaScript on the server for a consistent client/server JavaScript environment. We look at how Ajax databases affect security and provide an infrastructure for more secure Web applications. Finally, we cover JSON Referencing conventions as a mechanism for further expressing duplicate, circular, and cross-site referencing. Via a live demonstration, see how to use the Persevere open source tools to utilize these extensions to provide RESTful storage and server-side JavaScript. In this session you learn how to: Query JSON data with JSONPath; Use Persevere to provide a powerful persistence object store for JavaScript; Understand how JSON and the JSPON browser interacts with the Persevere object server; Employ JSON extensions and tools to enable open communication formats that can be used for rich and robust serialized object interaction between clients and servers with full object graph descriptiveness.

JSON SOA-based Client/Server App Dev with Kris Zip

JSON has proven to be a very easy to use, yet immensely powerful data interchange protocol. However, by itself JSON lacks a number of important expressibility capabilities and efficient client/server data interaction must usually be customized. This session looks at how we can use various open specifications built on JSON to standardize and
automate this interaction.
We examine REST JSON, JSPON, and JSONPath. We also explore the capabilities of Ajax-accessible REST databases. The dynamic nature of non-relational databases can
provide significant benefits for rapidly developing applications and providing JavaScript object persistence. Client-side code can directly participate in database interaction, simplifying the typical Web application stack. CouchDB, Persevere, and ActiveResource utilize a JSON REST interface. In this session, we learn how to interact with these simple interfaces and how to use JSONPath as a query language for JSON data stores.
We see how these dynamic databases utilize JavaScript on the server for a consistent client/server JavaScript environment. We look at how Ajax databases affect security and provide an infrastructure for more secure Web applications. Finally, we cover JSON Referencing conventions as a mechanism for further expressing duplicate, circular, and cross-site referencing. Via a live demonstration, see how to use the Persevere open source tools to utilize these extensions to provide RESTful storage and server-side JavaScript.
In this session you learn how to:
Query JSON data with JSONPath;
Use Persevere to provide a powerful persistence object store for JavaScript;
Understand how JSON and the JSPON browser interacts with the Persevere object server;
Employ JSON extensions and tools to enable open communication formats that can be used for rich and robust serialized object interaction between clients and servers with full object graph descriptiveness.

Ajax: Ajaxian

What Causes the Long-Running Script Warning?

Nicholas Zakas decided to dive deep on everyone's favorite sign that you've done something wrong:

Few web developers truly understand what triggers the long-running script dialog in various browsers, including myself. So I decided to sit down and figure out under what circumstances you’ll see this dialog. There are basically two different ways of determining that a script is long-running. First is by tracking how many statements have been executed and second is by timing how long the script takes to execute. Not surprisingly, the approach each browser takes is slightly different.

He finds that Internet Explorer's warning is based on total statements executed (5 million, and since it's Windows, you can change it via the Registry), Firefox and Safari time the actual script time (10 and 5 seconds, respectively), Chrome is a bit of a mystery, and Opera doesn't appear to have such a mechanism (and interestingly, appears to put its UI on a different thread than page rendering / script execution).

Regardless of the details, the lesson remains the same (again quoting from Nicholas' post):

Brendan Eich, creator of JavaScript, is quoted as saying, ā€œ[JavaScript] that executes in whole seconds is probably doing something wrongā€¦ā€ My personal threshold is actually much smaller: no script should take longer than 100ms to execute on any browser at any time. If it takes any longer than that, the processing must be split up into smaller chunks.

An interesting read!

Ajax: Ajaxian

QEvent: Small, Portable Event Library

Daniel Steigerwald told us about his labor of love: QEvent, a "powerful tiny extensible standalone event library". He provides this laundry-list of features:

* lightweight footprint
* no namespace pollution - everything is wrapped in obj.$QEvent
* normalizes the DOM event model
* work also with Javascript objects
* fixes common IE bugs including: all common used event properties, IE 2px bug http://ajaxian.com/archives/javascript-tip-cross-browser-cursor-positioning, fix many IE leaks, event handlers are FIFO executed
* prevents repeated registration of same type and listener
* 'this' in listeners references to object or element itself
* fixes window 'beforeunload' issue (doesn't work in Opera)
* fixes window 'unload' (must be removed by itself)
* fixes focus and blur events
* DOM events are more extendable: event keys, event objects ( event.myCustomFn() ), custom events
* firing events works for elements
* toggled and flashed events (removed after first fire)
* tested on (IE6-7, Firefox2/3, Safari, Opera, Chrome)

Isn't event sugar a solved problem? Daniel replies:

* Occasionally, I need a lightweight library that will work with other frameworks. Frameworks such as jQuery which don't extend the native prototype and therefor have no compatibility issues are not modular enough to meet my needs.
* No event implementation is perfect. So I took my own approach to the issue and created my dream package.
* This implementation could serve as a model for others.

The syntax is straight-forward:

JAVASCRIPT:
  1. QEvent.add(window, 'domready', function() { ... } );
  2.  
  3. // custom event
  4. QEvent.add(kitty, 'purr', onKittyPurr);
  5. QEvent.fire(kitty, 'purr', 'Sandy');
  6.  
  7. QEvent.remove(document.getElementById('testKeyEnter'), 'keyenter', keyenter);

Ajax: Ajaxian

Special Offer for Ajaxian Readers: TheServerSide Java Symposium

Hello Ajaxians!

We're inviting all of the Java developers out there to an event organized by our sister site, TheServerSide.com, the Web's largest enterprise Java community. As a member of Ajaxian, you save an extra $100 off the registration fee with the code AJAXIAN. (Register before January 16 to save a total of $400 and get a free book!)

TheServerSide Java Symposium explores current and emerging trends in enterprise Java and how they apply to your daily work. Choose from over 45 technical sessions on new technologies, best practices and practical tips from some of the brightest minds in the industry, including Rod Johnson, Neal Ford, Scott Davis and 35 Java experts.

Tracks include Frameworks, Architecture, SOA, Language, Tools and Techniques.

Project and spec leads dive into:

  • The latest features of Spring, JSF, Wicket, Tapestry, Google Web Toolkit and more frameworks.
  • New Java language features, such as EJB 3.1, Glassfish and JavaFX
  • Popular open source tools, including Eclipse, Maven, Lucene, soapUI, HtmlUnit for testing SOA, Ajax and RIAs.
  • Expert recommendations on the use of Groovy, Scala and JRuby
  • Building and maintaining a large-scale SOA
  • How to create and consume RESTful Web Services.
  • How and when to use an ESB.
  • Best practices and tools for optimizing performance and scalability.
  • And much more!

View TheServerSide Java Symposium agenda to see all of the sessions being presented. Register now with the code AJAXIAN to save an extra $100 and to get a free book while supplies last.

Ajax: Ajaxian

Who needs Flash? Having fun with Canvas and SVG

Over in SproutCore land, they have been talking about Peter Bergstrom and his amazing work with Canvas and SVG:

Peter Bergstrom has been doing some amazing work with SVG and canvas tags in his SproutCore-based these project called PaperCube.  PaperCube visualizes citations their relationships between authors.  Watching the videos of his project, you’d swear he was using Flash or Silverlight, but its not.  He’s using only native web technologies powered by SproutCore and JavaScript.  It’s a great example of what’s possible using the browser’s capabilities today.

Checkout PaperCube’s Node Graph (SVG),  Per Year View (SVG), and Paper Tree (pure HTML).

Starting to get