exports.qrcode = function*(next) {
    var url = 'http://' + this.pubno.appid + '.' + config.domain.client + '/order/' + this.giftorder.id + '/listen';
    var QRCode = require('qrcode');
    QRCode.toDataURL(url, function(err, src) {
        this.body = src;
    });
};
Example #2
0
 PzpInstance.getKeyHash(infile, function(status, value){
     if(status) {
         logger.log("get hash: " + value);
         if(PzpCommon.os.platform().toLowerCase() == "android") {
             try {
                 var bridge = require('bridge');
                 // Call interface to webinos-android
                 var QRencode = bridge.load(require("../platform_interfaces.json").android.QRImpl, this);
                 QRencode.enCode(value, width, height, outfile, function(outfile){
                     cb(outfile);
                 });
             }
             catch(e) {
                 logger.error("Android QRencode - error: "+e.message);
             }
         }
         else
         {
             try {
                 var QRCode = require("qrcode");
                 QRCode.toDataURL(value, function(err, value) {
                     logger.log("created url: " + value);
                     cb(err, value);
                 });
             } catch (err) {
                 logger.log("create QR failed: " + err);
             }
         }
     }
     else
         logger.log("get hash err: " + value);
 });
exports.gift_qrcode = function(req, res) {
  var url = 'http://'+req.host+'/gift/listen/'+req.order.id;
  var QRCode = require('qrcode');
  QRCode.toDataURL(url,function(err,src){
    res.render('qrcode_gift',{src:src,order:req.order});
  });
};
Example #4
0
function draw(array, callback) {
	QRCode.toDataURL(array[1], {errorCorrectLevel:array[2]}, function(err, url){
		var rs = {};
		rs[array[0]] = {};
		rs[array[0]][array[1]] = url;
		callback(err, rs);
	});
}
Example #5
0
module.exports = function(req, res){
	QRCode.toDataURL('http://10.0.10.143:4000/demo',function(err,url){
		console.log(url);
		res.send('<div>');
		res.send('<img src="' + url + '">');
		res.send('</div>');
	});
};
Example #6
0
 return new Promise((resolve,reject)=>{
   QRCode.toDataURL(url, function (err, datUri) {
     if(err){
       reject(err)
     }else{
       resolve(datUri)
     }
   })
 })
Example #7
0
File: totp.js Project: mozilla/fxa
        function createResponse() {
          const otpauth = authenticator.keyuri(sessionToken.email, config.serviceName, secret);

          return qrcode.toDataURL(otpauth, qrCodeOptions)
            .then((qrCodeUrl) => {
              response = {
                qrCodeUrl,
                secret
              };
            });
        }
function create(url, code, cb) {
  "use strict";
  try { 
    var QRCode = require("qrcode");
    var urlCode = "" + url + " " + code;
    QRCode.toDataURL(urlCode, function(err,url) {
      cb(err, url);
    });
  } catch (err) {
    cb(err, "<img src=\"http://www.yooter.com/images/pagenotfound.jpg\" />");
  }
}
Example #9
0
		.then(function (events) {
			qr.toDataURL(req.user.email, {
				errorCorrectionLevel: 'H'
			}, function (err, url) {
				req.user.qrData = url;
				var params = {
					user: req.user,
					subscribed: subscribed,
					pending: pending,
					title: "Dashboard"
				};
				res.renderState('dashboard/dashboard', params);
			});
		});
Example #10
0
    return new Promise(function(resolve,reject){
        var locals = {plistUrl:plistUrl,appName:appName};
        QRCode.toDataURL(pageUrl,function(err,url){
            locals.pageUrl = url;
            var html = fn(locals);
            var fileName = 'index.html';
            fs.writeFile(fileName, html, (err) => {
                if (err) {
                    reject(err)
                };
                resolve(`${fileName} was saved!`);
            });
        });

    })
Example #11
0
app.get('/progress', function(req, res){
	var gameid = req.query.gameid;
	if(gameid === undefined){
		//gameid = 0;
		res.send(404);
		return;
	}
	qrcode.toDataURL("http://phunt.jonathanysp.com/m?gameid=" + gameid, function(err, dataurl){
		game.getGame(gameid, function(err, g){
			if(g === null){
				res.send(404);
				return;
			}
			res.render("progressPage", {title: "Game: " + gameid, g: g, gameid: gameid, dataurl: dataurl});
		})
	});
});
Example #12
0
function createDynaQrcode(compid, expirePeriod, cb) {
    var qrCol = this.db.get('qrcodes');
    var currentTime = new Date().getTime();
    var expireTime = currentTime + expirePeriod;
    var id = uuid.v1();
    var signer = utils.getSigner();
    var signedID = signer.sign(id);
    var urlKey = utils.base64URLSafeEncode(signedID);
    var path = util.format(punchPath, urlKey);
    qrcode.toDataURL(path, '', function(err, data){
        var qrObj = {
            qrid: id,
            compid: compid,
            type: 'dynamic',
            qrdata: data,
            expire: expireTime
        };
        qrCol.findAndModify(
            {compid: compid, type:'dynamic'},
            {$set: qrObj},
            {new: true, upsert: true}, cb);
    });
}
Example #13
0
app.get("/qr", function(req, res){
	qrcode.toDataURL("text", function(err, dataurl){
		res.render("qr", {data: dataurl});
	});
});
Example #14
0
const QRCode = require('qrcode')

// 容錯率 L < M < Q < H
const opts = {
    errorCorrectionLevel: 'H',
    version: 2,
    color: {
        dark: '#00F',
        light: '#0000'
    }
};
const text = 'Hello Marc!!';

QRCode.toDataURL(text, opts, (err, url) => {
    if (err) throw err;
    console.log(url);
});

const path = './qrcode.png';
QRCode.toFile(path, text, opts, (err) => {
    if (err) throw err;
    console.log('saved.')
})
Example #15
0
InvoiceSchema.methods.getAddressQR = function(callback) {
  qrcode.toDataURL(this.address, callback.bind(this));
};
Example #16
0
var QRCode = require('qrcode');

QRCode.toDataURL('i am a pony!',function(err,url){
    console.log(url);
});