Coder Social home page Coder Social logo

times-two's Introduction

Times Two

A two-player version of the New York Times crossword! Originally designed for the "stackathon" event at Grace Hopper Academy.

At a basic level, this is a Chrome extension that connects to a Node server. It uses Express and socket.io, with a healthy dose of jQuery on the front end.

notes on Chrome extensions

The content script is the JS that gets injected into the page, and it can actually touch the DOM. Here, the content script listens for changes in the DOM using jQuery. The content script uses "message passing" to send any changes to the background script, which in turn emits the event to the server on the back end. WebSockets let the server then broadcast that event to the other users.

notes on events

At the moment, for adding / changing / removing letters, instead of listening for a keydown event, I'm just using DOMSubtreeModified.

I'm tracking the highlight by listening for a 'click' event on the cells, which (unfortunately) doesn't actually capture the wider range of ways that the highlighted cells (and the single active cell within them) can change, including clicking the clue number, using arrow keys, and straight-up inserting letters. Instead of using a click event, I'd like to switch to using Mutation Observers, which are new to me but at least seem entirely suited to this task.

I also need to find a way to abandon the totally duct-taped setTimeout that produces the array of highlighted cells in the content script. Once the mutation stuff above is wired up, maybe.

notes for eventually

I haven't tried this with rebus entries, but if they break things, it'll just be a question of adjusting to account for any differences in their inner HTML.

I also haven't tested this with more than two users, but I have a hunch I'll want to limit the number of clients in any given room to two or three at most.

Ideally, the popup would let users actually start or join a room.

Long-term, I need to redeploy this, update the URL accordingly, and then pack the extension to load it in the Chrome store. Cross your fingers.

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.