diff --git a/public/hiddenset.html b/public/hiddenset.html index 2009bb3..4dc7c7d 100644 --- a/public/hiddenset.html +++ b/public/hiddenset.html @@ -62,8 +62,6 @@ diff --git a/public/index.css b/public/index.css index b4f37f4..a9157f4 100644 --- a/public/index.css +++ b/public/index.css @@ -234,3 +234,40 @@ svg .stripe.purple { .light .purple.striped { stroke: #5A1398; } + + + +.modal { + display: none; /* Hidden by default */ + position: fixed; /* Stay in place */ + z-index: 1; /* Sit on top */ + left: 0; + top: 0; + width: 100%; /* Full width */ + height: 100%; /* Full height */ + overflow: auto; /* Enable scroll if needed */ +} + +/* Modal Content/Box */ +.modal-content { + margin: 15% auto; /* 15% from the top and centered */ + padding: 20px; + border: 1px solid #888; + width: 80%; /* Could be more or less, depending on screen size */ + background-color: 000000; +} + +/* The Close Button */ +.close { + color: #aaa; + float: right; + font-size: 28px; + font-weight: bold; +} + +.close:hover, +.close:focus { + color: black; + text-decoration: none; + cursor: pointer; +} diff --git a/public/index.html b/public/index.html index a4b8dbc..4e53a88 100644 --- a/public/index.html +++ b/public/index.html @@ -50,7 +50,16 @@ -
+ +
Settings
+ + +
Restart
@@ -62,8 +71,6 @@ diff --git a/public/index.js b/public/index.js index b46e24f..82f98a4 100644 --- a/public/index.js +++ b/public/index.js @@ -5,6 +5,9 @@ var $restartBig = $('#restartBig') var $restart = $('#restart') var $noSet = $('#no-set'); var $checkSet = $('#check-set'); +var $settings = $('#settings'); +var $close = $('#settings-x'); +var $settingspage = $('#settings-page'); var gameOver = false; function getClockTime() { @@ -134,17 +137,6 @@ function newGame() { } } -function setColorScheme(colorScheme) { - if (colorScheme == 'light') { - $body.addClass('light').removeClass('dark'); - } else if (colorScheme == 'dark') { - $body.addClass('dark').removeClass('light'); - } - if (typeof(Storage) !== 'undefined') { - localStorage.setItem('colorscheme', colorScheme); - } -} - function loadGame() { var gameid = currentVariant.name; if (typeof(Storage) !== 'undefined' && localStorage.getItem(gameid) != null) { @@ -185,6 +177,17 @@ function start() { } } +function setColorScheme(colorScheme) { + if (colorScheme == 'light') { + $body.addClass('light').removeClass('dark'); + } else if (colorScheme == 'dark') { + $body.addClass('dark').removeClass('light'); + } + if (typeof(Storage) !== 'undefined') { + localStorage.setItem('colorscheme', colorScheme); + } +} + function lightDark() { if ($body.hasClass('light')) { setColorScheme('dark'); @@ -193,6 +196,32 @@ function lightDark() { } } +function toggleFastMode() { + if (fastMode) { + fastMode = false; + } else { + fastMode = true; + } + + print ('setting fast mode ' + fastMode); + if (typeof(Storage) !== 'undefined') { + localStorage.setItem('fastMode', fastMode); + } +} + +function toggleAutoComplete() { + if (autoComplete) { + autoComplete = false; + } else { + autoComplete = true; + } + + print ('setting auto complete ' + autoComplete); + if (typeof(Storage) !== 'undefined') { + localStorage.setItem('autoComplete', autoComplete); + } +} + function getCardEl(i) { return $($display.children()[i]); } @@ -389,7 +418,7 @@ function release() { holdCount -= 1; } - if (holdCount == 0 && fastMode) { + if (holdCount == 0 && currentVariant.hasFastMode && fastMode) { checkAndClearSet(); } } @@ -405,7 +434,7 @@ function toggleCard($card) { } $card.toggleClass('selected'); - if ($card.hasClass('selected') && autoComplete) { + if ($card.hasClass('selected') && currentVariant.hasAutoComplete && autoComplete) { assistSet(); // only assist when autoComplete & selecting new } } @@ -439,6 +468,8 @@ $restartBig.on(clickStart, restart); $checkSet.on(clickStart, checkAndClearSet); $noSet.on(clickStart, help); +$settings.on(clickStart, function() {$settingspage[0].style.display = "block";}); +$close.on(clickStart, function() {$settingspage[0].style.display = "none";}); $body.on('keydown', function(evt) { if (evt.originalEvent.repeat) { @@ -457,6 +488,10 @@ $body.on('keydown', function(evt) { help(); } else if (evt.shiftKey && code == 'KeyF') { toggleFullScreen(); + } else if (evt.shiftKey && code == 'KeyJ') { + toggleFastMode(); + } else if (evt.shiftKey && code == 'KeyK') { + toggleAutoComplete(); } else if (codes.indexOf(code) != -1) { if (!evt.shiftKey && !evt.ctrlKey && !evt.altKey) { var i = codes.indexOf(code); @@ -491,4 +526,18 @@ if (typeof(Storage) !== 'undefined') { if (colorscheme != null) { setColorScheme(colorscheme); } + + var fastMode = localStorage.getItem('fastMode'); + if (fastMode == null || fastMode === 'true') { + this.fastMode = true; + } else { + this.fastMode = false; + } + + var autoComplete = localStorage.getItem('autoComplete'); + if (autoComplete == null || autoComplete === 'true') { + this.autoComplete = true; + } else { + this.autoComplete = false; + } } \ No newline at end of file diff --git a/public/powerset.html b/public/powerset.html index 5c55a35..180b576 100644 --- a/public/powerset.html +++ b/public/powerset.html @@ -62,8 +62,6 @@ diff --git a/public/superset.html b/public/superset.html index 8322356..32a4769 100644 --- a/public/superset.html +++ b/public/superset.html @@ -62,8 +62,6 @@ diff --git a/public/variants.js b/public/variants.js index 91448f4..4261157 100644 --- a/public/variants.js +++ b/public/variants.js @@ -108,44 +108,6 @@ function naiveSetFinder(setSize, isSet) { return findSet; } -set = { - name: 'Set', - makeDeck: makeStandardDeck, - deal: deal, - isSet: isStandardSet, - findSet: naiveSetFinder(3, isStandardSet), - findNextSet: naiveSetFinder(3, isStandardSet), - tableSize: 12, - tableIncrement: 3, -} - -superset = { - name: 'Super Set', - makeDeck: makeStandardDeck, - deal: deal, - isSet: isSuperSet, - - findSet: naiveSetFinder(4, isSuperSet), - findNextSet: naiveSetFinder(4, isSuperSet), - tableSize: 9, - tableIncrement: 2, -} - -hiddenset = { - name: 'Set', - makeDeck: function() { - var ret = makeStandardDeck(); - ret[0].hidden = true; - return ret; - }, - deal: deal, - isSet: isStandardSet, - findSet: naiveSetFinder(3, isStandardSet), - findNextSet: naiveSetFinder(3, isStandardSet), - tableSize: 12, - tableIncrement: 3, -} - function makePowerSetDeck() { var deck = []; for (var i = 1; i < 64; ++i) { @@ -196,6 +158,50 @@ function findPowerSet(cards, previous) { return best; } +set = { + name: 'Set', + makeDeck: makeStandardDeck, + deal: deal, + isSet: isStandardSet, + findSet: naiveSetFinder(3, isStandardSet), + findNextSet: naiveSetFinder(3, isStandardSet), + tableSize: 12, + tableIncrement: 3, + hasFastMode: true, + hasAutoComplete: true +} + +hiddenset = { + name: 'Hidden Set', + makeDeck: function() { + var ret = makeStandardDeck(); + ret[0].hidden = true; + return ret; + }, + deal: deal, + isSet: isStandardSet, + findSet: naiveSetFinder(3, isStandardSet), + findNextSet: naiveSetFinder(3, isStandardSet), + tableSize: 12, + tableIncrement: 3, + hasFastMode: true, + hasAutoComplete: true +} + +superset = { + name: 'Super Set', + makeDeck: makeStandardDeck, + deal: deal, + isSet: isSuperSet, + + findSet: naiveSetFinder(4, isSuperSet), + findNextSet: naiveSetFinder(4, isSuperSet), + tableSize: 9, + tableIncrement: 2, + hasFastMode: false, + hasAutoComplete: false +} + powerset = { name: 'Power Set', makeDeck: makePowerSetDeck, @@ -205,6 +211,8 @@ powerset = { findNextSet: findPowerSet, tableSize: 7, tableIncrement: 1, // mathematically impossible to have no-set + hasFastMode: true, + hasAutoComplete: false } Variants = {