slitaz-dev-tools rev 230

mercurial-style: on demand qrcode script load
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sun Jun 22 18:46:15 2014 +0200 (2014-06-22)
parents b62c3cef8ab7
children f53fe44e1e70
files slitaz-mercurial-style/templates/slitaz/footer.tmpl
line diff
     1.1 --- a/slitaz-mercurial-style/templates/slitaz/footer.tmpl	Mon May 19 16:38:52 2014 +0000
     1.2 +++ b/slitaz-mercurial-style/templates/slitaz/footer.tmpl	Sun Jun 22 18:46:15 2014 +0200
     1.3 @@ -1,7 +1,22 @@
     1.4  
     1.5  <!-- Footer -->
     1.6  
     1.7 -<script type="text/javascript" src="{staticurl}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 = "{staticurl}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 @@ -14,7 +29,7 @@
    1.28  	<a href="http://hg.slitaz.org/">Hg</a>
    1.29  	<p>
    1.30  		<img src="#" alt="SliTaz @" onmouseover="this.title = location.href"
    1.31 -		 onclick="this.src = QRCode.generatePNG(location.href, \{ecclevel: 'H'})" />
    1.32 +		 onclick="this.src = QRCodePNG(location.href, this)" />
    1.33  		<a href="http://twitter.com/slitaz">Twitter</a>
    1.34  		<a href="http://www.facebook.com/slitaz">Facebook</a>
    1.35  		<a href="http://distrowatch.com/slitaz">Distrowatch</a>