var loadCheck; if(loadCheck != 1){ if (! ("console" in window) || !("firebug" in console)) { var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"]; window.console = {}; for (var i = 0; i < names.length; ++i) window.console[names[i]] = function() {}; } var DebugMode = (window.location.search.indexOf("bug=de") == 1) ? DebugMode = true : DebugMode = false; if (DebugMode == true) {console.log("dbx service 3.1.0");} var dbxErr = ""; var Utils = { $p: null, subclass: function(sub, sup) { var X = function() {}; X.prototype = sup.prototype; sub.prototype = new X(); sub.prototype.constructor = sub; sub.superclass = sup.prototype; }, getPersonalization: function() { if (Utils.$p == null) { var pz; var c1 = readCookie("P1"); var c2 = readCookie("zip"); if (c1 == '' && c2 == '') { pz = undefined; } else { pz = { zip: null, locCode: null, quotes: null, affiliate: null, stateCode: null, leagues: null }; if (c1 != '') { var a = c1.split("|"); if (a[2] == ",") a[2] = ""; if (a[2] != '' && a[2] != undefined) { pz.locCode = a[2].substr(1); } if (a[6] != '' && a[6] != undefined) { if (a[6].indexOf(",") != -1) { pz.quotes = a[6].split(','); } else { pz.quotes = a[6]; } } if (a[5] != '' && a[5] != undefined) { pz.affiliate = a[5]; }; if (a[11] != '' && a[11] != undefined) { pz.leagues = a[11].substring(1, a[11].length - 1).split('~'); } if (a[12] != '' && a[12] != undefined) { pz.stateCode = a[12].substr(1); } } if (c2 != '') { pz.zip = c2.split("|")[0].substr(2); } } Utils.$p = pz; } else {} return Utils.$p; }, isPersonalized: function() { return (Utils.getPersonalization() != undefined); }, headTrunc: function(headline, lngth, cutWord) { if (headline.length > lngth) { chrAfter = headline.charCodeAt(lngth); headline = headline.substring(0, lngth); if (cutWord == true && chrAfter != 32) { headline = headline.replace(/\w+$/, ''); } if (!cutWord == true && chrAfter != 32) { headline = headline + "..."; } else { headline = headline + " ..."; } } return headline; }, commaCrop: function(comString) { comma = comString.indexOf(','); allcaps = comString.indexOf('TODAY'); if (comma > -1) { comString = comString.substr(0, comma); } else if (allcaps > -1) { comString = "Today"; } return comString; }, cleanDate: function(str) { str = str.replace(/-na-/g, ''); return str; }, dbx_Local: function() { var s = document.fgl.txtZip.value; s = Utils.trim(s); var re = /\d{5}/g; if (s.length == 0) { document.fgl.txtZip.value = ""; alert("Please enter a ZIP code or city name."); document.fgl.txtZip.focus(); } else if (s.length == 5 && s.match(re)) { location = "/databox/choices.aspx?tQSZip=" + s + "&return=25632630"; } else { alert(s + " did not match a major metro area. Please try your ZIP code again."); } return false; }, dbx_Change: function(s) { if (s != "0") { var l = "/id/25632630/"; return l; } return '#'; }, dbx_Remove: function(s) { if (s != "0") { var l = "/databox/choices.aspx?action=remove§ion=" + s + "&return=/"; return l; } return '#'; }, trim: function(inValue) { if (inValue) { inValue = inValue.replace(/^\s*/g, ""); inValue = inValue.replace(/\s*$/g, ""); } return inValue; } }; var DataboxService = function() {}; DataboxService.EVENT_LOAD = "onLoad"; DataboxService.DEFAULT_DB = "23283610"; DataboxService.COOKIED_DB = "23301549"; var rex = /\w+\:\/\/([^\/]+)/; var rootUri = rex.exec(window.location)[0]; DataboxService.SVC = rootUri + '/databox/data.aspx'; DataboxService.prototype = { $listeners: [], $data: null, addListener: function(c, e, b) { this.$listeners.push({ context: c, event: e, callback: b }); }, dispatchEvent: function(context, eventName, msg) { for (var i = this.$listeners.length - 1; i >= 0; i--) { if (this.$listeners[i].context == context && this.$listeners[i].event == eventName) this.$listeners[i].callback(msg); }; }, parse: function(result) { this.evaluate(result); }, evaluate: function(parsed_result) { try { this.$data = eval('(' + parsed_result + ')'); this.dispatchEvent(this, DataboxService.EVENT_LOAD, true); } catch(e) { dbxErr = "true"; if (DebugMode == true) { console.log("Databox validity error. Please send the XMLHttpRequest paths and the GET response to isiteui. Please also check IE6/7 for any JavaScript errors and send those as well. Thanks!"); } this.$data = undefined; this.dispatchEvent(this, DataboxService.EVENT_LOAD, false); } }, load: function(id, param) { var url = DataboxService.SVC + "?dbid=" + id + "&s=" + param + "&"; var request = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject("MSXML2.XMLHTTP.3.0"); var self = this; request.open("GET", url); request.onreadystatechange = function() { if (request.readyState == 4 && request.status == 200) { if (request.responseText) { self.parse(request.responseText); } } }; request.send(null); }, getData: function() { return this.$data; } }; var CookieDS = function() { arguments.callee.superclass.constructor.call(this); }; Utils.subclass(CookieDS, DataboxService); CookieDS.prototype.parse = function(result) { result = result.replace(/\n/g, ''); result = result.replace(/,"headlines"\:\[\{"foo"\:"null"\}\}/g, '}'); result = result.replace(/"leagues"\:\[\{"foo"\:"null"\}"error"\:\{"msg"\:"Score data not available"\}\]\}\]/, '"error":{"msg":"Score data not available"}'); result = result.replace(/\{"foo"\:"null"\},?/g, ''); this.evaluate(result); }; var DefaultDS = function() { arguments.callee.superclass.constructor.call(this); }; Utils.subclass(DefaultDS, DataboxService); DefaultDS.prototype.parse = function(result) { result = result.replace(/\n/g, ''); result = result.replace(/"error":\{"msg"\:"Weather data not available"\}\]\}/g, '"error":{"msg":"Weather data not available"}'); result = result.replace(/\{"foo"\:"null"\},?/g, ''); this.evaluate(result); }; var DBMgr = {}; (function() { var cookiedDB = new CookieDS(); var defDB = new DefaultDS(); var DEFAULT_ZIP = 10001; var activeDB = {}; var flavor = ''; var callbacks = []; var toLoad = 0; var loaded = 0; function init(ignore_personalization) { if (ignore_personalization) { flavor = "default"; return; } if (Utils.isPersonalized()) { flavor = "cookied";} else { flavor = "default"; } } function onLoad(e) { loaded++; if (loaded == toLoad) { notify(); } } function start() { if (flavor != "default") { cookiedDB.addListener(cookiedDB, DataboxService.EVENT_LOAD, onLoad); toLoad++; }; defDB.addListener(defDB, DataboxService.EVENT_LOAD, onLoad); toLoad++; defDB.load(DataboxService.DEFAULT_DB, DEFAULT_ZIP); if (flavor != "default") cookiedDB.load(DataboxService.COOKIED_DB, ''); } function getFlavor() { return flavor; } function subscribe(c) { callbacks.push({ callback: c }); } function notify() { for (var i = callbacks.length - 1; i >= 0; i--) { callbacks[i].callback(); } } function hasLoaded() { return (loaded == toLoad); } DBMgr.hasLoaded = hasLoaded; DBMgr.subscribe = subscribe; DBMgr.getFlavor = getFlavor; DBMgr.start = start; DBMgr.init = init; DBMgr.cookied = cookiedDB; DBMgr.def = defDB; })(); loadCheck = 1; }