xmpp_muc.js: Add get_child() function

Mon, 05 Apr 2010 13:18:00 +0100

author
Matthew Wild <mwild1@gmail.com>
date
Mon, 05 Apr 2010 13:18:00 +0100
changeset 41
d22dee1f3dba
parent 40
6fb7b98629ae
child 42
815816ceb1ad

xmpp_muc.js: Add get_child() function

src/js/xmpp_muc.js file | annotate | diff | comparison | revisions
--- a/src/js/xmpp_muc.js	Sat Apr 03 20:53:56 2010 +0100
+++ b/src/js/xmpp_muc.js	Mon Apr 05 13:18:00 2010 +0100
@@ -1,6 +1,20 @@
 // Wraps a function so that its 'this' is always 'context' when called
 var recontext = function (context, f) { return function () { return f.apply(context, arguments); }; };
 
+// Returns a child element given a tag name and xmlns
+function get_child(stanza, name, xmlns)
+{
+	var children = stanza.getElementsByTagName(name);
+	for(var i=0;i<=children.length;i++)
+	{
+		if(children[i].getAttribute("xmlns") == xmlns || !xmlns)
+			return children[i];
+	}
+	return null;
+}
+
+
+
 var MUC = function (conn, callbacks)
 {
 	/* Set our properties */

mercurial