Repository: cordova-plugin-globalization
Updated Branches:
  refs/heads/master f9583fe54 -> 77894697a


http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/77894697/www/firefoxos/l10n_date.js
----------------------------------------------------------------------
diff --git a/www/firefoxos/l10n_date.js b/www/firefoxos/l10n_date.js
index dcafba8..5e9d051 100644
--- a/www/firefoxos/l10n_date.js
+++ b/www/firefoxos/l10n_date.js
@@ -37,161 +37,161 @@
  * which is specific to Firefox -- no other browser is supported.
  */
 
-navigator.mozL10n.DateTimeFormat = function(locales, options) {
-  'use strict';
-
-  var _ = navigator.mozL10n.get;
-
-  // 
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleFormat
-  function localeFormat(d, format) {
-    var tokens = format.match(/(%E.|%O.|%.)/g);
-
-    for (var i = 0; tokens && i < tokens.length; i++) {
-      var value = '';
-
-      // http://pubs.opengroup.org/onlinepubs/007908799/xsh/strftime.html
-      switch (tokens[i]) {
-        // localized day/month names
-        case '%a':
-          value = _('weekday-' + d.getDay() + '-short');
-          break;
-        case '%A':
-          value = _('weekday-' + d.getDay() + '-long');
-          break;
-        case '%b':
-        case '%h':
-          value = _('month-' + d.getMonth() + '-short');
-          break;
-        case '%B':
-          value = _('month-' + d.getMonth() + '-long');
-          break;
-        case '%Eb':
-          value = _('month-' + d.getMonth() + '-genitive');
-          break;
-
-        // like %H, but in 12-hour format and without any leading zero
-        case '%I':
-          value = d.getHours() % 12 || 12;
-          break;
-
-        // like %d, without any leading zero
-        case '%e':
-          value = d.getDate();
-          break;
-
-        // %p: 12 hours format (AM/PM)
-        case '%p':
-          value = d.getHours() < 12 ? _('time_am') : _('time_pm');
-          break;
-
-        // localized date/time strings
-        case '%c':
-        case '%x':
-        case '%X':
-          // ensure the localized format string doesn't contain any %c|%x|%X
-          var tmp = _('dateTimeFormat_' + tokens[i]);
-          if (tmp && !(/(%c|%x|%X)/).test(tmp)) {
-            value = localeFormat(d, tmp);
-          }
-          break;
-
-        // other tokens don't require any localization
-      }
-
-      format = format.replace(tokens[i], value || d.toLocaleFormat(tokens[i]));
+navigator.mozL10n.DateTimeFormat = function (locales, options) {
+    'use strict';
+
+    var _ = navigator.mozL10n.get;
+
+    // 
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Date/toLocaleFormat
+    function localeFormat (d, format) {
+        var tokens = format.match(/(%E.|%O.|%.)/g);
+
+        for (var i = 0; tokens && i < tokens.length; i++) {
+            var value = '';
+
+            // http://pubs.opengroup.org/onlinepubs/007908799/xsh/strftime.html
+            switch (tokens[i]) {
+            // localized day/month names
+            case '%a':
+                value = _('weekday-' + d.getDay() + '-short');
+                break;
+            case '%A':
+                value = _('weekday-' + d.getDay() + '-long');
+                break;
+            case '%b':
+            case '%h':
+                value = _('month-' + d.getMonth() + '-short');
+                break;
+            case '%B':
+                value = _('month-' + d.getMonth() + '-long');
+                break;
+            case '%Eb':
+                value = _('month-' + d.getMonth() + '-genitive');
+                break;
+
+            // like %H, but in 12-hour format and without any leading zero
+            case '%I':
+                value = d.getHours() % 12 || 12;
+                break;
+
+            // like %d, without any leading zero
+            case '%e':
+                value = d.getDate();
+                break;
+
+            // %p: 12 hours format (AM/PM)
+            case '%p':
+                value = d.getHours() < 12 ? _('time_am') : _('time_pm');
+                break;
+
+            // localized date/time strings
+            case '%c':
+            case '%x':
+            case '%X':
+            // ensure the localized format string doesn't contain any %c|%x|%X
+                var tmp = _('dateTimeFormat_' + tokens[i]);
+                if (tmp && !(/(%c|%x|%X)/).test(tmp)) {
+                    value = localeFormat(d, tmp);
+                }
+                break;
+
+            // other tokens don't require any localization
+            }
+
+            format = format.replace(tokens[i], value || 
d.toLocaleFormat(tokens[i]));
+        }
+
+        return format;
     }
 
-    return format;
-  }
-
-  /**
-   * Returns the parts of a number of seconds
-   */
-  function relativeParts(seconds) {
-    seconds = Math.abs(seconds);
-    var descriptors = {};
-    var units = [
-      'years', 86400 * 365,
-      'months', 86400 * 30,
-      'weeks', 86400 * 7,
-      'days', 86400,
-      'hours', 3600,
-      'minutes', 60
-    ];
-
-    if (seconds < 60) {
-      return {
-        minutes: Math.round(seconds / 60)
-      };
+    /**
+    * Returns the parts of a number of seconds
+    */
+    function relativeParts (seconds) {
+        seconds = Math.abs(seconds);
+        var descriptors = {};
+        var units = [
+            'years', 86400 * 365,
+            'months', 86400 * 30,
+            'weeks', 86400 * 7,
+            'days', 86400,
+            'hours', 3600,
+            'minutes', 60
+        ];
+
+        if (seconds < 60) {
+            return {
+                minutes: Math.round(seconds / 60)
+            };
+        }
+
+        for (var i = 0, uLen = units.length; i < uLen; i += 2) {
+            var value = units[i + 1];
+            if (seconds >= value) {
+                descriptors[units[i]] = Math.floor(seconds / value);
+                seconds -= descriptors[units[i]] * value;
+            }
+        }
+        return descriptors;
     }
 
-    for (var i = 0, uLen = units.length; i < uLen; i += 2) {
-      var value = units[i + 1];
-      if (seconds >= value) {
-        descriptors[units[i]] = Math.floor(seconds / value);
-        seconds -= descriptors[units[i]] * value;
-      }
-    }
-    return descriptors;
-  }
-
-  /**
-   * Returns a translated string which respresents the
-   * relative time before or after a date.
-   * @param {String|Date} time before/after the currentDate.
-   * @param {String} useCompactFormat whether to use a compact display format.
-   * @param {Number} maxDiff returns a formatted date if the diff is greater.
-   */
-  function prettyDate(time, useCompactFormat, maxDiff) {
-    maxDiff = maxDiff || 86400 * 10; // default = 10 days
-
-    switch (time.constructor) {
-      case String: // timestamp
-        time = parseInt(time);
-        break;
-      case Date:
-        time = time.getTime();
-        break;
-    }
-
-    var secDiff = (Date.now() - time) / 1000;
-    if (isNaN(secDiff)) {
-      return _('incorrectDate');
-    }
-
-    if (Math.abs(secDiff) > 60) {
-      // round milliseconds up if difference is over 1 minute so the result is
-      // closer to what the user would expect (1h59m59s300ms diff should return
-      // "in 2 hours" instead of "in an hour")
-      secDiff = secDiff > 0 ? Math.ceil(secDiff) : Math.floor(secDiff);
+    /**
+    * Returns a translated string which respresents the
+    * relative time before or after a date.
+    * @param {String|Date} time before/after the currentDate.
+    * @param {String} useCompactFormat whether to use a compact display format.
+    * @param {Number} maxDiff returns a formatted date if the diff is greater.
+    */
+    function prettyDate (time, useCompactFormat, maxDiff) {
+        maxDiff = maxDiff || 86400 * 10; // default = 10 days
+
+        switch (time.constructor) {
+        case String: // timestamp
+            time = parseInt(time);
+            break;
+        case Date:
+            time = time.getTime();
+            break;
+        }
+
+        var secDiff = (Date.now() - time) / 1000;
+        if (isNaN(secDiff)) {
+            return _('incorrectDate');
+        }
+
+        if (Math.abs(secDiff) > 60) {
+            // round milliseconds up if difference is over 1 minute so the 
result is
+            // closer to what the user would expect (1h59m59s300ms diff should 
return
+            // "in 2 hours" instead of "in an hour")
+            secDiff = secDiff > 0 ? Math.ceil(secDiff) : Math.floor(secDiff);
+        }
+
+        if (secDiff > maxDiff) {
+            return localeFormat(new Date(time), '%x');
+        }
+
+        var f = useCompactFormat ? '-short' : '-long';
+        var parts = relativeParts(secDiff);
+
+        var affix = secDiff >= 0 ? '-ago' : '-until';
+        for (var i in parts) {
+            return _(i + affix + f, { value: parts[i] });
+        }
     }
 
-    if (secDiff > maxDiff) {
-      return localeFormat(new Date(time), '%x');
-    }
-
-    var f = useCompactFormat ? '-short' : '-long';
-    var parts = relativeParts(secDiff);
-
-    var affix = secDiff >= 0 ? '-ago' : '-until';
-    for (var i in parts) {
-      return _(i + affix + f, { value: parts[i]});
-    }
-  }
-
-  // API
-  return {
-    localeDateString: function localeDateString(d) {
-      return localeFormat(d, '%x');
-    },
-    localeTimeString: function localeTimeString(d) {
-      return localeFormat(d, '%X');
-    },
-    localeString: function localeString(d) {
-      return localeFormat(d, '%c');
-    },
-    localeFormat: localeFormat,
-    fromNow: prettyDate,
-    relativeParts: relativeParts
-  };
+    // API
+    return {
+        localeDateString: function localeDateString (d) {
+            return localeFormat(d, '%x');
+        },
+        localeTimeString: function localeTimeString (d) {
+            return localeFormat(d, '%X');
+        },
+        localeString: function localeString (d) {
+            return localeFormat(d, '%c');
+        },
+        localeFormat: localeFormat,
+        fromNow: prettyDate,
+        relativeParts: relativeParts
+    };
 };

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/77894697/www/globalization.js
----------------------------------------------------------------------
diff --git a/www/globalization.js b/www/globalization.js
index aa5f60c..476cfc5 100644
--- a/www/globalization.js
+++ b/www/globalization.js
@@ -19,8 +19,8 @@
  *
 */
 
-var argscheck = require('cordova/argscheck'),
-    exec = require('cordova/exec');
+var argscheck = require('cordova/argscheck');
+var exec = require('cordova/exec');
 
 var globalization = {
 
@@ -41,349 +41,344 @@ var globalization = {
 *    globalization.getPreferredLanguage(function (language) {alert('language:' 
+ language.value + '\n');},
 *                                function () {});
 */
-getPreferredLanguage:function(successCB, failureCB) {
-    argscheck.checkArgs('fF', 'Globalization.getPreferredLanguage', arguments);
-    exec(successCB, failureCB, "Globalization","getPreferredLanguage", []);
-},
+    getPreferredLanguage: function (successCB, failureCB) {
+        argscheck.checkArgs('fF', 'Globalization.getPreferredLanguage', 
arguments);
+        exec(successCB, failureCB, 'Globalization', 'getPreferredLanguage', 
[]);
+    },
 
-/**
-* Returns the string identifier for the client's current locale setting.
-* It returns the locale identifier string to the successCB callback with a
-* properties object as a parameter. If there is an error getting the locale,
-* then the errorCB callback is invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {String}: The locale identifier
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-*    globalization.getLocaleName(function (locale) {alert('locale:' + 
locale.value + '\n');},
-*                                function () {});
-*/
-getLocaleName:function(successCB, failureCB) {
-    argscheck.checkArgs('fF', 'Globalization.getLocaleName', arguments);
-    exec(successCB, failureCB, "Globalization","getLocaleName", []);
-},
+    /**
+    * Returns the string identifier for the client's current locale setting.
+    * It returns the locale identifier string to the successCB callback with a
+    * properties object as a parameter. If there is an error getting the 
locale,
+    * then the errorCB callback is invoked.
+    *
+    * @param {Function} successCB
+    * @param {Function} errorCB
+    *
+    * @return Object.value {String}: The locale identifier
+    *
+    * @error GlobalizationError.UNKNOWN_ERROR
+    *
+    * Example
+    *    globalization.getLocaleName(function (locale) {alert('locale:' + 
locale.value + '\n');},
+    *                                function () {});
+    */
+    getLocaleName: function (successCB, failureCB) {
+        argscheck.checkArgs('fF', 'Globalization.getLocaleName', arguments);
+        exec(successCB, failureCB, 'Globalization', 'getLocaleName', []);
+    },
 
+    /**
+    * Returns a date formatted as a string according to the client's user 
preferences and
+    * calendar using the time zone of the client. It returns the formatted 
date string to the
+    * successCB callback with a properties object as a parameter. If there is 
an error
+    * formatting the date, then the errorCB callback is invoked.
+    *
+    * The defaults are: formatLenght="short" and selector="date and time"
+    *
+    * @param {Date} date
+    * @param {Function} successCB
+    * @param {Function} errorCB
+    * @param {Object} options {optional}
+    *            formatLength {String}: 'short', 'medium', 'long', or 'full'
+    *            selector {String}: 'date', 'time', or 'date and time'
+    *
+    * @return Object.value {String}: The localized date string
+    *
+    * @error GlobalizationError.FORMATTING_ERROR
+    *
+    * Example
+    *    globalization.dateToString(new Date(),
+    *                function (date) {alert('date:' + date.value + '\n');},
+    *                function (errorCode) {alert(errorCode);},
+    *                {formatLength:'short'});
+    */
+    dateToString: function (date, successCB, failureCB, options) {
+        argscheck.checkArgs('dfFO', 'Globalization.dateToString', arguments);
+        var dateValue = date.valueOf();
+        exec(successCB, failureCB, 'Globalization', 'dateToString', [{'date': 
dateValue, 'options': options}]);
+    },
 
-/**
-* Returns a date formatted as a string according to the client's user 
preferences and
-* calendar using the time zone of the client. It returns the formatted date 
string to the
-* successCB callback with a properties object as a parameter. If there is an 
error
-* formatting the date, then the errorCB callback is invoked.
-*
-* The defaults are: formatLenght="short" and selector="date and time"
-*
-* @param {Date} date
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-*            formatLength {String}: 'short', 'medium', 'long', or 'full'
-*            selector {String}: 'date', 'time', or 'date and time'
-*
-* @return Object.value {String}: The localized date string
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-*    globalization.dateToString(new Date(),
-*                function (date) {alert('date:' + date.value + '\n');},
-*                function (errorCode) {alert(errorCode);},
-*                {formatLength:'short'});
-*/
-dateToString:function(date, successCB, failureCB, options) {
-    argscheck.checkArgs('dfFO', 'Globalization.dateToString', arguments);
-    var dateValue = date.valueOf();
-    exec(successCB, failureCB, "Globalization", "dateToString", [{"date": 
dateValue, "options": options}]);
-},
+    /**
+    * Parses a date formatted as a string according to the client's user
+    * preferences and calendar using the time zone of the client and returns
+    * the corresponding date object. It returns the date to the successCB
+    * callback with a properties object as a parameter. If there is an error
+    * parsing the date string, then the errorCB callback is invoked.
+    *
+    * The defaults are: formatLength="short" and selector="date and time"
+    *
+    * @param {String} dateString
+    * @param {Function} successCB
+    * @param {Function} errorCB
+    * @param {Object} options {optional}
+    *            formatLength {String}: 'short', 'medium', 'long', or 'full'
+    *            selector {String}: 'date', 'time', or 'date and time'
+    *
+    * @return    Object.year {Number}: The four digit year
+    *            Object.month {Number}: The month from (0 - 11)
+    *            Object.day {Number}: The day from (1 - 31)
+    *            Object.hour {Number}: The hour from (0 - 23)
+    *            Object.minute {Number}: The minute from (0 - 59)
+    *            Object.second {Number}: The second from (0 - 59)
+    *            Object.millisecond {Number}: The milliseconds (from 0 - 999),
+    *                                        not available on all platforms
+    *
+    * @error GlobalizationError.PARSING_ERROR
+    *
+    * Example
+    *    globalization.stringToDate('4/11/2011',
+    *                function (date) { alert('Month:' + date.month + '\n' +
+    *                    'Day:' + date.day + '\n' +
+    *                    'Year:' + date.year + '\n');},
+    *                function (errorCode) {alert(errorCode);},
+    *                {selector:'date'});
+    */
+    stringToDate: function (dateString, successCB, failureCB, options) {
+        argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
+        exec(successCB, failureCB, 'Globalization', 'stringToDate', 
[{'dateString': dateString, 'options': options}]);
+    },
 
+    /**
+    * Returns a pattern string for formatting and parsing dates according to 
the client's
+    * user preferences. It returns the pattern to the successCB callback with a
+    * properties object as a parameter. If there is an error obtaining the 
pattern,
+    * then the errorCB callback is invoked.
+    *
+    * The defaults are: formatLength="short" and selector="date and time"
+    *
+    * @param {Function} successCB
+    * @param {Function} errorCB
+    * @param {Object} options {optional}
+    *            formatLength {String}: 'short', 'medium', 'long', or 'full'
+    *            selector {String}: 'date', 'time', or 'date and time'
+    *
+    * @return    Object.pattern {String}: The date and time pattern for 
formatting and parsing dates.
+    *                                    The patterns follow Unicode Technical 
Standard #35
+    *                                    
http://unicode.org/reports/tr35/tr35-4.html
+    *            Object.timezone {String}: The abbreviated name of the time 
zone on the client
+    *            Object.utc_offset {Number}: The current difference in seconds 
between the client's
+    *                                        time zone and coordinated 
universal time.
+    *            Object.dst_offset {Number}: The current daylight saving time 
offset in seconds
+    *                                        between the client's non-daylight 
saving's time zone
+    *                                        and the client's daylight 
saving's time zone.
+    *
+    * @error GlobalizationError.PATTERN_ERROR
+    *
+    * Example
+    *    globalization.getDatePattern(
+    *                function (date) {alert('pattern:' + date.pattern + 
'\n');},
+    *                function () {},
+    *                {formatLength:'short'});
+    */
+    getDatePattern: function (successCB, failureCB, options) {
+        argscheck.checkArgs('fFO', 'Globalization.getDatePattern', arguments);
+        exec(successCB, failureCB, 'Globalization', 'getDatePattern', 
[{'options': options}]);
+    },
 
-/**
-* Parses a date formatted as a string according to the client's user
-* preferences and calendar using the time zone of the client and returns
-* the corresponding date object. It returns the date to the successCB
-* callback with a properties object as a parameter. If there is an error
-* parsing the date string, then the errorCB callback is invoked.
-*
-* The defaults are: formatLength="short" and selector="date and time"
-*
-* @param {String} dateString
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-*            formatLength {String}: 'short', 'medium', 'long', or 'full'
-*            selector {String}: 'date', 'time', or 'date and time'
-*
-* @return    Object.year {Number}: The four digit year
-*            Object.month {Number}: The month from (0 - 11)
-*            Object.day {Number}: The day from (1 - 31)
-*            Object.hour {Number}: The hour from (0 - 23)
-*            Object.minute {Number}: The minute from (0 - 59)
-*            Object.second {Number}: The second from (0 - 59)
-*            Object.millisecond {Number}: The milliseconds (from 0 - 999),
-*                                        not available on all platforms
-*
-* @error GlobalizationError.PARSING_ERROR
-*
-* Example
-*    globalization.stringToDate('4/11/2011',
-*                function (date) { alert('Month:' + date.month + '\n' +
-*                    'Day:' + date.day + '\n' +
-*                    'Year:' + date.year + '\n');},
-*                function (errorCode) {alert(errorCode);},
-*                {selector:'date'});
-*/
-stringToDate:function(dateString, successCB, failureCB, options) {
-    argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
-    exec(successCB, failureCB, "Globalization", "stringToDate", 
[{"dateString": dateString, "options": options}]);
-},
+    /**
+    * Returns an array of either the names of the months or days of the week
+    * according to the client's user preferences and calendar. It returns the 
array of names to the
+    * successCB callback with a properties object as a parameter. If there is 
an error obtaining the
+    * names, then the errorCB callback is invoked.
+    *
+    * The defaults are: type="wide" and item="months"
+    *
+    * @param {Function} successCB
+    * @param {Function} errorCB
+    * @param {Object} options {optional}
+    *            type {String}: 'narrow' or 'wide'
+    *            item {String}: 'months', or 'days'
+    *
+    * @return Object.value {Array{String}}: The array of names starting from 
either
+    *                                        the first month in the year or the
+    *                                        first day of the week.
+    * @error GlobalizationError.UNKNOWN_ERROR
+    *
+    * Example
+    *    globalization.getDateNames(function (names) {
+    *        for(var i = 0; i < names.value.length; i++) {
+    *            alert('Month:' + names.value[i] + '\n');}},
+    *        function () {});
+    */
+    getDateNames: function (successCB, failureCB, options) {
+        argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
+        exec(successCB, failureCB, 'Globalization', 'getDateNames', 
[{'options': options}]);
+    },
 
+    /**
+    * Returns whether daylight savings time is in effect for a given date 
using the client's
+    * time zone and calendar. It returns whether or not daylight savings time 
is in effect
+    * to the successCB callback with a properties object as a parameter. If 
there is an error
+    * reading the date, then the errorCB callback is invoked.
+    *
+    * @param {Date} date
+    * @param {Function} successCB
+    * @param {Function} errorCB
+    *
+    * @return Object.dst {Boolean}: The value "true" indicates that daylight 
savings time is
+    *                                in effect for the given date and "false" 
indicate that it is not.
+    *
+    * @error GlobalizationError.UNKNOWN_ERROR
+    *
+    * Example
+    *    globalization.isDayLightSavingsTime(new Date(),
+    *                function (date) {alert('dst:' + date.dst + '\n');}
+    *                function () {});
+    */
+    isDayLightSavingsTime: function (date, successCB, failureCB) {
+        argscheck.checkArgs('dfF', 'Globalization.isDayLightSavingsTime', 
arguments);
+        var dateValue = date.valueOf();
+        exec(successCB, failureCB, 'Globalization', 'isDayLightSavingsTime', 
[{'date': dateValue}]);
+    },
 
-/**
-* Returns a pattern string for formatting and parsing dates according to the 
client's
-* user preferences. It returns the pattern to the successCB callback with a
-* properties object as a parameter. If there is an error obtaining the pattern,
-* then the errorCB callback is invoked.
-*
-* The defaults are: formatLength="short" and selector="date and time"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-*            formatLength {String}: 'short', 'medium', 'long', or 'full'
-*            selector {String}: 'date', 'time', or 'date and time'
-*
-* @return    Object.pattern {String}: The date and time pattern for formatting 
and parsing dates.
-*                                    The patterns follow Unicode Technical 
Standard #35
-*                                    
http://unicode.org/reports/tr35/tr35-4.html
-*            Object.timezone {String}: The abbreviated name of the time zone 
on the client
-*            Object.utc_offset {Number}: The current difference in seconds 
between the client's
-*                                        time zone and coordinated universal 
time.
-*            Object.dst_offset {Number}: The current daylight saving time 
offset in seconds
-*                                        between the client's non-daylight 
saving's time zone
-*                                        and the client's daylight saving's 
time zone.
-*
-* @error GlobalizationError.PATTERN_ERROR
-*
-* Example
-*    globalization.getDatePattern(
-*                function (date) {alert('pattern:' + date.pattern + '\n');},
-*                function () {},
-*                {formatLength:'short'});
-*/
-getDatePattern:function(successCB, failureCB, options) {
-    argscheck.checkArgs('fFO', 'Globalization.getDatePattern', arguments);
-    exec(successCB, failureCB, "Globalization", "getDatePattern", [{"options": 
options}]);
-},
+    /**
+    * Returns the first day of the week according to the client's user 
preferences and calendar.
+    * The days of the week are numbered starting from 1 where 1 is considered 
to be Sunday.
+    * It returns the day to the successCB callback with a properties object as 
a parameter.
+    * If there is an error obtaining the pattern, then the errorCB callback is 
invoked.
+    *
+    * @param {Function} successCB
+    * @param {Function} errorCB
+    *
+    * @return Object.value {Number}: The number of the first day of the week.
+    *
+    * @error GlobalizationError.UNKNOWN_ERROR
+    *
+    * Example
+    *    globalization.getFirstDayOfWeek(function (day)
+    *                { alert('Day:' + day.value + '\n');},
+    *                function () {});
+    */
+    getFirstDayOfWeek: function (successCB, failureCB) {
+        argscheck.checkArgs('fF', 'Globalization.getFirstDayOfWeek', 
arguments);
+        exec(successCB, failureCB, 'Globalization', 'getFirstDayOfWeek', []);
+    },
 
+    /**
+    * Returns a number formatted as a string according to the client's user 
preferences.
+    * It returns the formatted number string to the successCB callback with a 
properties object as a
+    * parameter. If there is an error formatting the number, then the errorCB 
callback is invoked.
+    *
+    * The defaults are: type="decimal"
+    *
+    * @param {Number} number
+    * @param {Function} successCB
+    * @param {Function} errorCB
+    * @param {Object} options {optional}
+    *            type {String}: 'decimal', "percent", or 'currency'
+    *
+    * @return Object.value {String}: The formatted number string.
+    *
+    * @error GlobalizationError.FORMATTING_ERROR
+    *
+    * Example
+    *    globalization.numberToString(3.25,
+    *                function (number) {alert('number:' + number.value + 
'\n');},
+    *                function () {},
+    *                {type:'decimal'});
+    */
+    numberToString: function (number, successCB, failureCB, options) {
+        argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
+        exec(successCB, failureCB, 'Globalization', 'numberToString', 
[{'number': number, 'options': options}]);
+    },
 
-/**
-* Returns an array of either the names of the months or days of the week
-* according to the client's user preferences and calendar. It returns the 
array of names to the
-* successCB callback with a properties object as a parameter. If there is an 
error obtaining the
-* names, then the errorCB callback is invoked.
-*
-* The defaults are: type="wide" and item="months"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-*            type {String}: 'narrow' or 'wide'
-*            item {String}: 'months', or 'days'
-*
-* @return Object.value {Array{String}}: The array of names starting from either
-*                                        the first month in the year or the
-*                                        first day of the week.
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-*    globalization.getDateNames(function (names) {
-*        for(var i = 0; i < names.value.length; i++) {
-*            alert('Month:' + names.value[i] + '\n');}},
-*        function () {});
-*/
-getDateNames:function(successCB, failureCB, options) {
-    argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
-    exec(successCB, failureCB, "Globalization", "getDateNames", [{"options": 
options}]);
-},
+    /**
+    * Parses a number formatted as a string according to the client's user 
preferences and
+    * returns the corresponding number. It returns the number to the successCB 
callback with a
+    * properties object as a parameter. If there is an error parsing the 
number string, then
+    * the errorCB callback is invoked.
+    *
+    * The defaults are: type="decimal"
+    *
+    * @param {String} numberString
+    * @param {Function} successCB
+    * @param {Function} errorCB
+    * @param {Object} options {optional}
+    *            type {String}: 'decimal', "percent", or 'currency'
+    *
+    * @return Object.value {Number}: The parsed number.
+    *
+    * @error GlobalizationError.PARSING_ERROR
+    *
+    * Example
+    *    globalization.stringToNumber('1234.56',
+    *                function (number) {alert('Number:' + number.value + 
'\n');},
+    *                function () { alert('Error parsing number');});
+    */
+    stringToNumber: function (numberString, successCB, failureCB, options) {
+        argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
+        exec(successCB, failureCB, 'Globalization', 'stringToNumber', 
[{'numberString': numberString, 'options': options}]);
+    },
 
-/**
-* Returns whether daylight savings time is in effect for a given date using 
the client's
-* time zone and calendar. It returns whether or not daylight savings time is 
in effect
-* to the successCB callback with a properties object as a parameter. If there 
is an error
-* reading the date, then the errorCB callback is invoked.
-*
-* @param {Date} date
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.dst {Boolean}: The value "true" indicates that daylight 
savings time is
-*                                in effect for the given date and "false" 
indicate that it is not.
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-*    globalization.isDayLightSavingsTime(new Date(),
-*                function (date) {alert('dst:' + date.dst + '\n');}
-*                function () {});
-*/
-isDayLightSavingsTime:function(date, successCB, failureCB) {
-    argscheck.checkArgs('dfF', 'Globalization.isDayLightSavingsTime', 
arguments);
-    var dateValue = date.valueOf();
-    exec(successCB, failureCB, "Globalization", "isDayLightSavingsTime", 
[{"date": dateValue}]);
-},
-
-/**
-* Returns the first day of the week according to the client's user preferences 
and calendar.
-* The days of the week are numbered starting from 1 where 1 is considered to 
be Sunday.
-* It returns the day to the successCB callback with a properties object as a 
parameter.
-* If there is an error obtaining the pattern, then the errorCB callback is 
invoked.
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return Object.value {Number}: The number of the first day of the week.
-*
-* @error GlobalizationError.UNKNOWN_ERROR
-*
-* Example
-*    globalization.getFirstDayOfWeek(function (day)
-*                { alert('Day:' + day.value + '\n');},
-*                function () {});
-*/
-getFirstDayOfWeek:function(successCB, failureCB) {
-    argscheck.checkArgs('fF', 'Globalization.getFirstDayOfWeek', arguments);
-    exec(successCB, failureCB, "Globalization", "getFirstDayOfWeek", []);
-},
-
-
-/**
-* Returns a number formatted as a string according to the client's user 
preferences.
-* It returns the formatted number string to the successCB callback with a 
properties object as a
-* parameter. If there is an error formatting the number, then the errorCB 
callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {Number} number
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-*            type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.value {String}: The formatted number string.
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-*    globalization.numberToString(3.25,
-*                function (number) {alert('number:' + number.value + '\n');},
-*                function () {},
-*                {type:'decimal'});
-*/
-numberToString:function(number, successCB, failureCB, options) {
-    argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
-    exec(successCB, failureCB, "Globalization", "numberToString", [{"number": 
number, "options": options}]);
-},
-
-/**
-* Parses a number formatted as a string according to the client's user 
preferences and
-* returns the corresponding number. It returns the number to the successCB 
callback with a
-* properties object as a parameter. If there is an error parsing the number 
string, then
-* the errorCB callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {String} numberString
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-*            type {String}: 'decimal', "percent", or 'currency'
-*
-* @return Object.value {Number}: The parsed number.
-*
-* @error GlobalizationError.PARSING_ERROR
-*
-* Example
-*    globalization.stringToNumber('1234.56',
-*                function (number) {alert('Number:' + number.value + '\n');},
-*                function () { alert('Error parsing number');});
-*/
-stringToNumber:function(numberString, successCB, failureCB, options) {
-    argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
-    exec(successCB, failureCB, "Globalization", "stringToNumber", 
[{"numberString": numberString, "options": options}]);
-},
+    /**
+    * Returns a pattern string for formatting and parsing numbers according to 
the client's user
+    * preferences. It returns the pattern to the successCB callback with a 
properties object as a
+    * parameter. If there is an error obtaining the pattern, then the errorCB 
callback is invoked.
+    *
+    * The defaults are: type="decimal"
+    *
+    * @param {Function} successCB
+    * @param {Function} errorCB
+    * @param {Object} options {optional}
+    *            type {String}: 'decimal', "percent", or 'currency'
+    *
+    * @return    Object.pattern {String}: The number pattern for formatting 
and parsing numbers.
+    *                                    The patterns follow Unicode Technical 
Standard #35.
+    *                                    
http://unicode.org/reports/tr35/tr35-4.html
+    *            Object.symbol {String}: The symbol to be used when formatting 
and parsing
+    *                                    e.g., percent or currency symbol.
+    *            Object.fraction {Number}: The number of fractional digits to 
use when parsing and
+    *                                    formatting numbers.
+    *            Object.rounding {Number}: The rounding increment to use when 
parsing and formatting.
+    *            Object.positive {String}: The symbol to use for positive 
numbers when parsing and formatting.
+    *            Object.negative: {String}: The symbol to use for negative 
numbers when parsing and formatting.
+    *            Object.decimal: {String}: The decimal symbol to use for 
parsing and formatting.
+    *            Object.grouping: {String}: The grouping symbol to use for 
parsing and formatting.
+    *
+    * @error GlobalizationError.PATTERN_ERROR
+    *
+    * Example
+    *    globalization.getNumberPattern(
+    *                function (pattern) {alert('Pattern:' + pattern.pattern + 
'\n');},
+    *                function () {});
+    */
+    getNumberPattern: function (successCB, failureCB, options) {
+        argscheck.checkArgs('fFO', 'Globalization.getNumberPattern', 
arguments);
+        exec(successCB, failureCB, 'Globalization', 'getNumberPattern', 
[{'options': options}]);
+    },
 
-/**
-* Returns a pattern string for formatting and parsing numbers according to the 
client's user
-* preferences. It returns the pattern to the successCB callback with a 
properties object as a
-* parameter. If there is an error obtaining the pattern, then the errorCB 
callback is invoked.
-*
-* The defaults are: type="decimal"
-*
-* @param {Function} successCB
-* @param {Function} errorCB
-* @param {Object} options {optional}
-*            type {String}: 'decimal', "percent", or 'currency'
-*
-* @return    Object.pattern {String}: The number pattern for formatting and 
parsing numbers.
-*                                    The patterns follow Unicode Technical 
Standard #35.
-*                                    
http://unicode.org/reports/tr35/tr35-4.html
-*            Object.symbol {String}: The symbol to be used when formatting and 
parsing
-*                                    e.g., percent or currency symbol.
-*            Object.fraction {Number}: The number of fractional digits to use 
when parsing and
-*                                    formatting numbers.
-*            Object.rounding {Number}: The rounding increment to use when 
parsing and formatting.
-*            Object.positive {String}: The symbol to use for positive numbers 
when parsing and formatting.
-*            Object.negative: {String}: The symbol to use for negative numbers 
when parsing and formatting.
-*            Object.decimal: {String}: The decimal symbol to use for parsing 
and formatting.
-*            Object.grouping: {String}: The grouping symbol to use for parsing 
and formatting.
-*
-* @error GlobalizationError.PATTERN_ERROR
-*
-* Example
-*    globalization.getNumberPattern(
-*                function (pattern) {alert('Pattern:' + pattern.pattern + 
'\n');},
-*                function () {});
-*/
-getNumberPattern:function(successCB, failureCB, options) {
-    argscheck.checkArgs('fFO', 'Globalization.getNumberPattern', arguments);
-    exec(successCB, failureCB, "Globalization", "getNumberPattern", 
[{"options": options}]);
-},
-
-/**
-* Returns a pattern string for formatting and parsing currency values 
according to the client's
-* user preferences and ISO 4217 currency code. It returns the pattern to the 
successCB callback with a
-* properties object as a parameter. If there is an error obtaining the 
pattern, then the errorCB
-* callback is invoked.
-*
-* @param {String} currencyCode
-* @param {Function} successCB
-* @param {Function} errorCB
-*
-* @return    Object.pattern {String}: The currency pattern for formatting and 
parsing currency values.
-*                                    The patterns follow Unicode Technical 
Standard #35
-*                                    
http://unicode.org/reports/tr35/tr35-4.html
-*            Object.code {String}: The ISO 4217 currency code for the pattern.
-*            Object.fraction {Number}: The number of fractional digits to use 
when parsing and
-*                                    formatting currency.
-*            Object.rounding {Number}: The rounding increment to use when 
parsing and formatting.
-*            Object.decimal: {String}: The decimal symbol to use for parsing 
and formatting.
-*            Object.grouping: {String}: The grouping symbol to use for parsing 
and formatting.
-*
-* @error GlobalizationError.FORMATTING_ERROR
-*
-* Example
-*    globalization.getCurrencyPattern('EUR',
-*                function (currency) {alert('Pattern:' + currency.pattern + 
'\n');}
-*                function () {});
-*/
-getCurrencyPattern:function(currencyCode, successCB, failureCB) {
-    argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', arguments);
-    exec(successCB, failureCB, "Globalization", "getCurrencyPattern", 
[{"currencyCode": currencyCode}]);
-}
+    /**
+    * Returns a pattern string for formatting and parsing currency values 
according to the client's
+    * user preferences and ISO 4217 currency code. It returns the pattern to 
the successCB callback with a
+    * properties object as a parameter. If there is an error obtaining the 
pattern, then the errorCB
+    * callback is invoked.
+    *
+    * @param {String} currencyCode
+    * @param {Function} successCB
+    * @param {Function} errorCB
+    *
+    * @return    Object.pattern {String}: The currency pattern for formatting 
and parsing currency values.
+    *                                    The patterns follow Unicode Technical 
Standard #35
+    *                                    
http://unicode.org/reports/tr35/tr35-4.html
+    *            Object.code {String}: The ISO 4217 currency code for the 
pattern.
+    *            Object.fraction {Number}: The number of fractional digits to 
use when parsing and
+    *                                    formatting currency.
+    *            Object.rounding {Number}: The rounding increment to use when 
parsing and formatting.
+    *            Object.decimal: {String}: The decimal symbol to use for 
parsing and formatting.
+    *            Object.grouping: {String}: The grouping symbol to use for 
parsing and formatting.
+    *
+    * @error GlobalizationError.FORMATTING_ERROR
+    *
+    * Example
+    *    globalization.getCurrencyPattern('EUR',
+    *                function (currency) {alert('Pattern:' + currency.pattern 
+ '\n');}
+    *                function () {});
+    */
+    getCurrencyPattern: function (currencyCode, successCB, failureCB) {
+        argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', 
arguments);
+        exec(successCB, failureCB, 'Globalization', 'getCurrencyPattern', 
[{'currencyCode': currencyCode}]);
+    }
 
 };
 

http://git-wip-us.apache.org/repos/asf/cordova-plugin-globalization/blob/77894697/www/ubuntu/globalization.js
----------------------------------------------------------------------
diff --git a/www/ubuntu/globalization.js b/www/ubuntu/globalization.js
index 6b423be..37d78cf 100644
--- a/www/ubuntu/globalization.js
+++ b/www/ubuntu/globalization.js
@@ -23,147 +23,136 @@ var exec = require('cordova/exec');
 var argscheck = require('cordova/argscheck');
 var GlobalizationError = require('./GlobalizationError');
 
-function convertStringToDateOptions(override) {
+function convertStringToDateOptions (override) {
     var options = { formatLength: 'short', selector: 'date and time' };
 
     if (override) {
         for (var key in options) {
-            if (!options.hasOwnProperty(key))
-                continue;
-            if (typeof(options[key]) !== typeof(override[key]))
-                continue;
+            if (!options.hasOwnProperty(key)) { continue; }
+            if (typeof (options[key]) !== typeof (override[key])) { continue; }
             options[key] = override[key];
         }
     }
-    var formats = ["short", "medium", "long", "full"];
-    var selectors = ["date", "time", "date and time"];
+    var formats = ['short', 'medium', 'long', 'full'];
+    var selectors = ['date', 'time', 'date and time'];
 
     options.formatLength = formats.indexOf(options.formatLength);
     options.selector = selectors.indexOf(options.selector);
-    //TODO: throw error
-    if (options.formatLength === -1)
-        options.formatLength = 0;
-    if (options.selector === -1)
-        options.selector = 0;
+    // TODO: throw error
+    if (options.formatLength === -1) { options.formatLength = 0; }
+    if (options.selector === -1) { options.selector = 0; }
 
     return options;
 }
 
-function convertStringToNumberOptions(override) {
+function convertStringToNumberOptions (override) {
     var options = { type: 'decimal' };
-    //TODO: make function
+    // TODO: make function
     if (override) {
         for (var key in options) {
-            if (!options.hasOwnProperty(key))
-                continue;
-            if (typeof(options[key]) !== typeof(override[key]))
-                continue;
+            if (!options.hasOwnProperty(key)) { continue; }
+            if (typeof (options[key]) !== typeof (override[key])) { continue; }
             options[key] = override[key];
         }
     }
 
     var types = [ 'decimal', 'percent', 'currency' ];
     options.type = types.indexOf(options.type);
-    if (options.type === -1)
-        options.type = 0;
+    if (options.type === -1) { options.type = 0; }
 
     return options;
 }
 
-function isInt(n) {
-   return n % 1 === 0;
+function isInt (n) {
+    return n % 1 === 0;
 }
 
 module.exports = {
-    isDayLightSavingsTime: function(date, successCB, failureCB) {
+    isDayLightSavingsTime: function (date, successCB, failureCB) {
         argscheck.checkArgs('dfF', 'Globalization.isDayLightSavingsTime', 
arguments);
 
-        exec(successCB, failureCB, "Globalization", "isDayLightSavingsTime", [ 
{ time_t: date.getTime() } ]);
+        exec(successCB, failureCB, 'Globalization', 'isDayLightSavingsTime', [ 
{ time_t: date.getTime() } ]);
     },
 
-    dateToString: function(date, successCB, failureCB, override) {
+    dateToString: function (date, successCB, failureCB, override) {
         argscheck.checkArgs('dfFO', 'Globalization.dateToString', arguments);
 
         var options = convertStringToDateOptions(override);
-        exec(successCB, failureCB, "Globalization", "dateToString",
-             [ { time_t: date.getTime(), formatLength: options.formatLength, 
selector: options.selector } ]);
+        exec(successCB, failureCB, 'Globalization', 'dateToString',
+            [ { time_t: date.getTime(), formatLength: options.formatLength, 
selector: options.selector } ]);
 
     },
 
-    stringToDate: function(dateString, successCB, failureCB, override) {
+    stringToDate: function (dateString, successCB, failureCB, override) {
         argscheck.checkArgs('sfFO', 'Globalization.stringToDate', arguments);
 
         var options = convertStringToDateOptions(override);
-        exec(successCB, failureCB, "Globalization", "stringToDate",
-             [ { dateString: dateString, formatLength: options.formatLength, 
selector: options.selector } ]);
+        exec(successCB, failureCB, 'Globalization', 'stringToDate',
+            [ { dateString: dateString, formatLength: options.formatLength, 
selector: options.selector } ]);
     },
 
-    getDateNames: function(successCB, failureCB, override) {
+    getDateNames: function (successCB, failureCB, override) {
         argscheck.checkArgs('fFO', 'Globalization.getDateNames', arguments);
 
         var options = { type: 'wide', item: 'months' };
 
         if (override) {
             for (var key in options) {
-                if (!options.hasOwnProperty(key))
-                    continue;
-                if (typeof(options[key]) !== typeof(override[key]))
-                    continue;
+                if (!options.hasOwnProperty(key)) { continue; }
+                if (typeof (options[key]) !== typeof (override[key])) { 
continue; }
                 options[key] = override[key];
             }
         }
 
-        var requests = ["days", "months"];
-        var formats = ["narrow", "wide"];
+        var requests = ['days', 'months'];
+        var formats = ['narrow', 'wide'];
 
         options.item = requests.indexOf(options.item);
         options.type = formats.indexOf(options.type);
 
-        //TODO: throw error
-        if (options.item === -1)
-            options.item = 0;
-        if (options.type === -1)
-            options.type = 0;
+        // TODO: throw error
+        if (options.item === -1) { options.item = 0; }
+        if (options.type === -1) { options.type = 0; }
 
-        exec(successCB, failureCB, "Globalization", "getDateNames", [ options 
]);
+        exec(successCB, failureCB, 'Globalization', 'getDateNames', [ options 
]);
     },
 
-    numberToString: function(number, successCB, failureCB, override) {
+    numberToString: function (number, successCB, failureCB, override) {
         argscheck.checkArgs('nfFO', 'Globalization.numberToString', arguments);
 
         var options = convertStringToNumberOptions(override);
 
-        exec(successCB, failureCB, "Globalization", "numberToString",
-             [ { type: options.type, isInt: isInt(number), number: number } ]);
+        exec(successCB, failureCB, 'Globalization', 'numberToString',
+            [ { type: options.type, isInt: isInt(number), number: number } ]);
     },
 
-    stringToNumber: function(numberString, successCB, failureCB, override) {
+    stringToNumber: function (numberString, successCB, failureCB, override) {
         argscheck.checkArgs('sfFO', 'Globalization.stringToNumber', arguments);
 
         var options = convertStringToNumberOptions(override);
-        exec(successCB, failureCB, "Globalization", "stringToNumber", [ 
options.type, numberString ]);
+        exec(successCB, failureCB, 'Globalization', 'stringToNumber', [ 
options.type, numberString ]);
     },
 
-    getDatePattern: function(successCB, failureCB, override) {
+    getDatePattern: function (successCB, failureCB, override) {
         argscheck.checkArgs('fFO', 'Globalization.getDatePattern', arguments);
 
         var options = convertStringToDateOptions(override);
-        exec(successCB, failureCB, "Globalization", "getDatePattern", [ 
options.formatLength, options.selector ]);
+        exec(successCB, failureCB, 'Globalization', 'getDatePattern', [ 
options.formatLength, options.selector ]);
     },
 
     getNumberPattern: function (successCB, failureCB, override) {
         argscheck.checkArgs('fFO', 'getNumberPattern', arguments);
 
         var options = convertStringToNumberOptions(override);
-        Cordova.exec(successCB, failureCB, "Globalization", 
"getNumberPattern", [ options.type ]);
+        Cordova.exec(successCB, failureCB, 'Globalization', 
'getNumberPattern', [ options.type ]);
     },
 
-    getCurrencyPattern: function(currencyCode, successCB, failureCB) {
+    getCurrencyPattern: function (currencyCode, successCB, failureCB) {
         argscheck.checkArgs('sfF', 'Globalization.getCurrencyPattern', 
arguments);
 
-        failureCB(new GlobalizationError(GlobalizationError.PATTERN_ERROR, 
"unimplemented"));
-        //exec(successCB, failureCB, "Globalization", "getCurrencyPattern", 
[{"currencyCode": currencyCode}]);
+        failureCB(new GlobalizationError(GlobalizationError.PATTERN_ERROR, 
'unimplemented'));
+        // exec(successCB, failureCB, "Globalization", "getCurrencyPattern", 
[{"currencyCode": currencyCode}]);
     }
 };
 
-require("cordova/exec/proxy").add("navigator.globalization", module.exports);
+require('cordova/exec/proxy').add('navigator.globalization', module.exports);


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cordova.apache.org
For additional commands, e-mail: commits-h...@cordova.apache.org

Reply via email to