more fixes
This commit is contained in:
parent
892f3a06c7
commit
f87a89a5ce
|
@ -88,6 +88,9 @@ function loadImage2Monitor(monId,url) {
|
|||
} else {
|
||||
if ( monitorImageObject[monId].src == url ) return; // do nothing if it's the same
|
||||
if ( url == 'no data' ) {
|
||||
if ( ! monitorCanvasCtx[monId] ) {
|
||||
alert("No ctx for " + monId);
|
||||
} else {
|
||||
monitorCanvasCtx[monId].fillStyle="white";
|
||||
monitorCanvasCtx[monId].fillRect(0,0,monitorCanvasObj[monId].width,monitorCanvasObj[monId].height);
|
||||
var textSize=monitorCanvasObj[monId].width * 0.15;
|
||||
|
@ -96,6 +99,7 @@ function loadImage2Monitor(monId,url) {
|
|||
monitorCanvasCtx[monId].fillStyle="black";
|
||||
var textWidth = monitorCanvasCtx[monId].measureText(text).width;
|
||||
monitorCanvasCtx[monId].fillText(text,monitorCanvasObj[monId].width/2 - textWidth/2,monitorCanvasObj[monId].height/2);
|
||||
}
|
||||
} else {
|
||||
monitorLoading[monId]=true;
|
||||
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
|
||||
|
||||
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
|
||||
var url;
|
||||
if(liveMode!=0) url="?view=watch&mid=" + monId.toString();
|
||||
if ( liveMode != 0 )
|
||||
url="?view=watch&mid=" + monId.toString();
|
||||
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] )
|
||||
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]]);
|
||||
}
|
||||
|
||||
function zoom(monId,scale)
|
||||
{
|
||||
function zoom(monId,scale) {
|
||||
var lastZoomMonPriorScale = monitorZoomScale[monId];
|
||||
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;
|
||||
alert("You can't zoom that far -- rolling back");
|
||||
redrawScreen(); // put things back and hope it works
|
||||
}
|
||||
}
|
||||
|
||||
function clickMonitor(event,monId)
|
||||
{
|
||||
var pos_x = event.offsetX ? (event.offsetX) : event.pageX - $("Monitor"+monId.toString()).offsetLeft;
|
||||
var pos_y = event.offsetY ? (event.offsetY) : event.pageY - $("Monitor"+monId.toString()).offsetTop;
|
||||
if(pos_x < $("Monitor"+monId.toString()).width/4 && pos_y < $("Monitor"+monId.toString()).height/4) zoom(monId,1.15);
|
||||
else if(pos_x > $("Monitor"+monId.toString()).width * 3/4 && pos_y < $("Monitor"+monId.toString()).height/4) zoom(monId,1/1.15);
|
||||
else showOneMonitor(monId);
|
||||
function clickMonitor(event,monId) {
|
||||
var monitor_element = $("Monitor"+monId.toString());
|
||||
var pos_x = event.offsetX ? (event.offsetX) : event.pageX - monitor_element.offsetLeft;
|
||||
var pos_y = event.offsetY ? (event.offsetY) : event.pageY - monitor_element.offsetTop;
|
||||
if ( pos_x < monitor_element.width/4 && pos_y < monitor_element.height/4 )
|
||||
zoom(monId,1.15);
|
||||
else if ( pos_x > monitor_element.width * 3/4 && pos_y < monitor_element.height/4 )
|
||||
zoom(monId,1/1.15);
|
||||
else
|
||||
showOneMonitor(monId);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -694,10 +702,21 @@ function clickMonitor(event,monId)
|
|||
function initPage() {
|
||||
canvas=$("timeline");
|
||||
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];
|
||||
if ( ! monId ) continue;
|
||||
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');
|
||||
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();
|
||||
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
|
||||
|
||||
$minTimeSecs = strtotime("2036-01-01 01:01:01");
|
||||
$maxTimeSecs = strtotime("1950-01-01 01:01:01");
|
||||
$minTimeSecs = strtotime('2036-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
|
||||
|
||||
|
@ -35,16 +35,18 @@ $anyAlarms=false;
|
|||
foreach( dbFetchAll( $eventsSql ) as $event ) {
|
||||
if ( $minTimeSecs > $event['StartTimeSecs'] ) $minTimeSecs = $event['StartTimeSecs'];
|
||||
if ( $maxTimeSecs < $event['CalcEndTimeSecs'] ) $maxTimeSecs = $event['CalcEndTimeSecs'];
|
||||
echo "eMonId[$index]=" . $event['MonitorId'] . ";
|
||||
echo "
|
||||
eMonId[$index]=" . $event['MonitorId'] . ";
|
||||
eId[$index]=" . $event['Id'] . ";
|
||||
eStartSecs[$index]=" . $event['StartTimeSecs'] . ";
|
||||
eEndSecs[$index]=" . $event['CalcEndTimeSecs'] . ";
|
||||
eventFrames[$index]=" . $event['Frames'] . ";\n";
|
||||
eventFrames[$index]=" . $event['Frames'] . ";
|
||||
|
||||
";
|
||||
|
||||
$index = $index + 1;
|
||||
if ( $event['MaxScore'] > 0 )
|
||||
$anyAlarms = true;
|
||||
echo "\n";
|
||||
}
|
||||
|
||||
// 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 ) {
|
||||
// dump this one start a new
|
||||
$index++;
|
||||
echo " fMonId[$index]=" . $mId . ";";
|
||||
echo " fTimeFromSecs[$index]=" . $fromSecs . ";";
|
||||
echo " fTimeToSecs[$index]=" . $toSecs . ";";
|
||||
echo " fScore[$index]=" . $maxScore . ";\n";
|
||||
echo "
|
||||
fMonId[$index]= $mId;
|
||||
fTimeFromSecs[$index]= $fromSecs;
|
||||
fTimeToSecs[$index]= $toSecs;
|
||||
fScore[$index]= $maxScore;
|
||||
";
|
||||
$mId = $frame['MonitorId'];
|
||||
$fromSecs = $frame['TimeStampSecs'];
|
||||
$toSecs = $frame['TimeStampSecs'];
|
||||
|
@ -108,16 +112,19 @@ if($anyAlarms) {
|
|||
}
|
||||
}
|
||||
if ( $mId > 0 ) {
|
||||
echo " fMonId[$index]=" . $mId . ";";
|
||||
echo " fTimeFromSecs[$index]=" . $fromSecs . ";";
|
||||
echo " fTimeToSecs[$index]=" . $toSecs . ";";
|
||||
echo " fScore[$index]=" . $maxScore . ";\n";
|
||||
echo "
|
||||
fMonId[$index]= $mId;
|
||||
fTimeFromSecs[$index]= $fromSecs;
|
||||
fTimeToSecs[$index]= $toSecs;
|
||||
fScore[$index]= $maxScore;
|
||||
";
|
||||
}
|
||||
|
||||
echo "var maxScore=$maxScore;\n"; // used to skip frame load if we find no alarms.
|
||||
echo "var monitorName = [];\n";
|
||||
echo "var monitorLoading = [];\n";
|
||||
echo "var monitorImageObject = [];\n";
|
||||
echo "var monitorImageURL = [];\n";
|
||||
echo "var monitorLoadingStageURL = [];\n";
|
||||
echo "var monitorLoadStartTimems = [];\n";
|
||||
echo "var monitorLoadEndTimems = [];\n";
|
||||
|
@ -145,10 +152,7 @@ if($numMonitors>0) $avgArea= $avgArea / $numMonitors;
|
|||
$numMonitors = 0;
|
||||
foreach ( $monitors as $m ) {
|
||||
echo " monitorLoading[" . $m->Id() . "]=false;\n";
|
||||
echo " monitorImageObject[" . $m->Id() . "]=new Image();\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 " monitorImageURL[" . $m->Id() . "]='".$m->getStreamSrc( array('mode'=>'single','scale'=>$defaultScale), '&' )."';\n";
|
||||
echo " monitorLoadingStageURL[" . $m->Id() . "] = '';\n";
|
||||
echo " monitorColour[" . $m->Id() . "]=\"" . $m->WebColour() . "\";\n";
|
||||
echo " monitorWidth[" . $m->Id() . "]=" . $m->Width() . ";\n";
|
||||
|
@ -174,13 +178,13 @@ if(isset($defaultCurrentTime))
|
|||
else
|
||||
echo "var currentTimeSecs=" . ($minTimeSecs + $maxTimeSecs)/2 . ";\n";
|
||||
|
||||
echo "var speeds=[";
|
||||
echo 'var speeds=[';
|
||||
for ($i=0; $i<count($speeds); $i++)
|
||||
echo (($i>0)?", ":"") . $speeds[$i];
|
||||
echo (($i>0)?', ':'') . $speeds[$i];
|
||||
echo "];\n";
|
||||
?>
|
||||
|
||||
var scrubAsObject=document.getElementById('scrub');
|
||||
var scrubAsObject=$('scrub');
|
||||
var cWidth; // save canvas width
|
||||
var cHeight; // save canvas height
|
||||
var canvas; // global canvas definition so we don't have to keep looking it up
|
||||
|
|
Loading…
Reference in New Issue