Browse Source

Restructure and simplify upload form

spaghetti 7 years ago
parent
commit
b4f402bbba

+ 174
- 801
classes/torrent_form.class.php
File diff suppressed because it is too large
View File


+ 0
- 4
sections/ajax/index.php View File

@@ -37,10 +37,6 @@ if (!in_array($UserID, $UserExceptions) && isset($_GET['action']) && in_array($_
37 37
 
38 38
 switch ($_GET['action']) {
39 39
   // things that (may be) used on the site
40
-  case 'upload_section':
41
-    // Gets one of the upload forms
42
-    require(SERVER_ROOT . '/sections/ajax/upload.php');
43
-    break;
44 40
   case 'preview':
45 41
     require('preview.php');
46 42
     break;

+ 0
- 43
sections/ajax/upload.php View File

@@ -1,43 +0,0 @@
1
-<?
2
-// echo out the slice of the form needed for the selected upload type ($_GET['section']).
3
-
4
-
5
-// Include the necessary form class
6
-include(SERVER_ROOT.'/classes/torrent_form.class.php');
7
-$TorrentForm = new TORRENT_FORM();
8
-
9
-$GenreTags = $Cache->get_value('genre_tags');
10
-if (!$GenreTags) {
11
-  $DB->query('
12
-    SELECT Name
13
-    FROM tags
14
-    WHERE TagType=\'genre\'
15
-    ORDER BY Name');
16
-  $GenreTags = $DB->collect('Name');
17
-  $Cache->cache_value('genre_tags', $GenreTags, 3600 * 24);
18
-}
19
-
20
-$UploadForm = $Categories[$_GET['categoryid']];
21
-
22
-switch ($UploadForm) {
23
-  case 'Movies':
24
-    $TorrentForm->movies_form($GenreTags);
25
-    break;
26
-
27
-  case 'Anime':
28
-    $TorrentForm->anime_form($_GET['categoryid']);
29
-    break;
30
-  case 'Manga':
31
-    $TorrentForm->manga_form($_GET['categoryid']);
32
-    break;
33
-  case 'Games':
34
-    $TorrentForm->game_form($_GET['categoryid']);
35
-    break;
36
-  case 'Other':
37
-    $TorrentForm->simple_form($_GET['categoryid']);
38
-    break;
39
-  default:
40
-    echo 'Invalid action!';
41
-}
42
-
43
-?>

+ 2
- 22
sections/torrents/edit.php View File

@@ -69,27 +69,7 @@ View::show_header('Edit torrent', 'upload,torrent');
69 69
 
70 70
 $TorrentForm = new TORRENT_FORM($Properties, $Err, false);
71 71
 
72
-$TorrentForm->head();
73
-switch ($UploadForm) {
74
-  case 'Movies':
75
-    $TorrentForm->movies_form('');
76
-    break;
77
-  case 'Anime':
78
-    $TorrentForm->anime_form('');
79
-    break;
80
-  case 'Manga':
81
-    $TorrentForm->manga_form('');
82
-    break;
83
-  case 'Games':
84
-    $TorrentForm->game_form('');
85
-    break;
86
-  case 'Other':
87
-    $TorrentForm->simple_form();
88
-    break;
89
-  default:
90
-    $TorrentForm->movies_form('');
91
-}
92
-$TorrentForm->foot();
72
+$TorrentForm->upload_form();
93 73
 
94 74
 if (check_perms('torrents_edit') || check_perms('users_mod')) {
95 75
 ?>
@@ -177,7 +157,7 @@ if (check_perms('torrents_edit') || check_perms('users_mod')) {
177 157
       <tr>
178 158
         <td class="label">Change category</td>
179 159
         <td>
180
-          <select id="newcategoryid" name="newcategoryid" onchange="ChangeCategory(this.value);">
160
+          <select id="newcategoryid" name="newcategoryid">
181 161
 <?    foreach ($Categories as $CatID => $CatName) { ?>
182 162
             <option value="<?=($CatID + 1)?>"<?Format::selected('CategoryID', $CatID + 1, 'selected', $Properties)?>><?=($CatName)?></option>
183 163
 <?    } ?>

+ 2
- 27
sections/upload/upload.php View File

@@ -137,32 +137,7 @@ $HideDNU = check_perms('torrents_hide_dnu') && !$NewDNU;
137 137
   </table>
138 138
 </div><?=($HideDNU ? '<br />' : '')?>
139 139
 <?
140
-$TorrentForm->head();
141
-switch ($UploadForm) {
142
-  case 'Movies':
143
-    $TorrentForm->movies_form($GenreTags);
144
-    break;
145
-  case 'Anime':
146
-    $TorrentForm->anime_form($Properties['CategoryID']);
147
-    break;
148
-  case 'Manga':
149
-    $TorrentForm->manga_form();
150
-    break;
151
-  case 'Games':
152
-    $TorrentForm->game_form($Properties['CategoryID']);
153
-    break;
154
-  case 'Other':
155
-    $TorrentForm->simple_form($Properties['CategoryID']);
156
-    break;
157
-  default:
158
-    $TorrentForm->movies_form($GenreTags);
159
-}
160
-$TorrentForm->foot();
161
-?>
162
-<script type="text/javascript">
163
-  //Format();
164
-  //Bitrate();
165
-</script>
166
-<?
140
+$TorrentForm->upload_form();
141
+
167 142
 View::show_footer();
168 143
 ?>

+ 95
- 40
static/functions/upload.js View File

@@ -7,48 +7,102 @@ function DisplayTrans() {
7 7
 }
8 8
 
9 9
 function Categories() {
10
-  var save = {};
11
-  var form_elements = $('#dynamic_form input[name], #dynamic_form select, #dynamic_form textarea');
12
-  for (var i = 0; i < form_elements.length; i++) {
13
-    if (["Preview", "---", ""].indexOf(form_elements[i].value) == -1) {
14
-      if (form_elements[i].name.slice(-1) == '[]') {
15
-        save[form_elements[i].name] = save[form_elements[i].name] || new Array()
16
-        save[form_elements[i].name][form_elements[i].id.slice(form_elements[i].id.search(/[0-9]/))] = form_elements[i].value
17
-      } else if (form_elements[i].type == 'checkbox') {
18
-        save[form_elements[i].name] = form_elements[i].checked;
19
-      } else {
20
-        save[form_elements[i].name] = form_elements[i].value;
21
-      }
22
-    }
10
+  let def = ['title', 'title_rj', 'title_jp', 'year', 'lang', 'censored', 'tags', 'cover', 'group_desc', 'release_desc', 'anon']
11
+  let cats = [{
12
+    'javdb': {},
13
+    'idols': {name: 'Idol(s)'},
14
+    'studio': {name: 'Studio'},
15
+    'series': {name: 'Series'},
16
+    'media': {},
17
+    'container': {},
18
+    'codec': {},
19
+    'resolution': {},
20
+    'audio': {},
21
+    'sub': {},
22
+    'mediainfo': {},
23
+    'screenshots': {name: 'Screenshots'},
24
+    'group_desc': {notes: 'Contains information such as a description of the movie, a link to a JAV catalogue, etc.'},
25
+    'release_desc': {notes: 'Contains information such as encoder settings or watermarks'}
26
+  }, {
27
+    'anidb': {},
28
+    'idols': {name: 'Artist/Studio'},
29
+    'studio': false,
30
+    'series': {name: 'Circle (Optional)'},
31
+    'media': {},
32
+    'container': {},
33
+    'codec': {},
34
+    'resolution': {},
35
+    'audio': {},
36
+    'sub': {},
37
+    'mediainfo': {},
38
+    'tags': {notes: 'Remember to use the \'3d\' tag if your upload is 3DCG!'},
39
+    'screenshots': {name: 'Screenshots'},
40
+    'group_desc': {notes: 'Contains information such as a description of the anime, a link to AniDB, etc.'},
41
+    'release_desc': {notes: 'Contains information such as encoder settings or episode source differences'}
42
+  }, {
43
+    'ehentai': {},
44
+    'idols': {name: 'Artist'},
45
+    'studio': {name: 'Publisher (Optional)'},
46
+    'series': {name: 'Circle (Optional)'},
47
+    'pages': {},
48
+    'media_manga': {},
49
+    'archive_manga': {},
50
+    'trans': {name: 'Translation Group (optional)'},
51
+    'screenshots': {name: 'Samples'},
52
+    'group_desc': {notes: 'Contains information such as a description of the doujin.'},
53
+    'release_desc': {notes: 'Contains information such as formatting information.'}
54
+  }, {
55
+    'idols': {name: 'Developer'},
56
+    'series': {name: 'Circle (Optional)'},
57
+    'studio': {name: 'Publisher (Optional)'},
58
+    'dlsite': {},
59
+    'media_games': {},
60
+    'container_games': {},
61
+    'archive': {},
62
+    'trans': {name: 'Translation/Release Group (optional)'},
63
+    'tags': {notes: 'Tags you should consider, if appropriate: <strong>visual.novel</strong>, <strong>nukige</strong>'},
64
+    'screenshots': {name: 'Screenshots', notes: '<strong class="important_text">Promotional materials from a game\'s store page are NOT screenshots</strong>'},
65
+    'group_desc': {notes: 'Contains information such as a description of the game, its mechanics, etc.'},
66
+    'release_desc': {notes: 'Contains information such as <strong>version</strong>, install instructions, patching instructions, etc.'}
67
+  }, {
68
+    'idols': {name: 'Creators/Authors (Optional)'},
69
+    'studio': {name: 'Publisher (Optional)'},
70
+    'year': false,
71
+    'lang': false,
72
+    'dlsite': {},
73
+    'screenshots': {name: 'Screenshots'},
74
+    'release_desc': false
75
+  }]
76
+  let active = {}
77
+  for (let field of def) active[field] = {}
78
+  let category = 0
79
+  if ($('input[name="type"]').raw()) category = $('input[name="type"]').raw().value
80
+  if ($('#categories').raw()) category = $('#categories').raw().value
81
+  active = Object.assign(active, cats[category])
82
+
83
+  let hide = el => {
84
+    Array.from($(`#${el.id} input, #${el.id} select, #${el.id} textarea`)).forEach(inp => inp.disabled = true)
85
+    $(el).ghide()
86
+  }
87
+  let show = el => {
88
+    Array.from($(`#${el.id} input, #${el.id} select, #${el.id} textarea`)).forEach(inp => inp.disabled = false)
89
+    $(el).gshow()
23 90
   }
24 91
 
25
-  ajax.get('ajax.php?action=upload_section&categoryid=' + $('#categories').raw().value, function (response) {
26
-    $('#dynamic_form').raw().innerHTML = response;
27
-    initMultiButtons();
28
-    // Evaluate the code that generates previews.
29
-    eval($('#dynamic_form script.preview_code').html());
30
-
31
-    for (i in save) {
32
-      if (Array.isArray(save[i])) {
33
-        for (j in save[i]) {
34
-          if (!($('#'+i.slice(0,-2)+'_'+j).raw())) AddArtistField()
35
-          $('#'+i.slice(0,-2)+'_'+j).raw().value = save[i][j]
36
-        }
37
-      } else if (typeof(save[i]) == 'boolean') {
38
-        if ($('[name="'+i+'"]').raw()) $('[name="'+i+'"]').raw().checked = save[i]
39
-      } else {
40
-        if ($('[name="'+i+'"]').raw()) $('[name="'+i+'"]').raw().value = save[i]
92
+  let trs = $('#dynamic_form tr')
93
+  for (let tr of trs) {
94
+    let field = tr.id.slice(0,-3)
95
+    if (active[field]) {
96
+      if (active[field].name) {
97
+        tr.children[0].innerHTML = active[field].name
41 98
       }
99
+      let notes = $(`#${tr.id} p.notes`).raw()
100
+      if (notes) notes.innerHTML = active[field].notes||''
101
+      show(tr)
102
+    } else {
103
+      hide(tr)
42 104
     }
43
-    if ($('#categories').raw().value == "1") DisplayTrans()
44
-    if ($('#ressel').raw() && $('#ressel').raw().value == "Other") {
45
-      $('#resolution').raw().readOnly = false
46
-      $('#resolution').gshow()
47
-    }
48
-    initAutocomplete()
49
-    initAutofill()
50
-    $('.bbcode_editor').each(function(i, el) { BBEditor(el) })
51
-  });
105
+  }
52 106
 }
53 107
 
54 108
 function Bitrate() {
@@ -385,7 +439,7 @@ function JavAutofill() {
385 439
               image: 'image',
386 440
               tags: 'tags',
387 441
               description: 'album_desc' }
388
-  var cn = $('#catalogue').raw().value.toUpperCase()
442
+  var cn = $('#javdb_tr #catalogue').raw().value.toUpperCase()
389 443
   $.getJSON('/ajax.php?action=javfill&cn='+cn, function(data) {
390 444
     if (data.status != "success") {
391 445
       $('#catalogue').raw().value = 'Failed'
@@ -428,7 +482,7 @@ function DoujAutofill() {
428 482
               circle: 'series',
429 483
               pages: 'pages',
430 484
               description: 'release_desc' }
431
-  var nh = $('#catalogue').raw().value
485
+  var nh = $('#ehentai_tr #catalogue').raw().value
432 486
   $.getJSON('/ajax.php?action=doujin&url='+nh, function(data) {
433 487
     if (data.status != "success") {
434 488
       $('#catalogue').raw().value = 'Failed'
@@ -527,6 +581,7 @@ function initAutofill() {
527 581
 }
528 582
 
529 583
 $(function() {
584
+  Categories();
530 585
   initAutofill();
531 586
   $(document).on('click', '.add_artist_button', AddArtistField);
532 587
   $(document).on('click', '.remove_artist_button', RemoveArtistField);

Loading…
Cancel
Save