Advertisement
Guest User

Untitled

a guest
Aug 11th, 2017
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.31 KB | None | 0 0
  1. var currentRoom = null,
  2. currentGame = null,
  3. proxy = null;
  4. atWar.Static && atWar.Static.Proxy && (proxy = atWar.Static.Proxy);
  5. null == proxy && (proxy = atWar.ConnectionProxyFactory.CreateConnection(), proxy.add_ConnectionError(onConnectionError), proxy.add_ConnectionFailed(onConnectionFailed), proxy.add_ConnectionClosed(onConnectionFailed), proxy.add_Disconnected(onConnectionFailed), proxy.add_Reconnected(onReconnected), proxy.Connect(user_hash, user_kauth));
  6. setInterval(function() {
  7. proxy.get_IsConnected() && proxy.SendMessage(new MCUser$Ping)
  8. }, 3E4);
  9. window.onbeforeunload = function() {
  10. proxy.Disconnect(null, !0)
  11. };
  12. var connectionFailed = !1;
  13.  
  14. function onConnectionFailed(a) {
  15. connectionFailed || (connectionFailed = !0, $("#overlay").fadeOut(), DoConfirm2((Localize(a) || Localize("Connection lost")) + " - " + Localize("Reload") + "?", function() {
  16. location.reload()
  17. }, !1))
  18. }
  19.  
  20. function onConnectionError(a) {
  21. connectionFailed || ("function" === typeof addChatText ? (a = null != a ? null != a.message ? a.message : a : "unstable", a = Localize("Connection error") + ": " + a, addChatText(1, a, 0, null, null, !1)) : onConnectionFailed(a))
  22. }
  23.  
  24. function onReconnected() {
  25. if ("function" === typeof addChatText) {
  26. var a = Localize("Connection restored");
  27. addChatText(1, a, 0, null, null, !1)
  28. }
  29. }
  30.  
  31. function display_user(a) {
  32. display_user(a, !1, !1)
  33. }
  34.  
  35. function display_user(a, d) {
  36. display_user(a, d, !1)
  37. }
  38.  
  39. function display_user(a, d, c) {
  40. if (null != a) {
  41. var b = a.Name;
  42. "function" == typeof a.GetFormattedName && (b = a.GetFormattedName());
  43. var e = "";
  44. 1 != d && (e = display_user_rank(a));
  45. var g = $("<a href='javascript:void(0)'>" + b + "</a>");
  46. g.click(function(b) {
  47. b.preventDefault();
  48. b.stopPropagation();
  49. show_user_popover(g, a);
  50. c && a.Id != user_id && sendPM(a.Id, a.Name)
  51. });
  52. b = "";
  53. return b = 1 == d ? $("<span></span>").append(g) : $("<span></span>").append(e).append(" ").append(g)
  54. }
  55. return ""
  56. }
  57.  
  58. function display_user_rank(a) {
  59. if (null != a) {
  60. var d = "blackshield",
  61. c = "",
  62. b = "Rank " + a.Rank;
  63. (a.Flags & UserFlags.prototype.IsIncognito) == UserFlags.prototype.IsIncognito ? (b = Localize("Incognito mode"), a.Rank = "incognito", link = "") : ((a.Flags & UserFlags.prototype.PositionAdmin) == UserFlags.prototype.PositionAdmin ? (d = "redshield", c = "\n" + Localize("Admin")) : (a.Flags & UserFlags.prototype.PositionMod) == UserFlags.prototype.PositionMod ? (d = "blueshield", c = "\n" + Localize("Moderator")) : (a.Flags & UserFlags.prototype.IsPremium) == UserFlags.prototype.IsPremium &&
  64. (d = "goldshield", c = "\n" + Localize("Premium")), 1 > a.Rank && (a.Rank = "0", b = Localize("Rank") + " 0"));
  65. return $("<img src=/images/ranks/" + d + "/" + a.Rank + ".png width=18 height=18 title='" + b + " " + c + "'>")
  66. }
  67. return ""
  68. }
  69.  
  70. function display_user_avatar(a, d, c, b, e) {
  71. e = "";
  72. e = "../images/avatars/default.jpg";
  73. "" != d && null != d && (e = "../images/avatars/" + a.toString().substring(0, 1) + "/" + a + "." + d);
  74. e = "<img src=" + e + " class='pull-right rounded' style='" + c + "'>";
  75. b && (e = "<a target=_blank href=../users/profile.php?user_id=" + a + ">" + e + "</a>");
  76. return e
  77. }
  78.  
  79. function show_user_popover(a, d) {
  80. if (null != d && (d.Flags & UserFlags.prototype.IsIncognito) != UserFlags.prototype.IsIncognito) {
  81. $('[rel="popover"]').not(a).popover("destroy");
  82. $(".popover:not(.in)").hide().detach();
  83. if ("popover" != $(a).attr("rel")) {
  84. var c = new MCUser$GetAdditionalUserInfo;
  85. c.UserId = d.Id;
  86. proxy.SendEchoMessage(c, function(b) {
  87. $(a).popover("destroy");
  88. if (0 == b.Code) {
  89. b.Data = atWar.JarrSerializer.Deserialize$1(AdditionalUserInfo).call(null, b.Data);
  90. var c = $("<div style='min-width:150px;white-space: nowrap;' class='mini dark mini-line'></div>"),
  91. g = $("<div></div>"),
  92. f = display_user_avatar(d.Id, b.Data.Avatar, "width:50px;height:50px;margin-left:6px", !0, !1);
  93. g.append(f);
  94. g.append("<a class=darkgreen target=_blank href=../users/profile.php?user_id=" + d.Id + ">" + d.Name + "</a>");
  95. null != b.Data.Coalition && g.append("<br><a class='mini dark' style='display:block;margin-top:-2px' target=_blank href=../cln/cln.php?cln_id=" + b.Data.Coalition.Id + ">" + b.Data.Coalition.Value + "</a>");
  96. c.append(Localize("Rank") + ": " + d.Rank + " | Elo: " + Math.round(b.Data.Elo) + "<br>");
  97. c.append(Localize("Reputation") +
  98. ": <span id=popup_user_rep" + d.Id + " class='blue'>" + Math.round(b.Data.Rep) + "</span> ");
  99. if (d.Id != user_id && (b.Data.Flags & AdditionalUserFlags.prototype.IsRepped) != AdditionalUserFlags.prototype.IsRepped) {
  100. var h = $("<a id=popup_user_rep_button" + d.Id + ' class=green href="javascript:void(0)"><i class=\'fa fa-plus-circle fa-lg\' title="' + Localize("Add +1 to reputation") + '"></i></a>');
  101. h.click(function(a) {
  102. a.stopPropagation();
  103. donateRep(d.Id, b.Data.Rep)
  104. })
  105. }
  106. c.append(h);
  107. c.append("<br>");
  108. (b.Data.Flags & AdditionalUserFlags.prototype.IsOnline) !=
  109. AdditionalUserFlags.prototype.IsOnline && c.append("<span style='font-style:italic'>" + Localize("offline") + "</span><br>");
  110. b.Data.IsAFK ? c.append("<span class=red>" + Localize("AFK") + "</span><br>") : null != b.Data.Location && "" != b.Data.Location && c.append("<span style='font-style:italic'>" + LocalizeParts(b.Data.Location) + "</span><br>");
  111. if (d.Id != user_id) {
  112. 2 != user_pos && 3 != user_pos || (b.Data.Flags & AdditionalUserFlags.prototype.IsOnline) != AdditionalUserFlags.prototype.IsOnline || c.append("<hr style='margin-top:8px'><div class=text-center style='padding:3px'><a class=red href='javascript:void(0)' onclick='warnPlayer_Click(this, " +
  113. d.Id + ")'>" + Localize("Send warning") + "</a> &nbsp;|&nbsp; <a class=red href='javascript:void(0)' onclick='mutePlayer_Click(this, " + d.Id + ")'>" + Localize("Mute for 15 min") + "</a></div><hr>");
  114. f = $("<div class=user_popover_buttons style='margin-top:10px'></div>");
  115. (b.Data.Flags & AdditionalUserFlags.prototype.IsOnline) == AdditionalUserFlags.prototype.IsOnline && (h = $("<button type=button class='btn btn-info btn-xs' title='" + Localize("Send private message") + "'><i class='fa fa-comments'></i></button>"), h.click(function() {
  116. $(a).popover("destroy").attr("rel",
  117. "");
  118. sendPM2(d.Id, d.Name)
  119. }), f.append(h));
  120. h = $("<a class='btn btn-info btn-xs' title='" + Localize("Send PM") + "' href=../users/pm.php?new_pm=1&user_id=" + d.Id + " target=_blank><i class='fa fa-envelope'></i></a>");
  121. f.append(h);
  122. var k = $("<button type=button class='btnFriend btn btn-success btn-xs' title='" + Localize("Add player to Friends") + "'><i class='fa fa-user fa-lg'></i> <i class='fa fa-plus mini'></i></button>"),
  123. l = $("<button type=button class='btnUnfriend btn btn-default btn-xs' style='display:none' title='" +
  124. Localize("Remove player from Friends") + "'><i class='fa fa-user fa-lg'></i> <i class='fa fa-minus mini'></i></button>");
  125. k.click(function() {
  126. btnAddFriend_Click(k, l, d)
  127. });
  128. l.click(function() {
  129. btnRemoveFriend_Click(k, l, d)
  130. });
  131. (b.Data.Flags & AdditionalUserFlags.prototype.IsFriend) == AdditionalUserFlags.prototype.IsFriend && (k.css("display", "none"), l.css("display", ""));
  132. f.append(k);
  133. f.append(l);
  134. var m = $("<button type=button class='btn btn-danger btn-xs' title='" + Localize("Add player to Enemies") + "'>E <i class='fa fa-plus mini'></i></button>"),
  135. n = $("<button type=button class='btn btn-default btn-xs' style='display:none' title='" + Localize("Remove player from Enemies") + "'>E <i class='fa fa-minus mini'></i></button>");
  136. m.click(function() {
  137. btnAddEnemy_Click(m, n, d)
  138. });
  139. n.click(function() {
  140. btnRemoveEnemy_Click(m, n, d)
  141. });
  142. (b.Data.Flags & AdditionalUserFlags.prototype.IsEnemy) == AdditionalUserFlags.prototype.IsEnemy && (m.css("display", "none"), n.css("display", ""));
  143. f.append(m);
  144. f.append(n);
  145. var p = $("<button type=button class='btn btn-warning btn-xs' title='" +
  146. Localize("Ignore player") + "'><i class='fa fa-user fa-lg'></i> <i class='fa fa-ban mini'></i></button>"),
  147. q = $("<button type=button class='btn btn-default btn-xs' style='display:none' title='" + Localize("Unignore player") + "'><i class='fa fa-user fa-lg'></i> <i class='fa fa-bullhorn mini'></i></button>");
  148. p.click(function() {
  149. btnIgnore_Click(p, q, d)
  150. });
  151. q.click(function() {
  152. btnUnignore_Click(p, q, d)
  153. });
  154. (b.Data.Flags & AdditionalUserFlags.prototype.IsIgnored) == AdditionalUserFlags.prototype.IsIgnored && (p.css("display",
  155. "none"), q.css("display", ""));
  156. f.append(p);
  157. f.append(q);
  158. c.append(f)
  159. }
  160. $(a).popover({
  161. title: g,
  162. content: c,
  163. html: !0,
  164. container: "body",
  165. placement: "top"
  166. }).popover("toggle");
  167. $(a).attr("rel", "popover")
  168. }
  169. })
  170. } else $(a).popover("destroy").attr("rel", ""), $(".popover:not(.in)").hide().detach();
  171. $("body").on("click", function(a) {
  172. $('[rel="popover"]').each(function() {
  173. $(this).is(a.target) || 0 !== $(this).has(a.target).length || 0 !== $(".popover").has(a.target).length || $(this).popover("destroy").attr("rel", "")
  174. })
  175. });
  176. $("body").on("hidden.bs.popover",
  177. function() {
  178. $(".popover:not(.in)").hide().detach()
  179. })
  180. }
  181. }
  182.  
  183. function btnAddFriend_Click(a, d, c) {
  184. if (0 < c.Id) {
  185. var b = new MCUser$AddFriend;
  186. b.UserId = c.Id;
  187. b.UserName = c.Name;
  188. b.IsEnemy = !1;
  189. b.Flags = c.Flags;
  190. b.Rank = c.Rank;
  191. proxy.SendEchoMessage(b, function(b) {
  192. 0 == b.Code && (a.hide(), d.show(), "friends" == currentPlayerGroup && load_chat_players(currentPlayerGroup), addChatPlayersPill("friends"))
  193. })
  194. }
  195. }
  196.  
  197. function btnRemoveFriend_Click(a, d, c) {
  198. if (0 < c.Id) {
  199. var b = new MCUser$RemoveFriend;
  200. b.UserId = c.Id;
  201. b.IsEnemy = !1;
  202. proxy.SendEchoMessage(b, function(b) {
  203. 0 == b.Code && (a.show(), d.hide(), "friends" == currentPlayerGroup && load_chat_players(currentPlayerGroup))
  204. })
  205. }
  206. }
  207.  
  208. function btnAddEnemy_Click(a, d, c) {
  209. if (0 < c.Id) {
  210. var b = new MCUser$AddFriend;
  211. b.UserId = c.Id;
  212. b.UserName = c.Name;
  213. b.IsEnemy = !0;
  214. b.Flags = c.Flags;
  215. b.Rank = c.Rank;
  216. proxy.SendEchoMessage(b, function(b) {
  217. 0 == b.Code && (a.hide(), d.show(), "enemies" == currentPlayerGroup && load_chat_players(currentPlayerGroup), addChatPlayersPill("enemies"), $.inArray(c.Id, 0 > UserInfo.EnemyUserIds) && UserInfo.EnemyUserIds.push(c.Id))
  218. })
  219. }
  220. }
  221.  
  222. function btnRemoveEnemy_Click(a, d, c) {
  223. if (0 < c.Id) {
  224. var b = new MCUser$RemoveFriend;
  225. b.UserId = c.Id;
  226. b.IsEnemy = !0;
  227. proxy.SendEchoMessage(b, function(b) {
  228. 0 == b.Code && (a.show(), d.hide(), "enemies" == currentPlayerGroup && load_chat_players(currentPlayerGroup), UserInfo.EnemyUserIds.splice($.inArray(c.Id, UserInfo.EnemyUserIds), 1))
  229. })
  230. }
  231. }
  232.  
  233. function btnIgnore_Click(a, d, c) {
  234. if (0 < c.Id) {
  235. var b = new MCUser$AddIgnore;
  236. b.UserId = c.Id;
  237. b.UserName = c.Name;
  238. b.Flags = c.Flags;
  239. b.Rank = c.Rank;
  240. proxy.SendEchoMessage(b, function(b) {
  241. 0 == b.Code && (a.hide(), d.show(), "ignored" == currentPlayerGroup && load_chat_players(currentPlayerGroup), addChatPlayersPill("ignored"), $.inArray(c.Id, 0 > UserInfo.IgnoredUserIds) && UserInfo.IgnoredUserIds.push(c.Id))
  242. })
  243. }
  244. }
  245.  
  246. function btnUnignore_Click(a, d, c) {
  247. if (0 < c.Id) {
  248. var b = new MCUser$RemoveIgnore;
  249. b.UserId = c.Id;
  250. proxy.SendEchoMessage(b, function(b) {
  251. 0 == b.Code && (d.hide(), a.show(), "ignored" == currentPlayerGroup && load_chat_players(currentPlayerGroup), UserInfo.IgnoredUserIds.splice($.inArray(c.Id, UserInfo.IgnoredUserIds), 1))
  252. })
  253. }
  254. }
  255.  
  256. function addChatPlayersPill(a) {
  257. 0 == $("#player_pill_" + a).length && (a = $("<li id=player_pill_" + a + "><a href='javascript:void(0)' onclick=\"expand_chat_players(1, 0, 0);load_chat_players('" + a + "')\">" + Localize(a) + "</a></li>"), $("#chat_players_pills .dropup").length ? $("#chat_players_pills .dropup").append(a) : $("#chat_players_pills .players-pills").append(a))
  258. }
  259.  
  260. function warnPlayer_Click(a, d) {
  261. if (0 < d) {
  262. var c = new MCAdmin$WarnUser;
  263. c.UserId = d;
  264. proxy.SendEchoMessage(c, function() {});
  265. $(a).html("<i class='fa fa-check green'></i> <span class=green>" + Localize("Warned") + "</span>")
  266. }
  267. }
  268.  
  269. function mutePlayer_Click(a, d) {
  270. if (0 < d) {
  271. var c = new MCAdmin$MuteUser;
  272. c.ChannelId = 2;
  273. c.Duration = 15;
  274. c.UserId = d;
  275. proxy.SendEchoMessage(c, function() {});
  276. $(a).html("<i class='fa fa-check green'></i> <span class=green>" + Localize("Muted") + "</span>")
  277. }
  278. }
  279.  
  280. function donateRep(a, d) {
  281. $("#popup_user_rep_button" + a).remove();
  282. if (0 < a) {
  283. var c = new MCUser$DonateRep;
  284. c.UserId = a;
  285. proxy.SendEchoMessage(c, function(b) {
  286. 0 == b.Code && $("#popup_user_rep" + a).html(d + 1)
  287. })
  288. }
  289. }
  290.  
  291. function load_initial_game_settings(a, d, c, b) {
  292. 0 < $("#maps_modal").length && $("#maps_modal").fadeOut(function() {
  293. $("#maps_modal").modal("hide")
  294. });
  295. c = c ? 1 : 0;
  296. b = b ? 1 : 0;
  297. if (check_room_rank()) {
  298. var e = 0;
  299. null == currentRoom || 2 != currentRoom.Id && 51 != currentRoom.Id || (e = 1);
  300. a = "../inc_ajax/initial_game_settings.php?map_id=" + a + "&scenario_id=" + d + "&is_casual=" + c + "&is_cw=" + b + "&is_beginners=" + e;
  301. $("#white_modal").modal();
  302. $("#white_modal .modal-content").html(spinner_dark);
  303. $("#white_modal .modal-content").load(a)
  304. }
  305. }
  306.  
  307. function load_password_input(a) {
  308. currentGame = a;
  309. $("#white_modal").modal();
  310. $("#white_modal .modal-content").html(spinner_dark);
  311. $("#white_modal .modal-content").load("../inc_ajax/game_password.php", function() {
  312. setTimeout(function() {
  313. $("#game_password").focus()
  314. }, 300)
  315. })
  316. }
  317.  
  318. function game_password_submit() {
  319. $("#overlay").fadeIn();
  320. null != currentGame && ("" == $("#game_password").val() ? ($("#overlay").fadeOut(), $("#password_box").addClass("has-error"), $("#game_password").on("change keydown paste input", function() {
  321. "" != $("#game_password").val() && $("#password_box").removeClass("has-error")
  322. })) : redirectToGame(currentGame, $("#game_password").val()))
  323. }
  324.  
  325. function check_room_rank() {
  326. var a = "",
  327. d = !1;
  328. null != currentRoom && ((2 == currentRoom.Id || 51 == currentRoom.Id) && 6 < user_rank && 1 != user_pos && 2 != user_pos && 3 != user_pos ? (a = Localize("Beginners room is for ranks 0-6 only"), d = !0) : (1 == currentRoom.Id || 50 == currentRoom.Id) && 3 > user_rank && 2 != user_pos && 3 != user_pos && (a = Localize("Main room is for ranks 3+ only"), d = !0), d && ShowDialog(a));
  329. return !d
  330. }
  331.  
  332. function redirectToGame(a, d) {
  333. 0 < $("#white_modal").length && $("#white_modal").fadeOut(function() {
  334. $("#white_modal").modal("hide")
  335. });
  336. var c = "";
  337. if (a.IsPreGame) {
  338. var b = new MCPreGame$JoinPreGame;
  339. b.PreGameId = a.Id;
  340. "" != d && (b.Password = d);
  341. c = "../games/?newlink="
  342. } else b = new MCGame$JoinGame, b.GameId = a.Id, "" != d && (b.Password = d), c = "../games/?link=";
  343. proxy.SendEchoMessage(b, function(a) {
  344. 0 == a.Code ? window.location = c + a.Data : ($("#overlay").fadeOut(), setTimeout(function() {
  345. ShowDialog(Localize("Error") + ": " + Localize(a.Data))
  346. },
  347. 1E3))
  348. })
  349. }
  350.  
  351. function toggleFullscreen() {
  352. var a = document.documentElement;
  353. document.fullscreenElement || document.mozFullScreenElement || document.webkitFullscreenElement || document.msFullscreenElement ? document.exitFullscreen ? document.exitFullscreen() : document.msExitFullscreen ? document.msExitFullscreen() : document.mozCancelFullScreen ? document.mozCancelFullScreen() : document.webkitExitFullscreen && document.webkitExitFullscreen() : a.requestFullscreen ? a.requestFullscreen() : a.msRequestFullscreen ? a.msRequestFullscreen() : a.mozRequestFullScreen ?
  354. a.mozRequestFullScreen() : a.webkitRequestFullscreen && a.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)
  355. }
  356. $(document).bind("webkitfullscreenchange mozfullscreenchange msfullscreenchange fullscreenchange", function(a) {
  357. document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen || document.msIsFullScreen ? $(".fa-expand").addClass("fa-compress").removeClass("fa-expand") : $(".fa-compress").addClass("fa-expand").removeClass("fa-compress")
  358. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement