Oppaitime's version of Gazelle
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

validate_upload.js 1.1KB

123456789101112131415161718192021222324252627282930313233
  1. $(() => {
  2. $("#post").click(e => {
  3. let hard_error = m => {
  4. if (e.isDefaultPrevented()) return
  5. alert(m)
  6. e.preventDefault()
  7. }
  8. let soft_error = m => {
  9. if (e.isDefaultPrevented()) return
  10. if (!confirm(`${m}\n\nPress OK to upload anyway`)) {
  11. e.preventDefault()
  12. }
  13. }
  14. if (!$('#file').raw().value) {
  15. hard_error('No torrent file is selected')
  16. }
  17. if ($('#release_desc').raw().value.length < 10) {
  18. hard_error('The release description is too short')
  19. }
  20. if ($('#file').raw().value.slice(-8).toLowerCase() != '.torrent') {
  21. soft_error('The file selected does not appear to be a .torrent file')
  22. }
  23. let mi = $('#mediainfo').raw().value
  24. if (mi && (!mi.includes('General') || !mi.includes('Video'))) {
  25. soft_error('Your MediaInfo does not appear to be from a valid MediaInfo utility')
  26. }
  27. if (!$('#image').raw().value) {
  28. soft_error('You did not include a cover image, which is mandatory if one exists')
  29. }
  30. })
  31. $('#tags').on('blur', e => $('#tags').raw().value = $('#tags').raw().value.split(',').map(t=>t.trim()).filter(t=>t).join(', '))
  32. })