commit
42d02957cd
@ -1,5 +1,13 @@
|
||||
{
|
||||
"name": "jquery.qrcode",
|
||||
"displayName": "jQuery.qrcode",
|
||||
"version": "0.6.0"
|
||||
}
|
||||
"name": "jquery.qrcode",
|
||||
"displayName": "jQuery.qrcode",
|
||||
"version": "0.7.0",
|
||||
"description": "generate QR codes dynamically",
|
||||
"url": "http://larsjung.de/qrcode/",
|
||||
"author": "Lars Jung",
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/lrsjng/jQuery.qrcode.git"
|
||||
}
|
||||
}
|
||||
|
@ -1,93 +1,103 @@
|
||||
|
||||
var isOpera = Object.prototype.toString.call(window.opera) == '[object Opera]',
|
||||
(function ($) {
|
||||
'use strict';
|
||||
|
||||
guiValuePairs = [
|
||||
["size", "px"],
|
||||
["minversion", ""],
|
||||
["quiet", "modules"],
|
||||
["radius", "%"],
|
||||
["fontsize", "%"],
|
||||
["imagesize", "%"]
|
||||
],
|
||||
var isOpera = Object.prototype.toString.call(window.opera) === '[object Opera]',
|
||||
|
||||
updateGui = function () {
|
||||
guiValuePairs = [
|
||||
["size", "px"],
|
||||
["minversion", ""],
|
||||
["quiet", " modules"],
|
||||
["radius", "%"],
|
||||
["msize", "%"],
|
||||
["mposx", "%"],
|
||||
["mposy", "%"]
|
||||
],
|
||||
|
||||
for (var idx in guiValuePairs) {
|
||||
updateGui = function () {
|
||||
|
||||
var pair = guiValuePairs[idx],
|
||||
$label = $('label[for="' + pair[0] + '"]');
|
||||
$.each(guiValuePairs, function (idx, pair) {
|
||||
|
||||
$label.text($label.text().replace(/:.*/, ': ' + $('#' + pair[0]).val() + pair[1]));
|
||||
}
|
||||
},
|
||||
var $label = $('label[for="' + pair[0] + '"]');
|
||||
|
||||
updateQrCode = function () {
|
||||
$label.text($label.text().replace(/:.*/, ': ' + $('#' + pair[0]).val() + pair[1]));
|
||||
});
|
||||
},
|
||||
|
||||
var options = {
|
||||
render: $("#render").val(),
|
||||
ecLevel: $("#eclevel").val(),
|
||||
minVersion: parseInt($("#minversion").val(), 10),
|
||||
color: $("#color").val(),
|
||||
bgColor: $("#bg-color").val(),
|
||||
text: $("#text").val(),
|
||||
size: parseInt($("#size").val(), 10),
|
||||
radius: parseInt($("#radius").val(), 10) * 0.01,
|
||||
quiet: parseInt($("#quiet").val(), 10),
|
||||
updateQrCode = function () {
|
||||
|
||||
mode: parseInt($("#mode").val(), 10),
|
||||
var options = {
|
||||
render: $("#render").val(),
|
||||
ecLevel: $("#eclevel").val(),
|
||||
minVersion: parseInt($("#minversion").val(), 10),
|
||||
|
||||
label: $("#label").val(),
|
||||
labelsize: parseInt($("#fontsize").val(), 10) * 0.01,
|
||||
fontname: $("#font").val(),
|
||||
fontcolor: $("#fontcolor").val(),
|
||||
fill: $("#fill").val(),
|
||||
background: $("#background").val(),
|
||||
// fill: $("#img-buffer")[0],
|
||||
|
||||
image: $("#img-buffer")[0],
|
||||
imagesize: parseInt($("#imagesize").val(), 10) * 0.01
|
||||
};
|
||||
text: $("#text").val(),
|
||||
size: parseInt($("#size").val(), 10),
|
||||
radius: parseInt($("#radius").val(), 10) * 0.01,
|
||||
quiet: parseInt($("#quiet").val(), 10),
|
||||
|
||||
$("#container").empty().qrcode(options);
|
||||
},
|
||||
mode: parseInt($("#mode").val(), 10),
|
||||
|
||||
update = function () {
|
||||
mSize: parseInt($("#msize").val(), 10) * 0.01,
|
||||
mPosX: parseInt($("#mposx").val(), 10) * 0.01,
|
||||
mPosY: parseInt($("#mposy").val(), 10) * 0.01,
|
||||
|
||||
updateGui();
|
||||
updateQrCode();
|
||||
},
|
||||
label: $("#label").val(),
|
||||
fontname: $("#font").val(),
|
||||
fontcolor: $("#fontcolor").val(),
|
||||
|
||||
onImageInput = function () {
|
||||
image: $("#img-buffer")[0]
|
||||
};
|
||||
|
||||
var input = $("#image")[0];
|
||||
$("#container").empty().qrcode(options);
|
||||
},
|
||||
|
||||
if (input.files && input.files[0]) {
|
||||
update = function () {
|
||||
|
||||
var reader = new FileReader();
|
||||
updateGui();
|
||||
updateQrCode();
|
||||
},
|
||||
|
||||
reader.onload = function (event) {
|
||||
$("#img-buffer").attr("src", event.target.result);
|
||||
$("#mode").val("4");
|
||||
setTimeout(update, 250);
|
||||
};
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
}
|
||||
},
|
||||
onImageInput = function () {
|
||||
|
||||
var input = $("#image")[0];
|
||||
|
||||
if (input.files && input.files[0]) {
|
||||
|
||||
download = function (event) {
|
||||
var reader = new FileReader();
|
||||
|
||||
var data = $("#container canvas")[0].toDataURL('image/png');
|
||||
$("#download").attr("href", data);
|
||||
};
|
||||
reader.onload = function (event) {
|
||||
$("#img-buffer").attr("src", event.target.result);
|
||||
$("#mode").val("4");
|
||||
setTimeout(update, 250);
|
||||
};
|
||||
reader.readAsDataURL(input.files[0]);
|
||||
}
|
||||
},
|
||||
|
||||
download = function (event) {
|
||||
|
||||
$(function () {
|
||||
var data = $("#container canvas")[0].toDataURL('image/png');
|
||||
$("#download").attr("href", data);
|
||||
};
|
||||
|
||||
|
||||
$(function () {
|
||||
|
||||
if (isOpera) {
|
||||
$('html').addClass('opera');
|
||||
$('#radius').prop('disabled', true);
|
||||
}
|
||||
|
||||
if (isOpera) {
|
||||
$('html').addClass('opera');
|
||||
$('#radius').prop('disabled', true);
|
||||
}
|
||||
$("#download").on("click", download);
|
||||
$("#image").on('change', onImageInput);
|
||||
$("input, textarea, select").on("input change", update);
|
||||
$(window).load(update);
|
||||
update();
|
||||
});
|
||||
|
||||
$("#download").on("click", download);
|
||||
$("#image").on('change', onImageInput);
|
||||
$("input, textarea, select").on("input change", update);
|
||||
$(window).load(update);
|
||||
update();
|
||||
});
|
||||
}(jQuery));
|
||||
|
Loading…
Reference in New Issue