-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvcard.html
180 lines (161 loc) · 6.54 KB
/
vcard.html
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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>JWChat - VCard - </title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<script src="shared.js"></script>
<script src="switchStyle.js"></script>
<script src="xmlextras.js"></script>
<script src="jsjac.js"></script>
<script>
<!--
var jid , vcard;
var srcW; // the source window with necessary data
function sendSub() {
var iq = new JSJaCIQ();
iq.setType('set');
var vCard = iq.appendNode('vCard', {'xmlns': 'vcard-temp'});
for (var i=0; i<document.forms[0].elements.length; i++) {
var item = document.forms[0].elements[i];
if (item.id == '') continue;
if (item.value == '' ) continue;
if (item.id.indexOf('.') != -1) {
var tagname = item.id.substring(0,item.id.indexOf('.'));
var aNode;
if (vCard.getElementsByTagName(tagname).length > 0)
aNode = vCard.getElementsByTagName(tagname).item(0);
else
aNode = vCard.appendChild(iq.getDoc().createElement(tagname));
aNode.appendChild(iq.getDoc().createElement(item.id.substring(item.id.indexOf('.')+1))).appendChild(iq.getDoc().createTextNode(item.value));
} else {
vCard.appendChild(iq.getDoc().createElement(item.id)).appendChild(iq.getDoc().createTextNode(item.value));
}
}
srcW.Debug.log(iq.xml(),3);
srcW.con.send(iq);
window.close();
}
function init() {
srcW = opener.top;
getArgs();
jid = passedArgs['jid'];
document.title += jid;
for (var i=0; i<document.forms[0].elements.length;i++) {
if (document.forms[0].elements[i].id == '') continue;
if (cutResource(jid) != srcW.cutResource(srcW.jid)) {
document.forms[0].elements[i].className = "vcardBox";
document.forms[0].elements[i].readOnly = true;
}
}
if (cutResource(jid) != srcW.cutResource(srcW.jid))
document.getElementById("savebox").style.display = 'none';
// request vcard
var iq = new JSJaCIQ();
iq.setType('get');
if (cutResource(jid) != srcW.cutResource(srcW.jid)) // not me
iq.setTo(jid);
iq.appendNode('vCard', {'xmlns': 'vcard-temp'});
me = this;
srcW.con.send(iq,me.handleVCard);
}
function handleVCard(iq) {
if (!iq) {
srcW.Debug.log('got empty iq result',1);
return;
}
srcW.Debug.log(iq.xml(),3);
if (iq.getNode().getElementsByTagName('vCard').item(0)) {
for (var i=0; i<iq.getNode().getElementsByTagName('vCard').item(0).childNodes.length; i++) {
var token = iq.getNode().getElementsByTagName('vCard').item(0).childNodes.item(i);
tokenname = token.nodeName;
if (token.firstChild && token.firstChild.nodeType != 3) { // found a container
for (var j=0; j<token.childNodes.length; j++) {
if (typeof(document.forms[0].elements[tokenname+"."+token.childNodes.item(j).nodeName]) != 'undefined' && token.childNodes.item(j).firstChild)
document.forms[0].elements[tokenname+"."+token.childNodes.item(j).nodeName].value = token.childNodes.item(j).firstChild.nodeValue;
}
} else
if (typeof(document.forms[0].elements[tokenname]) != 'undefined' && token.firstChild)
document.forms[0].elements[tokenname].value = token.firstChild.nodeValue;
}
}
}
function keyPressed(e) {
if (e.keyCode == 27)
window.close();
}
onkeydown = keyPressed;
onload = init;
//-->
</script>
<script for="document" event="onkeydown()" language="JScript">
<!--
if (window.event.keyCode == 27)
window.close();
//-->
</script>
<style type="text/css">
/*<![CDATA[*/
th {
font-family: sans-serif;
font-size: 12px;
text-align: right;
}
/*]]>*/
</style>
</head>
<body style="margin:8px">
<form>
<fieldset>
<legend>Name</legend>
<table>
<tr><th nowrap>Full Name:</th><td width="100%"><input type=text id="FN" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>Family Name:</th><td width="100%"><input type=text id="N.FAMILY" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>Name:</th><td width="100%"><input type=text id="N.GIVEN" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>Nickname:</th><td width="100%"><input type=text id="NICKNAME" class="vcardBoxEditable"></td></tr>
</table>
</fieldset>
<fieldset>
<legend>Information</legend>
<table>
<tr><th nowrap>E-mail:</th><td width="100%"><input type=text id="EMAIL" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>Web Site:</th><td width="100%"><input type=text id="URL" class="vcardBoxEditable"></td></tr>
</table>
</fieldset>
<fieldset>
<legend>Address</legend>
<table>
<tr><th nowrap>Address:</th><td width="100%"><input type=text id="ADR.STREET" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>Address2:</th><td width="100%"><input type=text id="ADR.EXTADD" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>City:</th><td width="100%"><input type=text id="ADR.LOCALITY" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>State:</th><td width="100%"><input type=text id="ADR.REGION" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>Postal Code:</th><td width="100%"><input type=text id="ADR.PCODE" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>Country:</th><td width="100%"><input type=text id="ADR.CTRY" class="vcardBoxEditable"></td></tr>
</table>
</fieldset>
<fieldset>
<legend>Organization</legend>
<table>
<tr><th nowrap>Name:</th><td width="100%"><input type=text id="ORG.ORGNAME" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>Unit:</th><td width="100%"><input type=text id="ORG.ORGUNIT" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>Title:</th><td width="100%"><input type=text id="TITLE" class="vcardBoxEditable"></td></tr>
<tr><th nowrap>Role:</th><td width="100%"><input type=text id="ROLE" class="vcardBoxEditable"></td></tr>
</table>
</fieldset>
<fieldset>
<legend>About</legend>
<table width="100%">
<tr><th>Birthday:</th><td width="100%"><input type=text id="BDAY" class="vcardBoxEditable"></td></tr>
<tr><td colspan=2> </td></tr>
<tr><th>Description:</th><td width="100%"> </td></tr>
<tr><td colspan=2 width="100%"><textarea id="DESC" class="vcardBoxEditable" style="width:100%;" rows=4 wrap=virtual></textarea></td></tr>
</table>
</fieldset>
<div id="savebox">
<hr noshade size="1" size="100%">
<div align="right">
<button onClick="window.close();">Cancel</button> <button onClick="return sendSub();">Save</button>
</div>
</div>
</form>
</body>
</html>