Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var currentRoom = null,
- currentGame = null,
- proxy = null;
- atWar.Static && atWar.Static.Proxy && (proxy = atWar.Static.Proxy);
- 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));
- setInterval(function() {
- proxy.get_IsConnected() && proxy.SendMessage(new MCUser$Ping)
- }, 3E4);
- window.onbeforeunload = function() {
- proxy.Disconnect(null, !0)
- };
- var connectionFailed = !1;
- function onConnectionFailed(a) {
- connectionFailed || (connectionFailed = !0, $("#overlay").fadeOut(), DoConfirm2((Localize(a) || Localize("Connection lost")) + " - " + Localize("Reload") + "?", function() {
- location.reload()
- }, !1))
- }
- function onConnectionError(a) {
- 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))
- }
- function onReconnected() {
- if ("function" === typeof addChatText) {
- var a = Localize("Connection restored");
- addChatText(1, a, 0, null, null, !1)
- }
- }
- function display_user(a) {
- display_user(a, !1, !1)
- }
- function display_user(a, d) {
- display_user(a, d, !1)
- }
- function display_user(a, d, c) {
- if (null != a) {
- var b = a.Name;
- "function" == typeof a.GetFormattedName && (b = a.GetFormattedName());
- var e = "";
- 1 != d && (e = display_user_rank(a));
- var g = $("<a href='javascript:void(0)'>" + b + "</a>");
- g.click(function(b) {
- b.preventDefault();
- b.stopPropagation();
- show_user_popover(g, a);
- c && a.Id != user_id && sendPM(a.Id, a.Name)
- });
- b = "";
- return b = 1 == d ? $("<span></span>").append(g) : $("<span></span>").append(e).append(" ").append(g)
- }
- return ""
- }
- function display_user_rank(a) {
- if (null != a) {
- var d = "blackshield",
- c = "",
- b = "Rank " + a.Rank;
- (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 &&
- (d = "goldshield", c = "\n" + Localize("Premium")), 1 > a.Rank && (a.Rank = "0", b = Localize("Rank") + " 0"));
- return $("<img src=/images/ranks/" + d + "/" + a.Rank + ".png width=18 height=18 title='" + b + " " + c + "'>")
- }
- return ""
- }
- function display_user_avatar(a, d, c, b, e) {
- e = "";
- e = "../images/avatars/default.jpg";
- "" != d && null != d && (e = "../images/avatars/" + a.toString().substring(0, 1) + "/" + a + "." + d);
- e = "<img src=" + e + " class='pull-right rounded' style='" + c + "'>";
- b && (e = "<a target=_blank href=../users/profile.php?user_id=" + a + ">" + e + "</a>");
- return e
- }
- function show_user_popover(a, d) {
- if (null != d && (d.Flags & UserFlags.prototype.IsIncognito) != UserFlags.prototype.IsIncognito) {
- $('[rel="popover"]').not(a).popover("destroy");
- $(".popover:not(.in)").hide().detach();
- if ("popover" != $(a).attr("rel")) {
- var c = new MCUser$GetAdditionalUserInfo;
- c.UserId = d.Id;
- proxy.SendEchoMessage(c, function(b) {
- $(a).popover("destroy");
- if (0 == b.Code) {
- b.Data = atWar.JarrSerializer.Deserialize$1(AdditionalUserInfo).call(null, b.Data);
- var c = $("<div style='min-width:150px;white-space: nowrap;' class='mini dark mini-line'></div>"),
- g = $("<div></div>"),
- f = display_user_avatar(d.Id, b.Data.Avatar, "width:50px;height:50px;margin-left:6px", !0, !1);
- g.append(f);
- g.append("<a class=darkgreen target=_blank href=../users/profile.php?user_id=" + d.Id + ">" + d.Name + "</a>");
- 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>");
- c.append(Localize("Rank") + ": " + d.Rank + " | Elo: " + Math.round(b.Data.Elo) + "<br>");
- c.append(Localize("Reputation") +
- ": <span id=popup_user_rep" + d.Id + " class='blue'>" + Math.round(b.Data.Rep) + "</span> ");
- if (d.Id != user_id && (b.Data.Flags & AdditionalUserFlags.prototype.IsRepped) != AdditionalUserFlags.prototype.IsRepped) {
- 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>');
- h.click(function(a) {
- a.stopPropagation();
- donateRep(d.Id, b.Data.Rep)
- })
- }
- c.append(h);
- c.append("<br>");
- (b.Data.Flags & AdditionalUserFlags.prototype.IsOnline) !=
- AdditionalUserFlags.prototype.IsOnline && c.append("<span style='font-style:italic'>" + Localize("offline") + "</span><br>");
- 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>");
- if (d.Id != user_id) {
- 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, " +
- d.Id + ")'>" + Localize("Send warning") + "</a> | <a class=red href='javascript:void(0)' onclick='mutePlayer_Click(this, " + d.Id + ")'>" + Localize("Mute for 15 min") + "</a></div><hr>");
- f = $("<div class=user_popover_buttons style='margin-top:10px'></div>");
- (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() {
- $(a).popover("destroy").attr("rel",
- "");
- sendPM2(d.Id, d.Name)
- }), f.append(h));
- 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>");
- f.append(h);
- 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>"),
- l = $("<button type=button class='btnUnfriend btn btn-default btn-xs' style='display:none' title='" +
- Localize("Remove player from Friends") + "'><i class='fa fa-user fa-lg'></i> <i class='fa fa-minus mini'></i></button>");
- k.click(function() {
- btnAddFriend_Click(k, l, d)
- });
- l.click(function() {
- btnRemoveFriend_Click(k, l, d)
- });
- (b.Data.Flags & AdditionalUserFlags.prototype.IsFriend) == AdditionalUserFlags.prototype.IsFriend && (k.css("display", "none"), l.css("display", ""));
- f.append(k);
- f.append(l);
- 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>"),
- 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>");
- m.click(function() {
- btnAddEnemy_Click(m, n, d)
- });
- n.click(function() {
- btnRemoveEnemy_Click(m, n, d)
- });
- (b.Data.Flags & AdditionalUserFlags.prototype.IsEnemy) == AdditionalUserFlags.prototype.IsEnemy && (m.css("display", "none"), n.css("display", ""));
- f.append(m);
- f.append(n);
- var p = $("<button type=button class='btn btn-warning btn-xs' title='" +
- Localize("Ignore player") + "'><i class='fa fa-user fa-lg'></i> <i class='fa fa-ban mini'></i></button>"),
- 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>");
- p.click(function() {
- btnIgnore_Click(p, q, d)
- });
- q.click(function() {
- btnUnignore_Click(p, q, d)
- });
- (b.Data.Flags & AdditionalUserFlags.prototype.IsIgnored) == AdditionalUserFlags.prototype.IsIgnored && (p.css("display",
- "none"), q.css("display", ""));
- f.append(p);
- f.append(q);
- c.append(f)
- }
- $(a).popover({
- title: g,
- content: c,
- html: !0,
- container: "body",
- placement: "top"
- }).popover("toggle");
- $(a).attr("rel", "popover")
- }
- })
- } else $(a).popover("destroy").attr("rel", ""), $(".popover:not(.in)").hide().detach();
- $("body").on("click", function(a) {
- $('[rel="popover"]').each(function() {
- $(this).is(a.target) || 0 !== $(this).has(a.target).length || 0 !== $(".popover").has(a.target).length || $(this).popover("destroy").attr("rel", "")
- })
- });
- $("body").on("hidden.bs.popover",
- function() {
- $(".popover:not(.in)").hide().detach()
- })
- }
- }
- function btnAddFriend_Click(a, d, c) {
- if (0 < c.Id) {
- var b = new MCUser$AddFriend;
- b.UserId = c.Id;
- b.UserName = c.Name;
- b.IsEnemy = !1;
- b.Flags = c.Flags;
- b.Rank = c.Rank;
- proxy.SendEchoMessage(b, function(b) {
- 0 == b.Code && (a.hide(), d.show(), "friends" == currentPlayerGroup && load_chat_players(currentPlayerGroup), addChatPlayersPill("friends"))
- })
- }
- }
- function btnRemoveFriend_Click(a, d, c) {
- if (0 < c.Id) {
- var b = new MCUser$RemoveFriend;
- b.UserId = c.Id;
- b.IsEnemy = !1;
- proxy.SendEchoMessage(b, function(b) {
- 0 == b.Code && (a.show(), d.hide(), "friends" == currentPlayerGroup && load_chat_players(currentPlayerGroup))
- })
- }
- }
- function btnAddEnemy_Click(a, d, c) {
- if (0 < c.Id) {
- var b = new MCUser$AddFriend;
- b.UserId = c.Id;
- b.UserName = c.Name;
- b.IsEnemy = !0;
- b.Flags = c.Flags;
- b.Rank = c.Rank;
- proxy.SendEchoMessage(b, function(b) {
- 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))
- })
- }
- }
- function btnRemoveEnemy_Click(a, d, c) {
- if (0 < c.Id) {
- var b = new MCUser$RemoveFriend;
- b.UserId = c.Id;
- b.IsEnemy = !0;
- proxy.SendEchoMessage(b, function(b) {
- 0 == b.Code && (a.show(), d.hide(), "enemies" == currentPlayerGroup && load_chat_players(currentPlayerGroup), UserInfo.EnemyUserIds.splice($.inArray(c.Id, UserInfo.EnemyUserIds), 1))
- })
- }
- }
- function btnIgnore_Click(a, d, c) {
- if (0 < c.Id) {
- var b = new MCUser$AddIgnore;
- b.UserId = c.Id;
- b.UserName = c.Name;
- b.Flags = c.Flags;
- b.Rank = c.Rank;
- proxy.SendEchoMessage(b, function(b) {
- 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))
- })
- }
- }
- function btnUnignore_Click(a, d, c) {
- if (0 < c.Id) {
- var b = new MCUser$RemoveIgnore;
- b.UserId = c.Id;
- proxy.SendEchoMessage(b, function(b) {
- 0 == b.Code && (d.hide(), a.show(), "ignored" == currentPlayerGroup && load_chat_players(currentPlayerGroup), UserInfo.IgnoredUserIds.splice($.inArray(c.Id, UserInfo.IgnoredUserIds), 1))
- })
- }
- }
- function addChatPlayersPill(a) {
- 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))
- }
- function warnPlayer_Click(a, d) {
- if (0 < d) {
- var c = new MCAdmin$WarnUser;
- c.UserId = d;
- proxy.SendEchoMessage(c, function() {});
- $(a).html("<i class='fa fa-check green'></i> <span class=green>" + Localize("Warned") + "</span>")
- }
- }
- function mutePlayer_Click(a, d) {
- if (0 < d) {
- var c = new MCAdmin$MuteUser;
- c.ChannelId = 2;
- c.Duration = 15;
- c.UserId = d;
- proxy.SendEchoMessage(c, function() {});
- $(a).html("<i class='fa fa-check green'></i> <span class=green>" + Localize("Muted") + "</span>")
- }
- }
- function donateRep(a, d) {
- $("#popup_user_rep_button" + a).remove();
- if (0 < a) {
- var c = new MCUser$DonateRep;
- c.UserId = a;
- proxy.SendEchoMessage(c, function(b) {
- 0 == b.Code && $("#popup_user_rep" + a).html(d + 1)
- })
- }
- }
- function load_initial_game_settings(a, d, c, b) {
- 0 < $("#maps_modal").length && $("#maps_modal").fadeOut(function() {
- $("#maps_modal").modal("hide")
- });
- c = c ? 1 : 0;
- b = b ? 1 : 0;
- if (check_room_rank()) {
- var e = 0;
- null == currentRoom || 2 != currentRoom.Id && 51 != currentRoom.Id || (e = 1);
- a = "../inc_ajax/initial_game_settings.php?map_id=" + a + "&scenario_id=" + d + "&is_casual=" + c + "&is_cw=" + b + "&is_beginners=" + e;
- $("#white_modal").modal();
- $("#white_modal .modal-content").html(spinner_dark);
- $("#white_modal .modal-content").load(a)
- }
- }
- function load_password_input(a) {
- currentGame = a;
- $("#white_modal").modal();
- $("#white_modal .modal-content").html(spinner_dark);
- $("#white_modal .modal-content").load("../inc_ajax/game_password.php", function() {
- setTimeout(function() {
- $("#game_password").focus()
- }, 300)
- })
- }
- function game_password_submit() {
- $("#overlay").fadeIn();
- null != currentGame && ("" == $("#game_password").val() ? ($("#overlay").fadeOut(), $("#password_box").addClass("has-error"), $("#game_password").on("change keydown paste input", function() {
- "" != $("#game_password").val() && $("#password_box").removeClass("has-error")
- })) : redirectToGame(currentGame, $("#game_password").val()))
- }
- function check_room_rank() {
- var a = "",
- d = !1;
- 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));
- return !d
- }
- function redirectToGame(a, d) {
- 0 < $("#white_modal").length && $("#white_modal").fadeOut(function() {
- $("#white_modal").modal("hide")
- });
- var c = "";
- if (a.IsPreGame) {
- var b = new MCPreGame$JoinPreGame;
- b.PreGameId = a.Id;
- "" != d && (b.Password = d);
- c = "../games/?newlink="
- } else b = new MCGame$JoinGame, b.GameId = a.Id, "" != d && (b.Password = d), c = "../games/?link=";
- proxy.SendEchoMessage(b, function(a) {
- 0 == a.Code ? window.location = c + a.Data : ($("#overlay").fadeOut(), setTimeout(function() {
- ShowDialog(Localize("Error") + ": " + Localize(a.Data))
- },
- 1E3))
- })
- }
- function toggleFullscreen() {
- var a = document.documentElement;
- 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 ?
- a.mozRequestFullScreen() : a.webkitRequestFullscreen && a.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT)
- }
- $(document).bind("webkitfullscreenchange mozfullscreenchange msfullscreenchange fullscreenchange", function(a) {
- document.fullScreen || document.mozFullScreen || document.webkitIsFullScreen || document.msIsFullScreen ? $(".fa-expand").addClass("fa-compress").removeClass("fa-expand") : $(".fa-compress").addClass("fa-expand").removeClass("fa-compress")
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement