From 55770d9b48195a70911af836122f46086b39483e Mon Sep 17 00:00:00 2001 From: Alexander Yakovlev Date: Thu, 24 Jul 2014 09:30:30 +0700 Subject: [PATCH] Updated Undum from idmillington/undum --- js/undum.js | 120 +++++++++++++++++++++++++++++----------------------- 1 file changed, 67 insertions(+), 53 deletions(-) diff --git a/js/undum.js b/js/undum.js index 7e92fe8..74be14c 100644 --- a/js/undum.js +++ b/js/undum.js @@ -4,7 +4,7 @@ // define the content of the game. // --------------------------------------------------------------------------- -(function() { +(function($) { // ----------------------------------------------------------------------- // Internal Infrastructure Implementations [NB: These have to be // at the top, because we use them below, but you can safely @@ -135,7 +135,7 @@ * tags: a list of tags for this situation, which can be used for * implicit situation selection. The tags can also be given as * space, tab or comma separated tags in a string. Note that, - * when calling getSituationIdChoices, tags are prefixed with + * when calling `getSituationIdChoices`, tags are prefixed with * a hash, but that should not be the case here. Just use the * plain tag name. * @@ -167,7 +167,7 @@ this._frequency = (opts.frequency !== undefined) ? opts.frequency : 1; this._displayOrder = - (opts.displayOrder != undefined) ? opts.displayOrder : 1; + (opts.displayOrder !== undefined) ? opts.displayOrder : 1; // Tag are not stored with an underscore, because they are // accessed directy. They should not be context sensitive @@ -175,7 +175,7 @@ // manipulation). if (opts.tags !== undefined) { if ($.isArray(opts.tags)) { - this.tags = opts.tags + this.tags = opts.tags; } else { this.tags = opts.tags.split(/[ \t,]+/); } @@ -238,13 +238,13 @@ } }; /* Returns the priority, frequency and displayOrder for this situation, - * when being selected using system.getSituationIdChoices. */ + * when being selected using `system.getSituationIdChoices`. */ Situation.prototype.choiceData = function(character, system, situation) { return { priority: this._priority, frequency: this._frequency, displayOrder: this._displayOrder - } + }; }; /* A simple situation has a block of content that it displays when @@ -268,26 +268,27 @@ * * choices: A list of situation ids and tags that, if given, will * be used to compile an implicit option block using - * getSituationIdChoices (see that function for more details + * `getSituationIdChoices` (see that function for more details * of how this works). Tags in this list should be prefixed * with a hash # symbol, to distinguish them from situation - * ids. + * ids. If just a single tag or id is needed, it can be passed + * in as a string without wrapping into a list. * - * minChoices: If choices is given, and an implicit choice block + * minChoices: If `choices` is given, and an implicit choice block * should be compiled, set this option to require at least * this number of options to be displayed. See - * getSituationIdChoices for a description of the algorithm by + * `getSituationIdChoices` for a description of the algorithm by * which this happens. If you do not specify the `choices` * option, then this option will be ignored. * - * maxChoices: If choices is given, and an implicit choice block + * maxChoices: If `choices` is given, and an implicit choice block * should be compiled, set this option to require no more than * this number of options to be displayed. See - * getSituationIdChoices for a description of the algorithm by - * which this happens. If you do not specify the `choices` + * `getSituationIdChoices` for a description of the algorithm + * by which this happens. If you do not specify the `choices` * option, then this option will be ignored. * - * The remaining options in the opts parameter are the same as for + * The remaining options in the `opts` parameter are the same as for * the base Situation. */ var SimpleSituation = function(content, opts) { @@ -411,7 +412,7 @@ }; NonZeroIntegerQuality.inherits(IntegerQuality); NonZeroIntegerQuality.prototype.format = function(character, value) { - if (value == 0) { + if (value === 0) { return null; } else { return IntegerQuality.prototype.format.call( @@ -658,7 +659,7 @@ * return an ordered list of valid viewable situation ids. */ System.prototype.writeChoices = function(listOfIds, elementSelector) { - if (listOfIds.length == 0) return; + if (listOfIds.length === 0) return; var currentSituation = getCurrentSituation(); var $options = $("