Browse Source

Prepare autofills

pjc 5 years ago
parent
commit
1129d823ea
3 changed files with 58 additions and 7 deletions
  1. 4
    3
      classes/torrent_form.class.php
  2. 52
    2
      sections/ajax/autofill/jav.php
  3. 2
    2
      static/functions/upload.js

+ 4
- 3
classes/torrent_form.class.php View File

@@ -262,11 +262,12 @@ class TorrentForm
262 262
         value="<?= display_str($Torrent['CatalogueNumber']) ?>"
263 263
         <?= $this->Disabled ?>/>
264 264
       <?php if (!$this->DisabledFlag) { ?>
265
-        <input type="button" autofill="jav" value="Autofill"
266
-          style="background: lightgrey; pointer-events: none;">
265
+        <input type="button" autofill="jav" value="Autofill">
267 266
         </input>
268 267
         Coming Soon!<br />
269
-        RefSeq accession number, e.g., NM_001183340.1
268
+        <!-- Autofill only supports RefSeq and UniProt; -->
269
+        Enter any ID number that corresponds to the data,
270
+        preferring RefSeq and UniProt
270 271
       <?php } ?>
271 272
     </td>
272 273
   </tr>

+ 52
- 2
sections/ajax/autofill/jav.php View File

@@ -1,4 +1,6 @@
1 1
 <?
2
+
3
+# Headers, cache, etc.
2 4
 $debug = false;
3 5
 
4 6
 if (empty($_GET['cn'])) {
@@ -16,6 +18,54 @@ if (!$debug && $Cache->get_value('jav_fill_json_'.$cn)) {
16 18
   json_die('success', $Cache->get_value('jav_fill_json_'.$cn));
17 19
 } else {
18 20
 
21
+  # Query the API
22
+  # @todo Valida to change $db
23
+
24
+/* @todo
25
+ * switch $category:
26
+ *   case 'DNA' || 'RNA':
27
+ *     if $number = refseq_regex:
28
+ *        $db = 'refseq';
29
+ *     break;
30
+ *   case 'Protein':
31
+ *     if $number = uniprot_regex:
32
+ *        $db = 'uniprot';
33
+ *     break;
34
+ *   default:
35
+ *     error 'invalid number';
36
+ *     break;
37
+ */
38
+$id = 'NM_001183340.1';
39
+
40
+# Assemble the esearch URL
41
+$base = 'https://eutils.ncbi.nlm.nih.gov/entrez/eutils/';
42
+$url = $base . "esummary.fcgi?db=$db&id=$id&version=2.0";
43
+
44
+# Post the esearch URL
45
+$output = file_get_contents($url);
46
+
47
+# Parse WebEnv and QueryKey
48
+#$web = $1 if ($output =~ /<WebEnv>(\S+)<\/WebEnv>/);
49
+#$key = $1 if ($output =~ /<QueryKey>(\d+)<\/QueryKey>/);
50
+
51
+### Include this code for ESearch-ESummary
52
+# Assemble the esummary URL
53
+$url = $base . "esummary.fcgi?db=$db&query_key=$key&WebEnv=$web";
54
+
55
+# Post the esummary URL
56
+$docsums = file_get_contents($url);
57
+print "$docsums";
58
+
59
+### Include this code for ESearch-EFetch
60
+# Assemble the efetch URL
61
+$url = $base . "efetch.fcgi?db=$db&query_key=$key&WebEnv=$web";
62
+$url .= "&rettype=abstract&retmode=text";
63
+
64
+# Post the efetch URL
65
+$data = file_get_contents($url);
66
+print "$data";
67
+
68
+  /*
19 69
   $jlib_jp_url = ('http://www.javlibrary.com/ja/vl_searchbyid.php?keyword='.$cn);
20 70
   $jlib_en_url = ('http://www.javlibrary.com/en/vl_searchbyid.php?keyword='.$cn);
21 71
   $jdb_url     = ('http://javdatabase.com/movies/'.$cn.'/');
@@ -141,7 +191,7 @@ if (!$debug && $Cache->get_value('jav_fill_json_'.$cn)) {
141 191
       $image = 'https:'.$image;
142 192
     }
143 193
     if (!$desc) {
144
-      //Shit neither of the sites have descriptions
194
+      // Shit neither of the sites have descriptions
145 195
       $desc = '';
146 196
     }
147 197
   }
@@ -179,5 +229,5 @@ if (!$debug && $Cache->get_value('jav_fill_json_'.$cn)) {
179 229
   $Cache->cache_value('jav_fill_json_'.$cn, $json, 86400);
180 230
 
181 231
   json_die('success', $json);
182
-
232
+*/
183 233
 }

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

@@ -48,7 +48,7 @@ function Categories() {
48 48
       'group_desc': {},
49 49
       'release_desc': {}
50 50
     }, { // Imaging
51
-      //'javdb': {},
51
+      'javdb': {},
52 52
       'idols': {},
53 53
       'studio': {},
54 54
       'series': {},
@@ -60,7 +60,7 @@ function Categories() {
60 60
       'group_desc': {},
61 61
       'release_desc': {}
62 62
     }, { // Other
63
-      //'javdb': {},
63
+      'javdb': {},
64 64
       'idols': {},
65 65
       'studio': {},
66 66
       'series': {},

Loading…
Cancel
Save