Browse Source

Added nick links for origin OmnomIRC

Sorunome 11 years ago
parent
commit
f1b0d96e5b
3 changed files with 56 additions and 16 deletions
  1. 11 11
      app/OmnomIRC.js
  2. 39 0
      app/www/data/plugins/linkNicks/script.js
  3. 6 5
      app/www/js/omnomirc.js

+ 11 - 11
app/OmnomIRC.js

@@ -149,17 +149,6 @@ if(cluster.isMaster){
 		var c = msg[0];
 		msg = msg.substr(1);
 		
-			message = function(room,from,message,origin,socket){
-				if(typeof socket == 'undefined'){
-					socket = io.sockets.in(room);
-				}
-				socket.emit('message',{
-					message: message,
-					room: room,
-					from: from,
-					origin: origin
-				})
-			};
 		switch(c){
 			case 'Q':
 				if(typeof app != 'undefined' && typeof irc == 'undefined'){
@@ -433,6 +422,17 @@ if(cluster.isMaster){
 					});
 				}
 			},
+			message = function(room,from,message,origin,socket){
+				if(typeof socket == 'undefined'){
+					socket = io.sockets.in(room);
+				}
+				socket.emit('message',{
+					message: message,
+					room: room,
+					from: from,
+					origin: origin
+				})
+			},
 			fromServer = function(room,message,socket){
 				if(typeof socket == 'undefined'){
 					socket = io.sockets.in(room);

+ 39 - 0
app/www/data/plugins/linkNicks/script.js

@@ -0,0 +1,39 @@
+hook('message',function(msg,from,room,origin){
+	var origins = function(name){
+		for(var i in $o.prop('origins')){
+			if(name == $o.prop('origins')[i][1]){
+				return i;
+			}
+		}
+		return 1;
+	};
+	if(origins('OmnomIRC')==origin){
+		var parseMsg = $($('#content-list').children().last().children("span")[1]).html(),
+			nick,
+			before,
+			after,
+			newHTML;
+		if(parseMsg.substring(24,28)=="<"){
+			nick = parseMsg.substring(28,parseMsg.indexOf(">",29));
+			before = parseMsg.substring(0,28);
+			after = parseMsg.substring(parseMsg.indexOf(">",29));
+		}else if(parseMsg.substring(24,25)=="*"){
+			nick = parseMsg.substring(31,parseMsg.indexOf(" ",31));
+			before = parseMsg.substring(0,31);
+			after = parseMsg.substring(parseMsg.indexOf(" ",31));
+		}
+		newHTML = $(fragment())
+			.append(before)
+			.append(
+				$('<a>')
+						.attr('href','http:/'+'/www.omnimaga.org/index.php?action=ezportal;sa=page;p=13&userSearch='+nick)
+						.text(nick)
+			).append(after);
+		$o.event('links',newHTML.html());
+		//$($('#content-list').children().last().children("span").get(1)).html(newHTML);
+		//$($($o.ui.tabs.current().body).children().last().children().get(1)).html(newHTML);
+		//$('#content-list > li:nth-last-child(1) > span:nth-last-child(1)').html(newHTML);
+		$($o.ui.tabs.current().body).children().last().children().slice(1,2)
+			.add('#content-list > li:nth-last-child(1) > span:nth-last-child(1)').html(newHTML);
+	}
+});

+ 6 - 5
app/www/js/omnomirc.js

@@ -318,11 +318,7 @@
 		pluginSandbox = {
 			$: window.jQuery,
 			jQuery: window.jQuery,
-			$o: $o,
-			test: "hello world",
-			fragment: function(){
-				return document.createDocumentFragment();
-			}
+			$o: $o
 		},
 		currentPlugin = 0,
 		Sandbox = function(sandbox){
@@ -334,6 +330,11 @@
 			for(i in sandbox){
 				o[i] = sandbox[i];
 			}
+			if(!exists(o.fragment)){
+				o.fragment = function(){
+					return document.createDocumentFragment();
+				};
+			}
 			return o;
 		},
 		runHook = function(name,args){