-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPhoneNumberEditor.as
More file actions
156 lines (142 loc) · 2.81 KB
/
PhoneNumberEditor.as
File metadata and controls
156 lines (142 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
// *************************
// * COPYRIGHT
// * DEVELOPER: MTEAM ( info@mteamapp.com )
// * ALL RIGHTS RESERVED FOR MTEAM
// * YOU CAN'T USE THIS CODE IN ANY OTHER SOFTWARE FOR ANY PURPOSE
// * YOU CAN'T SHARE THIS CODE
// *************************
/***
* 1.1
* Debugged on 94/01/31
* 4/20/2015
*
*
*
*/
package
{
import flash.net.navigateToURL;
import flash.net.URLRequest;
public class PhoneNumberEditor
{
public static function call(phoneNumber:String):void
{
navigateToURL(new URLRequest('tel:'+phoneNumber));
}
/**this class will modify all numbers to standard style*/
public static function clearPhoneNumber(num:String):String
{
if(num==null)
{
return "false";
}
num = num.split(' ').join('').split('-').join('') ;
var minNum:String = '9127785180';
num = UnicodeStatic.numberCorrection(num);
if(num.length<minNum.length)
{
trace("The number is to short");
return 'false';
}
if(num.charAt(0)=='+')
{
num = '00'+num.substring(1);
}
if(isNaN(Number(num)))
{
trace('this is not a number');
return 'false';
}
if(num.charAt(0) == '0')
{
if(num.charAt(1) == '0')
{
//sample 00-----------
if(num.charAt(2) == '0')
{
//sample 000------
return 'false';
}
// ↓ this was 00989127785180 but other countries numbers can be larger than this. so I have to check Iran code first
else if(num.indexOf('0098')==0 && num.length<String('00989127785180').length)
{
//sample 00934
return 'false'
}
}
else if(num.charAt(1) == '9')
{
//sample 09----
if(num.charAt(2) == '8')
{
if(num.charAt(3) != '9')
{
//sample 00987----
return 'false';
}
else
{
//sample 0989423
num = '0'+num ;
}
}
else
{
//sample 09127785180
num = '0098'+num.substring(1);
}
}
else
{
//sample 04127785180
return 'false';//So the user must enter the 0 befor his number
}
}
else if(num.charAt(0) == '9')
{
//9--------
if(num.charAt(1) == '8')
{
//98-----
num = '00'+num;
}
else
{
//9------
num = '0098'+num ;
}
}
else
{
return 'false';
}
if(num.length<minNum.length)
{
trace('number is to short');
return 'false';
}
else if(num.length == minNum.length)
{
if(num.charAt(0) == '9')
{
num = '0098'+num;
}
else
{
trace('number is to short');
return 'false';
}
}
return num ;
}
/**+989125589669 → 09125589669*/
public static function IranMobile(mobile:String):String
{
if(mobile == null || mobile.length<9)
{
return '' ;
}
return '09'+mobile.substr(mobile.length-9);
}
}
}