<commit_before>#
#
#            Nim's Runtime Library
#        (c) Copyright 2012 <NAME>
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

## Declaration of the Document Object Model for the `JavaScript backend
## <backends.html#the-javascript-target>`_.

when not defined(js) and not defined(Nimdoc):
  {.error: "This module only works on the JavaScript platform".}

type
  TEventHandlers* {.importc.} = object of RootObj
    onabort*: proc (event: ref TEvent) {.nimcall.}
    onblur*: proc (event: ref TEvent) {.nimcall.}
    onchange*: proc (event: ref TEvent) {.nimcall.}
    onclick*: proc (event: ref TEvent) {.nimcall.}
    ondblclick*: proc (event: ref TEvent) {.nimcall.}
    onerror*: proc (event: ref TEvent) {.nimcall.}
    onfocus*: proc (event: ref TEvent) {.nimcall.}
    onkeydown*: proc (event: ref TEvent) {.nimcall.}
    onkeypress*: proc (event: ref TEvent) {.nimcall.}
    onkeyup*: proc (event: ref TEvent) {.nimcall.}
    onload*: proc (event: ref TEvent) {.nimcall.}
    onmousedown*: proc (event: ref TEvent) {.nimcall.}
    onmousemove*: proc (event: ref TEvent) {.nimcall.}
    onmouseout*: proc (event: ref TEvent) {.nimcall.}
    onmouseover*: proc (event: ref TEvent) {.nimcall.}
    onmouseup*: proc (event: ref TEvent) {.nimcall.}
    onreset*: proc (event: ref TEvent) {.nimcall.}
    onselect*: proc (event: ref TEvent) {.nimcall.}
    onsubmit*: proc (event: ref TEvent) {.nimcall.}
    onunload*: proc (event: ref TEvent) {.nimcall.}

    addEventListener*: proc(ev: cstring, cb: proc(ev: ref TEvent), useCapture: bool = false) {.nimcall.}

  Window* = ref WindowObj
  WindowObj {.importc.} = object of TEventHandlers
    document*: Document
    event*: ref TEvent
    history*: ref THistory
    location*: ref TLocation
    closed*: bool
    defaultStatus*: cstring
    innerHeight*, innerWidth*: int
    locationbar*: ref TLocationBar
    menubar*: ref TMenuBar
    name*: cstring
    outerHeight*, outerWidth*: int
    pageXOffset*, pageYOffset*: int
    personalbar*: ref TPersonalBar
    scrollbars*: ref TScrollBars
    statusbar*: ref TStatusBar
    status*: cstring
    toolbar*: ref TToolBar

    alert*: proc (msg: cstring) {.nimcall.}
    back*: proc () {.nimcall.}
    blur*: proc () {.nimcall.}
    captureEvents*: proc (eventMask: int) {.nimcall.}
    clearInterval*: proc (interval: ref TInterval) {.nimcall.}
    clearTimeout*: proc (timeout: ref TTimeOut) {.nimcall.}
    close*: proc () {.nimcall.}
    confirm*: proc (msg: cstring): bool {.nimcall.}
    disableExternalCapture*: proc () {.nimcall.}
    enableExternalCapture*: proc () {.nimcall.}
    find*: proc (text: cstring, caseSensitive = false,
                 backwards = false) {.nimcall.}
    focus*: proc () {.nimcall.}
    forward*: proc () {.nimcall.}
    handleEvent*: proc (e: ref TEvent) {.nimcall.}
    home*: proc () {.nimcall.}
    moveBy*: proc (x, y: int) {.nimcall.}
    moveTo*: proc (x, y: int) {.nimcall.}
    open*: proc (uri, windowname: cstring,
                 properties: cstring = nil): Window {.nimcall.}
    print*: proc () {.nimcall.}
    prompt*: proc (text, default: cstring): cstring {.nimcall.}
    releaseEvents*: proc (eventMask: int) {.nimcall.}
    resizeBy*: proc (x, y: int) {.nimcall.}
    resizeTo*: proc (x, y: int) {.nimcall.}
    routeEvent*: proc (event: ref TEvent) {.nimcall.}
    scrollBy*: proc (x, y: int) {.nimcall.}
    scrollTo*: proc (x, y: int) {.nimcall.}
    setInterval*: proc (code: cstring, pause: int): ref TInterval {.nimcall.}
    setTimeout*: proc (code: cstring, pause: int): ref TTimeOut {.nimcall.}
    stop*: proc () {.nimcall.}
    frames*: seq[TFrame]

  Frame* = ref FrameObj
  FrameObj {.importc.} = object of WindowObj

  ClassList* {.importc.} = object of RootObj
    add*: proc (class: cstring) {.nimcall.}
    remove*: proc (class: cstring) {.nimcall.}
    contains*: proc (class: cstring):bool {.nimcall.}
    toggle*: proc (class: cstring) {.nimcall.}

  TNodeType* = enum
    ElementNode = 1,
    AttributeNode,
    TextNode,
    CDATANode,
    EntityRefNode,
    EntityNode,
    ProcessingInstructionNode,
    CommentNode,
    DocumentNode,
    DocumentTypeNode,
    DocumentFragmentNode,
    NotationNode

  Node* = ref NodeObj
  NodeObj {.importc.} = object of TEventHandlers
    attributes*: seq[Node]
    childNodes*: seq[Node]
    children*: seq[Node]
    data*: cstring
    firstChild*: Node
    lastChild*: Node
    nextSibling*: Node
    nodeName*: cstring
    nodeType*: TNodeType
    nodeValue*: cstring
    parentNode*: Node
    previousSibling*: Node
    appendChild*: proc (child: Node) {.nimcall.}
    appendData*: proc (data: cstring) {.nimcall.}
    cloneNode*: proc (copyContent: bool): Node {.nimcall.}
    deleteData*: proc (start, len: int) {.nimcall.}
    getAttribute*: proc (attr: cstring): cstring {.nimcall.}
    getAttributeNode*: proc (attr: cstring): Node {.nimcall.}
    hasChildNodes*: proc (): bool {.nimcall.}
    innerHTML*: cstring
    insertBefore*: proc (newNode, before: Node) {.nimcall.}
    insertData*: proc (position: int, data: cstring) {.nimcall.}
    removeAttribute*: proc (attr: cstring) {.nimcall.}
    removeAttributeNode*: proc (attr: Node) {.nimcall.}
    removeChild*: proc (child: Node) {.nimcall.}
    replaceChild*: proc (newNode, oldNode: Node) {.nimcall.}
    replaceData*: proc (start, len: int, text: cstring) {.nimcall.}
    scrollIntoView*: proc () {.nimcall.}
    setAttribute*: proc (name, value: cstring) {.nimcall.}
    setAttributeNode*: proc (attr: Node) {.nimcall.}
    style*: ref TStyle

  Document* = ref DocumentObj
  DocumentObj {.importc.} = object of NodeObj
    alinkColor*: cstring
    bgColor*: cstring
    charset*: cstring
    cookie*: cstring
    defaultCharset*: cstring
    fgColor*: cstring
    lastModified*: cstring
    linkColor*: cstring
    referrer*: cstring
    title*: cstring
    URL*: cstring
    vlinkColor*: cstring
    captureEvents*: proc (eventMask: int) {.nimcall.}
    createAttribute*: proc (identifier: cstring): Node {.nimcall.}
    createElement*: proc (identifier: cstring): Element {.nimcall.}
    createTextNode*: proc (identifier: cstring): Node {.nimcall.}
    getElementById*: proc (id: cstring): Element {.nimcall.}
    getElementsByName*: proc (name: cstring): seq[Element] {.nimcall.}
    getElementsByTagName*: proc (name: cstring): seq[Element] {.nimcall.}<commit_msg>Added body and head properties to document.<commit_after>#
#
#            Nim's Runtime Library
#        (c) Copyright 2012 <NAME>
#
#    See the file "copying.txt", included in this
#    distribution, for details about the copyright.
#

## Declaration of the Document Object Model for the `JavaScript backend
## <backends.html#the-javascript-target>`_.

when not defined(js) and not defined(Nimdoc):
  {.error: "This module only works on the JavaScript platform".}

type
  TEventHandlers* {.importc.} = object of RootObj
    onabort*: proc (event: ref TEvent) {.nimcall.}
    onblur*: proc (event: ref TEvent) {.nimcall.}
    onchange*: proc (event: ref TEvent) {.nimcall.}
    onclick*: proc (event: ref TEvent) {.nimcall.}
    ondblclick*: proc (event: ref TEvent) {.nimcall.}
    onerror*: proc (event: ref TEvent) {.nimcall.}
    onfocus*: proc (event: ref TEvent) {.nimcall.}
    onkeydown*: proc (event: ref TEvent) {.nimcall.}
    onkeypress*: proc (event: ref TEvent) {.nimcall.}
    onkeyup*: proc (event: ref TEvent) {.nimcall.}
    onload*: proc (event: ref TEvent) {.nimcall.}
    onmousedown*: proc (event: ref TEvent) {.nimcall.}
    onmousemove*: proc (event: ref TEvent) {.nimcall.}
    onmouseout*: proc (event: ref TEvent) {.nimcall.}
    onmouseover*: proc (event: ref TEvent) {.nimcall.}
    onmouseup*: proc (event: ref TEvent) {.nimcall.}
    onreset*: proc (event: ref TEvent) {.nimcall.}
    onselect*: proc (event: ref TEvent) {.nimcall.}
    onsubmit*: proc (event: ref TEvent) {.nimcall.}
    onunload*: proc (event: ref TEvent) {.nimcall.}

    addEventListener*: proc(ev: cstring, cb: proc(ev: ref TEvent), useCapture: bool = false) {.nimcall.}

  Window* = ref WindowObj
  WindowObj {.importc.} = object of TEventHandlers
    document*: Document
    event*: ref TEvent
    history*: ref THistory
    location*: ref TLocation
    closed*: bool
    defaultStatus*: cstring
    innerHeight*, innerWidth*: int
    locationbar*: ref TLocationBar
    menubar*: ref TMenuBar
    name*: cstring
    outerHeight*, outerWidth*: int
    pageXOffset*, pageYOffset*: int
    personalbar*: ref TPersonalBar
    scrollbars*: ref TScrollBars
    statusbar*: ref TStatusBar
    status*: cstring
    toolbar*: ref TToolBar

    alert*: proc (msg: cstring) {.nimcall.}
    back*: proc () {.nimcall.}
    blur*: proc () {.nimcall.}
    captureEvents*: proc (eventMask: int) {.nimcall.}
    clearInterval*: proc (interval: ref TInterval) {.nimcall.}
    clearTimeout*: proc (timeout: ref TTimeOut) {.nimcall.}
    close*: proc () {.nimcall.}
    confirm*: proc (msg: cstring): bool {.nimcall.}
    disableExternalCapture*: proc () {.nimcall.}
    enableExternalCapture*: proc () {.nimcall.}
    find*: proc (text: cstring, caseSensitive = false,
                 backwards = false) {.nimcall.}
    focus*: proc () {.nimcall.}
    forward*: proc () {.nimcall.}
    handleEvent*: proc (e: ref TEvent) {.nimcall.}
    home*: proc () {.nimcall.}
    moveBy*: proc (x, y: int) {.nimcall.}
    moveTo*: proc (x, y: int) {.nimcall.}
    open*: proc (uri, windowname: cstring,
                 properties: cstring = nil): Window {.nimcall.}
    print*: proc () {.nimcall.}
    prompt*: proc (text, default: cstring): cstring {.nimcall.}
    releaseEvents*: proc (eventMask: int) {.nimcall.}
    resizeBy*: proc (x, y: int) {.nimcall.}
    resizeTo*: proc (x, y: int) {.nimcall.}
    routeEvent*: proc (event: ref TEvent) {.nimcall.}
    scrollBy*: proc (x, y: int) {.nimcall.}
    scrollTo*: proc (x, y: int) {.nimcall.}
    setInterval*: proc (code: cstring, pause: int): ref TInterval {.nimcall.}
    setTimeout*: proc (code: cstring, pause: int): ref TTimeOut {.nimcall.}
    stop*: proc () {.nimcall.}
    frames*: seq[TFrame]

  Frame* = ref FrameObj
  FrameObj {.importc.} = object of WindowObj

  ClassList* {.importc.} = object of RootObj
    add*: proc (class: cstring) {.nimcall.}
    remove*: proc (class: cstring) {.nimcall.}
    contains*: proc (class: cstring):bool {.nimcall.}
    toggle*: proc (class: cstring) {.nimcall.}

  TNodeType* = enum
    ElementNode = 1,
    AttributeNode,
    TextNode,
    CDATANode,
    EntityRefNode,
    EntityNode,
    ProcessingInstructionNode,
    CommentNode,
    DocumentNode,
    DocumentTypeNode,
    DocumentFragmentNode,
    NotationNode

  Node* = ref NodeObj
  NodeObj {.importc.} = object of TEventHandlers
    attributes*: seq[Node]
    childNodes*: seq[Node]
    children*: seq[Node]
    data*: cstring
    firstChild*: Node
    lastChild*: Node
    nextSibling*: Node
    nodeName*: cstring
    nodeType*: TNodeType
    nodeValue*: cstring
    parentNode*: Node
    previousSibling*: Node
    appendChild*: proc (child: Node) {.nimcall.}
    appendData*: proc (data: cstring) {.nimcall.}
    cloneNode*: proc (copyContent: bool): Node {.nimcall.}
    deleteData*: proc (start, len: int) {.nimcall.}
    getAttribute*: proc (attr: cstring): cstring {.nimcall.}
    getAttributeNode*: proc (attr: cstring): Node {.nimcall.}
    hasChildNodes*: proc (): bool {.nimcall.}
    innerHTML*: cstring
    insertBefore*: proc (newNode, before: Node) {.nimcall.}
    insertData*: proc (position: int, data: cstring) {.nimcall.}
    removeAttribute*: proc (attr: cstring) {.nimcall.}
    removeAttributeNode*: proc (attr: Node) {.nimcall.}
    removeChild*: proc (child: Node) {.nimcall.}
    replaceChild*: proc (newNode, oldNode: Node) {.nimcall.}
    replaceData*: proc (start, len: int, text: cstring) {.nimcall.}
    scrollIntoView*: proc () {.nimcall.}
    setAttribute*: proc (name, value: cstring) {.nimcall.}
    setAttributeNode*: proc (attr: Node) {.nimcall.}
    style*: ref TStyle

  Document* = ref DocumentObj
  DocumentObj {.importc.} = object of NodeObj
    alinkColor*: cstring
    bgColor*: cstring
    body*: Element
    charset*: cstring
    cookie*: cstring
    defaultCharset*: cstring
    fgColor*: cstring
    head*: Element
    lastModified*: cstring
    linkColor*: cstring
    referrer*: cstring
    title*: cstring
    URL*: cstring
    vlinkColor*: cstring
    captureEvents*: proc (eventMask: int) {.nimcall.}
    createAttribute*: proc (identifier: cstring): Node {.nimcall.}
    createElement*: proc (identifier: cstring): Element {.nimcall.}
    createTextNode*: proc (identifier: cstring): Node {.nimcall.}
    getElementById*: proc (id: cstring): Element {.nimcall.}
    getElementsByName*: proc (name: cstring): seq[Element] {.nimcall.}
    getElementsByTagName*: proc (name: cstring): seq[Element] {.nimcall.}
{'fraction_non_alphanumeric': 0.14715434580884626, 'fraction_numerical': 0.0007732755954222085, 'mean_word_length': 3.3167556742323097, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1946464', 'n_tokens_mistral': 4169, 'n_tokens_neox': 4274, 'n_words': 1303}