Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
trs
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Taddeüs Kroes
trs
Commits
216b5019
Commit
216b5019
authored
Apr 24, 2012
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implemented frontend logic for 'step' and 'answer'.
parent
feb84e0e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
82 additions
and
11 deletions
+82
-11
src/frontend/js/editor.js
src/frontend/js/editor.js
+82
-11
No files found.
src/frontend/js/editor.js
View file @
216b5019
...
@@ -108,13 +108,14 @@
...
@@ -108,13 +108,14 @@
})(
math_lines
,
real_lines
));
})(
math_lines
,
real_lines
));
}
}
setInterval
(
function
()
{
window
.
update_math
=
function
()
{
if
(
trigger_update
)
{
if
(
trigger_update
)
{
trigger_update
=
false
;
trigger_update
=
false
;
//update_math(input_box.getValue());
update_math
(
input_textarea
.
val
());
update_math
(
input_textarea
.
val
());
}
}
},
100
);
};
setInterval
(
window
.
update_math
,
100
);
});
});
var
loader
=
$
(
'
#loader
'
);
var
loader
=
$
(
'
#loader
'
);
...
@@ -127,23 +128,96 @@
...
@@ -127,23 +128,96 @@
loader
.
hide
();
loader
.
hide
();
};
};
window
.
append_hint
=
function
(
hint
)
{
$
(
'
#math div
'
).
last
().
filter
(
'
.hint
'
).
remove
();
var
elem
=
$
(
'
<div class=hint/>
'
);
elem
.
text
(
hint
);
$
(
'
#math
'
).
append
(
elem
);
};
window
.
append_input
=
function
(
input
)
{
input_textarea
.
val
(
input_textarea
.
val
()
+
'
\n
'
+
input
);
};
window
.
answer_input
=
function
()
{
show_loader
();
// TODO: disable input box and enable it when this ajax request is done
// (on failure and success).
$
.
post
(
'
/answer
'
,
{
data
:
input_textarea
.
val
()},
function
(
response
)
{
if
(
!
response
)
return
;
if
(
'
steps
'
in
response
)
{
for
(
i
=
0
;
i
<
response
.
steps
.
length
;
i
++
)
{
cur
=
response
.
steps
[
i
];
if
(
'
step
'
in
cur
)
window
.
append_input
(
cur
.
step
);
if
(
'
hint
'
in
cur
)
window
.
append_hint
(
cur
.
hint
);
trigger_update
=
true
;
window
.
update_math
();
}
}
if
(
'
hint
'
in
response
)
window
.
append_hint
(
response
.
hint
);
input_textarea
.
focus
();
hide_loader
();
},
'
json
'
).
error
(
function
(
e
)
{
console
.
log
(
'
error:
'
,
e
);
hide_loader
();
});
};
window
.
hint_input
=
function
()
{
window
.
hint_input
=
function
()
{
show_loader
();
show_loader
();
// TODO: disable input box and enable it when this ajax request is done
// TODO: disable input box and enable it when this ajax request is done
// (on failure and success).
// (on failure and success).
//$.post('/hint', {data: input_box.getValue()}, function(response) {
$
.
post
(
'
/hint
'
,
{
data
:
input_textarea
.
val
()},
function
(
response
)
{
$
.
post
(
'
/hint
'
,
{
data
:
input_textarea
.
val
()},
function
(
response
)
{
if
(
!
response
)
if
(
!
response
)
return
;
return
;
window
.
append_hint
(
response
.
hint
);
input_textarea
.
focus
();
hide_loader
();
},
'
json
'
).
error
(
function
(
e
)
{
console
.
log
(
'
error:
'
,
e
);
hide_loader
();
});
};
window
.
step_input
=
function
()
{
show_loader
();
// TODO: disable input box and enable it when this ajax request is done
// (on failure and success).
$
.
post
(
'
/step
'
,
{
data
:
input_textarea
.
val
()},
function
(
response
)
{
if
(
!
response
)
return
;
console
.
log
(
response
);
console
.
log
(
response
);
$
(
'
#math div
'
).
last
().
filter
(
'
.hint
'
).
remove
();
if
(
'
step
'
in
response
)
{
window
.
append_input
(
response
.
step
);
trigger_update
=
true
;
}
var
elem
=
$
(
'
<div class=hint/>
'
);
if
(
'
hint
'
in
response
)
elem
.
text
(
response
.
hint
);
window
.
append_hint
(
response
.
hint
);
$
(
'
#math
'
).
append
(
elem
);
input_textarea
.
focus
();
hide_loader
();
hide_loader
();
},
'
json
'
).
error
(
function
(
e
)
{
},
'
json
'
).
error
(
function
(
e
)
{
...
@@ -158,7 +232,6 @@
...
@@ -158,7 +232,6 @@
// TODO: disable input box and enable it when this ajax request is done
// TODO: disable input box and enable it when this ajax request is done
// (on failure and success).
// (on failure and success).
//$.post('/validate', {data: input_box.getValue()}, function(response) {
$
.
post
(
'
/validate
'
,
{
data
:
input_textarea
.
val
()},
function
(
response
)
{
$
.
post
(
'
/validate
'
,
{
data
:
input_textarea
.
val
()},
function
(
response
)
{
if
(
!
response
)
if
(
!
response
)
return
;
return
;
...
@@ -166,8 +239,6 @@
...
@@ -166,8 +239,6 @@
var
math_container
=
$
(
'
#math
'
),
var
math_container
=
$
(
'
#math
'
),
math_lines
=
math_container
.
find
(
'
div.box
'
);
math_lines
=
math_container
.
find
(
'
div.box
'
);
console
.
log
(
response
.
validated
);
var
i
=
0
;
var
i
=
0
;
// Mark every line as correct (and remove previous class names).
// Mark every line as correct (and remove previous class names).
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment