From cebae1734160889f5c21d8dda1e41574bf48e5d4 Mon Sep 17 00:00:00 2001 From: synth-ruiner Date: Fri, 6 Mar 2015 09:40:32 +0000 Subject: [PATCH] Add middle-click functionality to left click --- index.html | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index f9707a5..427877d 100644 --- a/index.html +++ b/index.html @@ -468,7 +468,9 @@ $('#setup').hide(); }); - $.fn.leftClick = function() { + $.fn.leftClick = function(automated) { + if (!automated) automated = false; + //don't want first click to be a mine if (firstClick) { var x = $(this).getX(); @@ -500,9 +502,11 @@ //$(this).middleClick(); //number of flags matches number of adjacent mines - $(this).getAdjacentTiles().filter(':not(.flagged)').each(function() { - //$(this).mousedown(); - }); + if (!automated && parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged, .revealed.mine').length) { + $(this).getAdjacentTiles().filter(':not(.flagged)').each(function() { + $(this).mousedown(); + }); + } } else { $(this).addClass("revealed"); @@ -522,8 +526,6 @@ } $.fn.middleClick = function() { - //move this functionality to left click - //number of flags matches number of adjacent mines if (parseInt($(this).text()) === $(this).getAdjacentTiles().filter('.flagged, .revealed.mine').length) { $(this).getAdjacentTiles().filter(':not(.flagged)').each(function() { @@ -558,9 +560,11 @@ $(this).middleClick(); break; case 1: - default: $(this).leftClick(); break; + default: + $(this).leftClick(true); //automated + break; } removeClearedRows();