Widget:CJP3: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
Line 8: | Line 8: | ||
if ($.isEmptyObject(wgUserName)) { | if ($.isEmptyObject(wgUserName)) { | ||
alert("Please Log In To Continue."); | alert("Please Log In To Continue."); | ||
window.location.replace("http://www.wikidoc.org/index.php?title=Special:UserLogin&returnto= | window.location.replace("http://www.wikidoc.org/index.php?title=Special:UserLogin&returnto=WikidocBoardReview"); | ||
} else { | } else { | ||
alert("You are logged in"); | alert("You are logged in"); | ||
Line 17: | Line 17: | ||
function runQuery() { | function runQuery() { | ||
$('#button').click(function() { | $('#button').click(function() { | ||
var jsonURL = "http://www.wikidoc.org/api.php?action=ask&query=[[Pill%20Shape::Oval]]|?Pill%20Imprint|?Pill%20Dosage|?Pill%20Ingred|?Pill%20Color|?Pill%20Shape|?Pill%20Size%20(mm)|?Pill%20Scoring|?NDC|?Pill%20Name&format=json" | |||
$.getJSON(jsonURL, function (data) { | |||
$.each(data.query.results, function(ind, val) { | |||
drugNameFull = val.fulltext; | |||
drugNameShort = drugNameFull.split("#")[0]; | |||
pillImprint = val.printouts["Pill Imprint"]; | |||
pillDosage = val.printouts["Pill Dosage"]; | |||
pillIngred = val.printouts["Pill Ingred"]; | |||
pillColor = val.printouts["Pill Color"]; | |||
pillShape = val.printouts["Pill Shape"]; | |||
pillSize = val.printouts["Pill Size (mm)"]; | |||
pillScoring = val.printouts["Pill Scoring"]; | |||
ndc = val.printouts["NDC"]; | |||
pillName = val.printouts["Pill Name"]; | |||
//Find a <table> element with id="resultsTable-body": | |||
table = document.getElementById("resultsTable-body"); | |||
//Create an empty <tr> element and add it to the 1st position of the table: | |||
row = table.insertRow(ind); | |||
//Insert new cells(<td> elements) into the "new" <tr> element: | |||
cellDrugName = row.insertCell(0); | |||
cellPillImprint = row.insertCell(1); | |||
cellPillDosage = row.insertCell(2); | |||
cellPillIngred = row.insertCell(3); | |||
cellPillColor = row.insertCell(4); | |||
cellPillShape = row.insertCell(5); | |||
cellPillSize = row.insertCell(6); | |||
cellPillSocring = row.insertCell(7); | |||
cellNDC = row.insertCell(8); | |||
cellPillName = row.insertCell(9); | |||
//Add Values to the cells: | //Add Values to the cells: | ||
cellDrugName.innerHTML = drugNameShort ; | |||
cellPillImprint.innerHTML = pillImprint; | |||
cellPillDosage.innerHTML = pillDosage; | |||
cellPillIngred.innerHTML = pillIngred; | |||
cellPillColor.innerHTML = pillColor; | |||
cellPillShape.innerHTML = pillShape; | |||
cellPillSize.innerHTML = pillSize; | |||
cellPillSocring.innerHTML = pillScoring; | |||
cellNDC.innerHTML = ndc; | |||
cellPillName.innerHTML = "[[file:" + pillName + "|thumb|300px]]"; | |||
}); | }); | ||
}); | |||
}); | }); | ||
}; | }; |