-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.html
195 lines (167 loc) · 6.16 KB
/
config.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<!DOCTYPE html>
<html>
<head>
<script src="js/jquery-2.0.0.min.js"></script>
<script src="js/jquery-ui-1.10.3/ui/jquery-ui.js"></script>
<script>
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
var slides = [];
var config = [];
$(document).ready(function(){
var ls = localStorage.config;
if(ls){
config = JSON.parse(ls);
updateTable();
}
$('#play').click(function(){
generateConfig();
window.open("./play.html");
})
$("#save").click(function(){
generateConfig();
});
$("#add").click(function(){
slides = $("#myfiles")[0].files;
for(var i = 0; i<slides.length;i++){
addToConfig(i);
}
});
$('#save_as').click(function(){
generateConfig();
uriContent = "data:application/octet-stream," +
encodeURIComponent(JSON.stringify(config));
window.open(uriContent,"InfoBeamer.config");
});
$('body').bind('dragenter',function(e){
e.stopPropagation();
e.preventDefault();
});
$('body').bind('dragover',function(e){
e.stopPropagation();
e.preventDefault();
});
$('body').bind('dragexit',function(e){
e.stopPropagation();
e.preventDefault();
});
function loadDrawing(e){
config = JSON.parse(e.target.result);
updateTable();
}
$('body').bind('drop',function(e){
e = e.originalEvent;
e.stopPropagation();
e.preventDefault();
var files = e.dataTransfer.files;
if(files.length > 0){
var reader = new FileReader();
reader.onload = loadDrawing;
reader.readAsText(files[0]);
}
});
});
function generateConfig(){
var children = $("#table")[0];
config=[];
for(var i = 0; i < children.rows.length; i++){
var time_ = $(children.rows[i]).find('input')[0].value;
var href_ = children.rows[i].cells[0].innerHTML;
config.push({"id":i,"time":time_,"href":href_});
localStorage.config = JSON.stringify(config);
}
}
function saveLocal(){
localStorage['slides']=JSON.stringify(slides);
updateTable();
}
function loadLocal(){
ls = localStorage['slides'];
if(ls){
slides = JSON.parse(ls);
}else{
slides = [];
}
}
function addToConfig(number){
var slide = slides[number];
var reader = new FileReader();
reader.number = number;
reader.onload = function(r){
var node = $('<div id="main"></div>');
node.html(r.target.result);
var fc = node.find(':first');
var time_ = fc.data('time');
var id_ = r.target.number;
var href_ = "./Folien/"+slides[id_].name;
config.push({time:time_ ,href:href_});
localStorage.config = JSON.stringify(config);
updateTable();
}
reader.readAsText(slide);
};
function updateTable(){
$("#table").html("");
for(var i = 0;i < config.length;i++){
$("#table").append("<tr><td class=\"link\">"+
config[i].href+
"</td><td><input type='text' value=\""+
config[i].time+"\"></input></td><td>"+
"<button onclick=\"deleteElement("+i+
")\">Delete</button></td></tr>");
}
$("#table").sortable();
}
function deleteElement(number){
config.remove(number);
updateTable();
}
</script>
<style>
body {
font-size: 2em;
font-family: sans;
background:#444;
}
#main {
background: #eee;
width:800px;
margin: auto;
padding: 1em;
box-shadow: 0 0 1em black;
}
article h1 {
}
table {
width: 100%;
border: 1px solid Gray;
border-collapse: collapse;
font-size:0.5em;
}
td {
border: 1px solid Gray;
}
</style>
</head>
<body>
<div id="main">
<h2>InfoBeamer</h2>
<p>Select your pages and you are ready to go.</p>
<input id="myfiles" multiple type="file">
<input id="add" type="submit" value="add">
<input id="save" type="submit" value="save">
<input id="save_as" type="submit" value="save as">
<input id="play" type="submit" value="play">
<table >
<thead></td><td>name</td><td>seconds</td></tr>
</thead>
<tbody id="table"></tbody>
</table>
</div>
<div>
</div>
</body>
</html>