2019-03-05 02:35:40 +08:00
|
|
|
var periodical_id;
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function nextCycleView() {
|
2018-07-10 00:33:21 +08:00
|
|
|
window.location.replace('?view=cycle&mid='+nextMid+'&mode='+mode, cycleRefreshTimeout);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-03-05 02:35:40 +08:00
|
|
|
function cyclePause() {
|
|
|
|
$clear(periodical_id);
|
|
|
|
$('pauseBtn').disabled = true;
|
|
|
|
$('playBtn').disabled = false;
|
|
|
|
}
|
|
|
|
function cycleStart() {
|
|
|
|
periodical_id = nextCycleView.periodical(cycleRefreshTimeout);
|
|
|
|
$('pauseBtn').disabled = false;
|
|
|
|
$('playBtn').disabled = true;
|
|
|
|
}
|
|
|
|
function cycleNext() {
|
|
|
|
monIdx ++;
|
2019-03-06 00:01:58 +08:00
|
|
|
if ( monIdx >= monitorData.length ) {
|
2019-03-05 02:35:40 +08:00
|
|
|
monIdx = 0;
|
2019-03-06 00:01:58 +08:00
|
|
|
}
|
|
|
|
if ( !monitorData[monIdx] ) {
|
2019-03-05 02:35:40 +08:00
|
|
|
console.log("No monitorData for " + monIdx);
|
2019-03-06 00:01:58 +08:00
|
|
|
}
|
2019-03-05 02:35:40 +08:00
|
|
|
|
|
|
|
window.location.replace('?view=cycle&mid='+monitorData[monIdx].id+'&mode='+mode, cycleRefreshTimeout);
|
|
|
|
}
|
|
|
|
function cyclePrev() {
|
2019-03-11 11:56:08 +08:00
|
|
|
if (monIdx) {
|
2019-03-05 02:35:40 +08:00
|
|
|
monIdx -= 1;
|
2019-03-11 11:56:08 +08:00
|
|
|
} else {
|
|
|
|
monIdx = monitorData.length - 1;
|
|
|
|
}
|
2019-03-05 02:35:40 +08:00
|
|
|
|
|
|
|
window.location.replace('?view=cycle&mid='+monitorData[monIdx].id+'&mode='+mode, cycleRefreshTimeout);
|
|
|
|
}
|
|
|
|
|
2017-05-19 01:50:56 +08:00
|
|
|
function initCycle() {
|
2019-03-05 02:35:40 +08:00
|
|
|
periodical_id = nextCycleView.periodical(cycleRefreshTimeout);
|
2008-07-14 21:54:50 +08:00
|
|
|
}
|
|
|
|
|
2019-03-05 02:35:40 +08:00
|
|
|
function changeSize() {
|
|
|
|
var width = $('width').get('value');
|
|
|
|
var height = $('height').get('value');
|
|
|
|
|
|
|
|
// Scale the frame
|
|
|
|
monitor_frame = $j('#imageFeed');
|
|
|
|
if ( !monitor_frame ) {
|
|
|
|
console.log("Error finding frame");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( width ) {
|
|
|
|
monitor_frame.css('width', width);
|
|
|
|
}
|
|
|
|
if ( height ) {
|
|
|
|
monitor_frame.css('height', height);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Stream could be an applet so can't use moo tools */
|
|
|
|
var streamImg = $('liveStream'+monitorData[monIdx].id);
|
|
|
|
if ( streamImg ) {
|
|
|
|
if ( streamImg.nodeName == 'IMG' ) {
|
|
|
|
var src = streamImg.src;
|
|
|
|
streamImg.src = '';
|
|
|
|
console.log(parseInt(width));
|
|
|
|
src = src.replace(/width=[\.\d]+/i, 'width='+parseInt(width));
|
|
|
|
src = src.replace(/height=[\.\d]+/i, 'height='+parseInt(height));
|
|
|
|
src = src.replace(/rand=\d+/i, 'rand='+Math.floor((Math.random() * 1000000) ));
|
|
|
|
streamImg.src = src;
|
|
|
|
}
|
|
|
|
streamImg.style.width = width ? width : null;
|
|
|
|
streamImg.style.height = height ? height : null;
|
|
|
|
} else {
|
|
|
|
console.log("Did not find liveStream"+monitorData[monIdx].id);
|
|
|
|
}
|
|
|
|
$('scale').set('value', '');
|
2019-03-06 00:01:58 +08:00
|
|
|
Cookie.write('zmCycleScale', '', {duration: 10*365});
|
|
|
|
Cookie.write('zmCycleWidth', width, {duration: 10*365});
|
|
|
|
Cookie.write('zmCycleHeight', height, {duration: 10*365});
|
2019-03-05 02:35:40 +08:00
|
|
|
} // end function changeSize()
|
|
|
|
|
|
|
|
function changeScale() {
|
|
|
|
var scale = $('scale').get('value');
|
|
|
|
$('width').set('value', 'auto');
|
|
|
|
$('height').set('value', 'auto');
|
2019-03-11 11:56:08 +08:00
|
|
|
Cookie.write('zmCycleScale', scale, {duration: 10*365});
|
|
|
|
Cookie.write('zmCycleWidth', 'auto', {duration: 10*365});
|
|
|
|
Cookie.write('zmCycleHeight', 'auto', {duration: 10*365});
|
2019-03-05 02:35:40 +08:00
|
|
|
var newWidth = ( monitorData[monIdx].width * scale ) / SCALE_BASE;
|
|
|
|
var newHeight = ( monitorData[monIdx].height * scale ) / SCALE_BASE;
|
|
|
|
|
|
|
|
// Scale the frame
|
|
|
|
monitor_frame = $j('#imageFeed');
|
|
|
|
if ( !monitor_frame ) {
|
|
|
|
console.log("Error finding frame");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if ( newWidth ) {
|
|
|
|
monitor_frame.css('width', newWidth+'px');
|
|
|
|
}
|
|
|
|
if ( newHeight ) {
|
|
|
|
monitor_frame.css('height', newHeight+'px');
|
|
|
|
}
|
|
|
|
/*Stream could be an applet so can't use moo tools*/
|
|
|
|
var streamImg = $j('#liveStream'+monitorData[monIdx].id)[0];
|
|
|
|
if ( streamImg ) {
|
|
|
|
if ( streamImg.nodeName == 'IMG' ) {
|
|
|
|
var src = streamImg.src;
|
|
|
|
streamImg.src = '';
|
|
|
|
|
|
|
|
//src = src.replace(/rand=\d+/i,'rand='+Math.floor((Math.random() * 1000000) ));
|
|
|
|
src = src.replace(/scale=[\.\d]+/i, 'scale='+scale);
|
|
|
|
src = src.replace(/width=[\.\d]+/i, 'width='+newWidth);
|
|
|
|
src = src.replace(/height=[\.\d]+/i, 'height='+newHeight);
|
|
|
|
streamImg.src = src;
|
|
|
|
}
|
|
|
|
streamImg.style.width = newWidth + 'px';
|
|
|
|
streamImg.style.height = newHeight + 'px';
|
|
|
|
} else {
|
|
|
|
console.log("Did not find liveStream"+monitorData[monIdx].id);
|
|
|
|
}
|
|
|
|
} // end function changeScale()
|
|
|
|
|
2019-01-22 00:14:32 +08:00
|
|
|
window.addEventListener('DOMContentLoaded', initCycle);
|