Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compatible with Android10+ and add a callback function #226

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@
<script type="text/javascript">
var qrcode = new QRCode(document.getElementById("qrcode"), {
width : 100,
height : 100
height : 100,
callback: function(_this){
console.log(_this._elImage)
}
});

function makeCode () {
Expand Down
10 changes: 6 additions & 4 deletions qrcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ var QRCode;

if (/android/i.test(sAgent)) { // android
android = true;
var aMat = sAgent.toString().match(/android ([0-9]\.[0-9])/i);
var aMat = sAgent.toString().match(/android ([0-9]+\.?[0-9]*)/i);

if (aMat && aMat[1]) {
android = parseFloat(aMat[1]);
Expand Down Expand Up @@ -276,7 +276,8 @@ var QRCode;
function _onMakeImage() {
this._elImage.src = this._elCanvas.toDataURL("image/png");
this._elImage.style.display = "block";
this._elCanvas.style.display = "none";
this._elCanvas.style.display = "none";
this._callback(this);
}

// Android 2.1 bug workaround
Expand Down Expand Up @@ -323,8 +324,8 @@ var QRCode;
}
};
var fOnSuccess = function() {
self._bSupportDataURI = true;

self._bSupportDataURI = true;
if (self._fSuccess) {
self._fSuccess.call(self);
}
Expand Down Expand Up @@ -366,6 +367,7 @@ var QRCode;
this._elImage.style.display = "none";
this._el.appendChild(this._elImage);
this._bSupportDataURI = null;
this._callback = htOption.callback;
};

/**
Expand Down
Loading