Browse Source

autoconnect functionality

Nathaniel van Diepen 11 years ago
parent
commit
56f1fbb032
1 changed files with 25 additions and 3 deletions
  1. 25 3
      app/www/js/omnomirc.js

+ 25 - 3
app/www/js/omnomirc.js

@@ -45,6 +45,7 @@
 			colour: false,
 			timestamp: 'exact',
 			server: location.origin,
+			autoconnect: true,
 			autojoin: [
 				'#omnimaga',
 				'#omnimaga-fr',
@@ -87,6 +88,20 @@
 					});
 				}
 			},
+			{ // connect
+				cmd: 'connect',
+				fn: function(){
+					if(!$o.connected()){
+						$o.connect();
+					}
+				}
+			},
+			{	// disconnect
+				cmd: 'disconnect',
+				fn: function(){
+					$o.disconnect();
+				}
+			},
 			{ // nick
 				cmd: 'nick',
 				fn: function(args){
@@ -295,8 +310,7 @@
 		},
 		connect: function(server){
 			if($o.connected()){
-				socket.disconnect();
-				socket = undefined;
+				$o.disconnect();
 			}
 			if(typeof server == 'undefined'){
 				server = settings.server;
@@ -307,6 +321,12 @@
 			}
 			$o.auth();
 		},
+		disconnect: function(){
+			if($o.connected()){
+				socket.disconnect();
+				socket = undefined;
+			}
+		},
 		auth: function(){
 			if(settings.nick == ''){
 				$o.set('nick','User');
@@ -823,7 +843,9 @@
 			$h.removeClass('hovered');
 		},1000);
 		$o.renderSettings();
-		$o.connect();
+		if(settings.autoconnect){
+			$o.connect();
+		}
 	});
 	delete window.io;
 })(window,jQuery,io);