Changeset 7412

Show
Ignore:
Timestamp:
03/12/09 16:17:43 (17 months ago)
Author:
josowski
Message:

Updates, changes and improvements to related articles linking logic.

References #1115

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • head/ambra/webapp/src/main/webapp/javascript/init_related.js

    r7343 r7412  
    3838  dojo.fadeOut({ node:'relatedArticlesSpinner', duration: 1000 }).play(); 
    3939   
    40   if(response == null) 
     40  if (response == null) 
    4141  { 
    4242    setError('pubMedRelatedErr'); 
     
    4646  var pubMedID = 0; 
    4747   
    48   if(response.article.pub_med) { 
     48  if (response.article.pub_med) { 
    4949    pubMedID = response.article.pub_med; 
    5050    dojo.byId('pubMedRelatedURL').href="http://www.ncbi.nlm.nih.gov/sites/entrez?Db=pubmed&DbFrom=pubmed&Cmd=Link&LinkName=pubmed_pubmed&LinkReadableName=Related%20Articles&IdsFromResult=" + pubMedID + "&ordinalpos=1&itool=EntrezSystem2.PEntrez.Pubmed.Pubmed_ResultsPanel.Pubmed_RVCitation"; 
     
    5858  dojo.fadeOut({ node:'relatedCitesSpinner', duration: 1000 }).play(); 
    5959 
    60   if(response == null) 
     60  if (response == null) 
    6161  { 
    6262    setError('relatedCites'); 
     
    6464  } 
    6565 
    66   if(response.article.sources.length > 0) { 
     66  var numCitesRendered = 0; 
     67  var doi = escape(dojo.byId('doi').value); 
     68 
     69  if (response.article.sources.length > 0) { 
    6770    var html = "<ul>"; 
    6871 
    6972    for(var a = 0; a < response.article.sources.length; a++) 
    7073    { 
    71       html = html + "<li><a href=\"\">" + response.article.sources[a].source + "(" + response.article.sources[a].count + ")</a></li>"; 
     74      var url = ""; 
     75 
     76      /** 
     77       * TODO: We really want to have the ALM server set these sources 
     78       * In the meantime we'll set them here. 
     79       * 
     80       * I figure we'll append a DOI to these urls with the right parameter name 
     81       * Or perhaps append an ID given to us from the ALM server? 
     82       * 
     83       * Nulling out any of the following values should stop the 
     84       * item from being displayed.  
     85      */ 
     86      switch (response.article.sources[a].source) { 
     87        case "CrossRef": 
     88            //Example of what it would like like to pass the doi to the website 
     89            url = "http://www.crossref.org/?paramName=" + doi; //+ response.article.sources[a].source.someID 
     90            //Example of what it would like if we got a response from the ALM server 
     91            //url = "http://www.crossref.org/?paramName=" + response.article.sources[a].source.someID; 
     92            //Example of null: 
     93            //url = null; 
     94          break; 
     95        case "PubMed": 
     96            url = "http://www.ncbi.nlm.nih.gov/pubmed/?paramName="; //+ doi (the article DOI) 
     97          break; 
     98        case "Scopus": 
     99            url = "http://www.scopus.com/scopus/home.url?paramName="; 
     100          break; 
     101        case "Citeulike": 
     102            url = "http://www.citeulike.org/?paramName="; 
     103          break; 
     104      } 
     105 
     106      //Only list links that HAVE DEFINED URLS 
     107      if (url) { 
     108        html = html + "<li><a href=\"" + url + "\">" + response.article.sources[a].source + "(" + response.article.sources[a].count + ")</a></li>"; 
     109        numCitesRendered++; 
     110      } 
    72111    } 
    73112     
    74113    html = html + "</ul>" 
    75   } else { 
     114  } 
     115 
     116  if (numCitesRendered == 0){ 
    76117    html = "<ul><li>No related cites found</li></ul>"; 
    77118  } 
     
    88129  dojo.fadeOut({ node:'relatedBlogSpinner', duration: 1000 }).play(); 
    89130 
    90   if(response == null) 
     131  if (response == null) 
    91132  { 
    92133    setError('relatedBlogPosts'); 
     
    94135  } 
    95136 
    96   if(response.article.sources.length > 0) { 
     137  var numBlogsRendered = 0; 
     138  var doi = escape(dojo.byId('doi').value); 
     139 
     140  if (response.article.sources.length > 0) { 
    97141    html = "<ul>"; 
    98142 
    99143    for(var a = 0; a < response.article.sources.length; a++) 
    100144    { 
    101       html = html + "<li><a href=\"\">" + response.article.sources[a].source + "(" + response.article.sources[a].count + ")</a></li>"; 
     145      var url = ""; 
     146 
     147      /** 
     148       * TODO: We really want to have the ALM server set these sources 
     149       * In the meantime we'll set them here. 
     150       * 
     151       * I figure we'll append a DOI to these urls with the right parameter name 
     152       * Or perhaps append an ID given to us from the ALM server? 
     153       * 
     154       * Nulling out any of the following values should stop the 
     155       * item from being displayed. 
     156      */ 
     157      switch(response.article.sources[a].source) { 
     158        case "Bloglines": 
     159            url = "http://www.crossref.org/?paramName=" + doi; 
     160            //url = "http://www.crossref.org/?paramName=" + response.article.sources[a].source.someID; 
     161          break; 
     162        case "Nature": 
     163            url = "http://www.nature.com/?paramName="; 
     164          break; 
     165        case "Postgenomic": 
     166            url = "http://www.postgenomic.com/?paramName="; 
     167          break; 
     168      } 
     169 
     170      //Only list links that HAVE DEFINED URLS 
     171      if (url) { 
     172        html = html + "<li><a href=\"" + url + "\">" + response.article.sources[a].source + "(" + response.article.sources[a].count + ")</a></li>"; 
     173        numBlogsRendered++; 
     174      } 
    102175    } 
    103176 
    104177    html = html + "</ul>" 
    105   } else { 
     178  } else 
     179 
     180  if (numBlogsRendered == 0) { 
    106181    html = "<ul><li>No related blog enrties found</li></ul>";  
    107182  }