-
Notifications
You must be signed in to change notification settings - Fork 7
/
tree.php
174 lines (154 loc) · 5.26 KB
/
tree.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<!Doctype html>
<html>
<head>
<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>
<title>Tree Experiment</title>
</head>
<body>
<div data-role="page" id="treePage">
<style>
g.node {
font-family: Verdana, Helvetica;
font-size: 11px;
font-weight: normal;
}
circle.node-dot {
cursor: pointer;
fill: #fff;
stroke: steelblue;
stroke-width: 2px;
}
path.link {
fill: none;
stroke: gray;
}
</style>
<div data-role="header">
<h1>Parivar Tree Maker</h1>
<a href="home.php" data-icon="home" class="ui-btn-left" data-theme="b">Home</a>
<?php
if (strlen(session_id()) < 1) {
session_start();
}
if(isset($_SESSION['id'])){
?>
<a href="logout.php" data-icon="delete" class="ui-btn-right" data-theme="b">Logout</a>
<?php
}
?>
</div><!-- /header -->
<div id="tree-container" style="min-width: 1300px; min-height: 800px; overflow-x: scroll;"></div>
<a id="lnkDialog" href="#actions" data-rel="popup" data-position-to="window" style="display: none;">Open dialog</a>
<span id="currentNodeId" style="display: none"></span>
<div data-role="footer">
<h4>2013 Crayon Bytes</h4>
</div>
<div data-role="popup" id="actions" data-theme="a" class="ui-content ui-corner-all" >
<div style="padding:10px 20px;">
<ul data-role="listview">
<li><a href="#addChild" data-rel="popup" data-position-to="window">Add a Child</a></li>
<li><a href="#addSpouse" data-rel="popup" data-position-to="window">Add Spouse</a></li>
<li><a href="#addParent" data-rel="popup" data-position-to="window">Add Parent</a></li>
</ul>
</div>
</div>
<div data-role="popup" id="addChild" data-theme="a" class="ui-corner-all">
<form>
<div style="padding:10px 20px;">
<h3>Add a child</h3>
<label for="childName" class="ui-hidden-accessible">Name:</label>
<input type="text" name="childName" id="childName" value="" placeholder="Name" data-theme="a" />
<input type="button" value="Add" id="addChild_btn" data-theme="b"/>
</div>
</form>
</div>
<div data-role="popup" id="addSpouse" data-theme="a" class="ui-corner-all">
<form>
<div style="padding:10px 20px;">
<h3>Add Spouse</h3>
<label for="spouseName" class="ui-hidden-accessible">Name:</label>
<input type="text" name="spouseName" id="spouseName" value="" placeholder="Name" data-theme="a" />
<input type="button" value="Add" id="addSpouse_btn" data-theme="b"/>
</div>
</form>
</div>
<div data-role="popup" id="addParent" data-theme="a" class="ui-corner-all">
<form>
<div style="padding:10px 20px;">
<h3>Add Parent</h3>
<label for="parentName" class="ui-hidden-accessible">Name:</label>
<input type="text" name="parentName" id="parentName" value="" placeholder="Name" data-theme="a" />
<input type="button" value="Add" id="addParent_btn" data-theme="b"/>
</div>
</form>
</div>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="tree.js"></script>
<?php
if(!isset($_SESSION['id']))
{
?>
<script>
//window.location = "home.php";
</script>
<?php
}
?>
<script>
$( '#treePage' ).live('pageinit',function(){
var treeId = <?php echo $_GET['treeId']; ?>;
$.ajax({
url: "getTreeJson.php",
data: {treeId: treeId},
type: "POST",
dataType: 'json',
success: function(data){
var treeOwner = false;
if(data.owner_id == <?php if(isset($_SESSION['id']))echo $_SESSION['id'];else echo 0; ?>)
treeOwner = true;
buildTree("#tree-container", data, treeOwner);
}
});
$("#addChild_btn").click(function(){
if($("#childName").val() == "")
return;
$.ajax({
url: "actions.php",
data: {action: "addChild", name: $("#childName").val(), id: $("#currentNodeId").html()},
dataType: 'json',
success: function(data){
window.location = "tree.php?treeId="+treeId;
}
});
});
$("#addSpouse_btn").click(function(){
if($("#spouseName").val() == "")
return;
$.ajax({
url: "actions.php",
data: {action: "addSpouse", name: $("#spouseName").val(), id: $("#currentNodeId").html()},
dataType: 'json',
success: function(data){
window.location = "tree.php?treeId="+treeId;
}
});
});
$("#addParent_btn").click(function(){
if($("#parentName").val() == "")
return;
$.ajax({
url: "actions.php",
data: {action: "addParent", name: $("#parentName").val(), id: $("#currentNodeId").html()},
dataType: 'json',
success: function(data){
window.location = "tree.php?treeId="+data;
}
});
});
});
</script>
</div>
</body>
</html>