-
Notifications
You must be signed in to change notification settings - Fork 0
/
presenter.js
55 lines (54 loc) · 2.02 KB
/
presenter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
function toggleNotesMode(){
console.log("toggleNotesMode");
var notesDiv = document.getElementById("notes");
if (notesDiv.style.display == "block"){
notesDiv.style.display = "none";
} else {
notesDiv.style.display = "block";
}
}
function setTitleAndNotes(title, notes,page,pages){
console.log("setTitleAndNotes: " + title + ", "+ notes);
document.getElementById("notesTitle").innerHTML = (title ? title : "");
document.getElementById("notesContent").innerHTML = (notes ? notes : "");
document.getElementById("pagecounter").innerHTML = page + "/" + pages;
}
function setUrlState(slideIdx,title){
console.log("setUrlState: " + slideIdx)
history.pushState({page:slideIdx},"Slide " + slideIdx,"#" + slideIdx);
document.title = title;
}
function getUrlSlideIdx(){
console.log("location hash: " + location.hash);
if ( location.hash.indexOf("#") == 0){
return parseInt(location.hash.substring(1));
} else {
return 0;
}
}
var popStateListener = function () {
console.log("popStateListener");
//var svgDoc = document.getElementById("presentation-2").getSVGDocument();
//var svgRoot = svgDoc.documentElement;
//console.log("svg doc: " + svgDoc + ", " + svgRoot);
if (location.hash.length > 1){
var slideIdx = parseInt(location.hash.substring(1));
try{
presentation.showSlide(slideIdx);
} catch(e){}
//console.log("history length: " + window.history.length);
//console.log("current state: " + window.history.state.page);
}
console.log("done on hash change");
}
var onLoadListener = function(){
window.addEventListener("popstate",popStateListener,false);
// document.addEventListener('touchstart', function(evt) {evt.preventDefault();}, false);
// document.addEventListener('touchmove', function(evt) {evt.preventDefault();}, false);
// document.getElementById("presentation-2").getSVGDocument().documentElement.focus();
};
console.log("window: "+window);
console.log("window.onload: " + window.onload);
//window.onload(onLoadListener);
//window.onEventListener("load",window,function(){console.log("hi there!");});
onLoadListener();