-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathtable-pico.js
More file actions
87 lines (85 loc) · 5.29 KB
/
table-pico.js
File metadata and controls
87 lines (85 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
$( document ).ajaxComplete(function() {
//Background-color of cells
});
$(document).ready(function(){
$("#header_pico").html("<p>Included trials, starting with the oldest trials.</p><table><caption>Randomized controlled trials of this topic</caption><tbody><tr><th width=\'180px\'>Trial</th><th>Patients</th><th>Intervention</th><th>Comparison</th><th>Outcome</th><th style='width:7px;background-color:white;border: 1px solid white'></th></tr></table>");
var url = "/" + repo_dir + "/tables/pico.xml";
$.ajax({
type: "GET",
url: url,
cache: false,
dataType: "xml",
error: function() {
alert("The XML File," + url + ", could not be processed correctly.");
},
success: function(xml) {
$(xml).find('study').each(function(){
var citationtext = $(this).find('citation').text() + ', ' + $(this).find("citation").attr("year") + '<br>' + $(this).find("citation").attr("journal_abbrev") + "<br>"
if ( $(this).find('citation').attr('pmid')){
if ( $(this).find('citation').attr('pmid').length > 4){
citationtext += "PMID: <a href='http://pubmed.gov/" + $(this).find('citation').attr('pmid') + "'>" + $(this).find('citation').attr('pmid') + "</a><br>"
}
}
if ( $(this).find('citation').attr('trialregistration')){
if ( $(this).find('citation').attr('trialregistration').toLowerCase().indexOf("nct") >= 0){
citationtext += "<a href='https://clinicaltrials.gov/ct2/show/study/" + $(this).find('citation').attr('trialregistration') + "'>" + $(this).find('citation').attr('trialregistration') + "</a><br>"
}
if ( $(this).find('citation').attr('trialregistration').toLowerCase().indexOf("isrctn") >= 0){
citationtext += "<a href='http://www.isrctn.com/" + $(this).find('citation').attr('trialregistration') + "'>" + $(this).find('citation').attr('trialregistration') + "</a><br>"
}
if ( $(this).find('citation').attr('trialregistration').toLowerCase().indexOf("actrn") >= 0){
citationtext += "<a href='http://www.anzctr.org.au/TrialSearch.aspx?searchTxt=" + $(this).find('citation').attr('trialregistration') + "'>" + $(this).find('citation').attr('trialregistration') + "</a><br>"
}
}
var patients = $(this).find('patients').attr('total') + ' subjects with ' + $(this).find('patients').find('description').text();
$(this).find('patients').find('bullet').each(function(){
patients += '<br>• ' + $(this).text()
})
var intervention = '';
$(this).find('intervention').find('bullet').each(function(){
intervention += '<br>• ' + $(this).text()
})
intervention = $(this).find('intervention').find('bullet').remove().end().html() + intervention
var comparison = '';
$(this).find('comparison').find('bullet').each(function(){
comparison += '<br>• ' + $(this).text()
})
comparison = $(this).find('comparison').find('bullet').remove().end().text() + comparison
var outcome = 'Primary:';
$(this).find('outcome').each(function(){
$(this).find("bullet[type='primary']").each(function(){
if ( $(this).attr('url'))
{outcome += "<br>• <a href=\"" + $(this).attr('url') + " \">" + $(this).text() + '</a>'}
else
{outcome += '<br>• ' + $(this).text()}
})
if ($(this).find("bullet[type='secondary']").length) {
outcome += '<br>Secondary:';
$(this).find("bullet[type='secondary']").each(function(){
if ( $(this).attr('url'))
{outcome += "<br>• <a href=\"" + $(this).attr('url') + " \">" + $(this).text() + '</a>'}
else
{outcome += '<br>• ' + $(this).text()}
})
}
})
var pmid= $(this).find('citation').attr('pmid');
var trHTML = '<tr><td width=\'180px\'>' + citationtext + '</td><td>' + patients + '</td><td>' + intervention + '</td><td>' + comparison + '</td><td>' + outcome + '</td></tr>';
//PubMed links
regex = /(\s{1,})(\d{7,})/ig; //from http://jsfiddle.net/badgettrg/60482cbh/
trHTML = trHTML.replace(regex, "$1<a href='http://pubmed.gov/$2'>$2</a>");
//Highlight emphasis
regex = /\*{2}(.+)\*{2}/ig;
trHTML = trHTML.replace(regex, "<span style='background-color:yellow;font-weight:bold;font-style:italic'>$1</span>");
$('#citations').append(trHTML);
})
}
});
//Write footer
//Reuse
$("#business-pico").append("<div style='text-align:center'><a href='https://github.com/openMetaAnalysis/openMetaAnalysis.github.io/blob/master/reusing.MD'>Cite & use this content</a></div>")
//Edit and history
$("#business-pico").append("<div style='text-align:center'>Source content: <a href='/" + repo_dir + "/tables/pico.xml'>view</a> - <a href='https://github.com/openMetaAnalysis/" + repo_dir + "/commits/gh-pages/tables/pico.xml'>history</a> - <a href='https://github.com/openMetaAnalysis/" + repo_dir + "/blob/gh-pages/tables/pico.xml'>edit</a> - <a id='xmlhelp' class='hastip' href='#'>help with editting</a> (Hint: use <a href=\"https://kobra.io\">Kobra</a> for collaborative editing)</div>")
//Issues and comments
$("#business-pico").append("<div style='text-align:center'><a href='https://github.com/openMetaAnalysis/" + repo_dir + "/issues?q=is%3Aopen+is%3Aissue'>Issues and comments</a></div>")
});