-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplay.html
130 lines (118 loc) · 3.99 KB
/
play.html
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="js/jquery-2.0.0.min.js"></script>
<script src="js/jquery.object-fit.min.js"></script>
<script>
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
var i;
var config = [];
var timeout;
$(document).ready(function(){
$("body").keydown(function(e){
refreshConfig();
if(e.keyCode == 39){
clearTimeout(timeout);
i = (i) % config.length;
slide(i);
}else if(e.keyCode == 37){
clearTimeout(timeout);
i = (i - 2) % config.length;
if(i<0){
i = config.length-i;
}
slide(i);
}else if(e.keyCode == 70){
fullscreen();
}
});
fullscreen();
i=0;
slide(0);
});
function fullscreen(){
$("#main")[0].mozRequestFullScreen();
}
function set_timeout(time){
if(config && config.length > i){
if(time > 0){
timeout = setTimeout("slide(i)",time*1000);
}else{
timeout = setTimeout("slide(i)",5000);
}
}
else{
i = 0;
timeout = setTimeout("slide(0)",500);
}
}
function slide(number){
refreshConfig();
if(config && config.length > number){
var href = config[number].href;
document.title=i;
if(href.endsWith(".html")){
$('#main').load(href);
}
else if(href.endsWith(".png") || href.endsWith(".jpg")|| href.endsWith(".gif"))
{
$('#main').html("<div style ='margin:auto; text-align:center; height:inherit'><img style='height:100%; width:100%;'"+
" src=\""+href+"\"></img></div>");
$('#main img').objectFit({type: 'contain', hideOverflow: true});
$('#main').css('background-color','#000');
}
else
{
$('#main').html("<iframe width=\"100%\" height=\"100%\" src=\""+href+"#toolbar=0&navpanes=0&scrollbar=0\"></iframe>");
}
var time = config[i].time;
i = (i + 1) % config.length;
set_timeout(time);
}
else{
set_timeout(500);
}
}
function refreshConfig(){
json_config = localStorage.config;
if(json_config){
config = JSON.parse(json_config);
}else{
config = [];
}
if(i > config.length ){
i = config.length-1;
}
}
</script>
<style>
body {
font-size: 2em;
font-family: sans;
background:#444;
}
#main {
background: white;
color:black;
width:800px;
height:600px;
margin: auto;
/*padding: 1em;*/
padding 0em;
box-shadow: 0 0 1em black;
}
</style>
</head>
<body>
<div id="main">
<h2>InfoBeamer</h2>
<p>No slides found<p>
</div>
<div>
<button onclick="fullscreen();">Fullscreen</button>
</div>
</body>
</html>