|
|
Line 1: |
Line 1: |
| <includeonly> | | <includeonly> |
| <script type = "text/javascript"> | | <script type = "text/javascript"> |
| function ensureLoggedIn() {
| | $(#prepend).val("{|class="wikitable sortable" cellpadding="5" !Drug Name !! Pill Imprint !! Dosage !! Ingredients !! Pill Color !! Pill Shape !! Pill Size (mm) !! Score !! NDC !! Pill Image |
| mw.loader.load('mediaWiki.user');
| | |-{{#ask:"); |
| if ($.isEmptyObject(wgUserName)) {
| | $(#pend).val([[Pill Shape::Round]] |
| alert("Please Log In To Continue.");
| | $(#append).val("|?Pill Imprint|?Pill Dosage|?Pill Ingred|?Pill Color|?Pill Shape|?Pill Size (mm)|?Pill Scoring |?NDC|?Pill Name|format=template|template=PillID}} |}" |
| window.location.replace("http://wikidoc.org/index.php?title=Special:UserLogin&returnto=LabelEditor");
| |
| } else {
| |
| createMicrochapter();
| |
| }
| |
| }
| |
| | |
| function createMicrochapter() {
| |
| $("#executeGo").click(function () {
| |
| microChapterData();
| |
| });
| |
| $("#checkContent").click(function () {
| |
| contentView();
| |
| });
| |
| 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?");
| |
| $('#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");
| |
| $("#prepend").val("{{TopOfDrugPage}} \n \n {{BlackBoxTemplate|blackBoxWarningTitle=");
| |
| $("#pend").val("|blackBoxWarningBody=");
| |
| $("#append").val("}}");
| |
| $("#instructions").html("These are some instructions");
| |
| } 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");
| |
| }
| |
| function contentView() {
| |
| alert($("#prepend").val() + $("#chapterContent").val() + $("#pend").val() + $("#chapterContent2").val() + $("#append").val());
| |
| }
| |
| }
| |
| $(document).ready(ensureLoggedIn);
| |
| </script> | | </script> |
| Page Title: <input type="text" id="drugName" /><br />
| |
| <div id="instructions">
| |
|
| |
| </div>
| |
| Microchapter: <select id="microChapter">
| |
| <option>Black Box Warning</option>
| |
| <option>Adult Indications and Dosage</option>
| |
| <option>Contraindications</option>
| |
| <option>Warnings</option>
| |
| <option>Adverse Reactions</option>
| |
| <option>Drug Interactions</option>
| |
| <option>Use In Specific Populations</option>
| |
| <option>Routes and Preparations</option>
| |
| <option>IV Compatibility</option>
| |
| <option>Overdosage</option>
| |
| <option>Pharmacology</option>
| |
| <option>Clinical Studies</option>
| |
| <option>How Supplied</option>
| |
| <option>Images</option>
| |
| <option>Patient Information</option>
| |
| <option>Combined Alcohol Use</option>
| |
| <option>Look-Alike Drug Names</option>
| |
| <option>Drug Shortage Status</option>
| |
| <option>Price</option>
| |
| </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="executeGo" value="Go" /> |
| <input type="button" id="skip" value="Skip" />
| |
| <input type="button" id="checkContent" value="Check" />
| |
| <input type="hidden" id="prepend" /> | | <input type="hidden" id="prepend" /> |
| <input type="hidden" id="pend" /> | | <input type="hidden" id="pend" /> |
| <input type="hidden" id="append" /> | | <input type="hidden" id="append" /> |
| </includeonly> | | </includeonly> |