1
/* $Id: contacts.js 1150 2008-08-20 00:27:11Z mikes@u.washington.edu $
2
* ========================================================================
3
* Copyright 2008 University of Washington
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
9
* http://www.apache.org/licenses/LICENSE-2.0
11
* ========================================================================
15
function boxChecked(o){
19
function editCheckedContact(){
20
var checked = contactsChecked();
21
switch (checked.length){
23
editContact({ book:checked[0].book, index:checked[0].index });
26
panelAlert('Choose just one contact to Edit');
34
function editContact(o){
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 = {
40
fields: ['Nickname','Personal','Mailbox','Fcc','Note']
42
takeDS.sendRequest(o.index,
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);
54
else showStatusMessage('Too many entries to Edit', 10);
56
failure: function(oReq,oResp,oPayload){
57
showStatusMessage('Error Taking Address: ' + oResp.responseText, 10);
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});
73
function doContactDelete(o){
74
var checked = contactsChecked();
76
var el = YAHOO.alpine.containers.contactlist;
78
for(var i = 0; i < checked.length; i++){
79
if(elist.length) elist += ',';
80
elist += checked[i].book + '.' + checked[i].index;
83
if(el && elist.length){
92
newContactList(el,null,gCurrentAbook,o);
97
function storeEditedContact(oFields){
98
var el = YAHOO.alpine.containers.contactlist;
107
for(var f in oFields) o.f = oFields[f];
108
newContactList(el,null,gCurrentAbook,o);
112
function storeNewContact(oFields){
113
var el = YAHOO.alpine.containers.contactlist;
122
for(var f in oFields) o.f = oFields[f];
123
newContactList(el,null,gCurrentAbook,o);
127
function sendToContact(){
128
var checked = contactsChecked('Send Email');
130
var cUrl = 'compose?contacts=';
132
for(var i = 0; i < checked.length; i++){
133
cUrl += comma + checked[i].book + '.' + checked[i].index;
137
window.location.href = cUrl;