Jo on webOS Tutorial

Today we’ll take a look at the Jo Javascript Framework. From the project’s website:

“Jo is a JavaScript framework for HTML5 capable browsers and devices. It was originally designed to work on mobile platforms as a GUI and light data layer on top of PhoneGap. Since its creation, Jo has also been tested successfully as a lightweight framework for mobile browsers, newer desktop browsers, and even Dashboard widgets.”

This tutorial is based on “Une Webapp en moins de 10 minutes avec Jo” http://www.k33g.org/?q=node/50

Let’s go ahead and create a quick little application called “Todo” for webOS with the Jo Javascript Framework:

Project Website: joapp.com
Download: https://github.com/davebalmer/jo/downloads (0.3.0 at the time of writing)
Documentation: http://joapp.com/docs/index.html

Download Jo and unpack it to a new directory, in our case jo_0.3.0. Let’s create a new subdirectory called projects and in that one another subdirectory for our project called todo. Copy the css folder from jo_0.3.0 and the js/jo_min.js file and put it in the root of our todo directory. Now create a new file index.html, this will be the file for our Application. Edit it to contain:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>My ToDo List</title>
 
    <!-- stylesheets -->
    <link rel="stylesheet" href="css/jo.css" type="text/css">

</head>
<body onload="App.load();">
<!-- lib -->
<script src="jo_min.js"></script>
<!-- app -->
<script>
    // Start "Jo"
    jo.load();
     
    var App = {
 
        // app init
        load: function() {
            // create a screen and a scroller
            this.screen = new joScreen([
                this.stack = new joStackScroller()
            ]).setStyle("stretch-full");
             
            // create a new card with a title
            this.card = new joCard([
                new joTitle("My ToDo List"),
            ]);
             
            // push the card to the stack
            this.stack.push(this.card);
        },

    };
     
</script>
</body>
</html>

As you can see, Jo uses a similar stack and card system as webOS.

Test the Application in your desktop browser first, we’ll package it for webOS later.

Let’s add a Group (that groups elements together) containing an Input Field and Button:

            // create a new card with a title
            this.card = new joCard([
                new joTitle("My ToDo List"),

		new joGroup([
		        new joLabel("I need to : "),
		        this.currentTask = new joFlexrow(this.myinput=new joInput("enter Todo")),
		        this.addTask = new joButton("Save").selectEvent.subscribe("none", this)  
	        ]),

            ]);

We’ll also add some predefined tasks. These would probably come from a database or web-service in a more refined version of this Application.

    var App = {

        // have some persistent entries
        tasks: ["Wash the dishes", "Take out the trash", "Clean the room"],
 
        // app init
        load: function() {

Those predefined (and also the tasks we add manually) will show up in a list farther down, let’s add that:

		new joGroup([
		        new joLabel("I need to : "),
		        this.currentTask = new joFlexrow(this.myinput=new joInput("enter Todo")),
		        this.addTask = new joButton("Save").selectEvent.subscribe("none", this)  
	        ]),

		this.taskListcontrol = new joList(this.tasks).setAutoSort(true),    

            ]);

Now lets add the functionality needed to add a new task to the list:

            // push the card to the stack
            this.stack.push(this.card);
        },

        addNewTask: function(){
            //push the new task to the tasks array
            this.tasks.push(this.myinput.getData());
            //refresh our list
            this.taskListcontrol.refresh();
            //create a popup notification
            this.screen.alert("New Task", "The new Task has been saved.");
        },

To make it work, we also need to modify the button code:

		        this.addTask = new joButton("Save").selectEvent.subscribe(this.addNewTask, this)  

Test it again in the desktop browser and make sure it works. To make a webOS application, we just need to change a few things:

add an appinfo.json file with the following contents:

{
	"id": "com.inorbit.todo",
	"version": "0.0.1",
	"vendor": "ThinMachine",
	"type": "web",
	"main": "index.html",
	"title": "Todo",
        "icon": "icon.png"
}

Change the id,vendor and title values to your liking and save the file.

Since we’re not using the Mojo Framework from the webOS SDK, we need to add one statement:

    // Start "Jo"
    jo.load();
     
    if (window.PalmSystem) {
       window.PalmSystem.stageReady();
    }

    var App = {

This tells the Palm Browser that our Application is ready when it starts.

Let’s package and install our webOS App:

palm-package todo

palm-install com.inorbit.todo_0.0.1_all.ipk

Either install it to the webOS emulator or to your webOS Device.

Webtuesday, December 14th 2010

I was invited to speak at the webtuesday Zurich on December 14th, 2010. I talked about what webOS is and how to develop web-based apps for it. Palm sent developer devices to give away … 2 people got very lucky and won a brand new Pre2 with webOS 2.0!

Link to the Presentation: http://www.thinmachine.ch/presentations/wt2010/

Resources:

Palm Developer Portal: http://developer.palm.com
My multi-part webOS SDK Development Tutorial: http://mobile.tutsplus.com
Community webOS Documentation Wiki: http://webos101.com
WebOS-Internals WIKI: http://www.webos-internals.org

Introduction to webOS SDK Development, 5-part Tutorial Series

I wrote a 5-part Tutorial Series on webOS SDK Development on mobile.tutsplus.com. You will learn how to install the webOS development environment and create a simple application. In subsequent parts of this series, we will create a usable application that allows you to browse and display the latest articles on the tuts+ network.

Introduction to webOS SDK Development

In this tutorial, you will learn how to install the webOS development environment and create a simple application.

Introduction to webOS SDK Development: Part 2

In this tutorial, you will learn how to build a webOS application to display all the sites in the tuts+ network. This is the second installment of a series on webOS mobile development. Read part one of this series for a general introduction to the platform and to become familiar with the tools you will need to develop webOS applications.

Introduction to webOS SDK Development: Part 3

Welcome to the third part of our series on webOS SDK development. In part 2, we supplied static data to a list. This tutorial will show you how to load dynamic data into a list. We’re going to use AJAX and YQL to achieve this.

Introduction to webOS SDK Development: Part 4

This is the fourth installment of our webOS introduction series. In this tutorial, you will learn how to use the webview widget in webOS to display a website embedded in your app. We’ll also add functionality to allow list item reordering and deleting.

Introduction to webOS SDK Development: Part 5

This is the fifth and final part of our beginning tutorial series on writing apps for the webOS SDK. In today’s tutorial, we’ll tie up some loose ends from previous tuts and then I’ll wrap up by showing you how to submit your own applications to the App Catalog.

Enjoy and i’m looking forward to feedback.

FrontTrends 2010, Warsaw, Poland

I had the pleasure to attend the Front-Trends 2010 Conference in Warsaw, Poland and give a talk about webOS. This was my first talk ever at a conference; based on feedback it was received quite well, although i managed to make some people fall asleep :)

webOS is not very well known in Poland, the current devices are not available there. It was interesting to show the audience that while the rest of the industry is moving towards web-based Apps, webOS had those from the beginning and it’s especially easy for web-developers to get into webOS development. I hopefully inspired many people in Poland to give webOS a try and compare it to other platforms; be it for “native” webOS applications or working with phonegap and other tools to have cross-platform webapps.

Seeing talks given by big names like Douglas Crockford (who’s talk i already enjoyed in Berlin at JSConf), Tantek Celik, Peter-Paul Koch and others i learned a lot how to present successfully and how to engage your audience. Most engaging talk for me was Jan Lehnardt’s “Peer to Peer Web and Why you should care”; while i was most inspired by Peter-Paul’s Koch “JSON over SMS”. It was great to meet so many new faces in the speaker community as well as in the developer community. For me conferences are always inspiring in terms of content but also how many new connections you can make.

Palm sent me some Palm Pre Plus Phones to give away during the conference, unfortunately they got stuck in customs so i had to cancel my planned hands-on webOS development workshop. I ended up raffling off four webOS development books and two devices (who will be sent to the lucky winners after they finally arrive in Poland).

My Talk “you know webOS”

We’ve seen the rise of web apps, written in HTML/CSS/Javascript, running on top of WebKit. Palm’s webOS treats web apps as first citizens, even the built-in apps are built that way. We’ll take a closer look at what webOS is and how to develop web apps for it. If you are a web developer, you’ll feel right at home with webOS.

Link to the Presentation: http://www.thinmachine.ch/presentations/ft2010/
If you attended my talk, please rate it and give feedback: http://speakerrate.com/talks/4879-you-know-webos

Resources:

Palm Developer Portal: http://developer.palm.com
My multi-part webOS SDK Development Tutorial: http://mobile.tutsplus.com
Community webOS Documentation Wiki: http://webos101.com
WebOS-Internals WIKI: http://www.webos-internals.org

MobileMonday, October 4, 2010

Tablets – the birth of a new mobile device category?

Archos – Devices 2010

5 different screen sizes: 2,8″ 3.2″ 4.3″ 7.0″ 10.1″
Video,Photo,Web,Music,WebCam (Video Calls)
Appslib.com, no Android Market .. another app store? 70/30 split? open to other manufacturers -> apps store fragmentation?
Apps on TV via HDMI .. Tablet used as touchpad, keyboard support via USB/Bluetooth
Games on TV via HDMI … Tablet sensors (e.g Accelerometer) used for Game Controls
no 3G, uses phone via bluetooth tethering
Thin and light, 1Ghz ARM Processor, low price ($99-$299) -> battery life?

Sobees – Social Media Aggregator App

if you come from smartphones, you need to rething your app because the surface on a tablet is much bigger
tablets have a more “normal” userbase (e.g kids and older people)
tablets are used differently than a desktop … Wife-acceptance-factor
cross-platform issues (c++/java/…) … web apps are not here yet? (questionable, depends on the app)

Transaction Consulting – The changing Media landscape

look how far mobile has come, 10 years ago we tried and failed with WAP
Paid Content — the saviour for the media industry?
Challenge for the media industry: growth with (sparen)?
declining Ad revenue on traditional media, tablets as the end of free content culture?
tablets -> new buiness models, new sales channels
Special Interest, indepth Journalism -> most likely to be paid-content
New business models in “mobile only” – foursquare,flipboard,…

Telesoftas – trends for tablets

Tablets have been around for 10 years … pen based w. full OS vs. touch based w. mobile OS
iPad Success: Usability,Apps,Design,Brand
2011: projected 55mio tablet devices will be shipped
Usage for tablets: consume content, new media usage .. in the future: productivity and business apps

HES-SO – Research Apps

securePP – phone and tablet are linked, data is shared .. if one device gets lost, data is deleted
mediPad – tablet as an interface for medical information
FloorNav: virtual tours of buildings on a tablet, WIFI based indoor positioning
Remote Control: tablet interface for home automation, NAIF framework, RFID authentication

JSConf.eu, September 24-27, 2010

I went to JSConf.eu in Berlin. Here is what i wrote down during the sessions:

Friday, PhoneGap Training

the web should be a first class development platform, agnotic to the device delivering the experience
phonegap is device data and device sensor interface
90+ app stores globally -> phonegap doesn’t address that
phonegap is a temporary progressive enhancement
phonegap is not trying to solve mobile web ui development
you have to install the native sdk, device provisioning, code signing, distribution
phonegap is solving: native device sensors and data access from javascript, installable web apps, tooling
now: iOS,Android,Blackberry,webOS,Symbian .. soon W7,Bada,MeeGo

device API’s:
WebKit, all that html5 stuff
Device(orientation,..), Events, Network, Notification, Accelerometer, Geolocation, FileIO, Camera, Contacts, Magnetometer(Compass), Media, XMPP, Maps
phonegap is participating in the W3C Device API group (widget and geo groups too)
installable web apps: title and icon, loading screen, permissions manifest
web apps are nearly impossible to protect from theft and forgery
-> docs.phonegap.com
all phonegap api’s are async

testing is hard, need devices ->qUnit,mobile-spec,mr.toad(node,remote debugging)
debugging: ios: xcode, eclipse: blackberry, android debug bridge, palm debugger/ares, symbian: eclipse, webkit inspector

contributing partners: sony ericsson,palm,nokia,symbian,ibm,microsoft,rim

phonegap alternatives: rhodes,appcelerator,quick connect,corona,monotouch

develop for just the browser first, don’t even include phonegap.js yet
meta tag viewport is important
create one page with different views (stage with scenes as on webos), a view is a div that is hidden and shown as needed
think of your phonegap app as an webapp
every phonegap app should listen to deviceready before doing anything
add application.js with your application logic

XUI: Mobile DOM Framework (follows jQuery, much smaller size), xuijs.com
LawnChair: micro json datastore library
zepto: minimalistic framework

JSConf.eu Day 1, Saturday

Using the Web to deliver the next wave of computing experiences: Dion Almaer & Ben Galbraith (Palm)

HTML5 APIs – The new frontier: Robert Nyman

progressive enhancement
video,audio,canvas,geolocation,svg,storage (sessionStorage,localStorage,webSQL,indexedDB), WebWorkers, Offline Web Applications, File API, Drag & Drop, History API, Web Sockets, WebGL

Creating interactive Data Visualizations for the Web: Nicola Garcia Belmonte

InfoVis Toolkit
Force Directed Graphs, based on Physical Simulation

If it moves they will watch it: Sebastian Deutsch & Sebastian Seidt

animation with canvas: manual redrawing, drawing loop (clear, change, draw), no DOM

add interaction -> click event, collision detections, (libraries: processingJS, three.js)

svg: XML, 2D, DOM based, Filters/Animations

css3: transitions/animations (translate,scale,rotate,matrix) .. hw accelerated on some platforms

target device decides what you’re going to use -> mobile device: css3

Server-side Javascript the untold story: Ulrike Müller (DemandWare)

ServerSide Javascript in Production for the demandware environment (SaaS)
using Rhino Core
shared environment + custom code + sla = challenges e.g malicious code, data sizes -> quotas: length of strings, length of arrays, size of arrays, …
lessons learned: java<->javascript

node.js + CouchDB == Crazy Delicious: Mikeal Rogers

both node.js and CouchDB use javascript and http
CouchApps are Apps served from a couchDB (html and client-side javascript, talking to server-side javascript)
Scenario one: Browser -> node -> couchDB (classical 3-tier)
CouchApp: Browser -> CouchDB -> node
Example: Browser with local couchDB: store job (e.g send email, async) -> sync to server couchdb -> node sends email, onsuccess updates server db -> updates client db -> browser

Dirty noSQL: Felix Geisendörfer

SQL or noSQL? look at your data! relational->SQL otherwise->noSQL
dirty.js=small node library (150loc) to store key,value (JSON), no network support, runs local, <1Mio records
db=require(‘dirty’)(‘test.db’);
db.set
db.get
db.forEach
db.remove

node.js in production use: nodealias.com: Philip Hofstetter

problems under load: file handle starvation due to left open sockets when an exception occurs

Lessons learnt pushing browsers to the limit: Ben Firshman

NES Emulator: c code was “ported” to javascript manually and the optimized
optimize canvas usage: instead of redrawing every pixel for the canvas, just redraw the changed pixels

Rapid Prototyping for Multiple Platforms with Javascript: Joe McCann

want a rapid prototype to see if an idea can be realized? Targets: Desktop Browser, Mobile Browser, Desktop App, Android App -> all with Javascript
Tools used: node.js with express and connect modules (serverside)
Appcelerator Titanium -> Desktop+Phone
PhoneGap -> Phone HAL
CouchDB -> DB
YQL – Webservice abstraction
CSS Media Queries (design for a flexible layout, not for a specific device)

Kick ass code editing and end-to-end JavaScript debugging: Fabian Jakobs

Cloud9, a new browser-based coding IDE: Editor+Debugger

Chakra: Building a new JavaScript Engine for Internet Explorer 9: Pete LePage

JSConf.eu Day 2, Sunday

Loopage: Douglas Crockford (Yahoo)

Multithreading vs. Event Loop (no more Deadlocks)
Never block; Never wait; Finish fast

The State of HTML5: Inaugural Address: Paul Irish (Google)

Dependable Features:
Doctype
charset
self-closed tags, optional “”
new sematics
data-*
contenteditable

Roughly usable:
audio,video tags
canvas
svg
geolocation
websockets
drag&drop
input autofocus/placeholder

Experimental Features:
Meter/Progress
webSQL
Storage
WebWorkers
WebGL
File API
History API

Edge Features:
HW Acceleration
indexedDB
Orientation
Device API
Audio Data API
<input speech>
SVG Filters

Use regressive Enhancement:
HTML5 fallbacks (modernizer)
yepnope.js/has.js

Introducing Unify- A Framework for Cross Platform Applications: Sebastian Werner

webOS Support in Q2/2010
mobile apps -> fragmentation
building blocks: qooxdoo/phonegap/sass/AIR
webengine as the unified platform, HTML/CSS/JS
1 Code -> App Store,Web,Desktop

Socket.IO: Web Sockets for everyone: Guillermo Rauch

http://socket.io

github.com/guille/nodestream for real-time apps
all major browsers supported

Robotic Javascript: Jörn Zaefferer & Nikolai Onken

ArduinoJS
node-serial
github.com/nonken

The Front-end Takeover: Aaron Quint

sammy.js
mustache templates
soca: sammy on couchapp
compass: css preprocessor

Performance Patterns: Stoyan Stefanov (Yahoo)

jsperf.com
reduce # of scripts
use gzip
minify
use expires
use CDN

async=good
use progress indicator to show the user that something is processing (user perception)
move js to the bottom of the page
create script element via js
use flush 1) header,flush 2) results,flush 3) js
script injection -> appendchild to head/body
use preloading e.g for images
cache length of strings/arrays instead of using variable.length
pass this and document to your functions instead of referencing them
cache results (global object or offline)
use a proxy object, at 1st call initialize proxy object, at 2nd call initialize real object, at 3rd and subsequent calls
access proxy object (caching)

Community.js (Chris Williams)

better education for JS beginners -> promoteJS.com
love the private, fear the privateer

I also gave 2 quick (40min) introduction crash courses about webOS Development, since many attendees got a Palm Pre with webOS at the Saturday Night Party

Swiss Open Expo, March 24/25 2010 in Bern, Switzerland

Palm WebOS shows its potential at the 8th Open Expo, the largest Swiss Open Source trade show. The Open Expo visitors were able to gain a first glance at the sophisticated smartphone operating system from Palm.

Report from the WebOS-Internals booth

Over 40 companies presented their open source products and related services during the two days of the trade show. Most open source projects were well visited and the visitors showed great interest.

As presenters of the WebOS-Internals Project (www.webos-internals.org) we were able to gain an initial impression of visitor reactions about WebOS.

The visitors’ reactions to WebOS, the new smartphone operating system by Palm and the successor to PalmOS, were very positive overall. We demonstrated WebOS on the Palm Pre, which is sold trough O2 in Germany and imported in Switzerland by Digitec. We demonstrated the ease of the included WebOS apps, the possibility of having multiple apps open simultaneously (multitasking), the latest 3D games, some of our own apps and, of course, the open source applications by WebOS Internals, for example Preware to install and manage homebrew and app catalog apps.

Many of our booth visitors were surprised  of the current developments, trends  and features of WebOS. Based on open source technologies such as Linux, WebKit, SDL, and Web standards such as HTML5 and javascript, it also offers developers an easy start, be they Linux experts or web developers. Our give-away book about WebOS-development was also well received.

In comparison to other products, such as Android (Google), many positive differences and advantages in favor of WebOS were noticed – iPhone (Apple) usually came out last, no surprise with our audience …

A frown was noted when our visitors had to learn that WebOS can “only” be used on Palm hardware. The most frequent question was: “Where can I buy hardware with WebOS?” Many were surprised to hear that WebOS is developed by Palm.

Conclusion:
The Palm Pre with WebOS should be released for sale on a carrier in Switzerland as soon as possible!

Presenters: Markus Leutwyler & Thomas Winteler

See a Picture Gallery from the Event