slitaz-forge rev 379
mirror/dir-generator.php: load qrcode.js on demand
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Thu Nov 28 11:34:10 2013 +0000 (2013-11-28) |
parents | fc273fd26908 |
children | d2d6aee377d5 |
files | mirror/root/dir-generator.php |
line diff
1.1 --- a/mirror/root/dir-generator.php Mon Oct 21 12:59:37 2013 +0000 1.2 +++ b/mirror/root/dir-generator.php Thu Nov 28 11:34:10 2013 +0000 1.3 @@ -146,8 +146,17 @@ 1.4 //$slitaz_style = ($_SERVER["SERVER_NAME"] == "mirror.slitaz.org"); 1.5 $slitaz_style = preg_match("/mirror\.slitaz\./",$_SERVER["SERVER_NAME"]); 1.6 if ($slitaz_style) { 1.7 + $modified = gmdate("D, d M Y H:i:s e", strtotime("-1 hour")); 1.8 + $expires = gmdate("D, d M Y H:i:s e", strtotime("+1 hour")); 1.9 $fvalue = ""; 1.10 if (isset($_GET['f'])) $fvalue = 'value="'.$_GET['f'].'"'; 1.11 + header("Expires: ".$expires); 1.12 + header("Last-Modified: " . $modified); 1.13 + header("Pragma: cache"); 1.14 +// header("Cache-Control: public"); 1.15 +// <meta http-equiv="cache-control" content="public" /> 1.16 +// <meta http-equiv="last-modified" content="$modified" /> 1.17 +// <meta http-equiv="expires" content="$expires" /> 1.18 print <<<EOT 1.19 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 1.20 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 1.21 @@ -219,7 +228,23 @@ 1.22 </div> 1.23 </div> 1.24 1.25 -<script type="text/javascript" src="/static/qrcode.js"></script> 1.26 +<!-- script type="text/javascript" src="/static/qrcode.js"></script --> 1.27 +<script type="text/javascript"> 1.28 + function QRCodePNG(str, obj) { 1.29 + try { 1.30 + return QRCode.generatePNG(str, {ecclevel: 'H'}); 1.31 + } 1.32 + catch (any) { 1.33 + var element = document.createElement("script"); 1.34 + element.src = "/static/qrcode.js"; 1.35 + element.type ="text/javascript"; 1.36 + element.onload = function() { 1.37 + obj.src = QRCode.generatePNG(str, {ecclevel: 'H'}); 1.38 + }; 1.39 + document.body.appendChild(element); 1.40 + } 1.41 + } 1.42 +</script> 1.43 <div id="lang"> 1.44 Path: /${vpath} 1.45 </div> 1.46 @@ -443,9 +468,7 @@ 1.47 print "<td class='m'>" . $file['modtimeasc'] . 1.48 " <img src=\"/static/qr.png\" alt=\"@\" onmouseover=" . 1.49 "\"this.title = location.href+'$url'\" onclick=" . 1.50 - "\"this.src = QRCode.generatePNG(location.href+'$url', " . 1.51 - "{ecclevel: 'H'}) \"/>" . 1.52 - "</td>"; 1.53 + "\"this.src = QRCodePNG(location.href+'$url', this) \"/></td>"; 1.54 print "<td class='s'>" . format_bytes($file['size']) . "</td>"; 1.55 print "<td class='t'>" . $file['file_type'] . "</td></tr>\n"; 1.56 } 1.57 @@ -473,7 +496,7 @@ 1.58 <a href="http://hg.slitaz.org/?sort=lastchange">Hg</a> 1.59 <p> 1.60 <img src="/static/qr.png" alt="#" onmouseover="this.title = location.href" 1.61 - onclick="this.src = QRCode.generatePNG(location.href, {ecclevel: 'H'})" /> 1.62 + onclick="this.src = QRCodePNG(location.href, this)" /> 1.63 SliTaz @ 1.64 <a href="http://twitter.com/slitaz">Twitter</a> 1.65 <a href="http://www.facebook.com/slitaz">Facebook</a>