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
46fe96ac
Commit
46fe96ac
authored
May 24, 2012
by
Sander Mathijs van Veen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix removal of outdated hint messages.
parent
6162dccc
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
32 deletions
+40
-32
src/frontend/js/editor.js
src/frontend/js/editor.js
+40
-32
No files found.
src/frontend/js/editor.js
View file @
46fe96ac
...
...
@@ -21,8 +21,18 @@
var
parts
=
tex
.
split
(
'
\n
'
);
var
math_container
=
$
(
'
#math
'
),
math_lines
=
math_container
.
find
(
'
div.box script
'
),
mathjax_instances
=
MathJax
.
Hub
.
getAllJax
(
'
math
'
);
math_lines
=
math_container
.
find
(
'
div.box script
'
);
// Select all mathjax instances which are inside a div.box element
var
mathjax_instances
=
[];
var
all_instances
=
MathJax
.
Hub
.
getAllJax
(
'
math
'
);
for
(
var
i
=
0
;
i
<
all_instances
.
length
;
i
++
)
{
var
elem
=
all_instances
[
i
];
if
(
$
(
'
#
'
+
elem
.
inputID
).
parent
().
hasClass
(
'
box
'
))
mathjax_instances
.
push
(
elem
);
}
var
real_lines
=
0
,
updated_line
=
-
1
;
...
...
@@ -31,9 +41,8 @@
if
(
!
parts
[
p
])
continue
;
// TODO: Mark updated line as "pending" (e.g. remove "wrong"
// and "good" class names from element).
// Check if we want to update an existing line or append the
// line.
if
(
real_lines
<
math_lines
.
length
)
{
var
elem
=
mathjax_instances
[
real_lines
];
...
...
@@ -62,32 +71,33 @@
real_lines
++
;
}
QUEUE
.
Push
(
function
()
{
// Remove out-dated mathematical lines.
for
(
var
p
=
real_lines
;
p
<
math_lines
.
length
;
p
++
)
$
(
math_lines
[
p
].
parentNode
).
remove
();
// Remove old hints, given that at least one line is updated.
// Iterate over the DOM nodes until the updated line is found,
// and remove all following hint nodes.
var
line_count
=
0
,
i
=
0
,
elems
=
$
(
'
#math div
'
);
// and remove all following hint nodes. Note that if there is
// no line updated, all hints not directly following the last
// line are removed.
var
elems
=
$
(
'
#math div
'
);
if
(
updated_line
==
-
1
)
updated_line
=
real_lines
+
1
;
updated_line
=
real_lines
;
for
(
;
i
<
elems
.
length
;
i
++
)
{
for
(
var
i
=
0
,
lines
=
0
,
hints
=
0
;
i
<
elems
.
length
;
i
++
)
{
var
elem
=
$
(
elems
[
i
]);
if
(
line_count
=
=
updated_line
)
{
if
(
lines
>
updated_line
||
hints
>
=
updated_line
)
{
if
(
elem
.
hasClass
(
'
hint
'
))
elem
.
remove
();
}
else
if
(
elem
.
hasClass
(
'
box
'
))
{
line_count
++
;
}
}
QUEUE
.
Push
((
function
(
math_lines
,
real_lines
)
{
return
function
()
{
for
(
var
p
=
real_lines
;
p
<
math_lines
.
length
;
p
++
)
{
$
(
math_lines
[
p
].
parentNode
).
remove
();
}
else
if
(
elem
.
hasClass
(
'
hint
'
))
hints
++
;
else
if
(
elem
.
hasClass
(
'
box
'
))
lines
++
;
}
};
})(
math_lines
,
real_lines
));
});
}
window
.
update_math
=
function
()
{
...
...
@@ -190,8 +200,6 @@
if
(
!
response
)
return
;
console
.
log
(
response
);
if
(
'
step
'
in
response
)
{
window
.
append_input
(
response
.
step
);
trigger_update
=
true
;
...
...
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