-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.js
77 lines (63 loc) · 2.61 KB
/
script.js
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
const badgeForm = document.getElementById('badgeForm');
const downloadBadge = document.getElementById('downBadge');
const createBadge = document.getElementById('createBadge');
badgeForm.addEventListener('submit', function(event) {
event.preventDefault();
const formContainer = document.getElementById('formContainer');
formContainer.style.display = 'none';
const eventName = document.getElementById('eventName').value;
const name = document.getElementById('name').value;
const designation = document.getElementById('designation').value;
const company = "@" + document.getElementById('company').value;
const access = document.getElementById('access').value;
const id = 'ID' + Math.floor(Math.random() * 100).toString().padStart(4, '0');
$('#badgeEvent').text(eventName);
$('#badgeName').text(name);
$('#badgeDesignation').text(designation);
$('#badgeContainer').text(company);
$('#badgeAccess').text(access);
$('#qrcode').empty();
$('#qrcode').qrcode({
text: `ID: ${id}\nEvent: ${eventName}\nDesignation: ${designation}\nCompany: ${company}\nAccess Level: ${access}`,
width: 128,
height: 128
});
$('#badge').css('display', 'block');
$('#downBadge').css('display', 'block');
$('#createBadge').css('display', 'block');
});
createBadge.addEventListener('click', function() {
$('#badge').css('display', 'none');
$('#downBadge').css('display', 'none');
$('#createBadge').css('display', 'none');
document.getElementById('formContainer').style.display = 'block';
document.getElementById('badgeForm').reset();
});
downloadBadge.addEventListener('click', function(e) {
e.preventDefault();
const badgeElement = document.getElementById('badge');
htmlToImage.toPng(badgeElement)
.then(function(dataUrl) {
const link = document.createElement('a');
link.download = document.getElementById('name').value + '.png';
link.href = dataUrl;
link.click();
})
.catch(function(error) {
console.error('Error Converting HTML To Image:', error);
});
document.addEventListener('contextmenu', function(event) {
event.preventDefault();
});
document.addEventListener('keydown', function(event) {
if (event.key === 'F12') {
event.preventDefault();
}
if (event.ctrlKey && event.shiftKey && ['I', 'J', 'C'].includes(event.key)) {
event.preventDefault();
}
if (event.ctrlKey && event.key === 'U') {
event.preventDefault();
}
});
});