Свойства класса:
Методы класса:
say('Пора вставати! Треба йти на роботу!', 1);
sleep(20);
runScript('playRadio');Объекты класса:
Свойства класса:
Методы класса:
$this->setProperty('volumeLevel',$params['VALUE']);
if (IsWindowsOs()) {
$volume=round(65535*$params['VALUE']/100);
safe_exec('..\\apps\\nircmd\\nircmdc setsysvolume '.$volume);
} else {
safe_exec('amixer sset PCM,0 '.$params['VALUE'].'%');
}
say("Изменилась громкость до ".$params['VALUE']." процентов");Объекты класса:
$command=$params['command'];
$short_command='';
$dt=recognizeTime($command,$short_command);
if (preg_match('/скажи сколько врем/uis',$command)) {
if ($dt>0) {
addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt);
say('Задача принята',2);
return;
}
global $voicemode;
$voicemode='on';
say('Сейчас '.timeNow(),2);
} elseif (preg_match('/сколько время/uis',$command)) {
if ($dt>0) {
addScheduledJob("command".$dt,"processCommand('".$short_command."');",$dt);
say('Задача принята');
echo $short_command;
return;
}
say('Сейчас '.timeNow());
} elseif (preg_match('/повтори (.+)/uis',$command,$m) || preg_match('/скажи (.+)/uis',$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('Неизвестная команда...',1);
}say("Отключено питание");Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/processHomebridgeMQTT.inc.php');
Объекты класса:
Объекты класса:
Свойства класса:
Методы класса:
$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','2');
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/nightmode_activate.php');
/* end injection of {SDevices} */setGlobal('minMsgLevel','1');
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/nightmode_deactivate.php');
/* end injection of {SDevices} */$objects=getObjectsByProperty('groupSunrise','=','1');
if (is_array($objects)) {
foreach($objects as $obj) {
callMethod($obj.'.turnOff');
}
}
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/darknessmode_deactivate.php');
/* end injection of {SDevices} */
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/darknessmode_activate.php');
/* end injection of {SDevices} */
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/nobodyhomemode_activate.php');
/* end injection of {SDevices} */
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/nobodyhomemode_deactivate.php');
/* end injection of {SDevices} */$objects=getObjectsByProperty('groupEco','=','1');
if (is_array($objects)) {
foreach($objects as $obj) {
callMethod($obj.'.turnOff');
}
}
$objects=getObjectsByProperty('allOffGroup','=','1');
if (is_array($objects)) {
foreach($objects as $obj) {
callMethod($obj.'.turnOff');
}
}
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/econommode_activate.php');
/* end injection of {SDevices} */if (gg('DarknessMode.active')) {
$objects=getObjectsByProperty('greetingOnGroup','=','1');
if (is_array($objects)) {
foreach($objects as $obj) {
callMethod($obj.'.turnOn');
}
}
}
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/econommode_deactivate.php');
/* end injection of {SDevices} */Объекты класса:
Методы класса:
Объекты класса:
/* begin injection of {app_radio} */
include_once(DIR_MODULES.'app_radio/app_radio.class.php');
$app_radio = new app_radio();
if(is_array($params)) {
foreach($params as $key=>$value) {
switch((string)$key) {
case 'sta': $app_radio->change_station($params['sta'], $app_radio); break;
case 'cmd': $app_radio->control($params['cmd']); break;
case 'vol': $app_radio->set_volume($params['vol'], $app_radio); break;
default:
if($value == 'play' || $value == 'stop') $app_radio->control($value);
elseif(strpos($value, 'vol') === 0) $app_radio->set_volume((int)substr($value, 3), $app_radio);
elseif(strpos($value, 'sta:') === 0) $app_radio->change_station(substr($value, 4), $app_radio);
}
}
}
/* end injection of {app_radio} */Свойства класса:
Методы класса:
$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");
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/Rooms_onActivity.php');
/* end injection of {SDevices} */$this->setProperty('SomebodyHere',0);
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/Rooms_onIdle.php');
/* end injection of {SDevices} */$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";
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/Rooms_updateActivityStatus.php');
/* end injection of {SDevices} */Объекты класса:
Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SDevices_statusUpdated.php');
require(DIR_MODULES.'devices/SDevices_logicAction.php');
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SDevices_setUpdatedText.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SButtons_pressed.php');
Свойства класса:
Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SCameras_motionDetected.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SCameras_updatePreview.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SCameras_takeSnapshot.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SCameras_takeSeries.php');
/* end injection of {SDevices} */Объекты класса:
Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SControllers_turnOn.php');
require(DIR_MODULES.'devices/SControllers_turnOff.php');
require(DIR_MODULES.'devices/SControllers_switch.php');
Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SDimmers_levelUpdated.php');
require(DIR_MODULES.'devices/SDimmers_turnOn.php');
require(DIR_MODULES.'devices/SDimmers_turnOff.php');
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SDimmers_levelWorkUpdated.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SGroups_turnOn.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SGroups_turnOff.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SGroups_switch.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SGroups_statusUpdated.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SRGB_colorUpdated.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SRGB_setColor.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SRGB_turnOn.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SRGB_turnOff.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_valueUpdated.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_statusUpdated.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_tempUp.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_tempDown.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_switchEnable.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_enable.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_disable.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_turnOn.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SThermostats_turnOff.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SCounters_valueUpdated.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SCounters_valueWorkUpdated.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SCounters_refreshStats.php');
/* end injection of {SDevices} */Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SLeak_statusUpdated.php');
/* end injection of {SDevices} */Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SMotions_motionDetected.php');
Объекты класса:
Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SOpenClose_statusUpdated.php');
Свойства класса:
Методы класса:
require(DIR_MODULES.'devices/SSensors_valueUpdated.php');
Свойства класса:
Свойства класса:
Свойства класса:
Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SPowerSensors_valueUpdated.php');
/* end injection of {SDevices} *//* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SPowerSensors_loadStatusChanged.php');
/* end injection of {SDevices} */Методы класса:
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/SSmoke_statusUpdated.php');
/* end injection of {SDevices} */Свойства класса:
Объекты класса:
Свойства класса:
Методы класса:
Объекты класса:
$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;
$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.".";
}
}
/*
$objects=array('MotionSensor1'=>'Датчик движения 1','MotionSensor2'=>'Датчик движения 2','TempSensor01'=>'Датчик температуры','HumSensor01'=>'Датчик влажности');
foreach($objects as $k=>$v) {
if (!gg($k.'.alive')) {
$yellow_state=1;
$details[]="Не обновляется ".$v.'.';
}
}
*/
if ((int)gg('ThisComputer.SpaceProblems')>0) {
$red_state=1;
$details[]="Недостаточно места на диске (".gg('ThisComputer.SpaceProblems_Details').').';
}
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),2);
} else {
say(LANG_GENERAL_SYSTEM_STATE." ".LANG_GENERAL_RESTORED_TO." ".$state_title,2);
}
$this->callMethod('stateChanged');
}
/* begin injection of {SDevices} */
require(DIR_MODULES.'devices/system_checkstate.php');
/* end injection of {SDevices} */$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');
}Свойства класса:
Методы класса:
//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 (timeBetween(getGlobal('NightModeEnd'),getGlobal('NightModeStart')) && 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(gg('NightModeStart'))) {
callMethod('NightMode.activate');
} elseif (timeIs(gg('NightModeEnd'))) {
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"); // выполним метод будильника
}
}
$paths=array('/var/log/*.1','/var/log/*.2',
'/var/log/*.1.*',
'/var/log/*.2.*',
'/var/log/*.3.*',
'/var/log/*.4.*',
'/var/log/*.5.*',
'/var/log/*.6.*',
'/var/log/*.7.*'
);
foreach($paths as $p) {
safe_exec('rm '.$p);
}
runScript('Hourly');
runScript('filesClearOld');Свойства класса:
Методы класса:
// МЕТОД 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("TodoList.sayTodo");
if ($sayTodo) {
say ("Задача: ".$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("TodoList.sayTodo");
if ($sayTodo) {
say ("З списку видалена задача: ".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("TodoList.sayTodo");
if ($sayTodo) {
say ("В список добавлена задача: ".$params["task"]."",($sayTodo-2));
}
$todo = $todo."|".$mytask; // добавляем с разделителем
$this->setProperty("todo", $todo);
// выполним подготовку для отображения
callMethod("TodoList.view");
}
Объекты класса:
// ******************************************************************
// * TO DO app - by Vovix - 09.12.2017 г. - v 3.20 *
// ******************************************************************
// создадим класс, объекты и свойства
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','sayTodo'); // настройка проговаривания (также зависит от общего уровня системы)
// например: при TodoList.sayTodo = 0 - проговаривания нет, далее уровень произношения устанавливается
// по принципу TodoList.sayTodo минус 2, т.е. при равном 1 будет -1, при 2 будет 0, при 3 будет 1 и т.д.
addClassProperty('ToDo','todo'); // сам лист to do
//
$this->setProperty('todo', '- to do list by Vovix -|-installed, ver 3.20');
$this->setProperty('sayTodo', '2'); // при ThisComputer.minMsgLevel = 0 будет говорить
$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;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
#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='
@import url("https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css");
#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;
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
}
#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("TodoList.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("TodoList.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("TodoList.sayTodo");
if ($sayTodo) {
say ("В лист todo добавлена задача: ".$params["task"]."",($sayTodo-2));
}
$todo = $todo."|".$mytask; // добавляем с разделителем
$this->setProperty("todo", $todo);
// выполним подготовку для отображения
callMethod("TodoList.view");
}
';
addClassMethod('ToDo', 'new', $new);
// выполним подготовку для отображения
callMethod("TodoList.view");
, Украина
На форуме: gridandy
© 2026 SJLab | Реквизиты: Курицын С. С. ИНН 762001394609 | Контакты | Публичный договор
SmartLiving