Skip to content

Commit

Permalink
portability
Browse files Browse the repository at this point in the history
  • Loading branch information
tokuhirom committed Dec 10, 2011
1 parent 817bd20 commit eed29f9
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions mobileagent.js
@@ -1,5 +1,9 @@
(function () {

"use strict";

var global = this;

var DoCoMoRE = /^DoCoMo\/\d\.\d[ \/]/;
var JPhoneRE = /^(?:J-PHONE\/\d\.\d)/i;
var VodafoneRE = /^Vodafone\/\d\.\d/;
Expand Down Expand Up @@ -90,8 +94,8 @@ $E(MobileAgentDoCoMo, MobileAgentBase, {
if (this.parsed) {
return;
}
var ua = this.getUserAgent(),
x = ua.match(/^([^ ]+) (.+)$/);
var ua = this.getUserAgent();
var x = ua.match(/^([^ ]+) (.+)$/);
// if ($foma_or_comment && $foma_or_comment =~ s/^\((.*)\)$/$1/) {
if (x) {
if (x[2].match(/^\(.*\)$/)) {
Expand Down Expand Up @@ -389,7 +393,7 @@ $E(MobileAgentEZWeb, MobileAgentBase, {
return;
}
var ua = this.getUserAgent();
var matched = ua.match(/^KDDI\-([^ ]+) ([^ /]+)\/([^ ]+ [^ ]+) (.+)$/);
var matched = ua.match(/^KDDI\-([^ ]+) ([^ \/]+)\/([^ ]+ [^ ]+) (.+)$/);
if (matched) {
this.device_id = matched[1];
this.name = matched[2];
Expand Down Expand Up @@ -444,6 +448,12 @@ function getMobileAgent(req) {
}

// export functions
exports.getMobileAgent = getMobileAgent;
exports.detectCarrier = detectCarrier;

var MA;
if (typeof exports !== 'undefined') {
MA = exports;
} else {
MA = global.MobileAgent = {};
}
MA.getMobileAgent = getMobileAgent;
MA.detectCarrier = detectCarrier;
})();

0 comments on commit eed29f9

Please sign in to comment.