Permalink
Browse files

VENGA DESIÑO

  • Loading branch information...
1 parent 0cff6dd commit 7e915e73c8367f7687befc6fc42655500783f8a7 Andreas Blixt committed Jun 15, 2012
Showing with 46 additions and 13 deletions.
  1. +32 −1 index.html
  2. +14 −12 venga.js
View
@@ -3,10 +3,41 @@
<head>
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script src="venga.js"></script>
+ <style>
+ body {
+ background: #333;
+ padding: 30px 0 20px;
+ text-align: center;
+ }
+
+ h1 {
+ color: #fff;
+ }
+
+ button {
+ background: #fff;
+ border: #ddd solid 1px;
+ border-radius: 3px;
+ color: #35f;
+ font-size: 16px;
+ }
+
+ input {
+ background: #fff;
+ display: block;
+ border: #ddd solid 1px;
+ border-radius: 3px;
+ font-size: 16px;
+ margin: 0 auto 5px;
+ padding: 4px 2px;
+ width: 400px;
+ }
+ </style>
</head>
<body>
+ <h1>VENGA POEMAS</h1>
<p>
- <input id="venga-frase" size="100" value="we found love wild international">
+ <input id="venga-frase" value="we found love wild international">
<button id="venga-button">Venga Musica!</button>
</p>
</body>
View
@@ -21,23 +21,25 @@ function vengaBuscarUno(vengaTitulo, cb, page) {
}
function vengaBuscar(vengaFrase, cb) {
- var vengaTracks = []
+ var vengaTracks = [];
var vengaPalabras = vengaFrase.split(' ');
// TODO: join palabras
var vengaTitulos = vengaPalabras;
+ var pending = 0;
for (var i = 0; i < vengaTitulos.length; i++) {
- vengaBuscarUno(vengaTitulos[i], function(track) {
- if (track) {
- // TODO: Instead of calling callback here, add track to a list and look up remaining words
- // (if all words have been looked up, THEN call the callback!)
- vengaTracks.push(track);
- if (vengaTracks.length == vengaTitulos.length) {
- cb(vengaTracks);
+ pending++;
+ vengaBuscarUno(vengaTitulos[i], function(i) {
+ return function(track) {
+ if (track) {
+ vengaTracks[i] = track;
+ if (!--pending) {
+ cb(vengaTracks);
+ }
+ } else {
+ console.log('FAIL');
}
- } else {
- console.log('FAIL');
- }
- });
+ };
+ }(i));
}
}

0 comments on commit 7e915e7

Please sign in to comment.