aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Tasklist.php
blob: 96b70af158aec948b9f91a5f98c13aa88426fd4c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

/**
 *   * Name: Task list
 *   * Description: Simple task list mangager
 */

namespace Zotlabs\Widget;

use App;

class Tasklist {

	function widget($arr) {

		if(! local_channel())
			return EMPTY_STR;

		if(App::$profile_uid !== local_channel())
			return EMPTY_STR;

		$o .= '<script>var tasksShowAll = 0; $(document).ready(function() { tasksFetch(); $("#tasklist-new-form").submit(function(event) { event.preventDefault(); $.post( "tasks/new", $("#tasklist-new-form").serialize(), function(data) { tasksFetch();  $("#tasklist-new-summary").val(""); } ); return false; } )});</script>';
		$o .= '<script>function taskComplete(id) { $.post("tasks/complete/"+id, function(data) { tasksFetch();}); }
			function tasksFetch() {
				$.get("tasks/fetch" + ((tasksShowAll) ? "/all" : ""), function(data) {
					$(".tasklist-tasks").html(data.html);
				});
			}
			</script>';

		$o .= '<div class="widget">' . '<h3>' . t('Tasks') . '</h3><div class="tasklist-tasks mb-1">';
		$o .= '</div><form id="tasklist-new-form" action="" ><input class="form-control" id="tasklist-new-summary" type="text" name="summary" value="" /></form>';
		$o .= '</div>';
		return $o;

	}
}