diff options
-rw-r--r-- | uploader/templates/publications/create-publication.html | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/uploader/templates/publications/create-publication.html b/uploader/templates/publications/create-publication.html index 4ddff0a..1961b4e 100644 --- a/uploader/templates/publications/create-publication.html +++ b/uploader/templates/publications/create-publication.html @@ -25,9 +25,13 @@ name="pubmed-id" class="form-control"/> <div class="input-group-text"> - <button class="btn btn-outline-primary">search</button> + <button class="btn btn-outline-primary" + id="btn-search-pubmed-id">search</button> </div> </div> + <span id="search-pubmed-id-error" + class="form-text text-muted text-danger visually-hidden"> + </span> <span class="form-text text-muted">This is the publication's ID on <a href="https://pubmed.ncbi.nlm.nih.gov/" title="Link to NCBI's PubMed service">NCBI's Pubmed Service</a> @@ -163,7 +167,25 @@ {%block javascript%} +<script type="text/javascript" src="/static/js/pubmed.js"></script> <script type="text/javascript"> - $(function() {}); + $(function() { + $("#btn-search-pubmed-id").on("click", (event) => { + event.preventDefault(); + var search_button = event.target; + var pubmed_id = $("#txt-pubmed-id").val().trim(); + remove_class($("#txt-pubmed-id").parent(), "has-error"); + if(pubmed_id == "") { + add_class($("#txt-pubmed-id").parent(), "has-error"); + return false; + } + + search_button.disabled = true; + // Fetch publication details + fetch_publication_details(pubmed_id, + [() => {search_button.disabled = false;}]); + return false; + }); + }); </script> {%endblock%} |