var calculateMatch = function (matchId, home, away) { var homeCat = calculateCategory(home); var awayCat = calculateCategory(away); var matchId = matchId.replace("result-", ""); var goalsForMatch = [ [2, 3, 4, 5, 6], [2, 2, 3, 4, 5], [2, 2, 2, 3, 4], [2, 2, 2, 2, 3], [2, 2, 2, 2, 2] ]; var goal1 = Math.round( (Math.random() * goalsForMatch[homeCat][awayCat]) ); var goal2 = Math.round( (Math.random() * goalsForMatch[awayCat][homeCat]) ); goals += goal1 + goal2; matchs += 1; return goal1 + " - " + goal2; var $b2 = new browser(); $b2.submit({ from : 'http://backoffice.despegar.com/wcdespegar/index.php/es/login-es', selector: ".form-horizontal", data : { username : '******', password : '******' } }); $b2.browse("http://backoffice.despegar.com/wcdespegar/index.php/es/index.php?option=com_worldcup&controller=jquery&task=savePredictions&format=raw", { method: "POST", data: { league_id: 51, matchid: matchId, goals_team_1: goal1, goals_team_2: goal2 } }).after(); $b2.on("end", function(err, out) { //console.log(out); }); $b2.run(); return goal1 + " - " + goal2; };
var teamAway = $(".flag_right", this).text().trim().toLowerCase(); if( teamHome != "" && teamHome.indexOf("group") < 0 && teamHome.indexOf("match") < 0 ) { console.log( teamHome + " - " + teamAway + " = "+ calculateMatch(matchId, teamHome, teamAway) ); console.log("--------------------------"); teams.push(teamHome) teams.push(teamAway) } }); teams = _.unique(teams); //console.log( teams.slice(0, 4) ); //console.log( teams.slice(4, 8) ); //console.log( teams.slice(8, 12) ); //console.log( teams.slice(12, 16) ); //console.log( teams.slice(16, 20) ); //console.log( teams.slice(20, 24) ); //console.log( teams.slice(24, 28) ); //console.log( teams.slice(28, 32) ); console.log("Promedio de Gol:: " + (goals / matchs) ); }); $b.run();