diff --git a/source/js/VMM.js b/source/js/VMM.js index 6ec4060..f28f30a 100644 --- a/source/js/VMM.js +++ b/source/js/VMM.js @@ -296,7 +296,7 @@ if (typeof VMM == 'undefined') { }; // VMM.getJSON(url, the_function); - VMM.getJSON = function(url, the_function) { + VMM.getJSON = function(url, data, callback) { if( typeof( jQuery ) != 'undefined' ){ /* CHECK FOR IE AND USE Use Microsoft XDR @@ -307,7 +307,7 @@ if (typeof VMM == 'undefined') { if (ie_url.match('^http://')){ //ie_url = ie_url.replace("http://","//"); - $.getJSON(url, the_function); + $.getJSON(url, data); } else if (ie_url.match('^https://')) { ie_url = ie_url.replace("https://","http://"); var xdr = new XDomainRequest(); @@ -319,7 +319,9 @@ if (typeof VMM == 'undefined') { xdr.send(); } } else { - $.getJSON(url, the_function); + //$.getJSON(url, data); + return jQuery.getJSON(url, data, callback); + } } @@ -1295,11 +1297,11 @@ if (typeof VMM == 'undefined') { // CREDIT if (data.credit != null && data.credit != "") { - creditElem = "
" + data.credit + "
"; + creditElem = "
" + VMM.Util.linkify_with_twitter(data.credit, "_blank") + "
"; } // CAPTION if (data.caption != null && data.caption != "") { - captionElem = "
" + data.caption + "
"; + captionElem = "
" + VMM.Util.linkify_with_twitter(data.caption, "_blank") + "
"; } // MEDIA TYPE @@ -1327,7 +1329,7 @@ if (typeof VMM == 'undefined') { } else if (m.type == "vimeo") { mediaElem = ""; } else if (m.type == "twitter"){ - mediaElem = "
Loading Tweet
"; + mediaElem = "
Loading Tweet
"; //VMM.ExternalAPI.twitter.getHTML(m.id); trace("TWITTER"); VMM.ExternalAPI.twitter.prettyHTML(m.id); @@ -1505,16 +1507,9 @@ if (typeof VMM == 'undefined') { onJSONLoaded: function(d) { trace("TWITTER JSON LOADED"); var id = d.id; - VMM.attachElement("#"+id, VMM.ExternalAPI.twitter.linkify(d.html) ); - }, - //somestring = VMM.ExternalAPI.twitter.linkify(d); - linkify: function(d) { - return d.replace(/[@]+[A-Za-z0-9-_]+/g, function(u) { - var username = u.replace("@",""); - - return u.link("http://twitter.com/"+username); - }); + 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)); @@ -1561,10 +1556,7 @@ if (typeof VMM == 'undefined') { /* FORMAT RESPONSE ================================================== */ var twit = "

"; - var td = VMM.Util.linkify(d.text); - td = td.replace(/(@([\w]+))/g,"$1"); - td = td.replace(/(#([\w]+))/g,"$1"); - //twit += VMM.Util.linkify(d.text); + var td = VMM.Util.linkify_with_twitter(d.text, "_blank"); twit += td; twit += "

"; @@ -1582,7 +1574,10 @@ if (typeof VMM == 'undefined') { var the_tweets = {tweetdata: tweetArray} VMM.fireEvent(global, "TWEETSLOADED", the_tweets); } - }); + }) + .success(function() { trace("second success"); }) + .error(function() { trace("error"); }) + .complete(function() { trace("complete"); }); } @@ -1591,8 +1586,6 @@ if (typeof VMM == 'undefined') { // VMM.ExternalAPI.twitter.getTweetSearch(search string); getTweetSearch: function(tweets, number_of_tweets) { - - var _number_of_tweets = 40; if (number_of_tweets != null && number_of_tweets != "") { _number_of_tweets = number_of_tweets; @@ -1607,9 +1600,7 @@ if (typeof VMM == 'undefined') { for(var i = 0; i < d.results.length; i++) { var tweet = {} var twit = ""; @@ -1624,32 +1615,51 @@ if (typeof VMM == 'undefined') { }, // VMM.ExternalAPI.twitter.prettyHTML(id); prettyHTML: function(id) { - - // https://api.twitter.com/1/statuses/show.json?id=164165553810976768&include_entities=true&callback=? + var id = id.toString(); + var error_obj = { + twitterid: id + }; var the_url = "http://api.twitter.com/1/statuses/show.json?id=" + id + "&include_entities=true&callback=?"; - VMM.getJSON(the_url, VMM.ExternalAPI.twitter.formatJSON); + trace("id " + id); + var twitter_timeout = setTimeout(VMM.ExternalAPI.twitter.notFoundError, 4000, id); + VMM.getJSON(the_url, VMM.ExternalAPI.twitter.formatJSON) + .error(function(jqXHR, textStatus, errorThrown) { + trace("TWITTER error"); + trace("TWITTER ERROR: " + textStatus + " " + qXHR.responseText); + VMM.attachElement("#twitter_"+id, "

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 = "

"; - var td = VMM.Util.linkify(d.text); - td = td.replace(/(@([\w]+))/g,"$1"); - td = td.replace(/(#([\w]+))/g,"$1"); + 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 += "

"; - twit += " " + "" + " "; + twit += " " + "" + " "; twit += ""; - VMM.attachElement("#"+id, twit ); + VMM.attachElement("#twitter_"+id.toString(), twit ); } diff --git a/source/js/timeline.js b/source/js/timeline.js index 34cdc55..7801628 100755 --- a/source/js/timeline.js +++ b/source/js/timeline.js @@ -1,5 +1,5 @@ /*! - Verite Timeline 0.88 + Open Timeline 0.88 Designed and built by Zach Wise digitalartwork.net Date: April 8, 2012 @@ -40,7 +40,7 @@ // @codekit-prepend "VMM.LoadLib.js"; // @codekit-prepend "bootstrap-tooltip.js"; -/* Timeline Class contained in VMM (verite) namespace +/* Open Timeline Class contained in VMM (verite) namespace ================================================== */ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') { @@ -333,14 +333,14 @@ if(typeof VMM != 'undefined' && typeof VMM.Timeline == 'undefined') { if (d.type == "tweets") { } else if (dd.type == "start") { - c._text += VMM.createElement("h2", d.headline, "start"); + c._text += VMM.createElement("h2", VMM.Util.linkify_with_twitter(d.headline, "_blank"), "start"); } else { - c._text += VMM.createElement("h3", d.headline); + c._text += VMM.createElement("h3", VMM.Util.linkify_with_twitter(d.headline, "_blank")); } } if (d.text != null && d.text != "") { _hastext = true; - c._text += VMM.createElement("p", d.text); + c._text += VMM.createElement("p", VMM.Util.linkify_with_twitter(d.text, "_blank")); } c._text = VMM.createElement("div", c._text, "container"); diff --git a/timeline.js b/timeline.js index d62f060..b9f22fe 100644 --- a/timeline.js +++ b/timeline.js @@ -296,7 +296,7 @@ if (typeof VMM == 'undefined') { }; // VMM.getJSON(url, the_function); - VMM.getJSON = function(url, the_function) { + VMM.getJSON = function(url, data, callback) { if( typeof( jQuery ) != 'undefined' ){ /* CHECK FOR IE AND USE Use Microsoft XDR @@ -307,7 +307,7 @@ if (typeof VMM == 'undefined') { if (ie_url.match('^http://')){ //ie_url = ie_url.replace("http://","//"); - $.getJSON(url, the_function); + $.getJSON(url, data); } else if (ie_url.match('^https://')) { ie_url = ie_url.replace("https://","http://"); var xdr = new XDomainRequest(); @@ -319,7 +319,9 @@ if (typeof VMM == 'undefined') { xdr.send(); } } else { - $.getJSON(url, the_function); + //$.getJSON(url, data); + return jQuery.getJSON(url, data, callback); + } } @@ -1295,11 +1297,11 @@ if (typeof VMM == 'undefined') { // CREDIT if (data.credit != null && data.credit != "") { - creditElem = "
" + data.credit + "
"; + creditElem = "
" + VMM.Util.linkify_with_twitter(data.credit, "_blank") + "
"; } // CAPTION if (data.caption != null && data.caption != "") { - captionElem = "
" + data.caption + "
"; + captionElem = "
" + VMM.Util.linkify_with_twitter(data.caption, "_blank") + "
"; } // MEDIA TYPE @@ -1327,7 +1329,7 @@ if (typeof VMM == 'undefined') { } else if (m.type == "vimeo") { mediaElem = ""; } else if (m.type == "twitter"){ - mediaElem = ""; + mediaElem = ""; //VMM.ExternalAPI.twitter.getHTML(m.id); trace("TWITTER"); VMM.ExternalAPI.twitter.prettyHTML(m.id); @@ -1505,16 +1507,9 @@ if (typeof VMM == 'undefined') { onJSONLoaded: function(d) { trace("TWITTER JSON LOADED"); var id = d.id; - VMM.attachElement("#"+id, VMM.ExternalAPI.twitter.linkify(d.html) ); - }, - //somestring = VMM.ExternalAPI.twitter.linkify(d); - linkify: function(d) { - return d.replace(/[@]+[A-Za-z0-9-_]+/g, function(u) { - var username = u.replace("@",""); - - return u.link("http://twitter.com/"+username); - }); + 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)); @@ -1561,10 +1556,7 @@ if (typeof VMM == 'undefined') { /* FORMAT RESPONSE ================================================== */ var twit = "