Presentations can access some of HTML Presenter's functions through its Javascript API, introduced in version 1.2.
This page is for developers who may want to access these advanced features using Javascript.
The API is provided using Apache Cordova so to use it, you'll need to include and reference cordova-2.2.0.js like in the Cordova documentation.
Here is a short example:
<script charset="utf-8" src="cordova-2.2.0.js"></script>
<script>
document.addEventListener("deviceready", function () {
alert("Your device, " + device.name +
", is running " + device.platform +
" version " + device.version);
}, false);
</script>
<a href="#" onclick="cordova.exec('HtmlPresenter.showMenu');">Show menu</a>
See the Cordova documentation for full details. Many more features are provided through Cordova. Only features specific to HTML Presenter are listed below.
Start synchronizing (unless already synchronizing).
cordova.exec("HtmlPresenter.sync");
Show the toolbar.
cordova.exec("HtmlPresenter.showMenu");
Load another iPad app, e.g. Mail, Safari, Maps, Youtube, Twitter
cordova.exec("HtmlPresenter.loadApp", "mailto:fred@example.com") // Mail
cordova.exec("HtmlPresenter.loadApp", "http://example.com/") // Safari
Change the behaviour of the Web View the presentation is loaded in.
Accepts two parameters: bounce
and zoom
, respectively. Both must be
either true or false according to how you want to set each of these
features.
cordova.exec("HtmlPresenter.webViewOpts", true, false); // Bounce on, Zoom off, like in Presenter 1.1
cordova.exec("HtmlPresenter.webViewOpts", false, false); // Bounce and Zoom off, default in Presenter 1.2
Self-destruct the current presentation by deleting it from the iPad and from the synchronization server. Be careful with this one!
cordova.exec("HtmlPresenter.deletePresentation");
Open another, named presentation.
cordova.exec("HtmlPresenter.showPresentation", "Intro to Presenter");
Get the HTML Presenter version.
cordova.exec( function(ver) { console.log(ver); },
function(err) { console.log(err); }, "HtmlPresenter", "getVersion");
This Javascript snippet will provide an HtmlPresenter object which will allow you to use a shorter way of calling the HTML Presenter Javascript API, as simply as this:
HtmlPresenter.sync();
Here is the code:
<script charset="utf-8" src="cordova-2.2.0.js"></script>
<script>
// HTML Presenter Javascript API Shortcuts
HtmlPresenter = {
sync: function() { cordova.exec("HtmlPresenter.sync"); },
showMenu: function() { cordova.exec("HtmlPresenter.showMenu"); },
loadApp: function(uri) { cordova.exec("HtmlPresenter.loadApp", uri); },
webViewOpts: function(bounce, zoom) {
cordova.exec("HtmlPresenter.webViewOpts", bounce, zoom); },
deletePresentation: function() {
cordova.exec("HtmlPresenter.deletePresentation"); },
showPresentation: function(presentationName) {
cordova.exec("HtmlPresenter.showPresentation", presentationName); },
getVersion: function(callback) { cordova.exec(callback,
function(err){console.log(err)}, "HtmlPresenter", "getVersion");
};