Widget:CJP2: Difference between revisions
Jump to navigation
Jump to search
Created page with "<includeonly> <script type = "text/javascript"> $(document).ready(function() { $('#pillTable').css('visibility','hidden'); $('#executeGo').click(function() { ..." |
No edit summary |
||
Line 1: | Line 1: | ||
<includeonly> | <includeonly> | ||
<script type="text/javascript"> | |||
var api = new mw.Api(); | |||
api.get({ | |||
action : 'ask', | |||
query : '[[Pill Shape::Oval]]|?Pill Imprint|?Pill Dosage|?Pill Ingred|?Pill Color|?Pill Shape|?Pill Size (mm)|?Pill Scoring|?NDC|?Pill Name', | |||
format : 'json' | |||
}) | |||
}); | .always(function (data) { | ||
$.each(data.query.results, function (index, value) { | |||
/*Assign variables the values returned from the function*/ | |||
var drugNameFull = value.fulltext; | |||
var drugNameShort = drugNameLong.split("#")[0]; | |||
var pillImprint = value.printouts["Pill Imprint"]; | |||
var pillDosage = value.printouts["Pill Dosage"]; | |||
var pillIngred = value.printouts["Pill Ingred"]; | |||
var pillColor = value.printouts["Pill Color"]; | |||
var pillShape = value.printouts["Pill Shape"]; | |||
var pillSize = value.printouts["Pill Size (mm)"]; | |||
var pillScoring = value.printouts["Pill Scoring"]; | |||
var ndc = value.printouts["NDC"]; | |||
var pillName = value.printouts["Pill Name"]; | |||
/*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>'; | |||
/*Append the new row with the information.*/ | |||
$('#resultsTable-body').append(newRow); | |||
}); | |||
}); | |||
</script> | </script> | ||
<div id="resultsTable-container"> | |||
<table id="resultsTable"> | |||
<thead> | |||
<th> | |||
</ | Drug Name | ||
</th> | |||
<th> | |||
Pill Imprint | |||
</th> | |||
<th> | |||
Dosage | |||
</th> | |||
<th> | |||
Ingredients | |||
</th> | |||
<th> | |||
Pill Color | |||
</th> | |||
<th> | |||
Pill Shape | |||
</th> | |||
<th> | |||
Pill Size (mm) | |||
</th> | |||
<th> | |||
Score | |||
</th> | |||
<th> | |||
NDC | |||
</th> | |||
<th> | |||
Pill Image | |||
</th> | |||
</thead> | |||
<tbody id="resultsTable-body"> | |||
</tbody> | |||
</table> | |||
</div> | |||
</includeonly> | </includeonly> |