mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Various wordplay fixes:
* Don't add blank lines to the dictionary. * Fix broken word length check in `score_word`. * Prevent event handler from submitting blank words.
This commit is contained in:
@@ -132,9 +132,8 @@ Template.scratchpad.events({
|
||||
'click button, keyup input': function (evt) {
|
||||
var textbox = $('#scratchpad input');
|
||||
// if we clicked the button or hit enter
|
||||
if (evt.type === "click" ||
|
||||
(evt.type === "keyup" && evt.which === 13)) {
|
||||
|
||||
if ((evt.type === "click" || (evt.type === "keyup" && evt.which === 13))
|
||||
&& textbox.val()) {
|
||||
var word_id = Words.insert({player_id: Session.get('player_id'),
|
||||
game_id: game() && game()._id,
|
||||
word: textbox.val().toUpperCase(),
|
||||
|
||||
@@ -106,7 +106,8 @@ Meteor.methods({
|
||||
// that the word is at least three chars, isn't already used, and is
|
||||
// possible to make on the board.
|
||||
if (game.clock === 0
|
||||
|| word.length < 3
|
||||
|| !word.word
|
||||
|| word.word.length < 3
|
||||
|| Words.find({game_id: word.game_id, word: word.word}).count() > 1
|
||||
|| paths_for_word(game.board, word.word).length === 0) {
|
||||
Words.update(word._id, {$set: {score: 0, state: 'bad'}});
|
||||
@@ -129,8 +130,8 @@ Meteor.methods({
|
||||
if (Meteor.isServer) {
|
||||
DICTIONARY = {};
|
||||
_.each(Assets.getText("enable2k.txt").split("\n"), function (line) {
|
||||
// Skip comment lines
|
||||
if (line.indexOf("//") !== 0) {
|
||||
// Skip blanks and comment lines
|
||||
if (line && line.indexOf("//") !== 0) {
|
||||
DICTIONARY[line] = true;
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user