replace mootool Cookie object with plain JS

This commit is contained in:
Andrew Bauer 2021-01-08 10:04:46 -06:00 committed by Isaac Connor
parent 85da53f86f
commit a1678f5ea4
6 changed files with 36 additions and 36 deletions

View File

@ -273,10 +273,10 @@ if ( currentView != 'none' && currentView != 'login' ) {
var flip = $j("#flip"); var flip = $j("#flip");
if ( flip.html() == 'keyboard_arrow_up' ) { if ( flip.html() == 'keyboard_arrow_up' ) {
flip.html('keyboard_arrow_down'); flip.html('keyboard_arrow_down');
Cookie.write('zmHeaderFlip', 'down', {duration: 10*365, samesite: 'strict'} ); setCookie('zmHeaderFlip', 'down', 3600);
} else { } else {
flip.html('keyboard_arrow_up'); flip.html('keyboard_arrow_up');
Cookie.write('zmHeaderFlip', 'up', {duration: 10*365, samesite: 'strict'} ); setCookie('zmHeaderFlip', 'up', 3600);
} }
}); });
// Manage the web console filter bar minimize chevron // Manage the web console filter bar minimize chevron
@ -285,10 +285,10 @@ if ( currentView != 'none' && currentView != 'login' ) {
var fbflip = $j("#fbflip"); var fbflip = $j("#fbflip");
if ( fbflip.html() == 'keyboard_arrow_up' ) { if ( fbflip.html() == 'keyboard_arrow_up' ) {
fbflip.html('keyboard_arrow_down'); fbflip.html('keyboard_arrow_down');
Cookie.write('zmFilterBarFlip', 'down', {duration: 10*365, samesite: 'strict'} ); setCookie('zmFilterBarFlip', 'down', 3600);
} else { } else {
fbflip.html('keyboard_arrow_up'); fbflip.html('keyboard_arrow_up');
Cookie.write('zmFilterBarFlip', 'up', {duration: 10*365, samesite: 'strict'} ); setCookie('zmFilterBarFlip', 'up', 3600);
$j('.chosen').chosen("destroy"); $j('.chosen').chosen("destroy");
$j('.chosen').chosen(); $j('.chosen').chosen();
} }
@ -300,10 +300,10 @@ if ( currentView != 'none' && currentView != 'login' ) {
var mfbflip = $j("#mfbflip"); var mfbflip = $j("#mfbflip");
if ( mfbflip.html() == 'keyboard_arrow_up' ) { if ( mfbflip.html() == 'keyboard_arrow_up' ) {
mfbflip.html('keyboard_arrow_down'); mfbflip.html('keyboard_arrow_down');
Cookie.write('zmMonitorFilterBarFlip', 'up', {duration: 10*365, samesite: 'strict'} ); setCookie('zmMonitorFilterBarFlip', 'up', 3600);
} else { } else {
mfbflip.html('keyboard_arrow_up'); mfbflip.html('keyboard_arrow_up');
Cookie.write('zmMonitorFilterBarFlip', 'down', {duration: 10*365, samesite: 'strict'} ); setCookie('zmMonitorFilterBarFlip', 'down', 3600);
$j('.chosen').chosen("destroy"); $j('.chosen').chosen("destroy");
$j('.chosen').chosen(); $j('.chosen').chosen();
} }

View File

@ -81,18 +81,18 @@ function changeSize() {
console.log('Did not find liveStream'+monitorData[monIdx].id); console.log('Did not find liveStream'+monitorData[monIdx].id);
} }
$j('#scale').val(''); $j('#scale').val('');
Cookie.write('zmCycleScale', '', {duration: 10*365, samesite: 'strict'}); setCookie('zmCycleScale', '', 3600);
Cookie.write('zmCycleWidth', width, {duration: 10*365, samesite: 'strict'}); setCookie('zmCycleWidth', width, 3600);
Cookie.write('zmCycleHeight', height, {duration: 10*365, samesite: 'strict'}); setCookie('zmCycleHeight', height, 3600);
} // end function changeSize() } // end function changeSize()
function changeScale() { function changeScale() {
var scale = $j('#scale').val(); var scale = $j('#scale').val();
$j('#width').val('auto'); $j('#width').val('auto');
$j('#height').val('auto'); $j('#height').val('auto');
Cookie.write('zmCycleScale', scale, {duration: 10*365, samesite: 'strict'}); setCookie('zmCycleScale', scale, 3600);
Cookie.write('zmCycleWidth', 'auto', {duration: 10*365, samesite: 'strict'}); setCookie('zmCycleWidth', 'auto', 3600);
Cookie.write('zmCycleHeight', 'auto', {duration: 10*365, samesite: 'strict'}); setCookie('zmCycleHeight', 'auto', 3600);
var newWidth = ( monitorData[monIdx].width * scale ) / SCALE_BASE; var newWidth = ( monitorData[monIdx].width * scale ) / SCALE_BASE;
var newHeight = ( monitorData[monIdx].height * scale ) / SCALE_BASE; var newHeight = ( monitorData[monIdx].height * scale ) / SCALE_BASE;

View File

@ -210,13 +210,13 @@ function changeScale() {
} else { } else {
alarmCue.html(renderAlarmCues(eventViewer));//just re-render alarmCues. skip ajax call alarmCue.html(renderAlarmCues(eventViewer));//just re-render alarmCues. skip ajax call
} }
Cookie.write('zmEventScale'+eventData.MonitorId, scale, {duration: 10*365, samesite: 'strict'}); setCookie('zmEventScale'+eventData.MonitorId, scale, 3600);
} // end function changeScale } // end function changeScale
function changeReplayMode() { function changeReplayMode() {
var replayMode = $j('#replayMode').val(); var replayMode = $j('#replayMode').val();
Cookie.write('replayMode', replayMode, {duration: 10*365, samesite: 'strict'}); setCookie('replayMode', replayMode, 3600);
refreshWindow(); refreshWindow();
} }
@ -249,7 +249,7 @@ function changeRate() {
streamReq({command: CMD_VARPLAY, rate: rate}); streamReq({command: CMD_VARPLAY, rate: rate});
} }
} }
Cookie.write('zmEventRate', rate, {duration: 10*365, samesite: 'strict'}); setCookie('zmEventRate', rate, 3600);
} // end function changeRate } // end function changeRate
function getCmdResponse( respObj, respText ) { function getCmdResponse( respObj, respText ) {
@ -292,7 +292,7 @@ function getCmdResponse( respObj, respText ) {
streamPause( ); streamPause( );
} else { } else {
$j('select[name="rate"]').val(streamStatus.rate*100); $j('select[name="rate"]').val(streamStatus.rate*100);
Cookie.write('zmEventRate', streamStatus.rate*100, {duration: 10*365, samesite: 'strict'}); setCookie('zmEventRate', streamStatus.rate*100, 3600);
streamPlay( ); streamPlay( );
} }
$j('#progressValue').html(secsToTime(parseInt(streamStatus.progress))); $j('#progressValue').html(secsToTime(parseInt(streamStatus.progress)));
@ -361,7 +361,7 @@ function vjsPlay() { //catches if we change mode programatically
stopFastRev(); stopFastRev();
} }
$j('select[name="rate"]').val(vid.playbackRate()*100); $j('select[name="rate"]').val(vid.playbackRate()*100);
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365, samesite: 'strict'}); setCookie('zmEventRate', vid.playbackRate()*100, 3600);
streamPlay(); streamPlay();
} }
@ -388,7 +388,7 @@ function streamFastFwd( action ) {
setButtonState('fastFwdBtn', 'unavail'); setButtonState('fastFwdBtn', 'unavail');
} }
$j('select[name="rate"]').val(vid.playbackRate()*100); $j('select[name="rate"]').val(vid.playbackRate()*100);
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365, samesite: 'strict'}); setCookie('zmEventRate', vid.playbackRate()*100, 3600);
} else { } else {
streamReq({command: CMD_FASTFWD}); streamReq({command: CMD_FASTFWD});
} }
@ -415,7 +415,7 @@ function stopFastRev() {
clearInterval(intervalRewind); clearInterval(intervalRewind);
vid.playbackRate(1); vid.playbackRate(1);
$j('select[name="rate"]').val(vid.playbackRate()*100); $j('select[name="rate"]').val(vid.playbackRate()*100);
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365, samesite: 'strict'}); setCookie('zmEventRate', vid.playbackRate()*100, 3600);
revSpeed = .5; revSpeed = .5;
} }
@ -433,7 +433,7 @@ function streamFastRev( action ) {
} }
clearInterval(intervalRewind); clearInterval(intervalRewind);
$j('select[name="rate"]').val(-revSpeed*100); $j('select[name="rate"]').val(-revSpeed*100);
Cookie.write('zmEventRate', vid.playbackRate()*100, {duration: 10*365, samesite: 'strict'}); setCookie('zmEventRate', vid.playbackRate()*100, 3600;
intervalRewind = setInterval(function() { intervalRewind = setInterval(function() {
if (vid.currentTime() <= 0) { if (vid.currentTime() <= 0) {
clearInterval(intervalRewind); clearInterval(intervalRewind);
@ -1134,11 +1134,11 @@ function initPage() {
handleClick(event); handleClick(event);
}); });
vid.on('volumechange', function() { vid.on('volumechange', function() {
Cookie.write('volume', vid.volume(), {duration: 10*365, samesite: 'strict'}); setCookie('volume', vid.volume(), 3600);
}); });
if ( Cookie.read('volume') != null ) { var cookie = getCookie('volume');
vid.volume(Cookie.read('volume')); if ( cookie ) vid.volume(cookie);
}
vid.on('timeupdate', function() { vid.on('timeupdate', function() {
$j('#progressValue').html(secsToTime(Math.floor(vid.currentTime()))); $j('#progressValue').html(secsToTime(Math.floor(vid.currentTime())));
}); });

View File

@ -24,7 +24,7 @@ function changeScale() {
img.css('width', newWidth + 'px'); img.css('width', newWidth + 'px');
img.css('height', newHeight + 'px'); img.css('height', newHeight + 'px');
} }
Cookie.write('zmWatchScale', scale, {duration: 10*365, samesite: 'strict'}); setCookie('zmWatchScale', scale, 3600);
$j.each(controlsLinks, function(k, anchor) { //Make frames respect scale choices $j.each(controlsLinks, function(k, anchor) { //Make frames respect scale choices
if ( anchor ) { if ( anchor ) {
anchor.prop('href', anchor.prop('href').replace(/scale=.*&/, 'scale=' + scale + '&')); anchor.prop('href', anchor.prop('href').replace(/scale=.*&/, 'scale=' + scale + '&'));

View File

@ -44,9 +44,9 @@ function selectLayout(element) {
if ( ! layout ) { if ( ! layout ) {
return; return;
} }
Cookie.write('zmMontageLayout', layout_id, {duration: 10*365, samesite: 'strict'}); setCookie('zmMontageLayout', layout_id, 3600);
if ( layouts[layout_id].Name != 'Freeform' ) { // 'montage_freeform.css' ) { if ( layouts[layout_id].Name != 'Freeform' ) { // 'montage_freeform.css' ) {
Cookie.write('zmMontageScale', '', {duration: 10*365, samesite: 'strict'}); setCookie('zmMontageScale', '', 3600);
$j('#scale').val(''); $j('#scale').val('');
$j('#width').val('0'); $j('#width').val('0');
} else { } else {
@ -129,9 +129,9 @@ function changeSize() {
} }
} }
$j('#scale').val(''); $j('#scale').val('');
Cookie.write('zmMontageScale', '', {duration: 10*365, samesite: 'strict'}); setCookie('zmMontageScale', '', 3600);
Cookie.write('zmMontageWidth', width, {duration: 10*365, samesite: 'strict'}); setCookie('zmMontageWidth', width, 3600);
Cookie.write('zmMontageHeight', height, {duration: 10*365, samesite: 'strict'}); setCookie('zmMontageHeight', height, 3600);
$j("#zmMontageLayout option:selected").removeAttr("selected"); $j("#zmMontageLayout option:selected").removeAttr("selected");
//selectLayout('#zmMontageLayout'); //selectLayout('#zmMontageLayout');
} // end function changeSize() } // end function changeSize()
@ -143,9 +143,9 @@ function changeScale() {
var scale = $j('#scale').val(); var scale = $j('#scale').val();
$j('#width').val('0'); //auto $j('#width').val('0'); //auto
$j('#height').val('0'); //auto $j('#height').val('0'); //auto
Cookie.write('zmMontageScale', scale, {duration: 10*365, samesite: 'strict'}); setCookie('zmMontageScale', scale, 3600);
Cookie.write('zmMontageWidth', '', {duration: 10*365, samesite: 'strict'}); setCookie('zmMontageWidth', '', 3600);
Cookie.write('zmMontageHeight', '', {duration: 10*365, samesite: 'strict'}); setCookie('zmMontageHeight', '', 3600);
if ( scale == '' ) { if ( scale == '' ) {
selectLayout('#zmMontageLayout'); selectLayout('#zmMontageLayout');
return; return;
@ -275,9 +275,9 @@ function initPage() {
$j("#hdrbutton").click(function() { $j("#hdrbutton").click(function() {
$j("#flipMontageHeader").slideToggle("slow"); $j("#flipMontageHeader").slideToggle("slow");
$j("#hdrbutton").toggleClass('glyphicon-menu-down').toggleClass('glyphicon-menu-up'); $j("#hdrbutton").toggleClass('glyphicon-menu-down').toggleClass('glyphicon-menu-up');
Cookie.write( 'zmMontageHeaderFlip', $j('#hdrbutton').hasClass('glyphicon-menu-up') ? 'up' : 'down', {duration: 10*365} ); setCookie( 'zmMontageHeaderFlip', $j('#hdrbutton').hasClass('glyphicon-menu-up') ? 'up' : 'down', 3600);
}); });
if ( Cookie.read('zmMontageHeaderFlip') == 'down' ) { if ( getCookie('zmMontageHeaderFlip') == 'down' ) {
// The chosen dropdowns require the selects to be visible, so once chosen has initialized, we can hide the header // The chosen dropdowns require the selects to be visible, so once chosen has initialized, we can hide the header
$j("#flipMontageHeader").slideToggle("fast"); $j("#flipMontageHeader").slideToggle("fast");
$j("#hdrbutton").toggleClass('glyphicon-menu-down').toggleClass('glyphicon-menu-up'); $j("#hdrbutton").toggleClass('glyphicon-menu-down').toggleClass('glyphicon-menu-up');

View File

@ -110,7 +110,7 @@ function changeScale() {
newHeight = monitorHeight * scale / SCALE_BASE; newHeight = monitorHeight * scale / SCALE_BASE;
} }
Cookie.write('zmWatchScale'+monitorId, scale, {duration: 10*365, samesite: 'strict'}); setCookie('zmWatchScale'+monitorId, scale, 3600);
var streamImg = $j('#liveStream'+monitorId); var streamImg = $j('#liveStream'+monitorId);
if ( streamImg ) { if ( streamImg ) {