From e2ecab4884e85b1a058a9df5bcfead93405e301a Mon Sep 17 00:00:00 2001 From: Guangcong Luo Date: Thu, 14 Jan 2016 21:31:13 -0500 Subject: [PATCH] Support allowRename in RoomGames Now, if you're in a roomgame that doesn't allow renames, the client will warn you about that. --- js/client-mainmenu.js | 4 +++- js/client.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 1 deletion(-) diff --git a/js/client-mainmenu.js b/js/client-mainmenu.js index b453ae73d..4f7d967e3 100644 --- a/js/client-mainmenu.js +++ b/js/client-mainmenu.js @@ -507,7 +507,9 @@ var buf = '

'; buf += '
'; for (var roomid in this.games) { - buf += '
' + Tools.escapeHTML(this.games[roomid]) + '
'; + var name = this.games[roomid]; + if (name.slice(-1) === '*') name = name.slice(0, -1); + buf += '
' + Tools.escapeHTML(name) + '
'; } buf += '
'; if (!$searchGroup.is(':visible')) buf += '

'; diff --git a/js/client.js b/js/client.js index 368d9964e..39be4007f 100644 --- a/js/client.js +++ b/js/client.js @@ -2450,6 +2450,25 @@ } } else if (data.reason) { buf += '

' + Tools.parseMessage(data.reason) + '

'; + } else if (!data.force) { + var noRenameGames = ''; + if (app.rooms[''].games) { + for (var roomid in app.rooms[''].games) { + var title = app.rooms[''].games[roomid]; + if (title.slice(-1) === '*') { + noRenameGames += '
  • ' + Tools.escapeHTML(title.slice(0, -1)) + '
  • '; + } + } + } + if (noRenameGames) { + buf += '

    You can\'t change name in the middle of these games:

    '; + buf += ''; + buf += '

    '; + buf += '

    '; + buf += '
    '; + this.$el.html(buf); + return; + } } var name = (data.name || ''); @@ -2469,6 +2488,15 @@ var css = hashColor(toUserid(name)).slice(6, -1); preview.css('color', css); }, + force: function () { + var sourceEl = this.sourceEl; + this.close(); + app.addPopup(LoginPopup, { + force: true, + sourceEl: sourceEl, + sourcePopup: app.popups[app.popups.length - 1] + }); + }, submit: function (data) { this.close(); if (!$.trim(data.username)) return;