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
         value="<?= display_str($Torrent['CatalogueNumber']) ?>"
262
         value="<?= display_str($Torrent['CatalogueNumber']) ?>"
263
         <?= $this->Disabled ?>/>
263
         <?= $this->Disabled ?>/>
264
       <?php if (!$this->DisabledFlag) { ?>
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
         </input>
266
         </input>
268
         Coming Soon!<br />
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
       <?php } ?>
271
       <?php } ?>
271
     </td>
272
     </td>
272
   </tr>
273
   </tr>

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

1
 <?
1
 <?
2
+
3
+# Headers, cache, etc.
2
 $debug = false;
4
 $debug = false;
3
 
5
 
4
 if (empty($_GET['cn'])) {
6
 if (empty($_GET['cn'])) {
16
   json_die('success', $Cache->get_value('jav_fill_json_'.$cn));
18
   json_die('success', $Cache->get_value('jav_fill_json_'.$cn));
17
 } else {
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
   $jlib_jp_url = ('http://www.javlibrary.com/ja/vl_searchbyid.php?keyword='.$cn);
69
   $jlib_jp_url = ('http://www.javlibrary.com/ja/vl_searchbyid.php?keyword='.$cn);
20
   $jlib_en_url = ('http://www.javlibrary.com/en/vl_searchbyid.php?keyword='.$cn);
70
   $jlib_en_url = ('http://www.javlibrary.com/en/vl_searchbyid.php?keyword='.$cn);
21
   $jdb_url     = ('http://javdatabase.com/movies/'.$cn.'/');
71
   $jdb_url     = ('http://javdatabase.com/movies/'.$cn.'/');
141
       $image = 'https:'.$image;
191
       $image = 'https:'.$image;
142
     }
192
     }
143
     if (!$desc) {
193
     if (!$desc) {
144
-      //Shit neither of the sites have descriptions
194
+      // Shit neither of the sites have descriptions
145
       $desc = '';
195
       $desc = '';
146
     }
196
     }
147
   }
197
   }
179
   $Cache->cache_value('jav_fill_json_'.$cn, $json, 86400);
229
   $Cache->cache_value('jav_fill_json_'.$cn, $json, 86400);
180
 
230
 
181
   json_die('success', $json);
231
   json_die('success', $json);
182
-
232
+*/
183
 }
233
 }

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

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

Loading…
Cancel
Save