function RovingImageDisplay(classid, scrollareaid, descriptionareaid) { this.classid = classid; this.scrollareaid = scrollareaid; this.descriptionareaid = descriptionareaid; this.position = 0; this.minx = 0; this.minpos = 0; this.timer = 0; this.numberofthumbs = 0; this.location = ""; this.descriptions = new Array(); this.map = null; this.marker = null; // Methods this.makelarge = makelarge; this.left = left; this.right = right; this.imageObject = imageObject; this.imageDB = new Array(); this.doAddImage = doAddImage; this.showAllImages = showAllImages; this.updateImages = updateImages; this.addDescription = addDescription; } function makelarge(filename) { if (!$("#largeimagearea").html().match("img")) { $("#largeimagearea").html(""); } /* var locData = false; var folder = "/"+this.imageLocation.replace("/rw/", "/rwdb/")+"/"+String(filename).replace(".jpg", "/locdata"); $.getJSON(folder, function(data) { if (!$("#largeimagearea").html().match("map")) { $("#largeimagearea").append("
"); } locData = data; // initmap(data.Latitude, data.Longitude, data.Accuracy); }); */ $("#largeimagearea img") .one('load', function() { //Set something to run when it finishes loading $(this).fadeIn(); //Fade it in when loaded if ($("#largeimagearea").is(":hidden")) { $("#largeimagearea").slideDown(2000, function() { // resizeThisFrame(); }); } }) .attr('src', "/"+this.imageLocation+"/"+filename) //Set the source so it begins fetching .each(function() { //Cache fix for browsers that don't trigger .load() if(this.complete) { $(this).fadeIn(); //Fade it in when loaded if ($("#largeimagearea").is(":hidden")) { $("#largeimagearea").slideDown(2000, function() { //resizeThisFrame(); /* if (locData != false) { initmap(locData.Latitude, locData.Longitude, locData.Accuracy); } */ }); } } }); } function initmap(Latitude, Longitude, Accuracy) { var latlng = new google.maps.LatLng(Latitude, Longitude); var map = this.map; var marker = this.marker; if (this.map != false) { map.panTo(latlng); marker.setPosition(latlng); market.setTitle("Accuracy: "+Accuracy+"m"); } else { var myOptions = { zoom: 12, center: latlng, mapTypeId: google.maps.MapTypeId.HYBRID }; map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); marker = new google.maps.Marker({ position: latlng, map: map, title:"Accuracy: "+Accuracy+"m" }); } this.map = map; this.marker = marker; } function hidelarge() { $("#largeimagearea").slideUp(500); } function right() { var x = 0; if (this.position-5 >= 0-this.imageDB.length) { this.position = this.position-5; x = (this.position * 102); $('#'+this.scrollareaid).animate ({ left: x }, 1500, "swing" ); } } function left() { var x = 0; if (this.position+5 <= 1) { this.position = this.position+5; x = (this.position * 102); $('#'+this.scrollareaid).animate ({ left: x }, 1500, "swing" ); } } /* function imageObject(camera, id, message, time, longitude, latitude) { this.camera = camera || ""; this.id = id || 0; this.message = message || ""; this.time = time || ""; this.longitude = longitude || 0; this.latitude = latitude || 0; } */ function imageObject(filename) { this.filename = filename || ""; } var imageDB = new Array(); // Object; function doAddImage(id) { if ($("#imagedisplayarea").is(":hidden")) { $("#imagedisplayarea").slideDown(2, function() { // resizeThisFrame(); }); } var atag = document.createElement("a"); // atag.href='javascript:'+this.classid+'.makelarge("'+this.imageDB[id].camera+'", "'+this.imageDB[id].id+'", "'+this.imageDB[id].message+'", "'+this.imageDB[id].time+'", "'+this.imageDB[id].longitude+'", "'+this.imageDB[id].latitude+'")'; atag.href='javascript:'+this.classid+'.makelarge("'+this.imageDB[id].filename.replace(/thumb/, "photo")+'")'; var img = document.createElement("img"); img.src = "/"+this.imageLocation+"/"+this.imageDB[id].filename; atag.appendChild(img); document.getElementById(this.scrollareaid).insertBefore(atag, document.getElementById(this.scrollareaid).firstChild); this.numberofthumbs += 1; $("#"+this.scrollareaid).css("width", 102*(this.numberofthumbs)+"px"); // resizeThisFrame() } function showAllImages() { var desc = "9999999999999999999999999999999999999"; for (count = 0; count < this.imageDB.length; count++) { // this.doAddImage(count, false); if (desc != this.imageDB[count].message.toLowerCase().replace(" ", "")) { this.addDescription(count, true); desc = this.imageDB[count].message.toLowerCase().replace(" ", ""); this.descriptions[this.descriptions.length] = desc; } } this.minx = 0-((this.imageDB.length-5)*102); this.minpos = 0-(this.imageDB.length-5); } function addDescription(id, select) { // var div = document.createElement("div"); var atag = document.createElement("a"); atag.setAttribute("class", "descsel"); atag.innerHTML = ""+this.imageDB[id].message; // div.appendChild(atag); //$(this.descriptionareaid).appendChild(div); $(this.descriptionareaid).insertBefore(atag, $(this.descriptionareaid).firstChild); // if (select) { // this.makelarge(this.imageDB[id].id, this.imageDB[id].message, this.imageDB[id].time, this.imageDB[id].longitude, this.imageDB[id].latitude); // } } function updateImages() { var self = this; var dat = "prefix="+this.imageLocation+"/"; if (this.imageDB[this.imageDB.length-1] != undefined) { dat = dat+"&marker="+this.imageLocation+"/"+this.imageDB[this.imageDB.length-1].filename+"/"; } $.ajax({ url: "http://"+this.server, cache: false, data: dat, dataType: "xml", success: function(xml) { $(xml).find('Contents').each(function(){ var filename = $(this).find('Key').text().replace(""+self.imageLocation+"\/", ""); if (filename != "") { if (filename.match(/thumb\.jpg$/)) { var id = self.imageDB.length; // self.imageDB[id] = new this.imageObject(res[count].camera, res[count].id, res[count].LM, res[count].DTO, res[count].Longitude, res[count].Latitude); self.imageDB[id] = new self.imageObject(filename); self.doAddImage(id); } } }); } }); }