-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbiodegradable.php
211 lines (197 loc) · 9.7 KB
/
biodegradable.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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
<?php
include_once 'classes/Messenger.php';
include_once 'classes/Logger.php';
include_once 'classes/TrashClassifier.php';
$trashCl = new \pulut\TrashClassifier();
$messenger = new \pulut\Messenger();
$log = new \pulut\Logger();
?>
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Pulut-Pukyutan!</title>
<?php include_once 'helpers/gen-inc.php' ?>
</head>
<body>
<?php include_once 'components/header.php' ?>
<div class="fluid container">
<font style="color: white; font-size: 30px;">Biodegradable Unit</font>
<div class="ui stackable grid">
<div class="four wide column">
<br />
<div style="border-radius: 10px; width: 100%; background-color: rgba(255, 255, 255, 0.2); padding: 10px;">
<font style="color: white; font-size: 20px;">Add a Biodegradable Object</font>
<br /><br />
<div class="ui fluid input">
<input type="text" placeholder="Object Name" id="updInput">
</div>
<br />
<button type="button" class="ui green button" id="updBtn" disabled="disabled">Add</button>
<button type="button" class="ui red button" id="resetBtn">Reset</button>
</div>
<br />
<div style="border-radius: 10px; width: 100%; background-color: rgba(255, 255, 255, 0.2); padding: 10px;">
<font style="color: white; font-size: 20px;">Biodegradable Unit Information</font>
<br /><br />
<div class="ui equal width grid">
<div class="column">
<font style="color: white; font-size: 20px" id="contentCount">X</font><br />
<font style="color: white; font-size: 14px">Contents</font><br />
<br />
<font style="color: white; font-size: 20px" id="classifiedObjs">X</font><br />
<font style="color: white; font-size: 14px">Classified Objs</font><br />
</div>
<div class="column">
<font style="color: white; font-size: 20px" id="maximumObj">X</font><br />
<font style="color: white; font-size: 14px">Maximum</font><br />
</div>
</div>
</div>
</div>
<div class="twelve wide column">
<br />
<div style="padding: 10px; height: 100%; width: 100%; border-radius: 10px 10px 0 0; background-image: linear-gradient(to bottom, rgba(255, 255, 255, 0.3), rgba(0, 0, 0, 0.1))">
<div class="ui fluid icon input">
<input type="text" placeholder="Search..." id="searchField">
<i class="search icon"></i>
</div>
<br /><br />
<div style="overflow-y: scroll; max-height: 90%; height: 90%; background-color: rgba(0,0,0,0)" id="queryResults">
</div>
</div>
</div>
</div>
</div>
<?php include_once "components/endScript.php" ?>
<script>
function deleteObject(item, objectID) {
var XMLHttp = new XMLHttpRequest();
XMLHttp.onreadystatechange = function () {
if (this.status == 200 && this.readyState == 4) {
if (this.responseText=="GOOD") {
setMaximum();
setCounter();
setClassifiedObjs();
objectID
.transition('scale')
.queue(200)
.hide();
} else {
alert('Cannot delete instance of "'+item+'" object! Try again.');
}
}
};
XMLHttp.open('POST','async/deleteObject.php', true);
XMLHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
XMLHttp.send("wasteItem="+item+"&referrer=biodegradable");
}
function declassifyObject(item, objectID) {
var XMLHttp = new XMLHttpRequest();
XMLHttp.onreadystatechange = function () {
if (this.status == 200 && this.readyState == 4) {
if (this.responseText=="GOOD") {
setMaximum();
setCounter();
setClassifiedObjs();
objectID
.transition('fade')
.queue(200)
.hide();
} else {
alert('Cannot delete instance of "'+item+'" object! Try again.');
}
}
};
XMLHttp.open('POST','async/declassifyObject.php', true);
XMLHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
XMLHttp.send("wasteItem="+item+"&referrer=biodegradable");
}
$('#searchField').keyup(function() {
var XMLHttp = new XMLHttpRequest;
XMLHttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
$('#queryResults').html(this.response);
}
};
XMLHttp.open('POST','async/bdgblpg_helper.php', true);
XMLHttp.setRequestHeader("Content-type","application/x-www-form-urlencoded");
XMLHttp.send('query='+$('#searchField').val()+'&referrer=biodegradable');
});
function updateQuery() {
var XMLHttp = new XMLHttpRequest;
XMLHttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
$('#queryResults').html(this.response);
}
};
XMLHttp.open('POST', 'async/bdgblpg_helper.php', true);
XMLHttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
XMLHttp.send('query=' + $('#searchField').val() + '&referrer=biodegradable');
}
$('#updBtn').click(function() {
var XMLHttp = new XMLHttpRequest();
XMLHttp.onreadystatechange = function() {
if (this.readyState == 4 && this.status == 200) {
if (this.responseText=='2') {
alert('Object "'+$('#updInput').val()+'" has been successfully added as a biodegradable object.');
updateQuery();
} else {
alert('Object "'+$('#updInput').val()+'" failed to be added as biodegradable object.');
}
$('#updInput').val("");
setClassifiedObjs();
setMaximum();
setCounter();
updateQuery();
}
};
XMLHttp.open('POST','async/addWasteObj.php');
XMLHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
XMLHttp.send('objectName='+$('#updInput').val()+"&objectType=biodegradable");
});
$('#resetBtn').click(function() {
$('#updInput').val('');
$('#updInput').focus();
$('#updBtn').prop('disabled',true);
});
function setCounter() {
var XMLHttp = new XMLHttpRequest();
XMLHttp.onreadystatechange = function() {
$('#contentCount').text(this.responseText);
};
XMLHttp.open('GET','async/bioContentCounter.php');
XMLHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
XMLHttp.send();
}
function setMaximum() {
var XMLHttp = new XMLHttpRequest();
XMLHttp.onreadystatechange = function() {
$('#maximumObj').text(this.responseText);
};
XMLHttp.open('GET','async/bioMaxCounter.php');
XMLHttp.setRequestHeader('Content-type','application/x-www-form-urlencoded');
XMLHttp.send();
}
function setClassifiedObjs() {
var XMLHttp = new XMLHttpRequest();
XMLHttp.onreadystatechange = function () {
$('#classifiedObjs').text(this.responseText);
};
XMLHttp.open('GET', 'async/bioObjectsClassified.php');
XMLHttp.setRequestHeader('Content-type', 'application/x-www-form-urlencoded');
XMLHttp.send();
}
$('#updInput').keyup(function() {
if ($('#updInput').val() == "") {
$('#updBtn').prop('disabled',true);
} else {
$('#updBtn').prop('disabled',false);
}
});
setClassifiedObjs();
setMaximum();
setCounter();
updateQuery();
</script>
</body>
</html>