diff --git a/direct/src/directscripts/DetectPanda3D.js b/direct/src/directscripts/DetectPanda3D.js new file mode 100644 index 0000000000..52c57cc034 --- /dev/null +++ b/direct/src/directscripts/DetectPanda3D.js @@ -0,0 +1,99 @@ +// Based on Apple sample code at +// http://developer.apple.com/internet/webcontent/examples/detectplugins_source.html + + +// initialize global variables +var detectableWithVB = false; +var pluginFound = false; + +function goURL(daURL) { + // Assume we have Javascript 1.1 functionality. + window.location.replace(daURL); + return; +} + +function redirectCheck(pluginFound, redirectURL, redirectIfFound) { + // check for redirection + if( redirectURL && ((pluginFound && redirectIfFound) || + (!pluginFound && !redirectIfFound)) ) { + // go away + goURL(redirectURL); + return pluginFound; + } else { + // stay here and return result of plugin detection + return pluginFound; + } +} + +function canDetectPlugins() { + if( detectableWithVB || (navigator.plugins && navigator.plugins.length > 0) ) { + return true; + } else { + return false; + } +} + +function detectPanda3D(redirectURL, redirectIfFound) { + pluginFound = detectPlugin('Panda3D'); + // if not found, try to detect with VisualBasic + if(!pluginFound && detectableWithVB) { + pluginFound = detectActiveXControl('P3DACTIVEX.P3DActiveXCtrl.1'); + } + // check for redirection + return redirectCheck(pluginFound, redirectURL, redirectIfFound); +} + +function detectPlugin() { + // allow for multiple checks in a single pass + var daPlugins = detectPlugin.arguments; + // consider pluginFound to be false until proven true + var pluginFound = false; + // if plugins array is there and not fake + if (navigator.plugins && navigator.plugins.length > 0) { + var pluginsArrayLength = navigator.plugins.length; + // for each plugin... + for (pluginsArrayCounter=0; pluginsArrayCounter < pluginsArrayLength; pluginsArrayCounter++ ) { + // loop through all desired names and check each against the current plugin name + var numFound = 0; + for(namesCounter=0; namesCounter < daPlugins.length; namesCounter++) { + // if desired plugin name is found in either plugin name or description + if( (navigator.plugins[pluginsArrayCounter].name.indexOf(daPlugins[namesCounter]) >= 0) || + (navigator.plugins[pluginsArrayCounter].description.indexOf(daPlugins[namesCounter]) >= 0) ) { + // this name was found + numFound++; + } + } + // now that we have checked all the required names against this one plugin, + // if the number we found matches the total number provided then we were successful + if(numFound == daPlugins.length) { + pluginFound = true; + // if we've found the plugin, we can stop looking through at the rest of the plugins + break; + } + } + } + return pluginFound; +} // detectPlugin + + +// Here we write out the VBScript block for MSIE Windows +if ((navigator.userAgent.indexOf('MSIE') != -1) && (navigator.userAgent.indexOf('Win') != -1)) { + document.writeln(''); +} diff --git a/direct/src/directscripts/RunPanda3D.js b/direct/src/directscripts/RunPanda3D.js new file mode 100644 index 0000000000..956e694a19 --- /dev/null +++ b/direct/src/directscripts/RunPanda3D.js @@ -0,0 +1,92 @@ +// This script injects the appropriate syntax into the document to +// embed Panda3D, either for the ActiveX or Mozilla-based plugin. + +// It is also possible to write browser-independent code by nesting +// tags, but this causes problems when you need to reference +// the particular object that is actually running (which object is +// it?) for scripting purposes. + +// This script writes only a single tag, and it can be +// assigned the id you specify, avoiding this ambiguity. + +var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false; +var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false; +var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false; + + +function P3D_Generateobj(objAttrs, params, embedAttrs) +{ + var str = ''; + if (isIE && isWin && !isOpera) + { + str += ' '; + } + str += ''; + } + else + { + str += '