Widget:SandboxNew: Difference between revisions
Jump to navigation
Jump to search
Matt Pijoan (talk | contribs) No edit summary |
Matt Pijoan (talk | contribs) No edit summary |
||
(42 intermediate revisions by the same user not shown) | |||
Line 34: | Line 34: | ||
} | } | ||
</style> | </style> | ||
<script type="text/javascript"> | <script type="text/javascript"> | ||
var countdownTimer, countdownCurrent; | var countdownTimer, countdownCurrent; | ||
Line 88: | Line 87: | ||
} | } | ||
function loginCheck( | function loginCheck(exam) { | ||
var form = "<div id='Pat' class='noSelect WBRButton'><br />USMLE Format</div><div id='Flash' class='noSelect WBRButton'><br />Flash Cards</div>"; | |||
var form = " | $("#question").html(form); | ||
$(".WBRButton").click(function () { | |||
$(" | alert($(this).attr('id')); | ||
var form = "<div id='y' class='noSelect WBRButton'><br />Enable Timer</div><div id='n' class='noSelect WBRButton'><br />Disable Timer</div>"; | |||
var form = " | $("#question").html(form); | ||
$(".WBRButton").click(function () { | |||
$(" | alert($(this).attr('id')); | ||
if ($( | if ($(this).attr('id') === 'y') { | ||
var | var form = "<div id='1' class='noSelect WBRButton'><br />1 Minute</div><div id='10' class='noSelect WBRButton'><br />10 Minute</div><div id='20' class='noSelect WBRButton'><br />20 Minutes</div><div id='40' class='noSelect WBRButton'><br />40 Minutes</div>" | ||
$("#question").html(form); | |||
$(" | $(".WBRButton").click(function () { | ||
countdownCurrent = parseInt($( | alert($(this).parent.attr('id')); | ||
countdownCurrent = parseInt($(this).attr('id')) * 6000; | |||
examHandler( | examHandler(exam); | ||
}); | }); | ||
} else { | } else { | ||
examHandler( | examHandler(exam); | ||
} | } | ||
}); | }); | ||
Line 118: | Line 118: | ||
return str; | return str; | ||
} | } | ||
function examHandler( | function examHandler(exam) { | ||
if (exam === 'Queue') { | |||
queueExam(); | |||
} else { | |||
selectExam(exam); | selectExam(exam); | ||
} | } | ||
Line 158: | Line 156: | ||
}); | }); | ||
} | } | ||
function catQuestionCount(exam, type, cat){ | |||
var queryString = "[[ExamType::"+exam+"]] "; | |||
if(type === "m") { | |||
queryString += "[[MainCategory::"+cat+"]]"; | |||
} else { | |||
queryString += "[[SubCategory::"+cat+"]]"; | |||
} | |||
var api = new mw.Api(); | |||
api.get( { | |||
action: 'ask', | |||
query: queryString, | |||
format: 'json', | |||
async: false | |||
}, { | |||
ok: function (data) { | |||
$.each(data.query.results,function(index, value) { | |||
var count = parseInt(document.getElementById(cat).innerHTML); | |||
count = count+1; | |||
document.getElementById(cat).innerHTML = count.toString(); | |||
}); | |||
}});} | |||
function | function completeQuestionCount(exam, main, sub) { | ||
var queryString = "[[ExamType::" + exam + "]][[MainCategory::"; | var queryString = "http://wikidoc.org/index.php?title=Special:Ask&q=[[ExamType::" + urlSwapSpace(exam) + "]][[MainCategory::"; | ||
for (var j = 0; j < main.length; j++) { | for (var j = 0; j < main.length; j++) { | ||
queryString += main[j]; | queryString += urlSwapSpace(main[j]); | ||
if (j != main.length - 1) { | if (j != main.length - 1) { | ||
queryString += " | queryString += "||"; | ||
} | } | ||
} | } | ||
queryString += "]][[SubCategory::"; | queryString += "]][[SubCategory::"; | ||
for (var i = 0; i < sub.length; i++) { | for (var i = 0; i < sub.length; i++) { | ||
queryString += sub[i]; | queryString += urlSwapSpace(sub[i]); | ||
if (i != sub.length - 1) { | if (i != sub.length - 1) { | ||
queryString += " | queryString += "||"; | ||
} | } | ||
} | } | ||
queryString += "]]"; | queryString += "]]&eq=yes&p[format]=json"; | ||
$.get(queryString, function (data) { | |||
var obj = jQuery.parseJSON(data); | |||
$("#countShow").html(obj.rows.toString()); | |||
$.each(obj.results, function(index, value){ | |||
alert(value.fulltext); | |||
}); | |||
$("#numQues").removeAttr('disabled'); | |||
}); | |||
} | |||
function urlSwapSpace(swap){ | |||
return swap.split(' ').join('+'); | |||
} | } | ||
Line 202: | Line 223: | ||
$xml = $(xmlDoc), | $xml = $(xmlDoc), | ||
$title = $xml.find("text"); | $title = $xml.find("text"); | ||
if ($title.text().indexOf('Placeholder,') == -1) { | if ($title.text().indexOf('Placeholder,') ==r-1) { | ||
addNewSection("User:" + mw.user.name() + "/WBRQueue", 'Placeholder,', mw.user.tokens.get('editToken')); | addNewSection("User:" + mw.user.name() + "/WBRQueue", 'Placeholder,', mw.user.tokens.get('editToken')); | ||
alert('First Timah!'); | alert('First Timah!'); | ||
Line 242: | Line 263: | ||
categories['sub'] = new Array("Cardiology", "Dermatology", "Endocrine", "Gastrointestinal", "Genitourinary", "Head and Neck", "Hematology", "Musculoskeletal/Rheumatology", "Neurology", "Oncology", "Pulmonology", "Reproductive", "Renal", "Vascular", "General Principles", "Infectious Disease"); | categories['sub'] = new Array("Cardiology", "Dermatology", "Endocrine", "Gastrointestinal", "Genitourinary", "Head and Neck", "Hematology", "Musculoskeletal/Rheumatology", "Neurology", "Oncology", "Pulmonology", "Reproductive", "Renal", "Vascular", "General Principles", "Infectious Disease"); | ||
} else if (exam === "USMLE Step 2 CK") { | } else if (exam === "USMLE Step 2 CK") { | ||
categories['main'] = new Array(" | categories['main'] = new Array("Internal medicine", "Surgery", "OB/GYN", "Pediatrics", "Psychiatry"); | ||
categories['sub'] = new Array("Allergy/Immunology", "Cardiovascular", "Dermatology", "Endocrine", "Gastrointestinal", "Hepatology", "Genitourinary", " | categories['sub'] = new Array("Allergy/Immunology", "Cardiovascular", "Dermatology", "Endocrine", "Gastrointestinal", "Hepatology", "Genitourinary", "Head and Neck", "Hematology", "Infectious Disease", "Musculoskeletal/Rheumatology", "Neurology", "Obstetrics and Gynecology", "Oncology", "Ophthalmology", "Pediatrics", "Poisoning", "Preventive Medicine", "Psychiatry", "Respiratory", "Surgery", "Biostatistics/ Epidemiology", "Ethics", "Electrolytes", "Genetics", "Miscellaneous"); | ||
} else if (exam === "USMLE Step 3") { | } else if (exam === "USMLE Step 3") { | ||
categories['main'] = new Array("Community Medical Health Center", "Primary Care Office", "Inpatient Facilities", "Emergency Room"); | categories['main'] = new Array("Community Medical Health Center", "Primary Care Office", "Inpatient Facilities", "Emergency Room"); | ||
Line 259: | Line 280: | ||
if (categories['sub'].length >= categories['main'].length) { | if (categories['sub'].length >= categories['main'].length) { | ||
for (var i = 0; i < categories['sub'].length; i++) { | for (var i = 0; i < categories['sub'].length; i++) { | ||
catQuestionCount(exam,"s",categories['sub'][i]); | |||
if (categories['main'][i]) { | if (categories['main'][i]) { | ||
catQuestionCount(exam,"m",categories['main'][i]); | |||
table += "<tr><td><input type='checkbox' name='MainCat' value='" + categories['main'][i] + "' />" + categories['main'][i] + ":<span id='"+categories['main'][i]+"'>0</span></td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + ":<span id='"+categories['sub'][i]+"'>0</span></td></tr>"; | |||
} else { | } else { | ||
table += "<tr><td></td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + "</td></tr>"; | table += "<tr><td></td><td><input type='checkbox' name='SubCat' value='" + categories['sub'][i] + "' />" + categories['sub'][i] + ":<span id='"+categories['sub'][i]+"'>0</span></td></tr>"; | ||
} | } | ||
} | } | ||
Line 279: | Line 302: | ||
} | } | ||
Q.innerHTML += "<div id='SelectAll' class='noSelect WBRButton'>Select All Main Categories</div><div id='UnselectAll' class='noSelect WBRButton'>Select All Sub Categories</div><div id='CountQ' class='noSelect WBRButton'>Count Questions</div><br /><br /><br /><br /><b>Second: choose the number of questions you would like to answer. The maximum number of questions you can select is | Q.innerHTML += "<div id='SelectAll' class='noSelect WBRButton'>Select All Main Categories</div><div id='UnselectAll' class='noSelect WBRButton'>Select All Sub Categories</div><br /><br /><br />Second: Click the Count Question Button below to calculate number of questions available:<br /><br /><br /><div id='CountQ' class='noSelect WBRButton'>Count Questions</div><br /><br /><br /><br /><b>Second: choose the number of questions you would like to answer. The maximum number of questions you can select is <span id='countShow'></span>.</b><br /><br /><br />Number of questions:<input type='text' id='numQues' disabled /><br /><br /><div id='Go' class='noSelect WBRButton'>Click here to begin the exam</div>"; | ||
$("#Go").click(function () { | $("#Go").click(function () { | ||
if (countdownCurrent) { | if (countdownCurrent) { | ||
Line 312: | Line 335: | ||
}); | }); | ||
var numQues = $("#numQues").val(); | var numQues = $("#numQues").val(); | ||
var Q = document.getElementById('question'); | |||
Q.innerHTML = "Loading..."; | |||
var Questions = loadExam(exam, numQues, sSub, sMain).toString(); | var Questions = loadExam(exam, numQues, sSub, sMain).toString(); | ||
$("input[name='stash']").val(Questions); | $("input[name='stash']").val(Questions); | ||
Q.innerHTML = ""; | Q.innerHTML = ""; | ||
$('#home').css('visibility', 'visible'); | $('#home').css('visibility', 'visible'); | ||
Line 360: | Line 384: | ||
sSub.push($(this).val()); | sSub.push($(this).val()); | ||
}); | }); | ||
completeQuestionCount(exam, sMain, sSub); | |||
}); | }); | ||
} | } | ||
Line 678: | Line 702: | ||
<div id="question" style="visibility:hidden;"> | <div id="question" style="visibility:hidden;"> | ||
<b>Click here to start the exam:</b><br /> | <b>Click here to start the exam:</b><br /> | ||
<a href="#" onclick="loginCheck( | <a href="#" onclick="loginCheck('USMLE Step 1')"><img src="http://static.wikidoc.org/8/87/Step1.png" /></a> | ||
<a href="#" onclick="loginCheck( | <a href="#" onclick="loginCheck('USMLE Step 2 CK')"><img src="http://static.wikidoc.org/0/07/Step2CK.png" /></a> | ||
<a href="#" onclick="loginCheck( | <a href="#" onclick="loginCheck('USMLE Step 3')"><img src="http://static.wikidoc.org/0/08/Step3.png" /></a> | ||
<a href="#" onclick="loginCheck( | <a href="#" onclick="loginCheck('Board Review')"><img src="http://static.wikidoc.org/7/75/Boardcertification.png" /></a> | ||
<a href="#" onclick="loginCheck( | <a href="#" onclick="loginCheck('MCAT')"><img src="http://static.wikidoc.org/4/4b/MCAT.png" /></a><br /> | ||
<!-- bold + larger font size--> | <!-- bold + larger font size--> | ||
<b>Click here to repeat questions you've gotten wrong previously</b> | <b>Click here to repeat questions you've gotten wrong previously</b> | ||
<input type="button" onclick="loginCheck('Queue | <input type="button" onclick="loginCheck('Queue')" value="Review Exam" /><br /> | ||
</div> | </div> |