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