more fixes
This commit is contained in:
parent
892f3a06c7
commit
f87a89a5ce
|
@ -88,6 +88,9 @@ function loadImage2Monitor(monId,url) {
|
||||||
} else {
|
} else {
|
||||||
if ( monitorImageObject[monId].src == url ) return; // do nothing if it's the same
|
if ( monitorImageObject[monId].src == url ) return; // do nothing if it's the same
|
||||||
if ( url == 'no data' ) {
|
if ( url == 'no data' ) {
|
||||||
|
if ( ! monitorCanvasCtx[monId] ) {
|
||||||
|
alert("No ctx for " + monId);
|
||||||
|
} else {
|
||||||
monitorCanvasCtx[monId].fillStyle="white";
|
monitorCanvasCtx[monId].fillStyle="white";
|
||||||
monitorCanvasCtx[monId].fillRect(0,0,monitorCanvasObj[monId].width,monitorCanvasObj[monId].height);
|
monitorCanvasCtx[monId].fillRect(0,0,monitorCanvasObj[monId].width,monitorCanvasObj[monId].height);
|
||||||
var textSize=monitorCanvasObj[monId].width * 0.15;
|
var textSize=monitorCanvasObj[monId].width * 0.15;
|
||||||
|
@ -96,6 +99,7 @@ function loadImage2Monitor(monId,url) {
|
||||||
monitorCanvasCtx[monId].fillStyle="black";
|
monitorCanvasCtx[monId].fillStyle="black";
|
||||||
var textWidth = monitorCanvasCtx[monId].measureText(text).width;
|
var textWidth = monitorCanvasCtx[monId].measureText(text).width;
|
||||||
monitorCanvasCtx[monId].fillText(text,monitorCanvasObj[monId].width/2 - textWidth/2,monitorCanvasObj[monId].height/2);
|
monitorCanvasCtx[monId].fillText(text,monitorCanvasObj[monId].width/2 - textWidth/2,monitorCanvasObj[monId].height/2);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
monitorLoading[monId]=true;
|
monitorLoading[monId]=true;
|
||||||
monitorLoadStartTimems[monId]=new Date().getTime();
|
monitorLoadStartTimems[monId]=new Date().getTime();
|
||||||
|
@ -655,37 +659,41 @@ function maxfit2(divW, divH)
|
||||||
|
|
||||||
// >>>>>>>>>>>>>>>> Handles individual monitor clicks and navigation to the standard event/watch display
|
// >>>>>>>>>>>>>>>> Handles individual monitor clicks and navigation to the standard event/watch display
|
||||||
|
|
||||||
function showOneMonitor(monId) // link out to the normal view of one event's data
|
function showOneMonitor(monId) {
|
||||||
{
|
// link out to the normal view of one event's data
|
||||||
// We know the monitor, need to determine the event based on current time
|
// We know the monitor, need to determine the event based on current time
|
||||||
var url;
|
var url;
|
||||||
if(liveMode!=0) url="?view=watch&mid=" + monId.toString();
|
if ( liveMode != 0 )
|
||||||
|
url="?view=watch&mid=" + monId.toString();
|
||||||
else
|
else
|
||||||
for(var i=0; i<eId.length; i++)
|
for ( var i=0, len=eId.length; i<len; i++ ) {
|
||||||
if ( eMonId[i] == monId && currentTimeSecs >= eStartSecs[i] && currentTimeSecs <= eEndSecs[i] )
|
if ( eMonId[i] == monId && currentTimeSecs >= eStartSecs[i] && currentTimeSecs <= eEndSecs[i] )
|
||||||
url="?view=event&eid=" + eId[i] + '&fid=' + parseInt(Math.max(1, Math.min(eventFrames[i], eventFrames[i] * (currentTimeSecs - eStartSecs[i]) / (eEndSecs[i] - eStartSecs[i] + 1) ) ));
|
url="?view=event&eid=" + eId[i] + '&fid=' + parseInt(Math.max(1, Math.min(eventFrames[i], eventFrames[i] * (currentTimeSecs - eStartSecs[i]) / (eEndSecs[i] - eStartSecs[i] + 1) ) ));
|
||||||
|
break;
|
||||||
|
}
|
||||||
createPopup(url, 'zmEvent', 'event', monitorWidth[eMonId[i]], monitorHeight[eMonId[i]]);
|
createPopup(url, 'zmEvent', 'event', monitorWidth[eMonId[i]], monitorHeight[eMonId[i]]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function zoom(monId,scale)
|
function zoom(monId,scale) {
|
||||||
{
|
|
||||||
var lastZoomMonPriorScale = monitorZoomScale[monId];
|
var lastZoomMonPriorScale = monitorZoomScale[monId];
|
||||||
monitorZoomScale[monId] *= scale;
|
monitorZoomScale[monId] *= scale;
|
||||||
if(redrawScreen()==0) // failure here is probably because we zoomed too far
|
if ( redrawScreen() == 0 ) {// failure here is probably because we zoomed too far
|
||||||
{
|
|
||||||
monitorZoomScale[monId] = lastZoomMonPriorScale;
|
monitorZoomScale[monId] = lastZoomMonPriorScale;
|
||||||
alert("You can't zoom that far -- rolling back");
|
alert("You can't zoom that far -- rolling back");
|
||||||
redrawScreen(); // put things back and hope it works
|
redrawScreen(); // put things back and hope it works
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function clickMonitor(event,monId)
|
function clickMonitor(event,monId) {
|
||||||
{
|
var monitor_element = $("Monitor"+monId.toString());
|
||||||
var pos_x = event.offsetX ? (event.offsetX) : event.pageX - $("Monitor"+monId.toString()).offsetLeft;
|
var pos_x = event.offsetX ? (event.offsetX) : event.pageX - monitor_element.offsetLeft;
|
||||||
var pos_y = event.offsetY ? (event.offsetY) : event.pageY - $("Monitor"+monId.toString()).offsetTop;
|
var pos_y = event.offsetY ? (event.offsetY) : event.pageY - monitor_element.offsetTop;
|
||||||
if(pos_x < $("Monitor"+monId.toString()).width/4 && pos_y < $("Monitor"+monId.toString()).height/4) zoom(monId,1.15);
|
if ( pos_x < monitor_element.width/4 && pos_y < monitor_element.height/4 )
|
||||||
else if(pos_x > $("Monitor"+monId.toString()).width * 3/4 && pos_y < $("Monitor"+monId.toString()).height/4) zoom(monId,1/1.15);
|
zoom(monId,1.15);
|
||||||
else showOneMonitor(monId);
|
else if ( pos_x > monitor_element.width * 3/4 && pos_y < monitor_element.height/4 )
|
||||||
|
zoom(monId,1/1.15);
|
||||||
|
else
|
||||||
|
showOneMonitor(monId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,10 +702,21 @@ function clickMonitor(event,monId)
|
||||||
function initPage() {
|
function initPage() {
|
||||||
canvas=$("timeline");
|
canvas=$("timeline");
|
||||||
ctx=canvas.getContext('2d');
|
ctx=canvas.getContext('2d');
|
||||||
for ( var i = 0; i < monitorPtr.length; i += 1 ) {
|
for ( var i = 0, len=monitorPtr.length; i < len; i += 1 ) {
|
||||||
var monId = monitorPtr[i];
|
var monId = monitorPtr[i];
|
||||||
|
if ( ! monId ) continue;
|
||||||
monitorCanvasObj[monId] = $('Monitor'+monId );
|
monitorCanvasObj[monId] = $('Monitor'+monId );
|
||||||
|
if ( ! monitorCanvasObj[monId] ) {
|
||||||
|
alert("Couldn't find DOM element for Monitor"+monId + "monitorPtr.length="+len);
|
||||||
|
} else {
|
||||||
monitorCanvasCtx[monId]=monitorCanvasObj[monId].getContext('2d');
|
monitorCanvasCtx[monId]=monitorCanvasObj[monId].getContext('2d');
|
||||||
|
monitorImageObject[monId]=new Image();
|
||||||
|
monitorImageObject[monId].src = monitorImageURL[monId];
|
||||||
|
monitorImageObject[monId].monId = monId;
|
||||||
|
monitorImageObject[monId].onload = function() {imagedone(this, this.monId, true )};
|
||||||
|
monitorImageObject[monId].onerror = function() {imagedone(this, this.monId, false )};
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
drawGraph();
|
drawGraph();
|
||||||
setSpeed(speedIndex);
|
setSpeed(speedIndex);
|
||||||
|
|
|
@ -24,8 +24,8 @@ var groupStr=<?php if($group=="") echo '""'; else echo "\"&group=$group\""; ?>;
|
||||||
|
|
||||||
// Because we might not have time as the criteria, figure out the min/max time when we run the query
|
// Because we might not have time as the criteria, figure out the min/max time when we run the query
|
||||||
|
|
||||||
$minTimeSecs = strtotime("2036-01-01 01:01:01");
|
$minTimeSecs = strtotime('2036-01-01 01:01:01');
|
||||||
$maxTimeSecs = strtotime("1950-01-01 01:01:01");
|
$maxTimeSecs = strtotime('1950-01-01 01:01:01');
|
||||||
|
|
||||||
// This builds the list of events that are eligible from this range
|
// This builds the list of events that are eligible from this range
|
||||||
|
|
||||||
|
@ -35,16 +35,18 @@ $anyAlarms=false;
|
||||||
foreach( dbFetchAll( $eventsSql ) as $event ) {
|
foreach( dbFetchAll( $eventsSql ) as $event ) {
|
||||||
if ( $minTimeSecs > $event['StartTimeSecs'] ) $minTimeSecs = $event['StartTimeSecs'];
|
if ( $minTimeSecs > $event['StartTimeSecs'] ) $minTimeSecs = $event['StartTimeSecs'];
|
||||||
if ( $maxTimeSecs < $event['CalcEndTimeSecs'] ) $maxTimeSecs = $event['CalcEndTimeSecs'];
|
if ( $maxTimeSecs < $event['CalcEndTimeSecs'] ) $maxTimeSecs = $event['CalcEndTimeSecs'];
|
||||||
echo "eMonId[$index]=" . $event['MonitorId'] . ";
|
echo "
|
||||||
|
eMonId[$index]=" . $event['MonitorId'] . ";
|
||||||
eId[$index]=" . $event['Id'] . ";
|
eId[$index]=" . $event['Id'] . ";
|
||||||
eStartSecs[$index]=" . $event['StartTimeSecs'] . ";
|
eStartSecs[$index]=" . $event['StartTimeSecs'] . ";
|
||||||
eEndSecs[$index]=" . $event['CalcEndTimeSecs'] . ";
|
eEndSecs[$index]=" . $event['CalcEndTimeSecs'] . ";
|
||||||
eventFrames[$index]=" . $event['Frames'] . ";\n";
|
eventFrames[$index]=" . $event['Frames'] . ";
|
||||||
|
|
||||||
|
";
|
||||||
|
|
||||||
$index = $index + 1;
|
$index = $index + 1;
|
||||||
if ( $event['MaxScore'] > 0 )
|
if ( $event['MaxScore'] > 0 )
|
||||||
$anyAlarms = true;
|
$anyAlarms = true;
|
||||||
echo "\n";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// if there is no data set the min/max to the passed in values
|
// if there is no data set the min/max to the passed in values
|
||||||
|
@ -92,10 +94,12 @@ if($anyAlarms) {
|
||||||
} else if ( $mId != $frame['MonitorId'] || $frame['TimeStampSecs'] - $toSecs > 10 ) {
|
} else if ( $mId != $frame['MonitorId'] || $frame['TimeStampSecs'] - $toSecs > 10 ) {
|
||||||
// dump this one start a new
|
// dump this one start a new
|
||||||
$index++;
|
$index++;
|
||||||
echo " fMonId[$index]=" . $mId . ";";
|
echo "
|
||||||
echo " fTimeFromSecs[$index]=" . $fromSecs . ";";
|
fMonId[$index]= $mId;
|
||||||
echo " fTimeToSecs[$index]=" . $toSecs . ";";
|
fTimeFromSecs[$index]= $fromSecs;
|
||||||
echo " fScore[$index]=" . $maxScore . ";\n";
|
fTimeToSecs[$index]= $toSecs;
|
||||||
|
fScore[$index]= $maxScore;
|
||||||
|
";
|
||||||
$mId = $frame['MonitorId'];
|
$mId = $frame['MonitorId'];
|
||||||
$fromSecs = $frame['TimeStampSecs'];
|
$fromSecs = $frame['TimeStampSecs'];
|
||||||
$toSecs = $frame['TimeStampSecs'];
|
$toSecs = $frame['TimeStampSecs'];
|
||||||
|
@ -108,16 +112,19 @@ if($anyAlarms) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ( $mId > 0 ) {
|
if ( $mId > 0 ) {
|
||||||
echo " fMonId[$index]=" . $mId . ";";
|
echo "
|
||||||
echo " fTimeFromSecs[$index]=" . $fromSecs . ";";
|
fMonId[$index]= $mId;
|
||||||
echo " fTimeToSecs[$index]=" . $toSecs . ";";
|
fTimeFromSecs[$index]= $fromSecs;
|
||||||
echo " fScore[$index]=" . $maxScore . ";\n";
|
fTimeToSecs[$index]= $toSecs;
|
||||||
|
fScore[$index]= $maxScore;
|
||||||
|
";
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "var maxScore=$maxScore;\n"; // used to skip frame load if we find no alarms.
|
echo "var maxScore=$maxScore;\n"; // used to skip frame load if we find no alarms.
|
||||||
echo "var monitorName = [];\n";
|
echo "var monitorName = [];\n";
|
||||||
echo "var monitorLoading = [];\n";
|
echo "var monitorLoading = [];\n";
|
||||||
echo "var monitorImageObject = [];\n";
|
echo "var monitorImageObject = [];\n";
|
||||||
|
echo "var monitorImageURL = [];\n";
|
||||||
echo "var monitorLoadingStageURL = [];\n";
|
echo "var monitorLoadingStageURL = [];\n";
|
||||||
echo "var monitorLoadStartTimems = [];\n";
|
echo "var monitorLoadStartTimems = [];\n";
|
||||||
echo "var monitorLoadEndTimems = [];\n";
|
echo "var monitorLoadEndTimems = [];\n";
|
||||||
|
@ -145,10 +152,7 @@ if($numMonitors>0) $avgArea= $avgArea / $numMonitors;
|
||||||
$numMonitors = 0;
|
$numMonitors = 0;
|
||||||
foreach ( $monitors as $m ) {
|
foreach ( $monitors as $m ) {
|
||||||
echo " monitorLoading[" . $m->Id() . "]=false;\n";
|
echo " monitorLoading[" . $m->Id() . "]=false;\n";
|
||||||
echo " monitorImageObject[" . $m->Id() . "]=new Image();\n";
|
echo " monitorImageURL[" . $m->Id() . "]='".$m->getStreamSrc( array('mode'=>'single','scale'=>$defaultScale), '&' )."';\n";
|
||||||
echo " monitorImageObject[" . $m->Id() . "].src='".$m->getStreamSrc( array('mode'=>'single','scale'=>$defaultScale) )."';\n";
|
|
||||||
echo " monitorImageObject[" . $m->Id() . "].onload = function() {imagedone(this, ".$m->Id().",true )};\n";
|
|
||||||
echo " monitorImageObject[" . $m->Id() . "].onerror = function() {imagedone(this, ".$m->Id().",false )};\n";
|
|
||||||
echo " monitorLoadingStageURL[" . $m->Id() . "] = '';\n";
|
echo " monitorLoadingStageURL[" . $m->Id() . "] = '';\n";
|
||||||
echo " monitorColour[" . $m->Id() . "]=\"" . $m->WebColour() . "\";\n";
|
echo " monitorColour[" . $m->Id() . "]=\"" . $m->WebColour() . "\";\n";
|
||||||
echo " monitorWidth[" . $m->Id() . "]=" . $m->Width() . ";\n";
|
echo " monitorWidth[" . $m->Id() . "]=" . $m->Width() . ";\n";
|
||||||
|
@ -174,13 +178,13 @@ if(isset($defaultCurrentTime))
|
||||||
else
|
else
|
||||||
echo "var currentTimeSecs=" . ($minTimeSecs + $maxTimeSecs)/2 . ";\n";
|
echo "var currentTimeSecs=" . ($minTimeSecs + $maxTimeSecs)/2 . ";\n";
|
||||||
|
|
||||||
echo "var speeds=[";
|
echo 'var speeds=[';
|
||||||
for ($i=0; $i<count($speeds); $i++)
|
for ($i=0; $i<count($speeds); $i++)
|
||||||
echo (($i>0)?", ":"") . $speeds[$i];
|
echo (($i>0)?', ':'') . $speeds[$i];
|
||||||
echo "];\n";
|
echo "];\n";
|
||||||
?>
|
?>
|
||||||
|
|
||||||
var scrubAsObject=document.getElementById('scrub');
|
var scrubAsObject=$('scrub');
|
||||||
var cWidth; // save canvas width
|
var cWidth; // save canvas width
|
||||||
var cHeight; // save canvas height
|
var cHeight; // save canvas height
|
||||||
var canvas; // global canvas definition so we don't have to keep looking it up
|
var canvas; // global canvas definition so we don't have to keep looking it up
|
||||||
|
|
Loading…
Reference in New Issue