-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprogress.php
150 lines (121 loc) · 3.96 KB
/
progress.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
<?php
session_start();
/**
* VERIFICATION
*/
/**
* END VERIFICATION
*/
require_once('init.php');
if(isset($_GET['error'])) {
switch($_GET['error']) {
case 'invalid_seq' :
$error_msg = "Enter a valid sequence, NCBI Gene Id or NCBI Accession No.";
break;
case 'invalid_request' :
$error_msg = "Invalid Request";
break;
} ?>
<div class="error-box"><?php echo $error_msg; ?></div>
<?php
}
if(empty($_GET['id'])) {
die("Invalid Request");
}
$id = $_GET['id'];
$output = $db -> get_row("SELECT * FROM searches WHERE id = $id");
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Progress</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="main.css">
<script src="main.js"></script>
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
</head>
<body>
<!-- Top Header -->
<?php require_once('inc/header.php'); ?>
<div id="main">
<?php
$status = strtolower($output -> status);
switch($status) {
case 'finished' :
?>
<script>
window.location.replace("./results?id=<?php echo $id; ?>");
</script>
<?php
break;
case 'created' :
case 'downloading' :
case 'searching' :
?>
<div id="progress-box">
<table>
<tr>
<td><label><strong>Search ID:</strong></label></td>
<td><span><?php echo $id; ?></span></td>
</tr>
<tr>
<td><label><strong>Status:</strong></label></td>
<td><?php echo $output -> status; ?></span></td>
</tr>
<tr>
<td><label><strong>Time taken:</strong></label></td>
<td><span id="minutes"><?php echo (int)((time() - strtotime($output -> creation_time)) / 60);?></span>:<span id="seconds"><?php echo (time() - strtotime($output -> creation_time)) % 60; ?></span></td>
</tr>
</table>
</div>
<div class="note"><strong>Note:</strong> The page automatically refreshes every 5 seconds.</div>
<script>
var minutesLabel = document.getElementById("minutes");
var secondsLabel = document.getElementById("seconds");
var totalSeconds = <?php echo time() - strtotime($output -> creation_time); ?>;
setInterval(setTime, 1000);
function setTime() {
++totalSeconds;
secondsLabel.innerHTML = pad(totalSeconds % 60);
minutesLabel.innerHTML = pad(parseInt(totalSeconds / 60));
}
function pad(val) {
var valString = val + "";
if (valString.length < 2) {
return "0" + valString;
} else {
return valString;
}
}
var startSeconds = 0;
function reloadPage() {
++startSeconds;
if(startSeconds >= 5) {
location.reload();
}
}
setInterval(reloadPage, 1000);
</script>
<?php
break;
case 'error' :
?>
<script>
window.location.replace("./results?id=<?php echo $id; ?>");
</script>
<?php
break;
default :
?>
<script>
window.location.replace("./results?id=<?php echo $id; ?>");
</script>
<?php
}
?>
</div>
<footer>
</footer>
</body>
</html>