51 lines
1.3 KiB
JavaScript
51 lines
1.3 KiB
JavaScript
|
|
$(document).ready(function() {
|
|
var apiUrl = "/list/videos?listId=" + listId;
|
|
// console.log(apiUrl);
|
|
callPadma(apiUrl, initList);
|
|
prevSearchTerms = [];
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
var padmaVideos = [];
|
|
function initList(json) {
|
|
var videos = json.videos;
|
|
for (var v=0; v < videos.length; v++) {
|
|
var thisVideo = new padmaVideo(videos[v], v);
|
|
padmaVideos.push(thisVideo);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
|
|
|