Forum Moderators: open
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<style type="text/css">
#container {
background:#fefefe;
margin:20px;
border:1px solid #aaa;
padding:10px;
width:400px;
height:200px;
font-family:Arial;
font-size:18px;
font-weight:normal;
color:#777;
}
</style>
<script type="text/javascript">
var kiosk = new function(){
var self = this;
// UPDATE STATUS
self.status = {
'last': '',
'next': '',
'thirty': 3*1000,
'sixty': 60*1000,
'hour': 60*60*1000
};
// PRESENTATION LAYER
self.content = {
'data':[],
'sequence': '',
'container': '',
'load': function(){
this.data = ['Huey','Dewey','Louie'];
this.sequence = this.data.length - 1;
this.container = document.getElementById('container');
this.update();
},
'update': function(){
this.container.innerHTML = this.data[this.index()];
setTimeout(function(){self.content.update()},self.status.thirty);
},
'index': function(){
((this.data.length - 1) == this.sequence) ? this.sequence = 0 : this.sequence++;
return this.sequence;
}
};
// DATA ARRAY UPDATE
self.data = {
't': '',
'load': function(){
this.t = self.status.hour;
},
'check': function(){
setTimeout(
function(){
self.status.next = self.ajax.getdata('timestamp.php','&lastupdate=' + self.status.last);
if(self.status.next == self.status.last){
self.data.t = self.status.minute;
this.check();
}
else {
self.data.update();
}
},self.data.t);
},
'update': function(){
self.content.data = self.ajax.getdata('update.php');
self.content.load();
this.t = self.status.hour;
this.check();
}
};
// AJAX
self.ajax = {
'request': false,
'newrequest': function(){
this.request = false;
try {this.request = new XMLHttpRequest()}
catch(error1){
try {this.request = new ActiveXObject('Msxml2.XMLHTTP')}
catch(error2){
try {this.request = new ActiveXObject('Microsoft.XMLHTTP')}
catch(error3){this.request = false}
}
}
},
// SYNCHRONOUS DATA RESPONSE
'getdata': function(url,args){
args = (typeof args == 'undefined') ? '' : args;
url += '?rand=' + Math.floor(Math.random()*1000) + args;
this.newrequest();
if(this.request != null){
this.request.open('GET',url,false);
this.request.send(null);
return this.request.responseText;
}
}
};
}
window.onload = function(){
kiosk.content.load();
}
</script>
</head>
<body>
<div id="container"></div>
</body>
</html>
<script type="text/javascript">
var kiosk = new function(){
var self = this;
};
</script>
// UPDATE STATUS
self.status = {
'last': '',
'next': '',
'thirty': 3*1000,
'sixty': 60*1000,
'hour': 60*60*1000
};
// PRESENTATION LAYER
self.content = {
'data':[],
'sequence': '',
'container': '',
'load': function(){
this.data = ['Huey','Dewey','Louie'];
this.sequence = this.data.length - 1;
this.container = document.getElementById('container');
this.update();
},
'update': function(){
this.container.innerHTML = this.data[this.index()];
setTimeout(function(){self.content.update()},self.status.thirty);
},
'index': function(){
((this.data.length - 1) == this.sequence) ? this.sequence = 0 : this.sequence++;
return this.sequence;
}
};
// DATA ARRAY UPDATE
self.data = {
't': '',
'load': function(){
this.t = self.status.hour;
},
'check': function(){
setTimeout(
function(){
self.status.next = self.ajax.getdata('timestamp.php','&lastupdate=' + self.status.last);
if(self.status.next == self.status.last){
self.data.t = self.status.minute;
this.check();
}
else {
self.data.update();
}
},self.data.t);
},
'update': function(){
self.content.data = self.ajax.getdata('update.php');
self.content.load();
this.t = self.status.hour;
this.check();
}
};
// AJAX
self.ajax = {
'request': false,
'newrequest': function(){
this.request = false;
try {this.request = new XMLHttpRequest()}
catch(error1){
try {this.request = new ActiveXObject('Msxml2.XMLHTTP')}
catch(error2){
try {this.request = new ActiveXObject('Microsoft.XMLHTTP')}
catch(error3){this.request = false}
}
}
},
// SYNCHRONOUS DATA RESPONSE
'getdata': function(url,args){
args = (typeof args == 'undefined') ? '' : args;
url += '?rand=' + Math.floor(Math.random()*1000) + args;
this.newrequest();
if(this.request != null){
this.request.open('GET',url,false);
this.request.send(null);
return this.request.responseText;
}
}
};
}
window.onload = function(){
kiosk.content.load();
}