-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorganiser.html
143 lines (127 loc) · 5.54 KB
/
organiser.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
<html>
<head>
<title>Organiser</title>
<link rel="stylesheet" type="text/css" href="/style/css/organiser.css"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="http://hackthemidlands.com/style/js/featherlight.js"></script>
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/featherlight/1.5.0/featherlight.min.css"/>
</head>
<body>
<section id="logo">
<a href="/">
<img src="/images/logo.svg"/>
</a>
</section>
<section id="users">
<div class="panel-header">
<h2><span id="hackathon-name"></span>, Organiser Panel</h2>
<a href="/myaccount">
<img id="profile" src="/images/profile.svg"/>
</a>
<hr>
</div>
<div class="panel-content">
<img src="/images/mail.svg"/>
<h3>Message a user</h3>
<div id="user-list">
</div>
</div>
</section>
<div class="lightboxes">
<div id="call-lightbox">
<h1>Message Centre</h1>
<form id="send" method="post" action="http://localhost:9001/text">
<div class="checkbox">
<input type="radio" name="messageOp" value="broadcast">Send Broadcast Call<br>
</div>
<div class="checkbox">
<input type="radio" name="messageOp" value="increment">Send Incremental Call<br>
</div>
<div class="checkbox">
<input type="radio" name="messageOp" value="individual">Send Individual Call<br>
</div>
<textarea id="message" name="message" value="message" placeholder="Enter your message..."></textarea>
<input id="hidden" type="hidden" name="hidden" value=""/>
<input id="submit" type="submit" name="submit" value="Send"/>
</form>
</div>
</div>
<script>
//Get event title
function getQueryVariable(variable) {
var query = window.location.search.substring(1);
var vars = query.split("&");
for (var i=0;i<vars.length;i++) {
var pair = vars[i].split("=");
if(pair[0] == variable){
return string = pair[1];
}
}
return(false);
}
var eventId = getQueryVariable('event_id');
$.ajax({
type: 'post',
url: 'http://localhost:9001/event/attendees',
data: {
eventID: getQueryVariable('event_id')
},
xhrFields: {
withCredentials: false
},
success: function (data) {
addData(data);
},
error: function () {
console.log('We are sorry but our servers are having an issue right now');
}
})
function addData(data){
//Add page name
$('#hackathon-name').html(data.eventName);
//Add users
const attendee = data.attendees;
const userList = document.getElementById('user-list');
attendee.forEach(processMembers);
function processMembers(item, i, array) {
const userItem = document.createElement("DIV");
userItem.className += 'user-item';
const userLeft = document.createElement("DIV");
userLeft.className += 'user-left';
const userRight = document.createElement("DIV");
userRight.className += 'user-right';
userItem.appendChild(userLeft);
userItem.appendChild(userRight);
const name = document.createElement("H3");
name.innerText = array[i].first_name;
const userRightLink = document.createElement("A");
userRightLink.href = '#';
userRightLink.className = 'messageButton';
userRightLink.setAttribute('data-featherlight', '#call-lightbox');
const button = document.createElement("BUTTON");
button.id = array[i].id;
button.setAttribute('index', i);
button.innerText = 'Message';
userRightLink.appendChild(button);
userLeft.appendChild(name);
userRight.appendChild(userRightLink);
userList.appendChild(userItem);
}
}
</script>
<script>
$(document).ready(function() {
setTimeout(function(){
$(".messageButton").click(function() {
var button = $(this).find("button");
const id = button.attr('id');
const index = button.attr('index');
console.log(index + ' ' + id);
$('#send').attr('action', 'http://localhost:9001/text/' + id);
$('#hidden').val(index);
});
}, 500);
});
</script>
</body>
</html>