286
HTML & templates / File upload with drag and drop
« on: January 28, 2014, 10:58:20 AM »
put this html5 file in your upload-folder
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
<html>
<head>
<title>mycam</title><META NAME="Author" CONTENT="DJ">
<meta name="viewport" content="width=device-width">
</head>
<body>
<img src="out.jpg" id="mypic" title="Update manually or use actual browser" style="cursor:pointer; max-width:100%">
<script>
Tmin=5;Tmax=60 //upate every 5 or 60 seconds (cam on or off)
//var t1, t //cam
var etag1, etag=""
img=document.getElementById("mypic")
bild1=img.src
window.URL = window.URL || window.webkitURL; // Take care of vendor prefixes.
BlobBuilder = window.MozBlobBuilder || window.WebKitBlobBuilder || window.BlobBuilder;
function req() {
var xhr = new XMLHttpRequest();
xhr.open('POST', 'out.jpg', true);
xhr.responseType = 'arraybuffer'; //blob
xhr.onload = function(e) {
// if (this.status == 200) {
if (BlobBuilder) {var bb = new BlobBuilder();bb.append(this.response);var blob = bb.getBlob('image/jpg'); } //android
else var blob = new Blob([this.response], {type : 'image/jpg'});
//var blob = this.response;
var t2=new Date(xhr.getResponseHeader('Last-Modified'));
//if (t2-t1!=0) t=(t2-t1)/1000; t1=t2 //todo: var. framerate, LMod updates, when cam is on!
var etag2=xhr.getResponseHeader('ETag') //Content-Length
if (etag1 && etag2!=etag1) {etag=new Date(); bild1=img.src}; etag1=etag2
img.title = t2.toLocaleString() + " mycam\n"
+etag.toLocaleString()+" changed\n"
+ new Date().toLocaleString() + " ("+T+"s) reload\n<"
T=(new Date()-t2 > Tmax*1000)?Tmax:Tmin; document.title=(T==Tmax)?"bye-cam":"yaw-cam"
img.onload = function(e) {
//window.URL.revokeObjectURL(img.src); // Clean up after yourself. //uncommend, if not downloadable
};
img.src = window.URL.createObjectURL(blob)
// }
};
xhr.send();
setTimeout(function(){req()},1000*T)
}
if(location.search) Tmin=location.search.substr(1)
T=Tmin
req();
img.onclick=function(){this.src=bild1}; //show last image
</script>
</body>
</html>