Initial commit
This commit is contained in:
61
js/index.js
Normal file
61
js/index.js
Normal file
@@ -0,0 +1,61 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const download = document.querySelector('#download');
|
||||
|
||||
console.log('I\'m outside clickers');
|
||||
|
||||
document.querySelector('#gen').addEventListener('click', () => {
|
||||
let link = document.querySelector('input[name="link"]').value;
|
||||
let idInstr =document.querySelector('input[name="id-str"]').value;
|
||||
|
||||
let canvas = document.querySelector('canvas');
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.clearRect(0,0,canvas.width, canvas.height);
|
||||
|
||||
ctx.fillStyle = "#333";
|
||||
|
||||
// Prepare img elements
|
||||
const qrImg = new Image();
|
||||
const ispcLogo = new Image();
|
||||
const erihsLogo = new Image();
|
||||
|
||||
ispcLogo.src = "./img/logo_ispc.png";
|
||||
erihsLogo.src = "./img/e-rihsit_logo.png";
|
||||
|
||||
let qr = new QRious({element: qrImg});
|
||||
|
||||
qr.set({
|
||||
size: 200,
|
||||
value: link
|
||||
})
|
||||
|
||||
// Draw images
|
||||
ispcLogo.onload = () => {
|
||||
ctx.drawImage(ispcLogo, 25, 10, 200, 75)
|
||||
}
|
||||
|
||||
qrImg.src = qr.toDataURL();
|
||||
qrImg.onload = () => {
|
||||
ctx.drawImage(qrImg, 25, 90, 200, 200)
|
||||
}
|
||||
// Draw instrument ID as text
|
||||
ctx.font = '48px sans-serif';
|
||||
ctx.fillText(idInstr, 45, 330);
|
||||
|
||||
erihsLogo.onload = () => {
|
||||
ctx.drawImage(erihsLogo, 25, 355, 200, 41)
|
||||
}
|
||||
download.classList.remove('disabled');
|
||||
});
|
||||
|
||||
download.addEventListener('click', () => {
|
||||
let downloadLink = document.createElement('a');
|
||||
downloadLink.setAttribute('download', 'etichetta.png');
|
||||
let canvas = document.querySelector('canvas');
|
||||
|
||||
canvas.toBlob(function(blob) {
|
||||
let url = URL.createObjectURL(blob);
|
||||
downloadLink.setAttribute('href', url);
|
||||
downloadLink.click();
|
||||
});
|
||||
});
|
||||
});
|
||||
3
js/package.json
Normal file
3
js/package.json
Normal file
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"dependencies": {}
|
||||
}
|
||||
6
js/qrious.min.js
vendored
Normal file
6
js/qrious.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
js/qrious.min.js.map
Normal file
1
js/qrious.min.js.map
Normal file
File diff suppressed because one or more lines are too long
16
js/vendor/.yarn-integrity
vendored
Normal file
16
js/vendor/.yarn-integrity
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"systemParams": "win32-x64-93",
|
||||
"modulesFolders": [
|
||||
"vendor"
|
||||
],
|
||||
"flags": [],
|
||||
"linkedModules": [],
|
||||
"topLevelPatterns": [
|
||||
"js-qrcode@^1.0.0"
|
||||
],
|
||||
"lockfileEntries": {
|
||||
"js-qrcode@^1.0.0": "https://registry.yarnpkg.com/js-qrcode/-/js-qrcode-1.0.0.tgz#5694d07033ef00a8c17d0eeda017a756ed460955"
|
||||
},
|
||||
"files": [],
|
||||
"artifacts": {}
|
||||
}
|
||||
4
js/yarn.lock
Normal file
4
js/yarn.lock
Normal file
@@ -0,0 +1,4 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user