~ubuntu-branches/ubuntu/lucid/jwchat/lucid

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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>JWChat - Subscribe to user</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 language="JavaScript1.2">
      <!--
var jid;
var srcW; // the source window with necessary data

function sendSub() {
  var aPresence = new JSJaCPresence();
  aPresence.setType('subscribe');
  
  if (!document.forms[0].to.value || document.forms[0].to.value == '') {
    alert("JID missing");
    document.forms[0].to.focus();
    return false;
  }

  var to = document.forms[0].to.value;
  if (to.indexOf('@') == -1)
    to += '@' + srcW.JABBERSERVER;

  aPresence.setTo(to);
  if (document.forms[0].msg.value && document.forms[0].msg.value != '')
    aPresence.setStatus(document.forms[0].msg.value);

  srcW.con.send(aPresence);
    
  window.close();
}

function selectService(selbox) {
  var el = selbox.options[selbox.selectedIndex];
  var to = document.forms[0].elements['to'];
  // cut off node
  var i = to.value.indexOf('@');
  if (i != -1)
    to.value = to.value.substring(0,i);
  if (el.value != '')
    to.value += "@" + el.value;
}

function init() {
  // determine source window
  if (opener.roster)
    srcW = opener.top;
  else
    srcW = opener.opener.top;
  
  getArgs();
  jid = (passedArgs['jid'])?passedArgs['jid']:'';
  
  document.title = "Send subscription";
  document.title += (jid)?" to " + jid:"";
  if (jid)
    document.forms[0].to.value = jid;
  
  /* detect services */
	
  var services = document.forms[0].elements["services"];
  var optidx=1;
  for (var i in srcW.disco) {
    if (!srcW.disco[i].getNode) continue;
    if (srcW.disco[i].getNode().getElementsByTagName('identity').item(0)) {
      var item = srcW.disco[i].getNode().getElementsByTagName('identity').item(0);
      if (item.getAttribute('category') == 'gateway')
	services.options[optidx++] = new Option(item.getAttribute('name'),srcW.disco[i].getFrom());
    }
  }

}
		
function keyPressed(e) {
  if (e.ctrlKey && e.keyCode == 13)
    sendSub();
  else if (e.keyCode == 27)
    window.close();
}
onkeydown = keyPressed;
onload = init;
      //-->
    </script>
    <script for="document" event="onkeydown()" language="JScript">
      <!--
      if (window.event.ctrlKey && window.event.keyCode == 13)
      sendSub();
      if (window.event.keyCode == 27)
      window.close();
      //-->
    </script>
  </head>
  <body style="margin:8px">
    <form name="sub" style="border:0;padding:0;margin:0;" onSubmit="return sendSub();">
      <table border="0" width="100%" height="100%">
          <tr><td nowrap>Search for a User:</td><td><button onClick="return srcW.openSearch();">Open Search</button></td></tr>
          <tr><td colspan=2><hr noshade size="1" size="100%"></td></tr>
          <tr>
            <td align="right" nowrap><label for="to">Send subscription to</label></td>
            <td width="100%"><input type="text" id="to" name="to" size="1" style="width:100%;" tabindex="1"></td>
          </tr>
          <tr>
            <td nowrap align="right"><label for="services">Service (optional)</label></td>
            <td width="100%">
              <select name="services" id="services" onChange="selectService(this);" tabindex="2"><option value="">local jabber user</option></select>
            </td>
          </tr>
          <tr height="100%">
            <td colspan=2>
              <textarea id="msg" wrap="physical" class="msgBox" tabindex="3">I would like to add you to my roster.</textarea>
            </td>
          </tr>
          <tr><td colspan="2"><hr noshade size="1" size="100%"></td></tr>
          <tr>
            <td colspan="2" align="right">
              <button type="button" onClick="window.close();" tabindex="5">Cancel</button>&nbsp;<button type="submit" tabindex="4">Send</button>
            </td>
          </tr>
      </table>
    </form>
  </body>
</html>