var AMP = AMP || {'startup': []};
AMP.load = function() {
$.each(AMP.startup, function(i, e) {
AMP[e].call();
});
};
// http://jdbartlett.github.com/innershiv | WTFPL License
AMP.d = undefined;
AMP.r = undefined;
AMP.innershiv = function(h, u) {
if (AMP.d === undefined) {
AMP.d = document.createElement('div');
AMP.r = document.createDocumentFragment();
/*@cc_on AMP.d.style.display = 'none';@*/
}
var e = AMP.d.cloneNode(true);
/*@cc_on document.body.appendChild(e);@*/
e.innerHTML = h.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
/*@cc_on document.body.removeChild(e);@*/
if (u === false) return e.childNodes;
var f = AMP.r.cloneNode(true), i = e.childNodes.length;
while (i--) f.appendChild(e.firstChild);
return f;
};
AMP.reactions = function() {
var that = {};
that.rpp = 10;
that.fsel = true;
var html = ' \
\
\
';
/**
* relative time calculator
* @param {string} dateString twitter date string returned from Twitter API.
* @return {string} relative time like "2 minutes ago".
*/
var timeAgo = function(dateString) {
var rightNow = new Date();
var then = new Date(dateString);
if ($.browser.msie) {
// IE can't parse these crazy Ruby dates
then = Date.parse(dateString.replace(/( \+)/, ' UTC$1'));
}
var diff = rightNow - then;
var second = 1000,
minute = second * 60,
hour = minute * 60,
day = hour * 24,
week = day * 7;
if (isNaN(diff) || diff < 0) { return ''; } // return blank string if unknown
if (diff < second * 2) { return 'recién'; } // within 2 seconds
if (diff < minute) { return 'hace cerca de ' + Math.floor(diff / second) + ' segundos'; }
if (diff < minute * 2) { return 'hace cerca de 1 minuto'; }
if (diff < hour) { return 'hace cerca de ' + Math.floor(diff / minute) + ' minutos'; }
if (diff < hour * 2) { return 'hace cerca de 1 hora'; }
if (diff < day) { return 'hace cerca de ' + Math.floor(diff / hour) + ' horas'; }
if (diff > day && diff < day * 2) { return 'ayer'; }
if (diff < day * 365) { return 'hace cerca de ' + Math.floor(diff / day) + ' días'; }
else { return 'hace más de un año'; }
};
/**
* The Twitalinkahashifyer!
* http://www.dustindiaz.com/basement/ify.html
* Eg:
* ify.clean('your tweet text');
*/
var ify = {
link: function(tweet) {
return tweet.replace(/\b(((https*\:\/\/)|www\.)[^\"\']+?)(([!?,.\)]+)?(\s|$))/g, function(link, m1, m2, m3, m4) {
var http = m2.match(/w/) ? 'http://' : '';
return '' +
((m1.length > 25) ? m1.substr(0, 24) + '...' : m1) + '' + m4;
});
},
at: function(tweet) {
return tweet.replace(/\B[@@]([a-zA-Z0-9_]{1,20})/g, function(m, username) {
return '@' + username + '';
});
},
list: function(tweet) {
return tweet.replace(/\B[@@]([a-zA-Z0-9_]{1,20}\/\w+)/g, function(m, userlist) {
return '@' + userlist + '';
});
},
hash: function(tweet) {
return tweet.replace(/(^|\s+)#(\w+)/gi, function(m, before, hash) {
return before + '#' + hash + '';
});
},
clean: function(tweet) {
return this.hash(this.at(this.list(this.link(tweet))));
}
};
var create_tweet = function(twt) {
var h = html.replace(/%uimage%/g, twt.profile_image_url)
.replace(/%uname%/g, twt.from_user)
.replace(/%text%/g, ify.clean(twt.text))
.replace(/%ulink%/g, twt.from_user)
.replace(/%time%/g, timeAgo(twt.created_at))
.replace(/%reply%/g, twt.id_str);
if ((that.frst) && (that.fsel)) {
h = h.replace('%first%', 'first');
that.fsel = false;
} else {
h = h.replace('%first%', '');
}
return h;
};
var on_success = function(data, status, xhr) {
var $r = $('#reactions');
var $mr = $('#more-reactions');
var rc = data.results;
$.each(rc, function(i, e) {
$r.append(AMP.innershiv(create_tweet(e)));
});
if ((rc.length > 0) && (that.frst)) {
$('#reactions-wrap').show();
}
if (rc.length >= that.rpp) {
$mr.attr('rel', parseInt($mr.attr('rel'), 10) + 1).show();
} else {
$mr.hide();
}
};
var on_error = function(xhr, status, error) {};
var getData = function(frst) {
that.frst = frst;
var page = $('#more-reactions').attr('rel');
var url = window.location.href;
$.ajax({'url': 'http://search.twitter.com/search.json',
'async': true,
'dataType': 'jsonp',
'type': 'GET',
'data': {'q': url, 'page': page, 'rpp': that.rpp, 'result_type': 'mixed'},
'success': on_success,
'error': on_error
});
};
that.getData = getData;
return that;
};
AMP.reacciones = function() {
AMP.react = AMP.reactions();
AMP.react.getData(true);
$('#more-reactions').click(function(ev) {
ev.stopPropagation();
AMP.react.getData(false);
return false;
});
};
AMP.setup_slide_header = function() {
$('#site-title').waypoint({
handler: function(event, direction) {
if (direction == 'down') {
$('#mini-title').show();
$('#home-blogs').hide();
} else {
$('#mini-title').hide();
$('#home-blogs').show();
}
}
});
};
AMP.setup_twshare = function() {
if ($('#twshare').length == 0) { return; }
new TWTR.Widget({
version: 2,
id: 'twshare',
type: 'search',
search: 'infobae.com -bahiadigital',
interval: 30000,
title: 'infobae.com',
subject: 'Blogs de Opinión de Infobae',
width: 300,
height: 500,
theme: { shell: {background: '#ffffff', color: '#ffffff'},
tweets: {background: '#ffffff', color: '#444444', links: '#4272DB'}
},
features: {scrollbar: false, loop: true, live: true, behavior: 'default'}
}).render().start();
};
AMP.processTweet = function(tweet) {
var rgxUrl = /(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig;
var rgxUserLink = /([@])([\w]+)/ig;
var rgxSearchLink = /([#])([\w]+)/ig;
return tweet
.replace(rgxUrl, '$1')
.replace(rgxUserLink, '$1$2')
.replace(rgxSearchLink, '$1$2');
};
AMP.setup_notas = function() {
AMP.reacciones();
AMP.showAds();
};
AMP.getTalkers = function(url, count) {
tt = this;
$.getJSON('http://search.twitter.com/search.json?callback=?&rpp=' + count + '&q=%23' + url, function(data) {
$.each(data, function(i, tweets) {
if (tweets.length != undefined) {
if (tweets[0] != undefined) {
if (tweets[0].created_at != undefined) {
$('#tweetbar .twshared').show();
for (var i = 0; i < tweets.length; i++) {
var txxt = '\n';
txxt += '
' + '\n\n';
$('#twimages').append(txxt);
}
var textocantidad;
if (i == 1) {
textocantidad = i + ' persona';
} else {
textocantidad = 'últimas ' + i + ' personas';
/*
if (i <= 29) {
textocantidad = i + ' personas';
} else {
textocantidad = '+' + i + ' personas';
}
*/
}
$('#twcounter').html(textocantidad);
}
}
}
});
$('.tooltip-wrapper').tooltip();
});
};
AMP.setup_front_page = function() {
AMP.getTalkers('opinion.infobae.com', 30);
AMP.showAds();
};
AMP.setup_home_blog = function() {
AMP.showAds();
};
AMP.addEplAd = function(domID, eID, opts) {
$('#' + domID).append('');
if (!opts) { opts = {t: 2}; }
if (document.epl != undefined) {
if (opts.custF) { document.epl.setCustomAdShow(eID, opts.custF); }
document.epl.setSpace(eID, opts);
} else {
window.eplAdsArray.push(new Array(eID, opts));
}
};
AMP.showAds = function() {
if (document.epl) {
document.epl.eplInit(window.eplArgs);
} else {
return;
}
var planID = [
['hernan-alberro', '63b7b689c34b104b'],
['jacques-benillouche', 'be093f1bd7698f9a'],
['pablo-diaz-de-brito', 'a8038b1c04f75199'],
['tomas-bulat', '51ee1fb980a0f063'],
['fabian-calle', '9eec9ad7af145093'],
['fernando-cardos', '7d444ed1c6be9beb'],
['jorge-castaneda', '03e2c8792474514f'],
['dario-acevedo-carmona', 'f593a37fffc36c6d'],
['umberto-eco', '624da5046c42b2c8'],
['marcos-alan-ferreira', '1d90fbea7110f9a2'],
['martin-guevara', '55c1cfb70d788ad1'],
['sandro-magister', 'f7368623df8d3d4f'],
['carlos-alberto-montaner', '1021abb3336743f1'],
['luis-novaresio', '95c4e0b321e4da44'],
['claudia-peiro', 'f0ca3a9e65ae6014'],
['ivan-garcia-quintero', 'c4ea4006167293c4'],
['gaston-recondo', '022dd8a282e2e164'],
['gabriel-salvia', '977db9bdcac0f700'],
['daniel-sticco', 'eec0a8770b9a6fbb'],
['roberto-funes-ugarte', 'dc6793c48c304b8a']
];
var default_args = {t:1,timeout:0,ma:1,custF:null,wh:"300x500",sd:"e65b!!http://ads.e-planning.net/!countries!"};
$.each(planID, function(i, e) {
if (window.location.href.indexOf(e[0]) >= 0) {
AMP.addEplAd('epl-banner', e[1], default_args);
}
});
};
$(function() {
AMP.load();
});
%uname%
\\ \- Responder
\
\