110 lines
2.3 KiB
JavaScript
110 lines
2.3 KiB
JavaScript
function setVODRecordingBadgeText(text, title) {
|
|
chrome.browserAction.setBadgeBackgroundColor({
|
|
color: [203, 0, 15, 255]
|
|
});
|
|
|
|
chrome.browserAction.setBadgeText({
|
|
text: text
|
|
});
|
|
|
|
chrome.browserAction.setTitle({
|
|
title: title && title.length ? title + ' duration' : 'Record Screen'
|
|
});
|
|
}
|
|
|
|
function msToTime(s) {
|
|
function addZ(n) {
|
|
return (n < 10 ? '0' : '') + n;
|
|
}
|
|
|
|
var ms = s % 1000;
|
|
s = (s - ms) / 1000;
|
|
var secs = s % 60;
|
|
s = (s - secs) / 60;
|
|
var mins = s % 60;
|
|
var hrs = (s - mins) / 60;
|
|
|
|
return addZ(hrs) + ':' + addZ(mins) + ':' + addZ(secs) + '.' + ms;
|
|
}
|
|
|
|
function convertTime(miliseconds) {
|
|
var totalSeconds = Math.floor(miliseconds / 1000);
|
|
var minutes = Math.floor(totalSeconds / 60);
|
|
var seconds = totalSeconds - minutes * 60;
|
|
|
|
minutes += '';
|
|
seconds += '';
|
|
|
|
if (minutes.length === 1) {
|
|
// minutes = '0' + minutes;
|
|
}
|
|
|
|
if (seconds.length === 1) {
|
|
seconds = '0' + seconds;
|
|
}
|
|
|
|
return minutes + ':' + seconds;
|
|
}
|
|
|
|
|
|
var initialTime, timer;
|
|
|
|
function checkTime() {
|
|
if (!initialTime || !isRecording) return;
|
|
var timeDifference = Date.now() - initialTime;
|
|
var formatted = convertTime(timeDifference);
|
|
setBadgeText(formatted);
|
|
|
|
chrome.browserAction.setTitle({
|
|
title: 'Recording duration: ' + formatted
|
|
});
|
|
}
|
|
|
|
function setBadgeText(text) {
|
|
chrome.browserAction.setBadgeBackgroundColor({
|
|
color: [255, 0, 0, 255]
|
|
});
|
|
|
|
chrome.browserAction.setBadgeText({
|
|
text: text + ''
|
|
});
|
|
}
|
|
|
|
|
|
var images = ['recordRTC-progress-1.png', 'recordRTC-progress-2.png', 'recordRTC-progress-3.png', 'recordRTC-progress-4.png', 'recordRTC-progress-5.png'];
|
|
var imgIndex = 0;
|
|
var reverse = false;
|
|
|
|
function onRecording() {
|
|
if(!isRecording) return;
|
|
|
|
chrome.browserAction.setIcon({
|
|
path: 'images/' + images[imgIndex]
|
|
});
|
|
|
|
if (!reverse) {
|
|
imgIndex++;
|
|
|
|
if (imgIndex > images.length - 1) {
|
|
imgIndex = images.length - 1;
|
|
reverse = true;
|
|
}
|
|
} else {
|
|
imgIndex--;
|
|
|
|
if (imgIndex < 0) {
|
|
imgIndex = 1;
|
|
reverse = false;
|
|
}
|
|
}
|
|
|
|
if (isRecording) {
|
|
setTimeout(onRecording, 800);
|
|
return;
|
|
}
|
|
|
|
chrome.browserAction.setIcon({
|
|
path: 'images/main-icon.png'
|
|
});
|
|
}
|