p2plabsxyz / dscan

A decentralized storage and file-sharing tool that uploads content to IPFS and generates decentralized QR codes.
https://chromewebstore.google.com/detail/dscan-own-your-identity-o/idpfgkgogjjgklefnkjdpghkifbjenap
MIT License
36 stars 26 forks source link

[bug]: "Uncaught TypeError: Cannot read properties of null (reading 'src')" #12

Closed akhileshthite closed 2 years ago

akhileshthite commented 2 years ago

After clicking on this download svg button (simply downloads the generated QR code) it says Uncaught TypeError: Cannot read properties of null (reading 'src'). Facing this issue after upgrading to webpack.

Screenshot 2022-03-06 at 2 44 54 AM

Make sure to update both main functions, i.e. fileUpload and folderUpload Code link:

https://github.com/buidltools/dscan/blob/771cbb9c779b01fd0049926050be792b1a37e65f/src/js/qrcode.js#L42

https://github.com/buidltools/dscan/blob/771cbb9c779b01fd0049926050be792b1a37e65f/src/js/qrcode.js#L79

Download function:

$("#svg-download").on("click", function () {
        // gets the base64 source of the qr code image
        var qrCodeSrc = document.getElementById('qr-code-image').src;
        var a = document.createElement("a");
        // an invisible a tag is given that href.
        a.href = qrCodeSrc;
        // filename for the qrcode is set
        a.download = "dscan_QR.png";
        document.body.appendChild(a);
        // the a tag is clicked, triggering the download
        a.click();
        document.body.removeChild(a);
});

For file structure and contributing guide, check the main README.md.