From a134e535c24e41cace9573390a8ba922eba869bf Mon Sep 17 00:00:00 2001 From: Richo Healey Date: Wed, 8 Oct 2014 21:55:00 -0700 Subject: [PATCH] Add browser.capabilities This removes some janky IE sniffing, and instead provides the beginning of a simple place to do capability based checks. --- core/main/client/browser.js | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/core/main/client/browser.js b/core/main/client/browser.js index ef7d4868f..89c0e787e 100644 --- a/core/main/client/browser.js +++ b/core/main/client/browser.js @@ -870,6 +870,19 @@ beef.browser = { return this.isO9_52() || this.isO9_60() || this.isO10() || this.isO11() || this.isO12(); }, + /** + * Returns a hash of string keys representing a given capability + * @example: beef.browser.capabilities()["navigator.plugins"] + */ + capabilities(): function() { + var out = {}; + var type = this.type(); + + out["navigator.plugins"] = (type.IE11 || !type.IE); + + return out; + } + /** * Returns the type of browser being used. * @example: beef.browser.type().IE6 @@ -1498,8 +1511,7 @@ beef.browser = { var quicktime = false; - // Not Internet Explorer - if (!this.type().IE) { + if (this.capabilities()["navigator.plugins"]) { for (i = 0; i < navigator.plugins.length; i++) { @@ -1509,7 +1521,7 @@ beef.browser = { } - // Internet Explorer + // Has navigator.plugins } else { try { @@ -1540,8 +1552,8 @@ beef.browser = { var realplayer = false; - // Not Internet Explorer - if (!this.type().IE) { + if (this.capabilities()["navigator.plugins"]) { + for (i = 0; i < navigator.plugins.length; i++) { @@ -1551,7 +1563,7 @@ beef.browser = { } - // Internet Explorer + // has navigator.plugins } else { var definedControls = [ @@ -1591,8 +1603,8 @@ beef.browser = { var wmp = false; - // Not Internet Explorer - if (!this.type().IE) { + if (this.capabilities()["navigator.plugins"]) { + for (i = 0; i < navigator.plugins.length; i++) { @@ -1602,7 +1614,7 @@ beef.browser = { } - // Internet Explorer + // Has navigator.plugins } else { try { @@ -1735,8 +1747,8 @@ beef.browser = { return r; }; - // Internet Explorer - if (this.isIE()) this.getPluginsIE(); + // Things lacking navigator.plugins + if (!this.capabilities()["navigator.plugins"]) this.getPluginsIE(); // All other browsers that support navigator.plugins else if (navigator.plugins && navigator.plugins.length > 0) {