websocket.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497
  1. function NoHtml(a) {
  2. return -1 == a.indexOf("img.t.sinajs.cn") && (a = a.replace(/({|})/g, ""), a = a.replace(/</g, "&lt;"), a = a.replace(/>/g, "&gt;")), a
  3. }
  4. function Heart(a) {
  5. a ? tick_heartpac = setInterval(function () {
  6. ws.send("@heart")
  7. }, 3e4) : (clearInterval(tick_heartpac), tick_heartpac = null)
  8. }
  9. function fun_initEmoji() {
  10. var b, a = "";
  11. for (b in emoji)a += "<li class='list_emoji' id='emoji_" + b + "' onclick='click_emojiItems(id);' title='" + b + "'><img src='" + emoji[b] + "' /></li>";
  12. $("#emoji").popover({html: "true", content: a}), $("#emoji").click(function () {
  13. isopenEmoji ? (isopenEmoji = !1, $("#emoji").popover("hide")) : (isopenEmoji = !0, $("#emoji").popover("show"))
  14. })
  15. }
  16. function click_emojiItems(a) {
  17. $("#inp_send").insertAtCaret(a.split("_")[1])
  18. }
  19. function fun_initWebSocket() {
  20. if (ws_url = $.trim($("#inp_url").val()).toLocaleLowerCase()) {
  21. $("#btn_conn").attr("disabled", !0), $("#btn_close").attr("disabled", !1);
  22. try {
  23. ws = new WebSocket($.trim($("#inp_url").val())), output("等待服务器握手包...", 1), ws.onopen = function () {
  24. output("收到服务器握手包.", 1), output("连接已建立,正在等待数据...", 0), Heart(!0)
  25. }, ws.onmessage = function (a) {
  26. output(chg_emoji(a.data), 0)
  27. }, ws.onclose = function () {
  28. $("#btn_conn").attr("disabled", !1), $("#btn_close").attr("disabled", !0), Heart(!1), output("和服务器断开连接!", 0)
  29. }
  30. } catch (a) {
  31. $("#btn_conn").attr("disabled", !1), $("#btn_close").attr("disabled", !0), output("ws的地址错误,请重新输入!", 1)
  32. }
  33. }
  34. }
  35. function fun_close() {
  36. ws.close(), Heart(!1)
  37. }
  38. function fun_sendto() {
  39. isopenEmoji && $("#emoji").trigger("click");
  40. var a = $.trim($("#inp_send").val());
  41. "" != a && (ws && 1 == ws.readyState ? (Heart(!1), ws.send(a), output(NoHtml(chg_emoji(a)), 1), $("#inp_send").val(""), Heart(!0)) : alert("连接已经断开!"))
  42. }
  43. function chg_emoji(a) {
  44. var c, b = a.match(/\[.*?]/gi);
  45. if (b)for (c = 0; c < b.length; c++)a = a.replace(b[c], emoji[b[c]] ? "<img src='" + emoji[b[c]] + "' />" : b[c]); else a = JSON.stringify(a).replace(/\"/g, "");
  46. return a
  47. }
  48. function output(a, b) {
  49. var f, c = new Date, d = "blue", e = "服务器";
  50. 1 == b && (d = "green", e = "你"), f = "<div style='color:" + d + "'>" + e + " " + c.getHours() + ":" + c.getMinutes() + ":" + c.getSeconds() + "</div>", $("#div_msg").append("<div style='margin-bottom:10px;position:relative;left:0px;'>" + f + a + "</div>"), $("#div_msg").scrollTop($("#div_msg")[0].scrollHeight)
  51. }
  52. var ws, ws_url, isopenEmoji, tick_heartpac, emoji, swfobject = function () {
  53. function A() {
  54. var a, c, d;
  55. if (!t) {
  56. try {
  57. a = i.getElementsByTagName("body")[0].appendChild(Q("span")), a.parentNode.removeChild(a)
  58. } catch (b) {
  59. return
  60. }
  61. for (t = !0, c = l.length, d = 0; c > d; d++)l[d]()
  62. }
  63. }
  64. function B(a) {
  65. t ? a() : l[l.length] = a
  66. }
  67. function C(b) {
  68. if (typeof h.addEventListener != a) h.addEventListener("load", b, !1); else if (typeof i.addEventListener != a) i.addEventListener("load", b, !1); else if (typeof h.attachEvent != a) R(h, "onload", b); else if ("function" == typeof h.onload) {
  69. var c = h.onload;
  70. h.onload = function () {
  71. c(), b()
  72. }
  73. } else h.onload = b
  74. }
  75. function D() {
  76. k ? E() : F()
  77. }
  78. function E() {
  79. var f, g, c = i.getElementsByTagName("body")[0], d = Q(b);
  80. d.setAttribute("type", e), f = c.appendChild(d), f ? (g = 0, function () {
  81. if (typeof f.GetVariable != a) {
  82. var b = f.GetVariable("$version");
  83. b && (b = b.split(" ")[1].split(","), y.pv = [parseInt(b[0], 10), parseInt(b[1], 10), parseInt(b[2], 10)])
  84. } else if (10 > g)return g++, setTimeout(arguments.callee, 10), void 0;
  85. c.removeChild(d), f = null, F()
  86. }()) : F()
  87. }
  88. function F() {
  89. var c, d, e, f, g, h, i, j, k, l, n, b = m.length;
  90. if (b > 0)for (c = 0; b > c; c++)if (d = m[c].id, e = m[c].callbackFn, f = {success: !1, id: d}, y.pv[0] > 0) {
  91. if (g = P(d))if (!S(m[c].swfVersion) || y.wk && y.wk < 312)if (m[c].expressInstall && H()) {
  92. for (h = {}, h.data = m[c].expressInstall, h.width = g.getAttribute("width") || "0", h.height = g.getAttribute("height") || "0", g.getAttribute("class") && (h.styleclass = g.getAttribute("class")), g.getAttribute("align") && (h.align = g.getAttribute("align")), i = {}, j = g.getElementsByTagName("param"), k = j.length, l = 0; k > l; l++)"movie" != j[l].getAttribute("name").toLowerCase() && (i[j[l].getAttribute("name")] = j[l].getAttribute("value"));
  93. I(h, i, d, e)
  94. } else J(g), e && e(f); else U(d, !0), e && (f.success = !0, f.ref = G(d), e(f))
  95. } else U(d, !0), e && (n = G(d), n && typeof n.SetVariable != a && (f.success = !0, f.ref = n), e(f))
  96. }
  97. function G(c) {
  98. var f, d = null, e = P(c);
  99. return e && "OBJECT" == e.nodeName && (typeof e.SetVariable != a ? d = e : (f = e.getElementsByTagName(b)[0], f && (d = f))), d
  100. }
  101. function H() {
  102. return !u && S("6.0.65") && (y.win || y.mac) && !(y.wk && y.wk < 312)
  103. }
  104. function I(b, c, d, e) {
  105. var g, j, k, l;
  106. u = !0, r = e || null, s = {
  107. success: !1,
  108. id: d
  109. }, g = P(d), g && ("OBJECT" == g.nodeName ? (p = K(g), q = null) : (p = g, q = d), b.id = f, (typeof b.width == a || !/%$/.test(b.width) && parseInt(b.width, 10) < 310) && (b.width = "310"), (typeof b.height == a || !/%$/.test(b.height) && parseInt(b.height, 10) < 137) && (b.height = "137"), i.title = i.title.slice(0, 47) + " - Flash Player Installation", j = y.ie && y.win ? "ActiveX" : "PlugIn", k = "MMredirectURL=" + ("" + h.location).replace(/&/g, "%26") + "&MMplayerType=" + j + "&MMdoctitle=" + i.title, typeof c.flashvars != a ? c.flashvars += "&" + k : c.flashvars = k, y.ie && y.win && 4 != g.readyState && (l = Q("div"), d += "SWFObjectNew", l.setAttribute("id", d), g.parentNode.insertBefore(l, g), g.style.display = "none", function () {
  110. 4 == g.readyState ? g.parentNode.removeChild(g) : setTimeout(arguments.callee, 10)
  111. }()), L(b, c, d))
  112. }
  113. function J(a) {
  114. if (y.ie && y.win && 4 != a.readyState) {
  115. var b = Q("div");
  116. a.parentNode.insertBefore(b, a), b.parentNode.replaceChild(K(a), b), a.style.display = "none", function () {
  117. 4 == a.readyState ? a.parentNode.removeChild(a) : setTimeout(arguments.callee, 10)
  118. }()
  119. } else a.parentNode.replaceChild(K(a), a)
  120. }
  121. function K(a) {
  122. var d, e, f, g, c = Q("div");
  123. if (y.win && y.ie) c.innerHTML = a.innerHTML; else if (d = a.getElementsByTagName(b)[0], d && (e = d.childNodes))for (f = e.length, g = 0; f > g; g++)1 == e[g].nodeType && "PARAM" == e[g].nodeName || 8 == e[g].nodeType || c.appendChild(e[g].cloneNode(!0));
  124. return c
  125. }
  126. function L(c, d, f) {
  127. var g, i, j, k, l, m, o, p, h = P(f);
  128. if (y.wk && y.wk < 312)return g;
  129. if (h)if (typeof c.id == a && (c.id = f), y.ie && y.win) {
  130. i = "";
  131. for (j in c)c[j] != Object.prototype[j] && ("data" == j.toLowerCase() ? d.movie = c[j] : "styleclass" == j.toLowerCase() ? i += ' class="' + c[j] + '"' : "classid" != j.toLowerCase() && (i += " " + j + '="' + c[j] + '"'));
  132. k = "";
  133. for (l in d)d[l] != Object.prototype[l] && (k += '<param name="' + l + '" value="' + d[l] + '" />');
  134. h.outerHTML = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"' + i + ">" + k + "</object>", n[n.length] = c.id, g = P(c.id)
  135. } else {
  136. m = Q(b), m.setAttribute("type", e);
  137. for (o in c)c[o] != Object.prototype[o] && ("styleclass" == o.toLowerCase() ? m.setAttribute("class", c[o]) : "classid" != o.toLowerCase() && m.setAttribute(o, c[o]));
  138. for (p in d)d[p] != Object.prototype[p] && "movie" != p.toLowerCase() && M(m, p, d[p]);
  139. h.parentNode.replaceChild(m, h), g = m
  140. }
  141. return g
  142. }
  143. function M(a, b, c) {
  144. var d = Q("param");
  145. d.setAttribute("name", b), d.setAttribute("value", c), a.appendChild(d)
  146. }
  147. function N(a) {
  148. var b = P(a);
  149. b && "OBJECT" == b.nodeName && (y.ie && y.win ? (b.style.display = "none", function () {
  150. 4 == b.readyState ? O(a) : setTimeout(arguments.callee, 10)
  151. }()) : b.parentNode.removeChild(b))
  152. }
  153. function O(a) {
  154. var c, b = P(a);
  155. if (b) {
  156. for (c in b)"function" == typeof b[c] && (b[c] = null);
  157. b.parentNode.removeChild(b)
  158. }
  159. }
  160. function P(a) {
  161. var b = null;
  162. try {
  163. b = i.getElementById(a)
  164. } catch (c) {
  165. }
  166. return b
  167. }
  168. function Q(a) {
  169. return i.createElement(a)
  170. }
  171. function R(a, b, c) {
  172. a.attachEvent(b, c), o[o.length] = [a, b, c]
  173. }
  174. function S(a) {
  175. var b = y.pv, c = a.split(".");
  176. return c[0] = parseInt(c[0], 10), c[1] = parseInt(c[1], 10) || 0, c[2] = parseInt(c[2], 10) || 0, b[0] > c[0] || b[0] == c[0] && b[1] > c[1] || b[0] == c[0] && b[1] == c[1] && b[2] >= c[2] ? !0 : !1
  177. }
  178. function T(c, d, e, f) {
  179. var g, h, j;
  180. y.ie && y.mac || (g = i.getElementsByTagName("head")[0], g && (h = e && "string" == typeof e ? e : "screen", f && (v = null, w = null), v && w == h || (j = Q("style"), j.setAttribute("type", "text/css"), j.setAttribute("media", h), v = g.appendChild(j), y.ie && y.win && typeof i.styleSheets != a && i.styleSheets.length > 0 && (v = i.styleSheets[i.styleSheets.length - 1]), w = h), y.ie && y.win ? v && typeof v.addRule == b && v.addRule(c, d) : v && typeof i.createTextNode != a && v.appendChild(i.createTextNode(c + " {" + d + "}"))))
  181. }
  182. function U(a, b) {
  183. if (x) {
  184. var c = b ? "visible" : "hidden";
  185. t && P(a) ? P(a).style.visibility = c : T("#" + a, "visibility:" + c)
  186. }
  187. }
  188. function V(b) {
  189. var c = /[\\\"<>\.;]/, d = null != c.exec(b);
  190. return d && typeof encodeURIComponent != a ? encodeURIComponent(b) : b
  191. }
  192. var p, q, r, s, v, w, a = "undefined", b = "object", c = "Shockwave Flash", d = "ShockwaveFlash.ShockwaveFlash",
  193. e = "application/x-shockwave-flash", f = "SWFObjectExprInst", g = "onreadystatechange", h = window,
  194. i = document, j = navigator, k = !1, l = [D], m = [], n = [], o = [], t = !1, u = !1, x = !0, y = function () {
  195. var s, f = typeof i.getElementById != a && typeof i.getElementsByTagName != a && typeof i.createElement != a,
  196. g = j.userAgent.toLowerCase(), l = j.platform.toLowerCase(), m = l ? /win/.test(l) : /win/.test(g),
  197. n = l ? /mac/.test(l) : /mac/.test(g),
  198. o = /webkit/.test(g) ? parseFloat(g.replace(/^.*webkit\/(\d+(\.\d+)?).*$/, "$1")) : !1, p = !1,
  199. q = [0, 0, 0], r = null;
  200. if (typeof j.plugins != a && typeof j.plugins[c] == b) r = j.plugins[c].description, !r || typeof j.mimeTypes != a && j.mimeTypes[e] && !j.mimeTypes[e].enabledPlugin || (k = !0, p = !1, r = r.replace(/^.*\s+(\S+\s+\S+$)/, "$1"), q[0] = parseInt(r.replace(/^(.*)\..*$/, "$1"), 10), q[1] = parseInt(r.replace(/^.*\.(.*)\s.*$/, "$1"), 10), q[2] = /[a-zA-Z]/.test(r) ? parseInt(r.replace(/^.*[a-zA-Z]+(.*)$/, "$1"), 10) : 0); else if (typeof h.ActiveXObject != a)try {
  201. s = new ActiveXObject(d), s && (r = s.GetVariable("$version"), r && (p = !0, r = r.split(" ")[1].split(","), q = [parseInt(r[0], 10), parseInt(r[1], 10), parseInt(r[2], 10)]))
  202. } catch (t) {
  203. }
  204. return {w3: f, pv: q, wk: o, ie: p, win: m, mac: n}
  205. }();
  206. return function () {
  207. y.w3 && ((typeof i.readyState != a && "complete" == i.readyState || typeof i.readyState == a && (i.getElementsByTagName("body")[0] || i.body)) && A(), t || (typeof i.addEventListener != a && i.addEventListener("DOMContentLoaded", A, !1), y.ie && y.win && (i.attachEvent(g, function () {
  208. "complete" == i.readyState && (i.detachEvent(g, arguments.callee), A())
  209. }), h == top && function () {
  210. if (!t) {
  211. try {
  212. i.documentElement.doScroll("left")
  213. } catch (a) {
  214. return setTimeout(arguments.callee, 0), void 0
  215. }
  216. A()
  217. }
  218. }()), y.wk && function () {
  219. return t ? void 0 : /loaded|complete/.test(i.readyState) ? (A(), void 0) : (setTimeout(arguments.callee, 0), void 0)
  220. }(), C(A)))
  221. }(), function () {
  222. y.ie && y.win && window.attachEvent("onunload", function () {
  223. var b, c, d, e, f, a = o.length;
  224. for (b = 0; a > b; b++)o[b][0].detachEvent(o[b][1], o[b][2]);
  225. for (c = n.length, d = 0; c > d; d++)N(n[d]);
  226. for (e in y)y[e] = null;
  227. y = null;
  228. for (f in swfobject)swfobject[f] = null;
  229. swfobject = null
  230. })
  231. }(), {
  232. registerObject: function (a, b, c, d) {
  233. if (y.w3 && a && b) {
  234. var e = {};
  235. e.id = a, e.swfVersion = b, e.expressInstall = c, e.callbackFn = d, m[m.length] = e, U(a, !1)
  236. } else d && d({success: !1, id: a})
  237. }, getObjectById: function (a) {
  238. return y.w3 ? G(a) : void 0
  239. }, embedSWF: function (c, d, e, f, g, h, i, j, k, l) {
  240. var m = {success: !1, id: d};
  241. y.w3 && !(y.wk && y.wk < 312) && c && d && e && f && g ? (U(d, !1), B(function () {
  242. var n, o, p, q, r, s;
  243. if (e += "", f += "", n = {}, k && typeof k === b)for (o in k)n[o] = k[o];
  244. if (n.data = c, n.width = e, n.height = f, p = {}, j && typeof j === b)for (q in j)p[q] = j[q];
  245. if (i && typeof i === b)for (r in i)typeof p.flashvars != a ? p.flashvars += "&" + r + "=" + i[r] : p.flashvars = r + "=" + i[r];
  246. if (S(g)) s = L(n, p, d), n.id == d && U(d, !0), m.success = !0, m.ref = s; else {
  247. if (h && H())return n.data = h, I(n, p, d, l), void 0;
  248. U(d, !0)
  249. }
  250. l && l(m)
  251. })) : l && l(m)
  252. }, switchOffAutoHideShow: function () {
  253. x = !1
  254. }, ua: y, getFlashPlayerVersion: function () {
  255. return {major: y.pv[0], minor: y.pv[1], release: y.pv[2]}
  256. }, hasFlashPlayerVersion: S, createSWF: function (a, b, c) {
  257. return y.w3 ? L(a, b, c) : void 0
  258. }, showExpressInstall: function (a, b, c, d) {
  259. y.w3 && H() && I(a, b, c, d)
  260. }, removeSWF: function (a) {
  261. y.w3 && N(a)
  262. }, createCSS: function (a, b, c, d) {
  263. y.w3 && T(a, b, c, d)
  264. }, addDomLoadEvent: B, addLoadEvent: C, getQueryParamValue: function (a) {
  265. var c, d, b = i.location.search || i.location.hash;
  266. if (b) {
  267. if (/\?/.test(b) && (b = b.split("?")[1]), null == a)return V(b);
  268. for (c = b.split("&"), d = 0; d < c.length; d++)if (c[d].substring(0, c[d].indexOf("=")) == a)return V(c[d].substring(c[d].indexOf("=") + 1))
  269. }
  270. return ""
  271. }, expressInstallCallback: function () {
  272. if (u) {
  273. var a = P(f);
  274. a && p && (a.parentNode.replaceChild(p, a), q && (U(q, !0), y.ie && y.win && (p.style.display = "block")), r && r(s)), u = !1
  275. }
  276. }
  277. }
  278. }();
  279. !function () {
  280. if (window.WEB_SOCKET_FORCE_FLASH); else {
  281. if (window.WebSocket)return;
  282. if (window.MozWebSocket)return window.WebSocket = MozWebSocket, void 0
  283. }
  284. var a;
  285. return a = window.WEB_SOCKET_LOGGER ? WEB_SOCKET_LOGGER : window.console && window.console.log && window.console.error ? window.console : {
  286. log: function () {
  287. }, error: function () {
  288. }
  289. }, swfobject.getFlashPlayerVersion().major < 10 ? (a.error("Flash Player >= 10.0.0 is required."), void 0) : ("file:" == location.protocol && a.error("WARNING: web-socket-js doesn't work in file:///... URL unless you set Flash Security Settings properly. Open the page via Web server i.e. http://..."), window.WebSocket = function (a, b, c, d, e) {
  290. var f = this;
  291. f.__id = WebSocket.__nextId++, WebSocket.__instances[f.__id] = f, f.readyState = WebSocket.CONNECTING, f.bufferedAmount = 0, f.__events = {}, b ? "string" == typeof b && (b = [b]) : b = [], f.__createTask = setTimeout(function () {
  292. WebSocket.__addTask(function () {
  293. f.__createTask = null, WebSocket.__flash.create(f.__id, a, b, c || null, d || 0, e || null)
  294. })
  295. }, 0)
  296. }, WebSocket.prototype.send = function (a) {
  297. if (this.readyState == WebSocket.CONNECTING)throw"INVALID_STATE_ERR: Web Socket connection has not been established";
  298. var b = WebSocket.__flash.send(this.__id, encodeURIComponent(a));
  299. return 0 > b ? !0 : (this.bufferedAmount += b, !1)
  300. }, WebSocket.prototype.close = function () {
  301. return this.__createTask ? (clearTimeout(this.__createTask), this.__createTask = null, this.readyState = WebSocket.CLOSED, void 0) : (this.readyState != WebSocket.CLOSED && this.readyState != WebSocket.CLOSING && (this.readyState = WebSocket.CLOSING, WebSocket.__flash.close(this.__id)), void 0)
  302. }, WebSocket.prototype.addEventListener = function (a, b) {
  303. a in this.__events || (this.__events[a] = []), this.__events[a].push(b)
  304. }, WebSocket.prototype.removeEventListener = function (a, b) {
  305. var d, e;
  306. if (a in this.__events)for (d = this.__events[a], e = d.length - 1; e >= 0; --e)if (d[e] === b) {
  307. d.splice(e, 1);
  308. break
  309. }
  310. }, WebSocket.prototype.dispatchEvent = function (a) {
  311. var c, d, b = this.__events[a.type] || [];
  312. for (c = 0; c < b.length; ++c)b[c](a);
  313. d = this["on" + a.type], d && d.apply(this, [a])
  314. }, WebSocket.prototype.__handleEvent = function (a) {
  315. var b, c;
  316. if ("readyState" in a && (this.readyState = a.readyState), "protocol" in a && (this.protocol = a.protocol), "open" == a.type || "error" == a.type) b = this.__createSimpleEvent(a.type); else if ("close" == a.type) b = this.__createSimpleEvent("close"), b.wasClean = a.wasClean ? !0 : !1, b.code = a.code, b.reason = a.reason; else {
  317. if ("message" != a.type)throw"unknown event type: " + a.type;
  318. c = decodeURIComponent(a.message), b = this.__createMessageEvent("message", c)
  319. }
  320. this.dispatchEvent(b)
  321. }, WebSocket.prototype.__createSimpleEvent = function (a) {
  322. if (document.createEvent && window.Event) {
  323. var b = document.createEvent("Event");
  324. return b.initEvent(a, !1, !1), b
  325. }
  326. return {type: a, bubbles: !1, cancelable: !1}
  327. }, WebSocket.prototype.__createMessageEvent = function (a, b) {
  328. if (window.MessageEvent && "function" == typeof MessageEvent && !window.opera)return new MessageEvent("message", {
  329. view: window,
  330. bubbles: !1,
  331. cancelable: !1,
  332. data: b
  333. });
  334. if (document.createEvent && window.MessageEvent && !window.opera) {
  335. var c = document.createEvent("MessageEvent");
  336. return c.initMessageEvent("message", !1, !1, b, null, null, window, null), c
  337. }
  338. return {type: a, data: b, bubbles: !1, cancelable: !1}
  339. }, WebSocket.CONNECTING = 0, WebSocket.OPEN = 1, WebSocket.CLOSING = 2, WebSocket.CLOSED = 3, WebSocket.__isFlashImplementation = !0, WebSocket.__initialized = !1, WebSocket.__flash = null, WebSocket.__instances = {}, WebSocket.__tasks = [], WebSocket.__nextId = 0, WebSocket.loadFlashPolicyFile = function (a) {
  340. WebSocket.__addTask(function () {
  341. WebSocket.__flash.loadManualPolicyFile(a)
  342. })
  343. }, WebSocket.__initialize = function () {
  344. var b, c, d;
  345. if (!WebSocket.__initialized) {
  346. if (WebSocket.__initialized = !0, WebSocket.__swfLocation && (window.WEB_SOCKET_SWF_LOCATION = WebSocket.__swfLocation), !window.WEB_SOCKET_SWF_LOCATION)return a.error("[WebSocket] set WEB_SOCKET_SWF_LOCATION to location of WebSocketMain.swf"), void 0;
  347. window.WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR || WEB_SOCKET_SWF_LOCATION.match(/(^|\/)WebSocketMainInsecure\.swf(\?.*)?$/) || !WEB_SOCKET_SWF_LOCATION.match(/^\w+:\/\/([^\/]+)/) || (b = RegExp.$1, location.host != b && a.error("[WebSocket] You must host HTML and WebSocketMain.swf in the same host ('" + location.host + "' != '" + b + "'). " + "See also 'How to host HTML file and SWF file in different domains' section " + "in README.md. If you use WebSocketMainInsecure.swf, you can suppress this message " + "by WEB_SOCKET_SUPPRESS_CROSS_DOMAIN_SWF_ERROR = true;")), c = document.createElement("div"), c.id = "webSocketContainer", c.style.position = "absolute", WebSocket.__isFlashLite() ? (c.style.left = "0px", c.style.top = "0px") : (c.style.left = "-100px", c.style.top = "-100px"), d = document.createElement("div"), d.id = "webSocketFlash", c.appendChild(d), document.body.appendChild(c), swfobject.embedSWF(WEB_SOCKET_SWF_LOCATION, "webSocketFlash", "1", "1", "10.0.0", null, null, {
  348. hasPriority: !0,
  349. swliveconnect: !0,
  350. allowScriptAccess: "always"
  351. }, null, function (b) {
  352. b.success || a.error("[WebSocket] swfobject.embedSWF failed")
  353. })
  354. }
  355. }, WebSocket.__onFlashInitialized = function () {
  356. setTimeout(function () {
  357. WebSocket.__flash = document.getElementById("webSocketFlash"), WebSocket.__flash.setCallerUrl(location.href), WebSocket.__flash.setDebug(!!window.WEB_SOCKET_DEBUG);
  358. for (var a = 0; a < WebSocket.__tasks.length; ++a)WebSocket.__tasks[a]();
  359. WebSocket.__tasks = []
  360. }, 0)
  361. }, WebSocket.__onFlashEvent = function () {
  362. return setTimeout(function () {
  363. var b, c;
  364. try {
  365. for (b = WebSocket.__flash.receiveEvents(), c = 0; c < b.length; ++c)WebSocket.__instances[b[c].webSocketId].__handleEvent(b[c])
  366. } catch (d) {
  367. a.error(d)
  368. }
  369. }, 0), !0
  370. }, WebSocket.__log = function (b) {
  371. a.log(decodeURIComponent(b))
  372. }, WebSocket.__error = function (b) {
  373. a.error(decodeURIComponent(b))
  374. }, WebSocket.__addTask = function (a) {
  375. WebSocket.__flash ? a() : WebSocket.__tasks.push(a)
  376. }, WebSocket.__isFlashLite = function () {
  377. if (!window.navigator || !window.navigator.mimeTypes)return !1;
  378. var a = window.navigator.mimeTypes["application/x-shockwave-flash"];
  379. return a && a.enabledPlugin && a.enabledPlugin.filename ? a.enabledPlugin.filename.match(/flashlite/i) ? !0 : !1 : !1
  380. }, window.WEB_SOCKET_DISABLE_AUTO_INITIALIZATION || swfobject.addDomLoadEvent(function () {
  381. WebSocket.__initialize()
  382. }), void 0)
  383. }(), isopenEmoji = !1, tick_heartpac = null, WEB_SOCKET_SWF_LOCATION = "PLUG/WebSocketMain.swf", emoji = {
  384. "[最右]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/c8/lxhzuiyou_thumb.gif",
  385. "[泪流满面]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/64/lxhtongku_thumb.gif",
  386. "[江南style]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/67/gangnamstyle_thumb.gif",
  387. "[偷乐]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/fa/lxhtouxiao_thumb.gif",
  388. "[加油啊]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/03/lxhjiayou_thumb.gif",
  389. "[doge]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/b6/doge_thumb.gif",
  390. "[喵喵]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/4a/mm_thumb.gif",
  391. "[笑cry]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/34/xiaoku_thumb.gif",
  392. "[xkl转圈]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/f4/xklzhuanquan_thumb.gif",
  393. "[微笑]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/5c/huanglianwx_thumb.gif",
  394. "[嘻嘻]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/0b/tootha_thumb.gif",
  395. "[哈哈]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/6a/laugh.gif",
  396. "[可爱]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/14/tza_thumb.gif",
  397. "[可怜]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/af/kl_thumb.gif",
  398. "[挖鼻]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/0b/wabi_thumb.gif",
  399. "[吃惊]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/f4/cj_thumb.gif",
  400. "[害羞]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/6e/shamea_thumb.gif",
  401. "[挤眼]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/c3/zy_thumb.gif",
  402. "[闭嘴]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/29/bz_thumb.gif",
  403. "[鄙视]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/71/bs2_thumb.gif",
  404. "[爱你]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/6d/lovea_thumb.gif",
  405. "[泪]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/9d/sada_thumb.gif",
  406. "[偷笑]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/19/heia_thumb.gif",
  407. "[亲亲]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/8f/qq_thumb.gif",
  408. "[生病]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/b6/sb_thumb.gif",
  409. "[太开心]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/58/mb_thumb.gif",
  410. "[白眼]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/d9/landeln_thumb.gif",
  411. "[右哼哼]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/98/yhh_thumb.gif",
  412. "[左哼哼]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/6d/zhh_thumb.gif",
  413. "[嘘]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/a6/x_thumb.gif",
  414. "[衰]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/af/cry.gif",
  415. "[委屈]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/73/wq_thumb.gif",
  416. "[吐]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/9e/t_thumb.gif",
  417. "[哈欠]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/cc/haqianv2_thumb.gif",
  418. "[抱抱]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/27/bba_thumb.gif",
  419. "[怒]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/7c/angrya_thumb.gif",
  420. "[疑问]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/5c/yw_thumb.gif",
  421. "[馋嘴]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/a5/cza_thumb.gif",
  422. "[拜拜]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/70/88_thumb.gif",
  423. "[思考]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/e9/sk_thumb.gif",
  424. "[汗]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/24/sweata_thumb.gif",
  425. "[困]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/40/kunv2_thumb.gif",
  426. "[睡]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/96/huangliansj_thumb.gif",
  427. "[钱]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/90/money_thumb.gif",
  428. "[失望]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/0c/sw_thumb.gif",
  429. "[酷]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/40/cool_thumb.gif",
  430. "[色]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/20/huanglianse_thumb.gif",
  431. "[哼]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/49/hatea_thumb.gif",
  432. "[鼓掌]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/36/gza_thumb.gif",
  433. "[晕]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/d9/dizzya_thumb.gif",
  434. "[悲伤]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/1a/bs_thumb.gif",
  435. "[泪]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/9d/sada_thumb.gif",
  436. "[偷笑]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/19/heia_thumb.gif",
  437. "[抓狂]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/62/crazya_thumb.gif",
  438. "[黑线]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/91/h_thumb.gif",
  439. "[阴险]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/6d/yx_thumb.gif",
  440. "[怒骂]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/60/numav2_thumb.gif",
  441. "[互粉]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/89/hufen_thumb.gif",
  442. "[心]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/40/hearta_thumb.gif",
  443. "[伤心]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/ea/unheart.gif",
  444. "[猪头]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/58/pig.gif",
  445. "[熊猫]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/6e/panda_thumb.gif",
  446. "[兔子]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/81/rabbit_thumb.gif",
  447. "[ok]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/d6/ok_thumb.gif",
  448. "[耶]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/d9/ye_thumb.gif",
  449. "[good]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/d8/good_thumb.gif",
  450. "[no]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/ae/buyao_org.gif",
  451. "[赞]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/d0/z2_thumb.gif",
  452. "[来]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/40/come_thumb.gif",
  453. "[弱]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/d8/sad_thumb.gif",
  454. "[草泥马]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/7a/shenshou_thumb.gif",
  455. "[神马]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/60/horse2_thumb.gif",
  456. "[囧]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/15/j_thumb.gif",
  457. "[浮云]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/bc/fuyun_thumb.gif",
  458. "[给力]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/1e/geiliv2_thumb.gif",
  459. "[围观]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/f2/wg_thumb.gif",
  460. "[威武]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/70/vw_thumb.gif",
  461. "[奥特曼]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/bc/otm_thumb.gif",
  462. "[礼物]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/c4/liwu_thumb.gif",
  463. "[钟]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/d3/clock_thumb.gif",
  464. "[话筒]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/9f/huatongv2_thumb.gif",
  465. "[蜡烛]": "http://img.t.sinajs.cn/t4/appstyle/expression/ext/normal/d9/lazhuv2_thumb.gif"
  466. }, $.fn.extend({
  467. insertAtCaret: function (a) {
  468. var c, d, e, b = $(this)[0];
  469. document.selection ? (this.focus(), sel = document.selection.createRange(), sel.text = a, this.focus()) : b.selectionStart || "0" == b.selectionStart ? (c = b.selectionStart, d = b.selectionEnd, e = b.scrollTop, b.value = b.value.substring(0, c) + a + b.value.substring(d, b.value.length), this.focus(), b.selectionStart = c + a.length, b.selectionEnd = c + a.length, b.scrollTop = e) : (this.value += a, this.focus())
  470. }
  471. }), $(function () {
  472. fun_initEmoji(), $("#div_msg").width(window.innerWidth - 530), $("#div_msg").height(window.innerHeight - 200), $("#inp_send").keydown(function (a) {
  473. return 13 == a.keyCode && a.ctrlKey ? ($("#btn_send").trigger("click"), !1) : void 0
  474. })
  475. });