/* External API ================================================== */ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { VMM.ExternalAPI = { twitter: { tweetArray: [], // VMM.ExternalAPI.twitter.getHTML(id); getHTML: function(id) { //var the_url = document.location.protocol + "//api.twitter.com/1/statuses/oembed.json?id=" + id+ "&callback=?"; var the_url = "http://api.twitter.com/1/statuses/oembed.json?id=" + id+ "&callback=?"; VMM.getJSON(the_url, VMM.ExternalAPI.twitter.onJSONLoaded); }, onJSONLoaded: function(d) { trace("TWITTER JSON LOADED"); var id = d.id; VMM.attachElement("#"+id, VMM.Util.linkify_with_twitter(d.html) ); }, // VMM.ExternalAPI.twitter.parseTwitterDate(date); parseTwitterDate: function(d) { var date = new Date(Date.parse(d)); /* var t = d.replace(/(\d{1,2}[:]\d{2}[:]\d{2}) (.*)/, '$2 $1'); t = t.replace(/(\+\S+) (.*)/, '$2 $1'); var date = new Date(Date.parse(t)).toLocaleDateString(); var time = new Date(Date.parse(t)).toLocaleTimeString(); */ return date; }, prettyParseTwitterDate: function(d) { var date = new Date(Date.parse(d)); return VMM.Util.date.prettyDate(date, true); }, // VMM.ExternalAPI.twitter.getTweets(tweets_array); getTweets: function(tweets) { var tweetArray = []; var number_of_tweets = tweets.length; for(var i = 0; i < tweets.length; i++) { var twitter_id = ""; /* FIND THE TWITTER ID ================================================== */ if (tweets[i].tweet.match("status\/")) { twitter_id = tweets[i].tweet.split("status\/")[1]; } else if (tweets[i].tweet.match("statuses\/")) { twitter_id = tweets[i].tweet.split("statuses\/")[1]; } else { twitter_id = ""; } /* FETCH THE DATA ================================================== */ var the_url = "http://api.twitter.com/1/statuses/show.json?id=" + twitter_id + "&include_entities=true&callback=?"; VMM.getJSON(the_url, function(d) { var tweet = {} /* FORMAT RESPONSE ================================================== */ var twit = "
"; var td = VMM.Util.linkify_with_twitter(d.text, "_blank"); twit += td; twit += "
"; twit += "— " + d.user.name + " (@" + d.user.screen_name + ") " + VMM.ExternalAPI.twitter.prettyParseTwitterDate(d.created_at) + "
"; var td = VMM.Util.linkify_with_twitter(d.results[i].text, "_blank"); twit += td; twit += "
"; twit += "— " + d.results[i].from_user_name + " (@" + d.results[i].from_user + ") " + VMM.ExternalAPI.twitter.prettyParseTwitterDate(d.results[i].created_at) + "
ERROR LOADING TWEET " + id + "
" ); }) .success(function() { clearTimeout(twitter_timeout); }); }, notFoundError: function(id) { trace("TWITTER JSON ERROR TIMEOUT " + id); VMM.attachElement("#twitter_" + id, "TWEET NOT FOUND " + id + "
" ); }, formatJSON: function(d) { trace("TWITTER JSON LOADED F"); trace(d); var id = d.id_str; var twit = ""; twit += " " + "" + " "; twit += " "; VMM.attachElement("#twitter_"+id.toString(), twit ); } }, //VMM.ExternalAPI.googlemaps.getMap() googlemaps: { /* //http://gsp2.apple.com/tile?api=1&style=slideshow&layers=default&lang=en_US&z={z}&x={x}&y={y}&v=9 http://maps.google.com/maps?q=chicago&hl=en&sll=41.874961,-87.619054&sspn=0.159263,0.351906&t=t&hnear=Chicago,+Cook,+Illinois&z=11&output=kml http://maps.google.com/maps/ms?msid=215143221704623082244.0004a53ad1e3365113a32&msa=0 http://maps.google.com/maps/ms?msid=215143221704623082244.0004a53ad1e3365113a32&msa=0&output=kml http://maps.google.com/maps/ms?msid=215143221704623082244.0004a21354b1a2f188082&msa=0&ll=38.719738,-9.142599&spn=0.04172,0.087976&iwloc=0004a214c0e99e2da91e0 http://maps.google.com/maps?q=Bavaria&hl=en&ll=47.597829,9.398804&spn=1.010316,2.709503&sll=37.0625,-95.677068&sspn=73.579623,173.408203&hnear=Bavaria,+Germany&t=m&z=10&output=embed http://maps.google.com/maps?q=Zernikedreef+11,+Leiden,+Nederland&hl=en&sll=37.0625,-95.677068&sspn=45.957536,93.076172&oq=zernike&hnear=Zernikedreef+11,+Leiden,+Zuid-Holland,+The+Netherlands&t=m&z=16 */ getMap: function(url, id) { var map_vars = VMM.Util.getUrlVars(url); trace(map_vars); var map_url = "http://maps.googleapis.com/maps/api/js?key=" + Aes.Ctr.decrypt(VMM.master_config.keys.google, VMM.master_config.vp, 256) + "&libraries=places&sensor=false&callback=VMM.ExternalAPI.googlemaps.onMapAPIReady"; var map = {url: url, vars: map_vars, id: id} if (VMM.master_config.googlemaps.active) { VMM.master_config.googlemaps.createMap(map); } else { VMM.master_config.googlemaps.que.push(map); if (VMM.master_config.googlemaps.api_loaded) { } else { VMM.LoadLib.js(map_url, function() { trace("Google Maps API Library Loaded"); }); } } }, onMapAPIReady: function() { VMM.master_config.googlemaps.map_active = true; VMM.master_config.googlemaps.places_active = true; VMM.ExternalAPI.googlemaps.onAPIReady(); }, onPlacesAPIReady: function() { VMM.master_config.googlemaps.places_active = true; VMM.ExternalAPI.googlemaps.onAPIReady(); }, onAPIReady: function() { if (!VMM.master_config.googlemaps.active) { if (VMM.master_config.googlemaps.map_active && VMM.master_config.googlemaps.places_active) { VMM.master_config.googlemaps.active = true; for(var i = 0; i < VMM.master_config.googlemaps.que.length; i++) { VMM.ExternalAPI.googlemaps.createMap(VMM.master_config.googlemaps.que[i]); } } } }, map_subdomains: ["", "a.", "b.", "c.", "d."], map_attribution: { "stamen": "Map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under CC BY SA.", "apple": "Map data © 2012 Apple, Imagery © 2012 Apple" }, map_providers: { "toner": { "url": "http://{S}tile.stamen.com/toner/{Z}/{X}/{Y}.png", "minZoom": 0, "maxZoom": 20, "attribution": "stamen" }, "toner-lines": { "url": "http://{S}tile.stamen.com/toner-lines/{Z}/{X}/{Y}.png", "minZoom": 0, "maxZoom": 20, "attribution": "stamen" }, "toner-labels": { "url": "http://{S}tile.stamen.com/toner-labels/{Z}/{X}/{Y}.png", "minZoom": 0, "maxZoom": 20, "attribution": "stamen" }, "sterrain": { "url": "http://{S}tile.stamen.com/terrain/{Z}/{X}/{Y}.jpg", "minZoom": 4, "maxZoom": 20, "attribution": "stamen" }, "apple": { "url": "http://gsp2.apple.com/tile?api=1&style=slideshow&layers=default&lang=en_US&z={z}&x={x}&y={y}&v=9", "minZoom": 4, "maxZoom": 20, "attribution": "apple" }, "watercolor": { "url": "http://{S}tile.stamen.com/watercolor/{Z}/{X}/{Y}.jpg", "minZoom": 3, "maxZoom": 16, "attribution": "stamen" } }, createMap: function(m) { trace(VMM.ExternalAPI.googlemaps.stamen_map_attribution); /* MAP PROVIDERS Including Stamen Maps http://maps.stamen.com/ Except otherwise noted, each of these map tile sets are © Stamen Design, under a Creative Commons Attribution (CC BY 3.0) license. ================================================== */ var map_attribution = ""; function mapProvider(name) { if (name in VMM.ExternalAPI.googlemaps.map_providers) { map_attribution = VMM.ExternalAPI.googlemaps.map_attribution[VMM.ExternalAPI.googlemaps.map_providers[name].attribution]; return VMM.ExternalAPI.googlemaps.map_providers[name]; } else { throw 'No such provider: "' + name + '"'; } } google.maps.VeriteMapType = function(name) { var provider = mapProvider(name); return google.maps.ImageMapType.call(this, { "getTileUrl": function(coord, zoom) { var index = (zoom + coord.x + coord.y) % VMM.ExternalAPI.googlemaps.map_subdomains.length; return [ provider.url .replace("{S}", VMM.ExternalAPI.googlemaps.map_subdomains[index]) .replace("{Z}", zoom) .replace("{X}", coord.x) .replace("{Y}", coord.y) .replace("{z}", zoom) .replace("{x}", coord.x) .replace("{y}", coord.y) ]; }, "tileSize": new google.maps.Size(256, 256), "name": name, "minZoom": provider.minZoom, "maxZoom": provider.maxZoom }); }; google.maps.VeriteMapType.prototype = new google.maps.ImageMapType("_"); /* Make the Map ================================================== */ var layer; if (type.of(VMM.master_config.Timeline.maptype) == "string") { layer = VMM.master_config.Timeline.maptype; } else { layer = "toner"; } var location = new google.maps.LatLng(41.875696,-87.624207); var latlong; var zoom = 11; var has_location = false; var has_zoom = false; var map_bounds; if (type.of(VMM.Util.getUrlVars(m.url)["ll"]) == "string") { has_location = true; latlong = VMM.Util.getUrlVars(m.url)["ll"].split(","); location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1])); } else if (type.of(VMM.Util.getUrlVars(m.url)["sll"]) == "string") { latlong = VMM.Util.getUrlVars(m.url)["sll"].split(","); location = new google.maps.LatLng(parseFloat(latlong[0]),parseFloat(latlong[1])); } if (type.of(VMM.Util.getUrlVars(m.url)["z"]) == "string") { has_zoom = true; zoom = parseFloat(VMM.Util.getUrlVars(m.url)["z"]); } var map_options = { zoom:zoom, disableDefaultUI: true, mapTypeControl: false, zoomControl: true, zoomControlOptions: { style: google.maps.ZoomControlStyle.SMALL, position: google.maps.ControlPosition.TOP_RIGHT }, center: location, mapTypeId: layer, mapTypeControlOptions: { mapTypeIds: [layer] } } var unique_map_id = m.id.toString() + "_gmap"; VMM.attachElement("#" + m.id, ""); var map = new google.maps.Map(document.getElementById(unique_map_id), map_options); map.mapTypes.set(layer, new google.maps.VeriteMapType(layer)); /* ATTRIBUTION ================================================== */ var map_attribution_html = ""; var td = VMM.Util.linkify_with_twitter(d.text, "_blank"); //td = td.replace(/(@([\w]+))/g,"$1"); //td = td.replace(/(#([\w]+))/g,"$1"); twit += td; twit += "