Widget:CJP: Difference between revisions

Jump to navigation Jump to search
Christopher Popma (talk | contribs)
No edit summary
Christopher Popma (talk | contribs)
No edit summary
 
(27 intermediate revisions by the same user not shown)
Line 1: Line 1:
<includeonly>
<includeonly>
<script type="text/javascript">
<script type = "text/javascript">
function ensureLoggedIn() {
$(document).ready(function() {
mw.loader.load('mediaWiki.user');
    $('#pillTable').css('visibility','hidden');
if ($.isEmptyObject(wgUserName)) {
    $('#executeGo').click(function() {
alert("Please Log In To Continue.");
        $('#searchParameters').append('<string>[[Pill Shape::</string>'+$('#selectPillShape option:selected').val() +'<string>]]</string>');
window.location.replace("http://wikidoc.org/index.php?title=Special:UserLogin&returnto=LabelEditor");
        $('#pillTable').css('visibility','visible');
} else {
createMicrochapter();
}
}


function createMicrochapter() {
        var api = new mw.Api();
$("#executeGo").click(function () {
            api.parse( $('#pillTable') )
microChapterData();
            .done( function ( html ) {
});
        console.log( 'Parsed result:', html );
function createPage() {
            } );
var chapterText = $("#chapterContent").val();
    });
var api = new mw.Api();
    $('#executeReset').click(function() {
api.post({
        $('#searchParameters').empty();
action : 'edit',
        $('#pillTable').css('visibility','hidden');
token : mw.user.tokens.get('editToken'),
    });
text : chapterText,
});
title : $("#drugName").val() + "/" + $("#microChapter").val(),
format : 'json'
})
.always(function (data) {
alert("Great success?");
$('option:selected', 'select').removeAttr('selected').next('option').attr('selected', 'selected');
microChapterData();
});
}
function createSection() {
var chapterText = $("#chapterContent").val();
var api = new mw.Api();
api.post({
action : 'edit',
token : mw.user.tokens.get('editToken'),
text : chapterText,
title : $("#drugName").val() + "/" + $("#microChapter").val(),
format : 'json'
})
.always(function (data) {
alert("Great success?");
$('#microChapter option:selected').removeAttr('selected').next('option').attr('selected', 'selected');
microChapterData();
});
}
function microChapterData(){
 
if ($('#microChapter option:selected').text() === "Black Box Warning") {
resetForm();
$("#chapterContent2").css("visibility", "visible");
} else if ($('#microChapter option:selected').text() === "Adult Indications and Dosage") {
resetForm();
if ($('#headings option').length == 0) {
addHeading(["FDA-Labeled Indications and Dosage Information (Adults)", "Off-Label Use and Dosage (Adults)"]);
                                microChapterData();
$("#instructions").html("These are some instructions");
} else if ($('#headings option:selected').text() === "FDA-Labeled Indications and Dosage Information (Adults)") {
alert("Hi");
                        $('#headings option:selected').removeAttr('selected').next('option').attr('selected', 'selected');
} else if ($('#headings option:selected').text() === "Off-Label Use and Dosage (Adults)") {
alert("Clear!");
resetForm();
}
} else if ($('#microChapter option:selected').text() === "Contraindications") {
alert("Passed.");
}
}
function clearHeading() {
$('#headings option').each(function () {
$(this).remove();
});
$("#headingDiv").css("visibility", "hidden");
}
function addHeading(headings) {
$("#headingDiv").css("visibility", "visible");
$.each(headings, function (key, value) {
$('#headings').append("<option>" + value + "</option>");
});
}
function resetForm() {
$("#instructions").html(" ");
$("#chapterContent").val(" ");
$("#chapterContent2").val(" ");
$("#prepend").val(" ");
$("#pend").val(" ");
$("#append").val(" ");
$("#chapterContent2").css("visibility", "hidden");
$("#headingDiv").css("visibility", "hidden");
}
}
$(document).ready(ensureLoggedIn);
</script>
</script>
Page Title: <input type="text" id="drugName" /><br />
Pill Shape: <select id="selectPillShape">
<div id="instructions">
                    <option>Round</option>
 
                    <option>Oval</option>
</div>
                    <option>Capsule</option>
Microchapter: <select id="microChapter">
                </select><br />
<option>Black Box Warning</option>
<input type="button" id="executeGo" value="Go" />
<option>Adult Indications and Dosage</option>
<input type="button" id="executeReset" value="Reset" />
<option>Contraindications</option>
<div id="pillTable" style="width:500px;">
<option>Warnings</option>
    {|class="wikitable sortable" cellpadding="5"
<option>Adverse Reactions</option>
    !Drug Name !! Pill Imprint !! Dosage !! Ingredients !! Pill Color !! Pill Shape !! Pill Size (mm) !! Score !! NDC !! Pill Image<br/>
<option>Drug Interactions</option>
    |- <br/>
<option>Use In Specific Populations</option>
    {{#ask:<string id="searchParameters"></string><br/>
<option>Routes and Preparations</option>
    |?Pill Imprint<br/>
<option>IV Compatibility</option>
    |?Pill Dosage<br/>
<option>Overdosage</option>
    |?Pill Ingred<br/>
<option>Pharmacology</option>
    |?Pill Color<br/>
<option>Clinical Studies</option>
    |?Pill Shape<br/>
<option>How Supplied</option>
    |?Pill Size (mm)<br/>
<option>Images</option>
    |?Pill Scoring<br/>
<option>Patient Information</option>
    |?NDC<br/>
<option>Combined Alcohol Use</option>
    |?Pill Name<br/>
<option>Look-Alike Drug Names</option>
    |format=template<br/>
<option>Drug Shortage Status</option>
    |template=PillID}}<br/>
<option>Price</option>
    |}
</select><br />
</div>
<div id="headingDiv" style="visibility:hidden;">
Sub Headings: <select id="headings">
 
</select>
</div><br />
 
<div id="content1">
Content:<textarea id="chapterContent"></textarea>
</div>
<div id="content2" style="visibility:hidden;">
Content:<textarea id="chapterContent2"></textarea><br />
</div>
<input type="button" id="executeGo" value="Go" />
<input type="button" id="skip" value="Skip" />
<input type="hidden" id="prepend" />
<input type="hidden" id="pend" />
<input type="hidden" id="append" />
</includeonly>
</includeonly>

Latest revision as of 13:36, 29 May 2014