Add switching theme based Screen Resolution, Java, Flash and other browser plugin
panji - November 27, 2008 - 21:26
| Project: | Switchtheme |
| Version: | 6.x-1.x-dev |
| Component: | Miscellaneous |
| Category: | feature request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | won't fix |
Jump to:
Description
For creating multi platform site and more usability drupal site, we can add more option for this module,.. such as Screen Resolution, Java, Flash and other browser plugin detection.
Here's what I've found to detect other plugin on browser to switch the themes,..
//This script detects the following:
//Flash
//Windows Media Player
//Java
//Shockwave
//RealPlayer
//QuickTime
//Acrobat Reader
//SVG Viewer
var agt=navigator.userAgent.toLowerCase();
var ie = (agt.indexOf("msie") != -1);
var ns = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
var mac = (agt.indexOf("mac")!=-1);
if (ie && win) { pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader"); }
if (ns || !win) {
nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase();
pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader");
}
function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); if (result) return name+','; else return ''; }
function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }
pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-1);
//SAMPLE USAGE- detect "Flash"
//if (pluginlist.indexOf("Flash")!=-1)
//document.write("You have flash installed")or maybe we can use some other source here:
http://www.polar-lights.com/fla/detection.html
http://www.kirupa.com/developer/mx/detection.htm
Other Java Plugin version detection:
<SCRIPT LANGUAGE="JavaScript">
var browsername;
function doNetscape()
{
for (i=0; i < navigator.plugins.length; i++)
{
for (j = 0; j < navigator.plugins[i].length; j++)
{
if(navigator.plugins[i][j].type == "application/x-java-applet;version=1.3")
{
alert("You are running Netscape with Java Plugin 1.3.0 - OK");
return;
};
}
}
alert("You are running Netscape\nPlease, install Java Runtime Environment 1.3.0");
}
function doMicrosoft()
{
var applet = document.myApplet;
if(applet == null)
{
alert("You are running Microsoft Browser.\nPlease, install Java Runtime Environment 1.3.0");
return;
};
var version = applet.getJavaVersion();
if(version == "1.3.0")
{
alert("You are running IE, Java Plugin 1.3.0 installed - OK");
}
else
{
alert("You are running IE, other plugin installed - mybe OK if later that 1.3.0\nYour version: " + version);
};
}
function getJava()
{
var applet = document.myApplet;
if(applet == null)
{
alert("Please, install Java Runtime Environment");
return;
};
alert("JRE Version: " + document.myApplet.getJavaVersion());
}
function checkJavaPlugin()
{
browsername = navigator.appName;
if(browsername.indexOf("Netscape")!= -1)
{
browsername="NS";
doNetscape();
}
else
{
if(browsername.indexOf("Microsoft")!=-1)
{
browsername="MSIE";
doMicrosoft();
}
else
{
browsername="N/A";
alert("Unknown browser: " + browsername);
}
};
}
</SCRIPT>
<body>
<Strong>Check Java Plugin</strong>
<OBJECT id="myApplet" classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
WIDTH = 1
HEIGHT = 1 >
<PARAM NAME = CODE VALUE = "DetectPluginApplet.class" >
<PARAM NAME="scriptable" VALUE="true" >
<embed type="application/x-java-applet;version=1.3"
code = DetectPluginApplet width = 2 height = 2 MAYSCRIPT = "true" >
</embed>
</EMBED>
</object>
<FORM>
<INPUT TYPE="button" value="Get Plugin Version in IE" onClick="getJava()">
<INPUT TYPE="button" value="Check Java Plugin in NS and IE" onClick="javascript:checkJavaPlugin()">
</FORM>
</BODY>For Screen Resolution:
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function redirectPage() {
var url640x480 = "http://www.yoursite.com/640x480";
var url800x600 = "http://www.yoursite.com/800x600";
var url1024x768 = "http://www.yoursite.com/1024x768";
if ((screen.width == 640) (screen.height == 480))
window.location.href= url640x480;
else if ((screen.width == 800) (screen.height == 600))
window.location.href= url800x600;
else if ((screen.width == 1024) (screen.height == 768))
window.location.href= url1024x768;
else window.location.href= url640x480;
}
// End -->
</SCRIPT>Source : http://molly.com/articles/markupandcss/1999-09-route.php
I don't know how to make it work with this module, so I need some help here,..
Regards,...
Panji

#1
Please provide a proper patch. See http://drupal.org/patch/create for further information.
#2
thanks Sun,.. and sorry for that, but it's not yet a patch, I can't create any patch, I don't think I can,.. I don't have any capability for that, coz am a designer, not a codder,.. it's just a little idea for this module..
#3
As mentioned in the other issue, all of the proposed client environment detections are running on the client-side, which is too late for SwitchTheme. SwitchTheme runs on the server-side and thus, switches the theme in front of delivering it to the client. It does not depend on JavaScript or any other browser addon technology (like Flash), which means that it works for 99.9% of all visitors.
Sorry, I do not see a way how a client-side detection and theme switching could work within SwitchTheme currently. Marking as won't fix.