a:1:{i:0;a:5:{s:5:"TITLE";s:4:"ToDo";s:5:"NOLOG";s:1:"0";s:11:"DESCRIPTION";s:0:"";s:7:"METHODS";a:1:{i:0;a:7:{s:5:"TITLE";s:7:"install";s:11:"DESCRIPTION";s:116:"метод для первоначальной инсталяции, запустить один первый раз";s:4:"CODE";s:0:"";s:11:"CALL_PARENT";s:1:"0";s:9:"SCRIPT_ID";s:1:"0";s:8:"EXECUTED";s:19:"2015-11-28 05:45:34";s:15:"EXECUTED_PARAMS";s:117:"a:4:{s:6:"object";s:8:"TodoList";s:2:"op";s:1:"m";s:1:"m";s:7:"install";s:21:"ORIGINAL_OBJECT_TITLE";s:8:"TodoList";}";}}s:7:"OBJECTS";a:1:{i:0;a:4:{s:5:"TITLE";s:8:"TodoList";s:11:"DESCRIPTION";s:0:"";s:12:"KEEP_HISTORY";s:1:"0";s:7:"METHODS";a:1:{i:0;a:7:{s:5:"TITLE";s:7:"install";s:11:"DESCRIPTION";s:0:"";s:4:"CODE";s:11561:"// ******************************************************************
// *    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 == "+") ? "&quot;выполненно&quot;" : "&quot;не выполнено&quot;";
              $sayTodo = gg("Sets.sayTodo");
 			  	if ($sayTodo) { 
         	  		say ("Todo задача: &quot;".$task."&quot; - отмечена как ".$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 удалена задача: &quot;".mb_substr($td[$i], 1)."&quot;",($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 добавлена задача: &quot;".$params["task"]."&quot;",($sayTodo-2));
    }	
 
	$todo = $todo."|".$mytask; // добавляем с разделителем 

	$this->setProperty("todo", $todo);

}
';

addClassMethod('ToDo', 'new', $new);



callMethod("TodoList.view");

";s:11:"CALL_PARENT";s:1:"1";s:9:"SCRIPT_ID";s:1:"0";s:8:"EXECUTED";s:19:"2015-11-28 05:45:34";s:15:"EXECUTED_PARAMS";s:73:"a:3:{s:6:"object";s:8:"TodoList";s:2:"op";s:1:"m";s:1:"m";s:7:"install";}";}}}}}}