// SoundManager 2: Page Player demo, MetaData UI prototype
/*jslint white: false, onevar: true, undef: true, nomen: false, eqeqeq: true, plusplus: false, bitwise: true, newcap: true, immed: true */
/*global pagePlayer, document, window */
var Metadata = function(oSound) {
var self = this,
pl = pagePlayer,
oLI = oSound._data.oLI,
o = oLI.getElementsByTagName('ul')[0],
oItems = o.getElementsByTagName('li'),
oTemplate = document.createElement('div'),
oTemplate2 = document.createElement('div'),
oTemplate3 = document.createElement('div'),
oDuration, i;
oTemplate.innerHTML = ' ';
oTemplate.className = 'annotation';
oTemplate2.innerHTML = ' ';
oTemplate2.className = 'annotation alt';
oTemplate3.className = 'note';
this.totalTime = 0;
this.data = [];
this.data.givenDuration = null;
this.data.currentItem = null;
this.data.mainTitle = oSound._data.oLink.innerHTML;
this.strToTime = function(sTime) {
var segments = sTime.split(':'),
seconds = 0, i;
for (i=segments.length; i--;) {
seconds += parseInt(segments[i],10)*Math.pow(60,segments.length-1-i); // hours, minutes
}
return seconds;
};
// make stuff
this.createElements = function() {
var oFrag = document.createDocumentFragment(),
oNode = null,
oNodeSpan = null,
oNode2 = null, i;
for (i=0; i= metadata[i].startTimeMS && now <= metadata[i].endTimeMS) {
index = i;
break;
}
}
if (index !== metadata.currentItem) {
// update
oSound._data.oLink.innerHTML = metadata.mainTitle+' | '+metadata[index].title+'';
pl.setPageTitle(metadata[index].title+' | '+metadata.mainTitle);
metadata.currentItem = index;
}
};
this.refresh = function() {
var offset = 0,
relWidth = null,
duration = (self.data.givenDuration?self.data.givenDuration:oSound.durationEstimate), i;
for (i=0; i