Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
T
trs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Taddeüs Kroes
trs
Commits
46fe96ac
Commit
46fe96ac
authored
12 years ago
by
Sander Mathijs van Veen
Browse files
Options
Downloads
Patches
Plain Diff
Fix removal of outdated hint messages.
parent
6162dccc
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/frontend/js/editor.js
+40
-32
40 additions, 32 deletions
src/frontend/js/editor.js
with
40 additions
and
32 deletions
src/frontend/js/editor.js
+
40
−
32
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
++
;
}
// 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
'
);
if
(
updated_line
==
-
1
)
updated_line
=
real_lines
+
1
;
for
(;
i
<
elems
.
length
;
i
++
)
{
var
elem
=
$
(
elems
[
i
]);
if
(
line_count
==
updated_line
)
{
if
(
elem
.
hasClass
(
'
hint
'
))
elem
.
remove
();
}
else
if
(
elem
.
hasClass
(
'
box
'
))
{
line_count
++
;
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. 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
;
for
(
var
i
=
0
,
lines
=
0
,
hints
=
0
;
i
<
elems
.
length
;
i
++
)
{
var
elem
=
$
(
elems
[
i
]);
if
(
lines
>
updated_line
||
hints
>=
updated_line
)
{
if
(
elem
.
hasClass
(
'
hint
'
))
elem
.
remove
();
}
else
if
(
elem
.
hasClass
(
'
hint
'
))
hints
++
;
else
if
(
elem
.
hasClass
(
'
box
'
))
lines
++
;
}
}
QUEUE
.
Push
((
function
(
math_lines
,
real_lines
)
{
return
function
()
{
for
(
var
p
=
real_lines
;
p
<
math_lines
.
length
;
p
++
)
{
$
(
math_lines
[
p
].
parentNode
).
remove
();
}
};
})(
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
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment