slitaz-forge diff mirror/info/index.php @ rev 568

chub, doc, forum, floppies, mirror-info, pkgs, pro, tank: on demand qrcode script load
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jun 22 18:37:40 2014 +0200 (2014-06-22)
parents 88002a7d0351
children ba908ef4f9ff
line diff
     1.1 --- a/mirror/info/index.php	Sat Apr 13 18:15:41 2013 +0200
     1.2 +++ b/mirror/info/index.php	Sun Jun 22 18:37:40 2014 +0200
     1.3 @@ -338,7 +338,22 @@
     1.4  
     1.5  <!-- Footer -->
     1.6  
     1.7 -<script type="text/javascript" src="/static/qrcode.js"></script>
     1.8 +<script type="text/javascript">
     1.9 +	function QRCodePNG(str, obj) {
    1.10 +		try {
    1.11 +			return QRCode.generatePNG(str, {ecclevel: 'H'});
    1.12 +		}
    1.13 +		catch (any) {
    1.14 +			var element = document.createElement("script");
    1.15 +			element.src = "/static/qrcode.js";
    1.16 +			element.type ="text/javascript"; 
    1.17 +			element.onload = function() {
    1.18 +				obj.src = QRCode.generatePNG(str, {ecclevel: 'H'});
    1.19 +			};
    1.20 +			document.body.appendChild(element);
    1.21 +		}
    1.22 +	}
    1.23 +</script>
    1.24  
    1.25  <div id="footer">
    1.26  	Copyright &copy; <span class="year"></span>
    1.27 @@ -351,8 +366,8 @@
    1.28  	<a href="http://bugs.slitaz.org">Bugs</a>
    1.29  	<a href="http://hg.slitaz.org/?sort=lastchange">Hg</a>
    1.30  	<p>
    1.31 -		<img src="#" alt="SliTaz @" onmouseover="this.title = location.href"
    1.32 -		 onclick="this.src = QRCode.generatePNG(location.href, {ecclevel: 'H'})" />
    1.33 +		<img src="/static/qr.png" alt="SliTaz @" onmouseover="this.title = location.href"
    1.34 +		 onclick="this.src = QRCodePNG(location.href, this)" />
    1.35  		<a href="http://twitter.com/slitaz">Twitter</a>
    1.36  		<a href="http://www.facebook.com/slitaz">Facebook</a>
    1.37  		<a href="http://distrowatch.com/slitaz">Distrowatch</a>