Activate your free membership today | Log-in

You searched for: 'iphone'

Monday, February 1st, 2010

Google isn’t Evil. Flash isn’t Dead; Thank god the Open Web doesn’t have a single vendor

Category: Editorial

The following post is a reprint from my personal blog. It is editorial in nature and even delves into random politics. I apologise. You can deal with it though :)

openclosed

Steve Jobs didn’t hold back when talking about Google and Adobe. That is great. Life is so much more fun when people speak their mind. I remember hearing a story when Sir Steve was asked why mac keyboards where the way they were. He grabbed a PC keyboard and started to rip out “stupid keys” (print screen, F keys, and the like) and swore a lot.

We love to paint with broad black and white brushes these days don’t we? Whenever I hear people talking about Google being “evil” or not…. I sit back and think about how interesting it is that companies become “people”, especially in this country.

It makes sense when you look up Corporation:

Corporations are recognized by the law to have rights and responsibilities like actual people.

That may have been a convenient (and often almost genius) abstraction by lawyers, but it is screwed up. It feels like the times when you use inheritence in a way that isn’t a ISA relationship, but it does kinda make the code nice. We have all done that, until we learned to favor composition. Corporations ISA Person? No. They are composed of them though.

I have been thinking about this ever since the recently surprise court decision the other day that “allows corporations and unions to pour unprecedented amounts of money into elections.”

Lawrence Lessig had some interesting commentary:

The court decision does feel totally wonky to me. Right now, $ has a direct bearing on elections, and allowing multi-nationals (who have the money) to rain it down makes no sense.

Fun aside

My renaissance friend Graham Glass talks about how corporations can be considered a single conscious in his series on “the mind”.

The issue with the vast number of corporations is that they are profit driven entities whose charter is to bring financial reward to shareholders. While you could argue that we as a species are driven by the selfish gene, corporations are driven by profits. Duh. Capitalism.

Google is a company. It is driven by this same goal. Now, there are various paths to a particular goal to make profits. Some companies sell things that kill people (weapons, cigarettes, etc). Others offer medical devices. All companies are not equal. Having spent time at Google, I do feel like the place isn’t just an evil cult. The people that make up the consciousness were very driven strong willed people that cared about the company mission (universal access to information and all that) more than just the $. Sure some folks are focused on that. Also, although the wool could be placed over your eyes, the guys at the top of the chain have their hearts in the right place. While Larry and Sergey are there, decisions will be made that aren’t solely based on profit. They want to create a different kind of legacy and company.

That being said, I think it is quite easy to fall into a trap such as:

If we do something here to block competition, we can make more $ and since we are Good Guys we can do better things with that money!

Google will sometimes do things that could be considered “evil” by some. That is life.

The good news with Google is that their search and ads business deals in a trust economy. It doesn’t take much to switch from Google to Bing. Google knows that. Even though they have some HUGE advantages (technical [data centers, talent], brand, etc) the low barrier to change is huge.

Not all corporations are profit driven

I had the huge pleasure of working for Mozilla, which is a mission based corporation. Wow does that make life different. While you have to sustain yourself, it does mean that you think of the world very differently. You would rather go out in a blaze of glory doing something great for the mission, than just slowly die not doing much. Every choice you make …. you think of the mission.

It was interesting to work there knowing that I actually wouldn’t want Firefox to be a 90% browser. You can fall into the similar trap as above and think:

We are mission based! If we had that domination we would use it for good!

But, not having that power in one hand is even better. Imagine working somewhere thinking “in my wildest dreams, the market would be shared somewhat evenly with the competition.” The Open Web is amazing in that there is NO SINGLE VENDOR. If we are able to keep a decent balance between browsers (and thus the platform as we know it) then we have a balance of powers. Sure, in some ways you can’t move as fast as a dictatorship, but there is a reason we don’t want dictatorships in our government (even if the trains run on time!)

And, this brings me to the Adobe half of the Steve Jobs equation. Flash isn’t dead. HTML5 is slowly going to put a dent into it if we ever get some of the use cases just right (e.g. video), but Adobe has a good penetration and can move at the speed of a dictatorship. The iPhone/iPad combo not shipping Flash will have an interesting dynamic here too, hopefully helping the HTML5 video cause. There is still much more work to be done. Flash and browser plugins have had a long history at forging new paths, and the Web can come in behind them and standardize. May that continue.

I do watch for single-owned platforms such as Flash, Silverlight, or now the Apple platform (even though they do great work on the HTML5 side of the house). I don’t want any of those vendors to have too much power. The thought of a Web that required the use of their technology makes me shudder (we have a piece of that with Flash video). Right now I can turn off those plugins and life moves on. Sure I can’t Hulu or Netflix, but that will change. I would miss some of the Flash sites that my kids use, but they could even be partially ported over to HTML5 these days.

I don’t want to “kill” these other platforms as they offer competition and spur on the industry. I just don’t want any one of them to take over. It may seem like the world would be better if we all just used Macs and iPhones and iPads, but would it? Do you think Steve would be a benevolent dictator?

Erm, no.

And thus I find myself torn. I really want to go out and by that iPad……. but when is it “too late”. Surely I have a few years right? I can enjoy the shiny new toy? :)

Faruk Ate? also has a nice post on where he see’s Flash going which is bolder than mine :)

What do you think?

Posted by Dion Almaer at 9:38 pm
16 Comments

+++--
3 rating from 23 votes

Tuesday, January 26th, 2010

A Titanium Tablet?

Category: Appcelerator, Apple

Appcelerator has published an interesting study on the Apple Tablet. You know, the iPhone OS based one that we will Steve will show us on Wednesday.

The study asks some interesting questions revolving around the development side of the tablet. Are developers going to develop for it? What are they looking for? What are they excited about from a technology perspective?

I found it interesting to see the type of companies looking to build apps:

Appcelerator_survey_tablet_category_ranking

Games will still probably be huge on the device, but it is great to see other types of apps at the ready.

Then we have the feature requests:

Appcelerator_survey_top_anticipated_features

Even if there is a way to run iPhone apps, it is clear that people will be spending effort creating truly native experiences. There are core differences beyond screen size here. Very different capabilities to take into account.

We are seeing an increase in consumer devices. I recently talked about the table stakes of 2010 and beyond. As a consumer it is exciting to see the vision of connected devices become real. As a developer, although there is new opportunity, it is incredibly daunting. How many proprietary SDKs can one learn and fund development on?

This is where the Web comes in. The Web has the potential to become the unifying platform across devices. This isn’t about write once run anywhere, but it is about offering advanced solutions to deliver experiences across the devices using shared code, services, and APIs.

Back to Appcelerator. They publish this study right before the tablet launch. Hmm…. something tells me that Titanium (now in mobile and desktop versions) will support Tablet. As companies struggle with the pull of delivering functionality to many devices, Titanium has an opportunity of helping developers out. We have heard that Titanium is going to GA some time soon (probably in March) and we will then see pricing plans and some new products (probably around analytics and metrics). Apparently more desktop and mobile applications will be developed using Titanium than Adobe AIR this year. That would be quite a feat.

What are your thoughts on the Tablet and the Web? What did you get out of the survey?

Here is Jeff talking about their work with Scoble:

Posted by Dion Almaer at 3:01 am
8 Comments

+++--
3.1 rating from 19 votes

Wednesday, January 13th, 2010

Gordon: Flash Runtime Implemented in Javascript

Category: Flash, JavaScript

This was quite a surprise! Tobias Schneider has built a Flash runtime that works right in the browser. It's implemented in pure Javascript and HTML5, and the whole thing is open source, MIT-licensed, and hosted on GitHub.

See Gordon in action (demos hosted by Paul Irish).

It works like a charm in recent versions of Firefox, Chrome, and Safari (and, yes, iPhone Safari, though the "blue" demo runs at tedious pace on my 3G). To install it yourself, use "git clone git://github.com/tobeytailor/gordon.git". I found the demos don't work from a file:/// URI due to the script dependency system, so point your web server at the root and point your browser at demos/.

There's not yet any docs, so it's not clear how broadly compatible Gordon is or where it's headed. But if nothing else, it makes a bold statement about the maturity of open web technologies.

HTML:
  1.  
  2.   <body onload="new Gordon.Movie('trip.swf', {id: 'stage', width: 500, height: 400})">
  3.     <div id="stage"></div>
  4.   </body>
  5.  

Gordon

(Update: After much twitter love, someone finally figured out the name. How did we miss it?!!)

Flash Gordon: Saviour?

Update 2: There's a SWF tag support table and a browser support table. (thanks @tuxified)

Posted by Michael Mahemoff at 3:38 pm
25 Comments

++++-
4.8 rating from 78 votes

Thursday, December 31st, 2009

Web 2.Snow

Category: CSS, Examples, Fun, JavaScript

When I talked about some snow related CSS3 experiment, I could not imagine @Natbat was already preparing something like snowflakes, an almost fully CSS3 featured snow FX created for clearleft, specially suited for Chrome and Safari.

And what about @zacharyjohnson? He put snow all over the network via its Winternetizer, the first snow proxy I have ever seen.

Am I missing anybody? ... sure, me!

Above FX is dedicated to all Ajaxian readers and created via some CSS3 rule handled via JavaScript for a partial cross browser implementation. WebKit based browsers, included Android and iPhone, plus Firefox 3.6, should render properly, while the most interesting thing, snow a part, is that for the first time rather than browser sniffing, I have implemented a sort of "screen resolution to power computation" sniff:

JAVASCRIPT:
  1.  
  2. var totalSnowFlakes = Math.max(
  3.     Math.min((
  4.         document.documentElement.offsetWidth *
  5.         document.documentElement.offsetHeight /
  6.         15000
  7.     )>> 0, 40), 10
  8. );
  9.  

Probably not perfect, the aim is to avoid same number of flakes in mobile devices, netbooks, or desktop PCs.
I guess one day we'll have exposed CPU model and RAM amount as read only userAgent properties, so that all new effects could avoid stress for web surfers.
Something like System namespace in ActionScript, with capabilities for audio and video and extra info about the current navigator ... maybe just an AS to JS bridge 'till that day? We'll see, today the important thing is simply one: Have Fun!

Posted by webreflection at 8:13 am
11 Comments

+++--
3 rating from 23 votes

Tuesday, December 15th, 2009

PastryKit: An iPhone Webdev Library from … Apple

Category: Library, Mobile, iPhone

John Gruber has spotted a library for iPhone web apps, from none other than Apple. This mysterious library, called PastryKit, seems to have flown under the radar as a Google search reveals precious little on it. In similar vein to other efforts, Apple's library provides support for native-feel websites - websites that run in Mobile Safari, but feel like native apps. (That's the objective anyway; some look-and-feel emulators are "good enough", while others get stuck in the uncanny valley).

To get hands-on with PastryKit:

  • Visit http://help.apple.com/iphone/3/mobile/ from your iPhone or iPod Touch. This is an official Apple site using PastryKit. If you're feeling lazy/iPhone-challenged, watch Gruber's screencasts.
  • Now with the same site in regular Safari (on your Mac/PC), open up the Develop Menu (if it's not there, enable it in Preference|Advanced). Choose User Agent > Mobile Safari 3.0 (or probably any other version number). And now you can see it in your browser. From Develop Menu, Web Inspector will let you view the script.

The HTML includes PastryKit as follows:

HTML:
  1.  
  2.     <!-- PastryKit -->
  3.     <link rel="stylesheet" href="dist/PastryKit-ug-compact.css">
  4.     <script type="text/javascript" src="dist/PastryKit-ug-compact.js" charset="utf-8"></script>
  5.  

PastryKit Javascript and PastryKit CSS are available. Unfortunately, they're a bit unclear due to compression, but Gruber nonetheless pored into the source:

PastryKit accomplishes all three of the aforementioned things — hiding the MobileSafari address bar, providing fixed-position toolbars, and providing scrolling with momentum — by disabling regular scrolling and setting up its own view hierarchy and implementing its own scrolling.

The whole question of native iPhone apps was a hot topic last month after PPK whipped up a storm on the question of web apps replacing iPhone apps. The really interesting thing here is Apple's stance. They launched the iPhone with web intended to be the platform for 3rd party apps, then switched over to native apps and haven't done much to facilitate native-style web apps since then. Is a change coming? As Gruber puts it:

The $64,000 question, though, is whether PastryKit is something Apple intends (or that a team within Apple hopes) to ship publicly. It seems like a lot of effort to build a framework this rich just for this iPhone User Guide, so I’m hopeful the answer is yes. Perhaps something integrated with the next major release of Dashcode? And, perhaps with integrated UI layout tools, along the lines of Interface Builder?

As well as apperaring in the user guide website, Chris Messina noted PastryKit apparently appears in the iTunes LP files.

Posted by Michael Mahemoff at 8:31 pm
11 Comments

++++-
4.6 rating from 25 votes

Tuesday, December 8th, 2009

PhoneGap Updated to Support Palm webOS Apps

Category: Mobile

The PhoneGapteam announced yesterday that they've got support for Palm's webOS Mojo API.

PhoneGap API’s available to Palm devices include geolocation, accelerometer, notification, orientation, sms, telephony, network, file (read only), and a limited selection of device properties (see the PhoneGap Mobile Spec running on the Palm Emulator to the left).

Essentially a JavaScript shim that maps to the various mobile APIs, the PhoneGap API & suite of tools makes it much easier to build mobile apps for the iPhone, Google Android and various versions of Blackberry by leveraging standard web-based technologies. You can now add Palm to the list of mobile devices being supported by the PhoneGap project.

Posted by Rey Bango at 7:00 am
4 Comments

++++-
4.4 rating from 16 votes

Friday, November 20th, 2009

Full Frontal ‘09: Simon Willison on Server-Side Javascript and Node.js

Category: JavaScript, Server

Simon Willison snuck in a last-minute topic change, and is now going to give the server-side Javascript talk.

The news of the past 24 hours is ChromeOS. For the first time in years, someone's re-thinking how an OS should work. With Chrome, you turn on your computer and you're in the browser. What's really interesting is to contrast it to the introduction of the iPhone, where Apple's apps used native APIs while they expected developers to write web apps running in the browser with limited abilities. Here, Google's apps are using the same web platform...it's a level playing field.

Javascript combined with JSONP makes it real easy to write quick and dirty apps. An example of a quick app is Tweetersation Simon wrote with Natalie Downe. Simple app, 200 lines, written in an afternoon. At a larger system level, there's Google Moderator, which is essentially a pure-Javascript solution with a no-op in the noscript tag.

These pure Javascript apps are great for experimenting and prototyping. The problem with this style of development, though, is you're completely breaking web standards. The web Simon "felll in love with" is one where you point to a URL and you get content coming back.

With server-side Javascript, we can get the benefits of the things we like about Javascript, but without throwing away with the things we like about the web. Simon has been playing with node.js, and evidently the results were important enough to throw out the old talk and make this new one.

Take a step back and look at the interaction patterns with a web server. The conventional model is straightforward request-response, where the server tries to respond and disconnect as quickly as possible. But ... there's also the event loop model. As in Comet; it's generally considered to be more efficient, so why do web developers avoid it? Simon says traditional server-side languages aren't designed to deal with event-driven programming. It's more like "do A, do B, do C, exit". Javascript, on the other hand, is well suited to do callback-driven event programming.

Brave Simon now proceeds to live code with node.js. He shows a "Hello World" daemon, where the code looks like Ajax in reverse, and runs extremely fast. But where it gets really interesting - and useful - is with Comet. Another demo. The code is tiny and the benchmark looks good.

Simon's built his own framework on top of node.js: Djangode takes the best features from Django and sticks them on the server.

JAVASCRIPT:
  1.  
  2. var dj = require('./djangode');
  3. dj.serve(dj.makeApp([
  4.     ['^/$', function(req, res) {        dj.respond(res, '<h1>Homepage</h1>');    }],    ['^/other$', function(req, res) {
  5.         dj.respond(res, '<h1>Other page</h1>');
  6.     }],
  7.     ['^/page/(\\d+)$', function(req, res, page) {
  8.         dj.respond(res, '<h1>Page ' + page + '</h1>');
  9.     }]
  10. ]), 8008); // Serves on port 8008
  11.  

The more interesting example is Comet, which he's demo'd here.

Moving on to persistence, there's the NOSQL trend of the past 18 months, and he shows how simple it is to write CouchDB queries from node. It's easy to talk to CouchDB from Node.js apps. Redis is another interesting database, which could lead to pages being rendered very quickly, given its performance benchmarks.

Posted by Michael Mahemoff at 12:41 pm
Comments Off

+++--
3.2 rating from 29 votes

Full Frontal ‘09: PPK on Mobile Quirks and Practices

Category: JavaScript, Mobile

PPK talks up the excitement of mobile web development, then brings the mood down a notch by listing the overwhelming array of browsers to be targeted! Quirksmode says it all. This talk is about quirks in mobile development, and some of the solutions out there.

Mobile CSS Quirks

So many platforms. Take just WebKit; there's iPhone Safari, Android WebKit, Bolt, Iris, different versions, etc. "If someone says my 'app should work in WebKit', laugh in their face. There are just too many versions of WebKit, so as PPK says it, there really is no "WebKit for mobile".

That said, it's good that things are starting to converge towards WebKit. As for the others: Blackberry browser "is dead" as they'll be switching to WebKit; Mozilla is very late to the game; NetFront "is not very good". Windows Mobile 6.5 is a big improvement on 6.1, and with an improved browser, but it's still IE6 based. ('Nuff said.)

There's also a large legacy share, and if users are used to it already, that may be what they want to keep using.

Landscape versus profile mode is an interesting one for those of us desktop developers whose users don't flip their heads around on a regular basis. NetFront has some very surprising and idiosyncratic ways of dealing with it.

The modes don't stop there. There is also mobile versus desktop mode in some browsers; sometimes users can switch these in some obscure corner of their mobile browser preferences. Again, some surprising things happen in Opera and Android. Perhaps of more concern is the difficulty he had diagnosing the situation at first, when Android was showing three divs of the same width in one mode, and not in the other.

@media to the Rescue

Okay, what can we do about all this? Media queries are extremely useful and fairly well supported in modern mobile browsers.

CSS:
  1.  
  2. div.sidebar {
  3.   width: 300px;
  4.   float: right;
  5. }
  6.  
  7. @media all and (max-width: 400px) {
  8.   div.sidebar {
  9.     width: auto;
  10.     float: none;
  11.   }
  12. }
  13.  

max-width and min-width have subtle issues which PPK is currently researching, but max-device-width and min-device-width give more reliable results. orientation, aspect-ratio, and dpi (also needs research).

Mobile Javascript

Performance-wise, IE Mobile and Blackberry extremely slow. iPhone is middle ground. The really fast browsers are Opera on Samsung and N97, and S60 on Nokia E71 and N97. The bottom line is take your time with mobile Javascript development; you generally can't expect it to "just work"; you'll have to optimise. Also, don't use iframes - they're major performance hogs.

Mobile Connections

Tempting fate, PPK informs us that if someone in the room starts downloading movies, the network gets slower for the rest of us.

Fortunately, browsers give us events to determine when user is going online and offline. Unfortunately, they're doing it wrong. Only Firefox automatically detects offline; all the others require the user to explicitly say "I'm offline now"!

W3C Widgets

In general mobile development, best practice is to put all the core files on the moble phone, and only download the data. But how can we do that with web apps, where the code comes down with the data? W3C widgets offer a solution. You just create a single HTML page with the CSS, Javascript, and images you need; add an icon and config; zip it up; and deploy. PPK reports it works in practice, and works in a "write once, run many" fashion. There are still problems to be sure, but he says it's the best interoperable solution we have today. But still many outstanding platforms: Blackberry (already talking about it), Nokia Maemo, Palm Pre, Android, and of course, iPhone.

Device APIs

Security risks mean critical device APIs will generally remain off limits to general websites for a while. Widgets have a better model, because they're more self-contained and can be verified, although not perfect either.

Posted by Michael Mahemoff at 7:58 am
Comment here

++++-
4.3 rating from 12 votes

Tuesday, November 17th, 2009

Resource Packages; Making a faster Web via packaging

Category: Browsers, Performance

HTML:
  1.  
  2. <link rel="resource-package" href="site-resources.zip" />
  3.  

What if we could agree on a simple backwards compatible approach to packaging Web resources so the browser could suck down the puppies in one go?

Alexander Limi (of Plone and Firefox UX fame) has been thinking about this for awhile, and has gotten his latest proposal out there which defines a simple way to package things.

It builds on existing tech: zip, manifests, and the like.... and degrades nicely.

This is so much nicer than spriting hacks, but does have its own issues:

  • In theory the browser could sometimes render faster by grabbing items in parallel
  • Mobile caches may be messed up (as larger than a cache size, like say iPhone's 256k)
  • What if the zip gets out of date with the other resources?
  • Ideally tools (and in fact even web server modules) would auto generate this stuff

Although not perfect, for the majority case this could be a real boon to performance. What do you say Steve?

Oh, and it sounds like Firefox will implement this in 3.7!

Posted by Dion Almaer at 6:23 am
22 Comments

+++--
3.1 rating from 26 votes

Monday, November 2nd, 2009

A State of the Web via October Tweets

Category: Ajax

A lot of great news is coming in via Twitter. I make a lot of Ajax comments under @dalmaer and wanted to give you a roundup on the month of October via Tweets. Always interesting to take a glance at the month. What do you think?

Posted by Dion Almaer at 6:44 pm
10 Comments

+----
1.5 rating from 86 votes

Friday, October 30th, 2009

WebSync: Comet for IIS

Category: Comet

The following is a guest post. If you have something to say to the Ajaxian community, please feel free to either link us to your work, or give us a guest posting that goes into detail! Contact us.

My name is Jerod Venema, and I'm excited to write to you about our new Comet server for the Microsoft stack - WebSync. It is written in 100% managed C#, and uses IIS to reach incredibly high user concurrency. Despite being written in C#, we've made it easy to integrate other languages as well by pre-building client libraries and allowing generic HTTP requests to send messages.

There are many challenges in getting a Comet server to operate efficiently in any language, and the .NET environment delivers its own set of unique challenges. One of the biggest challenges we faced was how to make IIS "play nice" when scaling to tens of thousands of concurrent HTTP connections and message transactions. A great deal of time was spent minimizing the memory footprint (even to the point of lazy object construction), optimizing libraries, and digging through pages of profiler results. Multi-threading reared its ugly (but powerful) head on more than one occasion as we sought to take maximum advantage of multiple CPU cores while keeping locking and concurrency issues to a minimum. We even ended up writing a new lock-free data structure similar to a linked queue that allows us to perform multiple-writer add/remove operations - very helpful when dealing with large lists of clients and messages. Once all was said and done, we tested on a $500 Acer desktop and saw over 30,000 concurrent users and 25,000 messages per second. (We were pretty pumped when we saw some of those numbers coming through!)

Once we were satisfied with the server's performance, we set our sights on a JavaScript client. We had originally been using the Dojo Toolkit, but the overhead was more than what we wanted (it rang in at about 90k after compression, but before gzipping), so we wrote our own library that, when compressed and gzipped, comes across the wire at about 8k total (just over 15k before gzipping). We also ran into a slew of cross-browser issues (of course), in particular when dealing with long-lived HTTP connections. A bit of effort, though, and we can now claim the client to be fully compatible with over a dozen browsers, from IE5.5 all the way to the iPhone and Android browsers. Being fans of open-source technology (even in a Microsoft world), we decided to use the Bayeux transport protocol rather than develop our own, so any Bayeux-compliant client can link in to the server.

We also spent some time on making it easy to integrate into non-browser applications. One of the really neat features is the ability to publish data via a simple GET/POST request, so it can integrate into any application that can make a web request, regardless of the language. If you're writing in PHP or .NET, we've made life even easier by writing publishers that wrap up the creation and invocation of the web request into single method calls.

Oh, and we've got a hosted version too (WebSync On-Demand), so people with smaller sites who don't want the cost of hosting their own Comet server can still get all the benefits of a full Comet solution. For the On-Demand solution we've also implemented request proxing, which allows developers to direct the low-impact publish and subscribe requests to their server first, so they can pre-process any incoming messages (to add authentication, save messages to a database, etc). And again, for PHP or .NET users, it's a one-liner to implement.

Anyway, it's a pretty neat product, easy to get started with, and as I said, we're pretty excited and proud of it, so check it out including demos or tutorials and let us know what you think!

Posted by Dion Almaer at 6:02 am
14 Comments

++++-
4 rating from 187 votes

Thursday, October 29th, 2009

S2.enableMultitouchSupport = true; // Getting touchy feely with scripty

Category: Prototype, Scriptaculous

Thomas Fuchs has been working with Nokia on their multi-touch API for Qt/WebKit:

scripty2 supports multiple API vendors for Multitouch events, and even provides a desktop emulation (click+drag to pan, shift+click+drag to scale and rotate)– so you can try this out even without having multitouch hardware at your disposal.

Currently the scripty2 API abstraction event supports Desktop emulation, Nokia Starlight and Apple iPhone Mobile Safari. With just one API, you can now multi-touch enable any web application easily, just check out the demos.

In a recent update to scripty2, I’ve also introduced automatic support for WebKit CSS transitions, so whenever scripty2 effects are used and CSS transitions are available, the effects engine will automatically do the right thing for you.

All in all, using this in your web sites or apps boils down to just a couple of lines of code:

JAVASCRIPT:
  1.  
  2. $('element').observe('manipulate:update', function(event){
  3.   $('element').transform(event.memo).setStyle({
  4.      left: event.memo.panX+'px', top: event.memo.panY+'px'
  5.   });
  6. });
  7.  

Posted by Dion Almaer at 6:56 am
7 Comments

++---
2.1 rating from 56 votes

Wednesday, October 7th, 2009

View Source Tutorial: Fancy Web Page Using HTML5, CSS, and SVG

Category: HTML, SVG, Tutorial, View Source

I recently ran across a site that made my jaw drop when I realized it's completely made with HTML5, CSS, and SVG. It's the site for the GNU Emacs for Mac OS X release:

emacssite1

Who ever knew GNU Emacs could look so sexy? When I think of GNU Emacs I generally imagine Richard Stallman's beard rather than the fancy site shown above.

stallman

Wow, I've got to get that image out of my head :) Moving on.

Here is what is cool about this site: it's completely using open web technologies to put things together. That's not just a big image you're seeing on the site.

Let's crack this thing open with a View Source tutorial and see what makes it tick so you can apply similar techniques in your own work. View Source is a new series of tutorials where we look at open web technology 'in the wild' and break them down step by step so you can learn what they are doing.

Continue reading View Source Tutorial: Fancy Web Page Using HTML5, CSS, and SVG...

Posted by Brad Neuberg at 6:30 am
22 Comments

+++--
3.5 rating from 36 votes

Tuesday, October 6th, 2009

Interactive CSS 3 Generator

Category: CSS

Many browsers have been experimenting with new custom CSS properties lately. Keeping track (and learning how to use them) can be a bit of a challenge.

Via WidgetPad comes a nifty CSS 3 Generator that helps you understand the new CSS 3 features in Webkit with an interactive tool that will build up and show how each new property affects an element. Here, for example, we see the results of applying rounded corners, box shadows, reflections, and a transform to an element:

css3_generator_screenshot

Which results in the following code:

CSS:
  1. -webkit-border-radius: 10px;
  2. -webkit-box-shadow: 5px 5px 5px rgba(0,0,0,0.5);
  3. -webkit-box-reflect: below 5px -webkit-gradient(linear, left top, left bottom, from(transparent), color-stop(0.5, transparent), to(white));
  4. -webkit-transform: rotateZ(15deg);

The CSS 3 Generator works on any webkit based browser, including Safari, the iPhone, and Chrome.

Here's a challenge to the community: can you create an enhanced version of this that works with all the new CSS 3 and vendor-specific properties, including on IE and Firefox, hiding the options that don't work on specific browsers? That would turn this into a more general purpose educational and testing tool that would be very valuable. Even better if you open source it and we can host it on the Open Web Developer Network we've been kicking around. Drop me a line if you create such a thing :)

As a side note, I had never seen the WidgetPad website where this is hosted before this which looks quite interesting. From the site:

[WidgetPad is a] collaborative development environment for developers to develop fully-interactive, stand-alone, downloadable SmartPhone applications in HTML5, CSS3 and Javascript. You don't need to install any special development tools or learn any platform-specific API sets. WidgetPad offers everything you need -- project management, source code editing, debugging, collaboration, versioning and even distribution -- in your own browser!

Posted by Brad Neuberg at 7:15 am
8 Comments

++---
2.8 rating from 28 votes

Thursday, September 24th, 2009

JavaScript Liquid Image FX

Category: JavaScript

Inspired by its conceptual simplicity, Andrea Giammarchi ( cough, the newest Ajaxian, cough ) has revisited an old ActionScript 1.0 Image effect making it lightweight, 1.2Kb minified and gzipped, and portable, thanks to its cross-browser nature and zero libraries dependencies. Last but not least, it's 100% JavaScript, and without canvas.

The theory is simple: expanding a div with an image as background, and moving a stretched image in the opposite direction, it is possible to adjust some pixel in order to find a match point between the last part of the expanded background and the moved image.

The practice is even more simple: a Liquid function call with a configuration object.

JAVASCRIPT:
  1.  
  2. var fx = Liquid({
  3.  
  4. // image src, every supported format
  5. src:"myimage.png",
  6.  
  7. // element to use as Liquid container
  8. target: document.getElementById("fx")
  9. // or $("#fx")[0] for some guy,
  10.  
  11. // optional direction, left by default
  12. // accepted: left, right, bottom, top
  13. direction: "left",
  14.  
  15. // optional scale factor, 2000% by default
  16. // it is how much the image should be stretched
  17. scale: 2000,
  18.  
  19. // optional speed, 1 to whatever, by default 10
  20. speed: 10,
  21.  
  22. // optional callback, will be executed at the end
  23. callback:function(){alert("it's Liquid!")},
  24.  
  25. // optional onload to perform some operation
  26. // after the image has been loaded
  27. onload:function(){/*FX not started yet*/},
  28.  
  29. // optional reverse property
  30. // performed only over a precedent liquid FX
  31. reverse:true
  32. });
  33.  
  34. // fx variable will have two methods
  35. // fx.pause()
  36. // to stop the animation
  37.  
  38. // fx.play()
  39. // to re-enable it after a pause
  40.  
  41. // these two effects are available only
  42. // during animation time, removed
  43. // before optional callback call
  44.  

Being this effect based on just 2 DOM nodes, even mobile devices such Android and iPhone can show it with a reasonable rendering time.

Here you can find the source code while to give it a try you have Demo 1, with Firefox logo, and Demo 2 , with VAIO one, thanks to its smooth lines specially suited for this effect.

Posted by webreflection at 6:30 am
13 Comments

++++-
4 rating from 46 votes

Tuesday, September 22nd, 2009

Gmail Mobile team talks Latency and Code Loading

Category: Google, Mobile, Tip

Bikin Chiu of the Gmail Mobile team picks up the HTML5 series with a piece on reducing startup latency.

It starts off by talking about lazily loading code via the old favorites of adding a <script> to the DOM, or XHR+eval, but then it gets beyond the typical and discusses the nuance of mobile + offline caching. The hack that is used, is another oldie.... which is to hide the script and eval it later:

For an HTML 5 application that takes advantage of the application cache to reduce startup latency and to serve the application offline, there are a few caveats one should be aware of. Mobile networks have decent bandwidth, but poor round trip latency, so listing each module as a separate resource in the manifest incurs quite a bit of extra startup latency when the application cache is empty. Also, if one of the module resources fails to be downloaded by the application cache (e.g. disconnected from network), additional error handling code needs to be written to handle such a case. Finally, applications today have no control when the application cache decides to download the resources in the manifest (such a feature is not defined in the current specification of the draft standard). Typically, resources are downloaded once the main page is loaded, but that's not an ideal time since that's when the application requests user data.

To work-around these caveats, we found a trick that allows you to bundle all of your modules into a single resource without having to parse any of the JavaScript. Of course, with this strategy, there is greater latency with the initial download of the single resource (since it has all your JavaScript modules), but once the resource is stored in the browser's application cache, this issue becomes much less of a factor.

To combine all modules into a single resource, we wrote each module into a separate script tag and hid the code inside a comment block (/* */). When the resource first loads, none of the code is parsed since it is commented out. To load a module, find the DOM element for the corresponding script tag, strip out the comment block, and eval() the code. If the web app supports XHTML, this trick is even more elegant as the modules can be hidden inside a CDATA tag instead of a script tag. An added bonus is the ability to lazy load your modules synchronously since there's no longer a need to fetch the modules asynchronously over the network.

On an iPhone 2.2 device, 200k of JavaScript held within a block comment adds 240ms during page load, whereas 200k of JavaScript that is parsed during page load added 2600 ms. That's more than a 10x reduction in startup latency by eliminating 200k of unneeded JavaScript during page load! Take a look at the code sample below to see how this is done.

HTML:
  1.  
  2. <script id="lazy">
  3. // Make sure you strip out (or replace) comment blocks in your JavaScript first.
  4. /*
  5. JavaScript of lazy module
  6. */
  7. </script>
  8.  
  9.   function lazyLoad() {
  10.     var lazyElement = document.getElementById('lazy');
  11.     var lazyElementBody = lazyElement.innerHTML;
  12.     var jsCode = stripOutCommentBlock(lazyElementBody);
  13.     eval(jsCode);
  14.   }
  15. </script>
  16.  

In the future, we hope that the HTML5 standard will allow more control over when the application cache should download resources in the manifest, since using comments to pass along code is not elegant but worked nicely for us.

Posted by Dion Almaer at 6:09 am
11 Comments

+++--
3.4 rating from 20 votes

Next Page »