Updated Code fix for the AutoUpdate (Scoring) Feature

Post here to discuss topics relate to the 4.x version for the ASP Football Pool software program. All support topics should go here.
User avatar
admin
Site Admin
Posts: 159
Joined: Mon Aug 26, 2013 3:47 pm

Updated Code fix for the AutoUpdate (Scoring) Feature

Post by admin »

Here is a slight update to the AutoUpdate (Scoring) feature of the program. I might have put this in another thread, but just wanted to make sure it is out there:

Here is the old fix:

Find the updateScores.asp file in your root directory

Find:

Code: Select all

    if (s.toLowerCase() == "final") {

Replace with:

Code: Select all

    if ((s != null) && (s.toLowerCase() == "final")) {


Here is what you should replace it with now:

Code: Select all

 if ((s != null) && ((s.trim().toLowerCase() == "final") || (s.trim().toLowerCase() == "final ot"))) {
Minor Change, but this now accounts for any games that go in to OT.

Here is an update posted later on, wanted to put it in the 1st post as well, but read the entire thread for full details.
mb323 wrote:If anyone is having trouble or hasn't updated the updatescores.asp yet, I made a change to mine to make the year update automatic.

I checked the current master download and it has all of the updates from above. Also there are no changes required for the LA RAMS.

To automatically change the year search for:

Code: Select all

var scoresUrlBase        = "http://www.nfl.com/scores/2014/REG";
The code above is dependent on the current master release as it has 2014, if you have updated yours then insert 2016 in the above search.

and replace it with:

Code: Select all

var currentYear = new Date().getFullYear();
var scoresUrlBase = "http://www.nfl.com/scores/" + currentYear + "/REG";

Phil
User avatar
mlhall
Posts: 2
Joined: Thu Aug 21, 2014 9:03 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by mlhall »

Nice work Phil, I've incorporated the fix for updateScores.asp into the download.
User avatar
philwojo
Posts: 143
Joined: Mon Aug 26, 2013 4:22 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by philwojo »

Cool, very good new Mike, thanks for the update!
User avatar
6burgh
Posts: 33
Joined: Thu Sep 04, 2014 7:53 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by 6burgh »

Thanks for the fix!
jasonlnlv
Posts: 16
Joined: Thu Sep 04, 2014 2:19 am

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by jasonlnlv »

I uploaded the new file the other day but when I try to load the scores it just comes up Saying 'Loading' with a progress bar repeating - never loads anything but I cancel and try again with no success ....
User avatar
philwojo
Posts: 143
Joined: Mon Aug 26, 2013 4:22 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by philwojo »

Works for me, can you open up the specific file on your web server and make sure the changes are actually in there. I have seen where it appears a file is uploaded but the web server rejects it so it is still the old file.
holgar
Posts: 32
Joined: Fri Aug 22, 2014 5:30 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by holgar »

This is my code and I've never gotten it to work... Is there a "dummy's" version of other places and/or the step by step for enabling?

Code: Select all

<%@ LANGUAGE="VBScript" %>
<!-- #include file="includes/config.asp" --><!-- #include file="includes/common.asp" --><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!-- #include file="includes/email.asp" -->
<!-- #include file="includes/encryption.asp" -->
<!-- #include file="includes/form.asp" -->
<!-- #include file="includes/side.asp" -->
<!-- #include file="includes/weekly.asp" -->
<%	'Limit access to the Administrator.
	call CheckAccess(true)

	'Open the database.
	call OpenDb() %>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<%	PageSubTitle = "Enter Game Scores"
	if not ENABLE_SCORES_ADDON then
		call BuildPageHeader("", "")
	else
		call BuildPageHeader("loadDialogs.css", "") %>
	<script type="text/javascript">//<![CDATA[
	//=========================================================================
	// Module: scoresLoader
	//
	// Used to set game scores using data retrieved from the NFL.com web site.
	//=========================================================================
	var scoresLoader = function () {

		// The update form.
		var formEl = null;

		// The week to update.
		var week = "";

		// Define an array to hold form field information for each game listed
		// on the form.
		var gameFields = [];

		// These are used to load the scores page from the NFL.com web site.
		var scoresIframe         =  null;
		var scoresUrlBase        = "http://www.nfl.com/scores/2013/REG";
		var loadCheckIntervalID  =  null;
		var loadCheckInterval    =  1000; // one second.
		var loadCheckMaxWaitTime = 30000; // 30 seconds.
		var loadStartTime        =     0;

		// Auto-update parameters.
		var autoUpdate               =  false;
		var autoUpdateLoadTimeoutID  =   null;
		var autoUpdateLoadTimeout    = 600000; // 10 minutes.
		var autoUpdateDialogTimeout  =    500; // one half second.

		// Holds the data parsed from the scores page.
		var gameData = null;

		// Used for dialog messages.
		var resultMsg       = "";
		var errorMsg        = "";
		var foundNewResults = false;

		//---------------------------------------------------------------------
		// Initializes the scores loader.
		//---------------------------------------------------------------------
		function init() {

			// Get the scores update form.
			formEl = document.getElementById("scoresForm");

			// Get the week.
			week = formEl.elements["week"].value;

			// Scan the form and build the games fields array.
			var i = 1;
			var el;
			while ((el = formEl.elements["id-" + i]) != null) {
				var vid      = formEl.elements["vid-" + i].value;
				var hid      = formEl.elements["hid-" + i].value;
				var vscoreEl = formEl.elements["vscore-" + i];
				var hscoreEl = formEl.elements["hscore-" + i];
				var otEl     = formEl.elements["ot-" + i];
				gameFields.push({
					"visitorID"      : vid,
					"visitorScoreEl" : vscoreEl,
					"homeID"         : hid,
					"homeScoreEl"    : hscoreEl,
					"overtimeEl"     : otEl
				});
				i++;
			}

			// If auto-update is checked, start it.
			autoUpdate = formEl.elements["autoUpdate"].checked;
			if (autoUpdate)
				autoUpdateLoadTimeoutID = setTimeout(getScores, autoUpdateLoadTimeout);
		}

		//---------------------------------------------------------------------
		// Initiates the retrieval of game results.
		//---------------------------------------------------------------------
		function getScores() {

			// Clear any existing game data.
			gameData = [];

			// Clear any highlighting on the form fields.
			for (var i = 0; i < gameFields.length; i++) {
				domUtils.removeClass(gameFields[i].visitorScoreEl,        "fieldLoaded");
				domUtils.removeClass(gameFields[i].homeScoreEl,           "fieldLoaded");
				domUtils.removeClass(gameFields[i].overtimeEl.parentNode, "fieldLoaded");
			}

			// Initialize the display.
			foundNewResults = false;
			showLoadingDisplay("loadingActive");

			// Create an iframe for loading the scores page and set an interval
			// timer to monitor it.
			if (scoresIframe != null)
				getScoresCleanUp();

			scoresIframe = document.createElement("IFRAME");
			scoresIframe.src = "javascript:false;document.write('');document.close();";
			scoresIframe.width = 0;
			scoresIframe.height = 0;
			scoresIframe.style.display ="none";
			scoresIframe = document.body.appendChild(scoresIframe);
			scoresIframe.src = "getHtmlScores.asp?url=" + escape(scoresUrlBase + week);
			loadStartTime = new Date();
			loadCheckIntervalID = setInterval(scoresLoadedCheck, loadCheckInterval);

			return false;
		}

		//-------------------------------------------------------------------------
		// Called by an interval timer to determine if the scores page has been
		// loaded.
		//-------------------------------------------------------------------------
		function scoresLoadedCheck() {

			try {

				// Get the document within the iframe.
				var obj = scoresIframe.contentWindow || scoresIframe.contentDocument;
	 			if (obj.document != null) {
					scoresIframe.scoresDoc = obj.document;

					// Check for our marker element to be sure the whole page
					// has been loaded.
					if (scoresIframe.scoresDoc.getElementById("BrainJar") != null) {

						// Stop checking.
						if (loadCheckIntervalID != null) {
							clearInterval(loadCheckIntervalID);
							loadCheckIntervalID = null;
						}

						// Process the scores page, clean-up and exit.
						processScores();
						getScoresCleanUp();
						return;
					}
				}
			}
			catch (ex) {}

			// Has the max wait time been exceeded?
			var currentTime = new Date();
			if (currentTime.valueOf() - loadStartTime.valueOf() > loadCheckMaxWaitTime) {

				// Yes, abort.
				getScoresCleanUp();
				errorMsg = "The operation timed out, try again later.";
				showLoadingDisplay("loadingError");

				// If auto-update is on, set for the next attempt.
				if (autoUpdate) {
					setTimeout(hideLoadingDisplay, autoUpdateDialogTimeout);
					autoUpdateLoadTimeoutID = setTimeout(getScores, autoUpdateLoadTimeout);
				}
			}
		}

		//---------------------------------------------------------------------
		// Cleans up after an attempt to load game results.
		//---------------------------------------------------------------------
		function getScoresCleanUp() {

			// Clear the interval timer.
			if (loadCheckIntervalID != null) {
				clearInterval(loadCheckIntervalID);
				loadCheckIntervalID = null;
			}

			// Remove the IFRAME.
			if (scoresIframe != null) {
				document.body.removeChild(scoresIframe);
				scoresIframe = null;
			}
		}

		//---------------------------------------------------------------------
		// Parses the scores page and updates the form with any new game
		// results.
		//---------------------------------------------------------------------
		function processScores() {

			// Get the document loaded in the iframe.
			var doc = scoresIframe.scoresDoc;

			// Scan the document for final game results. Below is the basic
			// pattern searched for. There should be one of these for each
			// game:
			//
			// <div class="new-score-box">
			//   <div class="team-wrapper">
			//     <div class="away-team">
			//       <a href="/teams/profile?team=AWAY_ID" ...>...</a>
			//       <div class="team-data">
			//         <div class="team-info">
			//           <p class="team-record">...</p>
			//           <p class="team-name"><a href="/teams/profile?team=AWAY_ID" ...>...</a></p>              
			//         </div>
			//         <p class="total-score">AWAY_SCORE</p>
			//         <p class="quarters-score"><span class="first-qt">nn</span><span class="second-qt">nn</span><span class="third-qt">nn</span><span class="fourth-qt">nn</span><span class="ot-qt">nn</span></p> 
			//       </div>
			//     </div>      
			//   </div>         
			//   <div class="team-wrapper">      
			//     <div class="home-team">
			//       <a href="/teams/profile?team=HOME_ID" ...>...</a>
			//       <div class="team-data">
			//         <div class="team-info">
			//           <p class="team-record">...</p>
			//           <p class="team-name"><a href="/teams/profile?team=HOME_ID" ...>...</a></p>              
			//         </div>
			//         <p class="total-score">HOME_SCORE</p>
			//         <p class="quarters-score"><span class="first-qt">nn</span><span class="second-qt">nn</span><span class="third-qt">nn</span><span class="fourth-qt">nn</span><span class="ot-qt">nn</span></p> 
			//       </div>
			//     </div>  
			//   </div>      
			//   <div class="game-center-area">
			//     ...
			//     <p><span class="time-left">FINAL</span></p>
			//     ...
			//   </div>
			//   ...
			// </div>
			var vid, hid, vscore, hscore, ot;
			var s
			var el, el2;
			var vn, hn;

			var divEls = doc.getElementsByTagName("DIV");
			for (var i = 0; i < divEls.length; i++) {

				// Is this a "new-score-box" DIV?
				if (domUtils.hasClass(divEls[i], "new-score-box")) {
					vid    = "";
					hid    = "";
					vscore = "";
					hscore = "";
					ot     = false;

					el = getFirstSubTagWithClass(divEls[i], "SPAN", "time-left");
					if (el && el.firstChild) {

						// Is the score final?
						s = el.firstChild.nodeValue;
                                                if ((s != null) && ((s.trim().toLowerCase() == "final") || (s.trim().toLowerCase() == "final ot"))) {

							// Get visitor team data.
							el = getFirstSubTagWithClass(divEls[i], "DIV", "away-team");
							el2 = getFirstSubTagWithClass(el, "P", "team-name");
							el2 = getFirstSubTag(el2, "A");
							if (el2)
								vid = getQueryStringParameter(el2.search, "team");
							el2 = getFirstSubTagWithClass(el, "P", "total-score");
							if (el2 && el2.firstChild)
								vscore = el2.firstChild.nodeValue;
							el2 = getFirstSubTagWithClass(el, "P", "quarters-score");
							el2 = getFirstSubTagWithClass(el2, "SPAN", "ot-qt");
							vn = null;
							if (el2 && el2.firstChild)
								vn = el2.firstChild.nodeValue;

							// Get home team data.
							el = getFirstSubTagWithClass(divEls[i], "DIV", "home-team");
							el2 = getFirstSubTagWithClass(el, "P", "team-name");
							el2 = getFirstSubTag(el, "A");
							if (el2)
								hid = getQueryStringParameter(el2.search, "team");
							el2 = getFirstSubTagWithClass(el, "P", "total-score");
							if (el2 && el2.firstChild)
								hscore = el2.firstChild.nodeValue;
							el2 = getFirstSubTagWithClass(el, "P", "quarters-score");
							el2 = getFirstSubTagWithClass(el2, "SPAN", "ot-qt");
							hn = null;
							if (el2 && el2.firstChild)
								hn = el2.firstChild.nodeValue;
															
							// Check for overtime.
							if (vn && !isNaN(vn) && hn && !isNaN(hn))
								ot = true;

							// Fix team IDs.
							if (vid == "JAC")
								vid = "JAX";
							if (hid == "JAC")
								hid = "JAX";

							// Save the results.
							gameData.push({
								"visitorID"    : vid,
								"visitorScore" : vscore,
								"homeID"       : hid, 
								"homeScore"    : hscore,
								"overtime"     : ot
							});
						}
					}
				}
			}

			// Copy any new results to the appropriate form fields and reset
			// the display.
			setGameFields();
			if (foundNewResults) {
				hideLoadingDisplay();

				// If auto-update is on, submit the form to update the scores.
				if (autoUpdate) {

					// Add a new submit button to the form and click it to
					// perform the update.
					var inputEl = document.createElement("INPUT");
					inputEl.name = "submit";
					inputEl.type = "submit";
					inputEl.value = "Update";
					inputEl = formEl.appendChild(inputEl);
					inputEl.click();
				}
			}
			else {
				showLoadingDisplay("loadingComplete");

				// Handle auto-update.
				if (autoUpdate) {
					setTimeout(hideLoadingDisplay, autoUpdateDialogTimeout);

					// Determine if any scores are still missing.
					var missingScores = false;
					for (i = 0; i < gameFields.length && !missingScores; i++)
						if (gameFields[i].visitorScoreEl.value == "" || gameFields[i].homeScoreEl.value == "")
							missingScores = true;

					// If there are missing scores, set for the next attempt.
					// Otherwise off turn auto-update.
					if (missingScores)
						autoUpdateLoadTimeoutID = setTimeout(getScores, autoUpdateLoadTimeout);
					else
						stopAutoUpdate();
				}
			}
		}

		//---------------------------------------------------------------------
		// Given an element, finds the first occurrence of the given tag with
		// the given class name in its descendants.
		//---------------------------------------------------------------------
		function getFirstSubTagWithClass(el, tName, cName) {

			if (el != null) {
				var elList = el.getElementsByTagName(tName);
				for (var i = 0; i < elList.length; i++)
					if (domUtils.hasClass(elList[i], cName))
						return elList[i];
			}

			return null;
		}

		//---------------------------------------------------------------------
		// Given an element, finds the first occurrence of the given tag in
		// its descendants.
		//---------------------------------------------------------------------
		function getFirstSubTag(el, tName) {

			if (el != null) {
				var elList = el.getElementsByTagName(tName);
				if (elList.length > 0)
					return elList[0];
			}

			return null;
		}

		//---------------------------------------------------------------------
		// Given a url, returns the value assigned to the given query string
		// parameter.
		//---------------------------------------------------------------------
		function getQueryStringParameter(qs, pName) {

			var re = new RegExp( "[?&]" + pName + "=([^&$]*)", "i" );
			var offset = qs.search(re);
			if (offset == -1)
				return "";

			return RegExp.$1;
		}

		//---------------------------------------------------------------------
		// Takes the parsed game results and updates the appropriate form
		// fields.
		//---------------------------------------------------------------------
		function setGameFields() {

			// For each game result found, find a matching set of form fields
			// to load the data into.
			if (gameData.length > 0) {
				resultMsg = "All game results are up to date.";
				for (var i = 0; i < gameFields.length; i++)
					for (var j = 0; j < gameData.length; j++)

						// Check if the teams match.
						if (gameFields[i].visitorID == gameData[j].visitorID && gameFields[i].homeID == gameData[j].homeID)
						{
							// Set the individual form fields.
							setFormField(gameFields[i].visitorScoreEl, gameData[j].visitorScore);
							setFormField(gameFields[i].homeScoreEl,    gameData[j].homeScore);
							setFormField(gameFields[i].overtimeEl,     gameData[j].overtime);
							break;
						}
			}
			else
				resultMsg = "No results available, try again later.";
		}

		//---------------------------------------------------------------------
		// Updates a single form field with the given value (if that value is
		// different from the field's current value).
		//---------------------------------------------------------------------
		function setFormField(fieldEl, newValue) {

			// Compare the old and new values.
			var oldValue = fieldEl.value;
			if (fieldEl.type == "checkbox")
				oldValue = fieldEl.checked;

			// If the values are the same, exit.
			if (oldValue == newValue)
				return;

			// Set the form field value and highlight it.
			if (fieldEl.type == "checkbox") {
				fieldEl.checked = newValue;
				domUtils.addClass(fieldEl.parentNode, "fieldLoaded");
			}
			else {
				fieldEl.value = newValue;
				domUtils.addClass(fieldEl, "fieldLoaded");
			}

			// Note that we have new results.
			foundNewResults = true;
		}

		//---------------------------------------------------------------------
		// Shows the loading display with the specified message box.
		//---------------------------------------------------------------------
		function showLoadingDisplay(id) {

			// Hide all the message boxes.
			document.getElementById("loadingActive").style.display   = "none";
			document.getElementById("loadingComplete").style.display = "none";
			document.getElementById("loadingError").style.display    = "none";

			// Set the result and error messages.
			var el = document.getElementById("loadingResultMsg");
			while (el.firstChild != null)
				el.removeChild(el.firstChild);
			document.getElementById("loadingResultMsg").appendChild(document.createTextNode(resultMsg));
			var el = document.getElementById("loadingErrorMsg");
			while (el.firstChild != null)
				el.removeChild(el.firstChild);
			document.getElementById("loadingErrorMsg").appendChild(document.createTextNode(errorMsg));

			// Show the specified message box.
			el = document.getElementById(id);
			if (el != null)
				el.style.display  = "";

			// Make it visible.
			document.getElementById("loadingDisplay").style.visibility = "visible";
		}

		//---------------------------------------------------------------------
		// Hides the loading display.
		//---------------------------------------------------------------------
		function hideLoadingDisplay() {

			document.getElementById("loadingDisplay").style.visibility = "hidden";
		}

		//---------------------------------------------------------------------
		// Turns auto-update off.
		//---------------------------------------------------------------------
		function stopAutoUpdate() {

			// Cancel any pending attempt.
			if (autoUpdateLoadTimeoutID != null) {
				clearTimeout(autoUpdateLoadTimeoutID);
				autoUpdateLoadTimeoutID = null;
			}

			// Set the flag to false and clear the checkbox.
			autoUpdate = false;
			formEl.elements["autoUpdate"].checked = false;
		}

		//=====================================================================
		// Initialization code.
		//=====================================================================

		// Initialize on page load.
		domUtils.onready(init);

		//=====================================================================
		// Public properties and methods.
		//=====================================================================
		return {

			//-----------------------------------------------------------------
			// Loads game scores for the given week.
			//-----------------------------------------------------------------
			load : function () {

				// Turn off auto-update, if it is on.
				if (autoUpdate)
					stopAutoUpdate();

				getScores();
				return false;
			},

			//-----------------------------------------------------------------
			// Cancels a load.
			//-----------------------------------------------------------------
			cancel : function () {

				getScoresCleanUp();
				hideLoadingDisplay();

				// If auto-update is on, turn it off.
				if (autoUpdate)
					stopAutoUpdate();

				return false;
			},

			//-----------------------------------------------------------------
			// Closes the load display.
			//-----------------------------------------------------------------
			close : function () {

				hideLoadingDisplay();
				return false;
			},

			//-----------------------------------------------------------------
			// Toggles auto-update.
			//-----------------------------------------------------------------
			toggleAutoUpdate : function () {

				// If auto-update is on, turn it off. Otherwise, turn it on and
				// make an attempt.
				if (autoUpdate)
					stopAutoUpdate();
				else {
					autoUpdate = true;
					getScores();
				}

				// Allow the check box to change.
				return true;
			}
		}
	}();
	//]]></script>
<%	end if %>
<!-- #include file="includes/custom.asp" -->
</head>
<body>
<!-- #include file="includes/header.asp" -->
<!-- #include file="includes/menu.asp" -->
	<div id="contentSection">
	<table id="mainWrapper" border="0" cellpadding="0" cellspacing="0"><tr><td>
<%	'Get the week to display.
	dim week
	week = GetRequestedWeek()

	'If there is form data, process it.
	dim n, i
	dim gameID, vscore, hscore, ot
	dim notify, infoMsg
	dim sql, rs
	n = GetGameCount(week)
	if Request.ServerVariables("Content_Length") > 0 and not IsCancelRequest() then
		for i = 1 to n

			'Get the form fields.
			gameID = Trim(Request.Form("id-"     & i))
			vscore = Trim(Request.Form("vscore-" & i))
			hscore = Trim(Request.Form("hscore-" & i))
			ot     = Trim(Request.Form("ot-"     & i))

			'Validate the form fields.
			if vscore <> "" or hscore <> "" or ot <> "" then
				if not IsValidInteger(vscore) then
					FormFieldErrors.Add "vscore-" & i, "'" & vscore & "' is not a valid game score."
				else
					if CInt(vscore) < 0 then
						FormFieldErrors.Add "vscore-" & i, "'" & vscore & "' is not a valid game score."
					end if
				end if
				if not IsValidInteger(hscore) then
					FormFieldErrors.Add "hscore-" & i, "'" & hscore & "' is not a valid game score."
				else
					if CInt(hscore) < 0 then
						FormFieldErrors.Add "hscore-" & i, "'" & hscore & "' is not a valid game score."
					end if
				end if
			end if
		next

		'If there were any errors, display the error summary message.
		'Otherwise, do the updates.
		if FormFieldErrors.Count > 0 then
			call DisplayFormFieldErrorsMessage("Error: Invalid fields. Please correct and resubmit.")
		else
			for i = 1 to n
				gameID = Trim(Request.Form("id-"    & i))
				vscore = Trim(Request.Form("vscore-" & i))
				hscore = Trim(Request.Form("hscore-" & i))
				ot     = Trim(Request.Form("ot-"     & i))
				if LCase(ot) <> "true" then
					ot = false
				end if

				'Update the scores.
				if vscore = "" then
					vscore ="NULL"
				end if
				if hscore = "" then
					hscore ="NULL"
				end if
				sql = "UPDATE Schedule SET" _
				   & " VisitorScore = " & vscore & "," _
				   & " HomeScore    = " & hscore & "," _
				   & " OT           = " & ot _
				   & " WHERE GameID = " & gameID
				call DbConn.Execute(sql)

				'Update the results.
				call SetGameResults(gameID)

			next

			'Clear any cached pool results.
			call ClearWeeklyResultsCache(week)
			if ENABLE_MARGIN_POOL then
				call ClearMarginResultsCache(week)
			end if
			if ENABLE_SURVIVOR_POOL then
				call ClearSurvivorStatus(week)
			end if

			'Send out email notifications, if checked.
			infoMsg = "Update successful."
			notify = Trim(Request.Form("notify"))
			if LCase(notify) = "true" then
				infoMsg = "Update successful, notifications sent."
				call SendNotifications()
			end if

			'Updates done, show an informational message.
			call DisplaySuccessMessage(infoMsg)
		end if
	end if

	'Display the schedule for the specified week.
	dim cols
	cols = 9
	if USE_POINT_SPREADS then
		cols = cols + 1
	end if %>
	<form id="scoresForm" action="<% = Request.ServerVariables("SCRIPT_NAME") %>" method="post">
		<div><input type="hidden" name="week" value="<% = week %>" /></div>
		<table border="0" cellpadding="0" cellspacing="0"><tr><td style="padding: 0px;">
		<table class="main" border="0" cellpadding="0" cellspacing="0">
			<tr class="header bottomEdge">
			  <th align="left" colspan="<% = cols %>">Week <% = week %></th>
			</tr>
<%	if ENABLE_SCORES_ADDON then
		dim autoUpdate, missingScores
		autoUpdate    = false
		missingScores = false
	end if

	dim gameDate, gameTime, vid, hid
	dim visitor, home, result, checkedStr
	dim spread, atsResult
	dim alt
	set rs = GetGamesRecordset(week)
	if not (rs.EOF and rs.BOF) then
		n = 1
		alt = false
		do while not rs.EOF
			gameID    = rs.Fields("GameID").Value
			gameDate  = rs.Fields("Date").Value
			gameTime  = rs.Fields("Time").Value
			vid       = rs.Fields("VisitorID").Value
			vscore    = rs.Fields("VisitorScore").Value
			spread    = rs.Fields("PointSpread").Value
			hid       = rs.Fields("HomeID").Value
			hscore    = rs.Fields("HomeScore").Value
			ot        = rs.Fields("OT").Value
			result    = rs.Fields("Result").Value
			atsResult = rs.Fields("ATSResult").Value
			visitor   = rs.Fields("VCity").Value
			home      = rs.Fields("HCity").Value

			if ENABLE_SCORES_ADDON then
				if IsNull(vscore) or IsNull(hscore) then
					missingScores = true
				end if
			end if

			'Set the team names for display.
			if rs.Fields("VDisplayName").Value <> "" then
				visitor = rs.Fields("VDisplayName").Value
			end if
			if rs.Fields("HDisplayName").Value <> "" then
				home = rs.Fields("HDisplayName").Value
			end if

			'Highlight the results.
			if result = vid then
				visitor = FormatWinner(visitor)
			elseif result = hid then
				home = FormatWinner(home)
			end if
			if atsResult = vid then
				visitor = FormatATSWinner(visitor)
			elseif atsResult = hid then
				home = FormatATSWinner(home)
			end if

			'If there were errors on the form post processing, restore those fields.
			if FormFieldErrors.Count > 0 then
				vscore = GetFieldValue("vscore-" & n, vscore)
				hscore = GetFieldValue("hscore-" & n, hscore)
				ot     = FormFieldExists("ot-" & n)
			end if

			'Set the OT checkbox state.
			checkedStr = ""
			if ot then
				checkedStr = CHECKED_ATTRIBUTE
			end if

			if alt then %>
			<tr align="right" class="alt">
<%			else %>
			<tr align="right">
<%			end if
			alt = not alt %>
<%				if ENABLE_SCORES_ADDON then %>
				<td><input type="hidden" name="id-<% = n %>" value="<% = gameID %>" /><input type="hidden" name="vid-<% = n %>" value="<% = vid %>" /><input type="hidden" name="hid-<% = n %>" value="<% = hid %>" /><% = WeekdayName(Weekday(gameDate), true) %></td>
<%				else %>
				<td><input type="hidden" name="id-<% = n %>" value="<% = gameID %>" /><% = WeekdayName(Weekday(gameDate), true) %></td>
<%				end if %>
				<td><% = FormatDate(gameDate) %></td>
				<td><% = FormatTime(gameTime) %></td>
				<td align="left"><% call DisplayTeamLogo(vid) %><% = visitor %></td>
				<td><input type="text" name="vscore-<% = n %>" value="<% = vscore %>" size="2" class="<% = StyleFormField("numeric", "vscore-" & n) %>" /></td>
<%			if USE_POINT_SPREADS then %>
				<td><% = FormatPointSpread(spread) %></td>
<%			end if %>
				<td>at</td>
				<td align="left"><% call DisplayTeamLogo(hid) %><% = home %></td>
				<td><input type="text" name="hscore-<% = n %>" value="<% = hscore %>" size="2" class="<% = StyleFormField("numeric", "hscore-" & n) %>" /></td>
				<td><label for="ot-<% = n %>"><span class="small">OT</span></label> <span class="fieldWrapper"><input type="checkbox" id="ot-<% = n %>" name="ot-<% = n %>" value="true"<% = checkedStr %> /></span></td>
			</tr>
<%			rs.MoveNext
			n = n + 1
		loop
		if SERVER_EMAIL_ENABLED then %>
			<tr class="subHeader topEdge">
				<th align="left" colspan="<% = cols %>"><input type="checkbox" id="notify" name="notify" value="true" /> <label for="notify">Send update notification to users.</label></th>
			</tr>
<%		end if %>
		</table>
<%		'List open dates.
		call DisplayOpenDates(week)
	end if

	if ENABLE_SCORES_ADDON then

		'If this was an auto-update post, turn the option on again but only if
		'there are still scores to get.
		autoUpdate = FormFieldExists("autoUpdate")
		if IsCancelRequest() or not missingScores then
			autoUpdate = false
		end if %>
		<p></p>
		<table border="0" cellpadding="0" cellspacing="0" style="width: 100%;">
			<tr valign="middle">
				<td style="padding: 0px;"><input type="submit" id="updateButton" name="submit" value="Update" class="button" />&nbsp;<input type="submit" name="submit" value="Cancel" class="button" /></td>
				<td align="right" style="padding: 0px;"><input type="checkbox" id="autoUpdate" name="autoUpdate" value="true"<% if autoUpdate then Response.Write(" checked=""checked""") end if %> onclick="return scoresLoader.toggleAutoUpdate();" /> <label for="autoUpdate">Auto-update</label>&nbsp;</td>
				<td align="right" style="padding: 0px;"><input type="submit" name="submit" value="Load" class="button" onclick="return scoresLoader.load(<% = week %>);" /></td>
			</tr>
		</table>
<%	else %>
		<p><input type="submit" name="submit" value="Update" class="button" />&nbsp;<input type="submit" name="submit" value="Cancel" class="button" /></p>
<%	end if %>
		</td></tr></table>
	</form>
<%	'List links to view other weeks.
	call DisplayGoToNavigation("week", GetWeekCount(), "") %>
	</td></tr></table>
	</div>
<!-- #include file="includes/footer.asp" -->
<%	if ENABLE_SCORES_ADDON then %>
	<div id="loadingDisplay" style="visibility: hidden;">
 		<div id="loadingDialog">
			<div id="loadingActive">
				<h2><em>Loading...</em></h2>
				<form action="#" method="post" onsubmit="return false;">
					<p><img src="graphics/loading.gif" alt="" /></p>
					<p><input type="submit" name="submit" value="Cancel" class="button" onclick="return scoresLoader.cancel();" /></p>
				</form>
			</div>
			<div id="loadingComplete">
				<h2>Load Complete</h2>
				<form action="#" method="post" onsubmit="return false;">
					<div class="successMsg"><div><span id="loadingResultMsg"></span></div></div>
					<p><input type="submit" name="submit" value="Close" class="button" onclick="return scoresLoader.close();" /></p>
				</form>
			</div>
			<div id="loadingError">
				<h2>Load Failed</h2>
				<form action="#" method="post" onsubmit="return false;">
					<div class="errorMsg"><div><span id="loadingErrorMsg"></span></div></div>
					<p><input type="submit" name="submit" value="Close" class="button" onclick="return scoresLoader.close();" /></p>
				</form>
			</div>
		</div>
	</div>
<%	end if %>
</body>
</html>
<%	'**************************************************************************
	'* Local functions and subroutines.                                       *
	'**************************************************************************

	'--------------------------------------------------------------------------
	' Sends an email notification to any users who have elected to receive
	' them.
	'--------------------------------------------------------------------------
	sub SendNotifications()

		dim subj, body
		dim rs
		dim vscore, hscore
		dim list, email

		subj = "Football Pool Game Results Notification"
		body = "Games results for Week " & week & " have been updated." & vbCrLf & vbCrLf

		'Show results.
		set rs = GetGamesRecordset(week)
		do while not rs.EOF
			vscore = ""
			hscore = ""
			if not IsNull(rs.Fields("Result").Value) then
				vscore = " " & rs.Fields("VisitorScore").Value
				hscore = " " & rs.Fields("HomeScore").Value
			end if
			body = body & rs.Fields("VisitorID").Value & vscore
			if USE_POINT_SPREADS then
				body = body & " (" & GetPlainTextPointSpread(rs.Fields("PointSpread").Value) & ")"
			end if
			body = body & " at " & rs.Fields("HomeID").Value & hscore
			if rs.Fields("OT").Value then
				body = body & " OT"
			end if
			body = body & vbCrLf
			rs.moveNext
		loop

		list = GetNotificationList("NotifyOfResultUpdates")
		for each email in list
			call SendMail(email, subj, body)
		next

	end sub %>
User avatar
philwojo
Posts: 143
Joined: Mon Aug 26, 2013 4:22 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by philwojo »

Here is your problem, with a quick glance that is:

Code: Select all

     var scoresUrlBase        = "http://www.nfl.com/scores/2013/REG";
That should be 2014, not 2013.

Edit that, and save it on your server, and then try it, should work then.

Easier yet, download the new 2014 package, and upload just this file from that package to your web-site, it will contain all the fixes.

Phil
mspslb
Posts: 17
Joined: Thu Sep 04, 2014 6:50 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by mspslb »

FYI - I had tons of trouble getting this to work as well. Manually making the changes - didn't matter what browser I used, what device etc. Long story short, yesterday I did get it working by downloading the latest copy of the pool software and pulling out that one file as Phil suggested. However, I still just get the "loading" screen in IE on my PC. However, it works on the same PC with Chrome and now works from my phone and iPad with Chrome and Safari. This particular machine still has Vista so just at IE9. Haven't found the issue, but if still having the problem a quick fix for you to try may be to download Chrome if you don't have it installed and see if it works there.
User avatar
philwojo
Posts: 143
Joined: Mon Aug 26, 2013 4:22 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by philwojo »

Try clearing your IE cache files, it is probably using the old file still even though the new one is on the server, at least that is what it sounds like to me.
jasonlnlv
Posts: 16
Joined: Thu Sep 04, 2014 2:19 am

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by jasonlnlv »

I have now re-downloaded the entire package tonight from the brainjar.com website and extracted the singe file updateScores.asp and updated it on the server - and I still get the 'Loading ......' window with no score update and the BAL/PIT game tonight did not go into OT so Im not sure why this is going on. Any Ideals?
User avatar
philwojo
Posts: 143
Joined: Mon Aug 26, 2013 4:22 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by philwojo »

Did you check to make sure that it is pointing to the 2014 site and not 2013?

Can you post the code from the file on your site, not what is on your local PC?
keeper
Posts: 1
Joined: Sun Oct 12, 2014 6:39 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by keeper »

The updates are still not working on any browser I have access to on a Mac. Everything stays on the "Loading" spinner and never completes. Any ideas? I've reloaded all the files from a fresh download and still no luck.
User avatar
philwojo
Posts: 143
Joined: Mon Aug 26, 2013 4:22 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by philwojo »

Are you sure the file on the site has the updates? Can you confirm it by looking at the ffile directly from the server in an editor.
User avatar
Stutgrtguy
Posts: 167
Joined: Sun Oct 20, 2013 3:54 pm
Location: Colorado

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by Stutgrtguy »

I know this is a hair early, but I cant remember if we had to modify the line "www.nfl.com/scores/2014/REG" in the updatescores.asp page to reflect the playoffs. Im guessin "www.nfl.com/scores/2015/POST"...?

I just cant recall from year to year, and ive searched all of the update score posts. Someday Im gonna write all of the year to year, regular and post season stuff down :)

Any ideas? If not I guess we'll find out next week.

Hope ya'll had a great year!
User avatar
philwojo
Posts: 143
Joined: Mon Aug 26, 2013 4:22 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by philwojo »

I'd love to help but I don't do the post season stuff, so I can't say, sorry, but if you figure it out let us know by posting here.

Phil
holgar
Posts: 32
Joined: Fri Aug 22, 2014 5:30 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by holgar »

Is this only change to make this work again this year:

Code: Select all

  var scoresUrlBase        = "http://www.nfl.com/scores/2014/REG"
to

Code: Select all

  var scoresUrlBase        = "http://www.nfl.com/scores/2015/REG"
User avatar
philwojo
Posts: 143
Joined: Mon Aug 26, 2013 4:22 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by philwojo »

Yep, that should be all you have to change.

Phil
holgar
Posts: 32
Joined: Fri Aug 22, 2014 5:30 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by holgar »

Silly question... but I've only finally got the auto-update to work.

Is the process to use it-
-go to enter game scores page
-check auto-update
-press load (at which point the games are updated)
-press 'Update' [unsure if this step is needed]

Is there a way to default this to ON so that I never have to log in? May put the auto-update/load job on a schedule somehow?
User avatar
philwojo
Posts: 143
Joined: Mon Aug 26, 2013 4:22 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by philwojo »

No, the process is just to click the "auto update" button and then everything else happens on its own. You just need to leave the web page up for it to function.

You do not have to hit load or update at all if you are using auto-update.

I don't about setting it to be on by default. I just looked at the code pretty quickly and without digging in to it a lot more I don't see a quick way. There are some checks going on that turn the auto-update off if all games are completed so that is affecting if it can be left to ON all the time or not.

Even if it is set to being checked (on) you would still need the web page up for it to function though, at least as it is currently written, and rewriting it to be called on a time schedule is way beyond me.

Phil
holgar
Posts: 32
Joined: Fri Aug 22, 2014 5:30 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by holgar »

I have an always on server at home for Plex media anyway... I could just open the web page on there and leave it open! Hopefully that'll work.

As always, thanks for the help Phil.

Go Bears.
User avatar
philwojo
Posts: 143
Joined: Mon Aug 26, 2013 4:22 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by philwojo »

I always leave my PC on at home, so this isn't an issue for me. You could also try it on a phone and put it in the mobile browser and then just shrink that down on the phone and see if it runs in the background, not sure how that would go.

Phil
User avatar
raider_nation
Posts: 34
Joined: Mon Aug 26, 2013 8:10 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by raider_nation »

Here is something more silly. I don't have the Auto Update check box on my updatescores page. It's early and I am not awake yet. But if someone can point me on how to enable it, that would be great.
User avatar
raider_nation
Posts: 34
Joined: Mon Aug 26, 2013 8:10 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by raider_nation »

Disregard last post. I didn't have the Enable_Scores_Addon set to true in the config page. duh
DesertDog
Posts: 10
Joined: Sat Aug 31, 2013 2:56 pm

Re: Updated Code fix for the AutoUpdate (Scoring) Feature

Post by DesertDog »

Is it just me or is this feature broken again?
Post Reply