Skip to content

Commit

Permalink
JavaScript cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nwtn committed Nov 4, 2013
1 parent 9fd497f commit 556b67a
Show file tree
Hide file tree
Showing 8 changed files with 1,163 additions and 201 deletions.
32 changes: 15 additions & 17 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

<link rel="stylesheet" href="css/default.css" />

<script src="js/modernizr-1.0.min.js"></script>
<script src="js/modernizr.js"></script>
</head>

<body>
Expand Down Expand Up @@ -81,13 +81,13 @@
<dt class="jsfdl-revision">Revision</dt>
<dd class="jsfdl-revision">Unknown</dd>

<dt class="jsfdl-revisionStr">Revision string</dt>
<dd class="jsfdl-revisionStr">Unknown</dd>
<dt class="jsfdl-revisionSt">Revision string</dt>
<dd class="jsfdl-revisionSt">Unknown</dd>
</dl>
</section>

<section class="details js" id="afpdkc">
<h2><a rel="external" target="_blank" href="http://www.adobe.com/products/flashplayer/download/detection_kit/">Adobe Flash Player Detection Kit</a> (Revision 1.5) Client-Side Detection</h2>
<h2><a rel="external" target="_blank" href="http://solutionpartners.adobe.com/products/flashplayer/download/detection_kit/">Adobe Flash Player Detection Kit</a> (Revision 1.5) Client-Side Detection</h2>
<dl>
<dt class="afpdkc-type">Type</dt>
<dd class="afpdkc-type">Unknown</dd>
Expand All @@ -98,7 +98,7 @@
</section>

<section class="details php" id="afpdks">
<h2><a rel="external" target="_blank" href="http://www.adobe.com/products/flashplayer/download/detection_kit/">Adobe Flash Player Detection Kit</a> (Revision 1.5) Server-Side Detection (PHP)</h2>
<h2><a rel="external" target="_blank" href="http://solutionpartners.adobe.com/products/flashplayer/download/detection_kit/">Adobe Flash Player Detection Kit</a> (Revision 1.5) Server-Side Detection (PHP)</h2>
<dl>
<dt class="afpdks-installed">Installed</dt>
<dd class="afpdks-installed"><?php print $fpdkInstalled; ?></dd>
Expand All @@ -121,21 +121,19 @@
</main>

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/vendor/jquery-1.10.2.min.js"><\/script>')</script>
<script>window.jQuery || document.write('<script src="js/jquery-1.10.2.min.js"><\/script>')</script>

<script src="js/isflashinstalled.js"></script>
<script src="js/flash_detect.js"></script>
<script src="js/AC_OETags.js"></script>
<script src="js/flash_detect_min.js"></script>
<script src="js/isflashinstalled.js"></script>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-11691016-1");
pageTracker._trackPageview();
} catch(err) {}
<script>
(function(b,o,i,l,e,r){b.GoogleAnalyticsObject=l;b[l]||(b[l]=
function(){(b[l].q=b[l].q||[]).push(arguments)});b[l].l=+new Date;
e=o.createElement(i);r=o.getElementsByTagName(i)[0];
e.src='//www.google-analytics.com/analytics.js';
r.parentNode.insertBefore(e,r)}(window,document,'script','ga'));
ga('create','UA-11691016-1');ga('send','pageview');
</script>
</body>
</html>
200 changes: 200 additions & 0 deletions js/flash_detect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,200 @@
/*
Copyright (c) Copyright (c) 2007, Carl S. Yestrau All rights reserved.
Code licensed under the BSD License: http://www.featureblend.com/license.txt
Version: 1.0.4
*/
var FlashDetect = new function(){
var self = this;
self.installed = false;
self.raw = "";
self.major = -1;
self.minor = -1;
self.revision = -1;
self.revisionStr = "";
var activeXDetectRules = [
{
"name":"ShockwaveFlash.ShockwaveFlash.7",
"version":function(obj){
return getActiveXVersion(obj);
}
},
{
"name":"ShockwaveFlash.ShockwaveFlash.6",
"version":function(obj){
var version = "6,0,21";
try{
obj.AllowScriptAccess = "always";
version = getActiveXVersion(obj);
}catch(err){}
return version;
}
},
{
"name":"ShockwaveFlash.ShockwaveFlash",
"version":function(obj){
return getActiveXVersion(obj);
}
}
];
/**
* Extract the ActiveX version of the plugin.
*
* @param {Object} The flash ActiveX object.
* @type String
*/
var getActiveXVersion = function(activeXObj){
var version = -1;
try{
version = activeXObj.GetVariable("$version");
}catch(err){}
return version;
};
/**
* Try and retrieve an ActiveX object having a specified name.
*
* @param {String} name The ActiveX object name lookup.
* @return One of ActiveX object or a simple object having an attribute of activeXError with a value of true.
* @type Object
*/
var getActiveXObject = function(name){
var obj = -1;
try{
obj = new ActiveXObject(name);
}catch(err){
obj = {activeXError:true};
}
return obj;
};
/**
* Parse an ActiveX $version string into an object.
*
* @param {String} str The ActiveX Object GetVariable($version) return value.
* @return An object having raw, major, minor, revision and revisionStr attributes.
* @type Object
*/
var parseActiveXVersion = function(str){
var versionArray = str.split(",");//replace with regex
return {
"raw":str,
"major":parseInt(versionArray[0].split(" ")[1], 10),
"minor":parseInt(versionArray[1], 10),
"revision":parseInt(versionArray[2], 10),
"revisionStr":versionArray[2]
};
};
/**
* Parse a standard enabledPlugin.description into an object.
*
* @param {String} str The enabledPlugin.description value.
* @return An object having raw, major, minor, revision and revisionStr attributes.
* @type Object
*/
var parseStandardVersion = function(str){
var descParts = str.split(/ +/);
var majorMinor = descParts[2].split(/\./);
var revisionStr = descParts[3];
return {
"raw":str,
"major":parseInt(majorMinor[0], 10),
"minor":parseInt(majorMinor[1], 10),
"revisionStr":revisionStr,
"revision":parseRevisionStrToInt(revisionStr)
};
};
/**
* Parse the plugin revision string into an integer.
*
* @param {String} The revision in string format.
* @type Number
*/
var parseRevisionStrToInt = function(str){
return parseInt(str.replace(/[a-zA-Z]/g, ""), 10) || self.revision;
};
/**
* Is the major version greater than or equal to a specified version.
*
* @param {Number} version The minimum required major version.
* @type Boolean
*/
self.majorAtLeast = function(version){
return self.major >= version;
};
/**
* Is the minor version greater than or equal to a specified version.
*
* @param {Number} version The minimum required minor version.
* @type Boolean
*/
self.minorAtLeast = function(version){
return self.minor >= version;
};
/**
* Is the revision version greater than or equal to a specified version.
*
* @param {Number} version The minimum required revision version.
* @type Boolean
*/
self.revisionAtLeast = function(version){
return self.revision >= version;
};
/**
* Is the version greater than or equal to a specified major, minor and revision.
*
* @param {Number} major The minimum required major version.
* @param {Number} (Optional) minor The minimum required minor version.
* @param {Number} (Optional) revision The minimum required revision version.
* @type Boolean
*/
self.versionAtLeast = function(major){
var properties = [self.major, self.minor, self.revision];
var len = Math.min(properties.length, arguments.length);
for(i=0; i<len; i++){
if(properties[i]>=arguments[i]){
if(i+1<len && properties[i]==arguments[i]){
continue;
}else{
return true;
}
}else{
return false;
}
}
};
/**
* Constructor, sets raw, major, minor, revisionStr, revision and installed public properties.
*/
self.FlashDetect = function(){
if(navigator.plugins && navigator.plugins.length>0){
var type = 'application/x-shockwave-flash';
var mimeTypes = navigator.mimeTypes;
if(mimeTypes && mimeTypes[type] && mimeTypes[type].enabledPlugin && mimeTypes[type].enabledPlugin.description){
var version = mimeTypes[type].enabledPlugin.description;
var versionObj = parseStandardVersion(version);
self.raw = versionObj.raw;
self.major = versionObj.major;
self.minor = versionObj.minor;
self.revisionStr = versionObj.revisionStr;
self.revision = versionObj.revision;
self.installed = true;
}
}else if(navigator.appVersion.indexOf("Mac")==-1 && window.execScript){
var version = -1;
for(var i=0; i<activeXDetectRules.length && version==-1; i++){
var obj = getActiveXObject(activeXDetectRules[i].name);
if(!obj.activeXError){
self.installed = true;
version = activeXDetectRules[i].version(obj);
if(version!=-1){
var versionObj = parseActiveXVersion(version);
self.raw = versionObj.raw;
self.major = versionObj.major;
self.minor = versionObj.minor;
self.revision = versionObj.revision;
self.revisionStr = versionObj.revisionStr;
}
}
}
}
}();
};
FlashDetect.JS_RELEASE = "1.0.4";
5 changes: 0 additions & 5 deletions js/flash_detect_min.js

This file was deleted.

Loading

0 comments on commit 556b67a

Please sign in to comment.