From da15e439e64c8314825ad5f28073fbcbd436946f Mon Sep 17 00:00:00 2001 From: Gertjan van den Burg Date: Thu, 30 May 2019 13:29:31 +0100 Subject: Initial version of demo This commit introduces the demo functionality. The task assignment has been removed at the moment, as this will be changed in a future commit. --- app/static/annotate.css | 6 +- app/static/css/demo/evaluate.css | 57 +++++++++++++++ app/static/css/demo/learn.css | 11 +++ app/static/css/global.css | 3 + app/static/js/buttons.js | 39 ++++++----- app/static/js/makeChart.js | 146 +++++++++++++++++++++++++++++++++++++-- app/static/view_annotation.css | 3 +- 7 files changed, 238 insertions(+), 27 deletions(-) create mode 100644 app/static/css/demo/evaluate.css create mode 100644 app/static/css/demo/learn.css create mode 100644 app/static/css/global.css (limited to 'app/static') diff --git a/app/static/annotate.css b/app/static/annotate.css index 7dc222f..8079053 100644 --- a/app/static/annotate.css +++ b/app/static/annotate.css @@ -20,5 +20,9 @@ rect { } #rubric { - text-align: center; + text-align: left; + padding-bottom: 20px; + padding-top: 10px; + width: 80%; + font-size: 16px; } diff --git a/app/static/css/demo/evaluate.css b/app/static/css/demo/evaluate.css new file mode 100644 index 0000000..0c7dbc2 --- /dev/null +++ b/app/static/css/demo/evaluate.css @@ -0,0 +1,57 @@ +.graph-wrapper { + width: 90%; + margin: 0 auto; +} + +#graph_user > svg { + width: 100%; + height: 100%; +} + +#graph_true > svg { + width: 100%; + height: 100%; +} + +.line { + fill: none; + stroke: blue; + clip-path: url(#clip); +} + +circle { + clip-path: url(#clip); + fill: blue; +} + +rect { + fill: white; + opacity: 0; +} + +.marked { + fill: #fc8d62; + stroke: #fc8d62; +} + +#next-btn { + text-align: right; + padding-bottom: 20px; +} + +#lesson { + padding-top: 10px; + padding-bottom: 10px; +} + +#lesson p { + font-size: 16px; +} + +.ann-line { + stroke-dasharray: 5; + clip-path: url(#clip); + fill: #fc8d62; + stroke: #fc8d62; + stroke-width: 2px; +} diff --git a/app/static/css/demo/learn.css b/app/static/css/demo/learn.css new file mode 100644 index 0000000..13dccd2 --- /dev/null +++ b/app/static/css/demo/learn.css @@ -0,0 +1,11 @@ +#next-btn { + text-align: right; +} + +#lesson { + padding-top: 10px; +} + +#lesson p { + font-size: 16px; +} diff --git a/app/static/css/global.css b/app/static/css/global.css new file mode 100644 index 0000000..6258057 --- /dev/null +++ b/app/static/css/global.css @@ -0,0 +1,3 @@ +h1, h2, h3 { + margin-bottom: 20px; +} diff --git a/app/static/js/buttons.js b/app/static/js/buttons.js index d26a15d..75adad2 100644 --- a/app/static/js/buttons.js +++ b/app/static/js/buttons.js @@ -8,7 +8,7 @@ function resetOnClick() { updateTable(); } -function noCPOnClick(task_id) { +function noCPOnClick(identifier) { var changepoints = document.getElementsByClassName("changepoint"); // validation if (changepoints.length > 0) { @@ -16,27 +16,27 @@ function noCPOnClick(task_id) { return; } - var obj = { - task: task_id, - changepoints: null - }; + var obj = {} + obj["identifier"] = identifier; + obj["changepoints"] = null; var xhr = new XMLHttpRequest(); - xhr.open("POST", ""); + xhr.open("POST", "", false); xhr.withCredentials = true; xhr.setRequestHeader("Content-Type", "application/json"); - xhr.send(JSON.stringify(obj)); + /* Flask's return to this POST must be a URL, not a template!*/ xhr.onreadystatechange = function() { - if (xhr.readyState == XMLHttpRequest.DONE) { - if (xhr.status === 200) - window.location.href = xhr.responseText; + if (xhr.readyState == XMLHttpRequest.DONE && xhr.status == 200) { + window.location.href = xhr.responseText; + console.log("XHR Success: " + xhr.responseText); } else { - console.log("Error: " + xhr.status); + console.log("XHR Error: " + xhr.status); } - }; + } + xhr.send(JSON.stringify(obj)); } -function submitOnClick(task_id) { +function submitOnClick(identifier) { var changepoints = document.getElementsByClassName("changepoint"); // validation if (changepoints.length === 0) { @@ -45,7 +45,7 @@ function submitOnClick(task_id) { } var obj = {}; - obj["task"] = task_id; + obj["identifier"] = identifier; obj["changepoints"] = []; var i, cp; for (i=0; i