Permalink
Browse files

Merge pull request #7319 from borjasalguero/remove_phonenumberjs_berlin

[Bug 811539] [SMS] Delete PhoneNumberJS once will be available in Gecko
  • Loading branch information...
2 parents d6516c8 + 40f20ef commit 3204365bfe5e927773b557ca46d1c5c485de56dd Francisco Borja Salguero Castellano committed Jan 9, 2013
Showing with 124 additions and 259 deletions.
  1. +0 −7 apps/sms/index.html
  2. +11 −23 apps/sms/js/contacts.js
  3. +0 −104 apps/sms/js/phoneNumberUtils.js
  4. +105 −120 apps/sms/js/sms.js
  5. +8 −5 apps/sms/js/utils.js
View
@@ -30,13 +30,6 @@
<script type="text/javascript" src="shared/js/custom_dialog.js"></script>
<script type="text/javascript" src="shared/js/desktop.js"></script>
<script type="text/javascript" src="shared/js/notification_helper.js"></script>
- <!-- Phone number library -->
- <script type="text/javascript" src="shared/js/phoneNumberJS/PhoneNumberMetaData.js"></script>
- <script type="text/javascript" src="shared/js/phoneNumberJS/PhoneNumber.js"></script>
- <script type="text/javascript" src="shared/js/phoneNumberJS/mcc_iso3166_table.js"></script>
- <script type="text/javascript" src="js/phoneNumberUtils.js"></script>
-
-
<!-- Specific code -->
<script type="text/javascript" src="js/blacklist.js"></script>
<script type="text/javascript" src="js/contacts.js"></script>
View
@@ -1,6 +1,8 @@
-/*
- * Contact Manager
-*/
+/* -*- Mode: js; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
+/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
+
+'use strict';
+
var ContactDataManager = {
contactData: {},
@@ -9,26 +11,12 @@ var ContactDataManager = {
if (!navigator.mozContacts) {
return;
}
- var numNormalized = PhoneNumberManager.getNormalizedNumber(number);
- // Based on E.164 (http://en.wikipedia.org/wiki/E.164)
- if (number.length < 8) {
- var options = {
- filterBy: ['tel'],
- filterOp: 'equals',
- filterValue: number
- };
- } else {
- // Based on E.164 (http://en.wikipedia.org/wiki/E.164)
- // Some locals added a '0' at the beggining (UK, Sweden...)
- if (numNormalized[0] == 0 || numNormalized[0] == '0') {
- var numNormalized = Number(numNormalized.toString().substr(1));
- }
- var options = {
- filterBy: ['tel'],
- filterOp: 'contains',
- filterValue: numNormalized
- };
- }
+ // Get contacts given a number
+ var options = {
+ filterBy: ['tel'],
+ filterOp: 'contains',
+ filterValue: number
+ };
var self = this;
var req = window.navigator.mozContacts.find(options);
req.onsuccess = function onsuccess() {
@@ -1,104 +0,0 @@
-/* Phone Number Manager for solving the country code format threadinf issue.
- * This Phone Number Manager required:
- * 1) PhoneNumberJS by Andreas Gal https://github.com/andreasgal/PhoneNumber.js
- * 2) mcc(Mobile Country Codes) - iso3166 country code table
- *
- * Methods in the PhoneNumberManager:
- * init - Setup mobile country code (mcc).
- *
- * getInternationalNum - Ruturn the phone number with international format.
- * If the second parameter is true, it will return original input number
- * while input number in invalid format, otherwise return null.
- *
- * getNationalNum - Ruturn the phone number with national format.
- * If the second parameter is true, it will return original input number
- * while input number in invalid format, otherwise return null.
- *
- * isValidNumber - We set a number string and it will check if the phone number
- * is valid or not.
- *
-*/
-// XXX Hack: If is the first time that we are launching SMS and there is any
-// problem with 'mozMobileConnection' we apply this as default
-// https://bugzilla.mozilla.org/show_bug.cgi?id=809057
-var PhoneNumberManager = {
- region: 'BR',
- init: function pnm_init(cb) {
- var self = this;
- // Method for retrieving the mcc
- function getLastMcc() {
- asyncStorage.getItem('mcc', function(mcc) {
- if (mcc) {
- self.region = MCC_ISO3166_TABLE[mcc];
- if (cb) {
- cb();
- }
- }
- });
- }
- // Update the MCC properly, retrieving for network
- var conn = window.navigator.mozMobileConnection;
- if (!!conn) {
- if (conn.voice.connected) {
- var currentMCC = conn.voice.network.mcc;
- // Update value of latest mcc retrieved
- asyncStorage.setItem('mcc', currentMCC);
- // Retrieve region
- self.region = MCC_ISO3166_TABLE[conn.voice.network.mcc];
- if (cb) {
- cb();
- }
- } else {
- getLastMcc();
- }
- } else {
- getLastMcc();
- }
- },
- getNormalizedNumber: function pnm_getNormalizedNumber(numInput) {
- if (!numInput) {
- return null;
- }
- try {
- var result = PhoneNumber.Parse(numInput, this.region);
- /// XXX HACK for getting smoke test working until having in Gecko
- if (result) {
- return result.nationalFormat.replace(/\s|\(|\)|-/g, '');
- } else {
- return numInput.replace(/\s|\(|\)|-/g, '');
- }
- } catch (e) {
- return numInput.replace(/\s|\(|\)|-/g, '');
- }
- },
- getNormalizedInternationalNumber: function pnm_getNormalizedNumber(numInput) {
- if (!numInput) {
- return null;
- }
- try {
- var result = PhoneNumber.Parse(numInput, this.region);
- // XXX HACK for getting smoke test working until having in Gecko
- if (result) {
- return result.internationalFormat.replace(/\s|\(|\)|-/g, '');
- } else {
- return numInput.replace(/\s|\(|\)|-/g, '');
- }
- } catch (e) {
- return numInput.replace(/\s|\(|\)|-/g, '');
- }
- },
- getOptionalNumbers: function pnm_getOptionalNumbers(numInput) {
- if (!numInput) {
- return [numInput];
- }
- try {
- /// XXX HACK for getting smoke test working until having in Gecko
- var nationalNum = this.getNormalizedNumber(numInput);
- var internationalNum = this.getNormalizedInternationalNumber(numInput);
- var internationalNumFormatted = internationalNum.replace('+', '00');
- return [nationalNum, internationalNum, internationalNumFormatted];
- } catch (e) {
- return [numInput];
- }
- }
-};
Oops, something went wrong.

0 comments on commit 3204365

Please sign in to comment.