-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit2.php
executable file
·66 lines (62 loc) · 1.88 KB
/
edit2.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
require_once "config.php";
header('Content-type: text/html');
if (!isset($_REQUEST['test'])) {
echo "No test specified!";
exit();
} else {
$test = $_REQUEST['test'];
if (!isTestNameValid($test) || !testExists($test)) {
echo "Not a valid tests.";
exit();
}
if (isset($_REQUEST["code"])) {
saveTestCode($test, $_REQUEST["code"]);
}
} ?>
<html>
<head>
<link rel="stylesheet" href="include/codemirror/css/codemirror.css">
<link rel="stylesheet" href="include/codemirror/css/night.css">
<style type="text/css">
.CodeMirror {
border: 1px solid #eee;
}
.CodeMirror-scroll {
height: auto;
overflow-y: hidden;
overflow-x: auto;
width: 100%;
}
</style>
<script type="text/javascript" charset="utf-8" src="js/jquery.min.js"></script>
<script type="text/javascript" charset="utf-8" src="include/codemirror/js/codemirror.js"></script>
<script type="text/javascript" charset="utf-8" src="include/codemirror/mode/haskell.js"></script>
</head>
<body>
<a href="/">All tests</a>
<form action="<?php echo $_SERVER["PHP_SELF"] ?>" method="post" onsubmit="return onSubmit();">
<input type="hidden" id="test" name="test" value="<?php echo $test; ?>" />
<input type="submit" value="Save" />
<textarea id="editor" name="code"><?php echo getTestCode ($test); ?></textarea>
</form>
<script>
jQuery(function() {
window.editor = CodeMirror.fromTextArea (document.getElementById('editor'), {
//value: "<?php // echo getTestCode ($test); ?>",
mode: "haskell",
theme: "night",
lineNumbers: true,
matchBrackets: true,
indentUnit: 2, // How many spaces a block (whatever that means in the edited language).
tabSize: 1 // The width of a tab character.
});
});
function onSubmit () {
// Copy the content of the editor into the textarea.
window.editor.save ();
return true;
}
</script>
</body>
</html>