Chrome, HTML5

HTML5 And Offline – Videos From Google Developer Day 2011

Demos in the keynote


The Chrome HTML5 demos are starting around 40:34…

Bleeding Edge HTML5

The GDD TLV Clip

I hope to get others as well… I’ll update this post with them.

If you wish, the full list of videos from this event is here on youtube.

Standard
Chrome, HTML5, webdev

HTML5 On Mobile Devices (iOS, Android & Windows)

More and more we see mobile devices with stronger browsers that implement a lot of HTML5 APIs. This is other factors are the root cause that mobile development has taken off. Many developers are choosing to go the mobile web route instead of writing the same application repeatedly for each different mobile platform. However, one of the things that you give up by “going web” is the application frameworks that make life easier for developers of native mobile applications. As a result, several web application frameworks are emerging. In this post I will look at some of the best frameworks: jQueryMobile and Sencha Touch. There are some other very good MVC frameworks that are worth look into: SproutCore, Cappuccino and backbone.js but that will be in another story (=post).

Let’s start with one of the most popular JavaScript library – jQueryMobile It’s now in version 1.0 and it’s a powerful HTML5-based user interface system for all popular mobile device platforms. They have a set of UI components that give the developers a lot of power. Its lightweight code is built with progressive enhancement, and has a flexible, easily themeable design. If you are developing apps for business (think components like grids) you might want to take a closer look at Sencha ExtJS and other products. They have a good integration with GWT (if you use it) and overall, they give the developer a lot of power: clean component model, powerful UI widgets etc’. There are some new capabilities that give more native look and feel to your web apps. The first is the Fixed position – Psss… its great for your menu at the top of the screen. I hope will see its adoption on other mobile browsers (and not just the safari 5+). Another cool aspect is the new ‘Path‘ button dynamics all in pure CSS and scroller live demo.

The wave of HTML5

The wave of HTML5 apps is here

Deployment

One of the ‘easy’ parts it the deployment. Once users added your web app as shortcut to their home screen it will be there and updated each time they starting it. You can also, use the Android, iOS stores with a webUI wrapper and tools like AppsGeyser or AppCelerator that will do the work of wrapping for you. I hope that in the future the webUI that we get in iOS/Android will be as good as the webkit we have in the browser on the same platform. Currently, it’s got some limitations. Lastly, in case you wish to check what HTML5 features will work on each device you are targeting: This is a good source: http://mobilehtml5.org/ and for more stats and development tips checkout my last post on html5 on mobile.

Be strong.

Standard
HTML5, JavaScript, webdev

Convert WebSQL To IndexedDB Tutorial

Exactly a year ago on November 18, 2010, the W3C announced that Web SQL database is a deprecated specification. Many major browsers including Chrome, Safari, Opera and nearly all Webkit based mobile devices support WebSQL, however, if you are going to start a new project and/or you wish to have your code running with the new version of client side database (that will receive updates and improvements) you should implement indexedDB as your client side database. In this short post we will see what are the main steps to refractor your WebSQL code to IndexedDB.

First lets create the databases


// WebSQL 
database = openDatabase('todos1', '1.0', 'todo list example db', 2*1024*1024);

// InxededDB
var todoDB = {};
var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB;
todoDB.indexedDB = {};
todoDB.indexedDB.db = null;


Create Table/ObjectStore

In both cases we need some ‘space’ to save our information


// WebSQL - creating a new table
 database.transaction(function(tx) {
     tx.executeSql("CREATE TABLE IF NOT EXISTS tasks (id REAL UNIQUE, text TEXT)", []);
   });

// IndexedDB - creating a new object store that will hold our data
todoDB.indexedDB.open = function() {
        var request = indexedDB.open("todos");

        request.onsuccess = function(e) {
          var v = "2.0 beta"; // yes! you can put strings in the version not just numbers
          todoDB.indexedDB.db = e.target.result;
          var db = todoDB.indexedDB.db;
          // We can only create Object stores in a setVersion transaction;
          if (v!= db.version) {
            var setVrequest = db.setVersion(v);

            // onsuccess is the only place we can create Object Stores
            setVrequest.onsuccess = function(e) {
              if(db.objectStoreNames.contains("todo")) {
                db.deleteObjectStore("todo");
              }
              var store = db.createObjectStore("todo",
              {keyPath: "timeStamp"});
              todoDB.indexedDB.getAllTodoItems();
            };
          }
          else {
            todoDB.indexedDB.getAllTodoItems();
          }
        };
        request.onfailure = todoDB.indexedDB.onerror;
      }

Add Item

Now it’s time to add some data to our database, no?


// WebSQL
function addTodo() {
        var todo = document.getElementById("todo");
        var task = {
          "id": new Date().getTime(),
          "text": todo.value };
        
        database.transaction(function(tx) {
          tx.executeSql('INSERT INTO tasks (id, text) values (?, ?)', [task.id, task.text]);
        });
        // now let clean it to the next todo
        todo.value = "";
        showAll();
      }
      
// IndexedDB
todoDB.indexedDB.addTodo = function(todoText) {
        var db = todoDB.indexedDB.db;
        var trans = db.transaction(['todo'], IDBTransaction.READ_WRITE);
        var store = trans.objectStore("todo");

        var data = {
          "text": todoText,
          "timeStamp": new Date().getTime()
        };

        var request = store.put(data);

        request.onsuccess = function(e) {
          todoDB.indexedDB.getAllTodoItems();
        };

        request.onerror = function(e) {
          console.log("Error Adding: ", e);
        };
      };

Fetch Items

After you have data it’s only make sense to show it to the world (and your dear friends)


// WebSQL
function showAll() {
        document.getElementById("ourList").innerHTML = "" ; 
        database.transaction(function(tx) {
          tx.executeSql('SELECT * FROM tasks', [], function (tx, results) {
            var len = results.rows.length, i;
            for (i = 0; i  Todo text: " + results.rows.item(i).text);
              
              var a = document.createElement("a");
              a.textContent = " [Delete]";
              a.setAttribute('data-key', results.rows.item(i).id);
              a.setAttribute('data-val', results.rows.item(i).text);
              a.addEventListener("click", function() {
                deleteTodo(this.getAttribute("data-key"),this.getAttribute("data-val") );
              }, false);
              li.appendChild(t);
              li.appendChild(a);
              document.getElementById("ourList").appendChild(li);
            }
          });        
        });
      }

// IndexedDB
function showAll() {
        document.getElementById("ourList").innerHTML = "" ;   
        var request = window.indexedDB.open("todos");
        request.onsuccess = function(event) {
          // Enumerate the entire object store.
          var db = todoDB.indexedDB.db;
          var trans = db.transaction(["todo"], IDBTransaction.READ_ONLY);
          var request = trans.objectStore("todo").openCursor();
  
          request.onsuccess = function(event) {
            var cursor = request.result || event.result;
            // If cursor is null then we've completed the enumeration.
            if (!cursor) {
              return;
            }
            var element = document.createElement("div");
            element.textContent = "key: " + cursor.key + " => Todo text: " + cursor.value.text;
            document.getElementById("ourList").appendChild(element);
            cursor.continue();
          }
        }                    
      }


Delete Item

In rare cases we wish to delete stuff… It’s easy.


// WebSQL
function deleteTodo(id, text) {
        if (confirm("Are you sure you want to Delete "+ text +"?")) {
          database.transaction(function(tx) {
            tx.executeSql('DELETE FROM tasks WHERE id=?', [id]); 
          });
          showAll();
        } 
      }

// IndexedDB
todoDB.indexedDB.deleteTodo = function(id) {
        var db = todoDB.indexedDB.db;
        var trans = db.transaction(["todo"], IDBTransaction.READ_WRITE);
        var store = trans.objectStore("todo");

        var request = store.delete(id);

        request.onsuccess = function(e) {
          todoDB.indexedDB.getAllTodoItems();
        };

        request.onerror = function(e) {
          console.log("Error Adding: ", e);
        };
      };


As Oscar Wilde said: “…Consistency is the last refuge of the unimaginative…” – so in our case, let’s save data locally and have more performance in our web apps (with some consistency).

Live Example

All the code is on github – https://github.com/greenido/WebSQL-to-IndexedDB-example

and you can play with a live example.

Standard
Chrome

How To Share Files/Photos From Chromebook

There are cases where you need to upload some photos from your Chromebook. Let’s take the classic case of a disk-on-key a friend just gave you and ask you to upload it to your Dropbox so you, him and all your friends can share this mountain bike trip photos (= true story). In other cases, it might be that you are on vacation and after 1275 photos you finally came to the conclusion, it make sense, to update your family and friends at home. You take the SD and insert it to the Chromebook (yes – we do have a slot for that). But how can you upload it? What are the best tool to share it?

Here are few good solutions:

  1. Flickr, Picasa and other photo sharing sites just got their web version of uploading photos – so that is the easy case.
  2. Google Docs – you can upload files and then share them with friends… It’s also works great with directories.
  3. We have some good extensions that works great on Chromebook.
    1. Cloud Save – add some right click functionality that will let you upload any image/file you click on,  to your favorite cloud storage: Dropbox, flickr, Box.net, Google Docs, Picasa, Facebook and more). It also got another extension that bind it with a nice integration to the file manager that we have on Chromebook – CrOS Save. This will let you choose files from the file manager and then to have a new button on the right side-bar that let you upload these files with one click.
    2. SMEStorage Cloud Dashboard – if you are using something from their services.
    3. Large Document – If you need to share BIG files. This is a secure file transfer and sharing service that does not require any login information. You can transfer files as large as 2 gigabytes in size and can store up to 15 gigabytes of data for up to 180 days for free.
  4. If you are ‘old school’ and you wish to use FTP – http://www.net2ftp.com just be careful when inserting user/password to ANY 3rd party site.

Know any other good tool I’m missing here? Please let me know…

Standard
Business, Chrome

CloudCon – Summary

First you might ask, what is CloudCon?
Well, this is what the organizers are saying: “…At the convention we will focus on the new possibilities opening before IT managers with the move to cloud computing services, listen to the new offers made by leading software providers and learn the ways of the cloud as presented by analysts, experienced infrastructure managers, developers, IT managers and other cloud experts.”
My main objective was to expose CIO/CTOs to ChromeOS, CWS and to educate them about the new capabilities that HTML5 is harnessing their IT departments. I also wanted to show IT Admins how easy and cost effective is to deploy Chromebooks in their organizations. Overall, there were 400+ attendees and among the invitees: IT managers, R&D Managers of Israeli ISV’s, Security Managers, infrastructure managers, storage managers and other IT pros.
This was my session “HTML5 & ChromeOS” and in case you miss the presentation.

This is a short summary from the organizers: pc.co.il/CloudCon
and for the ones that can read hebrew… here is another one:

Standard
Chrome, JavaScript

Chromebook and window.open()

I got few questions last week on #GDDDE (=Google Developers Day 2011 and #GDD11 which is the popular hash tag both in G+ and Twitter for these events) about window.open() in Chromebook. Here is a summary of the answers.

Few things you might didn’t know about window.open() in ChromeOS:

  • window.open() will open a new tab if the window size > 50% of the width or 60% of the height of the window. So it will be a bit different in Samsung and Acer due to the different screen sizes.
  • An app / extension can use the chrome.window API to call chrome.windows.create() which takes a “type” parameter which will always be obeyed. (Panel windows will be constrained to 80% of the screen width and height). Let’s have a look on how to use it.

First, let the browser ‘know’ what type of window you wish to have use this:

 chrome.windows.create(object createData, function callback) 

Creates (opens) a new browser with any optional sizing, position or default URL provided. You should use ‘type’ as part of the ‘createData’.

 type - ["normal", "popup", "panel"]  
This is the source of true about the window object API. Be strong.
Standard
Business, Chrome

If You Care About Security (And Privacy) – Chromebook Is Your Guardian

In today’s world, any website (even well-known ones), may be infected with malware. the problem is that when you go and visiting an infected web page, ordinary computers can get infected as well. This is not the case with Chromebooks. This new OS is changing a lot of things in the game and one of them is security. Let’s see what are the main features that harness your Chromebook with capabilities that other OS do not have (unless you invest in expensive software…).

Here are the main points to remember when you going to shop for a new ‘secure’ laptop:

All your data will be Encrypted

There are so many cases when you lost your laptop and then all your data is in the ‘wild’. On the Chromebook you are safe. When you use web apps on your Chromebook, all your documents are stored safely in the cloud. But certain kinds of files, like downloads, cookies, and browser cache files, may still be present on your computer. Your Chromebook encrypts all this data using tamper-resistant hardware, making it very difficult for anyone to access those files.

Verified boot – You can look at it as ‘self cure’ capability 

Even if malware manages to escape the sandbox, your Chromebook is still protected. Every time you boot the computer, it does a self check called Verified Boot. If it detects that your system has been tampered with, or corrupted in any way, typically it will repair itself without you lifting a finger. You will always be able to get back to an operating system that’s as good as new.

Automatic Updates – Most effective way to stay healthy

The most effective way to protect yourself from malware is to make sure all of the software on your computer is up to date and has the latest security fixes. Chromebooks manage updates for you automatically so you are always running the latest and most secure version. Ya, it’s like Chrome, where you get every 6 weeks a new update version with more features, speed improvements and security fixes.

Sandboxing – Sperate in order to gain control

On your Chromebook, each web page and application you visit runs in a restricted environment called a “sandbox.” So if you visit an infected page, it can’t affect the other tabs or apps on your computer, or anything else on your machine. The threat is contained.

These are the main features. Sounds good, no?

Standard
Chrome

How To Get Things Done With Chromebook

Some short videos to put you up and running with the new Chromebook you got (or gave) for the holidays… In this short tutorials we will see how lots of complicated tasks can be done quickly. We will start with some easy tasks like: fixing your dad’s computer (and you can take it to other places like: helping mom with her 2 years old desktop etc’), how to set it up and even how to backup!

At the end, we will see how Chromebook helping both students and business be more productive and getting A+

Continue reading

Standard
Chrome, HTML5

Google Developers Days (Tel Aviv & Berlin) And One CloudCon

It was a busy week. Busy but with lots of fun. It’s so great to meet wonderful developers that push the web forward and know (and love) their profession. Last sunday, we had Google Developers Day in Tel Aviv (or Airport city if you want to be accurate) – it was well organized event with more then 1400 developers. In the keynote we had three demos:

  • Android – Ice cream sandwich new capabilities (maps, nfc, HD and other features. To dive deeper, go check Romain Guy’s blog).
  • Chrome/HTML5 amazing new features – I did the demos and I hope to post a list next week.
  • G+ – the new hangout APIs with a robot that eat falafel and drink beers.
Here you can check some coverage:
 The CloudCon was also impressive in terms of the audience (mainly, CIO/CTO dudes) – they liked the story of HTML5 and ChromeOS. I got some good questions on new features: offline, notifications, threads and even on web audio. It could be great to have the new Chromebooks in Israel, it seems that the market really want them. The one argument (or selling point if you want to push here) that conviense IT people is that the TCO (=Total cost of ownership) is 60%-70% cheaper. Yes – these are the numbers… so if your organization can work with web apps (and Citrix for the apps that you don’t want to move to the web) it might be a perfect solution for you.

I hope to get some photos soon (from our dear wonderful photographer) – so I’ll update this post with fresh photos of some great looking people.

Tomorrow we are going to rock Berlin – so keep up with us using G+ with #GDD11 tag  or this blog next week. Btw, for Berlin GDD you might want to search after #GDDDE

Be strong.

This slideshow requires JavaScript.

In case you want to follow the slides from my Talk in CloudCon – The ‘love’ story of HTML5 & ChromeOS.

From Google Developers Day in Berlin here are the talks:

Standard
Chrome

ChromeOS In VirtualBox – Test Drive It

In a lot of cases you wish to develop to the new Chromebook but don’t have the hardware or just want to be more productive while working on your 8-core linux box… In these cases, there is a good option to run the latest ChromeOS inside Virtualbox (or VMware if you have it). A quick reminder, Chromium OS (which is the open source version of ChromeOS) is a project that aims to build an operating system that provides a fast, simple and more secure computing experience for people who spend most of their time on the web. In our tutorial here we will use Chromium OS images.

 

 

 

The steps to follow

  1. Download VirtualBox.
  2. You can build your own OS if you wish, just go to: chromium-os and read the details.
    However, there is an easy way – just download an image of Chromium OS – I have one for you here or just type http://bit.ly/crOS-16.
    And this guy is creating lots of fresh images of Chromium OS every day. So if you want the real ‘development’ (=alpha) version of it – check it out.
  3. Open the VirtualBox and click on ‘New’ button (upper left corner) – You will get this:

Choose Linux and Ubuntu and click ‘Continue’.

Next you need to set the memory – make sure to set an amount that you can devote to VirtualBox without killing your machine. Something around 1500MB should work. If you have more, even better.

The last part of this wizard is to choose the image file. Click on the radiobox and point to the place you save the image file of ChromeOS.

Next dialog will show you a summary of all the details and after you will click ‘Create’ you are good to go!

Tips

  • Make sure to open ‘Setting’ of your new virtual machine and under ‘Processor’ click the PAE checkbox. If you won’t do that, you will get the ‘black screen of death’ and the machine won’t start.
  • If you getting errors while loading – sometimes it’s due to lack of memory. Try to close some applications and start the virtual box again.
  • Make sure you have something like 100mb of memory to the ‘video memory’ under the display section in the settings.

 

3 Minutes Video Tutorial

Standard