Ver Mensaje Individual
  #5 (permalink)  
Antiguo 04/03/2015, 07:53
grossbergsteven
 
Fecha de Ingreso: diciembre-2014
Mensajes: 69
Antigüedad: 9 años, 4 meses
Puntos: 2
Respuesta: Limite de codigo en javascript?

Buenos dias gracias por tu respuesta, realmente identarlo no cambia nada más alla de tener una estructura un poco mas legible, vo y a colocar el cogigo identado con el comentario en las llaves que no cierran, ademas creo importante destacar que si todo el bloque de codigo lo comento, sigue pasando lo mismo, es como si hubiese una limitante de caracteres dentro de la funcion on_conect

Código Javascript:
Ver original
  1. var user = "logro";
  2. var userid = "178";
  3. var db = openDatabase("incasports", "1.0", "", 1024);
  4. var ws = new SockJS('http://incasports.com:15674/stomp');
  5. var client = Stomp.over(ws);
  6. var on_connect = function(conexion) {
  7.     var id = client.subscribe(user, function(d) {
  8.         var p = JSON.parse(d.body);
  9.         var tipo = (p["tipo"]);
  10.         if (tipo == "juegonuevo") {
  11.             var id = (p["datos"]["equipo1"]["id"]);
  12.             var id2 = (p["datos"]["equipo2"]["id"]);
  13.             var id_juego = (p["datos"]["id"]);
  14.             var fecha = (p["datos"]["fecha"]);
  15.             var ref = (p["datos"]["equipo1"]["ref"]);
  16.             var ref2 = (p["datos"]["equipo2"]["ref"]);
  17.             var nombre = (p["datos"]["equipo1"]["nombre"]);
  18.             var nombre2 = (p["datos"]["equipo2"]["nombre"]);
  19.             var ml = (p["datos"]["equipo1"]["ml"]);
  20.             var ml2 = (p["datos"]["equipo2"]["ml"]);
  21.             var rl = (p["datos"]["equipo1"]["rl"]+" "+p["datos"]["equipo1"]["rll"]);
  22.             var rl2 = (p["datos"]["equipo2"]["rl"]+" "+p["datos"]["equipo2"]["rll"]);
  23.             var ab = (p["datos"]["equipo1"]["ab"]+" "+p["datos"]["equipo1"]["abl"]);
  24.             var hora = new Date();
  25.             var tml = "ML";
  26.             var tab = "AB";
  27.             var trl = "RL";
  28.             db.transaction(function (tx) {
  29.                 tx.executeSql('CREATE TABLE IF NOT EXISTS juego (id_equipo unique, id_juego, fecha, nombre, ref)');
  30.                 tx.executeSql('CREATE TABLE IF NOT EXISTS logro (id_equipo, logros, clase, horac)');
  31.                 if ((p["datos"]["id_padre"]) != "null") {
  32.                     id_juego = (p["datos"]["id_padre"]);
  33.                     if (ref.substr(0,1)=="G") {
  34.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "GT", ?)', [id, ab, hora]);
  35.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "GT", ?)', [id2, ab, hora]);
  36.                     }
  37.                     ;
  38.                     if (ref.substr(0,1)=="9") {
  39.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "INN", ?)', [id, ml, hora]);
  40.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "INN", ?)', [id2, ml2, hora]);
  41.                     }
  42.                     ;
  43.                     if (ref.substr(0,1)=="7") {
  44.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "AP", ?)', [id, ml, hora]);
  45.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "AP", ?)', [id2, ml2, hora]);
  46.                     }
  47.                     ;
  48.                     if (ref.substr(0,1)=="5") {
  49.                         tml = "MLP";
  50.                         tab = "ABP";
  51.                         trl = "RLP";
  52.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, ml, tml, hora]);
  53.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, ml2, tml, hora]);
  54.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, rl, trl, hora]);
  55.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, rl2, trl, hora]);
  56.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, ab, tab, hora]);
  57.                         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, ab, tab, hora]);
  58.                     }
  59.                     ;
  60.                 } else {
  61.                     tx.executeSql('INSERT INTO juego (id_equipo, id_juego,  fecha, nombre, ref) VALUES (?, ?, ?, ?, ?)', [id, id_juego, fecha, nombre, ref]);
  62.                     tx.executeSql('INSERT INTO juego (id_equipo, id_juego, fecha, nombre, ref) VALUES (?, ?, ?, ?, ?)', [id2, id_juego, fecha, nombre2, ref2]);
  63.                     tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, ml,tml, hora]);
  64.                     tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, ml2, tml, hora]);
  65.                     tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, rl, trl, hora]);
  66.                     tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, rl2, trl, hora]);
  67.                     tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, ab, tab, hora]);
  68.                     tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, ab, tab, hora]);
  69.                 }
  70.                 ;
  71.                 if ((p["datos"]["equipo1"]["srll"]) !="0") {
  72.                     var srl = (p["datos"]["equipo1"]["srl"]+" "+p["datos"]["equipo1"]["srll"]);
  73.                     var srl2 = (p["datos"]["equipo2"]["srl"]+" "+p["datos"]["equipo2"]["srll"]);
  74.                     tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "SRL", ?)', [id, srl, hora]);
  75.                     tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "SRL", ?)', [id2, srl2, hora]);
  76.                 }
  77.                 ;
  78.                 if ((p["datos"]["empate"])) {
  79.                     var ref3 = (p["datos"]["empate"]["ref"]);
  80.                     var ml3 = (p["datos"]["empate"]["ml"]);
  81.                     var id3 = (p["datos"]["empate"]["id"]);
  82.                     tx.executeSql('INSERT INTO juego (id_equipo, id_juego, fecha, nombre, ref) VALUES (?, ?, ?, "Empate", ?)', [id3, id_juego, fecha, ref3]);
  83.                     tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "ML", ?)', [id3, ml3, hora]);
  84.                 }
  85.                 ;
  86.             }
  87.             );
  88.         } else if (tipo == "cambiologro") {
  89.             var id = (p["datos"]["id"]);
  90.             var logros = (p["datos"]["logros"]);
  91.             var clase = (p["datos"]["tipo"]);
  92.             var horac = (p["datos"]["fecha"]);
  93.             db.transaction(function (tx) {
  94.                 tx.executeSql('UPDATE  logro  SET logros=?, horac=? WHERE id_equipo=? && clase=?', [logros, horac, id, clase]);
  95.             }
  96.             );
  97.         } else if (tipo == "cambiofecha") {
  98.             var id = (p["datos"]["id"]);
  99.             var fecha = (p["datos"]["fecha"]);
  100.             db.transaction(function (tx) {
  101.                 tx.executeSql('UPDATE juego SET fecha=? WHERE id_juego=?' , [fecha, id]);
  102.             }
  103.             );
  104.         } else if (tipo == "juegocerrado") {
  105.             var id = (p["datos"]["id"]);
  106.             db.transaction(function (tx) {
  107.                 tx.executeSql('SELECT id_equipo FROM juego WHERE id_juego=?', [id], function (tx, results) {
  108.                     var len = results.rows.length, i;
  109.                     for (i = 0; i < len; i=i++) {
  110.                         var id_equipo = results.rows.item(i).id_equipo;
  111.                         tx.executeSql('DELETE FROM logros WHERE id_equipo=?' , [id_equipo]);
  112.                     }
  113.                     ;
  114.                 }
  115.                 , null);
  116.                 tx.executeSql('DELETE FROM juego  WHERE id_juego=?' , [id]);
  117.             }
  118.             );
  119.         }
  120.         ;
  121.     }//desde aquí comienzan las llaves que no cierran
  122.     );
  123. }//hasta aquí
  124. ;
  125. var on_error =  function() {
  126.     console.log('error');
  127. }
  128. ;
  129. client.connect('guest', 'guest', on_connect, on_error, 'logros');