Skip to content

Instantly share code, notes, and snippets.

@cognominal
Created April 3, 2011 23:30
Show Gist options
  • Save cognominal/900921 to your computer and use it in GitHub Desktop.
Save cognominal/900921 to your computer and use it in GitHub Desktop.
Want to work both on node and in a browser. my problem was the scope of window and $
class Cursor
constructor: (dadDiv) ->
dadDiv.append $ "<div class='cursor'></div>"
@visible = false
toggle : ->
cursor.style.visibility =
if @visible = !@visible then 'visible' else 'hidden'
setTimeout toggle, 500
main = ->
$ "body"
c = new Cursor $ "body"
console.log ($ ".cursor").length
if window?
main()
else
{ jsdom } = require 'jsdom'
this.$ = require 'jquery'
this.window = jsdom().createWindow()
main.call(window)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment