var serverName='archive.philippadrian.com'; function getParameter(get) { switch(get) { // Get Window Width case "windowWidth": if(window.innerWidth) return window.innerWidth; else if(document.documentElement && document.documentElement.offsetWidth) return document.documentElement.offsetWidth; else if(document.body && document.body.offsetWidth) return document.body.offsetWidth; else return false; break; // Get Window Height case "windowHeight": if(window.innerHeight) return window.innerHeight; else if(document.documentElement && document.documentElement.offsetHeight) return document.documentElement.offsetHeight; else if(document.body && document.body.offsetHeight) return document.body.offsetHeight; else return false; break; } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Define Icons var baseIconBIG = new GIcon(G_DEFAULT_ICON); baseIconBIG.shadow = "/bilder/markerShadowLarge.png"; baseIconBIG.iconSize = new GSize(24, 30); baseIconBIG.shadowSize = new GSize(42, 30); baseIconBIG.iconAnchor = new GPoint(12, 28); baseIconBIG.infoWindowAnchor = new GPoint(12, 2); var baseIconSMALL = new GIcon(G_DEFAULT_ICON); baseIconSMALL.shadow = '/bilder/markerShadowSmall.png'; baseIconSMALL.iconSize = new GSize(20, 24); baseIconSMALL.shadowSize = new GSize(33, 24); baseIconSMALL.iconAnchor = new GPoint(10, 22); baseIconSMALL.infoWindowAnchor = new GPoint(10, 2); var customIcons = []; customIcons["blue"] = new GIcon(baseIconSMALL); customIcons["blue"].image = "/bilder/markerBlueSmall.png"; customIcons["yellow"] = new GIcon(baseIconSMALL); customIcons["yellow"].image = "/bilder/markerWhiteSmall.png"; customIcons["red"] = new GIcon(baseIconBIG); customIcons["red"].image = "/bilder/markerRedLarge.png"; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// var map; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Initialize the Google Map. function initGoogleMap() { if (!GBrowserIsCompatible()) return; map = document.getElementById("googleMap").map = new GMap2(document.getElementById("googleMap")); map.setCenterTT(new GLatLng(0,0), 2); map.enableScrollWheelZoom(); map.addControl(new GSmallZoomControl3D(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(310,10))); map.addControl(new GMapTypeControl()); map.addControl(new GScaleControl(), new GControlPosition(G_ANCHOR_BOTTOM_LEFT, new GSize(370,10))); // map.addOverlay(new GMarker(new GLatLng(40.716666667, -74))); // document.getElementById("googleMap").innerHTML = document.getElementById("googleMap").innerHTML.replace('src="http://maps.gstatic.com/intl/de_ALL/mapfiles/poweredby.png"','src="http://maps.gstatic.com/intl/de_ALL/mapfiles/poweredby.png" id="logocontrol"'); // map.setTTMarkers(); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// GMap2.prototype.centerTT = false; GMap2.prototype.zoomendEvent = false; GMap2.prototype.moveendEvent = false; /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TwitterTrace setCenter function. Moves the center of the VISIBLE map. GMap2.prototype.setCenterTT = function(center, zoom, type) { // Eventlistener to keep the TT center point by scrooling or moving the map. if(this.zoomendEvent) GEvent.removeListener(this.zoomendEvent); if(this.moveendEvent) GEvent.removeListener(this.moveendEvent); // Moves the map to the center point that google would choose for the given location. if(center) { this.setCenter(center, zoom, type); this.centerTT=center; } else if(this.centerTT != false) this.setCenter(this.centerTT); else return; // Get the new center point for google. var newCenter=this.getCenterTT("absolute"); if(!newCenter) return; // Set new center and save the position. this.setCenter(newCenter, zoom, type); if(center) this.savePosition(); // Eventlistener to keep the TT center point by scrooling or moving the map. this.zoomendEvent=GEvent.addListener(this, "zoomend", function(oldZoom, newZoom) {this.setCenterTT();}); this.moveendEvent=GEvent.addListener(this, "moveend", function() {this.centerTT=this.getCenterTT("relative");}); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // TwitterTrace getCenter function. Calculates the center of the TT map. "Absolute" = center point for google, "Relative" = Visible center point for TT. GMap2.prototype.getCenterTT = function(type, point) { // Is window height and width available? go on : set googleCenter and return. var windowWidth = getParameter("windowWidth"); var windowHeight = getParameter("windowHeight"); if(!windowWidth || !windowHeight) return false; // "Absolute" = center point for google, "Relative" = Visible center point for TT. if(type == "absolute") var x=(windowWidth-parseFloat(document.getElementById("interface").offsetWidth))/2; else if(type == "relative") var x=(windowWidth+parseFloat(document.getElementById("interface").offsetWidth))/2; var actualCenterTT=this.fromContainerPixelToLatLng(new GPoint(x, windowHeight/2)); if(!point) return actualCenterTT; var actualCenter=document.getElementById("googleMap").map.getCenter().toString().slice(1,-1).split(","); actualCenterTT=actualCenterTT.toString().slice(1,-1).split(","); point=point.toString().slice(1,-1).split(","); var distanceX = parseFloat(actualCenterTT[0])-parseFloat(actualCenter[0]); var distanceY = parseFloat(actualCenterTT[1])-parseFloat(actualCenter[1]); var x=parseFloat(point[0])+distanceX; var y=parseFloat(point[1])+distanceY; return new GLatLng(parseFloat(point[0])+distanceX,parseFloat(point[1])+distanceY); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Parses the Marker xml GMap2.prototype.setTTMarkers = function (add){ if(add!="add") { map.clearOverlays(); map.setCenterTT(new GLatLng(0,0), 2); } GDownloadUrl("index.php?ajax=markers:googleMarkers", function(data) { var xml = GXml.parse(data); var markers = xml.documentElement.getElementsByTagName("marker"); showArrow(markers.length); for (var i = 0; i < markers.length; i++) { var markerData=new Array(); markerData["count"] = markers[i].getElementsByTagName("tweets")[0].getAttribute("count"); markerData["count"] > 1 ? markerData["type"]="blue":markerData["type"]="yellow"; if(markers[i].getAttribute("actual") == "true") markerData["type"]="red"; markerData["tweets"]=markers[i].getElementsByTagName("tweet"); map.getTTPoint(markers[i], markerData); } }); } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Tries to get a Point for a marker (recursive) GMap2.prototype.getTTPoint = function (marker, markerData) { if(marker.getAttribute("lat") && marker.getAttribute("lat") != "") { var point = new GLatLng(parseFloat(marker.getAttribute("lat")), parseFloat(marker.getAttribute("lng"))); var newMarker = map.createTTMarker(point, markerData); map.addOverlay(newMarker); if(marker.getAttribute("actual") == "true") map.setCenterTT(point, 11); } else { var geocoder = new GClientGeocoder(); var locations = marker.getElementsByTagName("location"); geocoder.getLocations(locations[0].textContent, function(response) { if (response && response.Status.code == 200) { place = response.Placemark[0]; point = new GLatLng(place.Point.coordinates[1],place.Point.coordinates[0]); if(point && place.AddressDetails.Accuracy > 0) { var newMarker = map.createTTMarker(point, markerData); map.addOverlay(newMarker); if(marker.getAttribute("actual") == "true") map.setCenterTT(point, 11); return; } } marker.getElementsByTagName("locations")[0].removeChild(locations[0]); if(locations[0]) map.getTTPoint(marker, markerData); else map.updateTweets(point, markerData["tweets"]); }); } } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // set a Marker with some Comments in a Popup GMap2.prototype.createTTMarker = function (point, markerData) { this.updateTweets(point, markerData["tweets"]); var html="
"+markerData["tweets"][0].textContent+"
"+markerData["count"]+" Tweets on this location. Last Tweet "+markerData["tweets"][0].getAttribute("created")+"
"; var newMarker = new GMarker(point, customIcons[markerData["type"]]); GEvent.addListener(newMarker, 'click', function() {newMarker.openInfoWindowHtml(html);}); return newMarker; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Updates Tweets. GMap2.prototype.updateTweets = function (point, tweets) { for(var key in tweets) if(key-0 == key && key.length>=0) { var position = document.getElementById("position"+tweets[key].getAttribute("id")); position.style.webkitAnimation="none"; position.style.webkitTranform="rotate(0deg)"; if(point) { position.src="bilder/toPosition.png"; position.title="Click to see where this has been tweeted."; position.onclick=function() { document.getElementById("googleMap").map.panTo(document.getElementById("googleMap").map.getCenterTT("absolute",point)); }; } else { position.title="No point found for this Tweet."; } } } function ajax(Url, Id, Continue, Wait, Failed) { var http; if(Wait && typeof Wait == "function") Wait(Id); try { if(typeof ActiveXObject!="undefined") http = new ActiveXObject("Microsoft.XMLHTTP"); else if(window.XMLHttpRequest) http = new XMLHttpRequest; } catch(e) { if(Failed && typeof Failed == "function") Failed(e, Id); } // alert(Url); http.open('post', Url, true); http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); http.onreadystatechange = function() { if(http.readyState == 4) { if(Continue && typeof Continue == "function") Continue(http.responseText, Id); else echo(http.responseText, Id); } } http.send(null); } /////////////////////////////////////////////////////////////////////////////////////////////////// function ajaxForm(FormId, Url, Id, Continue, Wait, Failed) { var params=""; if(document.forms[FormId]) for(var i = 0; i < document.forms[FormId].elements.length; i++) if((document.forms[FormId].elements[i].type!="radio" || document.forms[FormId].elements[i].checked==true) && !(document.forms[FormId].elements[i].type=="submit" || document.forms[FormId].elements[i].type=="button")) if(document.forms[FormId].elements[i].type=="file") params+="&"+document.forms[FormId].elements[i].name+"=FILE:"+encodeURIComponent(document.forms[FormId].elements[i].value); else if(document.forms[FormId].elements[i].type=="checkbox" && document.forms[FormId].elements[i].value == "") params+="&"+document.forms[FormId].elements[i].name+"="+encodeURIComponent(document.forms[FormId].elements[i].checked); else if(document.forms[FormId].elements[i].type!="checkbox" || document.forms[FormId].elements[i].checked == true) params+="&"+document.forms[FormId].elements[i].name+"="+encodeURIComponent(document.forms[FormId].elements[i].value); else params+="&"+document.forms[FormId].elements[i].name+"="+encodeURIComponent(false); if(Url.search("[\?]")>0) Url=Url+params; else Url="?"+params.substr(1); return ajax(Url, Id, Continue, Wait, Failed); } /////////////////////////////////////////////////////////////////////////////////////////////////// function echo(ajaxResult, Id) { if(document.getElementById(Id)) document.getElementById(Id).innerHTML = ajaxResult; } /////////////////////////////////////////////////////////////////////////////////////////////////// function ajaxConfirmation(MSG, Url, Id, Continue, Wait, Failed) { var Confirm = confirm(MSG); if(Confirm == true) return ajax(Url, Id, Continue, Wait, Failed); } /////////////////////////////////////////////////////////////////////////////////////////////////// function ajaxFormConfirmation(MSG, FormId, Url, Id, Continue, Wait, Failed) { var Confirm = confirm(MSG); if(Confirm == true) return ajaxForm(FormId, Url, Id, Continue, Wait, Failed); } function displayResult(response, id) { if(response=="done") { loader("tracing","Waiting for Twitter... Data received.","Waiting for Google..."); ajax("http://"+serverName+"?ajax=show:tweetsList","tweets",loadMarkers); } else if(response=="noUser") failure("Failure!","User not found.","Try again!"); else if(response=="noTerm") failure("Failure!","Invalid Search"); else if(response=="noData") failure("Failure!","No data received from Twitter.","Try again!"); } function loading(id) { loader("tracing","Waiting for Twitter..."); document.getElementById("tweets").innerHTML=""; } function showArrow(markersLength) { if(markersLength>0) ajax("http://"+serverName+"?ajax=show:arrowUserInfo","redArrow"); else failure("Failure!","User not found.","Try again!"); } function loader(title, line1, line2) { document.getElementById("redArrow").innerHTML="
"+(title||"")+"
"+(line1||"")+"
"+(line2||"")+"
"; } function failure(title, line1, line2) { document.getElementById("redArrow").innerHTML="\"avatar\"
"+(title||"")+"
"+(line1||"")+"
"+(line2||"")+"
"; map.setCenterTT(new GLatLng(0,0), 2); } function loadMarkers(response, id) { document.getElementById(id).innerHTML = response; setTweetLoader(); map.setTTMarkers(); } function setTweetLoader() { var tweets=document.getElementById("tweets"); for(var tweet in tweets.childNodes) if(tweets.childNodes[tweet].offsetHeight) { var height=parseFloat(tweets.childNodes[tweet].offsetHeight); var position = document.getElementById("position"+tweets.childNodes[tweet].id); position.style.top=(((height-33)/2)+1)+"px"; position.style.visibility="visible"; } }var intScroll; var startPos=new Array(); function initScroll() { document.getElementById("scrollTop").onmousedown = startScrollDown; document.getElementById("scrollBottom").onmousedown = startScrollUp; document.getElementById("scrollTop").onmouseup = document.getElementById("scrollBottom").onmouseup = stopScroll; document.getElementById("tweets").addEventListener("touchstart", touchScroll, false); document.getElementById("tweets").addEventListener("touchmove", touchScroll, false); } function startScrollUp() { scroll('up'); intScroll= setInterval("scroll('up')", 500); } function startScrollDown() { scroll('down'); intScroll= setInterval("scroll('down')", 500); } function stopScroll() { clearInterval(intScroll); } function scroll(direction) { var tweets=document.getElementById("tweets"); var newTop=0; for(var tweet in tweets.childNodes) if(tweets.childNodes[tweet].offsetHeight) { var actualScrollTop=tweets.scrollTop; if(direction =="up") tweets.scrollTop+=1; else if(direction =="down") tweets.scrollTop-=1; if(actualScrollTop == tweets.scrollTop) return; if(direction =="up" && tweets.scrollTop>=newTop) newTop+=tweets.childNodes[tweet].offsetHeight; else if(direction =="down" && tweets.scrollTop>newTop+tweets.childNodes[tweet].offsetHeight) newTop+=tweets.childNodes[tweet].offsetHeight; else if(direction != "") { move("tweets","scrollTop",newTop); return; } } } function touchScroll(event) { event.preventDefault(); if(event.type != "touchmove") { if((event.targetTouches[0].pageY-startPos["y"]) > 0) scroll('up'); else scroll('down'); } else startPos["y"]=event.targetTouches[0].pageY; } var movingInterval=false; var moveObjects=new Array(); function moving() { var movingId, Speed, did=done=false, Obj; for(movingId in moveObjects) if(movingId != "moveObjectsObj" && movingId!="moveThis") { did=false; for(attribute in moveObjects[movingId]) { if(attribute != "obj" && attribute != "moveThis" && moveObjects[movingId][attribute].target != moveObjects[movingId][attribute].position) { // Neue Position wird berechnet und zugewiesen moveObjects[movingId][attribute].position=(moveObjects[movingId][attribute].position+(moveObjects[movingId][attribute].target-moveObjects[movingId][attribute].position)*moveObjects[movingId][attribute].speed/100); // wenn ganz nahe beim ziel -> target if((moveObjects[movingId][attribute].position-moveObjects[movingId][attribute].target)<=0.33333 && (moveObjects[movingId][attribute].position-moveObjects[movingId][attribute].target)>=-0.33333 ) moveObjects[movingId][attribute].position=moveObjects[movingId][attribute].target; // attribut wird geƤndert moveObjects[movingId].obj[attribute] = moveObjects[movingId][attribute].position; // alert(moveObjects[movingId].style.left); // Wenn das bewegte objekt noch nicht Sichtbar ist, wirds sichtbar gemacht did=done=true } } // alert(movingId+";"+did); // if(did) moveObjects[movingId].style.visibility = "visible"; // if(moveObjects[movingId] && moveObjects[movingId].style.visibility != "visible") alert(movingId); } // Wenn bei diesem durchlauf keine bewegung statt gefunden hat wird der intervall beendet. if(!done) { clearInterval(movingInterval); movingInterval=false; } } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function move (id,attribute,target,start,speed,position) { if(!attribute || !id) return false; if(!moveObjects[id]) moveObjects[id] = new Object; if(!moveObjects[id][attribute]) moveObjects[id][attribute] = new Object; moveObjects[id].obj=document.getElementById(id); if(speed >= 0) moveObjects[id][attribute].speed=speed; if(!moveObjects[id][attribute].speed) moveObjects[id][attribute].speed = 20; if(start) moveObjects[id][attribute].start=start; else moveObjects[id][attribute].start = parseInt(moveObjects[id].obj[attribute]); moveObjects[id][attribute].target=target; if(!moveObjects[id][attribute].offset) moveObjects[id][attribute].offset = moveObjects[id][attribute].start; if(moveObjects[id][attribute].target=="BACK1") moveObjects[id][attribute].target=moveObjects[id][attribute].back; moveObjects[id][attribute].back = moveObjects[id][attribute].start; if(moveObjects[id][attribute].target=="BACK2") moveObjects[id][attribute].target=moveObjects[id][attribute].offset; if(position >= 0) moveObjects[id][attribute].position=position; else moveObjects[id][attribute].position=moveObjects[id][attribute].start; if(!movingInterval) movingInterval=setInterval("moving()", 20); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// Object.prototype.moveThis = function (attribute,target,start,speed,position) { move (this,attribute,target,start,speed,position); } ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// function initSearch() { if(location.href.split('#!/')[1]) ajax('http://'+serverName+'?ajax=twitter:search&source=twitter&noTweet=true&search='+location.href.split('#!/')[1],'redArrow', displayResult, loading); tweetThisUpdate(location.href.split('#!/')[1]); } function userSearch(username) { if(username) document.getElementById('searchValue').value=username; ajaxForm('search','http://'+serverName,'redArrow', displayResult, loading); username=document.getElementById('searchValue').value; location.hash='!/'+username; tweetThisUpdate(username); } function tweetThisUpdate(username) { return; if(username.substr(0,1) == '@') username=username.substring(1); var src=document.getElementById('twitterShareButton').getElementsByTagName('iframe')[0].src.toString(); document.getElementById('twitterShareButton').getElementsByTagName('iframe')[0].src=src.substring(0,src.search("&url="))+'&url=http%3A%2F%2Fwww.twitterchase.com%2F%23!%2F'+username+src.substr(src.search("&via=")); }