* removed the language attribute on the script element since it is obsolete and we can safely omit it.

* make QRCode JS works with IE :
  * behave as a normal link if canvas aren't supported (<=IE8)
  * default parameter values in JS aren't widely supported (see: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/Default_parameters ), use this method instead: http://stackoverflow.com/a/148918/1484919
  * dataset isn't supported in IE9 use getAttribute instead
  * addEventListener works with IE9+ and other browsers
This commit is contained in:
ArthurHoaro 2015-01-08 15:09:46 +01:00
parent a2d5ef2127
commit fe16b01edb
4 changed files with 32 additions and 24 deletions

View file

@ -12,11 +12,11 @@
<input type="text" name="totag" id="totag">
<input type="submit" name="renametag" value="Rename tag" class="bigbutton">
&nbsp;&nbsp;or&nbsp; <input type="submit" name="deletetag" value="Delete tag" class="bigbutton" onClick="return confirmDeleteTag();"><br>(Case sensitive)</form>
<script language="JavaScript">function confirmDeleteTag() { var agree=confirm("Are you sure you want to delete this tag from all links ?"); if (agree) return true ; else return false ; }</script>
<script>function confirmDeleteTag() { var agree=confirm("Are you sure you want to delete this tag from all links ?"); if (agree) return true ; else return false ; }</script>
</div>
{include="page.footer"}
{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()) && empty($GLOBALS['disablejquery'])"}
<script language="JavaScript">
<script>
$(document).ready(function()
{
$('#fromtag').autocomplete({source:'{$source}?ws=singletag',minLength:1});

View file

@ -33,7 +33,7 @@
</div>
{include="page.footer"}
{if="($GLOBALS['config']['OPEN_SHAARLI'] || isLoggedIn()) && empty($GLOBALS['disablejquery'])"}
<script language="JavaScript">
<script>
$(document).ready(function()
{
$('#lf_tags').autocomplete({source:'{$source}?ws=tags',minLength:1});

View file

@ -52,7 +52,7 @@
<span class="linkarchive"><a href="https://web.archive.org/web/{$value.url|htmlspecialchars}">archive</a> - </span>
{/if}
<div class="linkqrcode"><a href="http://qrfree.kaywa.com/?l=1&amp;s=8&amp;d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}"
onclick="showQrCode(this); return false;" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}"><img src="images/qrcode.png#" title="QR-Code" alt="QR-Code"></a></div> -
onclick="return showQrCode(this);" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}"><img src="images/qrcode.png#" title="QR-Code"></a></div> -
<a href="{$value.url|htmlspecialchars}"><span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span></a><br>
{if="$value.tags"}
<div class="linktaglist">
@ -79,12 +79,20 @@ function remove_qrcode()
return false;
}
function isCanvasSupported(){
var elem = document.createElement('canvas');
return !!(elem.getContext && elem.getContext('2d'));
}
// Show the QR-Code of a permalink (when the QR-Code icon is clicked).
function showQrCode(caller,loading=false)
function showQrCode(caller,loading)
{
if( !isCanvasSupported() ) return true;
// Dynamic javascript lib loading: We only load qr.js if the QR code icon is clicked:
if (typeof(qr)=='undefined') // Load qr.js only if not present.
{
loading = typeof loading !== 'undefined' ? loading : false;
if (!loading) // If javascript lib is still loading, do not append script to body.
{
var element = document.createElement("script");
@ -101,12 +109,12 @@ function showQrCode(caller,loading=false)
// Build the div which contains the QR-Code:
var element = document.createElement('div');
element.id="permalinkQrcode";
// Make QR-Code div commit sepuku when clicked:
if ( element.attachEvent ){ element.attachEvent('onclick', 'this.parentNode.removeChild(this);' ); } // Damn IE
else { element.setAttribute('onclick', 'this.parentNode.removeChild(this);' ); }
// Make QR-Code div commit sepuku when clicked:
element.addEventListener('click', remove_qrcode ); // Works on every canvas supported browser
// Build the QR-Code:
var image = qr.image({size: 8,value: caller.dataset.permalink});
var image = qr.image({size: 8,value: caller.getAttribute('data-permalink')});
if (image)
{
element.appendChild(image);