diff --git a/media/js/zamboni/browser.js b/media/js/zamboni/browser.js index 211c9b35b95..43764646af5 100644 --- a/media/js/zamboni/browser.js +++ b/media/js/zamboni/browser.js @@ -12,9 +12,11 @@ function BrowserUtils() { 'thunderbird': /Mozilla.*(Thunderbird|Shredder|Lanikai)\/([^\s*]*).*$/ }, osStrings = { - 'windows': 'Win32', + 'windows': 'Windows', 'mac': 'Mac', - 'linux': 'Linux' + 'linux': 'Linux', + 'android': 'Android', + 'maemo': 'Maemo' }; // browser detection @@ -37,19 +39,23 @@ function BrowserUtils() { for (i in osStrings) { if (osStrings.hasOwnProperty(i)) { pattern = osStrings[i]; - os[i] = navigator.platform.indexOf(pattern) != -1; + os[i] = navigator.userAgent.indexOf(pattern) != -1; if (os[i]) { platform = i; } } } - os['other'] = !platform; + if (!platform) { + os['other'] = !platform; + platform = "other"; + } return { "browser": browser, "browserVersion": browserVersion, "os": os, - "platform": platform + "platform": platform, + "platformName": gettext(osStrings[platform]) }; } @@ -103,9 +109,9 @@ var VersionCompare = { var pattern = /^([-\d]*)([^-\d]*)([-\d]*)(.*)$/, m = pattern.exec(p), r = { - 'numA' : parseInt(m[1]), + 'numA' : parseInt(m[1], 10), 'strB' : m[2], - 'numC' : parseInt(m[3]), + 'numC' : parseInt(m[3], 10), 'extraD' : m[4] }; if (r['strB'] == '+') { diff --git a/media/js/zamboni/mobile_buttons.js b/media/js/zamboni/mobile_buttons.js index 79a1cbd97ed..59905cab632 100644 --- a/media/js/zamboni/mobile_buttons.js +++ b/media/js/zamboni/mobile_buttons.js @@ -45,7 +45,7 @@ 'tooOld': format(gettext("Requires Newer Version of {0}"), z.appName), 'unreviewed': gettext("Unreviewed"), 'badApp': format(gettext("Not Available for {0}"), z.appName), - 'badPlatform': format(gettext("Not Available for {0}"), z.platform), + 'badPlatform': format(gettext("Not Available for {0}"), z.platformName), 'experimental': gettext("Experimental") }; @@ -85,7 +85,7 @@ versionPlatformCheck(); this.actionQueue.push([0, function() { - var href = activeInstaller.attr('href'); + var href = activeInstaller.attr('href'), hash = hashes[href], attr = self.attr, install = attr.search ? z.installSearch : z.installAddon; @@ -101,7 +101,7 @@ } // sort the actionQueue by priority - this.actionQueue.sort(function (a, b) {return b[0]-a[0]}); + this.actionQueue.sort(function (a, b) {return b[0]-a[0];}); }; function collectHashes() { @@ -126,7 +126,7 @@ // execute the next action if the current action returns true. if (result === true) { self.resumeInstall(); - }; + } } this.resumeInstall = function() { // moving on. @@ -166,8 +166,8 @@ var b = dom.self, attr = self.attr, classes = self.classes, - platformer = b.find('.platform').length, - platformSupported = (platformer && dom.buttons.filter("." + z.platform).length), + platformer = !!b.find('.platform').length, + platformSupported = !platformer || dom.buttons.filter("." + z.platform).length, appSupported = z.appMatchesUserAgent && attr.min && attr.max, olderBrowser, newerBrowser, canInstall = true; @@ -185,7 +185,7 @@ } else { if (!appSupported) errors.push("badApp"); if (!platformSupported) { - errors.push("badApp"); + errors.push("badPlatform"); dom.buttons.hide().eq(0).show(); } canInstall = false; @@ -215,7 +215,7 @@ } else { dom.buttons.click(startInstall); } - }; + } //and of course, initialize the button. this.init(); @@ -223,7 +223,7 @@ z.b = function() { new Button(this); - } + }; jQuery.fn.installButton = function() { return this.each(z.b);