Skip to main content

๐Ÿ‡ถ๐Ÿ‡ท QR Codes

Can I create QR codes with Slate? ๐Ÿค”

Slate has two methods for creating QR codes. Only one is useful for general purposes, but it's buggy. Consider an external service like https://goqr.me/api/.

qrcode.js

A script at /fw/framework/base/qrcode.js can replace an element on the page with a QR code image. Here's how to call the QRCode() function:

new QRCode(el,
    {
        text: 'blah',
        width: 128,
        height: 128
    });

Here's how Slate itself uses this to create event embed QR codes:

<div id="embed_qrcode" class="hidden">
    <script src="/fw/framework/base/qrcode.js"></script>
    <p><span>Right-click the image below and select "Copy Image" to add this QR Code link to a postcard, or use the
            following short URL in a tweet or social post: </span><span id="shorturl"
            style="color: red; font-weight: bold;">https://slate.to/vz0MA9ao</span></p>
    <div id="qrcode" style="margin: 15px auto; width: 128px;"></div>
    <script>/*<![CDATA[*/new QRCode(document.getElementById('qrcode'), { text: $('#shorturl').text(), width: 128, height: 128 });/*]]>*/</script>
</div>

Certain data length ranges (approximate 192 through 218) will throw an error, "Uncaught Error: code length overflow." You can pad out your data to avoid this.

API Endpoint

To our knowledge, Slate only offers one API endpoint/URL that returns a QR code:

/register/mobile?cmd=barcode&id=<guid>

The GUID must exist in [form.response].[id], making its usefulness limited.ย Example: https://rwf.test.technolutions.net/register/mobile?cmd=barcode&id=07F9A7C1-3B7F-493F-9098-4295B30A7D60