updates and additions
[webos-internals:modifications.git] / phone / phone-reverse-lookup---israel.patch
1 diff --git a/usr/palm/applications/com.palm.app.phone/app/controllers/calllog-assistant.js b/usr/palm/applications/com.palm.app.phone/app/controllers/calllog-assistant.js
2 index a7d2920..c40307d 100644
3 --- a/usr/palm/applications/com.palm.app.phone/app/controllers/calllog-assistant.js
4 +++ b/usr/palm/applications/com.palm.app.phone/app/controllers/calllog-assistant.js
5 @@ -55,7 +55,7 @@ var CalllogAssistant = Class.create({
6                 
7                 this.controller.setupWidget('rowdrawer', {
8                         drawerBottomOffset: Mojo.Environment.TOUCHABLE_ROW_HEIGHT
9 -               });
10 +               });             
11         },
12         
13         aboutToActivate: function(callback) {
14 @@ -213,6 +213,8 @@ var CalllogAssistant = Class.create({
15                                 name: "contact",
16                                 label: isKnown ? $L("View Contact") : $L("Add to Contacts")
17                         }});
18 +                       
19 +                       viewContact += '<div class="palm-row" x-mojo-touch-feedback="momentary" name="dolookup" displayName="asd"><div class="palm-row-wrapper"><div class="title contact-title truncating-text">Reverse 144 Lookup (IL)</div></div></div>';
20                 } else {
21                         viewContact = "";
22                 }
23 @@ -322,11 +324,62 @@ var CalllogAssistant = Class.create({
24                                                 TelephonyCommands.contactsLaunchWithPseudocard(itemModel.recentcall_address.addr, itemModel.recentcall_address.service);
25                                         }
26                                         return;
27 +                               case "dolookup":
28 +                                       //  look for reverse lookup
29 +                                       this.getReverseInfo("http://441il.com/look.php", itemModel.recentcall_address.addr);
30 +                                       return;                                 
31                                 }
32                         target = target.parentNode;
33                 }
34         },
35         
36 +       getReverseInfo : function ( url, thePhone )
37 +       {
38 +               var self = this;
39 +               try {
40 +                       var request = new Ajax.Request(url, {
41 +                                       method: 'post',
42 +                    parameters: {phone: thePhone }, // put any number here
43 +                    evalJSON: 'true', //to enforce parsing JSON if there is JSON response
44 +                    onSuccess: this.getReverseInfoCallback.bind(this),
45 +                                       onFailure: function() {
46 +                                               self.showDialogBox( "Reverse Lookup", "Failed to reverse lookup: [" + url + "]" ); 
47 +                                       } 
48 +                  });
49 +        }
50 +               catch(e)
51 +        {
52 +                       self.showDialogBox( "Reverse Lookup", "Failed to reverse lookup: " + e);
53 +        }
54 +       },
55 +       getReverseInfoCallback : function(transport)
56 +       {
57 +               var str = "Failed to reverse lookup!";
58 +               if (transport)
59 +               {
60 +                       if (transport.responseText.length) {
61 +                               str = transport.responseText;
62 +                               str = str.replace('<TR><TD>', '');
63 +                               str = str.replace('</TD></TR>', '');
64 +                               str = str.replace('</TD><TD>', '\r');
65 +                               str = str.replace('</TD><TD>', '\r');
66 +                               str = str.replace('</TD><TD>', '\r');
67 +                               str = str.replace('&quot;', '');
68 +                       }
69 +                       else str = 'Unable to locate number';
70 +               }
71 +               this.showDialogBox( "Reverse Lookup", str ); 
72 +       },
73 +       showDialogBox : function(title,message)
74 +       {
75 +               this.controller.showAlertDialog({
76 +                       onChoose: function(value) {},
77 +                       title:title,
78 +                       message:message,
79 +                       choices:[ {label:'OK', value:'OK', type:'color'} ]
80 +               });
81 +       },
82 +       
83         // utility function to set up a list
84         // type = all | missed
85         setupList: function(elementName, type) {