Skip to content

Commit 4af506e

Browse files
authored
initial commit
1 parent df679d2 commit 4af506e

25 files changed

Lines changed: 1731 additions & 0 deletions

qr-code-generator/favicon.ico

1.12 KB
Binary file not shown.

qr-code-generator/img/qr-code.svg

Lines changed: 96 additions & 0 deletions
Loading

qr-code-generator/img/screen.png

49.4 KB
Loading

qr-code-generator/img/spinner.svg

Loading

qr-code-generator/index.html

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<meta
8+
name="description"
9+
content="Generate a QR code image to point to a website URL"
10+
/>
11+
<meta
12+
name="keywords"
13+
content="qr code, qr codes, qrcodes, create qr code, qr code generator, create qrcodes, make a qr code, online qr code"
14+
/>
15+
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico" />
16+
<link rel="preconnect" href="https://fonts.googleapis.com" />
17+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
18+
<link
19+
href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;700&display=swap"
20+
rel="stylesheet"
21+
/>
22+
<script src="https://cdn.tailwindcss.com"></script>
23+
<script>
24+
tailwind.config = {
25+
theme: {
26+
extend: {
27+
fontFamily: {
28+
sans: ["Poppins", "sans-serif"],
29+
},
30+
},
31+
},
32+
};
33+
</script>
34+
<script
35+
src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"
36+
integrity="sha512-CNgIRecGo7nphbeZ04Sc13ka07paqdeTu0WR1IM4kNcpmBAUSHSQX0FslNhTDadL4O5SAGapGt4FodqL8My0mA=="
37+
crossorigin="anonymous"
38+
referrerpolicy="no-referrer"
39+
></script>
40+
<script src="js/script.js" defer></script>
41+
<style>
42+
#spinner {
43+
display: none;
44+
}
45+
</style>
46+
<title>Free Online QR Code Generator</title>
47+
</head>
48+
<body>
49+
<header class="p-4 mb-10 bg-red-500">
50+
<div class="max-w-5xl m-auto">
51+
<div class="text-xl font-bold text-white">QR Code Generator</div>
52+
</div>
53+
</header>
54+
<img src="img/spinner.svg" alt="" />
55+
<main>
56+
<div
57+
class="flex flex-col-reverse align-center justify-center m-auto md:max-w-4xl p-10 md:flex-row"
58+
>
59+
<div class="w-full md:w-2/3 mr-24">
60+
<h1 class="text-3xl font-bold mb-5 md:text-4xl">QR Code Generator</h1>
61+
<p class="mb-4">
62+
QR Codes allow smartphone users to access your website simply and
63+
quickly.
64+
</p>
65+
<p>
66+
Enter your URL below to generate a QR Code and download the image.
67+
</p>
68+
69+
<form id="generate-form" class="mt-4">
70+
<input
71+
id="url"
72+
type="url"
73+
placeholder="Enter a URL"
74+
class="w-full border-2 border-gray-200 rounded p-3 text-grey-dark mr-2 focus:outline-none mb-5"
75+
required
76+
/>
77+
78+
<select
79+
class="w-full border-2 border-gray-200 rounded p-3 text-grey-dark mr-2 focus:outline-none"
80+
name="size"
81+
id="size"
82+
>
83+
<option value="100">100x100</option>
84+
<option value="200">200x200</option>
85+
<option value="300" selected>300x300</option>
86+
<option value="400">400x400</option>
87+
<option value="500">500x500</option>
88+
<option value="600">600x600</option>
89+
<option value="700">700x700</option>
90+
</select>
91+
<button
92+
class="bg-gray-600 rounded w-full text-white py-3 px-4 mt-5 hover:bg-black"
93+
type="submit"
94+
>
95+
Generate QR Code
96+
</button>
97+
</form>
98+
</div>
99+
<div class="w-full md:w-1/3 self-center">
100+
<img
101+
class="w-1/2 m-auto mb-10 md:w-full"
102+
src="img/qr-code.svg"
103+
alt=""
104+
/>
105+
</div>
106+
</div>
107+
108+
<div
109+
id="generated"
110+
class="max-w-5xl m-auto flex flex-col text-center align-center justify-center mt-20"
111+
>
112+
<!-- Spinner -->
113+
<div id="spinner" role="status">
114+
<svg
115+
class="inline mr-2 w-24 h-24 text-gray-200 animate-spin dark:text-gray-600 fill-pink-600"
116+
viewBox="0 0 100 101"
117+
fill="none"
118+
xmlns="http://www.w3.org/2000/svg"
119+
>
120+
<path
121+
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
122+
fill="currentColor"
123+
/>
124+
<path
125+
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
126+
fill="currentFill"
127+
/>
128+
</svg>
129+
<span class="sr-only">Loading...</span>
130+
</div>
131+
132+
<div id="qrcode" class="m-auto"></div>
133+
</div>
134+
</main>
135+
</body>
136+
</html>

qr-code-generator/js/script.js

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
const form = document.getElementById("generate-form");
2+
const qr = document.getElementById("qrcode");
3+
4+
// Button submit
5+
const onGenerateSubmit = (e) => {
6+
e.preventDefault();
7+
8+
clearUI();
9+
10+
const url = document.getElementById("url").value;
11+
const size = document.getElementById("size").value;
12+
13+
// Validate url
14+
if (url === "") {
15+
alert("Please enter a URL");
16+
} else {
17+
showSpinner();
18+
// Show spinner for 1 sec
19+
setTimeout(() => {
20+
hideSpinner();
21+
generateQRCode(url, size);
22+
showScanner();
23+
// Generate the save button after the qr code image src is ready
24+
setTimeout(() => {
25+
// Get save url
26+
const saveUrl = qr.querySelector("canvas").toDataURL();
27+
// Create save button
28+
createSaveBtn(saveUrl);
29+
}, 50);
30+
}, 1000);
31+
}
32+
};
33+
34+
// Generate QR code
35+
const generateQRCode = (url, size) => {
36+
const qrcode = new QRCode("qrcode", {
37+
text: url,
38+
width: size,
39+
height: size,
40+
});
41+
};
42+
43+
// Clear QR code and save button
44+
const clearUI = () => {
45+
qr.innerHTML = "";
46+
const saveBtn = document.getElementById("save-link");
47+
if (saveBtn) {
48+
saveBtn.remove();
49+
}
50+
};
51+
52+
// hide scanner
53+
const showScanner = () => {
54+
const scanner = document.getElementById("qrCodeContainer");
55+
scanner.style.display = "block";
56+
};
57+
58+
// Show spinner
59+
const showSpinner = () => {
60+
const spinner = document.getElementById("spinner");
61+
spinner.style.display = "block";
62+
};
63+
64+
// Hide spinner
65+
const hideSpinner = () => {
66+
const spinner = document.getElementById("spinner");
67+
spinner.style.display = "none";
68+
};
69+
70+
// Create save button to download QR code as image
71+
const createSaveBtn = (saveUrl) => {
72+
const link = document.createElement("a");
73+
link.id = "save-link";
74+
link.classList =
75+
'bg-red-500 hover:bg-red-700 text-white font-bold py-2 rounded w-1/3 m-auto my-5';
76+
link.innerHTML = "Save Image";
77+
78+
link.href = saveUrl;
79+
link.download = "qrcode.png";
80+
81+
document.getElementById("generated").appendChild(link);
82+
};
83+
84+
hideSpinner();
85+
86+
form.addEventListener("submit", onGenerateSubmit);

qr-code-generator/readme.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# QR Code Generator
2+
3+
Simple app to generate and download a QR code that can be used to share a link.
4+
5+
[Live Demo](https://qrcodes.tech)
6+
7+
<img src="img/screen.png">
8+
9+
### MIT License
10+
11+
Copyright &copy; 2022 Brad Traversy
12+
13+
Permission is hereby granted, free of charge, to any person obtaining a copy
14+
of this software and associated documentation files (the "Software"), to deal
15+
in the Software without restriction, including without limitation the rights
16+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
17+
copies of the Software, and to permit persons to whom the Software is
18+
furnished to do so, subject to the following conditions:
19+
20+
The above copyright notice and this permission notice shall be included in all
21+
copies or substantial portions of the Software.
22+
23+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
24+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
26+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
28+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
29+
SOFTWARE.

saas-landing-page/Dockerfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
FROM ubuntu
2+
RUN apt update -y
3+
LABEL maintainer="Rohan Rustagi"
4+
RUN apt install nginx -y
5+
COPY . /var/www/html
6+
EXPOSE 80
7+
CMD ["nginx", "-g", "daemon off;"]

0 commit comments

Comments
 (0)