From 0914d7cd7ac4bdc938aadab3d78fe4efdb1c3f8b Mon Sep 17 00:00:00 2001 From: "marcins78@gmail.com" Date: Thu, 5 Jan 2012 17:00:52 +0000 Subject: [PATCH] If there are only 2 choices to do (and there usually are), you get to click a button with the answer you want, instead of having to choose the option from list and confirm with "OK". --- .../src/main/webapp/js/gameUi.js | 49 +++++++++++++------ 1 file changed, 35 insertions(+), 14 deletions(-) diff --git a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js index 0f07b1537..40546604d 100644 --- a/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js +++ b/gemp-lotr/gemp-lotr-web/src/main/webapp/js/gameUi.js @@ -1143,23 +1143,44 @@ var GempLotrGameUI = Class.extend({ var results = this.getDecisionParameters(decision, "results"); - var html = text + "
"; - var that = this; this.smallDialog - .html(html); + .html(text); - if (!this.replayMode) { - this.smallDialog.dialog("option", "buttons", - { - "OK": function() { - $(this).dialog("close"); - that.decisionFunction(id, $("#multipleChoiceDecision").val()); - } - }); + if (results.length > 2) { + var html = "
"; + this.smallDialog.append(html); + + if (!this.replayMode) { + this.smallDialog.dialog("option", "buttons", + { + "OK": function() { + $(this).dialog("close"); + that.decisionFunction(id, $("#multipleChoiceDecision").val()); + } + }); + } + } else { + for (var i = 0; i < results.length; i++) { + this.smallDialog.append("
"); + var but = $("").button(); + but.html(results[i]); + if (!this.replayMode) { + but.click( + (function(ind) { + return function() { + $(this).dialog("close"); + that.decisionFunction(id, "" + ind); + } + })(i)); + } + this.smallDialog.append(but); + } + if (!this.replayMode) + this.smallDialog.dialog("option", "buttons", {}); } this.smallDialog.dialog("open");