Add QR code generation when paste is created

This commit is contained in:
rugk
2017-11-26 15:59:12 +01:00
parent 9f973edb7d
commit 7bf5af761b
6 changed files with 114 additions and 43 deletions

2
js/kjua.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View File

@@ -21,6 +21,7 @@
/** global: prettyPrintOne */
/** global: showdown */
/** global: sjcl */
/** global: kjua */
// Immediately start random number generator collector.
sjcl.random.startCollectors();
@@ -1205,7 +1206,8 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
var $pasteSuccess,
$pasteUrl,
$remainingTime,
$shortenButton;
$shortenButton,
$qrCodeLink;
/**
* forward to URL shortener
@@ -1240,6 +1242,23 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
}
}
/**
* Shows the QR code of the current paste.
*
* @name PasteStatus.displayQrCode
* @function
* @param {Event} event
*/
function displayQrCode(event)
{
var qrCanvas = kjua({
render: 'canvas',
text: $pasteUrl.attr('href')
});
$('#qrcode-display').html(qrCanvas);
}
/**
* creates a notification after a successfull paste upload
*
@@ -1336,9 +1355,11 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
// $pasteUrl is saved in me.createPasteNotification() after creation
$remainingTime = $('#remainingtime');
$shortenButton = $('#shortenbutton');
$qrCodeLink = $('#qrcodelink');
// bind elements
$shortenButton.click(sendToShortener);
$qrCodeLink.click(displayQrCode);
}
return me;