forked from mozilla-b2g/gaia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webapi.js
1389 lines (1311 loc) · 32.5 KB
/
webapi.js
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
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- /
/* vim: set shiftwidth=2 tabstop=2 autoindent cindent expandtab: */
'use strict';
// navigator.mozContacts
(function(window) {
var navigator = window.navigator;
var contacts = [{
id: 0,
name: 'Andreas Gal',
familyName: ['Gal'],
givenName: ['Andreas'],
tel: ['123-4242-4242'],
email: ['[email protected]']
},
{
id: 1,
name: 'Coby Newman',
familyName: ['Newman'],
givenName: ['Coby'],
tel: ['1-823-949-7735'],
email: ['[email protected]']
},
{
id: 2,
name: 'Caesar Velasquez',
familyName: ['Velasquez'],
givenName: ['Caesar'],
tel: ['1-355-185-5419'],
email: ['[email protected]']
},
{
id: 3,
name: 'Hamilton Farrell',
familyName: ['Farrell'],
givenName: ['Hamilton'],
tel: ['1-682-456-9186'],
email: ['[email protected]']
},
{
id: 4,
name: 'Emery Livingston',
familyName: ['Livingston'],
givenName: ['Emery'],
tel: ['1-510-151-9801'],
email: ['[email protected]']
},
{
id: 5,
name: 'Griffith Heath',
familyName: ['Heath'],
givenName: ['Griffith'],
tel: ['1-800-719-3201'],
email: ['[email protected]']
},
{
id: 6,
name: 'Luke Stuart',
familyName: ['Stuart'],
givenName: ['Luke'],
tel: ['1-120-910-1976'],
email: ['[email protected]']
},
{
id: 7,
name: 'Brennan Love',
familyName: ['Love'],
givenName: ['Brennan'],
tel: ['1-724-155-2807'],
email: ['[email protected]']
},
{
id: 8,
name: 'Lamar Meadows',
familyName: ['Meadows'],
givenName: ['Lamar'],
tel: ['1-976-164-8769'],
email: ['[email protected]']
},
{
id: 9,
name: 'Erasmus Flynn',
familyName: ['Flynn'],
givenName: ['Erasmus'],
tel: ['1-488-678-3487'],
email: ['[email protected]']
},
{
id: 10,
name: 'Aladdin Ellison',
familyName: ['Ellison'],
givenName: ['Aladdin'],
tel: ['1-977-743-6797'],
email: ['[email protected]']
},
{
id: 11,
name: 'Valentine Rasmussen',
familyName: ['Rasmussen'],
givenName: ['Valentine'],
tel: ['1-265-504-2025'],
email: ['[email protected]']
},
{
id: 12,
name: 'Deacon Murphy',
familyName: ['Murphy'],
givenName: ['Deacon'],
tel: ['1-770-450-1221'],
email: ['[email protected]']
},
{
id: 13,
name: 'Paul Kennedy',
familyName: ['Kennedy'],
givenName: ['Paul'],
tel: ['1-689-891-3529'],
email: ['[email protected]']
},
{
id: 14,
name: 'Aaron Chase',
familyName: ['Chase'],
givenName: ['Aaron'],
tel: ['1-451-574-7937'],
email: ['[email protected]']
},
{
id: 15,
name: 'Geoffrey Dunn',
familyName: ['Dunn'],
givenName: ['Geoffrey'],
tel: ['1-924-387-2395'],
email: ['[email protected]']
},
{
id: 16,
name: 'Ashton Russo',
familyName: ['Russo'],
givenName: ['Ashton'],
tel: ['1-182-776-5600'],
email: ['[email protected]']
},
{
id: 17,
name: 'Owen Noble',
familyName: ['Noble'],
givenName: ['Owen'],
tel: ['1-463-693-1336'],
email: ['[email protected]']
},
{
id: 18,
name: 'Kamal Blake',
familyName: ['Blake'],
givenName: ['Kamal'],
tel: ['1-636-197-1985'],
email: ['[email protected]']
},
{
id: 19,
name: 'Tyrone Delaney',
familyName: ['Delaney'],
givenName: ['Tyrone'],
tel: ['1-886-920-6283'],
email: ['[email protected]']
},
{
id: 20,
name: 'Ciaran Sellers',
familyName: ['Sellers'],
givenName: ['Ciaran'],
tel: ['1-315-414-0323'],
email: ['[email protected]']
},
{
id: 21,
name: 'Bernard Alford',
familyName: ['Alford'],
givenName: ['Bernard'],
tel: ['1-430-958-2651'],
email: ['[email protected]']
},
{
id: 22,
name: 'Kamal Cote',
familyName: ['Cote'],
givenName: ['Kamal'],
tel: ['1-666-609-9141'],
email: ['[email protected]']
},
{
id: 23,
name: 'Lucius Mckee',
familyName: ['Mckee'],
givenName: ['Lucius'],
tel: ['1-224-590-6780'],
email: ['[email protected]']
},
{
id: 24,
name: 'Dale Coleman',
familyName: ['Coleman'],
givenName: ['Dale'],
tel: ['1-320-245-3036'],
email: ['[email protected]']
},
{
id: 25,
name: 'Kermit Nguyen',
familyName: ['Nguyen'],
givenName: ['Kermit'],
tel: ['1-247-825-8563'],
email: ['[email protected]']
},
{
id: 26,
name: 'Timon Horton',
familyName: ['Horton'],
givenName: ['Timon'],
tel: ['1-739-233-8981'],
email: ['[email protected]']
},
{
id: 27,
name: 'Dale Lamb',
familyName: ['Lamb'],
givenName: ['Dale'],
tel: ['1-640-507-8295'],
email: ['[email protected]']
},
{
id: 28,
name: 'Owen Acevedo',
familyName: ['Acevedo'],
givenName: ['Owen'],
tel: ['1-403-201-3170'],
email: ['[email protected]']
},
{
id: 29,
name: 'Richard Mckee',
familyName: ['Mckee'],
givenName: ['Richard'],
tel: ['1-783-513-0684'],
email: ['[email protected]']
},
{
id: 30,
name: 'Elijah Bass',
familyName: ['Bass'],
givenName: ['Elijah'],
tel: ['1-632-950-0553'],
email: ['[email protected]']
},
{
id: 31,
name: 'Barrett Wells',
familyName: ['Wells'],
givenName: ['Barrett'],
tel: ['1-112-180-5617'],
email: ['[email protected]']
},
{
id: 32,
name: 'Herman Meyer',
familyName: ['Meyer'],
givenName: ['Herman'],
tel: ['1-296-252-5507'],
email: ['[email protected]']
},
{
id: 33,
name: 'Ashton Hinton',
familyName: ['Hinton'],
givenName: ['Ashton'],
tel: ['1-695-256-8929'],
email: ['[email protected]']
},
{
id: 34,
name: 'Harrison Marsh',
familyName: ['Marsh'],
givenName: ['Harrison'],
tel: ['1-897-458-1730'],
email: ['[email protected]']
},
{
id: 35,
name: 'Benedict Santana',
familyName: ['Santana'],
givenName: ['Benedict'],
tel: ['1-565-457-4828'],
email: ['[email protected]']
},
{
id: 36,
name: 'David Church',
familyName: ['Church'],
givenName: ['David'],
tel: ['1-179-353-3314'],
email: ['[email protected]']
},
{
id: 37,
name: 'Colt Wolfe',
familyName: ['Wolfe'],
givenName: ['Colt'],
tel: ['1-587-970-8581'],
email: ['[email protected]']
},
{
id: 38,
name: 'Carlos Bishop',
familyName: ['Bishop'],
givenName: ['Carlos'],
tel: ['1-963-305-6702'],
email: ['[email protected]']
},
{
id: 39,
name: 'Dominic Ware',
familyName: ['Ware'],
givenName: ['Dominic'],
tel: ['1-609-458-5449'],
email: ['[email protected]']
},
{
id: 40,
name: 'Phillip Whitley',
familyName: ['Whitley'],
givenName: ['Phillip'],
tel: ['1-284-955-1766'],
email: ['[email protected]']
},
{
id: 41,
name: 'Valentine Sargent',
familyName: ['Sargent'],
givenName: ['Valentine'],
tel: ['1-346-890-6417'],
email: ['[email protected]']
},
{
id: 42,
name: 'Gabriel Huber',
familyName: ['Huber'],
givenName: ['Gabriel'],
tel: ['1-399-465-0589'],
email: ['[email protected]']
},
{
id: 43,
name: 'George Tyler',
familyName: ['Tyler'],
givenName: ['George'],
tel: ['1-739-571-2737'],
email: ['[email protected]']
},
{
id: 44,
name: 'Asher Carey',
familyName: ['Carey'],
givenName: ['Asher'],
tel: ['1-477-425-4723'],
email: ['[email protected]']
},
{
id: 45,
name: 'Anthony Solomon',
familyName: ['Solomon'],
givenName: ['Anthony'],
tel: ['1-570-753-4296'],
email: ['[email protected]']
},
{
id: 46,
name: 'Griffith Fuller',
familyName: ['Fuller'],
givenName: ['Griffith'],
tel: ['1-779-242-5342'],
email: ['[email protected]']
},
{
id: 47,
name: 'Beau Brewer',
familyName: ['Brewer'],
givenName: ['Beau'],
tel: ['1-664-184-7334'],
email: ['[email protected]']
},
{
id: 48,
name: 'Jordan Campbell',
familyName: ['Campbell'],
givenName: ['Jordan'],
tel: ['1-593-938-2525'],
email: ['Curae;[email protected]']
},
{
id: 49,
name: 'Cyrus Cabrera',
familyName: ['Cabrera'],
givenName: ['Cyrus'],
tel: ['1-915-748-1349'],
email: ['[email protected]']
},
{
id: 50,
name: 'Hamilton Boone',
familyName: ['Boone'],
givenName: ['Hamilton'],
tel: ['1-278-421-9845'],
email: ['[email protected]']
},
{
id: 51,
name: 'Wallace Donovan',
familyName: ['Donovan'],
givenName: ['Wallace'],
tel: ['1-940-175-9334'],
email: ['[email protected]']
},
{
id: 52,
name: 'Kirk Buckley',
familyName: ['Buckley'],
givenName: ['Kirk'],
tel: ['1-283-177-6304'],
email: ['[email protected]']
},
{
id: 53,
name: 'Simon Hall',
familyName: ['Hall'],
givenName: ['Simon'],
tel: ['1-269-202-5174'],
email: ['[email protected]']
},
{
id: 54,
name: 'Trevor Rush',
familyName: ['Rush'],
givenName: ['Trevor'],
tel: ['1-865-595-9074'],
email: ['[email protected]']
},
{
id: 55,
name: 'Todd Mccormick',
familyName: ['Mccormick'],
givenName: ['Todd'],
tel: ['1-398-916-3514'],
email: ['[email protected]']
},
{
id: 56,
name: 'Yuli Gay',
familyName: ['Gay'],
givenName: ['Yuli'],
tel: ['1-198-196-4256'],
email: ['[email protected]']
},
{
id: 57,
name: 'Joseph Frazier',
familyName: ['Frazier'],
givenName: ['Joseph'],
tel: ['1-969-410-7180'],
email: ['[email protected]']
},
{
id: 58,
name: 'Ali Chase',
familyName: ['Chase'],
givenName: ['Ali'],
tel: ['1-598-924-6112'],
email: ['[email protected]']
},
{
id: 59,
name: 'Guy Simpson',
familyName: ['Simpson'],
givenName: ['Guy'],
tel: ['1-558-377-3714'],
email: ['[email protected]']
},
{
id: 60,
name: 'Ivan Wynn',
familyName: ['Wynn'],
givenName: ['Ivan'],
tel: ['1-274-885-0477'],
email: ['[email protected]']
},
{
id: 61,
name: 'Preston Carpenter',
familyName: ['Carpenter'],
givenName: ['Preston'],
tel: ['1-758-120-5270'],
email: ['[email protected]']
},
{
id: 62,
name: 'Demetrius Santos',
familyName: ['Santos'],
givenName: ['Demetrius'],
tel: ['1-913-961-7009'],
email: ['[email protected]']
},
{
id: 63,
name: 'Dale Franklin',
familyName: ['Franklin'],
givenName: ['Dale'],
tel: ['1-443-971-0116'],
email: ['[email protected]']
},
{
id: 64,
name: 'Abraham Randolph',
familyName: ['Randolph'],
givenName: ['Abraham'],
tel: ['1-368-169-0957'],
email: ['[email protected]']
},
{
id: 65,
name: 'Hu Avila',
familyName: ['Avila'],
givenName: ['Hu'],
tel: ['1-311-333-8877'],
email: ['[email protected]']
},
{
id: 66,
name: 'Garth Trujillo',
familyName: ['Trujillo'],
givenName: ['Garth'],
tel: ['1-409-494-1231'],
email: ['[email protected]']
},
{
id: 67,
name: 'Quamar Buchanan',
familyName: ['Buchanan'],
givenName: ['Quamar'],
tel: ['1-114-992-7225'],
email: ['[email protected]']
},
{
id: 68,
name: 'Ulysses Bishop',
familyName: ['Bishop'],
givenName: ['Ulysses'],
tel: ['1-485-518-5941'],
email: ['[email protected]']
},
{
id: 69,
name: 'Avram Knapp',
familyName: ['Knapp'],
givenName: ['Avram'],
tel: ['1-307-139-5554'],
email: ['[email protected]']
},
{
id: 70,
name: 'Conan Grant',
familyName: ['Grant'],
givenName: ['Conan'],
tel: ['1-331-936-0280'],
email: ['[email protected]']
},
{
id: 71,
name: 'Chester Kemp',
familyName: ['Kemp'],
givenName: ['Chester'],
tel: ['1-554-119-4848'],
email: ['[email protected]']
},
{
id: 72,
name: 'Hedley Dudley',
familyName: ['Dudley'],
givenName: ['Hedley'],
tel: ['1-578-607-6287'],
email: ['[email protected]']
},
{
id: 73,
name: 'Jermaine Avila',
familyName: ['Avila'],
givenName: ['Jermaine'],
tel: ['1-860-455-2283'],
email: ['[email protected]']
},
{
id: 74,
name: 'Kamal Hamilton',
familyName: ['Hamilton'],
givenName: ['Kamal'],
tel: ['1-650-389-0920'],
email: ['[email protected]']
},
{
id: 75,
name: 'Castor Maxwell',
familyName: ['Maxwell'],
givenName: ['Castor'],
tel: ['1-260-489-7135'],
email: ['[email protected]']
},
{
id: 76,
name: 'Lyle Burris',
familyName: ['Burris'],
givenName: ['Lyle'],
tel: ['1-250-343-2038'],
email: ['[email protected]']
},
{
id: 77,
name: 'Merrill Dalton',
familyName: ['Dalton'],
givenName: ['Merrill'],
tel: ['1-851-675-1381'],
email: ['[email protected]']
},
{
id: 78,
name: 'Ezekiel Medina',
familyName: ['Medina'],
givenName: ['Ezekiel'],
tel: ['1-389-582-3443'],
email: ['[email protected]']
},
{
id: 79,
name: 'Len Tran',
familyName: ['Tran'],
givenName: ['Len'],
tel: ['1-434-573-6114'],
email: ['[email protected]']
},
{
id: 80,
name: 'Len Dominguez',
familyName: ['Dominguez'],
givenName: ['Len'],
tel: ['1-144-489-7487'],
email: ['[email protected]']
},
{
id: 81,
name: 'Paul Lane',
familyName: ['Lane'],
givenName: ['Paul'],
tel: ['1-448-169-4312'],
email: ['[email protected]']
},
{
id: 82,
name: 'Eric Horne',
familyName: ['Horne'],
givenName: ['Eric'],
tel: ['1-124-862-6890'],
email: ['[email protected]']
},
{
id: 83,
name: 'Elton Ellis',
familyName: ['Ellis'],
givenName: ['Elton'],
tel: ['1-492-834-0019'],
email: ['[email protected]']
},
{
id: 84,
name: 'Jameson Snyder',
familyName: ['Snyder'],
givenName: ['Jameson'],
tel: ['1-811-590-5893'],
email: ['[email protected]']
},
{
id: 85,
name: 'Micah Shelton',
familyName: ['Shelton'],
givenName: ['Micah'],
tel: ['1-402-504-4026'],
email: ['[email protected]']
},
{
id: 86,
name: 'Evan Lester',
familyName: ['Lester'],
givenName: ['Evan'],
tel: ['1-535-915-3570'],
email: ['[email protected]']
},
{
id: 87,
name: 'Reuben Dalton',
familyName: ['Dalton'],
givenName: ['Reuben'],
tel: ['1-296-598-2504'],
email: ['[email protected]']
},
{
id: 88,
name: 'Beau Baird',
familyName: ['Baird'],
givenName: ['Beau'],
tel: ['1-525-882-9957'],
email: ['[email protected]']
},
{
id: 89,
name: 'Hedley Olsen',
familyName: ['Olsen'],
givenName: ['Hedley'],
tel: ['1-945-295-5863'],
email: ['[email protected]']
},
{
id: 90,
name: 'Oliver Todd',
familyName: ['Todd'],
givenName: ['Oliver'],
tel: ['1-551-447-1296'],
email: ['[email protected]']
},
{
id: 91,
name: 'Keegan Mayo',
familyName: ['Mayo'],
givenName: ['Keegan'],
tel: ['1-351-848-2796'],
email: ['[email protected]']
},
{
id: 92,
name: 'Wang Cote',
familyName: ['Cote'],
givenName: ['Wang'],
tel: ['1-439-568-2013'],
email: ['[email protected]']
},
{
id: 93,
name: 'Hyatt Rowe',
familyName: ['Rowe'],
givenName: ['Hyatt'],
tel: ['1-596-765-3807'],
email: ['[email protected]']
},
{
id: 94,
name: 'Cade Wyatt',
familyName: ['Wyatt'],
givenName: ['Cade'],
tel: ['1-988-289-5924'],
email: ['[email protected]']
},
{
id: 95,
name: 'Stephen Vincent',
familyName: ['Vincent'],
givenName: ['Stephen'],
tel: ['1-954-435-1259'],
email: ['[email protected]']
},
{
id: 96,
name: 'Tobias Cherry',
familyName: ['Cherry'],
givenName: ['Tobias'],
tel: ['1-270-763-1111'],
email: ['[email protected]']
},
{
id: 97,
name: 'Keane Trevino',
familyName: ['Trevino'],
givenName: ['Keane'],
tel: ['1-794-929-8599'],
email: ['[email protected]']
},
{
id: 98,
name: 'Kennedy Cooley',
familyName: ['Cooley'],
givenName: ['Kennedy'],
tel: ['1-725-946-1901'],
email: ['[email protected]']
},
{
id: 99,
name: 'Lucian Pope',
familyName: ['Pope'],
givenName: ['Lucian'],
tel: ['1-186-946-8356'],
email: ['[email protected]']
},
{
id: 100,
name: 'Hu Combs',
familyName: ['Combs'],
givenName: ['Hu'],
tel: ['1-398-488-5222'],
email: ['[email protected]']
}];
if (('mozContacts' in navigator) && (navigator.mozContacts != null))
return;
navigator.mozContacts = {
find: function fakeContactFind() {
var request = {result: [].concat(contacts)};
setTimeout(function() {
if (request.onsuccess) {
request.onsuccess();
}
}, 0);
return request;
},
save: function fakeContactSave() {
setTimeout(function() {
if (request.onsuccess) {
request.onsuccess();
}
}, 0);
return request;
}
};
if (!('mozContact' in window)) {
window.mozContact = function() {
return {
id: 'undefined',
givenName: '',
familyName: '',
tel: [''],
email: [''],
init: function() {}
};
};
}
})(this);
// navigator.mozTelephony
(function(window) {
var navigator = window.navigator;
if ('mozTelephony' in navigator)
return;
var TelephonyCalls = [];
navigator.mozTelephony = {
dial: function(number) {
var TelephonyCall = {
number: number,
state: 'dialing',
addEventListener: function() {},
hangUp: function() {},
removeEventListener: function() {}
};
TelephonyCalls.push(TelephonyCall);
return TelephonyCall;
},
addEventListener: function(name, handler) {
},
get calls() {
return TelephonyCalls;
},
muted: false,
speakerEnabled: false,
// Stubs
onincoming: null,
oncallschanged: null
};
})(this);
// Register a handler to automatically update apps when the app cache
// changes.
(function(window) {
if (!window.applicationCache)
return;
window.applicationCache.addEventListener('updateready', function(evt) {
if (!navigator.mozNotification)
return;
// Figure out what our name is and where we come from
navigator.mozApps.getSelf().onsuccess = function(e) {
var app = e.target.result;
var name = app.manifest.name;
var origin = app.origin;
// FIXME Localize this message:
var notification = navigator.mozNotification.createNotification(
'Update Available',
'A new version of ' + name + ' is available');
notification.onclick = function(event) {
// If we're still running when the user taps on the notification
// then ask if they want to reload now
// FIXME: uncomment and localize when confirm() dialogs work
/* if (confirm('Update ' + name + ' from ' + origin + ' now?')) */
window.location.reload();
};
notification.show();
}
});
})(this);
// Emulate device buttons. This is groteskly unsafe and should be removed
// soon.
(function(window) {
var supportedEvents = { keydown: true, keyup: true };
var listeners = [];
var originalAddEventListener = window.addEventListener;
window.addEventListener = function(type, listener, capture) {
if (this === window && supportedEvents[type]) {
listeners.push({ type: type, listener: listener, capture: capture });
}
originalAddEventListener.call(this, type, listener, capture);
};
var originalRemoveEventListener = window.removeEventListener;
window.removeEventListener = function(type, listener) {
if (this === window && supportedEvents[type]) {
var newListeners = [];
for (var n = 0; n < listeners.length; ++n) {
if (listeners[n].type == type && listeners[n].listener == listener)
continue;
newListeners.push(listeners[n]);
}
listeners = newListeners;
}
originalRemoveEventListener.call(this, type, listener);
}
var KeyEventProto = {
DOM_VK_HOME: 36
};
window.addEventListener('message', function(event) {
var data = event.data;
if (typeof data === 'string' && data.indexOf('moz-key-') == 0) {
var type, key;
if (data.indexOf('moz-key-down-') == 0) {
type = 'keydown';
key = data.substr(13);
} else if (data.indexOf('moz-key-up-') == 0) {
type = 'keyup';
key = data.substr(11);
} else {
return;
}
key = KeyEvent[key];
for (var n = 0; n < listeners.length; ++n) {
if (listeners[n].type == type) {
var fn = listeners[n].listener;
var e = Object.create(KeyEventProto);
e.type = type;
e.keyCode = key;
if (typeof fn === 'function')
fn(e);
else if (typeof fn === 'object' && fn.handleEvent)
fn.handleEvent(e);
if (listeners[n].capture)
return;
}
}
}
});
})(this);
// navigator.mozWifiManager
(function(window) {
var navigator = window.navigator;
try {
if ('mozWifiManager' in navigator)
return;