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
 
(30 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 ) {
        contentView();
        console.log( 'Parsed result:', html );
            } );
     });
     });
     $("#skip").click(function () {
     $('#executeReset').click(function() {
         //$('option:selected', 'select').removeAttr('selected').next('option').attr('selected', 'selected');
         $('#searchParameters').empty();
        $('#pillTable').css('visibility','hidden');
     });
     });
    function createPage() {
});
        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?");
            $('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?");
            $('option:selected', 'select').removeAttr('selected').next('option').attr('selected', 'selected');
            microChapterData();
        });
    }
    function microChapterData() {
        if ($('option:selected', 'select').val() === "Black Box Warning") {
            $("#prepend").val("{{TopOfDrugPage}} \n \n {{BlackBoxTemplate|blackBoxWarningTitle=");
            $("pend").val("|blackBoxWarningBody=");
            $("#append").val("}}");
            $("#instructions").html("These are some instructions");
        } else if ($('option:selected', 'select').val() === "Chapter 2") {
            $("#prepend").val("Added Text to the Beginning");
            $("#pend").val("Added Text to the Middle");
            $("#append").val("Added Text to the End");
            $("#instructions").html("These are some instructions");
            $("#chapterContent2").css("visibility", "visible");
        }
    }
    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() {
        console.log($("#microChapter"));
        $("#instructions").html(" ");
        $("#chapterContent").val(" ");
        $("#chapterContent2").val(" ");
        $("#prepend").val(" ");
        $("#pend").val(" ");
        $("#append").val(" ");
        $("#chapterContent2").css("visibility", "hidden");
        $("#headingDiv").css("visibility", "hidden");
    }
    function contentView() {
        alert($("#prepend").val() + " " + $("#chapterContent").val());
    }
}
$(document).ready(ensureLoggedIn);
</script>
</script>
 
Pill Shape: <select id="selectPillShape">
Page Title: <input type="text" id="drugName" /><br />
                    <option>Round</option>
<div id="instructions">
                    <option>Oval</option>
 
                    <option>Capsule</option>
</div>
                </select><br />
Microchapter: <select id="microChapter">
<input type="button" id="executeGo" value="Go" />
<option>Black Box Warning</option>
<input type="button" id="executeReset" value="Reset" />
<option>Adult Indications and Dosage</option>
<div id="pillTable" style="width:500px;">
<option>Contraindications</option>
    {|class="wikitable sortable" cellpadding="5"
<option>Warnings</option>
    !Drug Name !! Pill Imprint !! Dosage !! Ingredients !! Pill Color !! Pill Shape !! Pill Size (mm) !! Score !! NDC !! Pill Image<br/>
<option>Adverse Reactions</option>
    |- <br/>
<option>Drug Interactions</option>
    {{#ask:<string id="searchParameters"></string><br/>
<option>Use In Specific Populations</option>
    |?Pill Imprint<br/>
<option>Routes and Preparations</option>
    |?Pill Dosage<br/>
<option>IV Compatibility</option>
    |?Pill Ingred<br/>
<option>Overdosage</option>
    |?Pill Color<br/>
<option>Pharmacology</option>
    |?Pill Shape<br/>
<option>Clinical Studies</option>
    |?Pill Size (mm)<br/>
<option>How Supplied</option>
    |?Pill Scoring<br/>
<option>Images</option>
    |?NDC<br/>
<option>Patient Information</option>
    |?Pill Name<br/>
<option>Combined Alcohol Use</option>
    |format=template<br/>
<option>Look-Alike Drug Names</option>
    |template=PillID}}<br/>
<option>Drug Shortage Status</option>
    |}
<option>Price</option>
</div>
</select><br />
<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