added padma tooltip.js
This commit is contained in:
parent
ca9c88bb2a
commit
e16346c611
75
padma.tooltip.js
Normal file
75
padma.tooltip.js
Normal file
|
@ -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);
|
Loading…
Reference in New Issue
Block a user