mirror of
https://github.com/nextcloud/passman.git
synced 2024-12-27 10:03:50 +08:00
43 lines
No EOL
1 KiB
JavaScript
43 lines
No EOL
1 KiB
JavaScript
(function () {
|
|
'use strict';
|
|
|
|
/**
|
|
* @ngdoc directive
|
|
* @name passmanApp.directive:passwordGen
|
|
* @description
|
|
* # passwordGen
|
|
*/
|
|
angular.module('passmanApp').directive("qrread", ['$parse',
|
|
function ($parse) {
|
|
return {
|
|
scope: true,
|
|
link: function (scope, element, attributes) {
|
|
var invoker = $parse(attributes.onRead);
|
|
scope.imageData = null;
|
|
|
|
qrcode.callback = function (result) {
|
|
//console.log('QR callback:',result);
|
|
invoker(scope, {
|
|
qrdata: {
|
|
qrData: result,
|
|
image: scope.imageData
|
|
}
|
|
});
|
|
//element.val('');
|
|
};
|
|
element.bind("change", function (changeEvent) {
|
|
var reader = new FileReader(), file = changeEvent.target.files[0];
|
|
reader.readAsDataURL(file);
|
|
reader.onload = (function () {
|
|
return function (e) {
|
|
//gCtx.clearRect(0, 0, gCanvas.width, gCanvas.height);
|
|
scope.imageData = e.target.result;
|
|
qrcode.decode(e.target.result);
|
|
};
|
|
})(file);
|
|
});
|
|
}
|
|
};
|
|
}
|
|
]);
|
|
}()); |