mirror of
https://github.com/grocy/grocy.git
synced 2025-08-16 02:34:44 +00:00
Merge used libraries for Barcode/QR-Code generation
This commit is contained in:
@@ -185,20 +185,18 @@ function RandomString()
|
||||
return Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100);
|
||||
}
|
||||
|
||||
function getQRCodeForContent(url)
|
||||
function QrCodeImgHtml(text)
|
||||
{
|
||||
var qr = qrcode(0, 'L');
|
||||
qr.addData(url);
|
||||
qr.make();
|
||||
return qr.createImgTag(10, 5);
|
||||
}
|
||||
var dummyCanvas = document.createElement("canvas");
|
||||
var img = document.createElement("img");
|
||||
|
||||
function getQRCodeForAPIKey(apikey_type, apikey_key)
|
||||
{
|
||||
var content = U('/api') + '|' + apikey_key;
|
||||
if (apikey_type === 'special-purpose-calendar-ical')
|
||||
{
|
||||
content = U('/api/calendar/ical?secret=' + apikey_key);
|
||||
}
|
||||
return getQRCodeForContent(content);
|
||||
bwipjs.toCanvas(dummyCanvas, {
|
||||
bcid: "qrcode",
|
||||
text: text,
|
||||
scale: 4,
|
||||
includetext: false
|
||||
});
|
||||
img.src = dummyCanvas.toDataURL("image/png");
|
||||
|
||||
return img.outerHTML;
|
||||
}
|
||||
|
Reference in New Issue
Block a user