3
passedArgs=new Array();
4
search = self.location.href;
5
search = search.split('?');
8
argList = argList.split('&');
9
for(var i=0; i<argList.length; i++){
11
newArg = argList[i].split('=');
12
passedArgs[unescape(newArg[0])] = unescape(newArg[1]);
17
function cutResource(aJID) { // removes resource from a given jid
18
if (typeof(aJID) == 'undefined' || !aJID)
21
if (retval.indexOf("/") != -1)
22
retval = retval.substring(0,retval.indexOf("/"));
26
function msgEscape(msg) {
27
if (typeof(msg) == 'undefined' || !msg || msg == '')
30
msg = msg.replace(/%/g,"%25"); // must be done first
32
msg = msg.replace(/\n/g,"%0A");
33
msg = msg.replace(/\r/g,"%0D");
34
msg = msg.replace(/ /g,"%20");
35
msg = msg.replace(/\"/g,"%22");
36
msg = msg.replace(/#/g,"%23");
37
msg = msg.replace(/\$/g,"%24");
38
msg = msg.replace(/&/g,"%26");
39
msg = msg.replace(/\(/g,"%28");
40
msg = msg.replace(/\)/g,"%29");
41
msg = msg.replace(/\+/g,"%2B");
42
msg = msg.replace(/,/g,"%2C");
43
msg = msg.replace(/\//g,"%2F");
44
msg = msg.replace(/\:/g,"%3A");
45
msg = msg.replace(/\;/g,"%3B");
46
msg = msg.replace(/</g,"%3C");
47
msg = msg.replace(/=/g,"%3D");
48
msg = msg.replace(/>/g,"%3E");
49
msg = msg.replace(/@/g,"%40");
54
// fucking IE is too stupid for window names
55
function makeWindowName(wName) {
56
wName = wName.replace(/@/,"at");
57
wName = wName.replace(/\./g,"dot");
58
wName = wName.replace(/\//g,"slash");
59
wName = wName.replace(/&/g,"amp");
60
wName = wName.replace(/\'/g,"tick");
61
wName = wName.replace(/=/g,"equals");
62
wName = wName.replace(/#/g,"pound");
63
wName = wName.replace(/:/g,"colon");
64
wName = wName.replace(/%/g,"percent");
65
wName = wName.replace(/-/g,"dash");
66
wName = wName.replace(/ /g,"blank");
67
wName = wName.replace(/\*/g,"asterix");
71
function htmlEnc(str) {
75
str = str.replace(/&/g,"&");
76
str = str.replace(/</g,"<");
77
str = str.replace(/>/g,">");
78
str = str.replace(/\"/g,""");
82
function msgFormat(msg) { // replaces emoticons and urls in a message
88
if (typeof(emoticons) != 'undefined') {
89
for (var i in emoticons) {
90
if (!emoticons.hasOwnProperty(i))
92
var iq = i.replace(/\\/g, '');
93
var emo = new Image();
94
emo.src = emoticonpath+emoticons[i];
95
if (emo.width > 0 && emo.height > 0)
96
msg = msg.replace(eval("/\(\\s\|\^\)"+i+"\(\\s|\$\)/g"),"$1<img src=\""+emo.src+"\" width='"+emo.width+"' height='"+emo.height+"' alt=\""+iq+"\" title=\""+iq+"\">$2");
98
msg = msg.replace(eval("/\(\\s\|\^\)"+i+"\(\\s|\$\)/g"),"$1<img src=\""+emo.src+"\" alt=\""+iq+"\" title=\""+iq+"\">$2");
102
// replace http://<url>
103
msg = msg.replace(/(\s|^)(https?:\/\/\S+)/gi,"$1<a href=\"$2\" target=\"_blank\">$2</a>");
105
// replace ftp://<url>
106
msg = msg.replace(/(\s|^)(ftp:\/\/\S+)/gi,"$1<a href=\"$2\" target=\"_blank\">$2</a>");
108
// replace mail-links
109
msg = msg.replace(/(\s|^)(\w+\@\S+\.\S+)/g,"$1<a href=\"mailto:$2\">$2</a>");
111
// replace *<pattern>*
112
msg = msg.replace(/(\s|^)\*([^\*\r\n]+)\*/g,"$1<b>\$2\</b>");
115
msg = msg.replace(/(\s|^)\_([^\*\r\n]+)\_/g,"$1<u>$2</u>");
117
msg = msg.replace(/\n/g,"<br>");
123
* checks whether jid is valid
125
var prohibited = ['"',' ','&','\'','/',':','<','>','@']; // invalid chars
126
function isValidJID(jid) {
127
var nodeprep = jid.substring(0,jid.lastIndexOf('@')); // node name (string before the @)
129
for (var i=0; i<prohibited.length; i++) {
130
if (nodeprep.indexOf(prohibited[i]) != -1) {
131
alert("JID invalido\n"+prohibited[i]+" non ammesso nello JID.\Scegline uno diverso!");
139
* converts from jabber timestamps to javascript date objects
141
function jab2date(ts) {
142
var date = new Date(Date.UTC(ts.substr(0,4),ts.substr(5,2)-1,ts.substr(8,2),ts.substr(11,2),ts.substr(14,2),ts.substr(17,2)));
143
if (ts.substr(ts.length-6,1) != 'Z') { // there's an offset
144
var offset = new Date();
146
offset.setUTCHours(ts.substr(ts.length-5,2));
147
offset.setUTCMinutes(ts.substr(ts.length-2,2));
148
if (ts.substr(ts.length-6,1) == '+')
149
date.setTime(date.getTime() - offset.getTime());
150
else if (ts.substr(ts.length-6,1) == '-')
151
date.setTime(date.getTime() + offset.getTime());
156
/* hrTime - human readable Time
157
* takes a timestamp in the form of 2004-08-13T12:07:04±02:00 as argument
158
* and converts it to some sort of humane readable format
160
function hrTime(ts) {
161
return jab2date(ts).toLocaleString();
165
* somewhat opposit to hrTime (see above)
166
* expects a javascript Date object as parameter and returns a jabber
167
* date string conforming to JEP-0082
169
function jabberDate(date) {
170
if (!date.getUTCFullYear)
173
var jDate = date.getUTCFullYear() + "-";
174
jDate += (((date.getUTCMonth()+1) < 10)? "0" : "") + (date.getUTCMonth()+1) + "-";
175
jDate += ((date.getUTCDate() < 10)? "0" : "") + date.getUTCDate() + "T";
177
jDate += ((date.getUTCHours()<10)? "0" : "") + date.getUTCHours() + ":";
178
jDate += ((date.getUTCMinutes()<10)? "0" : "") + date.getUTCMinutes() + ":";
179
jDate += ((date.getUTCSeconds()<10)? "0" : "") + date.getUTCSeconds() + "Z";