generated from ArdeshirV/Sample-Technical-Documentation-Page
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
116 lines (106 loc) · 3.53 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
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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US">
<head>
<title>SampleQRCodeJS</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no" />
<!--<link rel="stylesheet" href="https://raw.githubusercontent.com/ArdeshirV/ardeshirv.github.io/master/css/av-darklee.css">-->
<link rel="stylesheet" href="./css/av-darklee.css">
<link rel="stylesheet" href="./css/style.css">
<link rel="icon" href="img/tech-supp.png">
<script src="https://cdn.freecodecamp.org/testable-projects-fcc/v1/bundle.js"></script>
<script type="text/javascript" src="./js/qrcodejs/jquery.min.js"></script>
<script type="text/javascript" src="./js/qrcodejs/qrcode.js"></script>
<script type="text/javascript" src="./js/main.js"></script>
</head>
<body onload="pageLoad();" online="onLine();" offline="offLine();">
<div class="div-main-flex" id="main-div">
<nav id="navbar">
<header>
<h1>QR Code Generator</h1>
</header>
<div class="links">
<a class="nav-link" href="https://github.com/ArdeshirV/SampleQRCodeJS">Code on Github</a>
</div>
<br />
<h5 class="h5-description">Description</h5>
<p class="p-description">
Demonstrates using qrcodejs library on a dynamic web page
</p>
<p style="color: magneta; " id="online_status"></p/>
</nav>
<main id="main-doc">
<section id="Simple_Examples" class="main-section">
<header name="header">
<h4>Enter text and press Enter to convert text to QR Code</h4>
</header>
<p>
<input id="text_v" type="text" value="https://github.com/ArdeshirV" style="width:80%" />
<br/><br/>
<svg name="qrcodex" id="qx" style="border-color: white; width: 10em; height: 10em; border-style: solid; border-width: 0.5em;"
xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="qrcode"/>
</svg>
<br/><br/>
<button id="saveAs" onclick="saveImageAs(null); ">Save As...</button>
</p>
<hr>
</section>
<footer>
<p class="footer-p">
Copyright© 2020 <a href="mailto:[email protected]" alt="email">[email protected]</a>,
Licensed under GPL<sup>v3+</sup>
</p>
</footer>
</main>
</div>
<script>
function saveImageAs(imgOrURL) {
var canvas = document.getElementById("qx");
canvas.toBlob(function(blob) {
saveAs(blob, "pretty image.png");
});
}
var qrcode = new QRCode(document.getElementById("qrcode"), {
width : 100,
height : 100,
useSVG: true
});
function makeCode () {
var elText = document.getElementById("text_v");
if (!elText.value) {
alert("Enter text");
elText.focus();
return;
}
qrcode.makeCode(elText.value);
}
function pageLoad() {
$("#saveAs").prop("hidden", true); //-------
makeCode();
$("#text_v").
on("blur", function () {
makeCode();
}).
on("keydown", function (e) {
if (e.keyCode == 13) {
makeCode();
}
});
}
function onLine() {
alert("online");
let msg = document.getElementById("online_status");
msg.innerHTML = "Online";
var elText = document.getElementById("text_v");
elText.focus();
}
function offLine() {
alert("offline");
let msg = document.getElementById("online_status");
msg.innerHTML = "Offline";
}
</script>
</body>
</html>