This repository has been archived by the owner on May 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlist_posters.html
110 lines (100 loc) · 2.62 KB
/
list_posters.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
<!DOCTYPE html>
<html>
<head>
<!--
Jeroen van Oorschot 2015
e.t.s.v. Thor Eindhoven posterviewer
Lists all submitted, currently active posters, and possibility to delete them.
-->
<script type="text/javascript" src="./js/jquery-2.1.3.min.js"></script>
<title>PromoniThor Manage | List</title>
<style type="text/css">
html,body{
font-family: Verdana, Geneva, sans-serif;
}
img{
max-width:200px;
max-height:200px;
}
button.delete{
color: red;
}
table{
border-collapse:collapse;
margin-top: 10px;
}
th,tr,td{
padding: 10px;
border: 1px solid black;
}
</style>
</head>
<body class="metro">
<h1>PromoniThor Manage</h1>
<a href="index.php" title="Show posterviewer">Show posterviewer</a>
<br />
<a href="http://poster.thor.edu/upload" title="upload">Upload a new poster</a>
<h2>List of current posters</h2>
Posters are visible till the end of the end-day.
<button onclick="loadPosters()">Refresh</button>
<table>
<thead>
<tr><th>Name</th><th>Start</th><th>End</th><th>Preview</th><th>Delete</th></tr>
</thead>
<tbody id="postertable">
</tbody>
</table>
<script type="text/javascript">
var posters = [];
function loadPosters(){
//update the array containing the poster objects
$.getJSON('load_filenames.php', {Thor:"gaaf",type:"posters"} , function (data){
//empty old array
posters = [];
//fill array poster by poster
//filename equals "enddate','title','timeadded'.'extension"
$.each(data, function(key, val){
var loc = val;
var parts = loc.split('/');
//var folder = parts[1];
var fullname = parts[1];
parts = fullname.split(',');
name = parts[1];
end = parts[0];
parts = parts[2].split('.');
start = parts[0];
extension = parts[1];
posters.push({
fullname: fullname,
name: name,
start: start,
end: end,
loc: loc
});
});
var html = '';
//update the view
if(posters.length == 0){
html = "No posters yet";
}else{
$.each(posters, function(key, val){
html += "<tr><td>"+val.name+"</td><td>"+new Date(val.start*1000)+"</td><td>"+val.end+"</td><td><img src='"+val.loc+"' /></td><td><button class=\"delete\" onclick=\"deletePoster('"+val.fullname+"')\">Delete</button></td></tr>";
});
}
$("tbody#postertable").html(html);
});
}
function deletePoster(poster){
var passwd = prompt("Remove "+poster+"? Enter password:");
if(passwd != null){
$.post("delete_poster.php",{poster:poster,password:passwd},function(data){alert(data); loadPosters();});
}else{
alert("Removing poster cancelled");
}
}
$(function(){
loadPosters();
});
</script>
</body>
</html>