michael@0: /* michael@0: The code in this file is adapted from the original michael@0: Library Detector add-on michael@0: (https://addons.mozilla.org/en-US/firefox/addon/library-detector/) written by michael@0: Paul Bakaus (http://paulbakaus.com/) and made available under the michael@0: MIT License (http://www.opensource.org/licenses/mit-license.php). michael@0: */ michael@0: michael@0: var LD_tests = { michael@0: michael@0: 'jQuery': { michael@0: test: function(win) { michael@0: var jq = win.jQuery || win.$ || win.$jq || win.$j; michael@0: if(jq && jq.fn && jq.fn.jquery) { michael@0: return { version: jq.fn.jquery }; michael@0: } else { michael@0: return false; michael@0: } michael@0: } michael@0: }, michael@0: michael@0: 'jQuery UI': { michael@0: //phonehome: 'http://jqueryui.com/phone_home', michael@0: test: function(win) { michael@0: michael@0: var jq = win.jQuery || win.$ || win.$jq || win.$j; michael@0: if(jq && jq.fn && jq.fn.jquery && jq.ui) { michael@0: michael@0: var plugins = 'accordion,datepicker,dialog,draggable,droppable,progressbar,resizable,selectable,slider,menu,grid,tabs'.split(','), concat = []; michael@0: 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)); }; michael@0: michael@0: return { version: jq.ui.version, details: concat.length ? 'Plugins used: '+concat.join(',') : '' }; michael@0: } else { michael@0: return false; michael@0: } michael@0: michael@0: } michael@0: }, michael@0: michael@0: 'MooTools': { michael@0: test: function(win) { michael@0: if(win.MooTools && win.MooTools.version) { michael@0: return { version: win.MooTools.version }; michael@0: } else { michael@0: return false; michael@0: } michael@0: } michael@0: }, michael@0: michael@0: 'YUI': { michael@0: test: function(win) { michael@0: if(win.YAHOO && win.YAHOO.VERSION) { michael@0: return { version: win.YAHOO.VERSION }; michael@0: } else { michael@0: return false; michael@0: } michael@0: } michael@0: }, michael@0: michael@0: 'Closure': { michael@0: test: function(win) { michael@0: if(win.goog) { michael@0: return { version: '2.0' }; michael@0: } michael@0: return false; michael@0: } michael@0: }, michael@0: michael@0: 'Modernizr': { michael@0: test: function(win) { michael@0: if(win.Modernizr) { michael@0: return { version: win.Modernizr._version }; michael@0: } michael@0: return false; michael@0: } michael@0: }, michael@0: michael@0: michael@0: }; michael@0: michael@0: function testLibraries() { michael@0: var win = unsafeWindow; michael@0: var libraryList = []; michael@0: for(var i in LD_tests) { michael@0: var passed = LD_tests[i].test(win); michael@0: if (passed) { michael@0: let libraryInfo = { michael@0: name: i, michael@0: version: passed.version michael@0: }; michael@0: libraryList.push(libraryInfo); michael@0: } michael@0: } michael@0: self.postMessage(libraryList); michael@0: } michael@0: michael@0: testLibraries();