* fix: eslint operator-linebreak issue * fix: eslint quotes issue * fix: react jsx indent and props issues * fix: eslint trailing spaces issues * fix: eslint line around directives issue * fix: eslint semi rule * fix: eslint newline per chain rule * fix: eslint space infix ops rule * fix: eslint space-in-parens issue * fix: eslint space before function paren issue * fix: eslint space before blocks issue * fix: eslint arrow body style issue * fix: eslint dot-location issue * fix: eslint quotes issue * fix: eslint quote props issue * fix: eslint operator assignment issue * fix: eslint new line after import issue * fix: indent issues * fix: operator assignment issue * fix: all autofixable eslint issues * fix: all react related fixable issues * fix: autofixable eslint issues * chore: remove all template literals * fix: remaining autofixable issues * chore: apply amnesty on all existing issues * fix: failing xss-lint issues * refactor: apply amnesty on remaining issues * refactor: apply amnesty on new issues * fix: remove file level suppressions * refactor: apply amnesty on new issues
86 lines
3.1 KiB
JavaScript
86 lines
3.1 KiB
JavaScript
(function() {
|
|
var timeout = 1000;
|
|
|
|
waitForProtex();
|
|
|
|
function waitForProtex() {
|
|
if (typeof protex !== 'undefined' && protex) {
|
|
protex.onInjectionDone('protex');
|
|
// eslint-disable-next-line brace-style
|
|
}
|
|
/* if (typeof(protex) !== "undefined") {
|
|
//initializeProtex();
|
|
} */
|
|
else {
|
|
setTimeout(function() { waitForProtex(); }, timeout);
|
|
}
|
|
}
|
|
|
|
// NOTE:
|
|
// Protex uses three global functions:
|
|
// protexSetTargetShape (exported from GWT)
|
|
// exported protexCheckAnswer (exported from GWT)
|
|
// It calls protexIsReady with a deferred command when it has finished
|
|
// initialization and has drawn itself
|
|
|
|
function updateProtexField() {
|
|
var problem = $('#protex_container').parents('.problem');
|
|
var input_field = problem.find('input[type=hidden]');
|
|
var protex_answer = protexCheckAnswer();
|
|
var value = {protex_answer: protex_answer};
|
|
// console.log(JSON.stringify(value));
|
|
input_field.val(JSON.stringify(value));
|
|
}
|
|
|
|
protexIsReady = function() {
|
|
// Load target shape
|
|
var target_shape = $('#target_shape').val();
|
|
protexSetTargetShape(target_shape);
|
|
|
|
// Get answer from protex and store it into the hidden input field
|
|
// when Check button is clicked
|
|
var $fold_button = $('#fold-button');
|
|
$fold_button.on('click', function() {
|
|
var problem = $('#protex_container').parents('.problem');
|
|
var input_field = problem.find('input[type=hidden]');
|
|
var protex_answer = protexCheckAnswer();
|
|
var value = {protex_answer: protex_answer};
|
|
// console.log(JSON.stringify(value));
|
|
input_field.val(JSON.stringify(value));
|
|
});
|
|
updateProtexField();
|
|
};
|
|
|
|
/* function initializeProtex() {
|
|
//Check to see if the two exported GWT functions protexSetTargetShape
|
|
// and protexCheckAnswer have been appended to global scope -- this
|
|
//happens at the end of onModuleLoad() in GWT
|
|
if (typeof(protexSetTargetShape) === "function" &&
|
|
typeof(protexCheckAnswer) === "function") {
|
|
|
|
//Load target shape
|
|
var target_shape = $('#target_shape').val();
|
|
//protexSetTargetShape(target_shape);
|
|
|
|
//Get answer from protex and store it into the hidden input field
|
|
//when Check button is clicked
|
|
var problem = $('#protex_container').parents('.problem');
|
|
var check_button = problem.find('input.check');
|
|
var input_field = problem.find('input[type=hidden]');
|
|
check_button.on('click', function() {
|
|
var protex_answer = protexCheckAnswer();
|
|
var value = {protex_answer: protex_answer};
|
|
input_field.val(JSON.stringify(value));
|
|
});
|
|
|
|
//TO DO: Fix this, it works but is utterly ugly and unreliable
|
|
setTimeout(function() {
|
|
protexSetTargetShape(target_shape);}, 2000);
|
|
|
|
}
|
|
else {
|
|
setTimeout(function() {initializeProtex(); }, timeout);
|
|
}
|
|
} */
|
|
}).call(this);
|