changes
This commit is contained in:
9
views/error.ejs
Normal file
9
views/error.ejs
Normal file
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Error Page</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Some kind of error</h1>
|
||||
</body>
|
||||
</html>
|
||||
9
views/error.ejs~
Normal file
9
views/error.ejs~
Normal file
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>You don't have any tickets</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>No tickets for you!!</h1>
|
||||
</body>
|
||||
</html>
|
||||
9
views/notickets.ejs
Normal file
9
views/notickets.ejs
Normal file
@@ -0,0 +1,9 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>You don't have any tickets</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>No tickets for you!!</h1>
|
||||
</body>
|
||||
</html>
|
||||
27
views/notickets.ejs~
Normal file
27
views/notickets.ejs~
Normal file
@@ -0,0 +1,27 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Your Tickets</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome, <%= username %>!</h1>
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>Ticket</th>
|
||||
<th>Owner</th>
|
||||
<th>Offered To</th>
|
||||
<th>QRCode</th>
|
||||
</tr>
|
||||
<% for (const t in tlist) { %>
|
||||
<tr>
|
||||
<td> <%= t %> </td>
|
||||
<td> <%= tlist[t].owner %> </td>
|
||||
<td> <%= tlist[t].offered %> </td>
|
||||
<td> <%= QRCode.toDataURL("https://abc.com", function(err,url) { if (err) { console.error(err); return; } console.log(url); }); %> </td>
|
||||
</tr>
|
||||
<% } %>
|
||||
<tr>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
11
views/simpleowner.ejs
Normal file
11
views/simpleowner.ejs
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>You have a Ticket!</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome, <%= username %>!</h1>
|
||||
Your ticket is: <img src="<%= qrcode %>" alt="QR Code">
|
||||
<%= ticket %>
|
||||
</body>
|
||||
</html>
|
||||
28
views/simpleowner.ejs~
Normal file
28
views/simpleowner.ejs~
Normal file
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Your Tickets</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome, <%= username %>!</h1>
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>Ticket</th>
|
||||
<th>Owner</th>
|
||||
<th>Offered To</th>
|
||||
<th>QRCode</th>
|
||||
</tr>
|
||||
<% for (const t in tlist) { %>
|
||||
<tr>
|
||||
<td> <%= t %> </td>
|
||||
<td> <%= tlist[t].owner %> </td>
|
||||
<td> <%= tlist[t].offered %> </td>
|
||||
<td> <%= simpledata %> </td>
|
||||
<td> <%= QRCode.toDataURL("https://abc.com", function(err,url) { if (err) { console.error(err); return; } console.log(url); }); %> </td>
|
||||
</tr>
|
||||
<% } %>
|
||||
<tr>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
66
views/transfer.ejs
Normal file
66
views/transfer.ejs
Normal file
@@ -0,0 +1,66 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Your Tickets</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome, <%= username %>!</h1>
|
||||
<form id="editor">
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>Ticket</th>
|
||||
<th>Owner</th>
|
||||
<th>Offered To</th>
|
||||
<th>Used</th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
<% for (const t in tickets) { %>
|
||||
<tr>
|
||||
<td><%=t%></td>
|
||||
<td><%=tickets[t].owner%></td>
|
||||
<td><input type="edit" value="<%=tickets[t].offered%>" id="<%=t%>-offered"></td>
|
||||
<td><input type="checkbox" id="<%=t%>-used"<%=tickets[t].used ? ' checked' : ''%>></td>
|
||||
<td><button id="<%=t%>-action"> QRCode </button></td>
|
||||
</tr>
|
||||
<% } %>
|
||||
<tr>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
<script>
|
||||
// JavaScript to change the form element
|
||||
const EditOffer = document.getElementById('habitat-1-offered');
|
||||
const ActionButton = document.getElementById('habitat-1-action');
|
||||
|
||||
|
||||
function toggleUsed(el) {
|
||||
const id=el.target.id.slice(0,-5);
|
||||
const isChecked=this.checked;
|
||||
const js=JSON.stringify( { ticket: id, checked: isChecked } );
|
||||
const fetchtable={ method:'POST', headers: { 'Content-Type': 'application/json' },
|
||||
body: js };
|
||||
console.log(fetchtable);
|
||||
fetch('/toggle',fetchtable)
|
||||
.then( response => response.json() )
|
||||
.then( data => console.log('Server Response: ',data) )
|
||||
.catch( error => console.error('Error: ',error));
|
||||
}
|
||||
|
||||
const elements = document.querySelectorAll("[id$=-used]");
|
||||
|
||||
|
||||
elements.forEach((el) => {
|
||||
const UsedCheckbox = document.getElementById(el.id);
|
||||
UsedCheckbox.addEventListener("change",toggleUsed);
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
EditOffer.addEventListener('input', () => {
|
||||
ActionButton.textContent = "Update";
|
||||
});
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
28
views/transfer.ejs~
Normal file
28
views/transfer.ejs~
Normal file
@@ -0,0 +1,28 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>Your Tickets</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Welcome, <%= username %>!</h1>
|
||||
<table border="1">
|
||||
<tr>
|
||||
<th>Ticket</th>
|
||||
<th>Owner</th>
|
||||
<th>Offered To</th>
|
||||
<th>QRCode</th>
|
||||
</tr>
|
||||
<% for (const t in tlist) { %>
|
||||
<tr>
|
||||
<td> <%= t %> </td>
|
||||
<td> <%= tlist[t].owner %> </td>
|
||||
<td> <%= tlist[t].offered %> </td>
|
||||
<td> <%= simpledata %> </td>
|
||||
<td> <%= QRCode.toDataURL("https://abc.com", function(err,url) { if (err) { console.error(err); return; } console.log(url); }); %> </td>
|
||||
</tr>
|
||||
<% } %>
|
||||
<tr>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user