Jump to content
Sign in to follow this  
kphp

проблема с js

Recommended Posts

проблема с js я с js не очень дружен нужна помощь убрать точней подправить код socket из этого куска кода за помощь заранее спасибо

$(document).ready(function () {
	var socket = io.connect('http://127.0.0.1:8888');
	socket.on('connecting', function () {
		console.log('Send Ok');
	});
	socket.on('connect', function () {
		socket.emit("autch", JSON.stringify({
		  user_id: Auth.uid,
		  password: Auth.hash
		}));
	});
	socket.on('message', function (data) {
		Pucher(data);
	});
	function SendPush(for_user_id, user_id, data, room, type){
	  socket.emit("message", JSON.stringify({
		  for_user_id: for_user_id,
		  user_id: user_id,
		  room: room,
		  message: data,
		  type: type
		}));
	}
	window.SendPush = SendPush;
});

 

Edited by kphp

Share this post


Link to post
Share on other sites

да пожалуйста 

function Pucher(data){ 
	d = JSON.parse(data);
	if(d.user_id == 'msg'){
	    if(window.location.pathname == '/messages'){
			im.updateDialogs()
			im.update();
			$('#im_sound')[0].play();
		} else GoUpdate();
	} else if(d.user_id == 'typing'){
	    $('#im_typograf').show().delay(2000).fadeOut(300).stop();
		return false;
	} else if(d.type == 'wall_send'){
		if(window.location.pathname == '/u'+d.for_user_id){
		    rec_num = parseInt($('#wall_rec_num').text())+1;
			if(!rec_num) rec_num = 1;
			$('#wall_records').html(d.message);
			$('#wall_rec_num').text(rec_num);
		}
	} else if(d.type == 'wall_del'){
	    if(window.location.pathname == '/u'+d.for_user_id){
			var rec_num = parseInt($('#wall_rec_num').text())-1;
			if(!rec_num) rec_num = '';
				$('#wall_record_'+d.user_id).html(lang_wall_del_ok);
				$('#wall_fast_block_'+d.user_id).remove();
				$('#wall_rec_num').text(rec_num);
				myhtml.title_close(d.user_id);
		}
	}
        GoUpdate();
}

 

Share this post


Link to post
Share on other sites
4 часа назад, Kir KMS сказал:

да пожалуйста 

function Pucher(data){ 
	d = JSON.parse(data);
	if(d.user_id == 'msg'){
	    if(window.location.pathname == '/messages'){
			im.updateDialogs()
			im.update();
			$('#im_sound')[0].play();
		} else GoUpdate();
	} else if(d.user_id == 'typing'){
	    $('#im_typograf').show().delay(2000).fadeOut(300).stop();
		return false;
	} else if(d.type == 'wall_send'){
		if(window.location.pathname == '/u'+d.for_user_id){
		    rec_num = parseInt($('#wall_rec_num').text())+1;
			if(!rec_num) rec_num = 1;
			$('#wall_records').html(d.message);
			$('#wall_rec_num').text(rec_num);
		}
	} else if(d.type == 'wall_del'){
	    if(window.location.pathname == '/u'+d.for_user_id){
			var rec_num = parseInt($('#wall_rec_num').text())-1;
			if(!rec_num) rec_num = '';
				$('#wall_record_'+d.user_id).html(lang_wall_del_ok);
				$('#wall_fast_block_'+d.user_id).remove();
				$('#wall_rec_num').text(rec_num);
				myhtml.title_close(d.user_id);
		}
	}
        GoUpdate();
}

 

$(document).ready(function () {
	var socket = io.connect('http://127.0.0.1:8888');
	socket.on('connecting', function () {
		console.log('Send Ok');
	});
	socket.on('connect', function () {
		socket.emit("autch", JSON.stringify({
		  user_id: Auth.uid,
		  password: Auth.hash
		}));
	});
	socket.on('message', function (data) {
		Pucher(data);
	});
	function SendPush(for_user_id, user_id, data, room, type){
	  socket.emit("message", JSON.stringify({
		  for_user_id: for_user_id,
		  user_id: user_id,
		  room: room,
		  message: data,
		  type: type
		}));
	}
	window.SendPush = SendPush;
});

так и я мог сделать кусок кода убрать где socket и всё 

Edited by kphp

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×