Browse Source

Organize autofill entry points

spaghetti 3 years ago
parent
commit
d6dbba4cef

sections/ajax/anidb.php → sections/ajax/autofill/anime.php View File

@@ -6,8 +6,8 @@ if (empty($_GET['aid'])) {
6 6
 
7 7
 $aid = $_GET['aid'];
8 8
 
9
-if ($Cache->get_value('anidb_json_'.$aid)) {
10
-  json_die("success", $Cache->get_value('anidb_json_'.$aid));
9
+if ($Cache->get_value('anime_fill_json_'.$aid)) {
10
+  json_die("success", $Cache->get_value('anime_fill_json_'.$aid));
11 11
 } else {
12 12
 
13 13
   $anidb_url = 'http://api.anidb.net:9001/httpapi?request=anime&client='.API_KEYS['ANIDB'].'&clientver=1&protover=1&aid='.$aid;
@@ -51,7 +51,7 @@ if ($Cache->get_value('anidb_json_'.$aid)) {
51 51
     'description' => $desc
52 52
   );
53 53
 
54
-  $Cache->cache_value('anidb_json_'.$aid, $json_str, 86400);
54
+  $Cache->cache_value('anime_fill_json_'.$aid, $json_str, 86400);
55 55
 
56 56
   json_die("success", $json_str);
57 57
 }

sections/ajax/javfill.php → sections/ajax/autofill/jav.php View File

@@ -12,8 +12,8 @@ if (!strpos($cn, '-')) {
12 12
   if ($m) { $cn = substr_replace($cn, '-', $m[0][1], 0); }
13 13
 }
14 14
 
15
-if (!$debug && $Cache->get_value('jav_json_'.$cn)) {
16
-  json_die('success', $Cache->get_value('jav_json_'.$cn));
15
+if (!$debug && $Cache->get_value('jav_fill_json_'.$cn)) {
16
+  json_die('success', $Cache->get_value('jav_fill_json_'.$cn));
17 17
 } else {
18 18
 
19 19
   $jlib_jp_url = ('http://www.javlibrary.com/ja/vl_searchbyid.php?keyword='.$cn);
@@ -163,7 +163,7 @@ if (!$debug && $Cache->get_value('jav_json_'.$cn)) {
163 163
     'degraded'    => $degraded
164 164
   );
165 165
 
166
-  $Cache->cache_value('jav_json_'.$cn, $json, 86400);
166
+  $Cache->cache_value('jav_fill_json_'.$cn, $json, 86400);
167 167
 
168 168
   json_die('success', $json);
169 169
 

sections/ajax/doujin.php → sections/ajax/autofill/manga.php View File

@@ -16,8 +16,8 @@ if (empty($gid) || empty($token)) {
16 16
   json_die("failure", "Invalid URL");
17 17
 }
18 18
 
19
-if ($Cache->get_value('doujin_json_'.$gid)) {
20
-  json_die("success", $Cache->get_value('doujin_json_'.$gid));
19
+if ($Cache->get_value('manga_fill_json_'.$gid)) {
20
+  json_die("success", $Cache->get_value('manga_fill_json_'.$gid));
21 21
 } else {
22 22
 
23 23
   $data = json_encode(["method" => "gdata", "gidlist" => [[$gid, $token]], "namespace" => 1]);
@@ -91,7 +91,7 @@ if ($Cache->get_value('doujin_json_'.$gid)) {
91 91
     'cover'       => $cover
92 92
   ];
93 93
 
94
-  $Cache->cache_value('doujin_json_'.$gid, $json_str, 86400);
94
+  $Cache->cache_value('manga_fill_json_'.$gid, $json_str, 86400);
95 95
 
96 96
   json_die("success", $json_str);
97 97
 }

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

@@ -153,14 +153,10 @@ switch ($_GET['action']) {
153 153
   case 'clear_user_notification':
154 154
     require(SERVER_ROOT . '/sections/ajax/clear_user_notification.php');
155 155
     break;
156
-  case 'anidb':
157
-    require(SERVER_ROOT . '/sections/ajax/anidb.php');
158
-    break;
159
-  case 'javfill':
160
-    require(SERVER_ROOT . '/sections/ajax/javfill.php');
161
-    break;
162
-  case 'doujin':
163
-    require(SERVER_ROOT . '/sections/ajax/doujin.php');
156
+  case 'autofill':
157
+    if ($_GET['cat'] == 'anime') require(SERVER_ROOT . '/sections/ajax/autofill/anime.php');
158
+    if ($_GET['cat'] == 'jav')   require(SERVER_ROOT . '/sections/ajax/autofill/jav.php');
159
+    if ($_GET['cat'] == 'manga') require(SERVER_ROOT . '/sections/ajax/autofill/manga.php');
164 160
     break;
165 161
   default:
166 162
     // If they're screwing around with the query string

+ 6
- 6
static/functions/upload.js View File

@@ -402,7 +402,7 @@ function ToggleUnknown() {
402 402
   }
403 403
 }
404 404
 
405
-function AnidbAutofill() {
405
+function AnimeAutofill() {
406 406
   var map = { artist: 'idols_0',
407 407
               title: 'title',
408 408
               title_rj: 'title_rj',
@@ -410,7 +410,7 @@ function AnidbAutofill() {
410 410
               year: 'year',
411 411
               description: 'album_desc' }
412 412
   var aid = $('#anidb').raw().value
413
-  $.getJSON('/ajax.php?action=anidb&aid='+aid, function(data) {
413
+  $.getJSON('/ajax.php?action=autofill&cat=anime&aid='+aid, function(data) {
414 414
     if (data.status != "success") return
415 415
     for (i in data.response) {
416 416
       if (map[i] && !($('#'+map[i]).raw().value)) {
@@ -431,7 +431,7 @@ function JavAutofill() {
431 431
               tags: 'tags',
432 432
               description: 'album_desc' }
433 433
   var cn = $('#javdb_tr #catalogue').raw().value.toUpperCase()
434
-  $.getJSON('/ajax.php?action=javfill&cn='+cn, function(data) {
434
+  $.getJSON('/ajax.php?action=autofill&cat=jav&cn='+cn, function(data) {
435 435
     if (data.status != "success") {
436 436
       $('#catalogue').raw().value = 'Failed'
437 437
       return
@@ -462,7 +462,7 @@ function JavAutofill() {
462 462
   })
463 463
 }
464 464
 
465
-function DoujAutofill() {
465
+function MangaAutofill() {
466 466
   var map = {  artists: 'idols',
467 467
               title: 'title',
468 468
               title_jp: 'title_jp',
@@ -474,7 +474,7 @@ function DoujAutofill() {
474 474
               pages: 'pages',
475 475
               description: 'release_desc' }
476 476
   var nh = $('#ehentai_tr #catalogue').raw().value
477
-  $.getJSON('/ajax.php?action=doujin&url='+nh, function(data) {
477
+  $.getJSON('/ajax.php?action=autofill&cat=manga&url='+nh, function(data) {
478 478
     if (data.status != "success") {
479 479
       $('#catalogue').raw().value = 'Failed'
480 480
       return
@@ -566,7 +566,7 @@ function MediaInfoExtract() {
566 566
 function initAutofill() {
567 567
   $('[autofill]').each(function(i, el) {
568 568
     el.addEventListener('click', function(event) {
569
-      ({'douj':DoujAutofill, 'anime':AnidbAutofill, 'jav':JavAutofill})[el.attributes['autofill'].value]()
569
+      ({'douj':MangaAutofill, 'anime':AnimeAutofill, 'jav':JavAutofill})[el.attributes['autofill'].value]()
570 570
     })
571 571
   })
572 572
 }

Loading…
Cancel
Save