diff options
author | Samy Pessé <samypesse@gmail.com> | 2014-03-31 13:59:49 -0700 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2014-03-31 13:59:51 -0700 |
commit | 82b99189b1358424a9c2a622351961caa35cb764 (patch) | |
tree | d3ee2ad8563be75fc1c27c15f19887675445c59b /templates/includes/book/exercise.html | |
parent | 3f7f5667e4cab4eeefa89878261274ca52bd2c27 (diff) | |
download | gitbook-82b99189b1358424a9c2a622351961caa35cb764.zip gitbook-82b99189b1358424a9c2a622351961caa35cb764.tar.gz gitbook-82b99189b1358424a9c2a622351961caa35cb764.tar.bz2 |
Add base display of exercise
Diffstat (limited to 'templates/includes/book/exercise.html')
-rw-r--r-- | templates/includes/book/exercise.html | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/templates/includes/book/exercise.html b/templates/includes/book/exercise.html new file mode 100644 index 0000000..b94e39e --- /dev/null +++ b/templates/includes/book/exercise.html @@ -0,0 +1,37 @@ +<div class="header"> + <h2>Exercise #{{ section.id }}</h2> +</div> +<div class="message"> + {% autoescape false %}{{ section.content }}{% endautoescape %} +</div> +<div class="editor" style="height: {{ section.content.split("\n").length*20 }};">{{ section.codes.base }}</div> + +<pre class="hidden code-solution">{{ section.codes.solution }}</pre> +<pre class="hidden code-validation">{{ section.codes.validation }}</pre> + +<div class="btn-group btn-group-justified"> + <a href="#" class="btn btn-default action-submit">Submit</a> + <a href="#" class="btn btn-default action-solution">Solution</a> + <a href="https://github.com/{{ githubId }}/issues/new" target="_blank" class="btn btn-default">Have a Question?</a> +</div> + +<script> +$(document).ready(function() { + var $exercise = $("#section-{{ section.id }}"); + + var editor = ace.edit($exercise.find(".editor").get(0)); + editor.setTheme("ace/theme/tomorrow"); + editor.getSession().setMode("ace/mode/javascript"); + + $exercise.find(".action-submit").click(function(e) { + e.preventDefault(); + + alert("submit"); + }); + $exercise.find(".action-solution").click(function(e) { + e.preventDefault(); + + editor.setValue($exercise.find(".code-solution").html()); + }); +}); +</script>
\ No newline at end of file |