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

Aqui el fulano el problema es que no cierra on_conect, no creo que sea error del codigo, tal vez la funcion tiene un limite de lineas nose, ya tenemos dias dos programa

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.         if (ref.substr(0,1)=="9") {
  38.           tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "INN", ?)', [id, ml, hora]);
  39.           tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "INN", ?)', [id2, ml2, hora]);  
  40.         };
  41.         if (ref.substr(0,1)=="7") {
  42.           tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "AP", ?)', [id, ml, hora]);
  43.           tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "AP", ?)', [id2, ml2, hora]);
  44.         };
  45.         if (ref.substr(0,1)=="5") {
  46.         tml = "MLP";
  47.         tab = "ABP";
  48.         trl = "RLP";
  49.         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, ml, tml, hora]);
  50.         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, ml2, tml, hora]);
  51.         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, rl, trl, hora]);
  52.         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, rl2, trl, hora]);
  53.         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, ab, tab, hora]);
  54.         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, ab, tab, hora]);
  55.         };
  56.       } else {
  57.       tx.executeSql('INSERT INTO juego (id_equipo, id_juego,  fecha, nombre, ref) VALUES (?, ?, ?, ?, ?)', [id, id_juego, fecha, nombre, ref]);
  58.       tx.executeSql('INSERT INTO juego (id_equipo, id_juego, fecha, nombre, ref) VALUES (?, ?, ?, ?, ?)', [id2, id_juego, fecha, nombre2, ref2]);
  59.  
  60.       tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, ml,tml, hora]);
  61.       tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, ml2, tml, hora]);
  62.       tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, rl, trl, hora]);
  63.       tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, rl2, trl, hora]);
  64.       tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id, ab, tab, hora]);
  65.       tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, ?, ?)', [id2, ab, tab, hora]);
  66.       };
  67.       if ((p["datos"]["equipo1"]["srll"]) !="0") {
  68.       var srl = (p["datos"]["equipo1"]["srl"]+" "+p["datos"]["equipo1"]["srll"]);
  69.       var srl2 = (p["datos"]["equipo2"]["srl"]+" "+p["datos"]["equipo2"]["srll"]);
  70.       tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "SRL", ?)', [id, srl, hora]);
  71.       tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "SRL", ?)', [id2, srl2, hora]);
  72.       };
  73.       if ((p["datos"]["empate"])) {
  74.         var ref3 = (p["datos"]["empate"]["ref"]);
  75.         var ml3 = (p["datos"]["empate"]["ml"]);
  76.         var id3 = (p["datos"]["empate"]["id"]);
  77.         tx.executeSql('INSERT INTO juego (id_equipo, id_juego, fecha, nombre, ref) VALUES (?, ?, ?, "Empate", ?)', [id3, id_juego, fecha, ref3]);
  78.         tx.executeSql('INSERT INTO logro (id_equipo, logros, clase, horac) VALUES (?, ?, "ML", ?)', [id3, ml3, hora]);
  79.       };
  80.       });
  81.     } else if (tipo == "cambiologro") {
  82.       var id = (p["datos"]["id"]);
  83.       var logros = (p["datos"]["logros"]);
  84.       var clase = (p["datos"]["tipo"]);
  85.       var horac = (p["datos"]["fecha"]);
  86.       db.transaction(function (tx) {
  87.       tx.executeSql('UPDATE  logro  SET logros=?, horac=? WHERE id_equipo=? && clase=?', [logros, horac, id, clase]);
  88.       });
  89.     } else if (tipo == "cambiofecha") {
  90.       var id = (p["datos"]["id"]);
  91.       var fecha = (p["datos"]["fecha"]);
  92.       db.transaction(function (tx) {
  93.       tx.executeSql('UPDATE juego SET fecha=? WHERE id_juego=?' , [fecha, id]);
  94.       });
  95.     } else if (tipo == "juegocerrado") {
  96.       var id = (p["datos"]["id"]);
  97.       db.transaction(function (tx) {
  98.       tx.executeSql('SELECT id_equipo FROM juego WHERE id_juego=?', [id], function (tx, results) {
  99.       var len = results.rows.length, i;
  100.       for (i = 0; i < len; i=i++){
  101.       var id_equipo = results.rows.item(i).id_equipo;
  102.       tx.executeSql('DELETE FROM logros WHERE id_equipo=?' , [id_equipo]);
  103.      };
  104.         }, null);
  105.       tx.executeSql('DELETE FROM juego  WHERE id_juego=?' , [id]);
  106.       });
  107.     };
  108.   });
  109. };
  110.     var on_error =  function() {
  111.         console.log('error');
  112.     };
  113.     client.connect('guest', 'guest', on_connect, on_error, 'logros');