This repository has been archived by the owner on Nov 9, 2017. It is now read-only.
/
index.html
125 lines (113 loc) · 4.61 KB
/
index.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
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-us" lang="en-us">
<head>
<title>arbolito - cotización del dólar y euro en argentina</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="/css/style.css" type="text/css" media="screen, projection" />
<script src="http://www.google.com/jsapi" type="application/javascript"></script>
<script type="application/javascript">
google.load("visualization", "1", {packages:["linechart"]});
google.load('jquery', '1.3.2');
</script>
<script type="application/javascript">
var chart;
var colors = ["#0c8e40", "#c67010", "#0f5c7d", "#c63310"];
var usedColors = [];
var loading = false;
var selectedCells = [];
// Array Remove - By John Resig (MIT Licensed)
Array.prototype.remove = function(from, to) {
var rest = this.slice((to || from) + 1 || this.length);
this.length = from < 0 ? this.length + from : from;
return this.push.apply(this, rest);
};
var colorToHex = function(rgbString) {
var parts = rgbString.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
delete (parts[0]);
for (var i = 1; i <= 3; ++i) {
parts[i] = parseInt(parts[i]).toString(16);
if (parts[i].length == 1) parts[i] = '0' + parts[i];
}
return '#' + parts.join('');
};
var doQuery = function(items) {
var query = new google.visualization.Query('/vizdata?ti=' + items);
query.send(handleQueryResponse);
loading = true;
};
var handleQueryResponse = function(response) {
var data = response.getDataTable();
var formatter = new google.visualization.DateFormat({pattern: 'd-MM-yy'});
formatter.format(data, 0);
chart.draw(data, {width: 350, height: 240, legend: 'none', colors: usedColors});
loading = false;
};
$(document).ready(function() {
chart = new google.visualization.LineChart($('tbody#chart_container tr td')[0]);
$('table tbody td').click(function(e) { selectCell(e.target); });
var selectCell = function(cell) {
//if (loading) return;
if((td = $(cell)).hasClass('selected')) {
var ci = jQuery.inArray(colorToHex(td.css('color')), usedColors);
colors.push(usedColors[ci]);
usedColors.remove(ci);
selectedCells.remove(jQuery.inArray(td.attr('id'), selectedCells));
td.removeClass('selected');
td.css('color', '');
}
else {
td.addClass('selected');
td.css('color', usedColors[usedColors.push(colors.pop())-1]);
selectedCells.push(td.attr('id'));
}
if (selectedCells.length == 0) $('tbody#chart_container').hide();
else $('tbody#chart_container').show();
doQuery(selectedCells.join(','));
};
selectCell($('#USD-venta')[0]);
});
</script>
</head>
<body>
<div id="container">
<h1>arbolito</h1>
<table>
<caption>Cotizaciones según sitio web del <a href="http://www.bna.com.ar/bp/bp_cotizaciones.asp?op=m">Banco de la Nación Argentina</a> el <strong>{{FECHA|date:"d/m/Y"}}</strong>. Valores históricos: click sobre la tabla.</caption>
<thead>
<tr>
<th></th>
<th scope="col">Compra</th>
<th scope="col">Venta</th>
</tr>
</thead>
<tbody id="cotizaciones">
<tr>
<th scope="row">USD</th>
<td id="USD-compra">{{ USD.compra|floatformat:2 }}</td>
<td id="USD-venta">{{ USD.venta|floatformat:2 }}</td>
</tr>
<tr>
<th scope="row">EUR</th>
<td id="EUR-compra">{{ EUR.compra|floatformat:2 }}</td>
<td id="EUR-venta">{{ EUR.venta|floatformat:2 }}</td>
</tr>
</tbody>
<tbody id="chart_container">
<tr>
<td colspan="3"></td>
</tr>
</tbody>
</table>
<p id="about_arbolito"><span class="arbolito">arbolito</span> es una creación de <a href="http://jazzido.com">Manuel Aristarán</a>. <small><a href="http://github.com/jazzido/arbolito/tree/master">Acá está el código fuente</a>, si tanto te interesa.</small></p>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-68057-14");
pageTracker._trackPageview();
} catch(err) {}</script>
</body>
</html>