diff options
Diffstat (limited to 'tpl/linklist.html')
-rw-r--r-- | tpl/linklist.html | 20 |
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&s=8&d={$scripturl|urlencode}%3F{$value.linkdate|smallHash}" | 54 | <div class="linkqrcode"><a href="http://qrfree.kaywa.com/?l=1&s=8&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 | ||
82 | function 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). |
83 | function showQrCode(caller,loading=false) | 88 | function 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); |