2010-07-12 19:09:02 +00:00
|
|
|
|
2009-06-14 14:51:10 +00:00
|
|
|
$(document).ready(function() {
|
|
|
|
var apiUrl = "/list/videos?listId=" + listId;
|
2010-07-15 00:02:35 +00:00
|
|
|
// console.log(apiUrl);
|
2009-06-14 14:51:10 +00:00
|
|
|
callPadma(apiUrl, initList);
|
2009-06-15 00:34:10 +00:00
|
|
|
prevSearchTerms = [];
|
2010-07-13 12:08:50 +00:00
|
|
|
});
|
2009-06-14 14:51:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var padmaVideos = [];
|
|
|
|
function initList(json) {
|
|
|
|
var videos = json.videos;
|
2010-07-12 19:09:02 +00:00
|
|
|
for (var v=0; v < videos.length; v++) {
|
2009-06-14 14:51:10 +00:00
|
|
|
var thisVideo = new padmaVideo(videos[v], v);
|
|
|
|
padmaVideos.push(thisVideo);
|
|
|
|
}
|
2010-07-13 12:08:50 +00:00
|
|
|
}
|
2009-06-15 00:34:10 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns time-code in npt format from pos in miliseconds
|
|
|
|
* @param {Int} pos Position in miliseconds
|
|
|
|
* @returns {String} Time-code in npt format.
|
|
|
|
*/
|
|
|
|
function ms2npt(pos) {
|
|
|
|
var h = Math.floor(pos / 3600000);
|
|
|
|
var m = Math.floor(pos % 3600000 / 60000);
|
|
|
|
var s = Math.floor(pos % 60000 / 1000);
|
|
|
|
var ms = pos % 1000;
|
|
|
|
return h.toString().pad('0', 2) + ':' + m.toString().pad('0', 2) + ':' + s.toString().pad('0', 2) + '.' + ms.toString().pad('0', 3);
|
|
|
|
// return strpad(h.toString(), '0', 2, 'left') + ':' + strpad(m.toString(), '0', 2, 'left') + ':' + strpad(s.toString(), '0', 2, 'left') + '.' + strpad(ms.toString(), '0', 3, 'left');
|
|
|
|
}
|
|
|
|
|
|
|
|
String.prototype.pad = function(pad, len, dir) {
|
|
|
|
if (typeof(dir) == 'undefined')
|
|
|
|
dir = 'left';
|
|
|
|
var str = this;
|
|
|
|
while (str.length < len) {
|
|
|
|
if (dir == 'left')
|
|
|
|
str = pad + str;
|
|
|
|
else if (dir == 'right')
|
|
|
|
str = str + pad;
|
|
|
|
}
|
|
|
|
return str;
|
|
|
|
}
|
|
|
|
|
2010-07-12 19:09:02 +00:00
|
|
|
|