-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathapplyCodes.php
More file actions
190 lines (155 loc) · 7.04 KB
/
applyCodes.php
File metadata and controls
190 lines (155 loc) · 7.04 KB
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
<html>
<head>
<title>Pipoca</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
<!-- necessary for the sectiuon selection on images -->
<link rel="stylesheet" type="text/css" href="css/imgareaselect-default.css" />
<script type="text/javascript" src="scripts/jquery.min.js"></script>
<script type="text/javascript" src="scripts/jquery.imgareaselect.pack.js"></script>
<link href="http://vjs.zencdn.net/5.8.8/video-js.css" rel="stylesheet">
<link rel="stylesheet" href="css/videoplayerskin/polyzor-skin.min.css">
<script src="http://vjs.zencdn.net/5.8.8/video.js"></script>
<!-- necessary for the slider -->
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
function ajax_post(){
//video
if (document.getElementById("type").innerHTML == "v") {
var p = videojs('my-video');
document.getElementById('x1').value = Math.round($("#slider-range").slider("values",0)*p.duration()/100);
document.getElementById('y1').value = Math.round($("#slider-range").slider("values",1)*p.duration()/100);
}
// Create our XMLHttpRequest object
var hr = new XMLHttpRequest();
hr.open("POST", "addCoding.php", true);
// Set content type header information for sending url encoded variables in the request
hr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
// Access the onreadystatechange event for the XMLHttpRequest object
hr.onreadystatechange = function() {
if(hr.readyState == 4 && hr.status == 200) {
var return_data = hr.responseText;
document.getElementById("result").innerHTML = return_data;
}
}
// Send the data to PHP now... and wait for response to update the status div
vars = "source_id=" + document.getElementById('source_id').value + "&codes_id=" + document.getElementById('codes_id').value + "&x1=" + document.getElementById('x1').value + "&x2=" + document.getElementById('x2').value + "&y1=" + document.getElementById('y1').value + "&y2=" + document.getElementById('y2').value + "&memo=" + document.getElementById('memo').value + "&owner=" + document.getElementById('owner').value + "&status=" + document.getElementById('status').value + "&type=" + document.getElementById('type').innerHTML;
hr.send(vars); // Actually execute the request
document.getElementById("result").innerHTML = "processing...";
}
//creating the slider
$( function() {
$( "#slider-range" ).slider({ range: true, min: 0, max: 100, values: [ 25, 75 ],
slide: function( event, ui ) { $( "#amount" ).val( "$" + ui.values[ 0 ] + " - $" + ui.values[ 1 ] ); }
}
);
}
);
</script>
</head>
<body>
<div id="#tudo">
<object data="css/logo.svg" type="image/svg+xml" height=200 width=900></object>
<div id="menu">
<?php include("menu.html"); ?>
</div>
<div id="centro">
<?php
include("connection.php");
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
//getting the source
$sql = "SELECT * FROM sources WHERE id='" . $_GET["idImage"] . "'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
//basic info
echo "<span class='fieldname'>ID: </span>" . $row["id"]. "<br/><span class='fieldname'>Description: </span>" . $row["memo"]. "<br/>";
echo "<span style='display:none;' id='type'>" . $row["type"] . "</span>";
//getting and showing the attributes
$result3 = mysqli_query($conn, "SELECT * FROM (SELECT sourceAttributes.value, attributes.name, sourceAttributes.source_id FROM sourceAttributes INNER JOIN attributes ON sourceAttributes.attributes_id=attributes.id)fusao WHERE source_id=" . $_GET["idImage"]);
echo "<span class='fieldname'>Attributes:</span>";
while($row3 = mysqli_fetch_assoc($result3)) {
echo $row3["name"] . "=" . $row3["value"] . ", ";
}
echo "\n<br/>\n";
//image
if ($row["type"]=="i") {
list($width, $height) = getimagesize("sources/" . $row["name"]);
echo "<img src='sources/" . $row['name'] . "' id='image' style='margin: 20px 0 20px 0; width:800px'>\n";
echo "<span style='display:none;' id='altura'>" . $height . "</span>";
echo "<span style='display:none;' id='largura'>" . $width . "</span>";
}
//video
if ($row["type"]=="v") {
echo "<video id='my-video' class='video-js vjs-polyzor-skin' controls style='width: 800px; height: 600px;' preload='metadata'><source src='sources/" . $row["name"] . "' type='video/mp4'></video>\n";
echo "<br><span class='fieldname'>Select in the sliders below the begin and the end of the section:</span><br>";
echo "<div id='slider-range' style='width:800px;'></div>\n<br/>\n";
echo "<script>videojs('my-video');</script>";
}
//creating the code selector
$sql = "SELECT name, id FROM codes";
$result = mysqli_query($conn, $sql);
echo "<div style='float: left;'>";
echo "<span class='fieldname'>Select the code:</span><select id='codes_id'>";
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
echo "<option value='" . $row["id"] . "'>" . $row["name"] . "</option>";
}
}
echo "</select>\n<br>\n";
mysqli_close($conn);
?>
<br/>
<center><input type=Submit value="Apply code" onclick="ajax_post();"></center>
</div>
<div style='float: left;'>
<textarea id="memo" cols=70 rows=3 placeholder="Comment about the coding here..."></textarea>
</div>
<!--hidden fields with basic info for the coding-->
<input type=hidden id="owner" value="leo">
<input type=hidden id="status" value=1>
<input type=hidden id="source_id" value=<?php echo "'" . $_GET["idImage"] . "'";?> >
<!--hidden fields to keep the boundaries-->
<input type=hidden id="x1" name="x1">
<input type=hidden id="y1" name="y1">
<input type=hidden id="x2" name="x2">
<input type=hidden id="y2" name="y2">
<script type="text/javascript">
//image
if (document.getElementById("type").innerHTML == "i") {
$(document).ready(function () {
$('img#image').imgAreaSelect({
handles: true,
onSelectEnd: function (img, selection) {
document.getElementById("x1").value = selection.x1;
document.getElementById("y1").value = selection.y1;
document.getElementById("x2").value = selection.x2;
document.getElementById("y2").value = selection.y2;
},
imageHeight: document.getElementById("altura").innerHTML,
imageWidth: document.getElementById("largura").innerHTML
});
});
}
//video
if (document.getElementById("type").innerHTML == "v") {
document.getElementById("x2").value = 0;
document.getElementById("y2").value = 0;
}
</script>
<div style='clear:both;'>
<br>
<span id="result"></span>
<br>
<?php
echo "\n<br>\n<span class='fieldname'>actions:</span><a href='viewImagewithBites.php?idImage=" . $_GET["idImage"] . "'>Back</a> | <a href='editAttributes.php?idImage=" . $_GET["idImage"] . "'>Edit attributes</a>\n<br/>\n";
?>
</div>
</div>
</div>
</body>
</html>