/* External API ================================================== */ if(typeof VMM != 'undefined' && typeof VMM.ExternalAPI == 'undefined') { VMM.ExternalAPI = { pushQues: function() { if (VMM.master_config.googlemaps.active) { VMM.ExternalAPI.googlemaps.pushQue(); } if (VMM.master_config.youtube.active) { VMM.ExternalAPI.youtube.pushQue(); } if (VMM.master_config.soundcloud.active) { VMM.ExternalAPI.soundcloud.pushQue(); } if (VMM.master_config.googledocs.active) { VMM.ExternalAPI.googledocs.pushQue(); } if (VMM.master_config.googleplus.active) { VMM.ExternalAPI.googleplus.pushQue(); } if (VMM.master_config.wikipedia.active) { VMM.ExternalAPI.wikipedia.pushQue(); } if (VMM.master_config.vimeo.active) { VMM.ExternalAPI.vimeo.pushQue(); } }, twitter: { tweetArray: [], 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) ); }, 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.Date.prettyDate(date, true); }, 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(d) { clearTimeout(twitter_timeout); if (secondary) { VMM.ExternalAPI.twitter.secondaryMedia(d); } }); }, notFoundError: function(id) { trace("TWITTER JSON ERROR TIMEOUT " + id); VMM.attachElement("#twitter_" + id, "Error loading tweet: " + id + "
" ); // CHECK RATE STATUS VMM.getJSON("http://api.twitter.com/1/account/rate_limit_status.json", function(d) { trace("REMAINING TWITTER API CALLS " + d.remaining_hits); trace("TWITTER RATE LIMIT WILL RESET AT " + d.reset_time); var mes = ""; if (d.remaining_hits == 0) { mes = "You've reached the maximum number of tweets you can load in an hour.
"; mes += "You can view tweets again starting at:
" + d.reset_time + "
Tweet " + id + " was not found.
"; } VMM.attachElement("#twitter_" + id, "" + mes + "" ); }); }, formatJSON: function(d) { var id = d.id_str; var twit = ""; //twit += " " + "" + " "; twit += " "; if (typeof d.entities.media != 'undefined') { if (d.entities.media[0].type == "photo") { twit += "" } } VMM.attachElement("#twitter_"+id.toString(), twit ); VMM.attachElement("#text_thumb_"+id.toString(), d.text ); }, }, googlemaps: { get: function(url, id) { var timer, api_key, map_vars; map_vars = VMM.Util.getUrlVars(url); if (VMM.master_config.Timeline.api_keys.google != "") { api_key = VMM.master_config.Timeline.api_keys.google; } else { api_key = Aes.Ctr.decrypt(VMM.master_config.api_keys_master.google, VMM.master_config.vp, 256); } var map_url = "http://maps.googleapis.com/maps/api/js?key=" + api_key + "&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.que.push(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"); }); } } }, create: function(m) { var map_attribution = ""; var layer; var map; 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 { if (VMM.ExternalAPI.googlemaps.defaultType(name)) { trace("GOOGLE MAP DEFAULT TYPE"); return google.maps.MapTypeId[name.toUpperCase()]; } else { trace("Not a maptype: " + name ); } } } google.maps.VeriteMapType = function(name) { if (VMM.ExternalAPI.googlemaps.defaultType(name)) { return google.maps.MapTypeId[name.toUpperCase()]; } else { 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 ================================================== */ if (type.of(VMM.master_config.Timeline.maptype) == "string") { if (VMM.ExternalAPI.googlemaps.defaultType(VMM.master_config.Timeline.maptype)) { layer = google.maps.MapTypeId[VMM.master_config.Timeline.maptype.toUpperCase()]; } else { 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); if (VMM.ExternalAPI.googlemaps.defaultType(VMM.master_config.Timeline.maptype)) { } else { 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 += "
" + a_data.object.attachments[k].content + "
"; g_attachments += ""; g_attachments += "" + a_data.object.attachments[k].content + "
"; g_attachments += ""; g_attachments += "Wikipedia entry unable to load using Internet Explorer 8 or below.
"; VMM.attachElement("#"+api_obj.id, temp_text ); } VMM.getJSON(the_url, function(d) { if (d.query) { var wiki_extract, wiki_title, _wiki = "", wiki_text = "", wiki_number_of_paragraphs = 1, wiki_text_array = []; wiki_extract = VMM.Util.getObjectAttributeByIndex(d.query.pages, 0).extract; wiki_title = VMM.Util.getObjectAttributeByIndex(d.query.pages, 0).title; if (wiki_extract.match("")) { wiki_text_array = wiki_extract.split("
"); } else { wiki_text_array.push(wiki_extract); } for(var i = 0; i < wiki_text_array.length; i++) { if (i+1 <= wiki_number_of_paragraphs && i+1 < wiki_text_array.length) { wiki_text += "
" + wiki_text_array[i+1]; } } _wiki = "