collect_notes: function () {
var notes = new Array();
var divs = document.body.getElementsByTagName("div");
for (var i = 0; i < divs.length; ++i)
{
div = divs.item(i);
if (this.has_class(div, "handout"))
{
// add note to collection
notes[notes.length] = div;
// and hide it
this.add_class(div, "hidden");
}
}
this.notes = notes;
},
// return new array of all
// including named backgrounds e.g. class="background titlepage"
collect_backgrounds: function () {
var backgrounds = new Array();
var divs = document.body.getElementsByTagName("div");
for (var i = 0; i < divs.length; ++i)
{
div = divs.item(i);
if (this.has_class(div, "background"))
{
// add background to collection
backgrounds[backgrounds.length] = div;
// and hide it
this.add_class(div, "hidden");
}
}
this.backgrounds = backgrounds;
},
// set click handlers on all anchors
patch_anchors: function () {
var self = w3c_slidy;
var handler = function (event) {
// compare this.href with location.href
// for link to another slide in this doc
if (self.page_address(this.href) == self.page_address(location.href))
{
// yes, so find new slide number
var newslidenum = self.find_slide_number(this.href);
if (newslidenum != self.slide_number)
{
var slide = self.slides[self.slide_number];
self.hide_slide(slide);
self.slide_number = newslidenum;
slide = self.slides[self.slide_number];
self.show_slide(slide);
self.set_location();
}
}
else if (this.target == null)
location.href = this.href;
this.blur();
self.disable_slide_click = true;
};
var anchors = document.body.getElementsByTagName("a");
for (var i = 0; i < anchors.length; ++i)
{
if (window.addEventListener)
anchors[i].addEventListener("click", handler, false);
else
anchors[i].attachEvent("onclick", handler);
}
},
// ### CHECK ME ### see which functions are invoked via setTimeout
// either directly or indirectly for use of w3c_slidy vs this
show_slide_number: function () {
var timer = w3c_slidy.get_timer();
w3c_slidy.slide_number_element.innerHTML = timer + "slide".localize() + " " +
(w3c_slidy.slide_number + 1) + "/" + w3c_slidy.slides.length;
},
// every 200mS check if the location has been changed as a
// result of the user activating the Back button/menu item
// doesn't work for Opera < 9.5
check_location: function () {
var hash = location.hash;
if (w3c_slidy.slide_number > 0 && (hash == "" || hash == "#"))
w3c_slidy.goto_slide(0);
else if (hash.length > 2 && hash != "#("+(w3c_slidy.slide_number+1)+")")
{
var num = parseInt(location.hash.substr(2));
if (!isNaN(num))
w3c_slidy.goto_slide(num-1);
}
if (w3c_slidy.time_left && w3c_slidy.slide_number > 0)
{
w3c_slidy.show_slide_number();
if (w3c_slidy.time_left > 0)
w3c_slidy.time_left -= 200;
}
},
get_timer: function () {
var timer = "";
if (w3c_slidy.time_left)
{
var mins, secs;
secs = Math.floor(w3c_slidy.time_left/1000);
mins = Math.floor(secs / 60);
secs = secs % 60;
timer = (mins ? mins+"m" : "") + secs + "s ";
}
return timer;
},
// this doesn't push location onto history stack for IE
// for which a hidden iframe hack is needed: load page into
// the iframe with script that set's parent's location.hash
// but that won't work for standalone use unless we can
// create the page dynamically via a javascript: URL
set_location: function () {
var uri = w3c_slidy.page_address(location.href);
var hash = "#(" + (w3c_slidy.slide_number+1) + ")";
if (w3c_slidy.slide_number >= 0)
uri = uri + hash;
if (w3c_slidy.ie && !w3c_slidy.ie8)
w3c_slidy.push_hash(hash);
if (uri != location.href) // && !khtml
location.href = uri;
if (this.khtml)
hash = "(" + (w3c_slidy.slide_number+1) + ")";
if (!this.ie && location.hash != hash && location.hash != "")
location.hash = hash;
document.title = w3c_slidy.title + " (" + (w3c_slidy.slide_number+1) + ")";
w3c_slidy.show_slide_number();
},
page_address: function (uri) {
var i = uri.indexOf("#");
if (i < 0)
i = uri.indexOf("%23");
// check if anchor is entire page
if (i < 0)
return uri; // yes
return uri.substr(0, i);
},
// only used for IE6 and IE7
on_frame_loaded: function (hash) {
location.hash = hash;
var uri = w3c_slidy.page_address(location.href);
location.href = uri + hash;
},
// history hack with thanks to Bertrand Le Roy
push_hash: function (hash) {
if (hash == "") hash = "#(1)";
window.location.hash = hash;
var doc = document.getElementById("historyFrame").contentWindow.document;
doc.open("javascript:''");
// PWL modified this string literal to break the close script tag
// which otherwise gets parsed when incorporated
doc.write("