static/publish.js
// about attachments that are likely documents or source code.
about attachments that are likely documents or source code.
about attachments that are likely documents or source code .
function showFileWarniings () {
  document.getElementById('attachments')
    .addEventListener('change', onChange)
  function onChange (event) {
    event.preventDefault()
    event.stopPropagation()
    var oversize = false
    var looksLikeSoftware = false
    var looksLikeDocument = false
    var input = event.target
    var files = input.files
    for (var fileIndex = 0; fileIndex < files.length; fileIndex++) {
      var file = files[fileIndex]
      if (file.size > ATTACHMENT_SIZE) {
        oversize = true
        break
      }
      var index, extension, type
      for (index = 0; index < DOCUMENT_EXTENSIONS.length; index++) {
        extension = DOCUMENT_EXTENSIONS[index]
        if (file.name.endsWith(extension)) {
          looksLikeDocument = true
          break
        }
      }
      for (index = 0; index < DOCUMENT_TYPES.length; index++) {
        type = DOCUMENT_TYPES[index]
        if (file.type === type) {
          looksLikeDocument = true
          break
        }
      }
      for (index = 0; index < SOFTWARE_EXTENSIONS.length; index++) {
        extension = SOFTWARE_EXTENSIONS[index]
        if (file.name.endsWith(extension)) {
          looksLikeSoftware = true
          break
        }
      }
      for (index = 0; index < SOFTWARE_TYPES.length; index++) {
        type = SOFTWARE_TYPES[index]
        if (file.type === type) {
          looksLikeSoftware = true
          break
        }
      }
    }
    var warning
    if (oversize || looksLikeSoftware || looksLikeDocument) {
      warning = input.nextSibling
      var html = oversize
        ? OVERSIZE_WARNING
        : (looksLikeSoftware ? SOFTWARE_WARNING : DOCUMENT_WARNING)
      if (!warning) {
        warning = document.createElement('p')
        setClassName(warning)
        warning.innerHTML = html
        input.parentNode.appendChild(warning)
      } else {
        setClassName(warning)
        warning.innerHTML = html
      }
    } else {
      warning = input.nextSibling
      if (warning) {
        warning.parentNode.removeChild(warning)
      }
    }
    function setClassName (warning) {
      if (oversize) {
        warning.className = 'problem'
      } else if (looksLikeDocument) {
        warning.className = 'problem'
      } else if (looksLikeSoftware) {
        warning.className = 'legal'
      }
    }
  }
}
function showFileWarniings ( ) { document . getElementById ( 'attachments' ) . addEventListener ( 'change' , onChange ) function onChange ( event ) { event . preventDefault ( ) event . stopPropagation ( ) var oversize = false var looksLikeSoftware = false var looksLikeDocument = false var input = event . target var files = input . files for ( var fileIndex = 0 ; fileIndex < files . length ; fileIndex ++ ) { var file = files [ fileIndex ] if ( file . size > ATTACHMENT_SIZE ) { oversize = true break } var index , extension , type for ( index = 0 ; index < DOCUMENT_EXTENSIONS . length ; index ++ ) { extension = DOCUMENT_EXTENSIONS [ index ] if ( file . name . endsWith ( extension ) ) { looksLikeDocument = true break } } for ( index = 0 ; index < DOCUMENT_TYPES . length ; index ++ ) { type = DOCUMENT_TYPES [ index ] if ( file . type === type ) { looksLikeDocument = true break } } for ( index = 0 ; index < SOFTWARE_EXTENSIONS . length ; index ++ ) { extension = SOFTWARE_EXTENSIONS [ index ] if ( file . name . endsWith ( extension ) ) { looksLikeSoftware = true break } } for ( index = 0 ; index < SOFTWARE_TYPES . length ; index ++ ) { type = SOFTWARE_TYPES [ index ] if ( file . type === type ) { looksLikeSoftware = true break } } } var warning if ( oversize || looksLikeSoftware || looksLikeDocument ) { warning = input . nextSibling var html = oversize ? OVERSIZE_WARNING : ( looksLikeSoftware ? SOFTWARE_WARNING : DOCUMENT_WARNING ) if ( ! warning ) { warning = document . createElement ( 'p' ) setClassName ( warning ) warning . innerHTML = html input . parentNode . appendChild ( warning ) } else { setClassName ( warning ) warning . innerHTML = html } } else { warning = input . nextSibling if ( warning ) { warning . parentNode . removeChild ( warning ) } } function setClassName ( warning ) { if ( oversize ) { warning . className = 'problem' } else if ( looksLikeDocument ) { warning . className = 'problem' } else if ( looksLikeSoftware ) { warning . className = 'legal' } } } }
about attachments that are likely documents or source code.
about attachments that are likely documents or source code .