Giter VIP home page Giter VIP logo

jquery-qrcode's Introduction

jQuery.qrcode

license web github

jQuery plugin to dynamically generate QR codes. Uses QR Code Generator (MIT). There is a newer lib named kjua that works in all modern browsers with crisp codes on all devices.

License

The MIT License (MIT)

Copyright (c) 2020 Lars Jung (https://larsjung.de)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

jquery-qrcode's People

Contributors

lrsjng avatar nigelng avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jquery-qrcode's Issues

Ability to Save to SVG Instead of a PNG

I'm looking for a way to save the file as a SVG using a download a tag if possible.

I'd like to generate the QR, download and use it for print, however, I've been unable to find a way to do that.

I understand that doing that with the canvas element is not possible.

URL Encodes hashtag

The following code successfully generates a QR code. However, when I scan it on AT&TCodeScanner with an iPad, all the special characters after the hash tag get the equivalent of encodeURIComponent() done to them ("#" => "%23", "=" => "%3D, etc) , messing up the hash links. See the bottom of the page for the actually scanned link.

<div class="qr-3 qr-code"></div>

<script>
        $(document).ready(function() {

          $(".qr-3").qrcode({
            render: 'image',
            size: 86,
            fill: '#000',
              text: "http://www.google.com/search?tbm=shop&gws_rd=ssl#tbs=vw:l,mr:1,local_avail:1,seller:1311674%7C8740%7C1192406%7C9119074%7C3136905&q=lre3083st"
          });
       });
</script
http://www.google.com/search?tbm=shop&gws_rd=ssl%23tbs%3Dvw%3Al%2Cmr%3A1%2Clocal_avail%3A1%2Cseller%3A1311674%257C8740%257C1192406%257C9119074%257C3136905%26q%3Dlre3083st

Change Content

How can we update the information we added to the qr code without changing the qr code.

Inkonsistentes Verhalten

var image = new Image();
image.src = 'data:image/png;base64,' + logo;
image.setAttribute('id', 'logo');
image.setAttribute('style', 'display: none');
document.body.appendChild(image);

// Generate the QR Code.
$('#qrcodeDIV').qrcode({
    foreground: '#00000',
    background: '#fffff',
    width: 302,
    height: 302,
    text: "exampleValue",
    typeNumber: -1,
    errorCorrectLevel: 'M',
    mode: 4,
    image: $('#logo')[0]
});

Ich verwende den oben stehenden Code in einer FileMaker-Anwendung. "logo" (Zeile 3) ist ein Base64-String eines png-Bilds. Auf Windows verwendet FileMaker eine IE11-Engine. Dort funktioniert der Code ohne Probleme. Auf MacOSX wird eine Safari-Engine verwendet. Dort erhalte ich einen QR-Code ohne Logo. Nun habe ich den Code in eine HTML-Datei exportiert und verwende im image als 'src' einen Dateipfad (siehe hier: https://github.com/swissniggi/qrcode-test). Nun habe ich ein merkwürdiges Verhalten:

Wenn ich den Original-Code verwende (siehe testImage_ES6.html aus meinem Repository) funktioniert es in keinem Browser. IE11 uterstützt kein ES6 und in Firefox/Edge/Safari erhalte ich die Meldung:"Uncaught TypeError: $(...).qrcode is not a function".

Wenn ich den konvertierten Code verwende (siehe testImage_ES5.html aus meinem Repository) funktioniert es im IE11 einwandfrei. In Edge erhalte ich immer einen QR-Code ohne Logo. Im Firefox funktioniert es nur, wenn ich den Pfad zur HTML-Datei in die Adresszeile einfüge und Enter drücke. Wenn ich die Datei durch Doppelclick öffne oder die Seite neu lade erhalte ich ebenfalls einen QR-Code ohne logo. Im Safari stelle ich das gleiche Verhalten fest.

PS: Das Dateiformat des Bildes hat auf das Verhalten keinen Einfluss.

Can't Make It Working!

Hello please help, can't make it working...
I downloaded the script, integrated it to my site... opened created qrcode design, Now how to insert that qrcode into my pages?

Another Question: How to make qr code to Automatically generate page url where I'll insert the qrcode?

Thank you In advanced!

2

Da

drawImage failed execution

I'm receiving this error when I try to use mode 3/4 (images).

Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': No function was found that matched the signature provided.

Any ideas as to why this would be happening?

render mode

when i try to set size to 45, the render mode image and canvas is broken like blur added to it.when i try use render mode div, its sharp as hell...why is that?

Image not pixel-perfect

Some edges inside the rendered QR image are blurred by 1 pixel.

In comparison, google chart generated images have no blurred edges. The URL used was https://chart.googleapis.com/chart?cht=qr&chs=200x200&chld=M|1&chl=abcdefghijklmnopqrstuvwxyz0123456789

See the attached screen capture image.

Code in HTML template:

<div id="qrcode"></div>

Code in JavaScript helper:

$('#qrcode').qrcode({
                "render": "image",
                size: 165,
                text: "abcdefghijklmnopqrstuvwxyz0123456789"
            });

qr code generation comparison 2015-12-25_23-01-23

Note that google adds a blank frame around the QR code, so the actual QR code dimensions are 165 * 165 pixels.

Corners color

Is it possible to change corners color?
Something like this:
Would appreciate any help!

sss

Thanks

Do you has any document for this plugin?

Hi there,
Thanks for sharing this plugin.
May i know how to use background and can it show logo middle of QR code?
$("#qrDiv1").qrcode({
"render": "canvas",
"size": 150,
"color": "#000",
"background": "url(http://127.0.0.1/img/LOGO.png)", // I try also "background": "/img/LOGO.png", but fail.
"text": "$ 20"
});

correct bower version

i tired to install from bower but got the following error:
bower jquery-qrcode#v0.12.0 ENORESTARGET No tag found that was able to satisfy v0.12.0

think bower cannot recognise the the version syntax

Render mode text

If possible, I am looking for a way to save text format QR data files.

I want to generate QR and use text data, but I could not find that way.

I need to print the QR code on the ReWrite card.

Example)

11111110001000110011001111111
10000010111001110000101000001
10111010100000001100101011101
10111010010010110010001011101
10111010111011111110101011101
10000010101010010011101000001
11111110101010101010101111111
00000000101100010100100000000
11010011000111000000101110110
00001001110110001000111001001
11010111000110001011111111110
01000101111111100010111001110
00110110001101000100011001011
11010000010101000001110000100
00010011100100000000101100111
10111001110101001101011011010
01101010111010010101110001010
10101100110011000100011000001
01111110110110000010011101011
11001000100010010110101000011
01001111110001111000111110100
00000000110100001101100010111
11111110110001001110101010010
10000010010001001010100010101
10111010010011011110111111000
10111010101111000000011011010
10111010011010100000100011101
10000010110011000101101010010
11111110100111100100110110010

Can't Rander At IE 8

$(document).ready(function(){
    'use strict';
    var $ = jQuery;
    var options = {
            render: "image",
            minVersion: 6,
            radius: 0.5,
            quiet: 1,
            mode: 4,
            mSize: 0.15,
            mPosX: 0.5,
            mPosY: 0.5,

            //fill: "#800080",
            fill: "#000000",
            background: "#ffffff",

            ecLevel: "M",
            size: 300,
            text: 'http://hidden.com/100130',
            image: $("#img-buffer")[0]
            //label: '',
            //fontname: '',
            //fontcolor: '',
            //image: $("#img-buffer")[0]
        };
    $("#container").empty().qrcode(options);
});

QRCode for unicode characters ?

Hallo lars,

i would like to know how, language such as Chinese, Japanese, Arabic etc, are treated in order by produce the QR Code.
For example, before start to generate the QR Code, is Japanise (or Chinese etc) text converted to unicode character escape sequences ?
E.g. these are 2 Japanise character: \u3092\u30c0

I need this information to estimate a threshold value in my algorithm.

Cheers,
F

The web browser said that "Cannot read property 'naturalWidth' of null" !

I wrote my own file to generate QR code. I'm a Chinese, so some of the code comment may not be displayed
.
The JS code is like this:
`<script>
'use strict';
//写入二维码生成函数
function GenerateQR() {
//清空结果展示页面
document.getElementById("result-display").innerHTML = "";
//进行二维码值对应生成
$('#result-display').empty().qrcode(
{
render: "canvas",
text: document.getElementById("info-text").value,
ecLevel: "H",
size: value,
fill: document.getElementById("colorpicker-value").value,
background: "#ffffff",
typeNumber: -1,
radius: parseInt($("#info-radius").val(), 10) * 0.005,
quiet: quite,
mode: QRmode,
mSize: parseInt(document.getElementById("info-mSize").value) / 100,
mPosX: 50,
mPosY: 50,
image: $("LOGOimg")[0]
}
);
}

    //在二维码内容字符数超出300时,进行提示
    document.getElementById("info-text-length-display").style.display = "inline";
    function CheckTypeOfQR() {
        if (document.getElementById("info-text").value.length >= 300) {
            document.getElementById("info-text-length-warning").style.display = "inline";
            document.getElementById("info-text-length-display").style.color = "#f8b600";
            if (document.getElementById("info-text").value.length >= 400 && document.getElementById("info-text").value.length < 550) {
                document.getElementById("info-text-length-display").style.color = "#f87000";
            } else if (document.getElementById("info-text").value.length >= 550) {
                document.getElementById('info-text-length-display').style.color = "red";
            } else {
                document.getElementById("info-text-length-display").style.color = "#00dd12";
            }
        } else {
            document.getElementById("info-text").maxlength = "";
            document.getElementById("info-text-length-warning").style.display = "none";
            document.getElementById("info-text-length-display").style.color = "#00dd12";
        }
    }

    //二维码内容为“网址”时,在文本前添加“http://”
    document.getElementById("type-setting-url").onclick = function () {
        if (!document.getElementById("info-text").value.includes("http")) {
            document.getElementById("info-text").value = "http://";
        }
    }

    document.getElementById("type-setting-text").onclick = function () {
        document.getElementById("info-text").value = "";
    }

    //写入二维码宽度及拖动条改变函数
    var value, radius, quite = 1, mSize = 0.18;
    var QRmode = 0;
    value = $('#info-width').val() * 4 + 100;
    $('#info-width-display').html(value.toFixed(1));
    $('#info-width').css({
        "background-size": (value - 100) / 4 + "% 100%"
    })
    function ChangeWidth() {
        value = $('#info-width').val();
        var valStr = value + "% 100%";
        $('#info-width-display').html((value * 4 + 100).toFixed(1));
        $('#info-width').css({
            "background-size": valStr
        })
        $("input[name='info-width']").val((value * 1).toFixed(1));
        value = value * 4 + 100;
        if (value >= 375) {
            document.getElementById("info-width-warning").style.display = "inline-block";
        } else {
            document.getElementById("info-width-warning").style.display = "none";
        }
    }

    //写入码点圆滑程度改变函数
    $('#info-radius').css({
        "background-size": "0% 0%"
    })
    $("input[name='info-radius']").val("0");

    function ChangeRadius() {
        radius = $('#info-radius').val();
        var valStrOfRadius = radius + "% 100%";
        $('#info-radius-display').html((radius * 1).toFixed(1));
        $('#info-radius').css({
            "background-size": valStrOfRadius
        })
        $("input[name='info-radius']").val((radius * 1).toFixed(1));
        radius *= 0.5;
        if (radius >= 30) {
            document.getElementById("info-radius-warning").style.display = "inline-block";
        } else {
            document.getElementById("info-radius-warning").style.display = "none";
        }
    }

    //写入二维码空白区域变化函数
    $('#info-quite').css({
        "background-size": $('#info-quite').val() + "% 100%"
    })
    function ChangeQuiteSize() {
        quite = $('#info-quite').val();
        var valStrOfQuite = quite + "% 100%";
        $('#info-quite-display').html((quite / 20).toFixed(0));
        $('#info-quite').css({
            "background-size": valStrOfQuite
        })
        quite /= 20;
    }

    //写入二维码图片图片尺寸改变函数
    $('#info-mSize').css({
        "background-size": $('#info-mSize').val() + "% 100%"
    })
    function ChangeMSize() {
        mSize = $('#info-mSize').val();
        var valStrOfmSize = mSize + "% 100%";
        $('#info-mSize-display').html((mSize / 1).toFixed(0) + "%");
        $('#info-mSize').css({
            "background-size": valStrOfmSize
        })
        mSize /= 100;
    }

    //写入二维码生成总集成函数
    var guiValuePairs = [
        ['size', 'px'],
        ['minversion', ''],
        ['quiet', ' modules'],
        ['radius', '%'],
        ['msize', '%'],
        ['mposx', '%'],
        ['mposy', '%']
    ];

    function OnImageInput() {
        var input = $('#upload-file')[0];
        if (input.files && input.files[0]) {
            var reader = new FileReader();
            reader.onload = function (event) {
                $('#LOGOimg').attr('src', event.target.result);
                QRmode = 4;
                setTimeout(GenerateQR(), 250);
            };
            reader.readAsDataURL(input.files[0]);
        }
    }

    function download() {
        $('#download').attr('href', $('#container canvas')[0].toDataURL('image/png'));
    }

    //将颜色选择input框中的值进行改变
    document.getElementById("info-fgcolor").value = "#000000";
    //对input背景颜色进行调整
    document.getElementById("info-fgcolor").style.backgroundColor = "#000000";
    document.getElementById("info-fgcolor").style.color = "#ffffff";

    function ChangeFGValue() {
        //将颜色选择input框中的值进行改变
        document.getElementById("info-fgcolor").value = document.getElementById("colorpicker-value").value;
        //将值变为全大写模式
        document.getElementById("colorpicker-value").value = document.getElementById("colorpicker-value").value;
        //对input背景颜色进行调整
        document.getElementById("info-fgcolor").style.backgroundColor = document.getElementById("colorpicker-value").value;
        //对input框背景颜色十六进制值进行判断,如果在取整为10进制值后小于8000000,则改变字体颜色
        if (parseInt(document.getElementById("colorpicker-value").value.replace("#", ""), 16) < 8000000) {
            document.getElementById("info-fgcolor").style.color = "white";
        } else {
            document.getElementById("info-fgcolor").style.color = "black";
        }
    }

    //当enter键按下时,进行二维码生成
    document.onkeydown = function (e) {
        if (e.keyCode == 13 && document.getElementById("info-text").value != "") {
            GenerateQR();
        }
    }

    //写入二维码生成集成函数
    function init() {
        $('#upload-file').on('change', OnImageInput);
        $('input, textarea, select').on('input change', GenerateQR());
        $(window).load(GenerateQR());
        CheckTypeOfQR();
        document.getElementById("info-text-length-display").innerText = "  " + document.getElementById("info-text").value.length + " / 750";
        GenerateQR();
    }
    $(init);

</script>`

I have tried to attach a file to the page, but the result is:
screenshot
Issue-Upload.zip
Please reply me after you found the solution. thank you for your patient!

Label & background are not displayed

Hello dear and thank for your work

I can't figure out how to display my text label and image background

var img_codebar = document.createElement('img')
img_codebar.src = "img/codebar.jpg"

$(div_codebar).qrcode({label : 'QR-certificat', fontname: 'Arial', fontcolor: 'white',text : 'text'', size : 100, render:"canvas", fill : "black", background : img_codebar, quiet: 1});

This give me a QR with a transparent background and no label

Can you help?

doesn't show image-box?

Hi, I do as #16 , but the chrome & safari doesn't show the image box in generated qrcode, leaving blank, firefox is ok. After page loaded, exec the function in console of dev tools, then chrome & safari will show as expected.

Is the plugin's order important or did I miss something?

publish to npm

please publish this library to npm, so it could be used with package managers such as npm and jspm

Callback?

Any plans to add a call back function? So when the QR code is scanned, do this...etc.

GS1 qrcode specification

Is it possible to generate the GS1 qrcode? I have tried to manually encode the FNCs but it does not seem to work ( i am most certainly doing it wrong).
thanks

Main bower filename mistake

Bower main file of bower.json
"main": "dist/jquery.qrcode.js"
should be:
"main": "dist/jquery-qrcode.js"

or change the filename of dist js.

Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.

It is a bit weird, the qrcode rending suddenly stopped working (latest Chrome 74.0.3729.169), throwing this error:

    jquery-qrcode-0.17.0.js:220 Uncaught DOMException: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The HTMLImageElement provided is in the 'broken' state.
    at draw_background_img (jquery-qrcode-0.17.0.js:220:11)
    at draw_background (jquery-qrcode-0.17.0.js:236:5)
    at draw_on_canvas (jquery-qrcode-0.17.0.js:387:3)
    at create_canvas (jquery-qrcode-0.17.0.js:395:10)
    at create_img (jquery-qrcode-0.17.0.js:400:35)
    at create_html (jquery-qrcode-0.17.0.js:461:12)
    at HTMLDivElement.<anonymous> (jquery-qrcode-0.17.0.js:512:21)
    at Function.each (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:2715)
    at r.fn.init.each (https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js:2:1003)
    at r.fn.init.main [as qrcode] (jquery-qrcode-0.17.0.js:508:15)

Line:

context.drawImage(settings.image, sl * size, st * size, sw * size, sh * size);

Maybe var context = $canvas[0].getContext('2d'); is not set correctly?

A couple of features i'd like to have

First of all, great job! This plugin looks really promising!

I'd like to suggest some feature i find interesting:

  • a parameter to set the transparency level both for the black and white "squares"
  • the possibility to have a background image (so that the transparent qrcode goes on top of it)
  • a way to choose between standard squares and squares with low transparency, that contain smaller squares with a lower transparency

The goal would be something like this (this is the result of a simple generator in java i made for my company)
qrcode

default transparent background not suitable for high-contrast display settings

Hi, we recently found out that using the default transparent background might render certain A11Y display settings unusable. For instance with 'inverted colors' both the background of the webpage and the pixels of the QR code are then black... Not very A11Y friendly.

Might not be possible to change the default, but maybe warning in documentation?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.