~ubuntu-branches/debian/stretch/alpine/stretch

« back to all changes in this revision

Viewing changes to web/cgi/alpine-2.0/lib/contacts.js

  • Committer: Bazaar Package Importer
  • Author(s): Asheesh Laroia
  • Date: 2010-10-03 15:31:55 UTC
  • mfrom: (1.1.8 upstream)
  • Revision ID: james.westby@ubuntu.com-20101003153155-2exypc96j1e8tw0p
Tags: 2.02-1
* New upstream release, based on re-alpine project
* Updated debian/copyright to reflect this fact
* re-alpine removed the non-free from the tarball, so now
  we do not repack the upstream tarball. (Yay!)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: contacts.js 1150 2008-08-20 00:27:11Z mikes@u.washington.edu $
2
 
 * ========================================================================
3
 
 * Copyright 2008 University of Washington
4
 
 *
5
 
 * Licensed under the Apache License, Version 2.0 (the "License");
6
 
 * you may not use this file except in compliance with the License.
7
 
 * You may obtain a copy of the License at
8
 
 *
9
 
 *     http://www.apache.org/licenses/LICENSE-2.0
10
 
 *
11
 
 * ========================================================================
12
 
 */
13
 
 
14
 
 
15
 
function boxChecked(o){
16
 
    if(o) markOne(o);
17
 
}
18
 
 
19
 
function editCheckedContact(){
20
 
    var checked = contactsChecked();
21
 
    switch (checked.length){
22
 
    case 1 :
23
 
        editContact({ book:checked[0].book, index:checked[0].index });
24
 
        break;
25
 
    default :
26
 
        panelAlert('Choose just one contact to Edit');
27
 
    case 0 :
28
 
        break;
29
 
    }
30
 
 
31
 
    return(false);
32
 
}
33
 
 
34
 
function editContact(o){
35
 
    o.which = 'edit';
36
 
    var takeDS = new YAHOO.util.DataSource('conduit/getcontact.tcl?book=' + o.book + '&index=');
37
 
    takeDS.responseType = YAHOO.util.DataSource.TYPE_XML;
38
 
    takeDS.responseSchema = {
39
 
        resultNode: 'Result',
40
 
        fields: ['Nickname','Personal','Mailbox','Fcc','Note']
41
 
    };
42
 
    takeDS.sendRequest(o.index,
43
 
                       {
44
 
                           success: function(oReq,oResp,oPayload){
45
 
                               if(oResp.results.length == 1){
46
 
                                   o.nickname = oResp.results[0].Nickname;
47
 
                                   o.personal = oResp.results[0].Personal;
48
 
                                   o.email = oResp.results[0].Mailbox;
49
 
                                   if(o.email.search(/,/) >= 0) o.group = true;
50
 
                                   o.note = oResp.results[0].Note;
51
 
                                   o.fcc = oResp.results[0].Fcc;
52
 
                                   contactEditor(o,storeEditedContact);
53
 
                               }
54
 
                               else showStatusMessage('Too many entries to Edit', 10);
55
 
                           },
56
 
                           failure: function(oReq,oResp,oPayload){
57
 
                               showStatusMessage('Error Taking Address: ' + oResp.responseText, 10);
58
 
                           },
59
 
                           scope: this,
60
 
                           argument:[o]
61
 
                       });
62
 
    return(false);
63
 
}
64
 
 
65
 
function contactDelete(){
66
 
    var checked = contactsChecked();
67
 
    var plural = (checked.length > 1) ? 's' : '';
68
 
    var count = (checked.length > 1) ? '<b>' + checked.length + '</b> ' : '';
69
 
    if(checked.length) panelConfirm('Are you sure you want to permanently delete the ' + count + 'selected contact' + plural + '?',{text:'Delete Forever',fn:doContactDelete});
70
 
    return false;
71
 
}
72
 
 
73
 
function doContactDelete(o){
74
 
    var checked = contactsChecked();
75
 
    if(checked.length){
76
 
        var el = YAHOO.alpine.containers.contactlist;
77
 
        var elist = '';
78
 
        for(var i = 0; i < checked.length; i++){
79
 
            if(elist.length) elist += ',';
80
 
            elist += checked[i].book + '.' + checked[i].index;
81
 
        }
82
 
            
83
 
        if(el && elist.length){
84
 
            var o = {
85
 
                hdr:'on',
86
 
                sendto:'on',
87
 
                canedit:'on',
88
 
                op:'delete',
89
 
                entryList:elist
90
 
            }
91
 
 
92
 
            newContactList(el,null,gCurrentAbook,o);
93
 
        }
94
 
    }
95
 
}
96
 
 
97
 
function storeEditedContact(oFields){
98
 
    var el = YAHOO.alpine.containers.contactlist;
99
 
    if(el){
100
 
        var o = {
101
 
            hdr:'on',
102
 
            sendto:'on',
103
 
            canedit:'on',
104
 
            op:'change'
105
 
        }
106
 
 
107
 
        for(var f in oFields) o.f = oFields[f];
108
 
        newContactList(el,null,gCurrentAbook,o);
109
 
    }
110
 
}
111
 
 
112
 
function storeNewContact(oFields){
113
 
    var el = YAHOO.alpine.containers.contactlist;
114
 
    if(el){
115
 
        var o = {
116
 
            hdr:'on',
117
 
            sendto:'on',
118
 
            canedit:'on',
119
 
            op:'add'
120
 
        }
121
 
 
122
 
        for(var f in oFields) o.f = oFields[f];
123
 
        newContactList(el,null,gCurrentAbook,o);
124
 
    }
125
 
}
126
 
 
127
 
function sendToContact(){
128
 
    var checked = contactsChecked('Send Email');
129
 
    if(checked.length){
130
 
        var cUrl = 'compose?contacts=';
131
 
        var comma = '';
132
 
        for(var i = 0; i < checked.length; i++){
133
 
            cUrl += comma + checked[i].book + '.' + checked[i].index;
134
 
            comma = ',';
135
 
        }
136
 
        
137
 
        window.location.href = cUrl;
138
 
    }
139
 
 
140
 
    return(false);
141
 
}