X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=tpl%2Flinklist.html;h=daf870603a6484000adf626d419097d1743e2b0e;hb=b5d96e9b1f2a7be463ca33a66ab51819870cd4bd;hp=42a75a1af7be4059caf58c701e1ec4135f6b6fb9;hpb=8079dfd1cdec41a0bb3ee7ec2b974e8e64376d83;p=github%2Fshaarli%2FShaarli.git diff --git a/tpl/linklist.html b/tpl/linklist.html index 42a75a1a..daf87060 100644 --- a/tpl/linklist.html +++ b/tpl/linklist.html @@ -1,12 +1,22 @@ -{include="includes"} + + + {include="includes"} + @@ -23,7 +33,7 @@ {if="$search_type=='tags'"}
{$result_count} results for tags {loop="search_crits"} - {$value|htmlspecialchars} x + {$value} x {/loop}
{/if} {/if} @@ -40,23 +50,24 @@ {/if} - {$value.title|htmlspecialchars} + {$value.title}
{if="$value.description"}
{$value.description}
{/if} {if="!$GLOBALS['config']['HIDE_TIMESTAMPS'] || isLoggedIn()"} - {$value.localdate|htmlspecialchars} - permalink - + {function="strftime('%c', $value.timestamp)"} - permalink - {else} permalink - {/if} {if="$GLOBALS['config']['ARCHIVE_ORG']"} - archive - + archive - {/if}
QR-Code
- - {$value.url|htmlspecialchars}
+ onclick="return showQrCode(this);" class="qrcode" data-permalink="{$scripturl}?{$value.linkdate|smallHash}"> + QR-Code - + {$value.url}
{if="$value.tags"}
- {loop="value.taglist"}{$value|htmlspecialchars} {/loop} + {loop="value.taglist"}{$value} {/loop}
{/if} @@ -79,16 +90,24 @@ 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"); - element.src = "inc/qr.min.js"; + element.src = "inc/qr-1.1.3.min.js"; document.body.appendChild(element); } setTimeout(function() { showQrCode(caller,true);}, 200); // Retry in 200 milliseconds. @@ -101,12 +120,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); @@ -120,5 +139,6 @@ function showQrCode(caller,loading=false) return false; } +