diff options
Diffstat (limited to 'tpl/linklist.html')
-rw-r--r-- | tpl/linklist.html | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/tpl/linklist.html b/tpl/linklist.html index 42a75a1a..c8dfd122 100644 --- a/tpl/linklist.html +++ b/tpl/linklist.html | |||
@@ -52,7 +52,8 @@ | |||
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}"> |
56 | <img src="images/qrcode.png#" alt="QR-Code" title="{$value.localdate|htmlspecialchars}"></a></div> - | ||
56 | <a href="{$value.url|htmlspecialchars}"><span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span></a><br> | 57 | <a href="{$value.url|htmlspecialchars}"><span class="linkurl" title="Short link">{$value.url|htmlspecialchars}</span></a><br> |
57 | {if="$value.tags"} | 58 | {if="$value.tags"} |
58 | <div class="linktaglist"> | 59 | <div class="linktaglist"> |
@@ -79,16 +80,24 @@ function remove_qrcode() | |||
79 | return false; | 80 | return false; |
80 | } | 81 | } |
81 | 82 | ||
83 | function isCanvasSupported(){ | ||
84 | var elem = document.createElement('canvas'); | ||
85 | return !!(elem.getContext && elem.getContext('2d')); | ||
86 | } | ||
87 | |||
82 | // Show the QR-Code of a permalink (when the QR-Code icon is clicked). | 88 | // Show the QR-Code of a permalink (when the QR-Code icon is clicked). |
83 | function showQrCode(caller,loading=false) | 89 | function showQrCode(caller,loading) |
84 | { | 90 | { |
91 | if( !isCanvasSupported() ) return true; | ||
92 | |||
85 | // Dynamic javascript lib loading: We only load qr.js if the QR code icon is clicked: | 93 | // 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. | 94 | if (typeof(qr)=='undefined') // Load qr.js only if not present. |
87 | { | 95 | { |
96 | loading = typeof loading !== 'undefined' ? loading : false; | ||
88 | if (!loading) // If javascript lib is still loading, do not append script to body. | 97 | if (!loading) // If javascript lib is still loading, do not append script to body. |
89 | { | 98 | { |
90 | var element = document.createElement("script"); | 99 | var element = document.createElement("script"); |
91 | element.src = "inc/qr.min.js"; | 100 | element.src = "inc/qr-1.1.3.min.js"; |
92 | document.body.appendChild(element); | 101 | document.body.appendChild(element); |
93 | } | 102 | } |
94 | setTimeout(function() { showQrCode(caller,true);}, 200); // Retry in 200 milliseconds. | 103 | setTimeout(function() { showQrCode(caller,true);}, 200); // Retry in 200 milliseconds. |
@@ -101,12 +110,12 @@ function showQrCode(caller,loading=false) | |||
101 | // Build the div which contains the QR-Code: | 110 | // Build the div which contains the QR-Code: |
102 | var element = document.createElement('div'); | 111 | var element = document.createElement('div'); |
103 | element.id="permalinkQrcode"; | 112 | element.id="permalinkQrcode"; |
104 | // Make QR-Code div commit sepuku when clicked: | 113 | |
105 | if ( element.attachEvent ){ element.attachEvent('onclick', 'this.parentNode.removeChild(this);' ); } // Damn IE | 114 | // Make QR-Code div commit sepuku when clicked: |
106 | else { element.setAttribute('onclick', 'this.parentNode.removeChild(this);' ); } | 115 | element.addEventListener('click', remove_qrcode ); // Works on every canvas supported browser |
107 | 116 | ||
108 | // Build the QR-Code: | 117 | // Build the QR-Code: |
109 | var image = qr.image({size: 8,value: caller.dataset.permalink}); | 118 | var image = qr.image({size: 8,value: caller.getAttribute('data-permalink')}); |
110 | if (image) | 119 | if (image) |
111 | { | 120 | { |
112 | element.appendChild(image); | 121 | element.appendChild(image); |