Start
This commit is contained in:
@@ -0,0 +1,126 @@
|
||||
var dwvapp = [];
|
||||
|
||||
var marked_answers = {
|
||||
"correct": [],
|
||||
"half-correct": [],
|
||||
"incorrect": [],
|
||||
}
|
||||
|
||||
|
||||
$(document).ready(function () {
|
||||
$(".answer-list li").each(function (index, element) {
|
||||
console.log(element);
|
||||
$(element).click(function (e) {
|
||||
|
||||
var classes = ['correct', 'half-correct', 'incorrect'];
|
||||
$(element).each(function () {
|
||||
this.className = classes[($.inArray(this.className, classes) + 1) % classes.length];
|
||||
});
|
||||
|
||||
prepAnswerData();
|
||||
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
prepAnswerData();
|
||||
|
||||
if($(".post-form").length > 0) {
|
||||
$(".post-form").get(0).addEventListener("submit", function (e) {
|
||||
if($(".not-marked").length > 0) {
|
||||
e.preventDefault(); // before the code
|
||||
alert("Ensure all answers are marked first");
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
if($(".dwv-container").length) {
|
||||
$(".dwv-container").append($('<!-- DWV --> <div id="dwv"> <!-- Toolbar --> <div class="toolbar"></div> <input type="range" id="sliceRange" value="0"><!-- Layer Container --> <div class="layerContainer"> <div class="dropBox"></div> <canvas class="imageLayer">Only for HTML5 compatible browsers...</canvas> <div class="infoLayer"> <div class="infotl"></div> <div class="infotc"></div> <div class="infotr"></div> <div class="infocl"></div> <div class="infocr"></div> <div class="infobl"></div> <div class="infobc"></div> <div class="infobr" style="bottom: 64px;"></div></div></div><!-- /layerContainer --> <!-- /dwv -->'));
|
||||
|
||||
var app = new dwv.App();
|
||||
dwvapp = app;
|
||||
//DEBUG
|
||||
var listenerWL = function (event) {
|
||||
console.log("event: " + event.type);
|
||||
console.log(event);
|
||||
$(".infotc").text(event.wc);
|
||||
};
|
||||
app.addEventListener("wl-width-change", listenerWL);
|
||||
//app.addEventListener("wl-center-change", listener);
|
||||
app.init({
|
||||
|
||||
"containerDivId": "dwv",
|
||||
"fitToWindow": true,
|
||||
"isMobile": true,
|
||||
"gui": ["tool"],
|
||||
"filters": ["Threshold", "Sharpen", "Sobel"],
|
||||
"tools": ["Scroll", "WindowLevel", "ZoomAndPan"], // or try "ZoomAndPan"
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
var range = document.getElementById("sliceRange");
|
||||
range.min = 0;
|
||||
app.addEventListener("load-end", function () {
|
||||
range.max = app.getImage().getGeometry().getSize().getNumberOfSlices() - 1;
|
||||
|
||||
if(range.max == 0) {
|
||||
$(range).hide();
|
||||
}
|
||||
});
|
||||
app.addEventListener("slice-change", function () {
|
||||
range.value = app.getViewController().getCurrentPosition().k;
|
||||
});
|
||||
range.oninput = function () {
|
||||
var pos = app.getViewController().getCurrentPosition();
|
||||
pos.k = this.value;
|
||||
app.getViewController().setCurrentPosition(pos);
|
||||
}
|
||||
|
||||
try {
|
||||
app.loadURLs([$(".dwv-container").data("url")]);
|
||||
} catch(error) {
|
||||
toastr.error(error.message);
|
||||
|
||||
}
|
||||
dwv.gui.appendResetHtml(app);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
function prepAnswerData() {
|
||||
//$("#id_correct").val($("li.correct").map(function() {
|
||||
// ans = $(this).text();
|
||||
// window.marked_answers["correct"].push(ans);
|
||||
// return ans
|
||||
//}).get().join('--//--'));
|
||||
//$("#id_half_correct").val($("li.half-correct").map(function() {
|
||||
// ans = $(this).text();
|
||||
// window.marked_answers["half-correct"].push(ans);
|
||||
// return ans;
|
||||
//}).get().join('--//--'));
|
||||
//$("#id_incorrect").val($("li.incorrect").map(function() {
|
||||
// ans = $(this).text();
|
||||
// window.marked_answers["incorrect"].push(ans);
|
||||
// return ans;
|
||||
//}).get().join('--//--'));
|
||||
|
||||
window.marked_answers["correct"] = [];
|
||||
window.marked_answers["half-correct"] = [];
|
||||
window.marked_answers["incorrect"] = [];
|
||||
$("li.correct").map(function () {
|
||||
ans = $(this).text();
|
||||
window.marked_answers["correct"].push(ans);
|
||||
})
|
||||
$("li.half-correct").map(function () {
|
||||
ans = $(this).text();
|
||||
window.marked_answers["half-correct"].push(ans);
|
||||
})
|
||||
$("li.incorrect").map(function () {
|
||||
ans = $(this).text();
|
||||
window.marked_answers["incorrect"].push(ans);
|
||||
})
|
||||
$("#id_marked_answers").val(JSON.stringify(window.marked_answers));
|
||||
}
|
||||
Reference in New Issue
Block a user