kphp Posted December 18, 2019 Report Share Posted December 18, 2019 (edited) проблема с 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 December 19, 2019 by kphp Quote Link to comment Share on other sites More sharing options...
KirKMS Posted December 19, 2019 Report Share Posted December 19, 2019 да пожалуйста 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(); } Quote Link to comment Share on other sites More sharing options...
kphp Posted December 19, 2019 Author Report Share Posted December 19, 2019 (edited) 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 December 19, 2019 by kphp Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.