Skip to content

Instantly share code, notes, and snippets.

@afalchi82
Last active September 25, 2015 08:42
Show Gist options
  • Save afalchi82/fb7a7026c2465f258c53 to your computer and use it in GitHub Desktop.
Save afalchi82/fb7a7026c2465f258c53 to your computer and use it in GitHub Desktop.
Fast presenter
<!--
Copiare questo file nella cartella che contiene i file .jpg
Parametri:
f = Nome File (solo jpg, scritto senza estensione) [necessario]
bg = Codice esadecimale (senza #) [opzionale - default:#faf9f5]
w = Larghezza container (solo numeri) [opzionale - default:960px]
Es. prop.htm?f=nomefile&bg=ffffff&w=1200
Si può passare anche solo il nome del file senza nessuna chiave ( Es. prop.htm?nomefile )
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Proposta grafica</title>
<style type="text/css">
body {margin:0; padding:0; background: no-repeat top center #faf9f5; text-align:center;}
#wrapper {margin:0 auto; width:960px; overflow:hidden;}
#img {margin:0 auto; opacity:0;}
</style>
</head>
<body>
<div id="wrapper">
<img id="img" src="" alt="">
</div>
<script type="text/javascript">
var loc = location.search.slice(1),
locStr = loc.split(/(\d+)/)[0],
locNum = parseInt(loc.split(/(\d+)/)[1]),
path = location.href.split('?')[0],
arr = loc.split('&'),
q = [];
function nav(e) {
if(locNum) {
switch(e.keyCode) {
case 37:
if(locNum != 1 ) locNum = (locNum-1).toString();
location.href = path + '?' + locStr + locNum;
break;
case 39:
locNum = (locNum+1).toString();
location.href = path + '?' + locStr + locNum;
break;
}
}
}
for(i=0; i<arr.length; i++){
var tempArr = arr[i].split('=');
q[tempArr[0]] = tempArr[1];
};
if( q.f === undefined ) {
q.f = loc;
}
document.body.style.backgroundColor = '#' + q.bg;
document.body.style.backgroundImage = 'url("' + q.f + '.jpg' + '")';
document.getElementById('img').src = q.f + '.jpg';
document.getElementById('wrapper').style.width = q.w + 'px';
document.addEventListener("keydown", nav, false);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment