spacing, add a test for minTime being after maxTime
parent
d857c2c98a
commit
4240dc4bde
|
@ -49,28 +49,28 @@ function SetImageSource( monId, time ) {
|
|||
if ( liveMode == 1 ) {
|
||||
return monitorImageObject[monId].src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
|
||||
|
||||
} else {
|
||||
for ( var i=0, eIdlength = eId.length; i < eIdlength; i++ ) {
|
||||
// Search for the event matching this time. Would be more efficient if we had events indexed by monitor
|
||||
if ( eMonId[i] == monId && time >= eStartSecs[i] && time <= eEndSecs[i] ) {
|
||||
var duration = eEndSecs[i]-eStartSecs[i];
|
||||
var frame = parseInt((time - eStartSecs[i])/(duration)*eventFrames[i])+1;
|
||||
var storage = Storage[eStorageId[i]];
|
||||
if ( storage.ServerId ) {
|
||||
var server = Servers[storage.ServerId];
|
||||
if ( server ) {
|
||||
//console.log( server.Hostname + " for event " + eId[i] );
|
||||
return location.protocol + '//' + server.Hostname + '/index.php?view=image&eid=' + eId[i] + '&fid='+frame + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
} else {
|
||||
console.log("No server found for " + storage.ServerId );
|
||||
}
|
||||
}
|
||||
//console.log("No storage found for " + eStorageId[i] );
|
||||
return "index.php?view=image&eid=" + eId[i] + '&fid='+frame + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
}
|
||||
} // end for
|
||||
return "no data";
|
||||
}
|
||||
|
||||
for ( var i=0, eIdlength = eId.length; i < eIdlength; i++ ) {
|
||||
// Search for the event matching this time. Would be more efficient if we had events indexed by monitor
|
||||
if ( eMonId[i] == monId && time >= eStartSecs[i] && time <= eEndSecs[i] ) {
|
||||
var duration = eEndSecs[i]-eStartSecs[i];
|
||||
var frame = parseInt((time - eStartSecs[i])/(duration)*eventFrames[i])+1;
|
||||
var storage = Storage[eStorageId[i]];
|
||||
if ( storage.ServerId ) {
|
||||
var server = Servers[storage.ServerId];
|
||||
if ( server ) {
|
||||
//console.log( server.Hostname + " for event " + eId[i] );
|
||||
return location.protocol + '//' + server.Hostname + '/index.php?view=image&eid=' + eId[i] + '&fid='+frame + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
} else {
|
||||
console.log("No server found for " + storage.ServerId );
|
||||
}
|
||||
}
|
||||
//console.log("No storage found for " + eStorageId[i] );
|
||||
return "index.php?view=image&eid=" + eId[i] + '&fid='+frame + "&width=" + monitorCanvasObj[monId].width + "&height=" + monitorCanvasObj[monId].height;
|
||||
}
|
||||
} // end for
|
||||
return "no data";
|
||||
}
|
||||
|
||||
// callback when loading an image. Will load itself to the canvas, or draw no data
|
||||
|
@ -164,7 +164,7 @@ function loadImage2Monitor( monId, url ) {
|
|||
|
||||
function timerFire() {
|
||||
// See if we need to reschedule
|
||||
if ( currentDisplayInterval != timerInterval || currentSpeed == 0 ) {
|
||||
if ( ( currentDisplayInterval != timerInterval ) || ( currentSpeed == 0 ) ) {
|
||||
// zero just turn off interrupts
|
||||
clearInterval(timerObj);
|
||||
timerInterval=currentDisplayInterval;
|
||||
|
@ -335,60 +335,61 @@ function drawGraph() {
|
|||
}
|
||||
|
||||
function redrawScreen() {
|
||||
if ( liveMode == 1 ) {
|
||||
if ( liveMode == 1 ) {
|
||||
// if we are not in live view switch to history -- this has to come before fit in case we re-establish the timeline
|
||||
$('DateTimeDiv').style.display="none";
|
||||
$('SpeedDiv').style.display="none";
|
||||
$('timelinediv').style.display="none";
|
||||
$('live').innerHTML="History";
|
||||
$('zoomin').style.display="none";
|
||||
$('zoomout').style.display="none";
|
||||
$('panleft').style.display="none";
|
||||
$('panright').style.display="none";
|
||||
if ($('downloadVideo')) $('downloadVideo').style.display="none";
|
||||
$('DateTimeDiv').style.display="none";
|
||||
$('SpeedDiv').style.display="none";
|
||||
$('timelinediv').style.display="none";
|
||||
$('live').innerHTML="History";
|
||||
$('zoomin').style.display="none";
|
||||
$('zoomout').style.display="none";
|
||||
$('panleft').style.display="none";
|
||||
$('panright').style.display="none";
|
||||
if ($('downloadVideo')) $('downloadVideo').style.display="none";
|
||||
|
||||
} else {
|
||||
} else {
|
||||
// switch out of liveview mode
|
||||
$('DateTimeDiv').style.display="inline";
|
||||
$('SpeedDiv').style.display="inline";
|
||||
$('SpeedDiv').style.display="inline-flex";
|
||||
$('timelinediv').style.display=null;
|
||||
$('live').innerHTML="Live";
|
||||
$('zoomin').style.display="inline";
|
||||
$('zoomin').style.display="inline-flex";
|
||||
$('zoomout').style.display="inline";
|
||||
$('zoomout').style.display="inline-flex";
|
||||
$('panleft').style.display="inline";
|
||||
$('panleft').style.display="inline-flex";
|
||||
$('panright').style.display="inline";
|
||||
$('panright').style.display="inline-flex";
|
||||
if ($('downloadVideo')) $('downloadVideo').style.display="inline";
|
||||
}
|
||||
$('DateTimeDiv').style.display="inline";
|
||||
$('DateTimeDiv').style.display="inline-flex";
|
||||
$('SpeedDiv').style.display="inline";
|
||||
$('SpeedDiv').style.display="inline-flex";
|
||||
$('timelinediv').style.display=null;
|
||||
$('live').innerHTML="Live";
|
||||
$('zoomin').style.display="inline";
|
||||
$('zoomin').style.display="inline-flex";
|
||||
$('zoomout').style.display="inline";
|
||||
$('zoomout').style.display="inline-flex";
|
||||
$('panleft').style.display="inline";
|
||||
$('panleft').style.display="inline-flex";
|
||||
$('panright').style.display="inline";
|
||||
$('panright').style.display="inline-flex";
|
||||
if ($('downloadVideo')) $('downloadVideo').style.display="inline";
|
||||
}
|
||||
|
||||
if ( fitMode == 1 ) {
|
||||
$('ScaleDiv').style.display="none";
|
||||
$('fit').innerHTML="Scale";
|
||||
var vh=window.innerHeight;
|
||||
var vw=window.innerWidth;
|
||||
var pos=$('monitors').getPosition();
|
||||
var mh=(vh - pos.y - $('fps').getSize().y);
|
||||
$('monitors').setStyle('height',mh.toString() + "px"); // leave a small gap at bottom
|
||||
if(maxfit2($('monitors').getSize().x,$('monitors').getSize().y) == 0) /// if we fail to fix we back out of fit mode -- ??? This may need some better handling
|
||||
fitMode=1-fitMode;
|
||||
} else {
|
||||
// switch out of fit mode
|
||||
// if we fit, then monitors were absolutely positioned already (or will be) otherwise release them to float
|
||||
for( var i=0; i<numMonitors; i++ )
|
||||
monitorCanvasObj[monitorPtr[i]].style.position="";
|
||||
$('monitors').setStyle('height',"auto");
|
||||
$('ScaleDiv').style.display="inline";
|
||||
$('ScaleDiv').style.display="inline-flex";
|
||||
$('fit').innerHTML="Fit";
|
||||
setScale(currentScale);
|
||||
}
|
||||
drawGraph();
|
||||
outputUpdate(currentTimeSecs);
|
||||
timerFire(); // force a fire in case it's not timing
|
||||
if ( fitMode == 1 ) {
|
||||
$('ScaleDiv').style.display="none";
|
||||
$('fit').innerHTML="Scale";
|
||||
var vh=window.innerHeight;
|
||||
var vw=window.innerWidth;
|
||||
var pos=$('monitors').getPosition();
|
||||
var mh=(vh - pos.y - $('fps').getSize().y);
|
||||
$('monitors').setStyle('height',mh.toString() + "px"); // leave a small gap at bottom
|
||||
if(maxfit2($('monitors').getSize().x,$('monitors').getSize().y) == 0) /// if we fail to fix we back out of fit mode -- ??? This may need some better handling
|
||||
fitMode=1-fitMode;
|
||||
} else {
|
||||
// switch out of fit mode
|
||||
// if we fit, then monitors were absolutely positioned already (or will be) otherwise release them to float
|
||||
for( var i=0; i<numMonitors; i++ )
|
||||
monitorCanvasObj[monitorPtr[i]].style.position="";
|
||||
$('monitors').setStyle('height',"auto");
|
||||
$('ScaleDiv').style.display="inline";
|
||||
$('ScaleDiv').style.display="inline-flex";
|
||||
$('fit').innerHTML="Fit";
|
||||
setScale(currentScale);
|
||||
}
|
||||
drawGraph();
|
||||
outputUpdate(currentTimeSecs);
|
||||
timerFire(); // force a fire in case it's not timing
|
||||
}
|
||||
|
||||
function outputUpdate(time) {
|
||||
|
@ -401,21 +402,21 @@ function outputUpdate(time) {
|
|||
|
||||
/// Found this here: http://stackoverflow.com/questions/55677/how-do-i-get-the-coordinates-of-a-mouse-click-on-a-canvas-element
|
||||
function relMouseCoords(event){
|
||||
var totalOffsetX = 0;
|
||||
var totalOffsetY = 0;
|
||||
var canvasX = 0;
|
||||
var canvasY = 0;
|
||||
var currentElement = this;
|
||||
var totalOffsetX = 0;
|
||||
var totalOffsetY = 0;
|
||||
var canvasX = 0;
|
||||
var canvasY = 0;
|
||||
var currentElement = this;
|
||||
|
||||
do {
|
||||
totalOffsetX += currentElement.offsetLeft - currentElement.scrollLeft;
|
||||
totalOffsetY += currentElement.offsetTop - currentElement.scrollTop;
|
||||
} while(currentElement = currentElement.offsetParent);
|
||||
do {
|
||||
totalOffsetX += currentElement.offsetLeft - currentElement.scrollLeft;
|
||||
totalOffsetY += currentElement.offsetTop - currentElement.scrollTop;
|
||||
} while(currentElement = currentElement.offsetParent);
|
||||
|
||||
canvasX = event.pageX - totalOffsetX;
|
||||
canvasY = event.pageY - totalOffsetY;
|
||||
canvasX = event.pageX - totalOffsetX;
|
||||
canvasY = event.pageY - totalOffsetY;
|
||||
|
||||
return {x:canvasX, y:canvasY}
|
||||
return {x:canvasX, y:canvasY}
|
||||
}
|
||||
HTMLCanvasElement.prototype.relMouseCoords = relMouseCoords;
|
||||
|
||||
|
@ -476,7 +477,8 @@ function setSpeed( speed_index ) {
|
|||
speedIndex = speed_index;
|
||||
playSecsperInterval = Math.floor( 1000 * currentSpeed * currentDisplayInterval ) / 1000000;
|
||||
showSpeed(speed_index);
|
||||
if ( timerInterval != currentDisplayInterval || currentSpeed == 0 ) timerFire(); // if the timer isn't firing we need to trigger it to update
|
||||
if ( timerInterval != currentDisplayInterval ) timerFire(); // if the timer isn't firing we need to trigger it to update
|
||||
//if ( (timerInterval != currentDisplayInterval || currentSpeed == 0 ) timerFire(); // if the timer isn't firing we need to trigger it to update
|
||||
}
|
||||
|
||||
function setLive(value) {
|
||||
|
@ -734,6 +736,20 @@ function clickMonitor(event,monId) {
|
|||
}
|
||||
|
||||
function changeDateTime(e) {
|
||||
var minTime_element = $j('#minTime');
|
||||
var maxTime_element = $j('#maxTime');
|
||||
|
||||
var minTime = moment(minTime_element.val());
|
||||
var maxTime = moment(maxTime_element.val());
|
||||
if ( minTime.isAfter(maxTime) ) {
|
||||
maxTime_element.parent().addClass('has-error');
|
||||
console.log("maxTime is less than mintime");
|
||||
return; // Don't reload because we have invalid datetime filter.
|
||||
} else {
|
||||
console.log("maxTime is greater than mintime");
|
||||
maxTime_element.parent().removeClass('has-error');
|
||||
}
|
||||
|
||||
var minStr = "&minTime="+($j('#minTime')[0].value);
|
||||
var maxStr = "&maxTime="+($j('#maxTime')[0].value);
|
||||
|
||||
|
@ -798,6 +814,6 @@ function initPage() {
|
|||
}
|
||||
});
|
||||
}
|
||||
window.addEventListener("resize",redrawScreen);
|
||||
window.addEventListener("resize",redrawScreen,{passive:true});
|
||||
// Kick everything off
|
||||
window.addEvent( 'domready', initPage );
|
||||
|
|
Loading…
Reference in New Issue