       return
 
   D.createSocket = ->
-    class LocalSocket
+    class LocalSocket # imitate socket.io's API
       emit: (a...) -> @other.onevent data: a
       onevent: ({data}) -> (for f in @[data[0]] or [] then f data[1..]...); return
       on: (e, f) -> (@[e] ?= []).push f; @

    return

  $ ->
    contextMenu = null
    $ document
      .on 'keydown', '*', 'f12', -> nww.showDevTools(); false
      .on 'contextmenu', (e) ->
        if !contextMenu
          contextMenu = new gui.Menu
          ['Cut', 'Copy', 'Paste'].forEach (x) ->
            contextMenu.append new gui.MenuItem label: x, click: (-> document.execCommand x; return); return
        contextMenu.popup e.clientX, e.clientY
        false
    return

  D.readFile = fs.readFile

  # external editors (available only under nwjs)
  tmpDir = process.env.TMPDIR || process.env.TMP || process.env.TEMP || '/tmp'


  urlParams = {}
  for kv in (location + '').replace(/^[^\?]*($|\?)/, '').split '&'
    [_, k, v] = /^([^=]*)=?(.*)$/.exec kv; urlParams[unescape k || ''] = unescape v || ''

  do -> # restore window state:
    if D.floating
