Widget:CJP3: Difference between revisions

Jump to navigation Jump to search
Christopher Popma (talk | contribs)
No edit summary
Christopher Popma (talk | contribs)
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=User:Christopher_Popma/Sandbox_TestCJP3");
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"
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) {
$.getJSON(jsonURL, function (data) {
                                        $.each(data.query.results, function(ind, val) {
$.each(data.query.results, function(ind, val) {
                                          drugNameFull = val.fulltext;
drugNameFull = val.fulltext;
                                          drugNameShort = drugNameFull.split("#")[0];
drugNameShort = drugNameFull.split("#")[0];
                                          pillImprint = val.printouts["Pill Imprint"];
pillImprint = val.printouts["Pill Imprint"];
                                          pillDosage = val.printouts["Pill Dosage"];
pillDosage = val.printouts["Pill Dosage"];
                                          pillIngred = val.printouts["Pill Ingred"];
pillIngred = val.printouts["Pill Ingred"];
                                          pillColor = val.printouts["Pill Color"];
pillColor = val.printouts["Pill Color"];
                                          pillShape = val.printouts["Pill Shape"];
pillShape = val.printouts["Pill Shape"];
                                          pillSize = val.printouts["Pill Size (mm)"];
pillSize = val.printouts["Pill Size (mm)"];
                                          pillScoring = val.printouts["Pill Scoring"];
pillScoring = val.printouts["Pill Scoring"];
                                          ndc = val.printouts["NDC"];
ndc = val.printouts["NDC"];
                                          pillName = val.printouts["Pill Name"];
pillName = val.printouts["Pill Name"];


//Find a <table> element with id="resultsTable-body":
//Find a <table> element with id="resultsTable-body":
                                          table = document.getElementById("resultsTable-body");
table = document.getElementById("resultsTable-body");


//Create an empty <tr> element and add it to the 1st position of the table:
//Create an empty <tr> element and add it to the 1st position of the table:
  row = table.insertRow(ind);
row = table.insertRow(ind);


//Insert new cells(<td> elements) into the "new" <tr> element:
//Insert new cells(<td> elements) into the "new" <tr> element:
  cellDrugName = row.insertCell(0);
cellDrugName = row.insertCell(0);
  cellPillImprint = row.insertCell(1);
cellPillImprint = row.insertCell(1);
  cellPillDosage = row.insertCell(2);
cellPillDosage = row.insertCell(2);
  cellPillIngred = row.insertCell(3);
cellPillIngred = row.insertCell(3);
  cellPillColor = row.insertCell(4);
cellPillColor = row.insertCell(4);
  cellPillShape = row.insertCell(5);
cellPillShape = row.insertCell(5);
  cellPillSize = row.insertCell(6);
cellPillSize = row.insertCell(6);
  cellPillSocring = row.insertCell(7);
cellPillSocring = row.insertCell(7);
  cellNDC = row.insertCell(8);
cellNDC = row.insertCell(8);
  cellPillName = row.insertCell(9);
cellPillName = row.insertCell(9);


//Add Values to the cells:
//Add Values to the cells:
  cellDrugName.innerHTML = drugNameShort ;
cellDrugName.innerHTML = drugNameShort ;
  cellPillImprint.innerHTML = pillImprint;
cellPillImprint.innerHTML = pillImprint;
  cellPillDosage.innerHTML = pillDosage;
cellPillDosage.innerHTML = pillDosage;
  cellPillIngred.innerHTML = pillIngred;
cellPillIngred.innerHTML = pillIngred;
  cellPillColor.innerHTML = pillColor;
cellPillColor.innerHTML = pillColor;
  cellPillShape.innerHTML = pillShape;
cellPillShape.innerHTML = pillShape;
  cellPillSize.innerHTML = pillSize;
cellPillSize.innerHTML = pillSize;
  cellPillSocring.innerHTML = pillScoring;
cellPillSocring.innerHTML = pillScoring;
  cellNDC.innerHTML = ndc;
cellNDC.innerHTML = ndc;
  cellPillName.innerHTML = pillName;
cellPillName.innerHTML = "[[file:" + pillName + "|thumb|300px]]";
                                        });
});
});
});
});
});
};
};

Revision as of 20:27, 3 June 2014