Speed Dial API

By Opera Software

From Opera 15 onward, Opera 11 & 12’s extension format is no longer supported, and instead, we’ve switched to Chromium’s extension model. Check out our new documentation for developing extensions for Opera 15 and higher and start building your own extensions.

viewmodes attribute
Indicates whether the extension should be run in a minimized state.
feature element
A feature request by the extension to have its content displayed in a Speed Dial cell.
param element
The feature element's parameter that specifies its URL.
opera.contexts.speeddial.title
Represents the human-readable title given to a Speed Dial cell.
opera.contexts.speeddial.url
Represents the target URL of the Speed Dial cell when clicked or otherwise activated.

Overview

The Speed Dial page is the "start page" that is displayed every time you open a new tab in Opera.

In order to have the content of an Opera extension be displayed in a Speed Dial cell, a developer declares in the configuration document (config.xml) of an extension what content they would like to have displayed. As shown in the example below, this is done by using a combination of a feature request, called opera:speeddial, and by declaring support for the minimized view mode. In addition, a valid URI must be specified in the widget element's id attribute. While this should be provided for all extensions, it is a requirement for Speed Dial extensions.

For compatibility with Opera Link's synchronization of Speed Dial, and to not break the Speed Dial user experience, a developer is required to provide an URL as part of the Speed Dial feature request (via a param element, as shown).

Valid Speed Dial extensions can use the SpeedDialContext API which is available as an opera.contexts.speeddial object in the background process (but not in other documents inside the extension). The SpeedDialContext API enables developers to read and change the title and URL of a Speed Dial cell. Developers should, however, make provisions in their scripts to make sure the extension still functions without the availability of the SpeedDialContext API by checking for the presence of the API and dealing with it if it's not available. An example of how to use the SpeedDialContext API is given below.

Example

Sample config.xml file for a Speed Dial extension.


<!-- config.xml -->
<widget
    xmlns="http://www.w3.org/ns/widgets"
    id="http://example.com/myextension"
    defaultlocale="en"
    viewmodes="minimized">

  <content src="weather.html"/>

  <name short="Weather">
    The Weather In Oslo
  </name>

  <description>
    Speed Dial extension showing the current weather in Oslo.
  </description>

  <feature name="opera:speeddial" required="false">
  <!-- Link to open when the Speed Dial is clicked -->
    <param name="url" value="http://opera.com"/>
  </feature>
</widget>

The background process JavaScript for the above sample extension, using the SpeedDialContext API.

//
// The background process ('/background.js').
//

document.onload = function getWeather() {
  var xhr = new XMLHttpRequest();
  //... load weather info...
}

//Displays weather information in Speed Dial
//and update UI Item
function updateWeather(weatherInfo) {
  if (opera.contexts.speeddial) {
    var sd = opera.contexts.speeddial;
    var location = weatherInfo.location;

    // Change the Speed Dial's title
    sd.title = location + " " + weatherInfo.forecast;

    // Change the Speed Dial's URL
    sd.url = "http://weather.com/" + location;
  }
}

This article is licensed under a Creative Commons Attribution 3.0 Unported license.

Comments

No new comments accepted.