aboutsummaryrefslogtreecommitdiffhomepage
path: root/tpl/linklist.html
diff options
context:
space:
mode:
authornodiscc <nodiscc@gmail.com>2015-01-11 14:56:22 +0100
committernodiscc <nodiscc@gmail.com>2015-01-11 14:56:22 +0100
commit486f25a5f4ab2a9191618edcb89ebb61350ff600 (patch)
treec19fbb34904a1c5148202d01fa723d29b0e1557d /tpl/linklist.html
parenta2d5ef2127881561bf359390fac2d8d336a37335 (diff)
parentfe16b01edb80ac2f2212125fadba8358dff91b95 (diff)
downloadShaarli-486f25a5f4ab2a9191618edcb89ebb61350ff600.tar.gz
Shaarli-486f25a5f4ab2a9191618edcb89ebb61350ff600.tar.zst
Shaarli-486f25a5f4ab2a9191618edcb89ebb61350ff600.zip
Merge pull request #93 from ArthurHoaro/scripttag
Remove language attribute on script tag and improve QRCode JS
Diffstat (limited to 'tpl/linklist.html')
-rw-r--r--tpl/linklist.html20
1 files changed, 14 insertions, 6 deletions
diff --git a/tpl/linklist.html b/tpl/linklist.html
index 42a75a1a..d5bfadf8 100644
--- a/tpl/linklist.html
+++ b/tpl/linklist.html
@@ -52,7 +52,7 @@
52 <span class="linkarchive"><a href="https://web.archive.org/web/{$value.url|htmlspecialchars}">archive</a> - </span> 52 <span class="linkarchive"><a href="https://web.archive.org/web/{$value.url|htmlspecialchars}">archive</a> - </span>
53 {/if} 53 {/if}
54 <div class="linkqrcode"><a href="http://qrfree.kaywa.com/?l=1&amp;s=8&amp;d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}" 54 <div class="linkqrcode"><a href="http://qrfree.kaywa.com/?l=1&amp;s=8&amp;d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}"
55 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> - 55 onclick="return showQrCode(this);" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}"><img src="images/qrcode.png#" title="QR-Code"></a></div> -
56 <a href="{$value.url|htmlspecialchars}"><span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span></a><br> 56 <a href="{$value.url|htmlspecialchars}"><span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span></a><br>
57 {if="$value.tags"} 57 {if="$value.tags"}
58 <div class="linktaglist"> 58 <div class="linktaglist">
@@ -79,12 +79,20 @@ function remove_qrcode()
79 return false; 79 return false;
80} 80}
81 81
82function isCanvasSupported(){
83 var elem = document.createElement('canvas');
84 return !!(elem.getContext && elem.getContext('2d'));
85}
86
82// Show the QR-Code of a permalink (when the QR-Code icon is clicked). 87// Show the QR-Code of a permalink (when the QR-Code icon is clicked).
83function showQrCode(caller,loading=false) 88function showQrCode(caller,loading)
84{ 89{
90 if( !isCanvasSupported() ) return true;
91
85 // Dynamic javascript lib loading: We only load qr.js if the QR code icon is clicked: 92 // Dynamic javascript lib loading: We only load qr.js if the QR code icon is clicked:
86 if (typeof(qr)=='undefined') // Load qr.js only if not present. 93 if (typeof(qr)=='undefined') // Load qr.js only if not present.
87 { 94 {
95 loading = typeof loading !== 'undefined' ? loading : false;
88 if (!loading) // If javascript lib is still loading, do not append script to body. 96 if (!loading) // If javascript lib is still loading, do not append script to body.
89 { 97 {
90 var element = document.createElement("script"); 98 var element = document.createElement("script");
@@ -101,12 +109,12 @@ function showQrCode(caller,loading=false)
101 // Build the div which contains the QR-Code: 109 // Build the div which contains the QR-Code:
102 var element = document.createElement('div'); 110 var element = document.createElement('div');
103 element.id="permalinkQrcode"; 111 element.id="permalinkQrcode";
104 // Make QR-Code div commit sepuku when clicked: 112
105 if ( element.attachEvent ){ element.attachEvent('onclick', 'this.parentNode.removeChild(this);' ); } // Damn IE 113 // Make QR-Code div commit sepuku when clicked:
106 else { element.setAttribute('onclick', 'this.parentNode.removeChild(this);' ); } 114 element.addEventListener('click', remove_qrcode ); // Works on every canvas supported browser
107 115
108 // Build the QR-Code: 116 // Build the QR-Code:
109 var image = qr.image({size: 8,value: caller.dataset.permalink}); 117 var image = qr.image({size: 8,value: caller.getAttribute('data-permalink')});
110 if (image) 118 if (image)
111 { 119 {
112 element.appendChild(image); 120 element.appendChild(image);