diff blog.js @ 4:f630f4b90564

Remove the old log system and use console.log instead.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Mon, 19 Sep 2011 01:51:12 -0700
parents 82905edac9d8
children 7ab6b48122af
line wrap: on
line diff
--- a/blog.js
+++ b/blog.js
@@ -28,31 +28,9 @@ if (params.jid)
 if (params.node)
 	node = params.node;
 
-var logs = document.getElementById('log');
-if (params.debug)
-	logs.parentNode.hidden = false;
-
 var received = {};
 var messages = document.getElementById('messages');
 
-function log(msg, error) {
-	var p = document.createElementNS(ns.xhtml, 'p');
-	p.appendChild(document.createTextNode(msg));
-
-	if (!error)
-		p.setAttributeNS(null, 'class', 'error');
-
-	logs.appendChild(p);
-}
-
-function rawInput(data) {
-	log('RECV: ' + data, 1);
-}
-
-function rawOutput(data) {
-	log('SENT: ' + data, 1);
-}
-
 var html = function(name, id) {
 	return received[name][id].html;
 }
@@ -174,7 +152,6 @@ var parsePubSubEvent = function(stanza) 
 var onMessages = function(stanza) {
 	conn.addHandler(onMessages, null, 'message', null, null, null);
 
-	log('message');
 	stanza = xml2json(stanza);
 	var e = parsePubSubEvent(stanza);
 
@@ -188,14 +165,13 @@ var onMessages = function(stanza) {
 }
 
 var onInfo = function(stanza) {
-	log('info');
+	console.log('info'); // TODO!
 	/*var query = stanza.getElementsByTagNameNS(ns.info, 'query')[0];
 	var x = query.getElementsByTagNameNS(ns.data, 'x')[0];
 	var form = forms.parse(x);*/
 }
 
 var onSubscribed = function(stanza) {
-	log('subscribed');
 	var type = stanza.getAttribute('type');
 	if (type !== 'result') {
 		messages.innerHTML = 'Error, impossible to retrieve messages.';
@@ -204,20 +180,15 @@ var onSubscribed = function(stanza) {
 }
 
 function onConnect(status) {
-	if (status == Strophe.Status.CONNECTING) {
-		log('Strophe is connecting.');
-	} else if (status == Strophe.Status.CONNFAIL) {
-		log('Strophe failed to connect.');
-	} else if (status == Strophe.Status.AUTHENTICATING) {
-		log('Strophe is authenticating.');
+	if (status == Strophe.Status.CONNFAIL) {
+		console.log('Failed to connect.');
 	} else if (status == Strophe.Status.DISCONNECTING) {
-		log('Strophe is disconnecting.');
+		console.log('Disconnecting.');
 	} else if (status == Strophe.Status.DISCONNECTED) {
-		log('Strophe is disconnected.');
+		console.log('Disconnected.');
 		if (re)
 			conn.connect(jid, password, onConnect);
 	} else if (status == Strophe.Status.CONNECTED) {
-		log('Strophe is connected.');
 		conn.addHandler(onMessages, null, 'message', null, null, null);
 		conn.send($pres().tree());
 		conn.pubsub.subscribe(jid, service, node, undefined, onMessages, onSubscribed);
@@ -225,14 +196,11 @@ function onConnect(status) {
 			conn.pubsub.items(jid, service, node, onMessages);
 			conn.pubsub.info(jid, service, node, onInfo);
 		}
-	} else
-		log('Strophe is '+status+'.');
+	}
 }
 
 window.addEventListener('load', function () {
 	conn = new Strophe.Connection(BOSH_SERVICE);
-	conn.rawInput = rawInput;
-	conn.rawOutput = rawOutput;
 	conn.connect(jid, password, onConnect);
 }, false);