addon-sdk/source/examples/library-detector/data/library-detector.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/addon-sdk/source/examples/library-detector/data/library-detector.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,97 @@
     1.4 +/*
     1.5 +The code in this file is adapted from the original
     1.6 +Library Detector add-on
     1.7 +(https://addons.mozilla.org/en-US/firefox/addon/library-detector/) written by
     1.8 +Paul Bakaus (http://paulbakaus.com/) and made available under the
     1.9 +MIT License (http://www.opensource.org/licenses/mit-license.php).
    1.10 +*/
    1.11 +
    1.12 +var LD_tests = {
    1.13 +
    1.14 +    'jQuery': {
    1.15 +        test: function(win) {
    1.16 +            var jq = win.jQuery || win.$ || win.$jq || win.$j;
    1.17 +            if(jq && jq.fn && jq.fn.jquery) {
    1.18 +                return { version: jq.fn.jquery };
    1.19 +            } else {
    1.20 +                return false;
    1.21 +            }
    1.22 +        }
    1.23 +    },
    1.24 +
    1.25 +    'jQuery UI': {
    1.26 +        //phonehome: 'http://jqueryui.com/phone_home',
    1.27 +        test: function(win) {
    1.28 +
    1.29 +            var jq = win.jQuery || win.$ || win.$jq || win.$j;
    1.30 +            if(jq && jq.fn && jq.fn.jquery && jq.ui) {
    1.31 +
    1.32 +                var plugins = 'accordion,datepicker,dialog,draggable,droppable,progressbar,resizable,selectable,slider,menu,grid,tabs'.split(','), concat = [];
    1.33 +                for (var i=0; i < plugins.length; i++) { if(jq.ui[plugins[i]]) concat.push(plugins[i].substr(0,1).toUpperCase() + plugins[i].substr(1)); };
    1.34 +
    1.35 +                return { version: jq.ui.version, details: concat.length ? 'Plugins used: '+concat.join(',') : '' };
    1.36 +            } else {
    1.37 +                return false;
    1.38 +            }
    1.39 +
    1.40 +        }
    1.41 +    },
    1.42 +
    1.43 +    'MooTools': {
    1.44 +        test: function(win) {
    1.45 +            if(win.MooTools && win.MooTools.version) {
    1.46 +                return { version: win.MooTools.version };
    1.47 +            } else {
    1.48 +                return false;
    1.49 +            }
    1.50 +        }
    1.51 +    },
    1.52 +
    1.53 +    'YUI': {
    1.54 +        test: function(win) {
    1.55 +            if(win.YAHOO && win.YAHOO.VERSION) {
    1.56 +                return { version: win.YAHOO.VERSION };
    1.57 +            } else {
    1.58 +                return false;
    1.59 +            }
    1.60 +        }
    1.61 +    },
    1.62 +
    1.63 +    'Closure': {
    1.64 +        test: function(win) {
    1.65 +            if(win.goog) {
    1.66 +                return { version: '2.0' };
    1.67 +            }
    1.68 +            return false;
    1.69 +        }
    1.70 +    },
    1.71 +
    1.72 +    'Modernizr': {
    1.73 +        test: function(win) {
    1.74 +            if(win.Modernizr) {
    1.75 +                return { version: win.Modernizr._version };
    1.76 +            }
    1.77 +            return false;
    1.78 +        }
    1.79 +    },
    1.80 +
    1.81 +
    1.82 +};
    1.83 +
    1.84 +function testLibraries() {
    1.85 +  var win = unsafeWindow;
    1.86 +  var libraryList = [];
    1.87 +  for(var i in LD_tests) {
    1.88 +    var passed = LD_tests[i].test(win);
    1.89 +    if (passed) {
    1.90 +      let libraryInfo = {
    1.91 +        name: i,
    1.92 +        version: passed.version
    1.93 +      };
    1.94 +      libraryList.push(libraryInfo);
    1.95 +    }
    1.96 +  }
    1.97 +  self.postMessage(libraryList);
    1.98 +}
    1.99 +
   1.100 +testLibraries();
   1.101 \ No newline at end of file

mercurial