diff --git a/package.json b/package.json index 38d2c306..eafa25f4 100644 --- a/package.json +++ b/package.json @@ -28,7 +28,6 @@ "jquery-serializejson": "^2.9.0", "moment": "^2.27.0", "nosleep.js": "^0.11.0", - "qrcode-generator": "^1.4.4", "sprintf-js": "^1.1.2", "startbootstrap-sb-admin": "4.0.0", "summernote": "^0.8.18", diff --git a/public/js/extensions.js b/public/js/extensions.js index eb6654da..3d92f580 100644 --- a/public/js/extensions.js +++ b/public/js/extensions.js @@ -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; } diff --git a/public/viewjs/calendar.js b/public/viewjs/calendar.js index 3c9c74d2..20b8af27 100644 --- a/public/viewjs/calendar.js +++ b/public/viewjs/calendar.js @@ -33,7 +33,7 @@ $("#ical-button").on("click", function(e) bootbox.alert({ title: __t('Share/Integrate calendar (iCal)'), message: __t('Use the following (public) URL to share or integrate the calendar in iCal format') + '
' - + getQRCodeForContent(result.url) + "
", + + QrCodeImgHtml(result.url) + "", closeButton: false }); }, diff --git a/public/viewjs/manageapikeys.js b/public/viewjs/manageapikeys.js index f31d3954..4323f0db 100644 --- a/public/viewjs/manageapikeys.js +++ b/public/viewjs/manageapikeys.js @@ -67,9 +67,21 @@ $(document).on('click', '.apikey-delete-button', function(e) } }); }); + +function QrCodeForApiKey(apiKeyType, apiKey) +{ + var content = U('/api') + '|' + apiKey; + if (apiKeyType === 'special-purpose-calendar-ical') + { + content = U('/api/calendar/ical?secret=' + apiKey); + } + + return QrCodeImgHtml(content); +} + $('.apikey-show-qr-button').on('click', function() { - var qrcodeHtml = getQRCodeForAPIKey($(this).data('apikey-type'), $(this).data('apikey-key')); + var qrcodeHtml = QrCodeForApiKey($(this).data('apikey-type'), $(this).data('apikey-key')); bootbox.alert({ title: __t('API key'), message: "" + qrcodeHtml + "
", diff --git a/views/calendar.blade.php b/views/calendar.blade.php index 4a1d7186..685ef0da 100644 --- a/views/calendar.blade.php +++ b/views/calendar.blade.php @@ -7,7 +7,7 @@ @push('pageScripts') @if(!empty($__t('fullcalendar_locale') && $__t('fullcalendar_locale') != 'x'))@endif - + @endpush @push('pageStyles') diff --git a/views/manageapikeys.blade.php b/views/manageapikeys.blade.php index 783d4996..84169a59 100644 --- a/views/manageapikeys.blade.php +++ b/views/manageapikeys.blade.php @@ -5,7 +5,7 @@ @section('viewJsName', 'manageapikeys') @push('pageScripts') - + @endpush @push('pageStyles') diff --git a/yarn.lock b/yarn.lock index ca62679b..5c81ed3c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2362,11 +2362,6 @@ pupa@^2.0.1: dependencies: escape-goat "^2.0.0" -qrcode-generator@^1.4.4: - version "1.4.4" - resolved "https://registry.yarnpkg.com/qrcode-generator/-/qrcode-generator-1.4.4.tgz#63f771224854759329a99048806a53ed278740e7" - integrity sha512-HM7yY8O2ilqhmULxGMpcHSF1EhJJ9yBj8gvDEuZ6M+KGJ0YY2hKpnXvRD+hZPLrDVck3ExIGhmPtSdcjC+guuw== - qs@~6.5.2: version "6.5.2" resolved "https://registry.yarnpkg.com/qs/-/qs-6.5.2.tgz#cb3ae806e8740444584ef154ce8ee98d403f3e36"