comparison core.js @ 1564:a97e153eaecd

Started on playhead / scrubber bar. Now object in interfaceContext. Needs binding of setInterval.
author Nicholas Jillings <nickjillings@users.noreply.github.com>
date Wed, 10 Jun 2015 16:12:46 +0100
parents 4730207bcae0
children e2e39f867db3
comparison
equal deleted inserted replaced
1563:4730207bcae0 1564:a97e153eaecd
1649 node = new this.checkboxBox(element); 1649 node = new this.checkboxBox(element);
1650 } 1650 }
1651 this.commentQuestions.push(node); 1651 this.commentQuestions.push(node);
1652 return node; 1652 return node;
1653 }; 1653 };
1654
1655 this.playhead = new function()
1656 {
1657 this.object = document.createElement('div');
1658 this.object.className = 'playhead';
1659 this.object.align = 'left';
1660 var curTime = document.createElement('div');
1661 curTime.style.width = '50px';
1662 this.curTimeSpan = document.createElement('span');
1663 this.curTimeSpan.textContent = '00:00';
1664 curTime.appendChild(this.curTimeSpan);
1665 this.object.appendChild(curTime);
1666 this.scrubberTrack = document.createElement('div');
1667 this.scrubberTrack.className = 'playhead-scrub-track';
1668
1669 this.scrubberHead = document.createElement('div');
1670 this.scrubberHead.id = 'playhead-scrubber';
1671 this.scrubberTrack.appendChild(this.scrubberHead);
1672 this.object.appendChild(this.scrubberTrack);
1673
1674 this.timePerPixel = 0;
1675 this.maxTime = 0;
1676
1677 this.startPlay = function(maxTime) {
1678 //maxTime must be in seconds
1679 var width = 490; //500 - 10, 5 each side of the tracker head
1680 this.timePerPixel = maxTime/490;
1681 this.maxTime = maxTime;
1682 if (maxTime < 60) {
1683 this.curTimeSpan.textContent = '0.00';
1684 } else {
1685 this.curTimeSpan.textContent = '00:00';
1686 }
1687 };
1688
1689 this.update = function(time) {
1690 // Update the playhead position, startPlay must be called
1691 if (this.timePerPixel > 0) {
1692 var width = 490;
1693 var pix = Math.floor(width*time);
1694 this.scrubberHead.style.left = pix+'px';
1695 if (this.maxTime > 60.0) {
1696 var secs = time%60;
1697 var mins = Math.floor((time-secs)/60);
1698 secs = secs.toString();
1699 secs = secs.substr(0,2);
1700 mins = mins.toString();
1701 this.curTimeSpan.textContent = mins+':'+secs;
1702 } else {
1703 time = time.toString();
1704 this.curTimeSpan.textContent = time.substr(0,4);
1705 }
1706 }
1707 };
1708 };
1654 } 1709 }
1655 1710