-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
130 lines (101 loc) · 3.39 KB
/
index.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
<?php
require_once("conexion.php");
// Some Query
$sql = 'SELECT * FROM words order by idwords;';
$query = mysqli_query($con, $sql);
$palabras = [];
$i=0;
if (!$query) {
printf("Error: %s\n", mysqli_error($con));
exit();
}
while ($row = mysqli_fetch_array($query))
{
$palabras[$i]['idwords'] = $row['idwords'];
$palabras[$i]['english'] = $row['english'];
$palabras[$i]['pronunciation'] = $row['pronunciation'];
$palabras[$i]['sentence'] = $row['sentence'];
$palabras[$i]['spanish'] = $row['spanish'];
$palabras[$i]['used'] = $row['used'];
$palabras[$i]['group_id'] = $row['group_id'];
$palabras[$i]['created'] = $row['created'];
$palabras[$i]['modified'] = $row['modified'];
$palabras[$i]['isrepeat'] = $row['isrepeat'];
$i++;
}
//echo json_encode($palabras);
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>WordbitWeb</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<style>
.resaltar{
background-color: yellow !important;
}
</style>
</head>
<body>
<div class='container'>
<h1 style='text-align: center'>WordbitWeb</h1>
<table class="table table-striped">
<thead>
<tr>
<th>#</th>
<th>English</th>
<th>Pronunciation</th>
<th>Sentence</th>
<th>Spanish</th>
</tr>
</thead>
<tbody>
<?php
foreach ($palabras as &$palabra) {
echo "<tr id='tr_".$palabra["idwords"]."' class='fila'>
<td>".$palabra["idwords"]."</td>
<td>".$palabra["english"]."</td>
<td>".$palabra["pronunciation"]."</td>
<td>".$palabra["sentence"]."</td>
<td>".$palabra["spanish"]."</td>
</tr>";
}
?>
</tbody>
</table>
</div>
<script>
var palabra = [];
var palabraAnterior = {"idwords": "-1"};
$(document).ready(function() {
var minutos = parseInt(prompt("Por favor seleccione el intervalo en minutos"));
mostrar(minutos*60000);
});
function mostrar(milisegundos){
mostrarPalabra();
setInterval(function(){
mostrarPalabra();
}, milisegundos);
}
function mostrarPalabra(){
$.get("data.php", function(data, status){
var palabra = JSON.parse(data);
console.log(palabraAnterior["idwords"]+", "+palabra["idwords"]);
if(palabraAnterior["idwords"] != palabra["idwords"] || palabra["isrepeat"]==1){
var texto = palabra['english']+" ("+palabra['pronunciation']+"): "+palabra['spanish'];
$("#tr_"+palabraAnterior['idwords']).removeClass( "resaltar" );
$("#tr_"+palabra['idwords']).addClass( "resaltar" );
palabraAnterior = palabra;
var myWindow = window.open("word.php?idwords="+palabra['idwords']+"&english="+palabra['english']+"&pronunciation="+palabra['pronunciation']+"&spanish="+palabra['spanish']+"&sentence="+palabra['sentence'], "", "width=1000, height=600"); // Opens a new window
myWindow.focus();
}
});
}
</script>
</body>
</html>
<?php
// Close connection
mysqli_close ($con);
?>