ref: master
public/javascripts/vendor/strophejs-1.1.3/contrib/discojs/scripts/disco.js
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 |
var NS_DISCO_INFO = 'http://jabber.org/protocol/disco#info'; var NS_DISCO_ITEM = 'http://jabber.org/protocol/disco#items'; // Disco stuff Disco = function () { // Class that does nothing }; Disco.prototype = { showBrowser: function() { // Browser Display var disco = $('#disco'); var jid = $('#jid'); var server = connection.jid.split('@')[1]; // display input box disco.append("<div id='server'><form id='browse' name='browse'>Server : <input type='text' name='server' id='server' value='"+server+"' /><input type='submit' value='browse'/></form></div>"); // add handler for search form $("#browse").bind('submit', function () { this.startBrowse($("#server").get(0).value); return false; }); this.startBrowse(server); }, closeBrowser: function() { var disco = $('#disco'); disco.empty(); }, startBrowse: function(server) { // build iq request var id = 'startBrowse'; var discoiq = $iq({'from':connection.jid+"/"+connection.resource, 'to':server, 'id':id, 'type':'get'} ) .c('query', {'xmlns': NS_DISCO_INFO}); connection.addHandler(this._cbBrowse, null, 'iq', 'result', id); connection.send(discoiq.tree()); }, _cbBrowse: function(e) { var elem = $(e); // make this Element a JQuery Element alert(e); return false; // return false to remove the handler }, }; |