Space-saving QR Code Generator – qrize.js

Category: Javascript | February 22, 2023
Author:qrize
Views Total:309 views
Official Page:Go to website
Last Update:February 22, 2023
License:MIT

Preview:

Space-saving QR Code Generator – qrize.js

Description:

qrize.js is a JavaScript library used to generate space-saving, image/SVG/table based QR codes with URL shortener service integration.

How to use it:

Install and import the qrize.js package.

# Yarn
$ yarn add qrize
# NPM
$ npm install qrize --save
import Qrize from "qrize";

Or include the ‘qrize.umd.js’ directly on the web page.

<script src="qrize.umd.js"></script>

Create a container to place the generated QR code.

<div id="target"></div>

Initialize the QR code generator.

var qr = new Qrize({
    element: document.getElementById('target')
});

Generate a QR code inside the container.

qrize.createImg({ 
  url: "https://cssscript.com/" 
});
// or
qrize.createSvg({ 
  url: "https://cssscript.com/" 
});
// or
qrize.createTable({ 
  url: "https://cssscript.com/" 
});

To config the QR generator just by passing the following parameters to the constructor.

const qrize = new Qrize({
      element: document.getElementById("qr-target"),
      cellSize: 2,
      margin: 0
});

Callback functions.

qrize.createImg({ 
  url: "https://cssscript.com/",
  onSuccess: function onQrizeSuccess() {
    console.log('Success');
  },
  onFailure: function onQrizeFailure(status, text) {
    console.log('Failure: ', status, text);
  }
});

API methods.

Qrize.getHash({
  url: 'https://cssscript.com/',
  onSuccess({ hash }) {
    console.log(hash);
  }
})
Qrize.getUrl({
  hash: 'xxx',
  onSuccess({ url }) {
    console.log(url);
  }
})

Changelog:

v1.0.0 (02/22/2023)

  • Change API endpoint after migration to the DigitalOcean serverless functions

v0.4.0 (10/15/2018)

  • Add flow annotations

You Might Be Interested In:


Leave a Reply