-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathtreeList.php
75 lines (69 loc) · 2.11 KB
/
treeList.php
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
<!Doctype html>
<html>
<head>
<title>Parivar</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
<body>
<div data-role="page" id="treeList">
<?php
if (strlen(session_id()) < 1) {
session_start();
}
if(!isset($_SESSION['id']))
{
?>
<script>
window.location = "home.php";
</script>
<?php
}
?>
<?php
require_once("treeModel.php");
$tree = new Tree();
$treelist = $tree->getAllTrees($_SESSION['id']);
?>
<div data-role="header">
<h1>Parivar Tree Maker</h1>
</div><!-- /header -->
<div data-role="controlgroup" data-type="horizontal">
<a href="#createTree" id="createTreePop_btn" data-role="button" data-rel="popup" data-position-to="window" data-icon="plus">Add New Tree</a>
</div>
<ul data-role="listview" data-inset="true">
<?php
foreach($treelist as $myTree)
{
echo "<li><a href='tree.php?treeId=",$myTree['id'],"'>",$myTree['name'],"</a></li>";
}
?>
</ul>
<div data-role="popup" id="createTree" data-theme="a" class="ui-corner-all">
<form>
<div style="padding:10px 20px;">
<h3>Create a New Tree</h3>
<label for="treeName" class="ui-hidden-accessible">Name:</label>
<input type="text" name="treeName" id="treeName" value="" placeholder="Tree Name" data-theme="a" />
<input type="button" value="Create" id="createTree_btn" data-theme="b"/>
</div>
</form>
</div>
<script>
$( '#treeList' ).live('pageinit',function(){
$("#createTree_btn").click(function(){
$.ajax({
url: "actions.php",
data: {action: "createTree", name: $("#treeName").val(), id: <?php echo $_SESSION['id']; ?>},
dataType: 'json',
success: function(data){
window.location = "tree.php?treeId="+data;
}
});
});
});
</script>
</div>
</body>
</html>