/* SoundManager 2 - project home utility JS */ (function() { 'use strict'; /* global window, document, navigator, soundManager */ var IS_CHRISTMAS = (document.domain.match(/schillmania.com/i) && new Date().getMonth() === 11) || window.location.toString().match(/christmas/i); var utils; function _id(sID) { return document.getElementById(sID); } function init() { var i; var o; var el; o = document.getElementById('main'); el = o.getElementsByTagName('dt'); for (i = el.length; i--;) { if ((i + 1) % 2 === 0) { utils.addClass(el[i], 'alt'); } } el = o.getElementsByTagName('dl'); for (i = el.length; i--;) { if ((i + 1) % 2 === 0) { utils.addClass(el[i], 'alt'); } } var newCSS; if (IS_CHRISTMAS) { // overflow-x: hidden hack for homepage during christmas light season (so explosion fragments don't cause horizontal scrollbars.) newCSS = document.body.className.split(' '); newCSS.push('has-lights'); document.body.className = newCSS.join(' '); } } // so dirty. window.init = init; function Utils() { var self = this; this.hasClass = function(o, cStr) { return (typeof (o.className) !== 'undefined' ? new RegExp('(^|\\s)' + cStr + '(\\s|$)').test(o.className) : false); }; this.addClass = function(o, cStr) { if (!o || !cStr) return; // safety net if (self.hasClass(o, cStr)) return; o.className = (o.className ? o.className + ' ' : '') + cStr; }; this.removeClass = function(o, cStr) { if (!o || !cStr) return; // safety net if (!self.hasClass(o, cStr)) return; o.className = o.className.replace(new RegExp('( ' + cStr + ')|(' + cStr + ')', 'g'), ''); }; this.toggleClass = function(o, cStr) { var m = (self.hasClass(o, cStr) ? self.removeClass : self.addClass); m(o, cStr); }; this.getElementsByClassName = function(className, tagNames, oParent) { var doc = (oParent || document); var matches = []; var i, j; var nodes = []; if (typeof (tagNames) !== 'undefined' && typeof (tagNames) !== 'string') { for (i = tagNames.length; i--;) { if (!nodes || !nodes[tagNames[i]]) { nodes[tagNames[i]] = doc.getElementsByTagName(tagNames[i]); } } } else if (tagNames) { nodes = doc.getElementsByTagName(tagNames); } else { nodes = doc.all || doc.getElementsByTagName('*'); } if (typeof (tagNames) !== 'string') { for (i = tagNames.length; i--;) { for (j = nodes[tagNames[i]].length; j--;) { if (self.hasClass(nodes[tagNames[i]][j], className)) { matches[matches.length] = nodes[tagNames[i]][j]; } } } } else { for (i = 0; i < nodes.length; i++) { if (self.hasClass(nodes[i], className)) { matches[matches.length] = nodes[i]; } } } return matches; }; this.findParent = function(o) { if (!o || !o.parentNode) return false; o = o.parentNode; if (o.nodeType === 2) { while (o && o.parentNode && o.parentNode.nodeType === 2) { o = o.parentNode; } } return o; }; this.getOffY = function(o) { // http://www.xs4all.nl/~ppk/js/findpos.html var curtop = 0; if (o.offsetParent) { while (o.offsetParent) { curtop += o.offsetTop; o = o.offsetParent; } } else if (o.y) curtop += o.y; return curtop; }; this.isChildOfClass = function(oChild, oClass) { if (!oChild || !oClass) return false; while (oChild.parentNode && !self.hasClass(oChild, oClass)) { oChild = self.findParent(oChild); } return (self.hasClass(oChild, oClass)); }; this.getParentByClassName = function(oChild, sParentClassName) { if (!oChild || !sParentClassName) return false; sParentClassName = sParentClassName.toLowerCase(); while (oChild.parentNode && !self.hasClass(oChild.parentNode, sParentClassName)) { oChild = self.findParent(oChild); } return (oChild.parentNode && self.hasClass(oChild.parentNode, sParentClassName) ? oChild.parentNode : null); }; } utils = new Utils(); var lastSelected = null; function resetFilter(o) { // reset everything var oParent = null; _id('filter-box').style.display = 'none'; utils.removeClass(_id('main'), 'filtered'); var blocks = utils.getElementsByClassName('f-block', ['div', 'dl'], _id('main')); for (var i = blocks.length; i--;) { blocks[i].style.display = 'block'; oParent = utils.getParentByClassName(blocks[i], 'columnar', _id('main')); if (oParent) oParent.style.display = 'block'; } if (lastSelected) utils.removeClass(lastSelected, 'active'); if (o) lastSelected = o; return false; } // so dirty. window.resetFilter = resetFilter; function setFilter(e, sFilterPrefix) { var o = e ? e.target || e.srcElement : window.event.srcElement; utils.addClass(_id('main'), 'filtered'); var oName = o.nodeName.toLowerCase(); if (oName === 'a') { var parent = utils.findParent(o); if (parent && parent.nodeName.toLowerCase() === 'li') { // normalize to LI instead. o = parent; oName = o.nodeName.toLowerCase(); } } var sClass = ''; var blocks = utils.getElementsByClassName('f-block', ['div', 'dl'], _id('main')); var oParents = utils.getElementsByClassName('columnar', 'div', _id('main')); var oParent = null; var matchingParents = []; var i; if (oName !== 'li' || o.className === 'ignore') { return; } var isClear = (lastSelected && lastSelected === o && utils.hasClass(lastSelected, 'active')); if (oName === 'li' && isClear) { if (typeof e.preventDefault !== 'undefined') { e.preventDefault(); } resetFilter(); return; } if (oName === 'li') { // from shortcuts/filter menu var innerText = (o.getElementsByTagName('a').length ? o.getElementsByTagName('a')[0].innerHTML : o.innerHTML); // get inner text (minus link, if one is there) sClass = sFilterPrefix + innerText.substr(0, innerText.indexOf('(') !== -1 ? innerText.indexOf('(') : 999).toLowerCase().replace(/\s+/i, '-'); var last = sClass.substr(sClass.length - 1); if (last === '-' || last === ' ') { sClass = sClass.substr(0, sClass.length - 1); // IE innerHTML trailing whitespace hack (?) } for (i = blocks.length; i--;) { oParent = utils.getParentByClassName(blocks[i], 'columnar', _id('main')); if (utils.hasClass(blocks[i], sClass)) { blocks[i].style.display = 'block'; if (oParent) { matchingParents.push(oParent); } } else { blocks[i].style.display = 'none'; } } for (i = oParents.length; i--;) { oParents[i].style.display = 'none'; } for (i = matchingParents.length; i--;) { matchingParents[i].style.display = 'block'; } _id('search-results').innerHTML = '
',
items.join(''),
'
',
'',
(soundManager.html5.mp3 || soundManager.html5.mp4 ? (_hasFlash && soundManager.preferFlash ? 'Preferring flash for MP3/MP4; try preferFlash=false for HTML5-only mode.' : (soundManager.html5Only ? 'HTML5-only mode.' + (!soundManager.canPlayMIME('audio/aac') ? ' Try preferFlash=true for MP4 support as needed.' : '') : ' Some flash required; allowing HTML5 to play MP3/MP4, as supported.' + '
' + (soundManager.hasHTML5 ? 'The flash portion of ' : '') + 'SoundManager 2 was unable to start. ' + (soundManager.useHTML5Audio ? (soundManager.hasHTML5 ? '
Some HTML5 audio support is present, but flash is needed for MP3/MP4 support on this page.' : '
No HTML5 support was found, so flash is required.') : '') + '
All links to audio will degrade gracefully.
If you have a flash blocker, try allowing the SWF to run - it may be visible below.
' + (soundManager.useAltURL ? 'Viewing offline? You may need to change a Flash security setting.' : 'Other possible causes: Missing .SWF, or no Flash?') + ' Not to worry, as guided help is provided.
SoundManager 2 tried to start using HTML5 + Flash, but rebooted in HTML5-only mode as flash was blocked. Visualization demo features will not be shown in this mode. To enable flash, whitelist the blocked movie and reload this page.
' + (soundManager.useAltURL ? 'Running offline? Flash may be blocked due to security restrictions; see troubleshooting for more.' : '') + '
SoundManager 2 could not start. See below for details.
'; if (hatesFlash || soundManager.getMoviePercent()) { // movie loaded at least somewhat, so don't show flashblock things _id('flashblocker').style.display = 'none'; if (hatesFlash) { // none of that here. _id('flash-offline').style.display = 'none'; } } o.style.marginBottom = '1.5em'; o.style.display = 'block'; o2.style.display = 'inline-block'; }); } // side note: If it's not december but you want to smash things, try #christmas=1 in the homepage URL. // --------- /home JS ------------ function startStuff() { if (navigator.userAgent.match(/safari/i)) { document.getElementsByTagName('html')[0].className = 'isSafari'; } doVersion(); ie6Sucks(); fixLinks(); getLiveData(); doAltShortcuts(); soundManager.onready(function() { if (window.turntables) { // require this for links to play on the turntable UI demo. window.turntables.config.requireCSS = 'turntable-include'; } }); } if (document.addEventListener) { document.addEventListener('DOMContentLoaded', startStuff, false); } else { window.onload = startStuff; } }());