diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index 30bfe61..0000000 Binary files a/.DS_Store and /dev/null differ diff --git a/.gitignore b/.gitignore index 074ab52..baadd77 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +.DS_Store package-lock.json node_modules \ No newline at end of file diff --git a/Gruntfile.js b/Gruntfile.js index 07320b5..df66994 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -8,7 +8,10 @@ module.exports = function (grunt) { 'https://github.com/denissdubinin/Javascript-Sudoku - Licensed MIT */\n', uglify: { options: { - banner: '<%= banner %>' + banner: '<%= banner %>', + output: { + beautify: false + } }, dist: { files: { diff --git a/README.md b/README.md new file mode 100644 index 0000000..bc81afd --- /dev/null +++ b/README.md @@ -0,0 +1,120 @@ +# Javascript Sudoku + +[![License](https://img.shields.io/github/license/mashape/apistatus.svg)](https://github.com/denissdubinin/Javascript-sudoku) + +Javascript plugin that generates random sudoku grid. + +![Javascript Sudoku](example.png) + +## Installation + +### CDN +1. Add a sudoku script to your page: + + ```html + + ``` + +2. Add a sudoku stylesheet to your page: + + ```html + + ``` + +### Local files +1. Add a sudoku script to your page: + + ```html + + ``` + +2. Add a sudoku stylesheet to your page: + + ```html + + ``` + +## Usage + +1. Create `div` element on your page: + + ```html +
+ ``` + +2. Initialise Sudoku plugin: + + ```javascript + $(element).Sudoku(); + ``` + +3. Custom control buttons + + You can use custom buttons for sudoku. To disable default buttons, set options `useCustomButtons` to `true`. + + For custom buttons use `ID` selector: + + * `start-sudoku` for start button + * `r-sudoku` for reset button + * `gn-sudoku` for generate button + + Example: + + ```html + + + + ``` + +# Example + +```javascript +$(element).Sudoku({ + dropTimerOnReset: true, + markWrongCellsOnFly: false, + useTimer: true, + timerOnly: true, +}); +``` + +## Options + +`squareSize` + +Size of small squre. Default `3` + +`dropTimerOnReset` + +Reset timer on sudoku reset. Default `true` + +`markWrongCellsOnFly`: false, + +Mark cell with red if it has wrong value right after number is entered. Default `false` + +`markWrongCellsOnFinish` + +Mark cell with wrong value with red when all cells are filled. Default `true` + +`useTimer` + +Enable timer. Default `true` + +`timerOnly` + +Game can be started only with activated timer. Works only with `options.useTimer === true`. Default `true` + +`useCustomButtons` + +If you want to use own control buttons, enable this options. Default `false` + +`sudokuMixIterations` + +Iterations count for mixing random rows and columns between themselfs The larger number, the more mixed sudoku becomes and the more time script initialisation takes. Default `500` + +## Dependencies +jQuery 1.7 + +## License +Copyright © 2018 Deniss Dubinin + +Licensed under the MIT license. \ No newline at end of file diff --git a/dist/sudoku.min.css b/dist/sudoku.min.css index 19b0ed0..0369321 100644 --- a/dist/sudoku.min.css +++ b/dist/sudoku.min.css @@ -1,4 +1,4 @@ /*! Javascript Sudoku v1.0.0 by Deniss Dubinin - https://github.com/denissdubinin/Javascript-Sudoku - Licensed MIT */ -.sudoku{margin:0 auto;position:relative;width:370px}.sudoku.loading::after{background:#fff;content:'';cursor:not-allowed;display:block;height:100%;left:0;opacity:.5;position:absolute;top:0;width:100%}.sudoku table{width:370px;height:370px}.sudoku .sudoku-cell{padding:0}.sudoku .sudoku-cell.invalid-cell input{background:#f9d4d4}.sudoku tr:nth-of-type(3n){border-bottom:2px solid #c5c5c5}.sudoku tr:last-of-type{border-bottom:none}.sudoku td:nth-of-type(3n){border-right:2px solid #c5c5c5}.sudoku td:last-of-type{border-right:none}.sudoku input{border:0;height:100%;text-align:center;width:100%}.sudoku input:disabled{background:#f5f5f5;cursor:not-allowed} +/*! Javascript Sudoku v1.0.0 by Deniss Dubinin - https://github.com/denissdubinin/Javascript-Sudoku - Licensed MIT */.sudoku{margin:0 auto;position:relative;width:370px}.sudoku.loading::after{background:#fff;content:'';cursor:not-allowed;display:block;height:100%;left:0;opacity:.5;position:absolute;top:0;width:100%}.sudoku table{width:370px;height:370px}.sudoku .sudoku-cell{padding:0}.sudoku .sudoku-cell.invalid-cell input{background:#f9d4d4}.sudoku tr:nth-of-type(3n){border-bottom:2px solid #c5c5c5}.sudoku tr:last-of-type{border-bottom:none}.sudoku td:nth-of-type(3n){border-right:2px solid #c5c5c5}.sudoku td:last-of-type{border-right:none}.sudoku input{border:0;height:100%;text-align:center;width:100%}.sudoku input:disabled{background:#f5f5f5;cursor:not-allowed}.sudoku input.timer-disabled{cursor:not-allowed} /*# sourceMappingURL=sudoku.min.css.map */ diff --git a/dist/sudoku.min.css.map b/dist/sudoku.min.css.map index e130807..1cb493e 100644 --- a/dist/sudoku.min.css.map +++ b/dist/sudoku.min.css.map @@ -1,6 +1,6 @@ { "version": 3, -"mappings": "AAMA,OAAQ,CACJ,MAAM,CAAE,MAAM,CACd,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,KAAK,CAEZ,sBAAiB,CACb,UAAU,CAAE,IAAI,CAChB,OAAO,CAAE,EAAE,CACX,MAAM,CAAE,WAAW,CACnB,OAAO,CAAE,KAAK,CACd,MAAM,CAAE,IAAI,CACZ,IAAI,CAAE,CAAC,CACP,OAAO,CAAE,EAAE,CACX,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAE,CAAC,CACN,KAAK,CAAE,IAAI,CAGf,aAAM,CACF,KAAK,CAAE,KAAK,CACZ,MAAM,CAAE,KAAK,CAGjB,oBAAa,CACT,OAAO,CAAE,CAAC,CAEV,uCAAqB,CACjB,UAAU,CAAE,OAAO,CAKvB,0BAAkB,CACd,aAAa,CAAE,iBAAiB,CAGpC,uBAAe,CACX,aAAa,CAAE,IAAI,CAKvB,0BAAkB,CACd,YAAY,CAAE,iBAAiB,CAGnC,uBAAe,CACX,YAAY,CAAE,IAAI,CAI1B,aAAM,CACF,MAAM,CAAE,CAAC,CACT,MAAM,CAAE,IAAI,CACZ,UAAU,CAAE,MAAM,CAClB,KAAK,CAAE,IAAI,CAEX,sBAAW,CACP,UAAU,CAAE,OAAO,CACnB,MAAM,CAAE,WAAW", +"mappings": "AAAA,qHAAqH,AAErH,OAAQ,CACJ,MAAM,CAAE,MAAM,CACd,QAAQ,CAAE,QAAQ,CAClB,KAAK,CAAE,KAAK,CAEZ,sBAAiB,CACb,UAAU,CAAE,IAAI,CAChB,OAAO,CAAE,EAAE,CACX,MAAM,CAAE,WAAW,CACnB,OAAO,CAAE,KAAK,CACd,MAAM,CAAE,IAAI,CACZ,IAAI,CAAE,CAAC,CACP,OAAO,CAAE,EAAE,CACX,QAAQ,CAAE,QAAQ,CAClB,GAAG,CAAE,CAAC,CACN,KAAK,CAAE,IAAI,CAGf,aAAM,CACF,KAAK,CAAE,KAAK,CACZ,MAAM,CAAE,KAAK,CAGjB,oBAAa,CACT,OAAO,CAAE,CAAC,CAEV,uCAAqB,CACjB,UAAU,CAAE,OAAO,CAKvB,0BAAkB,CACd,aAAa,CAAE,iBAAiB,CAGpC,uBAAe,CACX,aAAa,CAAE,IAAI,CAKvB,0BAAkB,CACd,YAAY,CAAE,iBAAiB,CAGnC,uBAAe,CACX,YAAY,CAAE,IAAI,CAI1B,aAAM,CACF,MAAM,CAAE,CAAC,CACT,MAAM,CAAE,IAAI,CACZ,UAAU,CAAE,MAAM,CAClB,KAAK,CAAE,IAAI,CAEX,sBAAW,CACP,UAAU,CAAE,OAAO,CACnB,MAAM,CAAE,WAAW,CAGvB,4BAAiB,CACb,MAAM,CAAE,WAAW", "sources": ["../src/sudoku.scss"], "names": [], "file": "sudoku.min.css" diff --git a/dist/sudoku.min.js b/dist/sudoku.min.js index 4c43beb..50e336a 100644 --- a/dist/sudoku.min.js +++ b/dist/sudoku.min.js @@ -1,3 +1,3 @@ /*! Javascript Sudoku v1.0.0 by Deniss Dubinin - https://github.com/denissdubinin/Javascript-Sudoku - Licensed MIT */ -"use strict";window.sudoku={Valve:"Trilogy"},function(window,$){$.fn.Sudoku=function(options){var defaults={defaultSquare:3,dropTimerOnReset:!0,markWrongCellsOnFly:!1,markWrongCellsOnFinish:!0,useTimer:!0,timerOnly:!0,sudokuMixIterations:500},options=$.extend({},defaults,options),sudokuTimer;function create(o){generateGui(o),init()}function init(){toggleLoadingOverlay(!0),generateMatrix(),mixMatrix(),prepareEmptyMatrix(),fillGrid()}function generateGui(o){o.prepend(':'),$('