Docs

API Reference

The following is an API reference for the pokki namespace object which is accessible in JavaScript from both the popup and background pages.

pokki.addContextMenuItem

pokki.addContextMenuItem(text, identifier);

Parameters

Name Type Description
text String Textual string to display to users in the context menu item.
identifier String Internal identifier used when listening for context_menu event.

Description

Adds a menu item to your app's context menu during run-time; to learn more about adding items to the context menu read Context menu .

Supported in Pokki: All

pokki.addEventListener

pokki.addEventListener('event_name', function);

Parameters

Name Type Description
event_name String The event to listen for.
function Function A function or the name of a function to call when the event is fired.

Description

Register an event listener for a Pokki event. Supported events:

  1. context_menu - Fires when the user selects a developer defined item in the context menu; passes the identifier associated with that menu item
  2. hidden - Fires after the hiding event, once the app window is not visible
  3. hiding - Fires as the minimizes due to a user action (minimize and close) or pokki.hide being called
  4. link – Fires when the URL of the window is changed or a new window tries to be opened from the popup; passes the URL trying to be opened, and ignores the request
  5. showing - Fires when the user clicks on your app’s icon and the app window animates in
  6. shown - Fires after the showing event, once the app window is done animating in
  7. unload – Fires four seconds before the app and both it's pages are unloaded by Pokki
  8. work_area_change - Fires when the work area changes due to a user changing their display resolution
  9. fullscreen - Fires when user presses the full-screen button in the window title bar

Supported in Pokki: All

pokki.clearWebSheetCookies

pokki.clearWebSheetCookies();

Description

Clears cookies and local storage associated with web sheets used in your app.

Supported in Pokki: All

pokki.hide

pokki.hide();

Description

Minimizes the app window if it’s currently shown; may only be called from the window page.

Supported in Pokki: 0.251

pokki.descramble

pokki.descramble(scrambled_data);

Parameters

Name Type Description
scrambled_data String Scrambled data.

Returns

Type Description
Object Original, descrambled version of the data.

Description

Used to descramble data.

Supported in Pokki: All

pokki.getScrambled

pokki.getScrambled(key);

Parameters

Name Type Description
key String The scrambled data key defined in your app’s manifest.

Returns

Type Description
Object The descrambled data associated with the specified key.

Description

Retrieves and descrambles data from your app’s manifest file. The data is identified with a key. If your app is being developed locally and isn't yet packaged – meaning your data isn’t scrambled – this function continues to work as expected.

To learn more about the usage of scrambled data in your manifest read Obfuscating data.

Supported in Pokki: All

pokki.getWorkAreaSize

pokki.getWorkAreaSize();

Returns

Type Description
Object An object that contains the width and height of the available work area.

Description

Returns an object with the dimensions of the available work area. The work area is the maximum portion of the screen that a popup window may use. This object contains two properties; width and height specified in pixels.

Supported in Pokki: 0.236

pokki.hideWebSheet

pokki.hideWebSheet();

Description

Closes any open web sheet displayed in the popup window.

Supported in Pokki: All

pokki.isShown

pokki.isShown();

Returns

Type Description
Boolean True if the app window is currently visible, false if it isn't.

Description

Used to query whether or not the app window is currently visible.

Supported in Pokki: 0.251

pokki.show

pokki.show();

Description

Opens the app window; may only be called within 5 seconds of the context_menu event firing.

Supported in Pokki: 0.251

pokki.openURLInDefaultBrowser

pokki.openURLInDefaultBrowser(url);

Parameters

Name Type Description
url String The URL to open in the user’s preferred web browser.

Description

Opens the user's preferred web browser to the specified URL.

Supported in Pokki: All

pokki.removeIconBadge

pokki.removeIconBadge();

Description

Removes the badge displayed on your app's icon in the taskbar.

Supported in Pokki: All

pokki.resetContextMenu

pokki.resetContextMenu();

Description

Removes context menu items that were defined in the manifest file or added during run-time. To learn more about the context menu read Context menu .

Supported in Pokki: All

pokki.rpc

pokki.rpc(javascript_string);

Parameters

Name Type Description
javascript_string String A string containing JavaScript commands to run in the context of the opposing page. May include one or many JavaScript instructions as long as they are valid when evaluated in the opposing page's context.

Returns

Type Description
Any primitive type The result of the evaluated JavaScript string in the opposing page's context. Supported data types are limited to primitives (number, boolean, string, null, undefined). Complex types (e.g. Objects) cannot be returned. Null is returned if an error occurs.

Description

Runs the specified JavaScript string in the opposing page's context; if called from the popup page, the specified JavaScript is evaluated in the background page and vice versa. Forwards the return value as long as it is not a complex type (e.g. Object), otherwise returning null. If the evaluated JavaScript results in an error null is returned.

Read more about Communication between pages .

Supported in Pokki: All

pokki.rpcArgs

pokki.rpcArgs(function_string, optional args...);

Parameters

Name Type Description
function_string String Name of a function to evaluate in the opposing page’s context.
args Any Optional argument(s) to pass to the function when evaluated.

Returns

Type Description
Any primitive type The result of the evaluated JavaScript function in the opposing page's context. Supported data types are limited to primitives (number, boolean, string, null, undefined). Complex types (e.g. Objects) cannot be returned. Null is returned if an error occurs.

Description

Runs the specified JavaScript function in the opposing page's context with any args specified passed to it; if called from the popup page, the specified JavaScript is evaluated in the background page and vice versa. Forwards the return value as long as it is not a complex type (e.g. Object), otherwise returning null. If the evaluated JavaScript results in an error null is returned.

Read more about Communication between pages .

Supported in Pokki: All

pokki.scramble

pokki.scramble(data);

Parameters

Name Type Description
data Object An arbitrary (noncyclic) complex JavaScript object to obfuscate.

Returns
Type Description
String An obfuscated version of the data.

Description

Used to obfuscate sensitive data during run-time. The obfuscation is linked to your app, meaning that your app can only descramble data it has scrambled.

To learn more about scrambling read Obfuscating data .

Supported in Pokki: All

pokki.setIconBadge

pokki.setIconBadge(number);

Parameters

Name Type Description
number Number The number to display in your app’s badge.

Description

Sets the number inset in your app's badge on the top-right of the icon. Updates the badge number if it’s currently visible or causes the badge to display.

Supported in Pokki: All

pokki.setWindowFeature

pokki.setWindowFeature(feature, value);

Parameters

Name Type Description
feature String The name of the feature being modified.
value Object Data type and value specific to feature.

Description

Used to configure window features on a per app basis. The following features are supported:

  1. fullscreen - Pass true if the app currently supports full-screen, or false to specify it can not. May be called multiple times throughout the app's runtime.
  2. aspect - Pass a decimal to specify the aspect ratio to which the window is locked while the user resizes.

Supported in Pokki: 0.251

pokki.showWebSheet

pokki.showWebSheet(url, width, height, loading_callback, error_callback);

Parameters

Name Type Description
url String Initial URL to open in the web sheet.
width Number Web sheet's width in pixels.
height Number Web sheet's height in pixels.
loading_callback Function Either a function or function name to call when the URL of the web sheet changes but before the URL is loaded and displayed. This function is passed the URL being loaded as a parameter.
error_callback Function Either a function or function name to call when an error occurs loading a page in the web sheet.

Description

A web sheet is a chromeless browser embedded in the popup that is intended to be used with OAuth and similar protocols for authentication. The popup window is temporarily resized to fit the specified width and height, and will restore its original dimensions when the web sheet is hidden. The web sheet will be displayed once the initial page is loaded as specified by the url parameter.

When the web sheet loads a page, due to the initial page load, a redirect or a user interaction, the loading_callback function is called. The URL of the page being loaded is passed to this callback as a string parameter. This callback function will block the display of the page until it returns true. If the callback function returns false the page is not displayed. This provides an opportunity to capture web pages that may be better suited for display in a web browser or to pull an OAuth access token from a URL. To close the web sheet at any time use pokki.hideWebSheet.

The error_callback function is called if any error is encountered loading a page. The specific error is passed as a number parameter to this function. To see a list of all errors available please read http://src.chromium.org/svn/trunk/src/net/base/net_error_list.h . The web sheet automatically closes when an error occurs.

To learn more about the usage of web sheets please read Web sheets .

Supported in Pokki: All