Свойства класса:
Методы класса:
// ("Пора вставать!",2);
Объекты класса:
if (isWeekEnd()){ // сегодня выходной день
// все проснулись
setGlobal("SleepAllMode.active",0);
say('Пора вставать!', 5);
say('Хоть сегодня и выходной, но вы так сами захотели!', 5);
// Выбираем радиостанцию
$radio = gg("AlarmWeekDay.Radio");
$url = 'http://localhost/popup/app_101ru.html?&ajax=1&op=playstation&id='.$radio;
// включим радио
getURL($url ,0);
// запланируем выключить радио
SetTimeOut("AlarmWeekEnd_RadioStop",'callMethod("Radio.RadioStop");', 60*60);
}if (isWeekDay()){ // сегодня рабочий день
// все проснулись
setGlobal("SleepAllMode.active",0);
say('Пора вставать!', 5);
say('Сегодня отличный день заколачивать бабло!', 5);
// Выбираем радиостанцию
$radio = gg("AlarmWeekDay.Radio");
$url = 'http://localhost/popup/app_101ru.html?&ajax=1&op=playstation&id='.$radio;
// включим радио
getURL($url ,0);
// запланируем выключить радио
SetTimeOut("AlarmWeekEnd_RadioStop",'callMethod("Radio.RadioStop");', 60*60);
}// это однократный будильник, выключем его
sg("AlarmOne.AlarmOn",0);
// все проснулись
setGlobal("SleepAllMode.active",0);
say('Пора вставать!', 5);
// Выбираем радиостанцию
$radio = gg("AlarmOne.Radio");
$url = 'http://localhost/popup/app_101ru.html?&ajax=1&op=playstation&id='.$radio;
// включим радио
getURL($url ,0);
// запланируем выключить радио через 1час
SetTimeOut("AlarmOne_RadioStop","cm('RadioSetting.Control',array('cmd'=>'stop'));", 3600);Свойства класса:
Методы класса:
$val=$this->getProperty("level");
switch ($val) {
case 1:
runScript('light_min');
break;
case 2:
runScript('light_minus');
break;
case 3:
runScript('light_plus');
break;
case 4:
runScript('light_max');
break;
}
$this->setProperty('level',0);
runScript("light_on_off");Объекты класса:
Свойства класса:
Методы класса:
$volume=round(65535*$params['VALUE']/100);
$this->setProperty('volumeLevel',$params['VALUE']);
safe_exec('..\\apps\\nircmd\\nircmdc setsysvolume '.$volume);
// say("Громкость:".$params['VALUE']." процентов", 0);Объекты класса:
$command=$params['command'];
$short_command='';
$dt=recognizeTime($command,$short_command);
if (preg_match('/скажи сколько врем/is',$command)) {
if ($dt>0) {
addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt);
say('Задача принята',2);
return;
}
global $voicemode;
$voicemode='on';
say('Сейчас '.timeNow(),2);
} elseif (preg_match('/сколько время/is',$command)) {
if ($dt>0) {
addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt);
say('Задача принята');
echo $short_command;
return;
}
say('Сейчас '.timeNow());
} elseif (preg_match('/повтори (.+)/is',$command,$m) || preg_match('/скажи (.+)/is',$command,$m)) {
if ($dt>0) {
addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt);
say('Задача принята',2);
return;
}
global $voicemode;
$voicemode='on';
say($m[1],2);
} else {
say('Неизвестная команда...',2);
}
say("Отключено питание");// Метод выполняется когда некоторое время не работал основной цикл системы
// (например компьютер был некоторое время выключен или "спал")
$sleeptime=$params['sleeptime'];
$longtime=30*60; // если больше 30 минут, значит долго спала :)
/*
if ($sleeptime>$longtime) {
$ph='Как можно так забывать про меня?';
} else {
$ph='Немного вздремнула.';
}
getObject("alice")->raiseEvent("say", array("say"=>$ph." Где я?"));
*/
// далее можно вызывать какие-то процедуры определения положения
// или другие действия, которые необходимо выполнить после вынужденного простояsay("Алиса в работе",2);Свойства класса:
Методы класса:
$Red = $this->getProperty("RedOld");
$Green = $this->getProperty("GreenOld");
$Blue = $this->getProperty("BlueOld");
$this->setProperty("Red",$Red);
$this->setProperty("Green",$Green);
$this->setProperty("Blue",$Blue);
$this->setProperty("status",1);$Red = $this->getProperty("Red");
$Green = $this->getProperty("Green");
$Blue = $this->getProperty("Blue");
if ($Red == 255 && $Green == 255 && $Blue == 255) {
$Red2 = $this->getProperty("RedOld");
$Green2 = $this->getProperty("GreenOld");
$Blue2 = $this->getProperty("BlueOld");
$this->setProperty("Red",$Red2);
$this->setProperty("Green",$Green2);
$this->setProperty("Blue",$Blue2);
$this->setProperty("status",1);
}
else {
$this->setProperty("Red",255);
$this->setProperty("Green",255);
$this->setProperty("Blue",255);
$this->setProperty("status",0);
}$Red = $this->getProperty("Red");
$Green = $this->getProperty("Green");
$Blue = $this->getProperty("Blue");
$this->setProperty("RedOld",$Red);
$this->setProperty("GreenOld",$Green);
$this->setProperty("BlueOld",$Blue);
$this->setProperty("Red",255);
$this->setProperty("Green",255);
$this->setProperty("Blue",255);
$this->setProperty("status",0);Объекты класса:
$param=$this->getProperty("status");
if ($param == 1) {
getUrl("http://192.168.1.75/gpio/1");
} else if ($param == 0) {
getUrl("http://192.168.1.75/gpio/0");
}Свойства класса:
Методы класса:
//$params['t']
$this->setProperty("updated",time());
$this->setProperty("updatedTime",date("H:i",time()));
$this->setProperty("alive",1);
$this->setProperty("aliveIcon", 'fa fa-check');
$ot=$this->object_title;
$alive_timeout=(int)$this->getProperty("aliveTimeOut");
if (!$alive_timeout) {
$alive_timeout=30*60;
}
clearTimeOut($ot."_alive");
setTimeOut($ot."_alive","sg('".$ot.".alive',0); sg('".$ot.".aliveIcon', 'fa fa-times');",$alive_timeout);
if (!isset($params['h'])) {
return;
}
$old_temp=$this->getProperty('humidity');
$t=round($params['h'],1);
if ($t>100) return;
$this->setProperty('humidity',$t);
if ($params['uptime']) {
$this->setProperty('uptime',$params['uptime']);
}
if ($t>$old_temp) {
$d = 'fa fa-caret-up';
} elseif ($t<$old_temp) {
$d = 'fa fa-caret-down';
} else {
$d= '';
}
$this->setProperty('direction',$d);
$linked_room=$this->getProperty("LinkedRoom");
if ($linked_room) {
setGlobal($linked_room.'.Humidity',$t);
}Объекты класса:
Свойства класса:
Методы класса:
if ($params['status']) {
$this->setProperty('status',$params['status']);
}
$this->setProperty('updatedTimestamp',time());
$this->setProperty("alive",1);
$ot=$this->object_title;
$alive_timeout=(int)$this->getProperty("aliveTimeOut");
if (!$alive_timeout) {
$alive_timeout=12*60*60;
}
clearTimeOut($ot."_alive");
setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout);Объекты класса:
if ((int)$params['status']==0) {
say("Внимание! Открыта входная дверь.",5);
} else {
say("Входная дверь закрыта",5);
}
if ($params['status']) {
$this->setProperty('statusText','закрыта');
} else {
$this->setProperty('statusText','открыта');
}Свойства класса:
Методы класса:
$this->setProperty('status',$params['status']); // выставляем статус сенсора
$this->setProperty('updatedTimestamp',time()); // выставляем время срабатывания сенсора
$this->setProperty('alive',1);
$ot=$this->object_title;
$alive_timeout=(int)$this->getProperty("aliveTimeOut");
if (!$alive_timeout) {
$alive_timeout=24*60*60;
}
clearTimeOut($ot."_alive");
setTimeOut($ot."_alive","sg('".$ot.".alive',0);",$alive_timeout);
if ($params['status']) {
$this->setProperty('motionDetected',1);
clearTimeOut($this->object_title.'_detected');
setTimeOut($this->object_title.'_detected',"setGlobal('".$this->object_title.".motionDetected',0);",30);
$linked_room=$this->getProperty('LinkedRoom');
if ($linked_room!='') {
callMethod($linked_room.'.onActivity');
}
if ($this->object_title=='sensorMovement3' || $this->object_title=='sensorMovementRemote1' || $this->object_title=='sensorMovementRemote2') {
//|| $this->object_title=='sensorMovement5'
return; // не реагируем на движение в спальне, по ip-сенсорам и по сенсору на втром этаже
}
ClearTimeOut("nobodyHome");
SetTimeOut("nobodyHome","callMethod('NobodyHomeMode.activate');", 1*60*60); // выполняем если целый час никого не было
if (getGlobal('NobodyHomeMode.active')) {
callMethod('NobodyHomeMode.deactivate');
}
$last_register=registeredEventTime('inhouseMovement'); // проверяем когда в последний раз срабатывало событие "движение внутри дома"
registerEvent('inhouseMovement',$this->name,2); // регистрируем событие "движение внутри дома"
if (timeBetween('05:00', '12:00') && ((time()-$last_register)>2*60*60)) {
runScript('Greeting'); // запускаем скрипт "доброе утро"
}
}Объекты класса:
Свойства класса:
Методы класса:
say("Выключаю комп",1);
runScript("SuperPC_Off");
say("Включаю комп",1);
runScript("SuperPC_On");
$status=$this->getProperty("status");
if ($status == 2) {
$this->callMethod('WOL_Off');
} else if ($status == 1) {
$this->callMethod('WOL_On');
}Объекты класса:
Свойства класса:
Методы класса:
$WindDirection = $this->getProperty("wind_direction");
if ((int)$WindDirection > 350) {$naprWeter ='cеверный';}
elseif ($WindDirection > 280) {$naprWeter ='cеверо-западный';}
elseif ($WindDirection > 260) {$naprWeter ='западный';}
elseif ($WindDirection > 190) {$naprWeter ='юго-западный';}
elseif ($WindDirection > 170) {$naprWeter ='южный';}
elseif ($WindDirection > 100) {$naprWeter ='юго-восточный';}
elseif ($WindDirection > 80) {$naprWeter ='восточный';}
elseif ($WindDirection > 10) {$naprWeter ='северо-восточный';}
else {$naprWeter ='северный';}
$this->setProperty("wind_direction_text", $naprWeter);Объекты класса:
Свойства класса:
Методы класса:
$this->setProperty("updated",time());
$this->setProperty("updatedTime",date('H:i'));
if ($this->getProperty('active')) {
say("Режим ".$this->getProperty('title')." активирован.");
} else {
say("Режим ".$this->getProperty('title')." выключен.");
}$this->setProperty('active',1);$this->setProperty('active',0);Объекты класса:
setGlobal('minMsgLevel','3');
// Users
$objects=getObjectsByClass("Users");
foreach($objects as $obj) {
if (getGlobal($obj['TITLE'].".online") == 1){
if (getGlobal($obj['TITLE'].".BattLevel") < 50){
say( getGlobal($obj['TITLE'].".fullName")." , не забудьте поставить телефон на зарядку" );
}
}
}
setGlobal('minMsgLevel','1');Объекты класса:
include_once(DIR_MODULES.'app_radio/app_radio.class.php');
$app_radio=new app_radio();
if(is_array($params))
{
if(isset($params['sta'])) $app_radio->change_station($params['sta'],$app_radio);
if(isset($params['cmd'])) $app_radio->control($params['cmd']);
if(isset($params['vol'])) $app_radio->set_volume($params['vol'],$app_radio);
}
else
{
if($params=='play' || $params=='stop') $app_radio->control($params);
else if(strpos($params, "vol")===0) $app_radio->set_volume((int)substr($params,3),$app_radio);
else if(strpos($params, "sta:")===0) $app_radio->change_station(substr($params,4),$app_radio);
}Свойства класса:
Методы класса:
if (($this->getProperty("Code")) =="1250419")
{
$this->setProperty('status',1);
say("Хуй",2);
}else if (($this->getProperty("Code")) =="1250428")
{
$this->setProperty('status',0);
say("Пизда",2);
} Объекты класса:
Свойства класса:
Методы класса:
$status=$this->getProperty("status");
if ($status) {
$this->callMethod('turnOn');
} else {
$this->callMethod('turnOff');
}$status=$this->getProperty("status");
if ($status) {
$this->callMethod('turnOff');
} else {
$this->callMethod('turnOn');
}$this->setProperty("status",0);$this->setProperty("status",1);Объекты класса:
Свойства класса:
Методы класса:
$cmdline='"c:\Program Files\nooLite\nooLite.exe" -api '.$params['command'];
$last_called=gg('NoolightCommandSend');
$min_delay=3;
$now=time();
if (($now-$last_called)>$min_delay) {
//safe_exec($cmdline);
$last_callled=$now;
sg('NoolightCommandSend',$last_called);
DebMes("Noolite instant exec: ".$cmdline);
system($cmdline);
//exec($cmdline);
} else {
if ($last_callled<$now) {
$last_callled=$now;
}
$last_called+=$min_delay;
sg('NoolightCommandSend',$last_called);
DebMes("Noolite scheduled job for ".date('H:i:s',$last_called));
AddScheduledJob("noolight".md5($cmdline),"safe_exec('".$cmdline."');",$last_called);
}
$this->setProperty("status",0);
//safe_exec('"c:\Program Files\nooLite\noolite.exe" -api -off_ch'.$this->getProperty("channel"));
$this->callMethod("sendCommand",array('command'=>'-off_ch'.$this->getProperty("channel")));$this->setProperty("status",1);
$this->callMethod("sendCommand",array('command'=>'-on_ch'.$this->getProperty("channel")));Свойства класса:
Методы класса:
$code1=$this->getProperty('Code1');
$code2=$this->getProperty('Code2');
safe_exec("c:\_majordomo\apps\arduino_gw\arduino_gw.exe rcon$code1:$code2;");
$this->setProperty("status",1);$code1=$this->getProperty('Code1');
$code2=$this->getProperty('Code2');
safe_exec("c:\_majordomo\apps\arduino_gw\arduino_gw.exe rcoff$code1:$code2;");
$this->setProperty("status",0);Свойства класса:
Методы класса:
$latestActivity=$this->getProperty('LatestActivity');
$this->setProperty('LatestActivity',time());
$this->setProperty('LatestActivityTime',date('H:i'));
$this->setProperty('SomebodyHere',1);
$ot=$this->object_title;
if ($this->getProperty("IdleDelay")) {
$activity_timeout=(int)$this->getProperty("IdleDelay");
} else {
$activity_timeout=10*60;
}
clearTimeOut($ot."_activity_timeout");
setTimeOut($ot."_activity_timeout","callMethod('".$ot.".onIdle');",$activity_timeout);
$this->callMethod("updateActivityStatus");
$this->setProperty('SomebodyHere',0);$rooms=getObjectsByClass("Rooms");
$total=count($rooms);
for($i=0;$i<$total;$i++) {
$rooms[$i]['room']=getGlobal($rooms[$i]['TITLE'].'.Title');
if (!$rooms[$i]['room']) {
$rooms[$i]['room']=$rooms[$i]['TITLE'];
}
$rooms[$i]['active']=getGlobal($rooms[$i]['TITLE'].'.SomebodyHere');
$rooms[$i]['time']=getGlobal($rooms[$i]['TITLE'].'.LatestActivity');
$rooms[$i]['diff']=time()-$rooms[$i]['time'];
}
function cmp($a, $b)
{
if ($a['diff'] == $b['diff']) {
return 0;
}
return ($a['diff'] < $b['diff']) ? -1 : 1;
}
usort($rooms,"cmp");
if (!$rooms[0]['active']) {
$somebodyHomeText="Никого нет дома. Были в ".date('H:i',$rooms[0]['time'])." (".$rooms[0]['room'].")";
} else {
$res_rooms=array();
for($i=0;$i<$total;$i++) {
if ($rooms[$i]['active']) {
$res_rooms[]=$rooms[$i]['room'];
}
}
$somebodyHomeText="Кто-то дома: ".implode(", ",$res_rooms);
}
setGlobal('somebodyHomeText',$somebodyHomeText);
//echo "Updated";Объекты класса:
Методы класса:
Объекты класса:
echo "status received: ".$params['status'];
global $voicemode; $voicemode='off'; processCommand($params['message']);
Свойства класса:
Методы класса:
Объекты класса:
$details=array();
$red_state=0;
$yellow_state=0;
if (!isOnline('Internet')) {
$yellow_state=1;
$details[]=LANG_GENERAL_NO_INTERNET_ACCESS;
}
if ($red_state) {
$state='red';
$state_title=LANG_GENERAL_RED;
} elseif ($yellow_state) {
$state='yellow';
$state_title=LANG_GENERAL_YELLOW;
} else {
$state='green';
$state_title=LANG_GENERAL_GREEN;
}
$new_details=implode(". ",$details);
if ($this->getProperty("stateDetails")!=$new_details) {
$this->setProperty('stateDetails',$new_details);
}
if ($this->getProperty('stateColor')!=$state) {
$this->setProperty('stateColor',$state);
$this->setProperty('stateTitle',$state_title);
if ($state!='green') {
say(LANG_GENERAL_COMMUNICATION_STATE." ".LANG_GENERAL_CHANGED_TO." ".$state_title.".");
say(implode(". ",$details));
} else {
say(LANG_GENERAL_COMMUNICATION_STATE." ".LANG_GENERAL_RESTORED_TO." ".$state_title);
}
$this->callMethod('stateChanged');
}$details=array();
$red_state=0;
$yellow_state=0;
if ($red_state) {
$state='red';
$state_title=LANG_GENERAL_RED;
} elseif ($yellow_state) {
$state='yellow';
$state_title=LANG_GENERAL_YELLOW;
} else {
$state='green';
$state_title=LANG_GENERAL_GREEN;
}
$new_details=implode(". ",$details);
if ($this->getProperty("stateDetails")!=$new_details) {
$this->setProperty('stateDetails',$new_details);
}
if ($this->getProperty('stateColor')!=$state) {
$this->setProperty('stateColor',$state);
$this->setProperty('stateTitle',$state_title);
if ($state!='green') {
say(LANG_GENERAL_SECURITY_STATE." ".LANG_GENERAL_CHANGED_TO." ".$state_title.".");
say(implode(". ",$details));
} else {
say(LANG_GENERAL_SECURITY_STATE." ".LANG_GENERAL_RESTORED_TO." ".$state_title);
}
$this->callMethod('stateChanged');
}$details=array();
$red_state=0;
$yellow_state=0;
$cycles=array('states'=>'states','main'=>'main','execs'=>'exec','scheduler'=>'scheduler');
foreach($cycles as $k=>$v) {
$tm=getGlobal('ThisComputer.cycle_'.$k.'Run');
if (time()-$tm>5*60) {
$red_state=1;
$details[]=$v." ".LANG_GENERAL_CYCLE." ".LANG_GENERAL_STOPPED.".";
}
}
$cycles=array('ping'=>'ping','webvars'=>'webvars');
foreach($cycles as $k=>$v) {
$tm=getGlobal('ThisComputer.cycle_'.$k.'Run');
if (time()-$tm>10*60) {
$yellow_state=1;
$details[]=$v." ".LANG_GENERAL_CYCLE." ".LANG_GENERAL_STOPPED.".";
}
}
if ($red_state) {
$state='red';
$state_title=LANG_GENERAL_RED;
} elseif ($yellow_state) {
$state='yellow';
$state_title=LANG_GENERAL_YELLOW;
} else {
$state='green';
$state_title=LANG_GENERAL_GREEN;
}
$new_details=implode(". ",$details);
if ($this->getProperty("stateDetails")!=$new_details) {
$this->setProperty('stateDetails',$new_details);
}
if ($this->getProperty('stateColor')!=$state) {
$this->setProperty('stateColor',$state);
$this->setProperty('stateTitle',$state_title);
if ($state!='green') {
say(LANG_GENERAL_SYSTEM_STATE." ".LANG_GENERAL_CHANGED_TO." ".$state_title.".");
say(implode(". ",$details));
} else {
say(LANG_GENERAL_SYSTEM_STATE." ".LANG_GENERAL_RESTORED_TO." ".$state_title);
}
$this->callMethod('stateChanged');
}Свойства класса:
Методы класса:
//$params['t']
$this->setProperty("updated",time());
$this->setProperty("updatedTime",date("H:i",time()));
$this->setProperty("alive",1);
$this->setProperty("aliveIcon", 'fa fa-check');
$ot=$this->object_title;
$alive_timeout=(int)$this->getProperty("aliveTimeOut");
if (!$alive_timeout) {
$alive_timeout=30*60;
}
clearTimeOut($ot."_alive");
setTimeOut($ot."_alive","sg('".$ot.".alive',0); sg('".$ot.".aliveIcon', 'fa fa-times');",$alive_timeout);
if (!isset($params['t'])) {
return;
}
$old_temp=$this->getProperty('temp');
$t=round($params['t'],1);
if ($t>110) return;
$this->setProperty('temp',$t);
if ($params['uptime']) {
$this->setProperty('uptime',$params['uptime']);
}
if ($t>$old_temp) {
$d=1;
} elseif ($t<$old_temp) {
$d=-1;
} else {
$d=0;
}
$this->setProperty('direction',$d);
$linked_room=$this->getProperty("LinkedRoom");
if ($linked_room) {
setGlobal($linked_room.'.Temperature',$t);
}Объекты класса:
Свойства класса:
Методы класса:
/* START yaWeather module*/
$updateTime = gg('yw_setting.updateTime');
if($updateTime > 0){
$count = gg('yw_setting.countTime');
if($count >= $updateTime){
include_once(DIR_MODULES.'app_yaweather/app_yaweather.class.php');
$app_yaweather=new app_yaweather();
$app_yaweather->get_weather(gg('yw_setting.city_id'));
sg('yw_setting.countTime',1);
} else {
$count++;
sg('yw_setting.countTime',$count);
}
}/* END yaWeather*///START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather module//START openweather module
$updateTime = gg('ow_setting.updateTime');
if($updateTime > 0)
{
$count = gg('ow_setting.countTime');
if($count >= $updateTime)
{
include_once(DIR_MODULES . 'app_openweather/app_openweather.class.php');
$app_openweather = new app_openweather();
$app_openweather->get_weather(gg('ow_city.id'));
sg('ow_setting.countTime', 1);
}
else
{
$count++;
sg('ow_setting.countTime', $count);
}
}
// END openweather moduleОбъекты класса:
$h=(int)date('G',time());
$m=date('i',time());
if (isWeekDay()) {
}
if (($h>=8) && getGlobal('clockChimeEnabled')) {
if ($m=="00") {
say(timeNow(),1);
}
}
setGlobal('timeNow',date('H:i'));
$homeStatus=date('H:i');
if (getGlobal('NobodyHomeMode.active')) {
$homeStatus.=' Дома никого';
} else {
$homeStatus.=' Дома кто-то есть';
}
$homeStatus.=' '.getGlobal('Security.stateDetails');
$homeStatus.=' '.getGlobal('System.stateDetails');
$homeStatus.=' '.getGlobal('Communication.stateDetails');
setGlobal('HomeStatus',$homeStatus);
if (timeBetween(getGlobal('SunRiseTime'),getGlobal('SunSetTime')) && getGlobal('isDark')=="1") {
setGlobal("isDark",0);
callMethod('DarknessMode.deactivate');
} elseif (!timeBetween(getGlobal('SunRiseTime'),getGlobal('SunSetTime')) && getGlobal('isDark')!="1") {
setGlobal("isDark",1);
callMethod('DarknessMode.activate');
}
if (timeIs(getGlobal('SunRiseTime'))) {
say('Всходит солнце');
}
if (timeIs(getGlobal('SunSetTime'))) {
say('Солнце заходит',2);
}
if (timeIs("23:30") && (gg("EconomMode.active")!="1") && (gg("NobodyHomeMode.active")=="1")) {
say("Похоже никого нет сегодня, можно сэкономить немного.");
callMethod('EconomMode.activate');
}
if (timeIs('20:00')) {
callMethod('NightMode.activate');
} elseif (timeIs('08:00')) {
callMethod('NightMode.deactivate');
}
if (timeIs("03:00")) {
runScript("systemMaintenance");
}
if (gg('ThisComputer.AlarmStatus') && timeIs(gg('ThisComputer.AlarmTime'))) {
runScript('MorningAlarm');
}
//будильник
$objects=getObjectsByClass("AlarmClock");
foreach($objects as $obj) { // переберем все будильники в системе
if (getGlobal($obj['TITLE'].".AlarmOn") && timeIs(getGlobal($obj['TITLE'].".AlarmTime"))){ //если будильник включен и время совпало
callMethod($obj['TITLE'].".AlarmRun"); // выполним метод будильника
}
}
// получем ЧАСЫ и МИНУТЫ отдельно
$timeH=date("H", time());
$timeM=date("i", time());
sg("ThisComputer.timeH",$timeH);
sg("ThisComputer.timeM",$timeM);
// Заспуск скрипта "1 раз в 2 секунды" для HardWareMonitor
runScript('timer_2s');
if (timeIs("07:00")) {
runScript('kursValut');
}// раскидываем дату и время если изменилось в Windows
$h=(int)date('G',time());
if (gg('ThisComputer.DateD')!=date("d", time())) {
$day[0]="воскресенье";
$day[1]="понедельник";
$day[2]="вторник";
$day[3]="среда";
$day[4]="четверг";
$day[5]="пятница";
$day[6]="суббота";
$month[1]="января";
$monthAlt[1]="ЯНВАРЬ";
$month[2]="февраля";
$monthAlt[2]="ФЕВРАЛЬ";
$month[3]="марта";
$monthAlt[3]="МАРТ";
$month[4]="апреля";
$monthAlt[4]="АПРЕЛЬ";
$month[5]="мая";
$monthAlt[5]="МАЙ";
$month[6]="июня";
$monthAlt[6]="ИЮНЬ";
$month[7]="июля";
$monthAlt[7]="ИЮЛЬ";
$month[8]="августа";
$monthAlt[8]="АВГУСТ";
$month[9]="сентября";
$monthAlt[9]="СЕНТЯБРЬ";
$month[10]="октября";
$monthAlt[10]="ОКТЯБРЬ";
$month[11]="ноября";
$monthAlt[11]="НОЯБРЬ";
$month[12]="декабря";
$monthAlt[12]="ДЕКАБРЬ";
sg("ThisComputer.DateD",date( "d", time()));
sg("ThisComputer.DateM",date( "m", time()));
sg("ThisComputer.DateY",date( "Y", time()));
sg("ThisComputer.Date",date( "d.m.Y", time()));
sg("ThisComputer.Day",$day[date("w")]);
sg("ThisComputer.Month",$month[date("n")]);
sg("ThisComputer.MonthAlt",$monthAlt[date("n")]);
}
Свойства класса:
Методы класса:
// МЕТОД view - подготовка кода для отображения
$todo = $this->getProperty("todo");
// установим внутреннюю кодировку символов
mb_internal_encoding("UTF-8");
$td = explode("|", $todo);
$str_cod = '<div id="list">
<div class="new">
<input id="newtask" placeholder="New Item" type="text">
<button onClick="btnRunClicked();" class="fa fa-plus"></button>
</div>
<div class="list">';
for($i = 1; $i < sizeof($td); $i++) {
// выделим и сохраним первый символ
$check = mb_substr($td[$i], 0, 1);
// обрежем строку, не будем отображать первый символ + или -
$task = mb_substr($td[$i], 1);
// начинаем формировать код hsl(196,'.(73-24*(($i-1)%2)).'%,50%)
$str_cod = $str_cod.'
<div class="item" id="taskbox_'.$i.'" style ="background: hsl('.(190+$i*6).',73%,50%);">
<span id="task_'.$i.'"';
// если певый символ "+" то значит задание "выполнено"
if ($check == "+") {
$str_cod = $str_cod.' class="checked"';
}
$str_cod = $str_cod.'>'.$task.'</span>';
$str_cod = $str_cod.'
<div class="rightblock">
<button id="check_'.$i.'" class="check fa fa-check" onClick="checkClicked('.$i.');"></button>
<button id="delete_'.$i.'" class="delete fa fa-times" onClick="deleteClicked('.$i.');"></button>
</div>
</div>';
}
$str_cod = $str_cod.'
</div>
</div>';
// записываем получившийся код
$this->setProperty("StreamingCodeScene",$str_cod);
$str_cod_css = "<style>".$this->getProperty("menuCSS")."</style>";
$str_cod_js = "<script type='text/javascript'>".$this->getProperty("JS")."</script>";
$str_cod = $str_cod_css.$str_cod_js.$str_cod;
$this->setProperty("StreamingCodeMenu",$str_cod);
// МЕТОД check
$todo = $this->getProperty("todo");
// установим внутреннюю кодировку символов
mb_internal_encoding("UTF-8");
$td = explode("|", $todo);
if (isset($params["task"])) {
$ct = $params["task"];
for($i = 0; ($i < sizeof($td)); $i++) {
// выделим и сохраним первый символ
$check = mb_substr($td[$i], 0, 1);
// обрежем строку, не будем отображать первый символ + или -
$task = mb_substr($td[$i], 1);
// если совпадает номер строки
if ($i == $ct) {
// инвентируем check
$check = ($check == "+") ? "-" : "+";
$tcheck = ($check == "+") ? "выполненно" : "не выполнено";
$sayTodo = gg("Sets.sayTodo");
if ($sayTodo) {
say ("Todo задача:".$task." - отмечена как ".$tcheck,($sayTodo-2));
}
}
$td[$i] = $check.$task;
}
$todo = implode("|", $td);
$this->setProperty("todo", $todo);
}
// выполним подготовку для отображения
// callMethod("TodoList.view");
// МЕТОД delete
$todo = $this->getProperty("todo");
$dt = $params["task"]; // получаем номер строки на удаление
$td = explode("|", $todo); // Считываем всё в массив
for($i = 0; $i < sizeof($td); $i++) {
if($i == $dt) {
$sayTodo = gg("Sets.sayTodo");
if ($sayTodo) {
say ("Из листа todo удалена задача:".mb_substr($td[$i], 1)."",($sayTodo-2));
}
unset($td[$i]);
}
}
$todo = implode("|", $td);
$this->setProperty("todo", $todo);
// выполним подготовку для отображения
// callMethod("TodoList.view");
// МЕТОД new
if (isset($params["task"])) {
$todo = $this->getProperty("todo");
$mytask = "-".$params["task"]; // строка задачи
$sayTodo = gg("Sets.sayTodo");
if ($sayTodo) {
say ("В лист todo добавлена задача:".$params["task"]."",($sayTodo-2));
}
$todo = $todo."|".$mytask; // добавляем с разделителем
$this->setProperty("todo", $todo);
}
Объекты класса:
// ******************************************************************
// * TO DO app - by Vovix - 30.11.2015 г. - v 3.1 *
// ******************************************************************
// создадим класс и объекты
addClass('ToDo');
addClassObject('ToDo','TodoList');
addClassProperty('ToDo','StreamingCodeMenu'); // HTML для меню
addClassProperty('ToDo','StreamingCodeScene'); // HTML для сцен
addClassProperty('ToDo','menuCSS'); // CSS для меню
addClassProperty('ToDo','sceneCSS'); // CSS для сцены
addClassProperty('ToDo','JS'); // общий код javascript
addClassProperty('ToDo','todo'); // сам лист to do
//
$this->setProperty('todo', '- to do list by Vovix -');
$menuCSS='
@import url("https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css");
#item194 { /* здесь item194 - это номер ID пункта меню в котором он размещен */
padding: 0;
}
#list {
position: relative;
/* width: calc(100% + 40px); */
/* margin: 0 -20px 0 -20px; */
width: 100%;
margin: 0;
}
#list .new {
width: 100%;
height: 50px;
padding: 0;
margin: 0;
}
#list .new #newtask {
float: left;
width: calc(100% - 76px);
height: 50px;
padding: 0;
margin: 0;
background: #333333;
text-indent: 8px;
}
#list .new input {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 14px;
color: #FFF;
text-align: justify;
line-height: normal;
outline: 0;
border: 0;
border-radius: 0px;
text-shadow: none;
}
#list .new #newtask::-webkit-input-placeholder {
color: rgba(255, 255, 255, 0.5);
}
#list .new button {
cursor: pointer;
float: right;
width: 76px;
height: 50px;
padding: 0;
outline: 0;
border: 0;
border-radius: 0px;
margin: -9px 0 0 0;
background: #111111;
font-size: 24px;
color: #FFF;
}
#list .list .item {
clear: both;
width: 100%;
height: 38px;
margin: 0;
}
#list .list .item span {
cursor: default;
float: left;
width: calc(100% - 76px);
height: 20px;
padding: 9px 0 0 0;
margin: 0;
outline: 0;
border: 0;
background: transparent;
text-indent: 8px;
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 14px;
color: #FFF;
text-align: justify;
text-shadow: none;
}
#list .list .item span.checked {
opacity: .5;
text-decoration: line-through;
}
#list .list .item .rightblock {
float: right;
width: 76px;
height: 38px;
padding: 0;
margin: 0;
}
#list .list .item .rightblock button {
cursor: pointer;
float: left;
width: 38px;
height: 38px;
padding: 0px;
margin: 0;
outline: 0;
border: 0;
border-radius: 0px;
background: rgba(0,0,0,0.1);
font-size: 20px;
color: #FFF;
}
';
$this->setProperty('menuCSS', $menuCSS);
$sceneCSS='
#list {
position: relative;
width: 100%;
max-height: 528px;
overflow: auto;
margin: 0;
}
#list .new #newtask {
float: left;
width: calc(100% - 100px);
height: 100px;
padding: 0;
margin: 0;
outline: 0;
border: 0;
background: #333333;
line-height: 50px;
text-indent: 25px;
}
#list .new input {
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 28px;
color: #FFF;
text-align: justify;
line-height: normal;
outline: 0;
border: 0;
border-radius: 0px;
text-shadow: 0px;
}
#list .new #newtask::-webkit-input-placeholder {
color: rgba(255, 255, 255, 0.5);
}
#list .new button {
cursor: pointer;
float: right;
width: 100px;
height: 100px;
padding: 0;
margin: 0;
outline: 0;
border: 0;
border-radius: 0px;
background: #111111;
font-size: 84px;
color: #FFF;
}
#list .list .item {
clear: both;
width: 100%;
height: 50px;
margin: 0;
padding: 5px 0 0 0;
}
#list .list .item span {
cursor: default;
float: left;
width: calc(100% - 150px);
height: 50px;
padding: 0;
margin: 0;
outline: 0;
border: 0;
background: transparent;
text-indent: 25px;
font-family: "Lucida Sans Unicode", "Lucida Grande", sans-serif;
font-size: 28px;
color: #FFF;
text-align: justify;
line-height: normal;
}
#list .list .item span.checked {
opacity: .5;
text-decoration: line-through;
}
#list .list .item .rightblock {
float: right;
padding: 0;
margin: -2px 0 0 0;
}
#list .list .item button{
cursor: pointer;
float: left;
width: 50px;
height: 50px;
padding: 0;
margin: 0;
outline: 0;
border: 0;
box-shadow: 0 0 3px rgba(0,0,0,0.2);
background: rgba(0,0,0,0.1);
font-size: 32px;
color: #FFF;
}
';
$this->setProperty('sceneCSS', $sceneCSS);
$JS='
function btnRunClicked() {
var newtask = $("#newtask").val(),
ni = $("div.item").length + 1;
$("#newtask").val("");
if (newtask) {
var task1 = String(newtask);
var codItem1 = \'<div class="item" id="taskbox_\' + ni + \'" style ="background: hsl(\' + (190+ni*6) + \',73%,50%);">\';
var codItem2 = \'<span id="task_\' + ni + \'">\' + task1 + \'</span>\';
var codItem3 = \'<div class="rightblock"><button id="check_\' + ni + \'" class="check fa fa-check ui-btn ui-shadow ui-corner-all" onClick="checkClicked(\' + ni +\');"></button>\';
var codItem4 = \'<button id="delete_\' + ni + \'" class="delete fa fa-times ui-btn ui-shadow ui-corner-all" onClick="deleteClicked(\' + ni + \');"></button></div></div>\';
$.get( "/objects/", { object:"TodoList", op:"m", m:"new", task:newtask } );
setTimeout(function() { $.get( "/objects/", { object:"TodoList", op:"m", m:"view" } ) }, 100);
$(codItem1 + codItem2 + codItem3 + codItem4).appendTo("div.list");
return false;
}
}
function checkClicked(ctask) {
if (ctask) {
$.get( "/objects/", { object:"TodoList", op:"m",m:"check", task:ctask } );
$("#task_"+ctask).toggleClass("checked");
setTimeout(function() { $.get( "/objects/", { object:"TodoList", op:"m", m:"view" } ) }, 100);
return false;
}
}
function deleteClicked(dtask) {
if (dtask) {
$.get( "/objects/", { object:"TodoList", op:"m", m:"delete", task:dtask } );
$("#taskbox_"+dtask).remove();
setTimeout(function() { $.get( "/objects/", { object:"TodoList", op:"m", m:"view" } ) }, 100);
return false;
}
}
';
$this->setProperty('JS', $JS);
$view='
// МЕТОД view - подготовка кода для отображения
$todo = $this->getProperty("todo");
// установим внутреннюю кодировку символов
mb_internal_encoding("UTF-8");
$td = explode("|", $todo);
$str_cod = \'<div id="list">
<div class="new">
<input id="newtask" placeholder="New Item" type="text">
<button onClick="btnRunClicked();" class="fa fa-plus"></button>
</div>
<div class="list">\';
for($i = 1; $i < sizeof($td); $i++) {
// выделим и сохраним первый символ
$check = mb_substr($td[$i], 0, 1);
// обрежем строку, не будем отображать первый символ + или -
$task = mb_substr($td[$i], 1);
// начинаем формировать код hsl(196,\'.(73-24*(($i-1)%2)).\'%,50%)
$str_cod = $str_cod.\'
<div class="item" id="taskbox_\'.$i.\'" style ="background: hsl(\'.(190+$i*6).\',73%,50%);">
<span id="task_\'.$i.\'"\';
// если певый символ "+" то значит задание "выполнено"
if ($check == "+") {
$str_cod = $str_cod.\' class="checked"\';
}
$str_cod = $str_cod.\'>\'.$task.\'</span>\';
$str_cod = $str_cod.\'
<div class="rightblock">
<button id="check_\'.$i.\'" class="check fa fa-check" onClick="checkClicked(\'.$i.\');"></button>
<button id="delete_\'.$i.\'" class="delete fa fa-times" onClick="deleteClicked(\'.$i.\');"></button>
</div>
</div>\';
}
$str_cod = $str_cod.\'
</div>
</div>\';
// записываем получившийся код
$this->setProperty("StreamingCodeScene",$str_cod);
$str_cod_css = "<style>".$this->getProperty("menuCSS")."</style>";
$str_cod_js = "<script type=\'text/javascript\'>".$this->getProperty("JS")."</script>";
$str_cod = $str_cod_css.$str_cod_js.$str_cod;
$this->setProperty("StreamingCodeMenu",$str_cod);
';
addClassMethod('ToDo', 'view', $view);
$check='
// МЕТОД check
$todo = $this->getProperty("todo");
// установим внутреннюю кодировку символов
mb_internal_encoding("UTF-8");
$td = explode("|", $todo);
if (isset($params["task"])) {
$ct = $params["task"];
for($i = 0; ($i < sizeof($td)); $i++) {
// выделим и сохраним первый символ
$check = mb_substr($td[$i], 0, 1);
// обрежем строку, не будем отображать первый символ + или -
$task = mb_substr($td[$i], 1);
// если совпадает номер строки
if ($i == $ct) {
// инвентируем check
$check = ($check == "+") ? "-" : "+";
$tcheck = ($check == "+") ? ""выполненно"" : ""не выполнено"";
$sayTodo = gg("Sets.sayTodo");
if ($sayTodo) {
say ("Todo задача: "".$task."" - отмечена как ".$tcheck,($sayTodo-2));
}
}
$td[$i] = $check.$task;
}
$todo = implode("|", $td);
$this->setProperty("todo", $todo);
}
// выполним подготовку для отображения
// callMethod("TodoList.view");
';
addClassMethod('ToDo', 'check', $check);
$delete = '
// МЕТОД delete
$todo = $this->getProperty("todo");
$dt = $params["task"]; // получаем номер строки на удаление
$td = explode("|", $todo); // Считываем всё в массив
for($i = 0; $i < sizeof($td); $i++) {
if($i == $dt) {
$sayTodo = gg("Sets.sayTodo");
if ($sayTodo) {
say ("Из листа todo удалена задача: "".mb_substr($td[$i], 1).""",($sayTodo-2));
}
unset($td[$i]);
}
}
$todo = implode("|", $td);
$this->setProperty("todo", $todo);
// выполним подготовку для отображения
// callMethod("TodoList.view");
';
addClassMethod('ToDo', 'delete', $delete);
$new = '
// МЕТОД new
if (isset($params["task"])) {
$todo = $this->getProperty("todo");
$mytask = "-".$params["task"]; // строка задачи
$sayTodo = gg("Sets.sayTodo");
if ($sayTodo) {
say ("В лист todo добавлена задача: "".$params["task"].""",($sayTodo-2));
}
$todo = $todo."|".$mytask; // добавляем с разделителем
$this->setProperty("todo", $todo);
}
';
addClassMethod('ToDo', 'new', $new);
callMethod("TodoList.view");
Методы класса:
Объекты класса:
if ($params['serial']=='' && $params['devname']!='') {
$params['serial']=$params['devname'];
}
$device=SQLSelectOne("SELECT * FROM usbdevices WHERE SERIAL LIKE '".$params['serial']."'");
if (!$device['ID']) {
// new device connected
//say("Подключено новое устройство",1);
$device=array();
$device['SERIAL']=$params['serial'];
$device['TITLE']='устройство '.$params['devname'];
$device['FIRST_FOUND']=date('Y-m-d H:i:s');
$device['LAST_FOUND']=date('Y-m-d H:i:s');
$device['LOG'].=$device['FIRST_FOUND'].' подключено (впервые)'."\n";
$device['ID']=SQLInsert('usbdevices',$device);
} else {
// device already in our database
//say("Подключено ".$device['TITLE'],1);
if ($device['USER_ID']) {
$user=SQLSelectOne("SELECT * FROM users WHERE ID='".$device['USER_ID']."'");
if ($user['ID']) {
//$user['NAME']; // теперь мы знаем имя пользователя, связанного с этим устройством
}
}
$device['LAST_FOUND']=date('Y-m-d H:i:s');
$device['LOG']=$device['LAST_FOUND'].' подключено'."\n".$device['LOG'];
SQLUpdate('usbdevices',$device);
if ($device['SCRIPT_ID']!='') {
runScript($device['SCRIPT_ID'],$params);
} elseif ($device['SCRIPT']!='') {
eval($device['SCRIPT']);
}
}Свойства класса:
Методы класса:
$level=$this->getProperty("BattLevel");
if ($level > 88 && $level <= 100) {
$this->setProperty("battPic",'fa fa-battery-full');
} else if ($level > 62 && $level <= 88) {
$this->setProperty("battPic",'fa fa-battery-three-quarters');
} else if ($level > 37 && $level <= 62) {
$this->setProperty("battPic",'fa fa-battery-half');
} else if ($level > 12 && $level <= 37) {
$this->setProperty("battPic",'fa fa-battery-quarter');
} else if ($level < 12) {
$this->setProperty("battPic",'fa fa-battery-empty');
}$status = $this->getProperty("online");
$name = $this->getProperty("fullName");
$long = $this->getProperty("howLong");
$alive_timeout1=30*60; // 1 уровень отсутствия 30 мин
$alive_timeout2=1*60*60; // 2 уровень отсутствия 1 час
$alive_timeout3=8*60*60; // 3 уровень отсутствия 8 часов
$alive_timeout4=24*60*60; // 4 уровень отсутствия 24 часа
$ot=$this->object_title;
if ($status == 1) {
switch ($long) {
case "1":
say("С возвращением, ".$name, 2);
break;
case "2":
say("И снова здравствуйте, ".$name, 2);
break;
case "3":
say("Привет, '.$name.'. Рада вас видеть", 2);
break;
case "3":
say("Вас долго не было, '.$name'. Я уже начала скучать", 2);
break;
}
$this->setProperty("howLong", 0);
}
elseif ($status == 2) {
clearTimeOut($ot."_alive1");
clearTimeOut($ot."_alive2");
clearTimeOut($ot."_alive3");
clearTimeOut($ot."_alive3");
setTimeOut($ot."_alive1","sg('".$ot.".howLong',1);",$alive_timeout1);
setTimeOut($ot."_alive2","sg('".$ot.".howLong',2);",$alive_timeout2);
setTimeOut($ot."_alive3","sg('".$ot.".howLong',3);",$alive_timeout3);
setTimeOut($ot."_alive4","sg('".$ot.".howLong',4);",$alive_timeout4);
}
Объекты класса:
Свойства класса:
Объекты класса:
Свойства класса:
Методы класса:
//$params['t'];
$this->setProperty("updated",time());
$this->setProperty("updatedTime",date("H:i",time()));
$this->setProperty("alive",1);
$this->setProperty("aliveIcon", 'fa fa-check');
$ot=$this->object_title;
$alive_timeout=(int)$this->getProperty("aliveTimeOut");
if (!$alive_timeout) {
$alive_timeout=30*60;
}
clearTimeOut($ot."_alive");
setTimeOut($ot."_alive","sg('".$ot.".alive',0); sg('".$ot.".aliveIcon', 'fa fa-times');",$alive_timeout);
if (!isset($params['p'])) {
return;
}
$old_temp=$this->getProperty('pressure');
$t=round($params['p'],1);
if ($t>900) return;
$this->setProperty('pressure',$t);
if ($params['uptime']) {
$this->setProperty('uptime',$params['uptime']);
}
if ($t>$old_temp) {
$d = 'fa fa-caret-up';
} elseif ($t<$old_temp) {
$d = 'fa fa-caret-down';
} else {
$d= '';
}
$this->setProperty('direction',$d);Объекты класса:
, Россия
© 2026 SJLab | Реквизиты: Курицын С. С. ИНН 762001394609 | Контакты | Публичный договор
SmartLiving