padmaEssay/padma.links.js
2010-11-23 16:21:01 +01:00

40 lines
1.2 KiB
JavaScript

(function($) {
var PADMA_URL = padmaConfig.links_url;
$(function() {
$("a").each(function() {
var that = this;
if ($(this).attr("href") === undefined) {
return;
}
var href = $(this).attr("href");
if (href.indexOf('#') != -1) {
return;
}
$(this).attr("target", "_blank");
var link = href;
if (link.indexOf(PADMA_URL) != -1) {
$(that).addClass('padmaLink');
var linkData = parsePadmaUrl(link, PADMA_URL);
if (linkData) {
//Don't fetch data twice if video id already exists
var videoId = linkData.videoId;
var cacheVideo = padmaVideo.getFromCache(videoId);
if (cacheVideo) {
var videoObj = cacheVideo;
} else {
var videoObj = new padmaVideo(videoId);
}
// console.log(linkData);
videoObj.getAllData(setupPadmaLink, {'linkData': linkData, 'jq': that});
// v.getVideoData(setupSidenotes, {'linkData': linkData, 'jq': that});
// getPadmaData(linkData, that, {});
}
}
});
});
// D = parsePadmaUrl;
})(jQuery);