Widget:CJP2: Difference between revisions

Jump to navigation Jump to search
Christopher Popma (talk | contribs)
No edit summary
Christopher Popma (talk | contribs)
No edit summary
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>
<includeonly>
<script type="text/javascript">
<script type="text/javascript">
var api = new mw.Api();
$(document).ready(function() {
api.get({
mw.loader.load('mediawiki.Api', function() {
action : 'ask',
var api = new mw.Api();
query : '[[Pill Shape::Oval]]|?Pill Imprint|?Pill Dosage|?Pill Ingred|?Pill Color|?Pill Shape|?Pill Size (mm)|?Pill Scoring|?NDC|?Pill Name',
api.get({
format : 'json'
action : 'ask',
})
query : '[[Pill Shape::Oval]]|?Pill Imprint|?Pill Dosage|?Pill Ingred|?Pill Color|?Pill Shape|?Pill Size (mm)|?Pill Scoring|?NDC|?Pill Name',
.always(function (data) {
format : 'json'
$.each(data.query.results, function (index, value) {
},function(data) {alert("Data: " + data);});
//Assign variables the values returned from the function//
                /*.always(function (data) {
var drugNameFull = value.fulltext;
$.each(data.query.results, function (index, value) {
var drugNameShort = drugNameLong.split("#")[0];
//Assign variables the values returned from the function//
var pillImprint = value.printouts["Pill Imprint"];
var drugNameFull = value.fulltext;
var pillDosage = value.printouts["Pill Dosage"];
var drugNameShort = drugNameLong.split("#")[0];
var pillIngred = value.printouts["Pill Ingred"];
var pillImprint = value.printouts["Pill Imprint"];
var pillColor = value.printouts["Pill Color"];
var pillDosage = value.printouts["Pill Dosage"];
var pillShape = value.printouts["Pill Shape"];
var pillIngred = value.printouts["Pill Ingred"];
var pillSize = value.printouts["Pill Size (mm)"];
var pillColor = value.printouts["Pill Color"];
var pillScoring = value.printouts["Pill Scoring"];
var pillShape = value.printouts["Pill Shape"];
var ndc = value.printouts["NDC"];
var pillSize = value.printouts["Pill Size (mm)"];
var pillName = value.printouts["Pill Name"];
var pillScoring = value.printouts["Pill Scoring"];
                        //Find a <table> element with id="resultsTable-body":
var ndc = value.printouts["NDC"];
                        var table = document.getElementById("resultsTable-body");
var pillName = value.printouts["Pill Name"];
//Find a <table> element with id="resultsTable-body":
var 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:
                        var row = table.insertRow(index);
var row = table.insertRow(index);


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






//Create a variable containing the HTML to be appended to the end of the table//
//Create a variable containing the HTML to be appended to the end of the table//
//var newRow = '<tr> <td>' + drugNameShort + '</td> <td>' + pillImprint + '</td> <td>' + pillDosage + '</td> <td>' + pillIngred + '</td> <td>' + pillColor + '</td> <td>' + pillShape + '</td> <td>' + pillSize + '</td> <td>' + ndc + '</td> <td>' + pillName + '</td> </tr>';
var newRow = '<tr> <td>' + drugNameShort + '</td> <td>' + pillImprint + '</td> <td>' + pillDosage + '</td> <td>' + pillIngred + '</td> <td>' + pillColor + '</td> <td>' + pillShape + '</td> <td>' + pillSize + '</td> <td>' + ndc + '</td> <td>' + pillName + '</td> </tr>';
/*Append the new row with the information.*/
//Append the new row with the information.//
$('#resultsTable-body').append(newRow);//
$('#resultsTable-body').innerHTML(newRow);
});
});
});
});*/  
});
});  
</script>
</script>
<div id="resultsTable-container">
<div id="resultsTable-container">

Latest revision as of 13:06, 3 June 2014