Example #1
0
?>
;
      /* sunrise <?php 
echo date('H:i:s', getSunrise(false));
?>
 */
      currentRefMinutes = <?php 
echo dateToMinutes(time());
?>
;
      /* current <?php 
echo date('H:i:s', time());
?>
 */
      currentSunState = '<?php 
echo getSunStatus();
?>
';

      // switches the themes for night and day time
      if('<?php 
echo $_REQUEST['scheme'];
?>
' == '')
      setInterval(function() {
      
        var dt = new Date();
        var currentMinutes = dt.getMinutes()+dt.getHours()*60;
        var sunState = '';

        if(currentMinutes > sunSet || currentMinutes < sunRise) sunState = 'night'; else sunState = 'day';
Example #2
0
 function executeLine($line, $data)
 {
     $line = trim($line);
     if ($line == '' || substr($line, 0, 1) == '#') {
         return;
     }
     # if the line starts with : it's a device command
     if (substr($line, 0, 1) == ':') {
         $this->handleDeviceLine($line, $data);
     } else {
         $thisCommand = CutSegment('/', $line);
         $parts = explode(':', $thisCommand);
         CutSegment(':', $thisCommand);
         $fn = strtoupper(array_shift($parts));
         $data['fnParams'] = $parts;
         $data['line'] = $line;
         if ($data['reverseAction']) {
             $data['fnValue'] = $parts[1];
         } else {
             $data['fnValue'] = $parts[0];
         }
         $GLOBALS['log'][] = '(' . $fn . ' ' . implode(' ', $parts) . ')';
         switch ($fn) {
             case 'PHP':
                 eval($line);
                 break;
             case 'MAP':
                 $mapKey = CutSegment('>', $thisCommand);
                 $this->map[trim($mapKey)] = trim($thisCommand);
                 break;
             case 'DAY?':
                 if (getSunStatus() == 'day') {
                     $this->executeLine($line, $data);
                 }
                 break;
             case 'NIGHT?':
                 if (getSunStatus() == 'night') {
                     $this->executeLine($line, $data);
                 }
                 break;
             case 'REV?':
                 if ($data['reverseAction']) {
                     $data['reverseAction'] = !$data['reverseAction'];
                     $this->executeLine($line, $data);
                 }
                 break;
             case 'ACTION?':
                 if (!$data['reverseAction']) {
                     $this->executeLine($line, $data);
                 }
                 break;
             case 'MODE?':
                 $mode = new H2Mode();
                 if (strtoupper($mode->current) == strtoupper($thisCommand)) {
                     $this->executeLine($line, $data);
                 }
                 break;
             case 'SELECT':
                 $this->handleSelectLine($thisCommand, $data, true);
                 break;
             case 'LINELOG':
                 $this->handleLINELOGLine($thisCommand, $data, true);
                 break;
             case 'LOG':
                 $this->handleLOGLine($thisCommand, $data, true);
                 break;
             case 'REMOVE':
                 $this->handleSelectLine($thisCommand, $data, false);
                 break;
             default:
                 $fname = 'handle' . $fn . 'Line';
                 call_user_method($fname, $this, $thisCommand, $data);
                 break;
         }
     }
 }