Fix preset labels not being populated and causing javascript errors when they are.

This commit is contained in:
Isaac Connor 2021-12-22 11:25:46 -05:00
parent 81048b6191
commit 80166a1ab5
1 changed files with 10 additions and 9 deletions

View File

@ -60,16 +60,16 @@ var mode = "<?php echo $options['mode'] ?>";
var monitorData = new Array(); var monitorData = new Array();
<?php <?php
foreach ($monitors as $monitor) { foreach ($monitors as $m) {
?> ?>
monitorData[monitorData.length] = { monitorData[monitorData.length] = {
'id': <?php echo $monitor->Id() ?>, 'id': <?php echo $m->Id() ?>,
'width': <?php echo $monitor->ViewWidth() ?>, 'width': <?php echo $m->ViewWidth() ?>,
'height':<?php echo $monitor->ViewHeight() ?>, 'height':<?php echo $m->ViewHeight() ?>,
'url': '<?php echo $monitor->UrlToIndex() ?>', 'url': '<?php echo $m->UrlToIndex() ?>',
'onclick': function(){window.location.assign( '?view=watch&mid=<?php echo $monitor->Id() ?>' );}, 'onclick': function(){window.location.assign( '?view=watch&mid=<?php echo $m->Id() ?>' );},
'type': '<?php echo $monitor->Type() ?>', 'type': '<?php echo $m->Type() ?>',
'refresh': '<?php echo $monitor->Refresh() ?>' 'refresh': '<?php echo $m->Refresh() ?>'
}; };
<?php <?php
} // end foreach monitor } // end foreach monitor
@ -101,9 +101,10 @@ var appletRefreshTime = <?php echo ZM_RELOAD_CAMBOZOLA ?>;
var labels = new Array(); var labels = new Array();
<?php <?php
$labels = array(); $labels = array();
ZM\Debug("Presets");
foreach (dbFetchAll('SELECT * FROM ControlPresets WHERE MonitorId = ?', NULL, array($monitor->Id())) as $row) { foreach (dbFetchAll('SELECT * FROM ControlPresets WHERE MonitorId = ?', NULL, array($monitor->Id())) as $row) {
$label = $labels[$row['Preset']] = $row['Label']; $label = $labels[$row['Preset']] = $row['Label'];
echo 'labels['. validInt($index) .'] = \''.validJsStr($label).'\''; echo 'labels['. validInt($row['Preset']) .'] = \''.validJsStr($label).'\';'.PHP_EOL;
} }
?> ?>
var deleteString = "<?php echo translate('Delete') ?>"; var deleteString = "<?php echo translate('Delete') ?>";