SlideShare une entreprise Scribd logo
1  sur  43
PhoneGap and BlackBerry
WebWorks: Two Allies that Simplified
Development of Nursing App
Michael Brooks, Nitobi Software
COM12
October 20, 2011
Michael Brooks
     @mwbrooks
     Nitobi Software
     PhoneGap Core Maintainer
PhoneGap
User’s Perspective
Developer’s Perspective
Developer’s Perspective




document.addEventListener(‘deviceready’, function() {
  // PhoneGap is ready
}, false);
Contributor’s Perspective
PhoneGap is a Web view
PhoneGap is a Web view
PhoneGap binds JavaScript to Native
PhoneGap is Cross Platform
RNAO Overview
RNAO Mobile Website
RNAO Wanted




Vendor Store Presence

  Offline Application
RNAO Platforms
Visual Differences
RNAO Postmortem
Directory Structure
Command-line Build




$   rake   android
$   rake   desktop
$   rake   ios
$   rake   blackberry
$   rake   blackberry-webworks
Directory Structure
---                                     Platform Manifest File
blackberry-widget: true
destination: platforms/blackberry-widget/www
html:
     - filename: index.html
css:
     - filename: style/index.css
     - filename: style/blackberry.css
javascript:
     - filename: javascript/app.js
other:
     - filename: style/image/*
     - filename: platform/blackberry-webworks/*
---
Preloaded Database




$ rake database
    => database.json
JavaScript Libraries




xui           JSON2.js
      ~71kB




              }
Sprite Images
PhoneGap Plugins



BlackBerry®        BlackBerry WebWorks   Android™ / iOS

URLCache           URLCache              URLCache
Database restore   Database restore
Database search    Database search
Database update
SplashScreen
<!DOCTYPE html>                                              index.html
<html>
    <head>
        <meta name="viewport" content="width=device-width, initial-scale=1.0,
maximum-scale=1.0, user-scalable=no;" />
        <meta name="HandheldFriendly" content="true" />

        <title>Nursing Best Practice Guidelines</title>

       <link href="style/index.min.css" type="text/css" rel="stylesheet" />
   </head>
   <body>
       <script type="text/template" id="splashscreen-template" class="view">
           // ...
       </script>

        <script type="text/javascript" src="javascript/index.min.js"></script>
    </body>
</html>
UserAgent Sniffing
//
// Find the current device
// @return {{DomString}} 'blackberryX', 'android', 'webkit', 'desktop'
//
findDevice: function() {
    var userAgent = navigator.userAgent;

    if   (userAgent.match(/browzr/i))                 return   'blackberry4';
    if   (userAgent.match(/blackberryd*/4..*/i))   return   'blackberry4';
    if   (userAgent.match(/blackberryd*/5..*/i))   return   'blackberry5';
    if   (userAgent.match(/android/i))                return   'android';
    if   (userAgent.match(/blackberryd*/6..*/i))   return   'webkit';
    if   (userAgent.match(/webkit/i))                 return   'webkit';

    return 'desktop';
}
//
// Preload Images                                                   Preloading Images
//
// The images are preloaded into the DOM and then removed.
//
// @param {DOMString} imgSources is an array of image URLs to preload
//
Application.help.preloadImages = function(imgSources, callback) {
    var img = null;


     var preloadNextImage = function() {
         if (img !== null) delete img;
         if (imgSources.length <= 0) { Application.dispatch(callback); return; }


         img        = new Image();
         img.onload = preloadNextImage;
         img.src    = imgSources.pop();
     }


     preloadNextImage();
};
External Link Quirks
// BlackBerry child browser
  if (Application.supports.browser.widget) {
     blackberry.invoke.invoke(
         blackberry.invoke.APP_BROWSER,
         new blackberry.invoke.BrowserArguments(href)
     );
}
// Android child browser
else if (Application.supports.browser.android) {
     window.android.loadExternalUrl(href);
}
// Everyone else
else {
     document.location = href;
}
// @blackberry4 workaround for render issues that display a white
// block that proportional in height to the amount scrolled vertically.
if (!Application.is('blackberry4')) {
  x$(element).addClass('selected');                                       Page Target Quirks
}


hash = hash[0].replace('#', '');
if (hash !== '') {
  if (Application.events[hash]) {
    Application.trigger(hash, element);
  }
  else if (Application.is('android') || Application.is('blackberry4')) {
    document.location.hash = '#' + hash;
  }
  else {
    var $element = x$('a[name=' + hash + ']');
    $element     = ($element.length > 0) ? $element : x$('#' + hash);


        if ($element.length > 0) { $element[0].scrollIntoView(true); }
    }
}
Ellipsis Support
//
// Ellipsis Support
//
// @param {DOMElement} DOM element to apply ellipsis to
//
Application.help.ellipsis = function(element) {
    if (Application.supports.ellipsis) return;

     // ... manually create ellipsis
};

// ...

Application.supports.ellipsis = (typeof e.style.textOverflow !== 'undefined');
//
                                                                    Feature Detection
// Detect Browser Features
//
Application.help.detectFeatures = function() {
   Application.supports = {
     browser: {
        widget: !!(typeof window.blackberry !== 'undefined' && window.blackberry.invoke),
        android: !!(typeof window.android !== 'undefined' && window.android.loadExternalUrl)
     },


     splashScreen: {
        hide: !!(window.plugins && window.plugins.splashScreen && window.plugins.splashScreen.hide)
     },


     store: {
       backup: !!(window.plugins && window.plugins.store && window.plugins.store.backup),
       restore: !!(window.plugins && window.plugins.store && window.plugins.store.restore),
       search: !!(window.plugins && window.plugins.store && window.plugins.store.search)
     }
  };
};
Feature Detection



if (Application.supports.database.sqliteGears) {
    // ...
}
else if (Application.supports.file.reader && Application.supports.database.sqlite) {
   // ...
}
else if (Application.supports.store.restore) {
   // ...
}
//
// Search records using the PhoneGap plugin or JavaScript Feature   Detection
//
if (Application.supports.store.search) {
    window.plugins.store.search(query, function(response) {
        jsonResponse.data = response.message.data;
        jsonResponse.error = response.message.error;
        renderResults();
    });
}
else {
    Application.database.all(function(records) {
        for(var i = 0; i < records.length; i++) {
            matchRecord(records[i]);
        }

          renderResults();
    });
}
Application.help.getStoragePath = function() {
    var storagePath = '';                                      PhoneGap File API Quirks
     if (typeof navigator !== 'undefined' && navigator.fileMgr) {
         var rootPaths = navigator.fileMgr.getRootPaths();


         for (var i = 0; i < rootPaths.length; i++) {
             // iOS workaround. For some reason it returns an invalid path on the simulator.
             if (rootPaths[i].match(/document/i)) {
                 storagePath = './../Documents/';
                 break;
             }
             // BlackBerry / Android
             else if (rootPaths[i].match(/sdcard/i)) {
                 storagePath = rootPaths[i];
                 break;
             }
         }
     }


     return storagePath;
};
Performance
//
// Dispatch a function asynchronously
//
// This will push the process onto a new
// execution stack and allocate a new memory
// heap. This is very useful for BlackBerry5,
// which runs into memory issues on deep
// callback stacks. It is important to understand
// that dispatch will only fire after the current
// execution thread ends.
//
// @param {Function} function to dispatch. Accepts no args.
//
dispatch: function(fn) {
    setTimeout(fn, 10);
}
What would we do different?
Use Backbone.js
Use jQuery Mobile
Use Jasmine BDD




describe(‘Guidelines’, function() {
    it(‘has preloaded content’, function() {
        expect(this.guideline.get('sections').length).toEqual(2);
    });
});

describe(‘Sections’, function() {
    it(‘has models’, function() {
        expect(this.sections.model.length).toEqual(3);
    });
});
Generate small JSON files
Summary



• Decouple view from model
• Test model programmatically
• Test view through QA
• Test on real devices
• Create a simple build chain
• Generate static content to avoid runtime penalties
THANK YOU
Michael Brooks
COM 12
October 20, 2011

Contenu connexe

Tendances

PhoneGap:你应该知道的12件事
PhoneGap:你应该知道的12件事PhoneGap:你应该知道的12件事
PhoneGap:你应该知道的12件事longfei.dong
 
Writing java script for Csharp's Blazor
Writing java script for Csharp's BlazorWriting java script for Csharp's Blazor
Writing java script for Csharp's BlazorEd Charbeneau
 
Application Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server TracingApplication Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server TracingZendCon
 
The Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web appsThe Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web appsJohn Anderson
 
Magento - a Zend Framework Application
Magento - a Zend Framework ApplicationMagento - a Zend Framework Application
Magento - a Zend Framework ApplicationZendCon
 
Dive into Play Framework
Dive into Play FrameworkDive into Play Framework
Dive into Play FrameworkMaher Gamal
 
REST to JavaScript for Better Client-side Development
REST to JavaScript for Better Client-side DevelopmentREST to JavaScript for Better Client-side Development
REST to JavaScript for Better Client-side DevelopmentHyunghun Cho
 
Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4성일 한
 
The Magic of Advanced Debugging
The Magic of Advanced DebuggingThe Magic of Advanced Debugging
The Magic of Advanced DebuggingIvelina Dimova
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play NiceAlex Gaynor
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
 
From Hacker to Programmer (w/ Webpack, Babel and React)
From Hacker to Programmer (w/ Webpack, Babel and React)From Hacker to Programmer (w/ Webpack, Babel and React)
From Hacker to Programmer (w/ Webpack, Babel and React)Joseph Chiang
 
Игорь Фесенко "Web Apps Performance & JavaScript Compilers"
Игорь Фесенко "Web Apps Performance & JavaScript Compilers"Игорь Фесенко "Web Apps Performance & JavaScript Compilers"
Игорь Фесенко "Web Apps Performance & JavaScript Compilers"Fwdays
 
RESTful API in teamkube
RESTful API in teamkubeRESTful API in teamkube
RESTful API in teamkubefinion
 
JQuery UK Service Workers Talk
JQuery UK Service Workers TalkJQuery UK Service Workers Talk
JQuery UK Service Workers TalkNatasha Rooney
 
JQuery UK February 2015: Service Workers On Vacay
JQuery UK February 2015: Service Workers On VacayJQuery UK February 2015: Service Workers On Vacay
JQuery UK February 2015: Service Workers On VacayNatasha Rooney
 
Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2A.K.M. Ahsrafuzzaman
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Eric Palakovich Carr
 

Tendances (20)

PhoneGap:你应该知道的12件事
PhoneGap:你应该知道的12件事PhoneGap:你应该知道的12件事
PhoneGap:你应该知道的12件事
 
Thomas Fuchs Presentation
Thomas Fuchs PresentationThomas Fuchs Presentation
Thomas Fuchs Presentation
 
React Native
React NativeReact Native
React Native
 
Writing java script for Csharp's Blazor
Writing java script for Csharp's BlazorWriting java script for Csharp's Blazor
Writing java script for Csharp's Blazor
 
Application Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server TracingApplication Diagnosis with Zend Server Tracing
Application Diagnosis with Zend Server Tracing
 
The Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web appsThe Peanut Butter Cup of Web-dev: Plack and single page web apps
The Peanut Butter Cup of Web-dev: Plack and single page web apps
 
Magento - a Zend Framework Application
Magento - a Zend Framework ApplicationMagento - a Zend Framework Application
Magento - a Zend Framework Application
 
Dive into Play Framework
Dive into Play FrameworkDive into Play Framework
Dive into Play Framework
 
REST to JavaScript for Better Client-side Development
REST to JavaScript for Better Client-side DevelopmentREST to JavaScript for Better Client-side Development
REST to JavaScript for Better Client-side Development
 
Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4Ionic으로 모바일앱 만들기 #4
Ionic으로 모바일앱 만들기 #4
 
The Magic of Advanced Debugging
The Magic of Advanced DebuggingThe Magic of Advanced Debugging
The Magic of Advanced Debugging
 
Making Django and NoSQL Play Nice
Making Django and NoSQL Play NiceMaking Django and NoSQL Play Nice
Making Django and NoSQL Play Nice
 
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
 
From Hacker to Programmer (w/ Webpack, Babel and React)
From Hacker to Programmer (w/ Webpack, Babel and React)From Hacker to Programmer (w/ Webpack, Babel and React)
From Hacker to Programmer (w/ Webpack, Babel and React)
 
Игорь Фесенко "Web Apps Performance & JavaScript Compilers"
Игорь Фесенко "Web Apps Performance & JavaScript Compilers"Игорь Фесенко "Web Apps Performance & JavaScript Compilers"
Игорь Фесенко "Web Apps Performance & JavaScript Compilers"
 
RESTful API in teamkube
RESTful API in teamkubeRESTful API in teamkube
RESTful API in teamkube
 
JQuery UK Service Workers Talk
JQuery UK Service Workers TalkJQuery UK Service Workers Talk
JQuery UK Service Workers Talk
 
JQuery UK February 2015: Service Workers On Vacay
JQuery UK February 2015: Service Workers On VacayJQuery UK February 2015: Service Workers On Vacay
JQuery UK February 2015: Service Workers On Vacay
 
Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2Ride on the Fast Track of Web with Ruby on Rails- Part 2
Ride on the Fast Track of Web with Ruby on Rails- Part 2
 
Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!Django Rest Framework and React and Redux, Oh My!
Django Rest Framework and React and Redux, Oh My!
 

En vedette

Dawn of the Devices
Dawn of the DevicesDawn of the Devices
Dawn of the Devicesmwbrooks
 
Your Browser is Your SDK
Your Browser is Your SDKYour Browser is Your SDK
Your Browser is Your SDKmwbrooks
 
PhoneGap Day: How to Architect for Many Screens
PhoneGap Day: How to Architect for Many ScreensPhoneGap Day: How to Architect for Many Screens
PhoneGap Day: How to Architect for Many Screensmwbrooks
 
Hello PhoneGap
Hello PhoneGapHello PhoneGap
Hello PhoneGapmwbrooks
 
ApacheCon 2011
ApacheCon 2011ApacheCon 2011
ApacheCon 2011mwbrooks
 
7 things you should know about mobile
7 things you should know about mobile7 things you should know about mobile
7 things you should know about mobileRoland Tanglao
 

En vedette (6)

Dawn of the Devices
Dawn of the DevicesDawn of the Devices
Dawn of the Devices
 
Your Browser is Your SDK
Your Browser is Your SDKYour Browser is Your SDK
Your Browser is Your SDK
 
PhoneGap Day: How to Architect for Many Screens
PhoneGap Day: How to Architect for Many ScreensPhoneGap Day: How to Architect for Many Screens
PhoneGap Day: How to Architect for Many Screens
 
Hello PhoneGap
Hello PhoneGapHello PhoneGap
Hello PhoneGap
 
ApacheCon 2011
ApacheCon 2011ApacheCon 2011
ApacheCon 2011
 
7 things you should know about mobile
7 things you should know about mobile7 things you should know about mobile
7 things you should know about mobile
 

Similaire à BlackBerry DevCon 2011 - PhoneGap and WebWorks

After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegapyangdj
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaveryangdj
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVCAlive Kuo
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gearsdion
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it meansRobert Nyman
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Filippo Matteo Riggio
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJSAaronius
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps OfflinePedro Morais
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...SPTechCon
 
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)Igor Bronovskyy
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationAbdul Malik Ikhsan
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...Fabio Franzini
 
Django + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoDjango + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoJavier Abadía
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyDavid Padbury
 
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsMeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsSimo Ahava
 
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014John Hann
 

Similaire à BlackBerry DevCon 2011 - PhoneGap and WebWorks (20)

After max+phonegap
After max+phonegapAfter max+phonegap
After max+phonegap
 
混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver混搭移动开发:PhoneGap+JQurey+Dreamweaver
混搭移动开发:PhoneGap+JQurey+Dreamweaver
 
[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC[Coscup 2012] JavascriptMVC
[Coscup 2012] JavascriptMVC
 
DrupalCon jQuery
DrupalCon jQueryDrupalCon jQuery
DrupalCon jQuery
 
Having Fun with Play
Having Fun with PlayHaving Fun with Play
Having Fun with Play
 
Future of Web Apps: Google Gears
Future of Web Apps: Google GearsFuture of Web Apps: Google Gears
Future of Web Apps: Google Gears
 
The Open Web and what it means
The Open Web and what it meansThe Open Web and what it means
The Open Web and what it means
 
Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2Mobile App Development: Primi passi con NativeScript e Angular 2
Mobile App Development: Primi passi con NativeScript e Angular 2
 
Dependency Management with RequireJS
Dependency Management with RequireJSDependency Management with RequireJS
Dependency Management with RequireJS
 
Taking Web Apps Offline
Taking Web Apps OfflineTaking Web Apps Offline
Taking Web Apps Offline
 
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
The Magic Revealed: Four Real-World Examples of Using the Client Object Model...
 
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложенияCodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
CodeFest 2014. Пухальский И. — Отзывчивые кроссплатформенные веб-приложения
 
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
09 - express nodes on the right angle - vitaliy basyuk - it event 2013 (5)
 
Codeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept ImplementationCodeigniter : Two Step View - Concept Implementation
Codeigniter : Two Step View - Concept Implementation
 
Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2Angular Workshop_Sarajevo2
Angular Workshop_Sarajevo2
 
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
 
Django + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar DjangoDjango + Vue, JavaScript de 3ª generación para modernizar Django
Django + Vue, JavaScript de 3ª generación para modernizar Django
 
HTML5 for the Silverlight Guy
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
 
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analystsMeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
MeasureCamp IX (London) - 10 JavaScript Concepts for web analysts
 
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
Zero-config JavaScript apps with RaveJS -- SVCC fall 2014
 

Dernier

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 

Dernier (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 

BlackBerry DevCon 2011 - PhoneGap and WebWorks

  • 1. PhoneGap and BlackBerry WebWorks: Two Allies that Simplified Development of Nursing App Michael Brooks, Nitobi Software COM12 October 20, 2011
  • 2. Michael Brooks @mwbrooks Nitobi Software PhoneGap Core Maintainer
  • 8. PhoneGap is a Web view
  • 9. PhoneGap is a Web view
  • 11. PhoneGap is Cross Platform
  • 14. RNAO Wanted Vendor Store Presence Offline Application
  • 19. Command-line Build $ rake android $ rake desktop $ rake ios $ rake blackberry $ rake blackberry-webworks
  • 21. --- Platform Manifest File blackberry-widget: true destination: platforms/blackberry-widget/www html: - filename: index.html css: - filename: style/index.css - filename: style/blackberry.css javascript: - filename: javascript/app.js other: - filename: style/image/* - filename: platform/blackberry-webworks/* ---
  • 22. Preloaded Database $ rake database => database.json
  • 23. JavaScript Libraries xui JSON2.js ~71kB }
  • 25. PhoneGap Plugins BlackBerry® BlackBerry WebWorks Android™ / iOS URLCache URLCache URLCache Database restore Database restore Database search Database search Database update SplashScreen
  • 26. <!DOCTYPE html> index.html <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" /> <meta name="HandheldFriendly" content="true" /> <title>Nursing Best Practice Guidelines</title> <link href="style/index.min.css" type="text/css" rel="stylesheet" /> </head> <body> <script type="text/template" id="splashscreen-template" class="view"> // ... </script> <script type="text/javascript" src="javascript/index.min.js"></script> </body> </html>
  • 27. UserAgent Sniffing // // Find the current device // @return {{DomString}} 'blackberryX', 'android', 'webkit', 'desktop' // findDevice: function() { var userAgent = navigator.userAgent; if (userAgent.match(/browzr/i)) return 'blackberry4'; if (userAgent.match(/blackberryd*/4..*/i)) return 'blackberry4'; if (userAgent.match(/blackberryd*/5..*/i)) return 'blackberry5'; if (userAgent.match(/android/i)) return 'android'; if (userAgent.match(/blackberryd*/6..*/i)) return 'webkit'; if (userAgent.match(/webkit/i)) return 'webkit'; return 'desktop'; }
  • 28. // // Preload Images Preloading Images // // The images are preloaded into the DOM and then removed. // // @param {DOMString} imgSources is an array of image URLs to preload // Application.help.preloadImages = function(imgSources, callback) { var img = null; var preloadNextImage = function() { if (img !== null) delete img; if (imgSources.length <= 0) { Application.dispatch(callback); return; } img = new Image(); img.onload = preloadNextImage; img.src = imgSources.pop(); } preloadNextImage(); };
  • 29. External Link Quirks // BlackBerry child browser if (Application.supports.browser.widget) { blackberry.invoke.invoke( blackberry.invoke.APP_BROWSER, new blackberry.invoke.BrowserArguments(href) ); } // Android child browser else if (Application.supports.browser.android) { window.android.loadExternalUrl(href); } // Everyone else else { document.location = href; }
  • 30. // @blackberry4 workaround for render issues that display a white // block that proportional in height to the amount scrolled vertically. if (!Application.is('blackberry4')) { x$(element).addClass('selected'); Page Target Quirks } hash = hash[0].replace('#', ''); if (hash !== '') { if (Application.events[hash]) { Application.trigger(hash, element); } else if (Application.is('android') || Application.is('blackberry4')) { document.location.hash = '#' + hash; } else { var $element = x$('a[name=' + hash + ']'); $element = ($element.length > 0) ? $element : x$('#' + hash); if ($element.length > 0) { $element[0].scrollIntoView(true); } } }
  • 31. Ellipsis Support // // Ellipsis Support // // @param {DOMElement} DOM element to apply ellipsis to // Application.help.ellipsis = function(element) { if (Application.supports.ellipsis) return; // ... manually create ellipsis }; // ... Application.supports.ellipsis = (typeof e.style.textOverflow !== 'undefined');
  • 32. // Feature Detection // Detect Browser Features // Application.help.detectFeatures = function() { Application.supports = { browser: { widget: !!(typeof window.blackberry !== 'undefined' && window.blackberry.invoke), android: !!(typeof window.android !== 'undefined' && window.android.loadExternalUrl) }, splashScreen: { hide: !!(window.plugins && window.plugins.splashScreen && window.plugins.splashScreen.hide) }, store: { backup: !!(window.plugins && window.plugins.store && window.plugins.store.backup), restore: !!(window.plugins && window.plugins.store && window.plugins.store.restore), search: !!(window.plugins && window.plugins.store && window.plugins.store.search) } }; };
  • 33. Feature Detection if (Application.supports.database.sqliteGears) { // ... } else if (Application.supports.file.reader && Application.supports.database.sqlite) { // ... } else if (Application.supports.store.restore) { // ... }
  • 34. // // Search records using the PhoneGap plugin or JavaScript Feature Detection // if (Application.supports.store.search) { window.plugins.store.search(query, function(response) { jsonResponse.data = response.message.data; jsonResponse.error = response.message.error; renderResults(); }); } else { Application.database.all(function(records) { for(var i = 0; i < records.length; i++) { matchRecord(records[i]); } renderResults(); }); }
  • 35. Application.help.getStoragePath = function() { var storagePath = ''; PhoneGap File API Quirks if (typeof navigator !== 'undefined' && navigator.fileMgr) { var rootPaths = navigator.fileMgr.getRootPaths(); for (var i = 0; i < rootPaths.length; i++) { // iOS workaround. For some reason it returns an invalid path on the simulator. if (rootPaths[i].match(/document/i)) { storagePath = './../Documents/'; break; } // BlackBerry / Android else if (rootPaths[i].match(/sdcard/i)) { storagePath = rootPaths[i]; break; } } } return storagePath; };
  • 36. Performance // // Dispatch a function asynchronously // // This will push the process onto a new // execution stack and allocate a new memory // heap. This is very useful for BlackBerry5, // which runs into memory issues on deep // callback stacks. It is important to understand // that dispatch will only fire after the current // execution thread ends. // // @param {Function} function to dispatch. Accepts no args. // dispatch: function(fn) { setTimeout(fn, 10); }
  • 37. What would we do different?
  • 40. Use Jasmine BDD describe(‘Guidelines’, function() { it(‘has preloaded content’, function() { expect(this.guideline.get('sections').length).toEqual(2); }); }); describe(‘Sections’, function() { it(‘has models’, function() { expect(this.sections.model.length).toEqual(3); }); });
  • 42. Summary • Decouple view from model • Test model programmatically • Test view through QA • Test on real devices • Create a simple build chain • Generate static content to avoid runtime penalties
  • 43. THANK YOU Michael Brooks COM 12 October 20, 2011

Notes de l'éditeur

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n