-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest-list.php
451 lines (393 loc) · 18.9 KB
/
test-list.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
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
<?php
/* A quick mockup used during the paired research session on Sep. 27, 2012 */
session_start();
if(!isset($_SESSION["username"])){
header("location:index.php");
}
if (isset($_GET["tid"]))
$task_id = $_GET["tid"];
else
$task_id = 0;
//if (isset($_GET["iid"]))
// $interface_id = $_GET["iid"];
//else
$interface_id = 1;
include "conn.php";
if ($task_id == 0)
$result1 = $mysqli->query("SELECT * FROM videos");
else {
$result1 = $mysqli->query("SELECT * FROM videos WHERE task_id='$task_id'");
$result2 = $mysqli->query("SELECT * FROM tasks WHERE id='$task_id'");
$task = $result2->fetch_assoc();
}
$videos_array = array();
$labels_array = array();
$meta_array = array();
while ($video = $result1->fetch_assoc()) {
$video_filename = $video['filename'];
$string = file_get_contents("video/$video_filename.info.json");
$json = json_decode($string, true);
$result3 = $mysqli->query("SELECT * FROM labels WHERE video_id = '" . $video['id'] . "'");
$label_array = array();
// $html = "";
while ($label = $result3->fetch_assoc()) {
$label_array[] = $label;
}
$labels_array[] = $label_array;
$videos_array[] = $video;
$meta_array[] = $json;
}
if ($task_id == 0)
$result4 = $mysqli->query("SELECT count(distinct videos.id) AS freq, tool FROM labels, videos WHERE labels.video_id=videos.id AND tool<>'' GROUP BY tool ORDER BY freq DESC LIMIT 7");
else
$result4 = $mysqli->query("SELECT count(distinct videos.id) AS freq, tool FROM labels, videos WHERE labels.video_id=videos.id AND tool<>'' AND videos.task_id='$task_id' GROUP BY tool ORDER BY freq DESC LIMIT 7");
// $result4 = $mysqli->query("SELECT count(*) AS freq, tool FROM labels, videos WHERE labels.video_id=videos.id AND tool<>'' AND videos.task_id='$task_id' GROUP BY tool ORDER BY freq DESC LIMIT 7");
$tools_array = array();
while ($tool = $result4->fetch_assoc()) {
$tools_array[] = $tool;
}
include('header.php');
?>
<?php if ($interface_id == 1) { ?>
<div class="row">
<h1 class="span9" id="title"></h1>
<div class="span3">
<form id="myForm" action="vs-process.php" method="POST">
Done with the task?
<button id="nextButton" class="btn btn-large btn-primary" type="submit">
NEXT
</button>
</form>
</div>
<div class="span4">
<div id="stats"></div>
<div>
<h4 id="applied-filters-header">Showing all videos</h4>
<div id="applied-filters">
</div>
</div>
</div>
<div id="filters" class="span6 filters"><h3>Top tools</h3></div>
<div id="views" class="span2">
<h3>Views</h3>
<input type="radio" name="view-option" value="all"> All<br>
<input type="radio" name="view-option" value="simple" checked> Simple
</div>
</div>
<?php } elseif ($interface_id == 2) { ?>
<div class="row">
<h1 class="span9" id="title"></h1>
<div class="span3">
<form id="myForm" action="vs-process.php" method="POST">
Done with the task?
<button id="nextButton" class="btn btn-large btn-primary" type="submit">
NEXT
</button>
</form>
</div>
<div id="stats" class="span4"></div>
</div>
<?php } elseif ($interface_id == 3) { ?>
<div class="row">
<h1 class="span12" id="title"></h1>
<div id="stats" class="span4"></div>
</div>
<?php } ?>
<ol id="results" class="list-striped list-hover"></ol>
</div><!--container-->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/libs/jquery-1.7.2.min.js"><\/script>')</script>
<script src="js/libs/bootstrap/bootstrap.min.js"></script>
<script type="text/javascript" src="js/libs/jquery-ui-1.8.22.custom.min.js"></script>
<script type="text/javascript" src="js/libs/jcarousel/jquery.jcarousel.min.js"></script>
<script type="text/javascript" src="js/libs/lightbox/jquery.lightbox-0.5.js"></script>
<script src="js/libs/jcview/jquery.vt.jcview.js"></script>
<script src="js/libs/log4javascript.js"></script>
<script type="text/javascript">
$(document).ready(function() {
// Nav bar activation
var task_id = <?php echo $task_id; ?>;
var interface_id = <?php echo $interface_id; ?>;
var is_admin = <?php echo $_SESSION["is_admin"]; ?>;
//console.log(is_admin, !is_admin, (is_admin == true), (is_admin == false));
var log = log4javascript.getLogger();
var ajaxAppender = new log4javascript.AjaxAppender("ajax-add-log.php");
log.addAppender(ajaxAppender);
log.info(formatListLog(interface_id, task_id, "<?php echo $_SESSION['username']; ?>", "open", "page"));
var num_videos = <?php echo $result1->num_rows; ?>;
var labels_array = <?php echo json_encode($labels_array); ?>;
var videos_array = <?php echo json_encode($videos_array); ?>;
var tools_array = <?php echo json_encode($tools_array); ?>;
var meta_array = <?php echo json_encode($meta_array); ?>;
//var user_id = <?php echo $user_id; ?>;
var num_labels = 0;
var num_images = 0;
var num_tools = 0;
var filters = [];
var input = $("<input>").attr("type", "hidden").attr("name", "part").val("<?php echo $_GET['part'];?>");
$('#myForm').append($(input));
var input = $("<input>").attr("type", "hidden").attr("name", "cond").val("<?php echo $_GET['cond'];?>");
$('#myForm').append($(input));
var input = $("<input>").attr("type", "hidden").attr("name", "step").val("<?php echo $_GET['step'];?>");
$('#myForm').append($(input));
var input = $("<input>").attr("type", "hidden").attr("name", "from").val("<?php echo $_SERVER['PHP_SELF'];?>");
$('#myForm').append($(input));
var input = $("<input>").attr("type", "hidden").attr("name", "tid").val(task_id);
$('#myForm').append($(input));
var input = $("<input>").attr("type", "hidden").attr("name", "iid").val(interface_id);
$('#myForm').append($(input));
// Setting the page title
if (task_id == 0){
$("#title").html("Showing all videos");
} else {
$("#title").html("<?php echo $task['name'];?>");
}
$('input[type=radio]').live('change', function() {
log.info(formatListLog(interface_id, task_id, "<?php echo $_SESSION['username']; ?>", "click", "views", ""));
$(".all-view").toggle();
$(".simple-view").toggle();
});
// Add video entries for each interface
$.each(videos_array, function(index, value){
var params = "?vid=" + this.id + "&iid=" + interface_id;
if (interface_id == 1) {
num_labels = num_labels + labels_array[index].length;
var local_num_images = 0;
var local_num_tools = 0;
var before_img = "";
var after_img = "";
$.each(labels_array[index], function(i, v){
if (v.type == "image"){
local_num_images = local_num_images + 1;
if (v.comment == "#initial")
before_img = v.thumbnail;
if (v.comment == "#final")
after_img = v.thumbnail;
}
});
local_num_tools = labels_array[index].length - local_num_images;
num_images = num_images + local_num_images;
num_tools = num_tools + local_num_tools;
var html2 = "";
if (is_admin)
html2 = " | <a href='label.php" + params + "'>(Label)</a>";
//html2 = "<p class='video-info-meta pull-right'><a href='label.php" + params + "'>(Label)</a></p>";
$title = $("<h3/>").addClass("span12").append("<a href='test-browse.php" + params + "'>click to view</a>");
$desc = $("<div/>").addClass("span12").append("");
//$title = $("<h3/>").addClass("span12").append("<a href='test-browse.php" + params + "'>" + this.title + "</a>");
//$desc = $("<div/>").addClass("span12").append(meta_array[index].description);
//if (is_admin)
// $detail = $("<div/>").addClass("span3").append("<p class='pull-right video-info-meta'>" + labels_array[index].length + " labels (" + local_num_images + "+" + local_num_tools + ")</p>" + html2);
//else
// $detail = $("<div/>").addClass("span3").append("<p class='pull-right video-info-meta'>" + local_num_tools + " steps</p>" + html2);
//$info = $("<div/>").addClass("video-info row").append($title).append($detail).append($desc);
if (is_admin)
$detail = $("<div/>").addClass("span12 video-meta").append("<p>" + html2 + "</p>");
else
$detail = $("<div/>").addClass("span12 video-meta").append("<p></p>");
/*
if (is_admin)
$detail = $("<div/>").addClass("span12 video-meta").append("<p>" + labels_array[index].length + " labels (" + local_num_images + "+" + local_num_tools + ") | " + getTimeDisplay(this.duration) + " | by " + meta_array[index].uploader + " | " + formatDate(meta_array[index].upload_date) + html2 + "</p>");
else
$detail = $("<div/>").addClass("span12 video-meta").append("<p>" + local_num_tools + " steps | " + getTimeDisplay(this.duration) + " | by " + meta_array[index].uploader + " | " + formatDate(meta_array[index].upload_date) + html2 + "</p>");
*/ //$info = $("<div/>").addClass("video-info row span9").append($title).append($desc).append($detail);
$info = $("<div/>").addClass("video-info row").append($title).append($desc).append($detail);
var simpleHTML = "<div class='simple-view span12'><ul class='thumbnails'>" +
"<li class='span3'>" +
"<a href='" + before_img + "' class='thumbnail lightbox-simple'><img src='" + before_img + "'></a></li>" +
"<li class='span3'>" +
"<a href='" + after_img + "' class='thumbnail lightbox-simple'><img src='" + after_img + "'></a></li>" +
"</ul></div>";
$view = $("<div/>").addClass("row view-change").append("<div class='all-view video-view span12'></div>").append(simpleHTML);
$item = $("<div/>").addClass("video-item").append($info).append($view);
$("<li/>").data("video_id", this.id).append($item).appendTo("#results");
/* Generated <li> node:
<li>
<div class="video-item">
<div class="video-info row">
<h3 class="span8"><a href='<?=$url;?>'><?=$video['title'];?></a></h3>
<span class="span4 pull-right"><?=$html2;?> <?=$video['duration'];?> / <?=$result3->num_rows;?> labels</span>
</div>
<div class="row">
<div class="video-view span12"></div>
</div>
</div>
</li>
*/
} else if (interface_id == 2) {
console.log(meta_array[index]);
var thumbnail = meta_array[index].thumbnail;
$thumb = $("<div/>").addClass("span2").append("<a href='" + thumbnail + "'><img src='" + thumbnail + "'></a></div>");
$title = $("<h3/>").append("<a href='test-browse.php" + params + "'>" + this.title + "</a>");
$desc = $("<div/>").append(meta_array[index].description);
$detail = $("<div/>").addClass("video-meta").append("<p>" + getTimeDisplay(this.duration) + " | by " + meta_array[index].uploader + " | " + formatDate(meta_array[index].upload_date) + "</p>");
$info = $("<div/>").addClass("video-info-youtube span9").append($title).append($desc).append($detail);
$item = $("<div/>").addClass("video-item row").append($thumb).append($info);
$("<li/>").append($item).appendTo("#results");
/* <li>
<div class="video-item row">
<div class="span2">
<a href="http://i1.ytimg.com/vi/t8sTxPBtt8A/default.jpg"><img src="http://i1.ytimg.com/vi/t8sTxPBtt8A/default.jpg"></a>
</div>
<div class="video-info-youtube span9">
<h3><a href="browse.phpundefined">Create Movement - Motion Blur Photoshop Tutorial</a></h3>
<div>Image Link http://www.gamefront.com/files/20041298/skateboarder2.jpg Ignore Tags TeqTutorials,photoshop motion blur psd,after,affects,sony,vegas,pro,modern,w...</div>
<div><p class="pull-right">2:47</p></div>
</div>
</div>
</li>
*/
} else if (interface_id == 3) {
$title = $("<h3/>").append("<a href='test-browse.php" + params + "'>" + this.title + "</a>");
$desc = $("<div/>").append(meta_array[index].description);
$info = $("<div/>").addClass("video-info-google span8").append($title).append($desc);
$item = $("<div/>").addClass("video-item row").append($info);
$("<li/>").append($item).appendTo("#results");
}
});
// Display statistics
if (interface_id == 1){
if (is_admin)
$("#stats").html("Total: " + num_videos + " videos | " + num_labels + " labels (" + num_images + " images +" + num_tools + " steps)");
else
$("#stats").html("Total: " + num_videos + " videos | average " + Math.round(num_tools/num_videos) + " steps");
} else if (interface_id == 2)
$("#stats").html("Total: " + num_videos + " videos");
else if (interface_id == 3)
$("#stats").html("Total: " + num_videos + " results");
/* From here, VT Browser ONLY */
// Display top tools (most frequently used tool)
$("#filters").append($("<ul/>"));
$.each(tools_array, function(index, value){
var bar_width = parseInt(this.freq) * 10;
$("#filters ul").append("<li class='row'>"
+ "<div class='progress span2' style='margin-top:5px; margin-bottom: 5px; height:12px;'><div class='bar' style='float: right; width:" + bar_width + "px;'></div></div>"
+ "<span class='span4'><a href='#' class='tool-filter' data-tool-id='" + this.tool + "'>"
+ formatTool(this.tool, "toolname-emphasize") + "</a> (" + this.freq + ")</span>"
+ "</li>");
});
// Dynamically update the results based on the applied filters
function update_list(filters){
var hide_array = [];
var num_labels = 0;
// get video_id that must be hidden
$.each(videos_array, function(index, video){
var is_shown = true;
if (filters.length == 0){
num_labels = num_labels + labels_array[index].length;
return;
}
$.each(filters, function(i,filter){
var does_exist = false;
//console.log("filter", filter)
$.each(labels_array[index], function(ii, label){
//console.log("label", label);
if (label.type != "image" && label.tool == filter)
does_exist = true;
});
if (!does_exist)
is_shown = false;
});
/*
$.each(labels_array[index], function(i, v){
// skip image and only look at others
// also, do not count duplicates
// if any mismatch, this should be hidden (multiple filters are connected via AND not OR)
if (!is_shown && this.type != "image" && filters.indexOf(this.tool) == -1) {
is_shown = false;
}
});
*/
if (!is_shown) {
hide_array.push(video.id);
} else {
num_labels = num_labels + labels_array[index].length;
}
});
//console.log("hide_array", hide_array);
// for each li, hide the ones that are not in the list
$("#results li").each(function(index, value){
if (hide_array.indexOf($(this).data('video_id')) != -1)
$(this).hide();
else
$(this).show();
});
// update list alternating gradient, only on visible ones
$(".list-striped > li").css("background-color", "#ffffff");
$(".list-striped > li:visible").each(function (i){
if (i%2 == 0)
$(this).css("background-color", "#eeeeee");
});
if (interface_id == 1)
$("#stats").html("Total: " + parseInt(videos_array.length - hide_array.length) + " videos and " + num_labels + " labels");
}
// when clicking on a tool, add a filter
$(".tool-filter").click(function(event, ui){
var tool = $(this).data('tool-id');
filters.push(tool);
$("#applied-filters-header").html("Showing all videos with:");
$("#applied-filters").append("<div class='applied-filter' data-tool-id='" + tool+ "'>" + tool + "<i class='icon-remove'></i></div>");
//console.log("add filter", tool);
//console.log("filters", filters);
// for each video div, hide the ones that do not have this tool in it
update_list(filters);
log.info(formatListLog(interface_id, task_id, "<?php echo $_SESSION['username']; ?>", "click", "filter", tool));
});
// when click on an already-added filter, remove a filter
$("body").on("click", ".applied-filter", function(){
var tool = $(this).data('tool-id');
var index = filters.indexOf(tool);
if (index != -1)
filters.splice(index, 1);
if (filters.length == 0)
$("#applied-filters-header").html("Showing all videos");
$(this).toggle();
console.log("remove filter", tool);
console.log("filters", filters);
// for each video div, hide the ones that do not have this tool in it
update_list(filters);
log.info(formatListLog(interface_id, task_id, "<?php echo $_SESSION['username']; ?>", "click", "applied-filter", tool));
});
// for each result entry, display a slideshow summary
$(".video-view").each(function(index){
//console.log(videos_array[index].duration);
$(this).jcview({
labels: labels_array[index],
duration: videos_array[index].duration
});
});
$("a.lightbox").lightBox();
$("a.lightbox-simple").lightBox();
/*
function mycarousel_initCallback(carousel) {
$('.jcarousel-control a').click(function() {
carousel.scroll($.jcarousel.intval($('.jcarousel-control a').index($(this))));
return false;
});
}
*/
$(".mycarousel").jcarousel({
scroll: 2,
visible: 7//,
//initCallback: mycarousel_initCallback
});
var cond = "<?php echo $_GET["cond"]; ?>";
if (cond == "A")
$("#task-selector li").eq(5).addClass("active");
else
$("#task-selector li").eq(6).addClass("active");
$(".all-view").hide();
$(".simple-view").show();
});
</script>
<script src="js/script.js"></script>
<!--
<script>
var _gaq=[['_setAccount','UA-XXXXX-X'],['_trackPageview']];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
s.parentNode.insertBefore(g,s)}(document,'script'));
</script>
-->
</body>
</html>