Merge branch 'master' of https://christophhagen.de/git/ch/FestivalServer
This commit is contained in:
commit
896a9f79d1
@ -17,3 +17,17 @@ function loadList(name, source) {
|
|||||||
txtFile.open("GET", list, true);
|
txtFile.open("GET", list, true);
|
||||||
txtFile.send(null);
|
txtFile.send(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function loadCount() {
|
||||||
|
var txtFile = new XMLHttpRequest();
|
||||||
|
var allText = "";
|
||||||
|
txtFile.onreadystatechange = function () {
|
||||||
|
if (txtFile.readyState === XMLHttpRequest.DONE && txtFile.status == 200) {
|
||||||
|
allText = txtFile.responseText;
|
||||||
|
}
|
||||||
|
document.getElementById("left-button").innerHTML = "Registered (" + allText + ")";
|
||||||
|
}
|
||||||
|
var list = '/festival/api/count' + name;
|
||||||
|
txtFile.open("GET", list, true);
|
||||||
|
txtFile.send(null);
|
||||||
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
<link rel="stylesheet" type="text/css" href="assets/festival.css">
|
<link rel="stylesheet" type="text/css" href="assets/festival.css">
|
||||||
<link rel="stylesheet" type="text/css" href="assets/festival-info.css">
|
<link rel="stylesheet" type="text/css" href="assets/festival-info.css">
|
||||||
<script src="assets/festival.js?v=9"></script>
|
<script src="assets/festival.js?v=9"></script>
|
||||||
<script src="assets/festival-info.js?v=0"></script>
|
<script src="assets/festival-info.js?v=1"></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="wrapper">
|
<div class="wrapper">
|
||||||
@ -49,6 +49,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="member-list" id="remote-content">Liste nicht geladen</div>
|
<div class="member-list" id="remote-content">Liste nicht geladen</div>
|
||||||
<script>loadList('registered.txt', document.getElementById('left-button'))</script>
|
<script>loadList('registered.txt', document.getElementById('left-button'))</script>
|
||||||
|
<script>loadCount()</script>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -16,6 +16,16 @@ private let df: DateFormatter = {
|
|||||||
return df
|
return df
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
func guestCount() -> Int {
|
||||||
|
registeredGuests
|
||||||
|
.reduce([]) { $0 + $1.components(separatedBy: "+") }
|
||||||
|
.reduce([]) { $0 + $1.components(separatedBy: "-") }
|
||||||
|
.reduce([]) { $0 + $1.components(separatedBy: "und ") }
|
||||||
|
.reduce([]) { $0 + $1.components(separatedBy: "&") }
|
||||||
|
//.map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }
|
||||||
|
.count
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
func add(guest: String) -> String {
|
func add(guest: String) -> String {
|
||||||
registeredGuests.insert(guest)
|
registeredGuests.insert(guest)
|
||||||
|
@ -12,16 +12,13 @@ private func register(_ req: Request, isAttending: Bool) -> String {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func routes(_ app: Application) throws {
|
func routes(_ app: Application) throws {
|
||||||
app.get { req in
|
|
||||||
|
app.get("festival", "api", "ping") { req in
|
||||||
return "It works!"
|
return "It works!"
|
||||||
}
|
}
|
||||||
|
|
||||||
app.get("festival", "api", "hello") { req in
|
app.get("festival", "api", "count") { req in
|
||||||
return "It works!"
|
return "\(guestCount())"
|
||||||
}
|
|
||||||
|
|
||||||
app.get("hello") { req in
|
|
||||||
return "It works!"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
app.post("festival", "api", "register") { req -> String in
|
app.post("festival", "api", "register") { req -> String in
|
||||||
|
Loading…
Reference in New Issue
Block a user