|
Struts example source code file (flash.js)
The Struts flash.js source code/* Copyright (c) 2004-2006, The Dojo Foundation All Rights Reserved. Licensed under the Academic Free License version 2.1 or above OR the modified BSD license. For more information on Dojo licensing, see: http://dojotoolkit.org/community/licensing.shtml */ dojo.provide("dojo.flash"); dojo.require("dojo.string.*"); dojo.require("dojo.uri.*"); dojo.require("dojo.html.common"); dojo.flash = function () { }; dojo.flash = {flash6_version:null, flash8_version:null, ready:false, _visible:true, _loadedListeners:new Array(), _installingListeners:new Array(), setSwf:function (fileInfo) { if (fileInfo == null || dojo.lang.isUndefined(fileInfo)) { return; } if (fileInfo.flash6 != null && !dojo.lang.isUndefined(fileInfo.flash6)) { this.flash6_version = fileInfo.flash6; } if (fileInfo.flash8 != null && !dojo.lang.isUndefined(fileInfo.flash8)) { this.flash8_version = fileInfo.flash8; } if (!dojo.lang.isUndefined(fileInfo.visible)) { this._visible = fileInfo.visible; } this._initialize(); }, useFlash6:function () { if (this.flash6_version == null) { return false; } else { if (this.flash6_version != null && dojo.flash.info.commVersion == 6) { return true; } else { return false; } } }, useFlash8:function () { if (this.flash8_version == null) { return false; } else { if (this.flash8_version != null && dojo.flash.info.commVersion == 8) { return true; } else { return false; } } }, addLoadedListener:function (listener) { this._loadedListeners.push(listener); }, addInstallingListener:function (listener) { this._installingListeners.push(listener); }, loaded:function () { dojo.flash.ready = true; if (dojo.flash._loadedListeners.length > 0) { for (var i = 0; i < dojo.flash._loadedListeners.length; i++) { dojo.flash._loadedListeners[i].call(null); } } }, installing:function () { if (dojo.flash._installingListeners.length > 0) { for (var i = 0; i < dojo.flash._installingListeners.length; i++) { dojo.flash._installingListeners[i].call(null); } } }, _initialize:function () { var installer = new dojo.flash.Install(); dojo.flash.installer = installer; if (installer.needed() == true) { installer.install(); } else { dojo.flash.obj = new dojo.flash.Embed(this._visible); dojo.flash.obj.write(dojo.flash.info.commVersion); dojo.flash.comm = new dojo.flash.Communicator(); } }}; dojo.flash.Info = function () { if (dojo.render.html.ie) { document.writeln("<script language=\"VBScript\" type=\"text/vbscript\">"); document.writeln("Function VBGetSwfVer(i)"); document.writeln(" on error resume next"); document.writeln(" Dim swControl, swVersion"); document.writeln(" swVersion = 0"); document.writeln(" set swControl = CreateObject(\"ShockwaveFlash.ShockwaveFlash.\" + CStr(i))"); document.writeln(" if (IsObject(swControl)) then"); document.writeln(" swVersion = swControl.GetVariable(\"$version\")"); document.writeln(" end if"); document.writeln(" VBGetSwfVer = swVersion"); document.writeln("End Function"); document.writeln("</script>"); } this._detectVersion(); this._detectCommunicationVersion(); }; dojo.flash.Info.prototype = {version:-1, versionMajor:-1, versionMinor:-1, versionRevision:-1, capable:false, commVersion:6, installing:false, isVersionOrAbove:function (reqMajorVer, reqMinorVer, reqVer) { reqVer = parseFloat("." + reqVer); if (this.versionMajor >= reqMajorVer && this.versionMinor >= reqMinorVer && this.versionRevision >= reqVer) { return true; } else { return false; } }, _detectVersion:function () { var versionStr; for (var testVersion = 25; testVersion > 0; testVersion--) { if (dojo.render.html.ie) { versionStr = VBGetSwfVer(testVersion); } else { versionStr = this._JSFlashInfo(testVersion); } if (versionStr == -1) { this.capable = false; return; } else { if (versionStr != 0) { var versionArray; if (dojo.render.html.ie) { var tempArray = versionStr.split(" "); var tempString = tempArray[1]; versionArray = tempString.split(","); } else { versionArray = versionStr.split("."); } this.versionMajor = versionArray[0]; this.versionMinor = versionArray[1]; this.versionRevision = versionArray[2]; var versionString = this.versionMajor + "." + this.versionRevision; this.version = parseFloat(versionString); this.capable = true; break; } } } }, _JSFlashInfo:function (testVersion) { if (navigator.plugins != null && navigator.plugins.length > 0) { if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) { var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : ""; var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description; var descArray = flashDescription.split(" "); var tempArrayMajor = descArray[2].split("."); var versionMajor = tempArrayMajor[0]; var versionMinor = tempArrayMajor[1]; if (descArray[3] != "") { var tempArrayMinor = descArray[3].split("r"); } else { var tempArrayMinor = descArray[4].split("r"); } var versionRevision = tempArrayMinor[1] > 0 ? tempArrayMinor[1] : 0; var version = versionMajor + "." + versionMinor + "." + versionRevision; return version; } } return -1; }, _detectCommunicationVersion:function () { if (this.capable == false) { this.commVersion = null; return; } if (typeof djConfig["forceFlashComm"] != "undefined" && typeof djConfig["forceFlashComm"] != null) { this.commVersion = djConfig["forceFlashComm"]; return; } if (dojo.render.html.safari == true || dojo.render.html.opera == true) { this.commVersion = 8; } else { this.commVersion = 6; } }}; dojo.flash.Embed = function (visible) { this._visible = visible; }; dojo.flash.Embed.prototype = {width:215, height:138, id:"flashObject", _visible:true, protocol:function () { switch (window.location.protocol) { case "https:": return "https"; break; default: return "http"; break; } }, write:function (flashVer, doExpressInstall) { if (dojo.lang.isUndefined(doExpressInstall)) { doExpressInstall = false; } var containerStyle = new dojo.string.Builder(); containerStyle.append("width: " + this.width + "px; "); containerStyle.append("height: " + this.height + "px; "); if (this._visible == false) { containerStyle.append("position: absolute; "); containerStyle.append("z-index: 10000; "); containerStyle.append("top: -1000px; "); containerStyle.append("left: -1000px; "); } containerStyle = containerStyle.toString(); var objectHTML; var swfloc; if (flashVer == 6) { swfloc = dojo.flash.flash6_version; var dojoPath = djConfig.baseRelativePath; swfloc = swfloc + "?baseRelativePath=" + escape(dojoPath); objectHTML = "<embed id=\"" + this.id + "\" src=\"" + swfloc + "\" " + " quality=\"high\" bgcolor=\"#ffffff\" " + " width=\"" + this.width + "\" height=\"" + this.height + "\" " + " name=\"" + this.id + "\" " + " align=\"middle\" allowScriptAccess=\"sameDomain\" " + " type=\"application/x-shockwave-flash\" swLiveConnect=\"true\" " + " pluginspage=\"" + this.protocol() + "://www.macromedia.com/go/getflashplayer\">"; } else { swfloc = dojo.flash.flash8_version; var swflocObject = swfloc; var swflocEmbed = swfloc; var dojoPath = djConfig.baseRelativePath; if (doExpressInstall) { var redirectURL = escape(window.location); document.title = document.title.slice(0, 47) + " - Flash Player Installation"; var docTitle = escape(document.title); swflocObject += "?MMredirectURL=" + redirectURL + "&MMplayerType=ActiveX" + "&MMdoctitle=" + docTitle + "&baseRelativePath=" + escape(dojoPath); swflocEmbed += "?MMredirectURL=" + redirectURL + "&MMplayerType=PlugIn" + "&baseRelativePath=" + escape(dojoPath); } if (swflocEmbed.indexOf("?") == -1) { swflocEmbed += "?baseRelativePath=" + escape(dojoPath) + "' "; } objectHTML = "<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" " + "codebase=\"" + this.protocol() + "://fpdownload.macromedia.com/pub/shockwave/cabs/flash/" + "swflash.cab#version=8,0,0,0\" " + "width=\"" + this.width + "\" " + "height=\"" + this.height + "\" " + "id=\"" + this.id + "\" " + "align=\"middle\"> " + " " + " " + " " + " " + "" + ""; } objectHTML = "<div id=\"" + this.id + "Container\" style=\"" + containerStyle + "\"> " + objectHTML + " Other Struts examples (source code examples)Here is a short list of links related to this Struts flash.js source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.