Last active
January 2, 2016 15:09
-
-
Save mapreal19/8321417 to your computer and use it in GitHub Desktop.
Comunio Puntos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function calcPtos() | |
| { | |
| var _i, _fila; | |
| var _filas_tabla = $('#tablestandings tr'); | |
| var _pushed; | |
| var myMappings = []; | |
| //Somos 7 jugadores | |
| for (_i = 1; _i < _filas_tabla.length; _i += 1) { | |
| _pushed = false | |
| _fila = _filas_tabla[_i]; | |
| var _nombre_puntos = $(_fila).find('td').eq(2).text(); | |
| var res = _nombre_puntos.split(['+'])[1]; | |
| if (typeof res != 'undefined') { | |
| var _puntos = parseInt($(_fila).find('td').eq(3).text()); | |
| $(_fila).find('td').eq(3).text(_puntos+parseInt(res)); | |
| myMappings.push([_i,_puntos+parseInt(res)]); | |
| _pushed = true; | |
| } | |
| else { | |
| res = _nombre_puntos.split(['-'])[1]; | |
| if (typeof res != 'undefined') { | |
| var _puntos = parseInt($(_fila).find('td').eq(3).text()); | |
| $(_fila).find('td').eq(3).text(_puntos-parseInt(res)); | |
| myMappings.push([_i,_puntos-parseInt(res)]); | |
| _pushed = true; | |
| } | |
| } | |
| if (!_pushed) { | |
| myMappings.push([_i,parseInt($(_fila).find('td').eq(3).text())]); | |
| } | |
| } | |
| myMappings.sort(function(a,b) { return b[1] - a[1] } ); | |
| //console.table(myMappings); | |
| for (_i = 0; _i < myMappings.length; _i += 1) { | |
| _fila = _filas_tabla[myMappings[_i][0]]; | |
| $(_fila).remove(); | |
| $('#tablestandings tr:last').after(_fila.outerHTML); | |
| } | |
| alert('PeloMoco'); | |
| } | |
| calcPtos(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment