       return element if element.nodeName == 'FORM'
       element = element.parentNode
     null
-    
+
+PwnFx.registerEffect 'data-pwnfx-refresh-url', PwnFxRefresh
+
+
 # Shows elements conditionally, depending on whether some inputs' values match.
 #
 # Element attributes:

    element.addEventListener 'change', onChange
    element.addEventListener 'keydown', onChange
    element.addEventListener 'keyup', onChange
        
# Moves an element using data-pwnfx-move.
class PwnFxMove
  constructor: (element, identifier) ->
    targetSelector = 
    target = document.querySelector "[data-pwnfx-move-target=\"#{identifier}\"]"
    target.appendChild element
    
# Renders the contents of a template into a DOM element.
#
# Attributes:
#   data-pwnfx-render: identifier for the render operation
#   data-pwnfx-render-where: insertAdjacentHTML position argument; can be
#       beforebegin, afterbegin, beforeend, afterend; defaults to beforeend
#   data-pwnfx-render-target: set on the element(s) receiving the rendered HTML;
#       set to the identifier in data-pwnfx-render 
#   data-pwnfx-render-source: set on the <script> tag containing the source HTML
#       to be rendered; set to the identifier in data-pwnfx-render
class PwnFxRender
  constructor: (element, identifier) ->
    sourceSelector = "script[data-pwnfx-render-source=\"#{identifier}\"]"
    targetSelector = "[data-pwnfx-render-target=\"#{identifier}\"]"
    insertionPoint = element.getAttribute('data-pwnfx-render-where') ||
                     'beforeend'
    
    onClick = (event) ->
      source = document.querySelector sourceSelector
      html = source.innerHTML
      for element in document.querySelectorAll(targetSelector)
        element.insertAdjacentHTML insertionPoint, html
      event.preventDefault()
      false
    element.addEventListener 'click', onClick


# Shows / hides elements when an element is clicked or checked / unchecked.

      element.addEventListener 'change', onChange
      onChange()

PwnFx.registerEffect 'data-pwnfx-reveal', PwnFxReveal


# Export the PwnFx instance.
window.PwnFx = PwnFx

# Wire up the entire DOM after the document is loaded.
window.addEventListener 'load', -> PwnFx.wire(document)
