Jump to content

проблема с 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
Link to comment
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();
}

 

Link to comment
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
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...