--- a/testappproj/templates/code.html Mon May 31 19:18:57 2010 +0530
+++ b/testappproj/templates/code.html Mon Jun 14 01:00:59 2010 +0530
@@ -1,8 +1,37 @@
{# {%extends "base.html"%} #}
+<script type="text/javascript">
+function run_code(params){
+
+if (window.XMLHttpRequest)
+ {// code for IE7+, Firefox, Chrome, Opera, Safari
+
+ xmlhttp=new XMLHttpRequest();
+ }
+else
+ {// code for IE6, IE5
+ xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
+ }
+xmlhttp.onreadystatechange=function()
+ {
+ if (xmlhttp.readyState==4 && xmlhttp.status==200)
+ {
+ document.getElementById("code_form").innerHTML=xmlhttp.responseText;
+ }
+ }
+xmlhttp.open("POST","/run/",true);
+xmlhttp.send(params);
+}
+function process_form(element) {
+
+ var poststr = "user_code=" + encodeURI( document.getElementById("code-area").value ) +
+ "&problem_id=" + encodeURI( document.getElementById("problem_id").value );
+ run_code(poststr);
+ }
+
+</script>
{%block body%}
<h2>{{ problem.name }}</h2>
-
{% comment %}
{% load pykata_extras %}
{% autoescape off %}
@@ -12,21 +41,19 @@
{% endautoescape %}
{% endcomment %}
-<h3>Examples</h3>
<pre>
{{ problem.examples }}
</pre>
-
- <form method="post" action="/run/">
+ <div id="code_form">
+ <form method="post" action="javascript:process_form(document.getElementById('code_form'));">
<p><strong>Enter your solution here:</strong></p>
<p><textarea id="code-area" name="user_code" rows="22" cols="80">
{% ifequal pu.classname "ProblemUser" %}{{ pu.solution }}{% else %}{{ problem.skeleton }}{% endifequal %}
-
</textarea></p>
- <input type="hidden" name="problem_id" value="{{ problem.id }}" />
- <p><input type="submit" name="submit" value="Run" /></p>
+ <input id="problem_id" type="hidden" name="problem_id" value="{{ problem.id }}" />
+ <p><input type="submit" name="submit" value="Done" ></p>
</form>
-
+</div>
<script language="javascript" type="text/javascript" src="/static/edit_area_full.js"></script>
<script language="javascript" type="text/javascript">
editAreaLoader.init({
@@ -34,9 +61,10 @@
syntax: "python",
start_highlight: true,
allow_resize: "both",
+ cursor_position: "begin",
font_size: 14,
toolbar: "new_document, select_font, |, help",
replace_tab_by_spaces: 4
});
</script>
-{%endblock%}
+ {%endblock%}