-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconsulta_csv.html
180 lines (159 loc) · 5.56 KB
/
consulta_csv.html
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
<!doctype html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=2.0, user-scalable=yes" />
<meta charset="UTF-8">
<title>Consulta archivo CSV</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script src="http://jquery-csv.googlecode.com/git/src/jquery.csv.js"></script>
<script>
$(document).ready(function() {
if(isAPIAvailable()) {
$('#files').bind('change', handleFileSelect);
}
});
function isAPIAvailable() {
// Check for the various File API support.
if (window.File && window.FileReader && window.FileList && window.Blob) {
// Great success! All the File APIs are supported.
return true;
} else {
// source: File API availability - http://caniuse.com/#feat=fileapi
// source: <output> availability - http://html5doctor.com/the-output-element/
document.writeln('The HTML5 APIs used in this form are only available in the following browsers:<br>');
// 6.0 File API & 13.0 <output>
document.writeln(' - Google Chrome: 13.0 or later<br>');
// 3.6 File API & 6.0 <output>
document.writeln(' - Mozilla Firefox: 6.0 or later<br>');
// 10.0 File API & 10.0 <output>
document.writeln(' - Internet Explorer: Not supported (partial support expected in 10.0)<br>');
// ? File API & 5.1 <output>
document.writeln(' - Safari: Not supported<br>');
// ? File API & 9.2 <output>
document.writeln(' - Opera: Not supported');
return false;
}
}
function handleFileSelect(evt) {
var files = evt.target.files; // FileList object
var file = files[0];
// read the file metadata
var output = ''
output += '<span style="font-weight:bold;">' + escape(file.name) + '</span><br>\n';
output += ' - FileType: ' + (file.type || 'n/a') + '<br>\n';
output += ' - FileSize: ' + file.size + ' bytes<br>\n';
output += ' - LastModified: ' + (file.lastModifiedDate ? file.lastModifiedDate.toLocaleDateString() : 'n/a') + '<br>\n';
// read the file contents
printTable(file);
// post the results
$('#list').html(output);
}
function printTable(file) {
var reader = new FileReader();
reader.readAsText(file);
reader.onload = function(event){
var csv = event.target.result;
var data = $.csv.toArrays(csv, {
delimiter:"'", // sets a custom value delimiter character
separator:';', // sets a custom field separator character
});
var html = '';
for(var row in data) {
html += '<tr>\r\n';
//alert(data[row]);
nac = data[row][0]; // Nacionalidad
ced = data[row][1]; // Cedula
nombre = data[row][2]; // Nombre
var nombre_array = nombre.split(',');
html += '<td>' + nac + ' - ' + ced + '<br>' + nombre_array[0] + ' ' + nombre_array[1] + '</td>\r\n';
fecha = data[row][3].split("-");
y = fecha[0];
m = fecha[1];
d = fecha[2];
html += '<td>' + y + '-' + m + '-' + d + '<br>' + nombre_array[2] + ' ' + nombre_array[3] + '</td>\r\n'; // Nombre
html += '</tr>\r\n';
html += '<tr><td>' + botonCNE(nac, ced) + '</td><td>' + botonesIVSS( nac, ced, parseInt(y), parseInt(m), parseInt(d) ) + '</td></tr>\r\n'; // Nombre
}
$('#contents').html(html);
};
reader.onerror = function(){ alert('Unable to read ' + file.fileName); };
}
</script>
<script>
function creaForm(btn, n, c, y, m, d){
in_y = "<input type='hidden' name='y' value='" + y + "'>";
in_m = "<input type='hidden' name='m' value='" + m + "'>";
in_d = "<input type='hidden' name='d' value='" + d + "'>";
if( btn == 'CI'){
/// Para asegurados
a='http://www.ivss.gob.ve:28083/CuentaIndividualIntranet/CtaIndividual_PortalCTRL';
nac_n='nacionalidad_aseg';
ced_n='cedula_aseg';
if(isDevice() == true){
s='CI';
}else{
s='Cuenta Individual';
}
}else
{
/// Para pensionados
a='http://www.ivss.gob.ve:28080/Pensionado/PensionadoCTRL';
nac_n='nacionalidad';
ced_n='cedula';
if(isDevice() == true){
s='Pens';
}else{
s='Pensionados';
}
}
b = '';
b += "<form action='"+ a +"' method='get' target='_blank'>";
b += "<input type='hidden' id='nac' value='" + n + "' name='" + nac_n + "'>";
b += "<input type='hidden' id='ced' value='" + c + "' name='" + ced_n + "'>";
b += in_y;
b += in_m;
b += in_d;
b += "<input type='submit' value='" + s + "'>";
b += "</form>";
return b;
}
function botonesIVSS(nac, ced, y, m, d){
btn = '';
btn += creaForm('CI', nac, ced, y, m, d);
btn += ' ';
btn += creaForm('P', nac, ced, y, m, d);
return btn;
}
function botonCNE(nac, ced){
btn = '';
btn += "<form action='http://www.cne.gov.ve/web/registro_electoral/ce.php' method='get' target='_blank'>";
btn += "<input type='hidden' id='nac' value='" + nac + "' name='nacionalidad'>";
btn += "<input type='hidden' id='ced' value='" + ced + "' name='cedula'>";
btn += "<input type='submit' value='REP CNE'>";
btn += "</form>";
return btn;
}
function isDevice(){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
return true;
}else{
return false;
}
}
</script>
</head>
<body>
<div id=inputs class=clearfix>
<input type=file id=files name=files[] multiple />
</div>
<hr />
<output id=list>
</output>
<hr />
<table id=contents style="width:100%;height:400px;" border>
</table>
<table width='100%' border>
<tr><td><a href='https://raw.githubusercontent.com/carloscelis/consulta_publica/master/consulta_csv.html' target='_blank'>Actualizar</a></td></tr>
</table>
</body>
<html>