1/* 2 * RapidWeaver 3.5.0 theme functions. 3 * Script Version 2.1 4 * Updated 26 May 2006. 5 */ 6 7 8 9/* 10 * Function to generate "open in new window" link as W3C compliant 11 */ 12 13function externalLinks() { 14if (!document.getElementsByTagName) return; 15var anchors = document.getElementsByTagName("a"); 16for (var i=0; i<anchors.length; i++) { 17var anchor = anchors[i]; 18if (anchor.getAttribute("href") && 19anchor.getAttribute("rel") == "external") 20anchor.target = "_blank"; 21} 22} 23window.onload = externalLinks; 24 25 26 27 28/* 29 * Functions to generate OBJECT and EMBED tags for Flash content. 30 * Resource: http://blog.deconcept.com/swfobject/ 31 * 32 * SWFObject is (c) 2006 Geoff Stearns and is released under the MIT License: 33 * http://www.opensource.org/licenses/mit-license.php 34 */ 35 36if(typeof deconcept == "undefined") var deconcept = new Object(); 37if(typeof deconcept.util == "undefined") deconcept.util = new Object(); 38if(typeof deconcept.SWFObjectUtil == "undefined") deconcept.SWFObjectUtil = new Object(); 39deconcept.SWFObject = function(swf, id, w, h, ver, c, useExpressInstall, quality, xiRedirectUrl, redirectUrl, detectKey){ 40 if (!document.createElement || !document.getElementById) { return; } 41 this.DETECT_KEY = detectKey ? detectKey : 'detectflash'; 42 this.skipDetect = deconcept.util.getRequestParameter(this.DETECT_KEY); 43 this.params = new Object(); 44 this.variables = new Object(); 45 this.attributes = new Array(); 46 if(swf) { this.setAttribute('swf', swf); } 47 if(id) { this.setAttribute('id', id); } 48 if(w) { this.setAttribute('width', w); } 49 if(h) { this.setAttribute('height', h); } 50 if(ver) { this.setAttribute('version', new deconcept.PlayerVersion(ver.toString().split("."))); } 51 this.installedVer = deconcept.SWFObjectUtil.getPlayerVersion(this.getAttribute('version'), useExpressInstall); 52 if(c) { this.addParam('bgcolor', c); } 53 var q = quality ? quality : 'high'; 54 this.addParam('quality', q); 55 this.setAttribute('useExpressInstall', useExpressInstall); 56 this.setAttribute('doExpressInstall', false); 57 var xir = (xiRedirectUrl) ? xiRedirectUrl : window.location; 58 this.setAttribute('xiRedirectUrl', xir); 59 this.setAttribute('redirectUrl', ''); 60 if(redirectUrl) { this.setAttribute('redirectUrl', redirectUrl); } 61} 62deconcept.SWFObject.prototype = { 63 setAttribute: function(name, value){ 64 this.attributes[name] = value; 65 }, 66 getAttribute: function(name){ 67 return this.attributes[name]; 68 }, 69 addParam: function(name, value){ 70 this.params[name] = value; 71 }, 72 getParams: function(){ 73 return this.params; 74 }, 75 addVariable: function(name, value){ 76 this.variables[name] = value; 77 }, 78 getVariable: function(name){ 79 return this.variables[name]; 80 }, 81 getVariables: function(){ 82 return this.variables; 83 }, 84 getVariablePairs: function(){ 85 var variablePairs = new Array(); 86 var key; 87 var variables = this.getVariables(); 88 for(key in variables){ 89 variablePairs.push(key +"="+ variables[key]); 90 } 91 return variablePairs; 92 }, 93 getSWFHTML: function() { 94 var swfNode = ""; 95 if (navigator.plugins && navigator.mimeTypes && navigator.mimeTypes.length) { // netscape plugin architecture 96 if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "PlugIn"); 97 swfNode = '<embed type="application/x-shockwave-flash" src="'+ this.getAttribute('swf') +'" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'"'; 98 swfNode += ' id="'+ this.getAttribute('id') +'" name="'+ this.getAttribute('id') +'" '; 99 var params = this.getParams(); 100 for(var key in params){ swfNode += [key] +'="'+ params[key] +'" '; } 101 var pairs = this.getVariablePairs().join("&"); 102 if (pairs.length > 0){ swfNode += 'flashvars="'+ pairs +'"'; } 103 swfNode += '/>'; 104 } else { // PC IE 105 if (this.getAttribute("doExpressInstall")) this.addVariable("MMplayerType", "ActiveX"); 106 swfNode = '<object id="'+ this.getAttribute('id') +'" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+ this.getAttribute('width') +'" height="'+ this.getAttribute('height') +'">'; 107 swfNode += '<param name="movie" value="'+ this.getAttribute('swf') +'" />'; 108 var params = this.getParams(); 109 for(var key in params) { 110 swfNode += '<param name="'+ key +'" value="'+ params[key] +'" />'; 111 } 112 var pairs = this.getVariablePairs().join("&"); 113 if(pairs.length > 0) {swfNode += '<param name="flashvars" value="'+ pairs +'" />';} 114 swfNode += "</object>"; 115 } 116 return swfNode; 117 }, 118 write: function(elementId){ 119 if(this.getAttribute('useExpressInstall')) { 120 // check to see if we need to do an express install 121 var expressInstallReqVer = new deconcept.PlayerVersion([6,0,65]); 122 if (this.installedVer.versionIsValid(expressInstallReqVer) && !this.installedVer.versionIsValid(this.getAttribute('version'))) { 123 this.setAttribute('doExpressInstall', true); 124 this.addVariable("MMredirectURL", escape(this.getAttribute('xiRedirectUrl'))); 125 document.title = document.title.slice(0, 47) + " - Flash Player Installation"; 126 this.addVariable("MMdoctitle", document.title); 127 } 128 } 129 if(this.skipDetect || this.getAttribute('doExpressInstall') || this.installedVer.versionIsValid(this.getAttribute('version'))){ 130 var n = (typeof elementId == 'string') ? document.getElementById(elementId) : elementId;
131 n.innerHTML = this.getSWFHTML(); 132 return true; 133 }else{ 134 if(this.getAttribute('redirectUrl') != "") { 135 document.location.replace(this.getAttribute('redirectUrl')); 136 } 137 } 138 return false; 139 } 140} 141 142/* ---- detection functions ---- */ 143deconcept.SWFObjectUtil.getPlayerVersion = function(reqVer, xiInstall){ 144 var PlayerVersion = new deconcept.PlayerVersion([0,0,0]); 145 if(navigator.plugins && navigator.mimeTypes.length){ 146 var x = navigator.plugins["Shockwave Flash"]; 147 if(x && x.description) { 148 PlayerVersion = new deconcept.PlayerVersion(x.description.replace(/([a-z]|[A-Z]|\s)+/, "").replace(/(\s+r|\s+b[0-9]+)/, ".").split(".")); 149 } 150 }else{ 151 try{ 152 var axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash"); 153 for (var i=3; axo!=null; i++) { 154 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."+i); 155 PlayerVersion = new deconcept.PlayerVersion([i,0,0]); 156 } 157 }catch(e){} 158 if (reqVer && PlayerVersion.major > reqVer.major) return PlayerVersion; // version is ok, skip minor detection 159 // this only does the minor rev lookup if the user's major version 160 // is not 6 or we are checking for a specific minor or revision number 161 // see http://blog.deconcept.com/2006/01/11/getvariable-setvariable-crash-internet-explorer-flash-6/ 162 if (!reqVer || ((reqVer.minor != 0 || reqVer.rev != 0) && PlayerVersion.major == reqVer.major) || PlayerVersion.major != 6 || xiInstall) { 163 try{ 164 PlayerVersion = new deconcept.PlayerVersion(axo.GetVariable("$version").split(" ")[1].split(",")); 165 }catch(e){} 166 } 167 } 168 return PlayerVersion; 169} 170deconcept.PlayerVersion = function(arrVersion){ 171 this.major = parseInt(arrVersion[0]) != null ? parseInt(arrVersion[0]) : 0; 172 this.minor = parseInt(arrVersion[1]) || 0; 173 this.rev = parseInt(arrVersion[2]) || 0; 174} 175deconcept.PlayerVersion.prototype.versionIsValid = function(fv){ 176 if(this.major < fv.major) return false; 177 if(this.major > fv.major) return true; 178 if(this.minor < fv.minor) return false; 179 if(this.minor > fv.minor) return true; 180 if(this.rev < fv.rev) return false; 181 return true; 182} 183/* ---- get value of query string param ---- */ 184deconcept.util = { 185 getRequestParameter: function(param){ 186 var q = document.location.search || document.location.hash; 187 if(q){ 188 var startIndex = q.indexOf(param +"="); 189 var endIndex = (q.indexOf("&", startIndex) > -1) ? q.indexOf("&", startIndex) : q.length; 190 if (q.length > 1 && startIndex > -1) { 191 return q.substring(q.indexOf("=", startIndex)+1, endIndex); 192 } 193 } 194 return ""; 195 } 196} 197/* fix for video streaming bug */ 198deconcept.SWFObjectUtil.cleanupSWFs = function() { 199 var objects = document.getElementsByTagName("OBJECT"); 200 for (var i=0; i < objects.length; i++) { 201 for (var x in objects[i]) { 202 if (typeof objects[i][x] == 'function') { 203 objects[i][x] = null; 204 } 205 } 206 } 207} 208if (typeof window.onunload == 'function') { 209 var oldunload = window.onunload; 210 window.onunload = function() { 211 deconcept.SWFObjectUtil.cleanupSWFs(); 212 oldunload(); 213 } 214} else { 215 window.onunload = deconcept.SWFObjectUtil.cleanupSWFs; 216} 217/* add Array.push if needed (ie5) */ 218if (Array.prototype.push == null) { Array.prototype.push = function(item) { this[this.length] = item; return this.length; }} 219 220/* add some aliases for ease of use/backwards compatibility */ 221var getQueryParamValue = deconcept.util.getRequestParameter; 222var FlashObject = deconcept.SWFObject; // for legacy support 223var SWFObject = deconcept.SWFObject; 224 225 226 227 228 229/* 230 * Functions to generate OBJECT and EMBED tags for QuickTime content. 231 * Resource: http://developer.apple.com/internet/ieembedfix.html 232 */ 233 234/************** LOCALIZABLE GLOBAL VARIABLES ****************/ 235 236var gArgCountErr = 'The "%%" function requires an even number of arguments.' 237 + '\nArguments should be in the form "atttributeName", "attributeValue", ...'; 238 239/******************** END LOCALIZABLE **********************/ 240 241var gTagAttrs = null; 242var gQTGeneratorVersion = 1.0; 243 244function AC_QuickTimeVersion() { return gQTGeneratorVersion; } 245 246function _QTComplain(callingFcnName, errMsg) 247{ 248 errMsg = errMsg.replace("%%", callingFcnName); 249 alert(errMsg); 250} 251 252function _QTAddAttribute(prefix, slotName, tagName) 253{ 254 var value; 255 256 value = gTagAttrs[prefix + slotName]; 257 if ( null == value ) 258 value = gTagAttrs[slotName]; 259 260 if ( null != value ) 261 { 262 if ( 0 == slotName.indexOf(prefix) && (null == tagName) ) 263 tagName = slotName.substring(prefix.length); 264 if ( null == tagName ) 265 tagName = slotName; 266 return tagName + '="' + value + '" '; 267 } 268 else 269 return ""; 270} 271 272function _QTAddObjectAttr(slotName, tagName) 273{ 274 // don't bother if it is only for the embed tag 275 if ( 0 == slotName.indexOf("emb#") ) 276 return ""; 277 278 if ( 0 == slotName.indexOf("obj#") && (null == tagName) ) 279 tagName = slotName.substring(4); 280 281 return _QTAddAttribute("obj#", slotName, tagName); 282} 283 284function _QTAddEmbedAttr(slotName, tagName) 285{ 286 // don't bother if it is only for the object tag 287 if ( 0 == slotName.indexOf("obj#") ) 288 return ""; 289 290 if ( 0 == slotName.indexOf("emb#") && (null == tagName) ) 291 tagName = slotName.substring(4); 292 293 return _QTAddAttribute("emb#", slotName, tagName); 294} 295 296 297function _QTAddObjectParam(slotName, generateXHTML) 298{ 299 var paramValue; 300 var paramStr = ""; 301 var endTagChar = (generateXHTML) ? ' />' : '>'; 302 303 if ( -1 == slotName.indexOf("emb#") ) 304 {
305 // look for the OBJECT-only param first. if there is none, look for a generic one 306 paramValue = gTagAttrs["obj#" + slotName]; 307 if ( null == paramValue ) 308 paramValue = gTagAttrs[slotName]; 309 310 if ( 0 == slotName.indexOf("obj#") ) 311 slotName = slotName.substring(4); 312 313 if ( null != paramValue ) 314 paramStr = ' <param name="' + slotName + '" value="' + paramValue + '"' + endTagChar + '\n'; 315 } 316 317 return paramStr; 318} 319 320function _QTDeleteTagAttrs() 321{ 322 for ( var ndx = 0; ndx < arguments.length; ndx++ ) 323 { 324 var attrName = arguments[ndx]; 325 delete gTagAttrs[attrName]; 326 delete gTagAttrs["emb#" + attrName]; 327 delete gTagAttrs["obj#" + attrName]; 328 } 329} 330 331 332 333// generate an embed and object tag, return as a string 334function _QTGenerate(callingFcnName, generateXHTML, args) 335{ 336 // is the number of optional arguments even? 337 if ( args.length < 4 || (0 != (args.length % 2)) ) 338 { 339 _QTComplain(callingFcnName, gArgCountErr); 340 return ""; 341 } 342 343 // allocate an array, fill in the required attributes with fixed place params and defaults 344 gTagAttrs = new Array(); 345 gTagAttrs["src"] = args[0]; 346 gTagAttrs["width"] = args[1]; 347 gTagAttrs["height"] = args[2]; 348 gTagAttrs["classid"] = "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"; 349 gTagAttrs["pluginspage"] = "http://www.apple.com/quicktime/download/"; 350 351 // set up codebase attribute with specified or default version before parsing args so 352 // anything passed in will override 353 var activexVers = args[3] 354 if ( (null == activexVers) || ("" == activexVers) ) 355 activexVers = "6,0,2,0"; 356 gTagAttrs["codebase"] = "http://www.apple.com/qtactivex/qtplugin.cab#version=" + activexVers; 357 358 var attrName, 359 attrValue; 360 361 // add all of the optional attributes to the array 362 for ( var ndx = 4; ndx < args.length; ndx += 2) 363 { 364 attrName = args[ndx].toLowerCase(); 365 attrValue = args[ndx + 1]; 366 367 // "name" and "id" should have the same value, the former goes in the embed and the later goes in 368 // the object. use one array slot 369 if ( "name" == attrName || "id" == attrName ) 370 gTagAttrs["name"] = attrValue; 371 372 else 373 gTagAttrs[attrName] = attrValue; 374 } 375 376 // init both tags with the required and "special" attributes 377 var objTag = '<object ' 378 + _QTAddObjectAttr("classid") 379 + _QTAddObjectAttr("width") 380 + _QTAddObjectAttr("height") 381 + _QTAddObjectAttr("codebase") 382 + _QTAddObjectAttr("name", "id") 383 + _QTAddObjectAttr("tabindex") 384 + _QTAddObjectAttr("hspace") 385 + _QTAddObjectAttr("vspace") 386 + _QTAddObjectAttr("border") 387 + _QTAddObjectAttr("align") 388 + _QTAddObjectAttr("class") 389 + _QTAddObjectAttr("title") 390 + _QTAddObjectAttr("accesskey") 391 + _QTAddObjectAttr("noexternaldata") 392 + '>\n' 393 + _QTAddObjectParam("src", generateXHTML); 394 var embedTag = ' <embed ' 395 + _QTAddEmbedAttr("src") 396 + _QTAddEmbedAttr("width") 397 + _QTAddEmbedAttr("height") 398 + _QTAddEmbedAttr("pluginspage") 399 + _QTAddEmbedAttr("name") 400 + _QTAddEmbedAttr("align") 401 + _QTAddEmbedAttr("tabindex"); 402 403 // delete the attributes/params we have already added 404 _QTDeleteTagAttrs("src","width","height","pluginspage","classid","codebase","name","tabindex", 405 "hspace","vspace","border","align","noexternaldata","class","title","accesskey"); 406 407 // and finally, add all of the remaining attributes to the embed and object 408 for ( var attrName in gTagAttrs ) 409 { 410 attrValue = gTagAttrs[attrName]; 411 if ( null != attrValue ) 412 { 413 embedTag += _QTAddEmbedAttr(attrName); 414 objTag += _QTAddObjectParam(attrName, generateXHTML); 415 } 416 } 417 418 // end both tags, we're done 419 return objTag + embedTag + '> </em' + 'bed>\n</ob' + 'ject' + '>'; 420} 421 422// return the object/embed as a string 423function QT_GenerateOBJECTText() 424{ 425 return _QTGenerate("QT_GenerateOBJECTText", false, arguments); 426} 427 428function QT_GenerateOBJECTText_XHTML() 429{ 430 return _QTGenerate("QT_GenerateOBJECTText_XHTML", true, arguments); 431} 432 433function QT_WriteOBJECT() 434{ 435 document.writeln(_QTGenerate("QT_WriteOBJECT", false, arguments)); 436} 437 438function QT_WriteOBJECT_XHTML() 439{ 440 document.writeln(_QTGenerate("QT_WriteOBJECT_XHTML", true, arguments)); 441} 442 443
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.