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.4KB

12345678910111213141516171819202122232425262728293031323334353637
  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 ($('#album_desc').raw().value.length < 10) {
  18. hard_error('The group 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') && !mi.includes('Audio')))) {
  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. if ($('#media_tr select').raw().value == 'DVD' && (['720p','1080i','1080p','4K'].includes($('#ressel').raw().value) || +$('#resolution').raw().value.split('x')[1] > 576)) {
  31. soft_error('Your selected resolution is too high to be a DVD. Are you sure the media type should be DVD and not WEB?')
  32. }
  33. })
  34. $('#tags').on('blur', e => $('#tags').raw().value = $('#tags').raw().value.split(',').map(t=>t.trim()).filter(t=>t).join(', '))
  35. })