Debian Codegraph @

dojox/flash/_base.js

raw symbols SCIP
1 dojo.provide("dojox.flash._base");
2 dojo.experimental("dojox.flash");
3
4 // for dojo.window.getBox(), needed by dojox.flash.Embed.center()
5 dojo.require("dojo.window");
6
7 dojox.flash = {
8 // summary:
9 // Utilities to embed and communicate with the Flash player from Javascript
10 // description:
11 // The goal of dojox.flash is to make it easy to extend Flash's capabilities
12 // into an Ajax/DHTML environment.
13 //
14 // dojox.flash provides an easy object for interacting with the Flash plugin.
15 // This object provides methods to determine the current version of the Flash
16 // plugin (dojox.flash.info); write out the necessary markup to
17 // dynamically insert a Flash object into the page (dojox.flash.Embed; and
18 // do dynamic installation and upgrading of the current Flash plugin in
19 // use (dojox.flash.Install). If you want to call methods on the Flash object
20 // embedded into the page it is your responsibility to use Flash's ExternalInterface
21 // API and get a reference to the Flash object yourself.
22 //
23 // To use dojox.flash, you must first wait until Flash is finished loading
24 // and initializing before you attempt communication or interaction.
25 // To know when Flash is finished use dojo.connect:
26 //
27 // | dojo.connect(dojox.flash, "loaded", myInstance, "myCallback");
28 //
29 // Then, while the page is still loading provide the file name:
30 //
31 // | dojox.flash.setSwf(dojo.moduleUrl("dojox", "_storage/storage.swf"));
32 //
33 // If no SWF files are specified, then Flash is not initialized.
34 //
35 // Your Flash must use Flash's ExternalInterface to expose Flash methods and
36 // to call JavaScript.
37 //
38 // setSwf can take an optional 'visible' attribute to control whether
39 // the Flash object is visible or not on the page; the default is visible:
40 //
41 // | dojox.flash.setSwf(dojo.moduleUrl("dojox", "_storage/storage.swf"), false);
42 //
43 // Once finished, you can query Flash version information:
44 //
45 // | dojox.flash.info.version
46 //
47 // Or can communicate with Flash methods that were exposed:
48 //
49 // | var f = dojox.flash.get();
50 // | var results = f.sayHello("Some Message");
51 //
52 // Your Flash files should use DojoExternalInterface.as to register methods;
53 // this file wraps Flash's normal ExternalInterface but correct various
54 // serialization bugs that ExternalInterface has.
55 //
56 // Notes:
57 //
58 // - dojox.flash is not meant to be a generic Flash embedding
59 // mechanism; it is as generic as necessary to make Dojo Storage's
60 // Flash Storage Provider as clean and modular as possible. If you want
61 // a generic Flash embed mechanism see [SWFObject](http://blog.deconcept.com/swfobject/).
62 // - dojox.flash can currently only work with one Flash object
63 // on the page; it does not yet support multiple Flash objects on
64 // the same page.
65 // - Your code can detect whether the Flash player is installing or having
66 // its version revved in two ways. First, if dojox.flash detects that
67 // Flash installation needs to occur, it sets dojox.flash.info.installing
68 // to true. Second, you can detect if installation is necessary with the
69 // following callback:
70 //
71 // | dojo.connect(dojox.flash, "installing", myInstance, "myCallback");
72 //
73 // You can use this callback to delay further actions that might need Flash;
74 // when installation is finished the full page will be refreshed and the
75 // user will be placed back on your page with Flash installed.
76 //
77 // -------------------
78 // Todo/Known Issues
79 // -------------------
80 //
81 // - On Internet Explorer, after doing a basic install, the page is
82 // not refreshed or does not detect that Flash is now available. The way
83 // to fix this is to create a custom small Flash file that is pointed to
84 // during installation; when it is finished loading, it does a callback
85 // that says that Flash installation is complete on IE, and we can proceed
86 // to initialize the dojox.flash subsystem.
87 // - Things aren't super tested for sending complex objects to Flash
88 // methods, since Dojo Storage only needs strings.
89 //
90 // Author- Brad Neuberg, http://codinginparadise.org
91
92 ready: false,
93 url: null,
94
95 _visible: true,
96 _loadedListeners: [],
97 _installingListeners: [],
98
99 setSwf: function(/* String */ url, /* boolean? */ visible){
100 // summary:
101 // Sets the SWF files and versions we are using.
102 // url: String
103 // The URL to this Flash file.
104 // visible: boolean?
105 // Whether the Flash file is visible or not. If it is not visible we hide
106 // it off the screen. This defaults to true (i.e. the Flash file is
107 // visible).
108 this.url = url;
109
110 this._visible = true;
111 if(visible !== null && visible !== undefined){
112 this._visible = visible;
113 }
114
115 // initialize ourselves
116 this._initialize();
117 },
118
119 addLoadedListener: function(/* Function */ listener){
120 // summary:
121 // Adds a listener to know when Flash is finished loading.
122 // Useful if you don't want a dependency on dojo.event.
123 // listener: Function
124 // A function that will be called when Flash is done loading.
125
126 this._loadedListeners.push(listener);
127 },
128
129 addInstallingListener: function(/* Function */ listener){
130 // summary:
131 // Adds a listener to know if Flash is being installed.
132 // Useful if you don't want a dependency on dojo.event.
133 // listener: Function
134 // A function that will be called if Flash is being
135 // installed
136
137 this._installingListeners.push(listener);
138 },
139
140 loaded: function(){
141 // summary:
142 // Called back when the Flash subsystem is finished loading.
143 // description:
144 // A callback when the Flash subsystem is finished loading and can be
145 // worked with. To be notified when Flash is finished loading, add a
146 // loaded listener:
147 //
148 // dojox.flash.addLoadedListener(loadedListener);
149
150 dojox.flash.ready = true;
151 if(dojox.flash._loadedListeners.length){ // FIXME: redundant if? use forEach?
152 for(var i = 0;i < dojox.flash._loadedListeners.length; i++){
153 dojox.flash._loadedListeners[i].call(null);
154 }
155 }
156 },
157
158 installing: function(){
159 // summary:
160 // Called if Flash is being installed.
161 // description:
162 // A callback to know if Flash is currently being installed or
163 // having its version revved. To be notified if Flash is installing, connect
164 // your callback to this method using the following:
165 //
166 // dojo.event.connect(dojox.flash, "installing", myInstance, "myCallback");
167
168 if(dojox.flash._installingListeners.length){ // FIXME: redundant if? use forEach?
169 for(var i = 0; i < dojox.flash._installingListeners.length; i++){
170 dojox.flash._installingListeners[i].call(null);
171 }
172 }
173 },
174
175 // Initializes dojox.flash.
176 _initialize: function(){
177 //console.debug("dojox.flash._initialize");
178 // see if we need to rev or install Flash on this platform
179 var installer = new dojox.flash.Install();
180 dojox.flash.installer = installer;
181
182 if(installer.needed()){
183 installer.install();
184 }else{
185 // write the flash object into the page
186 dojox.flash.obj = new dojox.flash.Embed(this._visible);
187 dojox.flash.obj.write();
188
189 // setup the communicator
190 dojox.flash.comm = new dojox.flash.Communicator();
191 }
192 }
193 };
194
195
196 dojox.flash.Info = function(){
197 // summary:
198 // A class that helps us determine whether Flash is available.
199 // description:
200 // A class that helps us determine whether Flash is available,
201 // it's major and minor versions, and what Flash version features should
202 // be used for Flash/JavaScript communication. Parts of this code
203 // are adapted from the automatic Flash plugin detection code autogenerated
204 // by the Macromedia Flash 8 authoring environment.
205 //
206 // An instance of this class can be accessed on dojox.flash.info after
207 // the page is finished loading.
208
209 this._detectVersion();
210 };
211
212 dojox.flash.Info.prototype = {
213 // version: String
214 // The full version string, such as "8r22".
215 version: -1,
216
217 // versionMajor, versionMinor, versionRevision: String
218 // The major, minor, and revisions of the plugin. For example, if the
219 // plugin is 8r22, then the major version is 8, the minor version is 0,
220 // and the revision is 22.
221 versionMajor: -1,
222 versionMinor: -1,
223 versionRevision: -1,
224
225 // capable: Boolean
226 // Whether this platform has Flash already installed.
227 capable: false,
228
229 // installing: Boolean
230 // Set if we are in the middle of a Flash installation session.
231 installing: false,
232
233 isVersionOrAbove: function(
234 /* int */ reqMajorVer,
235 /* int */ reqMinorVer,
236 /* int */ reqVer){ /* Boolean */
237 // summary:
238 // Asserts that this environment has the given major, minor, and revision
239 // numbers for the Flash player.
240 // description:
241 // Asserts that this environment has the given major, minor, and revision
242 // numbers for the Flash player.
243 //
244 // Example- To test for Flash Player 7r14:
245 //
246 // dojox.flash.info.isVersionOrAbove(7, 0, 14)
247 // returns:
248 // Returns true if the player is equal
249 // or above the given version, false otherwise.
250
251 // make the revision a decimal (i.e. transform revision 14 into
252 // 0.14
253 reqVer = parseFloat("." + reqVer);
254
255 if(this.versionMajor >= reqMajorVer && this.versionMinor >= reqMinorVer
256 && this.versionRevision >= reqVer){
257 return true;
258 }else{
259 return false;
260 }
261 },
262
263 _detectVersion: function(){
264 var versionStr;
265
266 // loop backwards through the versions until we find the newest version
267 for(var testVersion = 25; testVersion > 0; testVersion--){
268 if(dojo.isIE){
269 var axo;
270 try{
271 if(testVersion > 6){
272 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash."
273 + testVersion);
274 }else{
275 axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
276 }
277 if(typeof axo == "object"){
278 if(testVersion == 6){
279 axo.AllowScriptAccess = "always";
280 }
281 versionStr = axo.GetVariable("$version");
282 }
283 }catch(e){
284 continue;
285 }
286 }else{
287 versionStr = this._JSFlashInfo(testVersion);
288 }
289
290 if(versionStr == -1 ){
291 this.capable = false;
292 return;
293 }else if(versionStr != 0){
294 var versionArray;
295 if(dojo.isIE){
296 var tempArray = versionStr.split(" ");
297 var tempString = tempArray[1];
298 versionArray = tempString.split(",");
299 }else{
300 versionArray = versionStr.split(".");
301 }
302
303 this.versionMajor = versionArray[0];
304 this.versionMinor = versionArray[1];
305 this.versionRevision = versionArray[2];
306
307 // 7.0r24 == 7.24
308 var versionString = this.versionMajor + "." + this.versionRevision;
309 this.version = parseFloat(versionString);
310
311 this.capable = true;
312
313 break;
314 }
315 }
316 },
317
318 // JavaScript helper required to detect Flash Player PlugIn version
319 // information. Internet Explorer uses a corresponding Visual Basic
320 // version to interact with the Flash ActiveX control.
321 _JSFlashInfo: function(testVersion){
322 // NS/Opera version >= 3 check for Flash plugin in plugin array
323 if(navigator.plugins != null && navigator.plugins.length > 0){
324 if(navigator.plugins["Shockwave Flash 2.0"] ||
325 navigator.plugins["Shockwave Flash"]){
326 var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
327 var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
328 var descArray = flashDescription.split(" ");
329 var tempArrayMajor = descArray[2].split(".");
330 var versionMajor = tempArrayMajor[0];
331 var versionMinor = tempArrayMajor[1];
332 var tempArrayMinor = (descArray[3] || descArray[4]).split("r");
333 var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0;
334 var version = versionMajor + "." + versionMinor + "." + versionRevision;
335
336 return version;
337 }
338 }
339
340 return -1;
341 }
342 };
343
344 dojox.flash.Embed = function(visible){
345 // summary:
346 // A class that is used to write out the Flash object into the page.
347 // description:
348 // Writes out the necessary tags to embed a Flash file into the page. Note that
349 // these tags are written out as the page is loaded using document.write, so
350 // you must call this class before the page has finished loading.
351
352 this._visible = visible;
353 };
354
355 dojox.flash.Embed.prototype = {
356 // width: int
357 // The width of this Flash applet. The default is the minimal width
358 // necessary to show the Flash settings dialog. Current value is
359 // 215 pixels.
360 width: 215,
361
362 // height: int
363 // The height of this Flash applet. The default is the minimal height
364 // necessary to show the Flash settings dialog. Current value is
365 // 138 pixels.
366 height: 138,
367
368 // id: String
369 // The id of the Flash object. Current value is 'flashObject'.
370 id: "flashObject",
371
372 // Controls whether this is a visible Flash applet or not.
373 _visible: true,
374
375 protocol: function(){
376 switch(window.location.protocol){
377 case "https:":
378 return "https";
379 break;
380 default:
381 return "http";
382 break;
383 }
384 },
385
386 write: function(/* Boolean? */ doExpressInstall){
387 // summary:
388 // Writes the Flash into the page.
389 // description:
390 // This must be called before the page
391 // is finished loading.
392 // doExpressInstall: Boolean
393 // Whether to write out Express Install
394 // information. Optional value; defaults to false.
395
396 // figure out the SWF file to get and how to write out the correct HTML
397 // for this Flash version
398 var objectHTML;
399 var swfloc = dojox.flash.url;
400 var swflocObject = swfloc;
401 var swflocEmbed = swfloc;
402 var dojoUrl = dojo.baseUrl;
403 var xdomainBase = document.location.protocol + '//' + document.location.host;
404 if(doExpressInstall){
405 // the location to redirect to after installing
406 var redirectURL = escape(window.location);
407 document.title = document.title.slice(0, 47) + " - Flash Player Installation";
408 var docTitle = escape(document.title);
409 swflocObject += "?MMredirectURL=" + redirectURL
410 + "&MMplayerType=ActiveX"
411 + "&MMdoctitle=" + docTitle
412 + "&baseUrl=" + escape(dojoUrl)
413 + "&xdomain=" + escape(xdomainBase);
414 swflocEmbed += "?MMredirectURL=" + redirectURL
415 + "&MMplayerType=PlugIn"
416 + "&baseUrl=" + escape(dojoUrl)
417 + "&xdomain=" + escape(xdomainBase);
418 }else{
419 // IE/Flash has an evil bug that shows up some time: if we load the
420 // Flash and it isn't in the cache, ExternalInterface works fine --
421 // however, the second time when its loaded from the cache a timing
422 // bug can keep ExternalInterface from working. The trick below
423 // simply invalidates the Flash object in the cache all the time to
424 // keep it loading fresh. -- Brad Neuberg
425 swflocObject += "?cachebust=" + new Date().getTime();
426 swflocObject += "&baseUrl=" + escape(dojoUrl);
427 swflocObject += "&xdomain=" + escape(xdomainBase);
428 }
429
430 if(swflocEmbed.indexOf("?") == -1){
431 swflocEmbed += '?baseUrl='+escape(dojoUrl);
432 }else{
433 swflocEmbed += '&baseUrl='+escape(dojoUrl);
434 }
435 swflocEmbed += '&xdomain='+escape(xdomainBase);
436
437 objectHTML =
438 '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" '
439 + 'codebase="'
440 + this.protocol()
441 + '://fpdownload.macromedia.com/pub/shockwave/cabs/flash/'
442 + 'swflash.cab#version=8,0,0,0"\n '
443 + 'width="' + this.width + '"\n '
444 + 'height="' + this.height + '"\n '
445 + 'id="' + this.id + '"\n '
446 + 'name="' + this.id + '"\n '
447 + 'align="middle">\n '
448 + '<param name="allowScriptAccess" value="always"></param>\n '
449 + '<param name="movie" value="' + swflocObject + '"></param>\n '
450 + '<param name="quality" value="high"></param>\n '
451 + '<param name="bgcolor" value="#ffffff"></param>\n '
452 + '<embed src="' + swflocEmbed + '" '
453 + 'quality="high" '
454 + 'bgcolor="#ffffff" '
455 + 'width="' + this.width + '" '
456 + 'height="' + this.height + '" '
457 + 'id="' + this.id + 'Embed' + '" '
458 + 'name="' + this.id + '" '
459 + 'swLiveConnect="true" '
460 + 'align="middle" '
461 + 'allowScriptAccess="always" '
462 + 'type="application/x-shockwave-flash" '
463 + 'pluginspage="'
464 + this.protocol()
465 +'://www.macromedia.com/go/getflashplayer" '
466 + '></embed>\n'
467 + '</object>\n';
468
469 // using same mechanism on all browsers now to write out
470 // Flash object into page
471
472 // document.write no longer works correctly due to Eolas patent workaround
473 // in IE; nothing happens (i.e. object doesn't go into page if we use it)
474 dojo.connect(dojo, "loaded", dojo.hitch(this, function(){
475 // Prevent putting duplicate SWFs onto the page
476 var containerId = this.id + "Container";
477 if(dojo.byId(containerId)){
478 return;
479 }
480
481 var div = document.createElement("div");
482 div.id = this.id + "Container";
483
484 div.style.width = this.width + "px";
485 div.style.height = this.height + "px";
486 if(!this._visible){
487 div.style.position = "absolute";
488 div.style.zIndex = "10000";
489 div.style.top = "-1000px";
490 }
491
492 div.innerHTML = objectHTML;
493
494 var body = document.getElementsByTagName("body");
495 if(!body || !body.length){
496 throw new Error("No body tag for this page");
497 }
498 body = body[0];
499 body.appendChild(div);
500 }));
501 },
502
503 get: function(){ /* Object */
504 // summary:
505 // Gets the Flash object DOM node.
506
507 if(dojo.isIE || dojo.isWebKit){
508 //TODO: should this really be the else?
509 return dojo.byId(this.id);
510 }else{
511 // different IDs on OBJECT and EMBED tags or
512 // else Firefox will return wrong one and
513 // communication won't work;
514 // also, document.getElementById() returns a
515 // plugin but ExternalInterface calls don't
516 // work on it so we have to use
517 // document[id] instead
518 return document[this.id + "Embed"];
519 }
520 },
521
522 setVisible: function(/* Boolean */ visible){
523 // summary:
524 // Sets the visibility of this Flash object.
525
526 //console.debug("setVisible, visible="+visible);
527
528 var container = dojo.byId(this.id + "Container");
529 if(visible){
530 container.style.position = "absolute"; // IE -- Brad Neuberg
531 container.style.visibility = "visible";
532 }else{
533 container.style.position = "absolute";
534 container.style.y = "-1000px";
535 container.style.visibility = "hidden";
536 }
537 },
538
539 center: function(){
540 // summary:
541 // Centers the flash applet on the page.
542
543 var elementWidth = this.width;
544 var elementHeight = this.height;
545
546 var viewport = dojo.window.getBox();
547
548 // compute the centered position
549 var x = viewport.l + (viewport.w - elementWidth) / 2;
550 var y = viewport.t + (viewport.h - elementHeight) / 2;
551
552 // set the centered position
553 var container = dojo.byId(this.id + "Container");
554 container.style.top = y + "px";
555 container.style.left = x + "px";
556 }
557 };
558
559
560 dojox.flash.Communicator = function(){
561 // summary:
562 // A class that is used to communicate between Flash and JavaScript.
563 // description:
564 // This class helps mediate Flash and JavaScript communication. Internally
565 // it uses Flash 8's ExternalInterface API, but adds functionality to fix
566 // various encoding bugs that ExternalInterface has.
567 }
568
569 dojox.flash.Communicator.prototype = {
570 // Registers the existence of a Flash method that we can call with
571 // JavaScript, using Flash 8's ExternalInterface.
572 _addExternalInterfaceCallback: function(methodName){
573 //console.debug("addExternalInterfaceCallback, methodName="+methodName);
574 var wrapperCall = dojo.hitch(this, function(){
575 // some browsers don't like us changing values in the 'arguments' array, so
576 // make a fresh copy of it
577 var methodArgs = new Array(arguments.length);
578 for(var i = 0; i < arguments.length; i++){
579 methodArgs[i] = this._encodeData(arguments[i]);
580 }
581
582 var results = this._execFlash(methodName, methodArgs);
583 results = this._decodeData(results);
584
585 return results;
586 });
587
588 this[methodName] = wrapperCall;
589 },
590
591 // Encodes our data to get around ExternalInterface bugs that are still
592 // present even in Flash 9.
593 _encodeData: function(data){
594 //console.debug("encodeData, data=", data);
595 if(!data || typeof data != "string"){
596 return data;
597 }
598
599 // transforming \ into \\ doesn't work; just use a custom encoding
600 data = data.replace("\\", "&custom_backslash;");
601
602 // also use custom encoding for the null character to avoid problems
603 data = data.replace(/\0/g, "&custom_null;");
604
605 return data;
606 },
607
608 // Decodes our data to get around ExternalInterface bugs that are still
609 // present even in Flash 9.
610 _decodeData: function(data){
611 //console.debug("decodeData, data=", data);
612 // weirdly enough, Flash sometimes returns the result as an
613 // 'object' that is actually an array, rather than as a String;
614 // detect this by looking for a length property; for IE
615 // we also make sure that we aren't dealing with a typeof string
616 // since string objects have length property there
617 if(data && data.length && typeof data != "string"){
618 data = data[0];
619 }
620
621 if(!data || typeof data != "string"){
622 return data;
623 }
624
625 // needed for IE; \0 is the NULL character
626 data = data.replace(/\&custom_null\;/g, "\0");
627
628 // certain XMLish characters break Flash's wire serialization for
629 // ExternalInterface; these are encoded on the
630 // DojoExternalInterface side into a custom encoding, rather than
631 // the standard entity encoding, because otherwise we won't be able to
632 // differentiate between our own encoding and any entity characters
633 // that are being used in the string itself
634 data = data.replace(/\&custom_lt\;/g, "<")
635 .replace(/\&custom_gt\;/g, ">")
636 .replace(/\&custom_backslash\;/g, '\\');
637
638 return data;
639 },
640
641 // Executes a Flash method; called from the JavaScript wrapper proxy we
642 // create on dojox.flash.comm.
643 _execFlash: function(methodName, methodArgs){
644 //console.debug("execFlash, methodName="+methodName+", methodArgs=", methodArgs);
645 var plugin = dojox.flash.obj.get();
646 methodArgs = (methodArgs) ? methodArgs : [];
647
648 // encode arguments that are strings
649 for(var i = 0; i < methodArgs; i++){
650 if(typeof methodArgs[i] == "string"){
651 methodArgs[i] = this._encodeData(methodArgs[i]);
652 }
653 }
654
655 // we use this gnarly hack below instead of
656 // plugin[methodName] for two reasons:
657 // 1) plugin[methodName] has no call() method, which
658 // means we can't pass in multiple arguments dynamically
659 // to a Flash method -- we can only have one
660 // 2) On IE plugin[methodName] returns undefined --
661 // plugin[methodName] used to work on IE when we
662 // used document.write but doesn't now that
663 // we use dynamic DOM insertion of the Flash object
664 // -- Brad Neuberg
665 var flashExec = function(){
666 return eval(plugin.CallFunction(
667 "<invoke name=\"" + methodName
668 + "\" returntype=\"javascript\">"
669 + __flash__argumentsToXML(methodArgs, 0)
670 + "</invoke>"));
671 };
672 var results = flashExec.call(methodArgs);
673
674 if(typeof results == "string"){
675 results = this._decodeData(results);
676 }
677
678 return results;
679 }
680 }
681
682 // FIXME: dojo.declare()-ify this
683
684 // TODO: I did not test the Install code when I refactored Dojo Flash from 0.4 to
685 // 1.0, so am not sure if it works. If Flash is not present I now prefer
686 // that Gears is installed instead of Flash because GearsStorageProvider is
687 // much easier to work with than Flash's hacky ExternalInterface.
688 // -- Brad Neuberg
689 dojox.flash.Install = function(){
690 // summary:
691 // Helps install Flash plugin if needed.
692 // description:
693 // Figures out the best way to automatically install the Flash plugin
694 // for this browser and platform. Also determines if installation or
695 // revving of the current plugin is needed on this platform.
696 };
697
698 dojox.flash.Install.prototype = {
699 needed: function(){ /* Boolean */
700 // summary:
701 // Determines if installation or revving of the current plugin is
702 // needed.
703
704 // do we even have flash?
705 if(!dojox.flash.info.capable){
706 return true;
707 }
708
709 // Must have ExternalInterface which came in Flash 8
710 if(!dojox.flash.info.isVersionOrAbove(8, 0, 0)){
711 return true;
712 }
713
714 // otherwise we don't need installation
715 return false;
716 },
717
718 install: function(){
719 // summary:
720 // Performs installation or revving of the Flash plugin.
721 var installObj;
722
723 // indicate that we are installing
724 dojox.flash.info.installing = true;
725 dojox.flash.installing();
726
727 if(dojox.flash.info.capable == false){ // we have no Flash at all
728 // write out a simple Flash object to force the browser to prompt
729 // the user to install things
730 installObj = new dojox.flash.Embed(false);
731 installObj.write(); // write out HTML for Flash
732 }else if(dojox.flash.info.isVersionOrAbove(6, 0, 65)){ // Express Install
733 installObj = new dojox.flash.Embed(false);
734 installObj.write(true); // write out HTML for Flash 8 version+
735 installObj.setVisible(true);
736 installObj.center();
737 }else{ // older Flash install than version 6r65
738 alert("This content requires a more recent version of the Macromedia "
739 +" Flash Player.");
740 window.location.href = + dojox.flash.Embed.protocol() +
741 "://www.macromedia.com/go/getflashplayer";
742 }
743 },
744
745 // Called when the Express Install is either finished, failed, or was
746 // rejected by the user.
747 _onInstallStatus: function(msg){
748 if (msg == "Download.Complete"){
749 // Installation is complete.
750 dojox.flash._initialize();
751 }else if(msg == "Download.Cancelled"){
752 alert("This content requires a more recent version of the Macromedia "
753 +" Flash Player.");
754 window.location.href = dojox.flash.Embed.protocol() +
755 "://www.macromedia.com/go/getflashplayer";
756 }else if (msg == "Download.Failed"){
757 // The end user failed to download the installer due to a network failure
758 alert("There was an error downloading the Flash Player update. "
759 + "Please try again later, or visit macromedia.com to download "
760 + "the latest version of the Flash plugin.");
761 }
762 }
763 };
764
765 // find out if Flash is installed
766 dojox.flash.info = new dojox.flash.Info();
767
768 // vim:ts=4:noet:tw=0: