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
No known key found for this signature in database
GPG Key ID: 05D40A636AFAB34D
6 changed files with 114 additions and 43 deletions

View File

@ -76,6 +76,26 @@ body.loading {
#deletelink { #deletelink {
float: right; float: right;
margin-left: 5px;
}
#qrcodelink {
color: #337ab7;
float: right;
margin-left: 5px;
cursor: pointer;
}
#qrcodelink:hover, #qrcodelink:focus {
color: #23527c;
}
#qrcodemodalClose {
float: right;
}
#qrcode-display {
width: 200px;
height: 200px;
margin: auto;
} }
#pastelink { #pastelink {

View File

@ -132,7 +132,7 @@ h3.title {
#toolbar, #status { margin-bottom: 5px; } #toolbar, #status { margin-bottom: 5px; }
#copyhint { color: #666; font-size: 0.85em; } #copyhint { color: #666; font-size: 0.85em }
button, .button { button, .button {
color: #fff; color: #fff;

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: prettyPrintOne */
/** global: showdown */ /** global: showdown */
/** global: sjcl */ /** global: sjcl */
/** global: kjua */
// Immediately start random number generator collector. // Immediately start random number generator collector.
sjcl.random.startCollectors(); sjcl.random.startCollectors();
@ -1205,7 +1206,8 @@ jQuery.PrivateBin = function($, sjcl, Base64, RawDeflate) {
var $pasteSuccess, var $pasteSuccess,
$pasteUrl, $pasteUrl,
$remainingTime, $remainingTime,
$shortenButton; $shortenButton,
$qrCodeLink;
/** /**
* forward to URL shortener * 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 * 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 // $pasteUrl is saved in me.createPasteNotification() after creation
$remainingTime = $('#remainingtime'); $remainingTime = $('#remainingtime');
$shortenButton = $('#shortenbutton'); $shortenButton = $('#shortenbutton');
$qrCodeLink = $('#qrcodelink');
// bind elements // bind elements
$shortenButton.click(sendToShortener); $shortenButton.click(sendToShortener);
$qrCodeLink.click(displayQrCode);
} }
return me; return me;

View File

@ -33,16 +33,17 @@ if ($SYNTAXHIGHLIGHTING):
?> ?>
<link type="text/css" rel="stylesheet" href="css/prettify/prettify.css?<?php echo rawurlencode($VERSION); ?>" /> <link type="text/css" rel="stylesheet" href="css/prettify/prettify.css?<?php echo rawurlencode($VERSION); ?>" />
<?php <?php
if (strlen($SYNTAXHIGHLIGHTINGTHEME)): if (strlen($SYNTAXHIGHLIGHTINGTHEME)):
?> ?>
<link type="text/css" rel="stylesheet" href="css/prettify/<?php echo rawurlencode($SYNTAXHIGHLIGHTINGTHEME); ?>.css?<?php echo rawurlencode($VERSION); ?>" /> <link type="text/css" rel="stylesheet" href="css/prettify/<?php echo rawurlencode($SYNTAXHIGHLIGHTINGTHEME); ?>.css?<?php echo rawurlencode($VERSION); ?>" />
<?php <?php
endif; endif;
endif; endif;
?> ?>
<noscript><link type="text/css" rel="stylesheet" href="css/noscript.css" /></noscript> <noscript><link type="text/css" rel="stylesheet" href="css/noscript.css" /></noscript>
<script type="text/javascript" src="js/jquery-3.1.1.js" integrity="sha512-U6K1YLIFUWcvuw5ucmMtT9HH4t0uz3M366qrF5y4vnyH6dgDzndlcGvH/Lz5k8NFh80SN95aJ5rqGZEdaQZ7ZQ==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/jquery-3.1.1.js" integrity="sha512-U6K1YLIFUWcvuw5ucmMtT9HH4t0uz3M366qrF5y4vnyH6dgDzndlcGvH/Lz5k8NFh80SN95aJ5rqGZEdaQZ7ZQ==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/sjcl-1.0.6.js" integrity="sha512-DsyxLV/uBoQlRTJmW5Gb2SxXUXB+aYeZ6zk+NuXy8LuLyi8oGti9AGn6He5fUY2DtgQ2//RjfaZog8exFuunUQ==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/sjcl-1.0.6.js" integrity="sha512-DsyxLV/uBoQlRTJmW5Gb2SxXUXB+aYeZ6zk+NuXy8LuLyi8oGti9AGn6He5fUY2DtgQ2//RjfaZog8exFuunUQ==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/kjua.min.js" integrity="sha512-hmvfOhcr4J8bjQ2GuNVzfSbuulv72wgQCJpgnXc2+cCHKqvYo8pK2nc0Q4Esem2973zo1radyIMTEkt+xJlhBA==" crossorigin="anonymous"></script>
<?php <?php
if ($ZEROBINCOMPATIBILITY): if ($ZEROBINCOMPATIBILITY):
?> ?>
@ -70,7 +71,7 @@ if ($MARKDOWN):
<?php <?php
endif; endif;
?> ?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-EvNAh1GXOoUiGZ/W8iPtzsce06bvVHy6+ajJztmfSgdQcKMPoj0dB8j1FC90MEChl7MOeR4xozvDymH/6HwIlA==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-HXQpEiyKGjM1QuKb+BfxjMcyrrmD3FX5nw5hwgOTONCtQqxCM5Q5bGkmsEvSKc+RcBUpGT3Mc48TddPI8kAlIg==" crossorigin="anonymous"></script>
<!--[if lt IE 10]> <!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style> <style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]--> <![endif]-->
@ -88,8 +89,8 @@ if ($isCpct):
?> class="navbar-spacing"<?php ?> class="navbar-spacing"<?php
endif; endif;
?>> ?>>
<div id="passwordmodal" class="modal fade" role="dialog"> <div id="passwordmodal" tabindex="-1" class="modal fade" role="dialog" aria-hidden="true">
<div class="modal-dialog"> <div class="modal-dialog" role="document">
<div class="modal-content"> <div class="modal-content">
<div class="modal-body"> <div class="modal-body">
<form id="passwordform" role="form"> <form id="passwordform" role="form">
@ -103,6 +104,29 @@ endif;
</div> </div>
</div> </div>
</div> </div>
<div id="qrcodemodal" tabindex="-1" class="modal fade" aria-labelledby="qrcodemodalTitle" role="dialog" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<!-- <div class="modal-header">
<h5 id="qrcodemodalTitle" class="modal-title">QR code</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div> -->
<div class="modal-body">
<div class="mx-auto" id="qrcode-display"></div>
</div>
<!-- <div class="modal-footer"> -->
<button type="button" class="btn btn-primary btn-block" data-dismiss="modal"><?php echo I18n::_('Close') ?></button>
<!-- </div> -->
</div>
</div>
</div>
<nav class="navbar navbar-<?php echo $isDark ? 'inverse' : 'default'; ?> navbar-<?php echo $isCpct ? 'fixed' : 'static'; ?>-top"><?php <nav class="navbar navbar-<?php echo $isDark ? 'inverse' : 'default'; ?> navbar-<?php echo $isCpct ? 'fixed' : 'static'; ?>-top"><?php
if ($isCpct): if ($isCpct):
?><div class="container"><?php ?><div class="container"><?php
@ -157,9 +181,9 @@ endif;
foreach ($EXPIRE as $key => $value): foreach ($EXPIRE as $key => $value):
?> ?>
<option value="<?php echo $key; ?>"<?php <option value="<?php echo $key; ?>"<?php
if ($key == $EXPIREDEFAULT): if ($key == $EXPIREDEFAULT):
?> selected="selected"<?php ?> selected="selected"<?php
endif; endif;
?>><?php echo $value; ?></option> ?>><?php echo $value; ?></option>
<?php <?php
endforeach; endforeach;
@ -189,28 +213,28 @@ if ($isCpct):
<li id="burnafterreadingoption" class="checkbox hidden"> <li id="burnafterreadingoption" class="checkbox hidden">
<label> <label>
<input type="checkbox" id="burnafterreading" name="burnafterreading"<?php <input type="checkbox" id="burnafterreading" name="burnafterreading"<?php
if ($BURNAFTERREADINGSELECTED): if ($BURNAFTERREADINGSELECTED):
?> checked="checked"<?php ?> checked="checked"<?php
endif; endif;
?> /> ?> />
<?php echo I18n::_('Burn after reading'), PHP_EOL; ?> <?php echo I18n::_('Burn after reading'), PHP_EOL; ?>
</label> </label>
</li> </li>
<?php <?php
if ($DISCUSSION): if ($DISCUSSION):
?> ?>
<li id="opendiscussionoption" class="checkbox hidden"> <li id="opendiscussionoption" class="checkbox hidden">
<label> <label>
<input type="checkbox" id="opendiscussion" name="opendiscussion"<?php <input type="checkbox" id="opendiscussion" name="opendiscussion"<?php
if ($OPENDISCUSSION): if ($OPENDISCUSSION):
?> checked="checked"<?php ?> checked="checked"<?php
endif; endif;
?> /> ?> />
<?php echo I18n::_('Open discussion'), PHP_EOL; ?> <?php echo I18n::_('Open discussion'), PHP_EOL; ?>
</label> </label>
</li> </li>
<?php <?php
endif; endif;
?> ?>
<li role="separator" class="divider"></li> <li role="separator" class="divider"></li>
<li> <li>
@ -219,7 +243,7 @@ if ($isCpct):
</div> </div>
</li> </li>
<?php <?php
foreach ($FORMATTER as $key => $value): foreach ($FORMATTER as $key => $value):
?> ?>
<li> <li>
<a href="#" data-format="<?php echo $key; ?>"> <a href="#" data-format="<?php echo $key; ?>">
@ -227,20 +251,20 @@ if ($isCpct):
</a> </a>
</li> </li>
<?php <?php
endforeach; endforeach;
?> ?>
</ul> </ul>
<select id="pasteFormatter" name="pasteFormatter" class="hidden"> <select id="pasteFormatter" name="pasteFormatter" class="hidden">
<?php <?php
foreach ($FORMATTER as $key => $value): foreach ($FORMATTER as $key => $value):
?> ?>
<option value="<?php echo $key; ?>"<?php <option value="<?php echo $key; ?>"<?php
if ($key == $FORMATTERDEFAULT): if ($key == $FORMATTERDEFAULT):
?> selected="selected"<?php ?> selected="selected"<?php
endif; endif;
?>><?php echo $value; ?></option> ?>><?php echo $value; ?></option>
<?php <?php
endforeach; endforeach;
?> ?>
</select> </select>
</li> </li>
@ -251,31 +275,31 @@ else:
<div id="burnafterreadingoption" class="navbar-text checkbox hidden"> <div id="burnafterreadingoption" class="navbar-text checkbox hidden">
<label> <label>
<input type="checkbox" id="burnafterreading" name="burnafterreading"<?php <input type="checkbox" id="burnafterreading" name="burnafterreading"<?php
if ($BURNAFTERREADINGSELECTED): if ($BURNAFTERREADINGSELECTED):
?> checked="checked"<?php ?> checked="checked"<?php
endif; endif;
?> /> ?> />
<?php echo I18n::_('Burn after reading'), PHP_EOL; ?> <?php echo I18n::_('Burn after reading'), PHP_EOL; ?>
</label> </label>
</div> </div>
</li> </li>
<?php <?php
if ($DISCUSSION): if ($DISCUSSION):
?> ?>
<li> <li>
<div id="opendiscussionoption" class="navbar-text checkbox hidden"> <div id="opendiscussionoption" class="navbar-text checkbox hidden">
<label> <label>
<input type="checkbox" id="opendiscussion" name="opendiscussion"<?php <input type="checkbox" id="opendiscussion" name="opendiscussion"<?php
if ($OPENDISCUSSION): if ($OPENDISCUSSION):
?> checked="checked"<?php ?> checked="checked"<?php
endif; endif;
?> /> ?> />
<?php echo I18n::_('Open discussion'), PHP_EOL; ?> <?php echo I18n::_('Open discussion'), PHP_EOL; ?>
</label> </label>
</div> </div>
</li> </li>
<?php <?php
endif; endif;
endif; endif;
if ($PASSWORD): if ($PASSWORD):
?> ?>
@ -311,21 +335,21 @@ if (!$isCpct):
<li class="dropdown"> <li class="dropdown">
<select id="pasteFormatter" name="pasteFormatter" class="hidden"> <select id="pasteFormatter" name="pasteFormatter" class="hidden">
<?php <?php
foreach ($FORMATTER as $key => $value): foreach ($FORMATTER as $key => $value):
?> ?>
<option value="<?php echo $key; ?>"<?php <option value="<?php echo $key; ?>"<?php
if ($key == $FORMATTERDEFAULT): if ($key == $FORMATTERDEFAULT):
?> selected="selected"<?php ?> selected="selected"<?php
endif; endif;
?>><?php echo $value; ?></option> ?>><?php echo $value; ?></option>
<?php <?php
endforeach; endforeach;
?> ?>
</select> </select>
<a id="formatter" href="#" class="hidden dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php echo I18n::_('Format'); ?>: <span id="pasteFormatterDisplay"><?php echo $FORMATTER[$FORMATTERDEFAULT]; ?></span> <span class="caret"></span></a> <a id="formatter" href="#" class="hidden dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php echo I18n::_('Format'); ?>: <span id="pasteFormatterDisplay"><?php echo $FORMATTER[$FORMATTERDEFAULT]; ?></span> <span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<?php <?php
foreach ($FORMATTER as $key => $value): foreach ($FORMATTER as $key => $value):
?> ?>
<li> <li>
<a href="#" data-format="<?php echo $key; ?>"> <a href="#" data-format="<?php echo $key; ?>">
@ -333,7 +357,7 @@ if (!$isCpct):
</a> </a>
</li> </li>
<?php <?php
endforeach; endforeach;
?> ?>
</ul> </ul>
</li> </li>
@ -349,7 +373,7 @@ if (strlen($LANGUAGESELECTION)):
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-flag" aria-hidden="true"></span> <?php echo $LANGUAGES[$LANGUAGESELECTION][0]; ?> <span class="caret"></span></a> <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><span class="glyphicon glyphicon-flag" aria-hidden="true"></span> <?php echo $LANGUAGES[$LANGUAGESELECTION][0]; ?> <span class="caret"></span></a>
<ul class="dropdown-menu"> <ul class="dropdown-menu">
<?php <?php
foreach ($LANGUAGES as $key => $value): foreach ($LANGUAGES as $key => $value):
?> ?>
<li> <li>
<a href="#" data-lang="<?php echo $key; ?>"> <a href="#" data-lang="<?php echo $key; ?>">
@ -357,7 +381,7 @@ if (strlen($LANGUAGESELECTION)):
</a> </a>
</li> </li>
<?php <?php
endforeach; endforeach;
?> ?>
</ul> </ul>
</li> </li>
@ -449,6 +473,9 @@ if (strlen($URLSHORTENER)):
endif; endif;
?> ?>
</div> </div>
<div id="qrcodelink" data-toggle="modal" data-target="#qrcodemodal">
<span class="glyphicon glyphicon-qrcode" title="<?php echo I18n::_('Show QR code') ?>"></span>
</div>
</div> </div>
<ul id="editorTabs" class="nav nav-tabs hidden"> <ul id="editorTabs" class="nav nav-tabs hidden">
<li role="presentation" class="active"><a id="messageedit" href="#"><?php echo I18n::_('Editor'); ?></a></li> <li role="presentation" class="active"><a id="messageedit" href="#"><?php echo I18n::_('Editor'); ?></a></li>

View File

@ -22,6 +22,7 @@ endif;
?> ?>
<script type="text/javascript" src="js/jquery-3.1.1.js" integrity="sha512-U6K1YLIFUWcvuw5ucmMtT9HH4t0uz3M366qrF5y4vnyH6dgDzndlcGvH/Lz5k8NFh80SN95aJ5rqGZEdaQZ7ZQ==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/jquery-3.1.1.js" integrity="sha512-U6K1YLIFUWcvuw5ucmMtT9HH4t0uz3M366qrF5y4vnyH6dgDzndlcGvH/Lz5k8NFh80SN95aJ5rqGZEdaQZ7ZQ==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/sjcl-1.0.6.js" integrity="sha512-DsyxLV/uBoQlRTJmW5Gb2SxXUXB+aYeZ6zk+NuXy8LuLyi8oGti9AGn6He5fUY2DtgQ2//RjfaZog8exFuunUQ==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/sjcl-1.0.6.js" integrity="sha512-DsyxLV/uBoQlRTJmW5Gb2SxXUXB+aYeZ6zk+NuXy8LuLyi8oGti9AGn6He5fUY2DtgQ2//RjfaZog8exFuunUQ==" crossorigin="anonymous"></script>
<script type="text/javascript" src="js/kjua.min.js" integrity="sha512-hmvfOhcr4J8bjQ2GuNVzfSbuulv72wgQCJpgnXc2+cCHKqvYo8pK2nc0Q4Esem2973zo1radyIMTEkt+xJlhBA==" crossorigin="anonymous"></script>
<?php <?php
if ($ZEROBINCOMPATIBILITY): if ($ZEROBINCOMPATIBILITY):
?> ?>
@ -48,7 +49,7 @@ if ($MARKDOWN):
<?php <?php
endif; endif;
?> ?>
<script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-EvNAh1GXOoUiGZ/W8iPtzsce06bvVHy6+ajJztmfSgdQcKMPoj0dB8j1FC90MEChl7MOeR4xozvDymH/6HwIlA==" crossorigin="anonymous"></script> <script type="text/javascript" src="js/privatebin.js?<?php echo rawurlencode($VERSION); ?>" integrity="sha512-HXQpEiyKGjM1QuKb+BfxjMcyrrmD3FX5nw5hwgOTONCtQqxCM5Q5bGkmsEvSKc+RcBUpGT3Mc48TddPI8kAlIg==" crossorigin="anonymous"></script>
<!--[if lt IE 10]> <!--[if lt IE 10]>
<style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style> <style type="text/css">body {padding-left:60px;padding-right:60px;} #ienotice {display:block;} #oldienotice {display:block;}</style>
<![endif]--> <![endif]-->