Git Product home page Git Product logo

tic-tac-toe's Introduction

Tic Tac Toe Solution

I've created my solution in JavaScript. Initially I considered doing a Python and JavaScript hybrid with ajax calls to a Django backend but this seemed like overkill to me. The final solution is implemented as a jQuery plugin (code/jquery.tictac.js).

To view the solution, open code/game.html in your browser.

How to use the plugin

Using the tictac plugin is easy. It's a basic jQuery plugin that doesn't allow for any customizations in its current form. Create an HTML page with a table marked up like so:

<table id="board" class="board">
    <tr>
        <td id="one" class="even"></td>
        <td id="two"></td>
        <td id="three" class="even"></td>
    </tr>
    <tr>
        <td id="four"></td>
        <td id="five" class="even"></td>
        <td id="six"></td>
    </tr>
    <tr>
        <td id="seven" class="even"></td>
        <td id="eight"></td>
        <td id="nine" class="even"></td>
    </tr>
</table>

Then add the following JavaScript to your HTML page before the </body> tag:

<script src="http://code.jquery.com/jquery-1.5.1.js" type="text/javascript" charset="utf-8"></script>
<script src="path/to/jquery.tictac.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
    $(function() {
        $("#board").tictac();
    });
</script>

The HTML page in code/game.html has a full working example with three boards on it.

Tests

Tests were built using QUnit. To run them, simply open code/tests/qunit.html in your browser.

tic-tac-toe's People

Contributors

richleland avatar cmheisel avatar datagrok avatar richardbronosky avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.