Browse Source

Organize autofill entry points

spaghetti 7 years ago
parent
commit
d6dbba4cef

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

6
 
6
 
7
 $aid = $_GET['aid'];
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
 } else {
11
 } else {
12
 
12
 
13
   $anidb_url = 'http://api.anidb.net:9001/httpapi?request=anime&client='.API_KEYS['ANIDB'].'&clientver=1&protover=1&aid='.$aid;
13
   $anidb_url = 'http://api.anidb.net:9001/httpapi?request=anime&client='.API_KEYS['ANIDB'].'&clientver=1&protover=1&aid='.$aid;
51
     'description' => $desc
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
   json_die("success", $json_str);
56
   json_die("success", $json_str);
57
 }
57
 }

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

12
   if ($m) { $cn = substr_replace($cn, '-', $m[0][1], 0); }
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
 } else {
17
 } else {
18
 
18
 
19
   $jlib_jp_url = ('http://www.javlibrary.com/ja/vl_searchbyid.php?keyword='.$cn);
19
   $jlib_jp_url = ('http://www.javlibrary.com/ja/vl_searchbyid.php?keyword='.$cn);
163
     'degraded'    => $degraded
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
   json_die('success', $json);
168
   json_die('success', $json);
169
 
169
 

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

16
   json_die("failure", "Invalid URL");
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
 } else {
21
 } else {
22
 
22
 
23
   $data = json_encode(["method" => "gdata", "gidlist" => [[$gid, $token]], "namespace" => 1]);
23
   $data = json_encode(["method" => "gdata", "gidlist" => [[$gid, $token]], "namespace" => 1]);
91
     'cover'       => $cover
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
   json_die("success", $json_str);
96
   json_die("success", $json_str);
97
 }
97
 }

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

153
   case 'clear_user_notification':
153
   case 'clear_user_notification':
154
     require(SERVER_ROOT . '/sections/ajax/clear_user_notification.php');
154
     require(SERVER_ROOT . '/sections/ajax/clear_user_notification.php');
155
     break;
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
     break;
160
     break;
165
   default:
161
   default:
166
     // If they're screwing around with the query string
162
     // If they're screwing around with the query string

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

402
   }
402
   }
403
 }
403
 }
404
 
404
 
405
-function AnidbAutofill() {
405
+function AnimeAutofill() {
406
   var map = { artist: 'idols_0',
406
   var map = { artist: 'idols_0',
407
               title: 'title',
407
               title: 'title',
408
               title_rj: 'title_rj',
408
               title_rj: 'title_rj',
410
               year: 'year',
410
               year: 'year',
411
               description: 'album_desc' }
411
               description: 'album_desc' }
412
   var aid = $('#anidb').raw().value
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
     if (data.status != "success") return
414
     if (data.status != "success") return
415
     for (i in data.response) {
415
     for (i in data.response) {
416
       if (map[i] && !($('#'+map[i]).raw().value)) {
416
       if (map[i] && !($('#'+map[i]).raw().value)) {
431
               tags: 'tags',
431
               tags: 'tags',
432
               description: 'album_desc' }
432
               description: 'album_desc' }
433
   var cn = $('#javdb_tr #catalogue').raw().value.toUpperCase()
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
     if (data.status != "success") {
435
     if (data.status != "success") {
436
       $('#catalogue').raw().value = 'Failed'
436
       $('#catalogue').raw().value = 'Failed'
437
       return
437
       return
462
   })
462
   })
463
 }
463
 }
464
 
464
 
465
-function DoujAutofill() {
465
+function MangaAutofill() {
466
   var map = {  artists: 'idols',
466
   var map = {  artists: 'idols',
467
               title: 'title',
467
               title: 'title',
468
               title_jp: 'title_jp',
468
               title_jp: 'title_jp',
474
               pages: 'pages',
474
               pages: 'pages',
475
               description: 'release_desc' }
475
               description: 'release_desc' }
476
   var nh = $('#ehentai_tr #catalogue').raw().value
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
     if (data.status != "success") {
478
     if (data.status != "success") {
479
       $('#catalogue').raw().value = 'Failed'
479
       $('#catalogue').raw().value = 'Failed'
480
       return
480
       return
566
 function initAutofill() {
566
 function initAutofill() {
567
   $('[autofill]').each(function(i, el) {
567
   $('[autofill]').each(function(i, el) {
568
     el.addEventListener('click', function(event) {
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