Skip to content

Instantly share code, notes, and snippets.

@bmatzelle
Created August 23, 2009 15:54
Show Gist options
  • Save bmatzelle/173337 to your computer and use it in GitHub Desktop.
Save bmatzelle/173337 to your computer and use it in GitHub Desktop.
Vuzit on page changed example
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Vuzit On Page Changed Example</title>
<link href="http://vuzit.com/stylesheets/Vuzit-2.7.css" rel="Stylesheet" type="text/css" />
<script src="http://vuzit.com/javascripts/Vuzit-2.7.js" type="text/javascript"></script>
<script type="text/javascript">
var lastPage = 1;
var viewer = null;
var checkInterval = 500; // Check every half second
// Call-back for when the viewer page changes.
function onPageChanged() {
var newNumber = viewer.getPageNumber();
if(newNumber != -1 && lastPage != newNumber) {
// TODO: Put your page change event code here.
document.getElementById("page_number").innerHTML = newNumber;
lastPage = newNumber;
}
var page = setTimeout(onPageChanged, checkInterval);
}
// Called when the page is loaded.
function initialize() {
// Add your public key and the document ID below
vuzit.Base.apiKeySet("b12c30a5-77aa-ef5f-9b4f-b83a4f88149e");
viewer = vuzit.Viewer.fromId("1dix", {});
viewer.display(document.getElementById("vuzit_viewer"), { zoom: 1, page: lastPage });
// Starts off the process checking event code
var page = setTimeout(onPageChanged, checkInterval);
}
</script>
</head>
<body onload="initialize()">
<div id="vuzit_viewer" style="width: 650px; height: 500px;"></div>
<p>
Current page is: <span id="page_number">1</span>
</p>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment