.
The Open Protein Structure Annotation Network
PDB Keyword
.

SearchPage

  • You do not have permissions to view this page - please try logging in.
Table of contents
No headers

 

 

dekiapi('0.2');
template('PubMed/Styles');

/**
 * Search form
 */
<form ctor="
        var timeout;
        var processing;

        // make sure the dialog has been initialized
        Popup.init({defaultKeyListeners: false});
        // remove default popup handlers
        if (Popup.removeDefaultEventHandler) {
                Popup.removeDefaultEventHandler();
        }

        when(#pubmedsubmit.click) {
                processing = true;
                #pubmedterm.addClass('loading');

                var query = Deki.$.trim(#pubmedterm.val());
                MindTouch.Deki.Reload('#pubmedresults', { term: query }, function() {
                        processing = false;
                        #pubmedterm.removeClass('loading');

                        if (query != Deki.$.trim(#pubmedterm.val()) ) {
                                #pubmedsubmit.click();
                        } else {
                                // hook clicks
                                #pubmedresults.find('li.pubmeditem').click(function() {
                                        // grab the pmid
                                        var pmid = $(this).find('.pmid').text();
                                        var title = $(this).find('.title').text();
                                        @pubmedsubmit({
                                                'pmid': pmid,
                                                'title': title
                                        });
                                });
                        }
                });
                return false;
        }

        when(#pubmedterm.keypress || (#pubmedterm.keydown && $event.keyCode == 8 /* backspace */)) { {
                        if (timeout) clearTimeout(timeout);

                if ($event.keyCode == 13) {
                        @pubmedsearch();
                        return false; // prevent default
                        } else {
                                timeout = setTimeout(function() { @pubmedsearch(); }, 1000);
                        }
        } }

        when(@pubmedsearch && !processing) { {
                var query = Deki.$.trim(#pubmedterm.val());
                if (query.length == 0 || query.length >= 3) {
                        #pubmedsubmit.click();
                }
        } }

        when(@pubmedsubmit) {
                        var PubMedDialogConfig = Popup.getParams();
                        // config comes from parent editor plugin
                        var pagePath = PubMedDialogConfig.pubmedArticlePath + @pubmedsubmit.pmid;
                        var templatePath = PubMedDialogConfig.pubmedArticleStubPath;

                // create the discussion stub if it doesn't exist
                // TODO: need to pass pmid to template
                var page_api = MindTouch.Plugin.PubMed.GetPageApi(Deki.Env.SiteApi, pagePath);
                var template_api = MindTouch.Plugin.PubMed.GetPageApi(Deki.Env.SiteApi, templatePath, {pmid: @pubmedsubmit.pmid});
                MindTouch.Plugin.PubMed.CreatePageFromTemplate(page_api, template_api,
                        function(xhr)
                        {
                                Popup.close(@pubmedsubmit);
                        },
                        function(error)
                        {
                                if (error.status == 409) {
                                        // page already created
                                        Popup.close(@pubmedsubmit);
                                } else if (error.status == 403) {
                                        alert('The reference cannot be inserted because a corresponding article page does not yet exist and could not be created.');
                                } else {
                                        alert('An error occurred trying to create the article at ' + pagePath + ' (status: ' + error.status + ' - ' + MindTouch.Web.GetStatusText(error.status) + ')');
                                }
                        }
                );
                return false;
        }

    " >
    // end ctor

        // search tools div
        <div id="pubmedsearchtools">
                // input search box
                <input id="pubmedterm" type="text" />

                // input button
                <input id="pubmedsubmit" type="submit" value="Search" />
                <span class="hint">"Enter a keyword, ISBN or PubMed number to search for references."</span>
        </div>
</form>

// this is the <div> that shows the results
<div id="pubmedresults">
    if(#__request.args.term > 0) {
        template('PubMed/ESearch', [__request.args.term, 15]);
    }
</div>

Reviews

References

 

No references found.

Tag page
  • No tags

Files (0)

 
You must login to post a comment.
All content on this site is licensed under a Creative Commons Attribution 3.0 License
Powered by MindTouch