GithubHelp home page GithubHelp logo

jgibbons / blackberry.polarmobile.childbrowser Goto Github PK

View Code? Open in Web Editor NEW

This project forked from polarmobile/blackberry.polarmobile.childbrowser

0.0 1.0 0.0 146 KB

ChildBrowser Extension for BlackBerry WebWorks Tablet SDK

License: MIT License

ActionScript 69.78% JavaScript 30.22%

blackberry.polarmobile.childbrowser's Introduction

blackberry.polarmobile.childbrowser

This extension for the BlackBerry WebWorks SDK for Tablet OS provides a "child browser" mechanism for displaying external webpages within WebWorks applications.

Webpages hosted within this child browser run within a WebKit instance that is completely isolated and independent from the WebKit instance being used to host your core WebWorks app.

Installation

Clone this repository into a folder called blackberry.polarmobile.childbrowser/ within the bbwp/ext/ folder of your WebWorks SDK installation.

Compatibility

This extension has been tested with the BlackBerry WebWorks SDK for TabletOS v2.1.0.6.

Usage

Configuration

In the config.xml file of your WebWorks app, include the following feature element:

<feature id="blackberry.polarmobile.childbrowser" />

Code Sample

var browser = blackberry.polarmobile.childbrowser;

// view http://polarmobile.com
browser.loadURL("http://polarmobile.com");

// get the URL of the browser's current location
browser.getLocation();

// refresh the current page
browser.refresh();

// clear all cookies
browser.clearCookies();

// automatically close the browser in 10 seconds from now
setTimeout(function(){ browser.close(); }, 10000);

Basic Async Code Sample

var browser = blackberry.polarmobile.childbrowser;
var url = "http://twitter.com/gogibbons";
browser.loadURLAsync(
    url,
    function (result)
    {
        console.log("The current url is: " + result.data);
    },
    function ()
    {
        console.log("The browser has been closed");
    });

Async Code Sample Showing How To Obtain Facebook Credentials

var browser = blackberry.polarmobile.childbrowser;
var appID = "<insert numeric app ID here>";
var redirect = "https://www.facebook.com/connect/login_success.html";

var path = 'https://www.facebook.com/dialog/oauth?display=wap&scope=publish_actions,read_stream&';
var queryParams = ['client_id=' + appID, 'redirect_uri=' + redirect, 'response_type=token'];
var query = queryParams.join('&');
var url = path + query;
var browserIsOpen = true;
browser.loadURLAsync(
    url,  // URL to open in browser
    function (result){
        var url = result.data;
        if (url.substring(0, redirect.length) == redirect)
        {
            var fbAccessToken = url.match(/access_token=([^&]+)/)[1];
            localStorage.setItem('fbAccessToken', fbAccessToken);
            browserIsOpen = false;
            browser.close();
            browser.clearCookies();
            alert("You authenticated with Facebook");
        }
    },
    function ()
    {
        if (browserIsOpen)
        {
            alert("You closed the browser before we authenticated you!");
        }
    });

Known Issues/ TODO

  • "back" and "forward" not functional
  • "pause" button
  • button to re-launch current web page in dedicated browser app

Acknowledgements

License

The source code for this project is distributed under the MIT license. See LICENSE for details.

blackberry.polarmobile.childbrowser's People

Contributors

mjrusso avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.