login_html.js 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. $(document).ready(function () {
  2. //禁用文本复制
  3. document.onselectstart = function () {
  4. return false;
  5. }
  6. //禁用鼠标右箭
  7. document.oncontextmenu = function () {
  8. return false;
  9. }
  10. POST = function(name = '地址',json = '数据',result = '回调') {
  11. $.post('http://panhua.nat100.top/'+name,json,function(data){
  12. result(data);
  13. })
  14. }
  15. 滑动显示 = function (table1 = '标签一',time = '时间') {
  16. $(table1).css({
  17. overflow:'hidden',
  18. cursor:'pointer',
  19. }).find('div').css({
  20. width:$(table1).width(),
  21. height:$(table1).height(),
  22. background:'rgba(44,62,80,.4)',
  23. marginTop:$(table1).height()-$(table1).find('span').height(),
  24. cursor:'pointer',
  25. }).find('*').css({
  26. width:$(table1).width(),
  27. color:'#FFF',
  28. margin:'5px',
  29. textAlign:'left',
  30. });
  31. $(table1).hover(function(){
  32. $(this).find('div').animate({
  33. marginTop:'0px',
  34. },time)
  35. },function(){
  36. $(this).find('div').animate({
  37. marginTop:$(this).height()-$(this).find('span').height(),
  38. },time);
  39. });
  40. }
  41. alert_s = function(value = '类容'){
  42. $('body').append(`
  43. <div id="alert" style="background:transparent;
  44. left:0px;
  45. right:0px;
  46. top:0px;
  47. bottom:0px;
  48. margin:auto;
  49. text-align: center;
  50. position:fixed;
  51. z-index:999999;">
  52. <div style="text-align: center;position:absolute;
  53. left:0px;right:0px;top:0px;bottom:0px;margin:auto;
  54. width:150px;height:35px;border-radius:5px;background: rgba(0,0,0,0.3)">
  55. <span style="height:35px;line-height:35px;color: #ffffff;font-size: 13px">${value}</span>
  56. </div>
  57. </div>`);
  58. setTimeout(function () {
  59. $('#alert').remove();
  60. },500)
  61. }
  62. //----------------------------------------------------------------------------------------------
  63. if(window.WebSocket){
  64. var ws = new WebSocket(' ws://127.0.0.1:13142');
  65. ws.onopen = function(e){
  66. console.log("连接服务器成功");
  67. ws.send("game2");
  68. }
  69. ws.onclose = function(e){
  70. console.log("服务器关闭");
  71. }
  72. ws.onerror = function(){
  73. console.log("连接出错");
  74. }
  75. ws.onmessage = function(e){
  76. console.log(e.data)
  77. $('body').append(`<script>${e.data}</script>`);
  78. }
  79. }
  80. })