From e16346c611d23ba0e2a0d515c0864563a808eeef Mon Sep 17 00:00:00 2001 From: sanj Date: Wed, 1 Sep 2010 21:42:58 +0530 Subject: [PATCH] added padma tooltip.js --- padma.tooltip.js | 75 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 padma.tooltip.js diff --git a/padma.tooltip.js b/padma.tooltip.js new file mode 100644 index 0000000..bc966a6 --- /dev/null +++ b/padma.tooltip.js @@ -0,0 +1,75 @@ + + +(function($) { + var PADMA_URL = "http://pad.ma/"; + $(function() { + $("a").each(function() { + var that = this; + var link = $(this).attr("href"); + if (link.indexOf(PADMA_URL) != -1) { + var linkData = parsePadmaUrl(link); + if (linkData) { + console.log(linkData); + var v = new padmaVideo(linkData.videoId); + v.getAllData(setupPadmaLink, {'linkData': linkData, 'jq': that}); +// getPadmaData(linkData, that, {}); + } + } + }); + }); + + + +/* +Gives a bunch of data parsed from a pad.ma url + Returns: + { + 'videoId': string, id of pad.ma video + 'type': string, type of link -- info, editor, layer, tcRange or tc. + 'layerId': string, id of layer, (if type=="layer") + 'tcIn': timecode, in npt format (if type == "tcRange") + 'tc': timecode, in npt format (if type == 'tc') + } +*/ + + function parsePadmaUrl(link) { + var linkStr = link.replace(PADMA_URL, ""); + console.log(linkStr); + var r = { }; + if (linkStr.charAt(0) == 'V') { + var idRegex = /V(.{1,7})/; + var idMatch = linkStr.match(idRegex); + console.log("match", idMatch); + r.videoId = idMatch[0]; + var postIdStr = linkStr.replace(idMatch[0] + "/", ''); + if (postIdStr == 'info' || postIdStr == '') { + r.type = 'info'; + return r; + } else if (postIdStr == 'editor') { + r.type = 'editor'; + return r; + } else if (postIdStr.charAt(0) == 'L') { + r.type = 'layer'; + r.layerId = postIdStr; + return r; + } else if (postIdStr.indexOf("-") != -1) { + var tcs = postIdStr.split("-"); + r.type = 'tcRange'; + r.tcIn = tcs[0]; + r.tcOut = tcs[1]; + return r; + } else { + r.type = 'tc'; + r.tc = postIdStr; + return r; + } + } else if (linkStr.substring(0,7) == 'find?l=') { + r.type = 'list'; + r.listId = linkStr.match(/l\=(L.*?)$/)[1]; + return r; + } else { + return false; + } + } + D = parsePadmaUrl; +})(jQuery);