-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathindex.html
73 lines (63 loc) · 1.99 KB
/
index.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
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8'>
<meta http-equiv='X-UA-Compatible' content='IE=edge'>
<title>ACSDAYS'22 QR Code Oluşturucu</title>
<meta name='viewport' content='width=device-width, initial-scale=1'>
<link rel='stylesheet' type='text/css' media='screen' href='main.css'>
</head>
<body>
<script src="https://cdn.rawgit.com/davidshimjs/qrcodejs/gh-pages/qrcode.min.js"></script>
<div class="form">
<h1>QR Code Oluşturma</h1>
<form>
<input type="name" id="name" name="website" placeholder="Ad Soyad" required />
<input type="mail" id="mail" name="website" placeholder="Mail" required />
<button type="button" onclick="generateQRCode()">
QR Code Oluştur
</button>
</form>
<div id="qrcode-container">
<div id="qrcode" class="qrcode"></div>
</div>
<script type="text/javascript">
function translate(text) {
var trMap = {
'ç':'c',
'ğ':'g',
'ş':'s',
'ü':'u',
'ı':'i',
'ö':'o',
'Ç':'C',
'Ğ':'G',
'Ş':'S',
'Ü':'U',
'İ':'I',
'Ö':'O'
};
for(var key in trMap) {
text = text.replace(new RegExp('['+key+']','g'), trMap[key]);
}
return text.replace(/[^-a-zA-Z0-9\s]+/ig, '') // remove non-alphanumeric chars
.replace(/\s/gi, "-") // convert spaces to dashes
.replace(/[-]+/gi, "-") // trim repeated dashes
.toLowerCase();
}
function generateQRCode() {
let name = translate(document.getElementById("name").value);
let mail = translate(document.getElementById("mail").value);
if (mail&&name) {
let qrcodeContainer = document.getElementById("qrcode");
qrcodeContainer.innerHTML = "";
new QRCode(qrcodeContainer, name+"~"+mail);
document.getElementById("qrcode-container").style.display = "block";
} else {
alert("Please enter a valid name and mail address.");
}
}
</script>
</div>
</body>
</html>