Skip to content

Commit

Permalink
jslint work. Reworked build.sh as IE 7 don't like jsmin and plugindet…
Browse files Browse the repository at this point in the history
…ect.js
  • Loading branch information
Austin King committed Mar 10, 2010
1 parent 267dbde commit ed2267e
Show file tree
Hide file tree
Showing 8 changed files with 175 additions and 718 deletions.
75 changes: 32 additions & 43 deletions build.sh
Expand Up @@ -10,57 +10,46 @@ echo "Checking for bad uses of jQuery"
# We shouldn't use $, we have Pfs.$ instead, Regex OK
grep "$." $PERFIDIES/*.js | grep -v "Pfs.$." | grep -v "$/"

echo "building plugincheck.js"
echo "building plugincheck.js ================================================"
rm -f js/plugincheck.js
cp $PERFIDIES/notice.txt js/plugincheck.min.js
echo -ne '// Version: ' >> js/plugincheck.min.js;
echo `cat ${PERFIDIES}/*.js | md5sum` >> js/plugincheck.min.js

cat $PERFIDIES/lib/plugindetect.js >> js/plugincheck.js
~/bin/jsmin < $PERFIDIES/lib/browserdetect.js >> js/plugincheck.min.js
# So it turns out that plugindetect can't be passed through jsmin or IE 7 will barf
cat $PERFIDIES/lib/plugindetect.js >> js/plugincheck.min.js
# Bug#535030 use mozilla.com's jquery
cat $PERFIDIES/lib/browserdetect.js >> js/plugincheck.js
cat $PERFIDIES/lib/plugindetect.js >> js/plugincheck.js
cat $PERFIDIES/lib/jquery.jsonp-1.1.0.js >> js/plugincheck.js
cat $PERFIDIES/perfidies.js >> js/plugincheck.js
cat $PERFIDIES/messages.js >> js/plugincheck.js
cat $PERFIDIES/web.js >> js/plugincheck.js
cat $PERFIDIES/exploder.js >> js/plugincheck.js
cat $PERFIDIES/plugincheck.js >> js/plugincheck.js
# $PERFIDIES/lib/jquery-1.3.2.min.js
~/bin/jsmin < $PERFIDIES/lib/jquery.jsonp-1.1.0.js >> js/plugincheck.min.js
~/bin/jsmin < $PERFIDIES/perfidies.js >> js/plugincheck.min.js
~/bin/jsmin < $PERFIDIES/messages.js >> js/plugincheck.min.js
~/bin/jsmin < $PERFIDIES/web.js >> js/plugincheck.min.js
~/bin/jsmin < $PERFIDIES/exploder.js >> js/plugincheck.min.js
~/bin/jsmin < $PERFIDIES/plugincheck.js >> js/plugincheck.min.js

cp $PERFIDIES/notice.txt js/plugincheck.min.js
echo -ne '// Version: ' >> js/plugincheck.min.js;
echo -ne `cat ${PERFIDIES}/*.js | md5sum` >> js/plugincheck.min.js
~/bin/jsmin < js/plugincheck.js >> js/plugincheck.min.js
mv js/plugincheck.min.js js/plugincheck.js

echo "building plugincheck_badge.js"
rm -f js/plugincheck_badge.js

cat $PERFIDIES/lib/browserdetect.js >> js/plugincheck_badge.js
cat $PERFIDIES/lib/plugindetect.js >> js/plugincheck_badge.js
cat $PERFIDIES/lib/jquery-1.3.2.min.js >> js/plugincheck_badge.js
cat $PERFIDIES/lib/jquery.jsonp-1.1.0.js >> js/plugincheck_badge.js
cat $PERFIDIES/perfidies.js >> js/plugincheck_badge.js
# Badge uses images outside of JS, so no localization in messages.js
# $PERFIDIES/messages.js >> js/plugincheck.js
cat $PERFIDIES/web.js >> js/plugincheck_badge.js
cat $PERFIDIES/exploder.js >> js/plugincheck_badge.js
cat $PERFIDIES/plugincheck_badge.js >> js/plugincheck_badge.js

cp $PERFIDIES/notice.txt js/plugincheck_badge.min.js
echo -ne '// Version: ' >> js/plugincheck_badge.min.js;
echo -ne `cat ${PERFIDIES}/*.js | md5sum` >> js/plugincheck_badge.min.js
echo "building plugincheck_badge.js ================================================"
rm -f js/plugincheck_badge.js
cp $PERFIDIES/notice.txt js/plugincheck_badge.min.js
echo -ne '// Version: ' >> js/plugincheck_badge.min.js

echo `cat ${PERFIDIES}/*.js | md5sum` >> js/plugincheck_badge.min.js
~/bin/jsmin < $PERFIDIES/lib/browserdetect.js >> js/plugincheck_badge.min.js

# Pick one of the two following minimizers...
# Used Google Closure Compiler for a release, but then on 11/23 with no
# code change, it's output broke the script ;)
# So it turns out that plugindetect can't be passed through jsmin or IE 7 will barf
cat $PERFIDIES/lib/plugindetect.js >> js/plugincheck_badge.min.js

# BEGIN Using jsmin
~/bin/jsmin < js/plugincheck_badge.js >> js/plugincheck_badge.min.js
mv js/plugincheck_badge.min.js js/plugincheck_badge.js
# END Using jsmin
~/bin/jsmin < $PERFIDIES/lib/jquery-1.3.2.min.js >> js/plugincheck_badge.js
~/bin/jsmin < $PERFIDIES/lib/jquery.jsonp-1.1.0.js >> js/plugincheck_badge.js
~/bin/jsmin < $PERFIDIES/perfidies.js >> js/plugincheck_badge.js
# Badge uses images outside of JS, so no localization in messages.js
# $PERFIDIES/messages.js
~/bin/jsmin < $PERFIDIES/web.js >> js/plugincheck_badge.js
~/bin/jsmin < $PERFIDIES/exploder.js >> js/plugincheck_badge.js
~/bin/jsmin < $PERFIDIES/plugincheck_badge.js >> js/plugincheck_badge.js

# BEGIN Using Google Closure Compiler...
# remove whitespace for HTTP POST
#~/bin/jsmin < js/plugincheck_badge.js >> js/plugincheck_badge.post.js
#$PERFIDIES/closure_compiler.php /home/aking/mozilla.com/js/plugincheck_badge.post.js >> js/plugincheck_badge.min.js
#rm js/plugincheck_badge.post.js
#mv js/plugincheck_badge.min.js js/plugincheck_badge.js
# END Using Google Closure Compiler...
mv js/plugincheck_badge.min.js js/plugincheck_badge.js
9 changes: 6 additions & 3 deletions exploder.js
@@ -1,14 +1,17 @@
/*jslint browser: true */
/*global Pfs, PluginDetect, window*/

if (Pfs.$.browser.msie) {
window.iePlugins = [];
var alterNavigator = function(name, description, filename, mimeType) {
var alterNavigator = function (name, description, filename, mimeType) {
window.iePlugins.push({
name: name,
description: description,
filename: filename,
length: 1,
"0": {type: mimeType }
});
}
};

/* IE has no proper navigator.plugins, so we use the pinlady library
to detect COM objects or plugins via <object> tags.
Expand Down Expand Up @@ -77,5 +80,5 @@ if (Pfs.$.browser.msie) {
'npvlc.dll', // FIXME
'video/mp4');
}

alert('Setup ' + window.iePlugins.length + ' plugins');
}
30 changes: 20 additions & 10 deletions lib/browserdetect.js
@@ -1,11 +1,16 @@
/*jslint browser: true, plusplus: false */
/*global Pfs, PluginDetect, window*/
// jslint that we should fix below
/*jslint eqeqeq: false*/

/**
* Browser detection based on QuirksMode code
*
* See also: http://www.quirksmode.org/js/detect.html
* License: http://www.quirksmode.org/about/copyright.html
*/
/*jslint laxbreak: true */
BrowserDetect = {
window.BrowserDetect = {
detect: function () {
return {
browser:
Expand All @@ -24,9 +29,10 @@ BrowserDetect = {
};
},
searchString: function (data) {
for (var i=0;i<data.length;i++) {
var dataString = data[i].string;
var dataProp = data[i].prop;
var i, dataString, dataProp;
for (i = 0; i < data.length; i++) {
dataString = data[i].string;
dataProp = data[i].prop;
this.versionSearchString = data[i].versionSearch || data[i].identity;
this.buildSearchString = data[i].buildSearch || data[i].identity;
if (dataString) {
Expand All @@ -37,11 +43,15 @@ BrowserDetect = {
return data[i].identity;
}
}
return undefined;
},
searchRev: function (searchString, dataString) {
var index = dataString.indexOf(searchString);
if (index == -1) { return; }
var val = dataString.substring(index+searchString.length+1);
var index = dataString.indexOf(searchString),
val;
if (index == -1) {
return undefined;
}
val = dataString.substring(index + searchString.length + 1);
return val.split(' ')[0];
},
dataBrowser: [
Expand All @@ -50,7 +60,7 @@ BrowserDetect = {
subString: "Chrome",
identity: "Chrome"
},
{
{
string: navigator.userAgent,
subString: "OmniWeb",
versionSearch: "OmniWeb/",
Expand All @@ -63,11 +73,11 @@ BrowserDetect = {
versionSearch: "Version",
buildSearch: "Safari"
},
{
{
prop: window.opera,
identity: "Opera",
buildSearch: "Presto"
},
},
{
string: navigator.vendor,
subString: "iCab",
Expand Down

0 comments on commit ed2267e

Please sign in to comment.