Widget:CJP2: Difference between revisions

Jump to navigation Jump to search
Christopher Popma (talk | contribs)
Created page with "<includeonly> <script type = "text/javascript"> $(document).ready(function() { $('#pillTable').css('visibility','hidden'); $('#executeGo').click(function() { ..."
 
Christopher Popma (talk | contribs)
No edit summary
Line 1: Line 1:
<includeonly>
<includeonly>
<script type = "text/javascript">
$(document).ready(function() {
    $('#pillTable').css('visibility','hidden');
    $('#executeGo').click(function() {
        var api = new mw.Api();
            api.parse( $('#pillTable') )
            .done( function ( html ) {
        console.log( 'Parsed result:', html );
            } );


        $('#pillTable').css('visibility','visible');
<script type="text/javascript">
 
var api = new mw.Api();
    });
api.get({
    $('#executeReset').click(function() {
action : 'ask',
        $('#searchParameters').empty();
query : '[[Pill Shape::Oval]]|?Pill Imprint|?Pill Dosage|?Pill Ingred|?Pill Color|?Pill Shape|?Pill Size (mm)|?Pill Scoring|?NDC|?Pill Name',
        $('#pillTable').css('visibility','hidden');
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>
Pill Shape: <select id="selectPillShape">
<div id="resultsTable-container">
                    <option>Round</option>
    <table id="resultsTable">
                    <option>Oval</option>
        <thead>
                    <option>Capsule</option>
            <th>
                 </select><br />
                Drug Name
<input type="button" id="executeGo" value="Go" />
                </th>
<div id="pillTable" style="width:500px;">
               
    '''Hello World'''
                <th>
</div>
                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>

Revision as of 18:39, 30 May 2014