| 1 |
// NOTE you have to configure this! |
| 2 |
var _pEXTERNAL_ASSETS = "/external_assets"; |
| 3 |
|
| 4 |
document.writeln("<script src='" + _pEXTERNAL_ASSETS + "/javascript/appConfig.js'><\/script>"); |
| 5 |
|
| 6 |
// NOTE this is a global hack to get the zap viewers to work |
| 7 |
document.writeln("<style>.simstripCont{white-space:nowrap}</style>"); |
| 8 |
|
| 9 |
/** |
| 10 |
* Protect window.console method calls, e.g. console is not defined on IE8, IE9 |
| 11 |
* unless dev tools are open, and IE doesn't define console.debug |
| 12 |
* If 'console' is undefined, then it is defined and all possible console.* functions are defined, |
| 13 |
* but operationally do nothing. This prevents javascript exceptions in IE8, IE9. |
| 14 |
* Adapted from https://stackoverflow.com/questions/3326650/console-is-undefined-error-for-internet-explorer |
| 15 |
*/ |
| 16 |
(function () { |
| 17 |
if (!window.console) { |
| 18 |
window.console = {}; |
| 19 |
} |
| 20 |
// union of Chrome, FF, IE, and Safari console methods |
| 21 |
var m = [ |
| 22 |
'assert', 'clear', 'count', 'debug', 'dir', 'dirxml', 'error', |
| 23 |
'exception', 'group', 'groupCollapsed', 'groupEnd', 'info', 'log', |
| 24 |
'markTimeline', 'profile', 'profileEnd', 'table', 'time', 'timeEnd', |
| 25 |
'timeStamp', 'trace', 'warn' |
| 26 |
]; |
| 27 |
// define undefined methods as noops to prevent errors |
| 28 |
for (var i = 0; i < m.length; i++) { |
| 29 |
if (!window.console[m[i]]) { |
| 30 |
window.console[m[i]] = function () { |
| 31 |
}; |
| 32 |
} |
| 33 |
} |
| 34 |
})(); |
| 35 |
|
| 36 |
//v1.7 |
| 37 |
// Flash Player Version Detection |
| 38 |
// Detect Client Browser type |
| 39 |
// Copyright 2005-2007 Adobe Systems Incorporated. All rights reserved. |
| 40 |
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; |
| 41 |
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; |
| 42 |
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; |
| 43 |
|
| 44 |
function ControlVersion() { |
| 45 |
var version; |
| 46 |
var axo; |
| 47 |
var e; |
| 48 |
|
| 49 |
// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry |
| 50 |
|
| 51 |
try { |
| 52 |
// version will be set for 7.X or greater players |
| 53 |
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7"); |
| 54 |
version = axo.GetVariable("$version"); |
| 55 |
} catch (e) { |
| 56 |
} |
| 57 |
|
| 58 |
if (!version) { |
| 59 |
try { |
| 60 |
// version will be set for 6.X players only |
| 61 |
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6"); |
| 62 |
|
| 63 |
// installed player is some revision of 6.0 |
| 64 |
// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29, |
| 65 |
// so we have to be careful. |
| 66 |
|
| 67 |
// default to the first public version |
| 68 |
version = "WIN 6,0,21,0"; |
| 69 |
|
| 70 |
// throws if AllowScripAccess does not exist (introduced in 6.0r47) |
| 71 |
axo.AllowScriptAccess = "always"; |
| 72 |
|
| 73 |
// safe to call for 6.0r47 or greater |
| 74 |
version = axo.GetVariable("$version"); |
| 75 |
|
| 76 |
} catch (e) { |
| 77 |
} |
| 78 |
} |
| 79 |
|
| 80 |
if (!version) { |
| 81 |
try { |
| 82 |
// version will be set for 4.X or 5.X player |
| 83 |
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); |
| 84 |
version = axo.GetVariable("$version"); |
| 85 |
} catch (e) { |
| 86 |
} |
| 87 |
} |
| 88 |
|
| 89 |
if (!version) { |
| 90 |
try { |
| 91 |
// version will be set for 3.X player |
| 92 |
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3"); |
| 93 |
version = "WIN 3,0,18,0"; |
| 94 |
} catch (e) { |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
if (!version) { |
| 99 |
try { |
| 100 |
// version will be set for 2.X player |
| 101 |
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); |
| 102 |
version = "WIN 2,0,0,11"; |
| 103 |
} catch (e) { |
| 104 |
version = -1; |
| 105 |
} |
| 106 |
} |
| 107 |
|
| 108 |
return version; |
| 109 |
} |
| 110 |
|
| 111 |
// JavaScript helper required to detect Flash Player PlugIn version information |
| 112 |
function GetSwfVer() { |
| 113 |
// NS/Opera version >= 3 check for Flash plugin in plugin array |
| 114 |
var flashVer = -1; |
| 115 |
|
| 116 |
if (navigator.plugins != null && navigator.plugins.length > 0) { |
| 117 |
if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { |
| 118 |
var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; |
| 119 |
var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; |
| 120 |
var descArray = flashDescription.split(" "); |
| 121 |
var tempArrayMajor = descArray[2].split("."); |
| 122 |
var versionMajor = tempArrayMajor[0]; |
| 123 |
var versionMinor = tempArrayMajor[1]; |
| 124 |
var versionRevision = descArray[3]; |
| 125 |
if (versionRevision == "") { |
| 126 |
versionRevision = descArray[4]; |
| 127 |
} |
| 128 |
if (versionRevision[0] == "d") { |
| 129 |
versionRevision = versionRevision.substring(1); |
| 130 |
} else if (versionRevision[0] == "r") { |
| 131 |
versionRevision = versionRevision.substring(1); |
| 132 |
if (versionRevision.indexOf("d") > 0) { |
| 133 |
versionRevision = versionRevision.substring(0, versionRevision.indexOf("d")); |
| 134 |
} |
| 135 |
} |
| 136 |
var flashVer = versionMajor + "." + versionMinor + "." + versionRevision; |
| 137 |
} |
| 138 |
} |
| 139 |
// MSN/WebTV 2.6 supports Flash 4 |
| 140 |
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4; |
| 141 |
// WebTV 2.5 supports Flash 3 |
| 142 |
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3; |
| 143 |
// older WebTV supports Flash 2 |
| 144 |
else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2; |
| 145 |
else if (isIE && isWin && !isOpera) { |
| 146 |
flashVer = ControlVersion(); |
| 147 |
} |
| 148 |
return flashVer; |
| 149 |
} |
| 150 |
|
| 151 |
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available |
| 152 |
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision) { |
| 153 |
var versionArray; |
| 154 |
var versionStr = GetSwfVer(); |
| 155 |
if (versionStr == -1) { |
| 156 |
return false; |
| 157 |
} else if (versionStr != 0) { |
| 158 |
if (isIE && isWin && !isOpera) { |
| 159 |
// Given "WIN 2,0,0,11" |
| 160 |
var tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"] |
| 161 |
var tempString = tempArray[1]; // "2,0,0,11" |
| 162 |
versionArray = tempString.split(","); // ['2', '0', '0', '11'] |
| 163 |
} else { |
| 164 |
versionArray = versionStr.split("."); |
| 165 |
} |
| 166 |
var versionMajor = versionArray[0]; |
| 167 |
var versionMinor = versionArray[1]; |
| 168 |
var versionRevision = versionArray[2]; |
| 169 |
|
| 170 |
// is the major.revision >= requested major.revision AND the minor version >= requested minor |
| 171 |
if (versionMajor > parseFloat(reqMajorVer)) { |
| 172 |
return true; |
| 173 |
} else if (versionMajor == parseFloat(reqMajorVer)) { |
| 174 |
if (versionMinor > parseFloat(reqMinorVer)) |
| 175 |
return true; |
| 176 |
else if (versionMinor == parseFloat(reqMinorVer)) { |
| 177 |
if (versionRevision >= parseFloat(reqRevision)) |
| 178 |
return true; |
| 179 |
} |
| 180 |
} |
| 181 |
return false; |
| 182 |
} |
| 183 |
} |
| 184 |
// END Flash Player Version Detection |
| 185 |
///////////////////////////////////// |
| 186 |
|
| 187 |
var _pBrowserSupport = { |
| 188 |
|
| 189 |
// initialize with an object containing keys & values for browser names & versions as in: |
| 190 |
// {webkit:'531.0', msie:'8.0', mozilla:'1.9.2'} |
| 191 |
// |
| 192 |
// this.supported means the current browser has version >= the minumum_list, |
| 193 |
// this.not_supported means the current browser is in the minumum_list and |
| 194 |
// has vesion less than that given. |
| 195 |
// |
| 196 |
// NOTE that both supported & not_supported may legitimately be false, if the |
| 197 |
// current browser is not in the list. |
| 198 |
initialize: function (minimum_list) { |
| 199 |
|
| 200 |
var userAgent = navigator.userAgent.toLowerCase(); |
| 201 |
this.minimum_list = minimum_list ? minimum_list : {}; |
| 202 |
|
| 203 |
this.version = (userAgent.match(/.+(?:rv|it|ra|ie|me)[\/: ]([\d.]+)/) || [])[1]; |
| 204 |
|
| 205 |
this.webkit = /webkit/.test(userAgent); |
| 206 |
this.opera = /opera/.test(userAgent); |
| 207 |
this.msie = /msie|trident/.test(userAgent) && !/opera/.test(userAgent); // only IE uses trident rendering engine |
| 208 |
this.mozilla = /mozilla/.test(userAgent) && !/(trident|compatible|webkit)/.test(userAgent); |
| 209 |
this.chrome = /chrome/.test(userAgent); |
| 210 |
|
| 211 |
this.ie_compat_version = this.version; // is this used?? |
| 212 |
|
| 213 |
// Note: IE browser version is based on the Trident rendering engine version number, which is used on post IE7 browsers |
| 214 |
// Trident info: https://en.wikipedia.org/wiki/Trident_(layout_engine) |
| 215 |
if (this.msie) { |
| 216 |
var calcVersion = this._browserVersionFromTrident(userAgent); |
| 217 |
this.version = calcVersion ? calcVersion : this.version; |
| 218 |
} |
| 219 |
|
| 220 |
this.extended_version = this._version_to_number(this.version); |
| 221 |
|
| 222 |
this.name = this.chrome ? 'chrome' : this.webkit ? 'webkit' : this.opera ? 'opera' : this.msie ? 'msie' : this.mozilla ? 'mozilla' : 'unknown'; |
| 223 |
this.supported = this._is_supported(this.minimum_list); |
| 224 |
this.not_supported = this._is_not_supported(this.minimum_list); |
| 225 |
}, |
| 226 |
|
| 227 |
/** |
| 228 |
* Determine IE browser version based on Trident rendering engine version. |
| 229 |
* This is effective beginning with IE8, Trident4 |
| 230 |
* |
| 231 |
* For IE8, Trident4, the versions of both browser and trident have incremented by one each all the way |
| 232 |
* up to and including IE11, Trident7 |
| 233 |
* We will use this algorithm until it fails someday in the future, at which point the business logic |
| 234 |
* can be adjusted. |
| 235 |
* |
| 236 |
* @param {string} userAgent downcased version of the user agent string |
| 237 |
* @returns {string} [version number].0, or undefined if trident number is too low |
| 238 |
*/ |
| 239 |
_browserVersionFromTrident: function (userAgent) { |
| 240 |
var ieStart = 8; |
| 241 |
var tridentStart = 4; |
| 242 |
var ieVersion; |
| 243 |
|
| 244 |
var tridentMatch = userAgent.match(/trident\/(\d+)/); |
| 245 |
if (tridentMatch) { |
| 246 |
var tridentNum = parseInt(tridentMatch[1]); |
| 247 |
if (tridentNum >= tridentStart) { |
| 248 |
var delta = tridentNum - tridentStart; |
| 249 |
ieVersion = (ieStart + delta) + ".0"; |
| 250 |
} |
| 251 |
} |
| 252 |
|
| 253 |
return ieVersion; |
| 254 |
}, |
| 255 |
|
| 256 |
_is_not_supported: function (list) { |
| 257 |
|
| 258 |
for (var key in list) { |
| 259 |
if (key == this.name) { |
| 260 |
var supported_version = this._version_to_number(list[key]); |
| 261 |
|
| 262 |
if (supported_version.major > this.extended_version.major) |
| 263 |
return (true); |
| 264 |
|
| 265 |
if ((supported_version.major == this.extended_version.major) |
| 266 |
&& |
| 267 |
(supported_version.minor > this.extended_version.minor)) |
| 268 |
return (true); |
| 269 |
|
| 270 |
if ((supported_version.major == this.extended_version.major) |
| 271 |
&& |
| 272 |
(supported_version.minor == this.extended_version.minor) |
| 273 |
&& |
| 274 |
(supported_version.build > this.extended_version.build)) |
| 275 |
return (true); |
| 276 |
} |
| 277 |
} |
| 278 |
return (false); |
| 279 |
}, |
| 280 |
|
| 281 |
_is_supported: function (list) { |
| 282 |
for (var key in list) { |
| 283 |
if (key == this.name) { |
| 284 |
var supported_version = this._version_to_number(list[key]); |
| 285 |
|
| 286 |
if ((supported_version.major == this.extended_version.major) |
| 287 |
&& |
| 288 |
(supported_version.minor == this.extended_version.minor) |
| 289 |
&& |
| 290 |
(supported_version.build <= this.extended_version.build)) |
| 291 |
return (true); |
| 292 |
|
| 293 |
if ((supported_version.major == this.extended_version.major) |
| 294 |
&& |
| 295 |
(supported_version.minor <= this.extended_version.minor)) |
| 296 |
return (true); |
| 297 |
|
| 298 |
if (supported_version.major <= this.extended_version.major) |
| 299 |
return (true); |
| 300 |
} |
| 301 |
} |
| 302 |
return (false); |
| 303 |
}, |
| 304 |
|
| 305 |
_version_to_number: function (version) { |
| 306 |
|
| 307 |
var version_components = version ? version.split('.') : [0]; |
| 308 |
var ret = {}; |
| 309 |
|
| 310 |
ret.major = parseInt(version_components[0]); |
| 311 |
ret.minor = version_components.length > 1 ? parseInt(version_components[1]) : 0; |
| 312 |
ret.build = version_components.length > 2 ? parseInt(version_components[2]) : 0; |
| 313 |
return (ret); |
| 314 |
}, |
| 315 |
|
| 316 |
_cookie_check: function () { |
| 317 |
|
| 318 |
var tmpcookie = new Date(); |
| 319 |
var chkcookie = (tmpcookie.getTime() + ''); |
| 320 |
document.cookie = "chkcookie=" + chkcookie + "; path=/"; |
| 321 |
if (document.cookie.indexOf(chkcookie, 0) < 0) |
| 322 |
return (false); |
| 323 |
|
| 324 |
return (true); |
| 325 |
}, |
| 326 |
|
| 327 |
_flash_check: function () { |
| 328 |
|
| 329 |
if (!flashVersion || !flashVersion.length >= 3) |
| 330 |
return (false); |
| 331 |
|
| 332 |
if (!DetectFlashVer) |
| 333 |
return (false); |
| 334 |
|
| 335 |
return (DetectFlashVer(flashVersion[0], flashVersion[1], flashVersion[2])); |
| 336 |
}, |
| 337 |
|
| 338 |
_flash_version: function () { |
| 339 |
|
| 340 |
if (!GetSwfVer) |
| 341 |
return ('unknown'); |
| 342 |
|
| 343 |
return (GetSwfVer()); |
| 344 |
} |
| 345 |
|
| 346 |
}; |
| 347 |
|
| 348 |
|
| 349 |
function _pSiteWarning() { |
| 350 |
|
| 351 |
this.warn_box_zindex = 100000; // make sure above SIV, Dual Viewer SIV |
| 352 |
this.warn_box = null; |
| 353 |
this.warn_content = ''; |
| 354 |
this.warning_present = false; |
| 355 |
|
| 356 |
this.show_stats = function () { |
| 357 |
|
| 358 |
var msg = "Browser name: " + _pBrowserSupport.name; |
| 359 |
msg += "<br/>Version: " + _pBrowserSupport.version; |
| 360 |
msg += "<br/>IE compat version: " + _pBrowserSupport.ie_compat_version; |
| 361 |
add_warning(msg); |
| 362 |
} |
| 363 |
|
| 364 |
// called by atlasviewer |
| 365 |
this.show_flash_warning = function () { |
| 366 |
if (!_pBrowserSupport.supported_flash) { |
| 367 |
|
| 368 |
var flash_ver = flashVersion ? 'Flash version ' + flashVersion.join('.') + ' or higher' : 'A more recent version of Flash'; |
| 369 |
var warn_list = document.getElementById('_pWarnList'); |
| 370 |
|
| 371 |
if (warn_list) { |
| 372 |
var li = document.createElement('li'); |
| 373 |
li.style.cssText = 'margin-left:22px;'; |
| 374 |
li.innerHTML = flash_ver + " is required."; |
| 375 |
warn_list.appendChild(li); |
| 376 |
} else { |
| 377 |
var msg = "<br/>This site requires " + flash_ver; |
| 378 |
msg += "<br/>Some content may not function properly."; |
| 379 |
add_warning(msg); |
| 380 |
} |
| 381 |
} |
| 382 |
} |
| 383 |
|
| 384 |
var _self = this; |
| 385 |
|
| 386 |
function create_warning_box() { |
| 387 |
|
| 388 |
_self.warn_box = document.createElement('div'); |
| 389 |
_self.warn_box.setAttribute('id', 'version_warning_container'); |
| 390 |
_self.warn_box.style.cssText = 'width:480px; height:74px; border:1px solid #f00; position:absolute; top:8px; left:260px;background-color:#fee;padding:6px;color:#c00' + ';z-index:' + _self.warn_box_zindex; |
| 391 |
document.body.appendChild(_self.warn_box); |
| 392 |
} |
| 393 |
|
| 394 |
function add_warning(msg) { |
| 395 |
|
| 396 |
if (!_self.warn_box) |
| 397 |
create_warning_box(); |
| 398 |
|
| 399 |
// warn some other way? |
| 400 |
if (!_self.warn_box) |
| 401 |
return; |
| 402 |
|
| 403 |
_self.warn_content += msg; |
| 404 |
_self.warn_box.innerHTML = _self.warn_content; |
| 405 |
} |
| 406 |
|
| 407 |
function show_warning(browser_info) { |
| 408 |
|
| 409 |
var msg = "Your web browser does not meet one or more of the system requirements for this site:<ul id='_pWarnList' style='padding:0px; margin:0px;'>"; |
| 410 |
|
| 411 |
if (!browser_info.supported) |
| 412 |
msg += "<li style='margin-left:22px;'>Your browser version is not supported.</li>"; |
| 413 |
msg += "</ul>"; |
| 414 |
|
| 415 |
if (!browser_info.supported) { |
| 416 |
|
| 417 |
// if the legacy warning is already present, hide it. |
| 418 |
var old_warn = document.getElementById('js_cookie_check'); |
| 419 |
if (old_warn) |
| 420 |
old_warn.style.cssText = "display:none"; |
| 421 |
|
| 422 |
msg += "<div style='margin-top:4px;'>To see the minimum requirements for this site click <a href='javascript:_pShowSysReqs();'>here</a>.</div>"; |
| 423 |
_self.warning_present = true; |
| 424 |
add_warning(msg); |
| 425 |
} |
| 426 |
} |
| 427 |
|
| 428 |
function show_flash_warning() { |
| 429 |
|
| 430 |
if (typeof _pSupressBrowserFlashWarning !== 'undefined' && _pSupressBrowserFlashWarning) |
| 431 |
return; |
| 432 |
|
| 433 |
if (!_pBrowserSupport.supported_flash) { |
| 434 |
|
| 435 |
var flash_ver = flashVersion ? 'Flash version ' + flashVersion.join('.') + ' or higher' : 'A more recent version of Flash'; |
| 436 |
var warn_list = document.getElementById('_pWarnList'); |
| 437 |
|
| 438 |
if (warn_list) { |
| 439 |
var li = document.createElement('li'); |
| 440 |
li.style.cssText = 'margin-left:22px;'; |
| 441 |
li.innerHTML = flash_ver + " is required."; |
| 442 |
warn_list.appendChild(li); |
| 443 |
} else { |
| 444 |
var msg = "<br/>This site requires " + flash_ver; |
| 445 |
msg += "<br/>Some content may not function properly."; |
| 446 |
add_warning(msg); |
| 447 |
} |
| 448 |
} |
| 449 |
} |
| 450 |
|
| 451 |
function add_warning_closer() { |
| 452 |
|
| 453 |
if (!_self.warn_box) |
| 454 |
return; |
| 455 |
|
| 456 |
var style = "width:16px; height:16px; border:0px solid #a99; position:absolute; top:3px; right:3px; cursor:pointer"; |
| 457 |
var src = _pEXTERNAL_ASSETS + "/images/close_x.png"; |
| 458 |
_self.warn_content += "<img id='version_warning_closer' src='" + src + "' style='" + style + "'/>"; |
| 459 |
_self.warn_box.innerHTML = _self.warn_content; |
| 460 |
|
| 461 |
var closer = document.getElementById('version_warning_closer'); |
| 462 |
if (closer.addEventListener) { |
| 463 |
document.getElementById('version_warning_closer').addEventListener( |
| 464 |
'click', |
| 465 |
function () { |
| 466 |
document.getElementById('version_warning_container').style.display = "none"; |
| 467 |
}, |
| 468 |
false); |
| 469 |
} else { |
| 470 |
document.getElementById('version_warning_closer').attachEvent( |
| 471 |
'onclick', |
| 472 |
function () { |
| 473 |
document.getElementById('version_warning_container').style.display = "none"; |
| 474 |
}, |
| 475 |
false); |
| 476 |
} |
| 477 |
} |
| 478 |
|
| 479 |
function init() { |
| 480 |
|
| 481 |
_pBrowserSupport.initialize(_pSUPPORTED_BROWSERS); |
| 482 |
var url = document.URL; |
| 483 |
|
| 484 |
// if (url.indexOf('show_browser_stats') >= 0) |
| 485 |
// _self.show_stats(); |
| 486 |
// else |
| 487 |
// show_warning(_pBrowserSupport); |
| 488 |
// |
| 489 |
// show_flash_warning(); |
| 490 |
// |
| 491 |
// add_warning_closer(); |
| 492 |
} |
| 493 |
|
| 494 |
init(); |
| 495 |
} |
| 496 |
|
| 497 |
var _pSiteWarnings = null; |
| 498 |
function _pShowFlashWarning() { |
| 499 |
|
| 500 |
|
| 501 |
if (!_pSiteWarnings) |
| 502 |
_pSiteWarnings = new _pSiteWarning(); |
| 503 |
|
| 504 |
if (_pSiteWarnings) |
| 505 |
_pSiteWarnings.show_flash_warning(); |
| 506 |
} |
| 507 |
|
| 508 |
function _pShowSysReqs() { |
| 509 |
|
| 510 |
var reqs_win = window.open('', '_blank', 'width=460,height=400,status=0,scrollbars=0,titlebar=0,location=0'); |
| 511 |
reqs_win.document.writeln("<script src='" + _pEXTERNAL_ASSETS + "/javascript/browserVersions.js'><\/script>"); |
| 512 |
} |
| 513 |
|
| 514 |
if (window.addEventListener) |
| 515 |
window.addEventListener('load', function () { |
| 516 |
if (!_pSiteWarnings) _pSiteWarnings = new _pSiteWarning(); |
| 517 |
}, false); |
| 518 |
else if (window.attachEvent) |
| 519 |
window.attachEvent('onload', function () { |
| 520 |
if (!_pSiteWarnings) _pSiteWarnings = new _pSiteWarning(); |
| 521 |
}); |
| 522 |
|
| 523 |
|
| 524 |
/* |
| 525 |
* JavaScript used by the ABA Portal. |
| 526 |
* |
| 527 |
* Configuration of the Portal app is done by setting values of the four arrays, |
| 528 |
* _pTabNames, _pTabLinks, _pMoreProjectsMenu, _pFooterLinks |
| 529 |
* |
| 530 |
* Note on IE browser support - needed to put in a hack in _pGetPosOffset() for IE versions > v5 |
| 531 |
* browers. May need to tweak hack for future versions of IE. |
| 532 |
*/ |
| 533 |
|
| 534 |
//******************************************** |
| 535 |
//******** define constants for site search ******** |
| 536 |
//******************************************** |
| 537 |
var _pSiteSearchUrl = "http://host/search/index.html?query="; |
| 538 |
var _pSiteSearchButton = "pSiteSearchButton"; |
| 539 |
var _pSiteSearchTextInput = "pSiteSearchTextInput"; |
| 540 |
|
| 541 |
//***************************************************************** |
| 542 |
//****** define all tab names, this determines ******** |
| 543 |
//****** what is displayed as tab text ******** |
| 544 |
//****** (index is tab CSS ID) ******** |
| 545 |
//****** Note: order of appearance of main menu items is ******** |
| 546 |
//****** determined in portalHeader.js ******** |
| 547 |
//**************************************************************** |
| 548 |
var _pTabNames = []; |
| 549 |
_pTabNames["pHome"] = "Home"; |
| 550 |
_pTabNames["pMouseBrain"] = "Mouse Brain"; |
| 551 |
_pTabNames["pDevelopingMouseBrain"] = "Developing Mouse Brain"; |
| 552 |
_pTabNames["pHuman"] = "Human Brain"; |
| 553 |
_pTabNames["pMouseConnectivity"] = "Mouse Connectivity"; |
| 554 |
_pTabNames["pMoreProjects"] = "More"; |
| 555 |
_pTabNames["pDevelopingHumanBrain"] = "Developing Human Brain"; |
| 556 |
_pTabNames["pSleep"] = "Sleep"; |
| 557 |
_pTabNames["pMouseDiversity"] = "Mouse Strains"; |
| 558 |
_pTabNames["pNonHumanPrimate"] = "Non-Human Primate"; |
| 559 |
_pTabNames["pMouseSpinalCord"] = "Mouse Spinal Cord"; |
| 560 |
_pTabNames["pGlioblastoma"] = "Glioblastoma"; |
| 561 |
_pTabNames["pCellTypes"] = "Cell Types"; |
| 562 |
|
| 563 |
_pTabNames["pAnnouncements"] = "Get Started"; |
| 564 |
_pTabNames["pTutorials"] = "Tutorials"; |
| 565 |
_pTabNames["pHighlights"] = "Data Highlights"; |
| 566 |
_pTabNames["pCaseStudies"] = "Case Study"; |
| 567 |
_pTabNames["pAPI"] = "API"; |
| 568 |
_pTabNames["pAtlas"] = "Reference Atlases"; |
| 569 |
_pTabNames["pHelp"] = "Help"; |
| 570 |
|
| 571 |
|
| 572 |
//************************************* |
| 573 |
//****** define tab link urls ******** |
| 574 |
//****** (index is tab CSS ID) ******** |
| 575 |
//************************************* |
| 576 |
var _pTabLinks = []; |
| 577 |
_pTabLinks["pHome"] = "http://www.brain-map.org/"; |
| 578 |
_pTabLinks["pMouseBrain"] = "http://mouse.brain-map.org/"; |
| 579 |
_pTabLinks["pMouseSpinalCord"] = "http://mousespinal.brain-map.org/"; |
| 580 |
_pTabLinks["pDevelopingMouseBrain"] = "http://developingmouse.brain-map.org/"; |
| 581 |
_pTabLinks["pHuman"] = "http://human.brain-map.org/"; |
| 582 |
_pTabLinks["pDevelopingHumanBrain"] = "http://www.brainspan.org/"; |
| 583 |
_pTabLinks["pMouseConnectivity"] = "http://connectivity.brain-map.org/"; |
| 584 |
_pTabLinks["pNonHumanPrimate"] = "http://www.blueprintnhpatlas.org/"; |
| 585 |
_pTabLinks["pGlioblastoma"] = "http://glioblastoma.alleninstitute.org/"; |
| 586 |
_pTabLinks["pCellTypes"] = "http://celltypes.alleninstitute.org/"; |
| 587 |
|
| 588 |
_pTabLinks["pAnnouncements"] = "http://www.brain-map.org/announcements/index.html"; |
| 589 |
_pTabLinks["pTutorials"] = "http://www.brain-map.org/tutorials/index.html"; |
| 590 |
_pTabLinks["pHighlights"] = "http://www.brain-map.org/highlights/index.html"; |
| 591 |
_pTabLinks["pCaseStudies"] = "http://casestudies.brain-map.org/ggb"; |
| 592 |
_pTabLinks["pAPI"] = "http://www.brain-map.org/api/index.html"; |
| 593 |
_pTabLinks["pAtlas"] = "http://atlas.brain-map.org"; |
| 594 |
_pTabLinks["pHelp"] = "http://help.brain-map.org"; |
| 595 |
|
| 596 |
// note: _pTabLinkTargets is a separate table because _pTabLinks values are accessed directly by some of the apps. |
| 597 |
var _pTabLinkTargets = []; |
| 598 |
_pTabLinkTargets["pHome"] = '_self'; |
| 599 |
_pTabLinkTargets["pMouseBrain"] = '_self'; |
| 600 |
_pTabLinkTargets["pMouseSpinalCord"] = '_self'; |
| 601 |
_pTabLinkTargets["pDevelopingMouseBrain"] = '_self'; |
| 602 |
_pTabLinkTargets["pHuman"] = '_self'; |
| 603 |
_pTabLinkTargets["pDevelopingHumanBrain"] = '_blank'; |
| 604 |
_pTabLinkTargets["pMouseConnectivity"] = '_self'; |
| 605 |
_pTabLinkTargets["pNonHumanPrimate"] = '_blank'; |
| 606 |
_pTabLinkTargets["pGlioblastoma"] = '_blank'; |
| 607 |
_pTabLinkTargets["pCellTypes"] = '_blank'; |
| 608 |
|
| 609 |
_pTabLinkTargets["pAnnouncements"] = '_self'; |
| 610 |
_pTabLinkTargets["pTutorials"] = '_self'; |
| 611 |
_pTabLinkTargets["pHighlights"] = '_self'; |
| 612 |
_pTabLinkTargets["pCaseStudies"] = '_blank'; |
| 613 |
_pTabLinkTargets["pAPI"] = '_self'; |
| 614 |
_pTabLinkTargets["pAtlas"] = '_blank'; |
| 615 |
_pTabLinkTargets["pHelp"] = '_self'; |
| 616 |
|
| 617 |
var _pIsTopLevelTab = { |
| 618 |
"pHome": true, |
| 619 |
"pAnnouncements": true, |
| 620 |
"pHelp": true |
| 621 |
}; |
| 622 |
|
| 623 |
//************************************************************************** |
| 624 |
//****** define the "More Projects" drop down menu items and links ******** |
| 625 |
//****** 'items' property has array of values: name, link, target ******** |
| 626 |
//****** The 'target' value is optional, can be '_blank', '_self' ******** |
| 627 |
// |
| 628 |
// Note: this hash and array are probably no longer used |
| 629 |
//************************************************************************** |
| 630 |
var _pMoreProjectsMenu = {divclass: 'pDropDownMenu', inlinestyle: '', linktarget: '_self'}; |
| 631 |
_pMoreProjectsMenu.items = [ |
| 632 |
[_pTabNames["pDevelopingHumanBrain"], _pTabLinks["pDevelopingHumanBrain"], "_blank"], |
| 633 |
[_pTabNames["pGlioblastoma"], _pTabLinks["pGlioblastoma"], "_blank"], |
| 634 |
[_pTabNames["pNonHumanPrimate"], _pTabLinks["pNonHumanPrimate"], "_blank"], |
| 635 |
[_pTabNames["pMouseSpinalCord"], _pTabLinks["pMouseSpinalCord"]], |
| 636 |
[_pTabNames["pMouseDiversity"], _pTabLinks["pMouseDiversity"]], |
| 637 |
[_pTabNames["pSleep"], _pTabLinks["pSleep"]] |
| 638 |
]; |
| 639 |
|
| 640 |
//**************************************** |
| 641 |
//****** define the header links ********* |
| 642 |
//**************************************** |
| 643 |
var _pHeaderLinks = new Object(); |
| 644 |
|
| 645 |
|
| 646 |
//**************************************** |
| 647 |
//****** define the footer links ********* |
| 648 |
//**************************************** |
| 649 |
var _pFooterLinks = []; |
| 650 |
_pFooterLinks["pPrivacyPolicy"] = "http://www.alleninstitute.org/Media/policies/privacy_policy_content.html"; |
| 651 |
_pFooterLinks["pTermsOfUse"] = "https://github.com/AllenInstitute/AllenSDK/blob/master/COPYING"; |
| 652 |
_pFooterLinks["pCitationPolicy"] = "http://www.alleninstitute.org/Media/policies/citation_policy_content.html"; |
| 653 |
_pFooterLinks["pAbout"] = "http://www.alleninstitute.org/about_us/overview.html"; |
| 654 |
_pFooterLinks["pContactUs"] = "http://www.alleninstitute.org/contact_us/index.html"; |
| 655 |
_pFooterLinks["pFooterLogo"] = "http://www.AllenInstitute.org/"; |
| 656 |
|
| 657 |
_pFooterLinks["pPublications"] = "http://alleninstitute.org/science/publications/index.html"; |
| 658 |
_pFooterLinks["pContactUs"] = "http://alleninstitute.org/contact_us/index.html"; |
| 659 |
|
| 660 |
_pFooterLinks["pFacebook"] = "http://facebook.com/AllenInstitute"; |
| 661 |
_pFooterLinks["pTwitter"] = "http://twitter.com/Allen_Institute"; |
| 662 |
_pFooterLinks["pYouTube"] = "http://www.youtube.com/AllenInstitute"; |
| 663 |
_pFooterLinks["pLinkedIn"] = "http://www.linkedin.com/company/allen-institute-for-brain-science"; |
| 664 |
|
| 665 |
|
| 666 |
/* |
| 667 |
* Checks to ensure global javascript vars _pImagePath, _pMoreProjectsId, _pTabId are defined, |
| 668 |
* then uses _pTabId to select the designated project tab. |
| 669 |
* |
| 670 |
* This function needs to be called directly from the host HTML page, in response to a JavaScript "onload" |
| 671 |
* event. |
| 672 |
* |
| 673 |
* Valid values of _pTabId are: |
| 674 |
* pHome, pMouseBrain, pMouseSpinalCord, pDevelopingMouseBrain, pHumanBrain, pMoreProjects, pSleep, etc. |
| 675 |
*/ |
| 676 |
function _pPortalOnLoad() { |
| 677 |
// ***** use javascript vars defined on main HTML page: _pTabId, _pMoreProjectsId, _pImagePath ******** |
| 678 |
// ***** Note: pImagePath must end in a "/" ******** |
| 679 |
|
| 680 |
var error; |
| 681 |
var theTab; |
| 682 |
|
| 683 |
// validate _pImagePath |
| 684 |
try { |
| 685 |
if (_pImagePath) { |
| 686 |
if (_pImagePath.charAt(_pImagePath.length - 1) != "/") { |
| 687 |
throw "noSlash"; |
| 688 |
} |
| 689 |
} |
| 690 |
else if (_pImagePath == undefined) { |
| 691 |
throw "undefined"; |
| 692 |
} |
| 693 |
else if (_pImagePath == "") { |
| 694 |
throw "emptyString"; |
| 695 |
} |
| 696 |
} |
| 697 |
catch (error) { |
| 698 |
if (error == "noSlash") { |
| 699 |
alert("Javascript var _pImagePath needs to be terminated with a '/'"); |
| 700 |
} |
| 701 |
else if (error == "emptyString") { |
| 702 |
alert("Javascript var _pImagePath is an empty String"); |
| 703 |
} |
| 704 |
else { |
| 705 |
alert("Javascript var _pImagePath is undeclared or undefined"); |
| 706 |
} |
| 707 |
return; |
| 708 |
} |
| 709 |
|
| 710 |
// validate _pMoreProjectsId |
| 711 |
try { |
| 712 |
if (_pMoreProjectsId) { |
| 713 |
// do nothing, it has a value |
| 714 |
} |
| 715 |
else if (_pMoreProjectsId == undefined) { |
| 716 |
throw "undefined"; |
| 717 |
} |
| 718 |
else if (_pMoreProjectsId == "") { |
| 719 |
throw "emptyString"; |
| 720 |
} |
| 721 |
} |
| 722 |
catch (error) { |
| 723 |
if (error == "emptyString") { |
| 724 |
alert("Javascript var _pMoreProjectsId is an empty String"); |
| 725 |
} |
| 726 |
else { |
| 727 |
alert("Javascript var _pMoreProjectsId is undeclared or undefined"); |
| 728 |
} |
| 729 |
return; |
| 730 |
} |
| 731 |
|
| 732 |
// validate _pMoreProjectsId |
| 733 |
try { |
| 734 |
if (_pTabId) { |
| 735 |
var tabName = _pTabNames[_pTabId]; |
| 736 |
theTab = _pSetSelectedTab(_pTabId, "pTabSelected", tabName); |
| 737 |
if (theTab == null) { |
| 738 |
throw "null"; |
| 739 |
} |
| 740 |
} |
| 741 |
else if (_pTabId == undefined) { |
| 742 |
throw "undefined"; |
| 743 |
} |
| 744 |
else if (_pTabId == "") { |
| 745 |
throw "emptyString"; |
| 746 |
} |
| 747 |
} |
| 748 |
catch (error) { |
| 749 |
if (error == "null") { |
| 750 |
alert("Element for menu item _pTabId = " + _pTabId + " was not found in the DOM"); |
| 751 |
} |
| 752 |
else if (error == "emptyString") { |
| 753 |
alert("Javascript var _pTabId is an empty String"); |
| 754 |
} |
| 755 |
else { |
| 756 |
alert("_pTabId is undeclared or undefined"); |
| 757 |
} |
| 758 |
return; |
| 759 |
} |
| 760 |
} |
| 761 |
|
| 762 |
|
| 763 |
/* |
| 764 |
Set the visual state of the current page's tab. |
| 765 |
NOTE that whenever we select a tab we have just loaded a new page, |
| 766 |
so I'm not worrying about UNselecting anything here. |
| 767 |
*/ |
| 768 |
function _pSetSelectedTab(tab_id) { |
| 769 |
|
| 770 |
var tab = document.getElementById(tab_id); |
| 771 |
|
| 772 |
// nav item sare being treated differently depending on whether they are |
| 773 |
// top-level tabs or flyout menu items. |
| 774 |
if (_pIsTopLevelTab[tab_id]) { |
| 775 |
|
| 776 |
// top-level tabs are simple, add the class that |
| 777 |
// (currently) just changes the color of the text. |
| 778 |
tab.parentNode.className += " portal_tab_active"; |
| 779 |
} |
| 780 |
else { |
| 781 |
|
| 782 |
// In this case we want to change the text of the menu header |
| 783 |
// to show the current selection, as well as highlight |
| 784 |
// the item that's selected in the flyout. |
| 785 |
tab.parentNode.className += " portal_menu_item_active"; |
| 786 |
var title = document.getElementById("pMenuTitle"); |
| 787 |
title.innerHTML = _pTabNames[tab_id]; |
| 788 |
title.parentNode.className += " portal_menu_active"; |
| 789 |
} |
| 790 |
|
| 791 |
return (tab); |
| 792 |
} |
| 793 |
|
| 794 |
/* turn "More Projects" triangle green on mouseover */ |
| 795 |
function _pTriangleMouseOver() { |
| 796 |
if (document.images) |
| 797 |
document._pTriangle.src = _pImagePath + "arrow_over.gif"; |
| 798 |
} |
| 799 |
|
| 800 |
/* restore "More Projects" triangle image on mouseout */ |
| 801 |
function _pTriangleMouseOut() { |
| 802 |
if (document.images) { |
| 803 |
if (_pTabId == _pMoreProjectsId) { |
| 804 |
// white triangle (tab selected) |
| 805 |
document._pTriangle.src = _pImagePath + "arrow_on.gif"; |
| 806 |
} |
| 807 |
else { |
| 808 |
// blue triangle (tab unselected) |
| 809 |
document._pTriangle.src = _pImagePath + "arrow_off.gif"; |
| 810 |
} |
| 811 |
} |
| 812 |
} |
| 813 |
|
| 814 |
/* detect Enter/Return key press in Site Search Text input widget, |
| 815 |
* then simulate a click on the Site Search button. |
| 816 |
*/ |
| 817 |
function doSiteSearchKeyPress(e) { |
| 818 |
// look for window.event in case event isn't passed in |
| 819 |
e = e || window.event; |
| 820 |
if (e.keyCode == 13) { |
| 821 |
document.getElementById(_pSiteSearchButton).click(); |
| 822 |
} |
| 823 |
} |
| 824 |
|
| 825 |
/* build Site Search URL and open page */ |
| 826 |
function doSiteSearch() { |
| 827 |
var queryString; |
| 828 |
var searchInput = document.getElementById(_pSiteSearchTextInput); |
| 829 |
//auto select the passed qc facet |
| 830 |
var auto_select_facet = "&fa=false&e_sp=t&e_ag=t&e_tr=t&e_fa=t"; |
| 831 |
|
| 832 |
if (searchInput != null) { |
| 833 |
queryString = searchInput.value; |
| 834 |
} |
| 835 |
|
| 836 |
if ((queryString != null) && (queryString.length > 0)) { |
| 837 |
location.href = _pSiteSearchUrl + encodeURIComponent(queryString) + auto_select_facet; |
| 838 |
} |
| 839 |
else { |
| 840 |
location.href = _pSiteSearchUrl + auto_select_facet; |
| 841 |
} |
| 842 |
|
| 843 |
} |