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
68cc841d
Commit
68cc841d
authored
Nov 19, 2012
by
Taddeüs Kroes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Code cleanup + error message improvement + autofocus on input area
parent
b847b423
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
13 deletions
+21
-13
src/frontend/js/editor.js
src/frontend/js/editor.js
+21
-13
No files found.
src/frontend/js/editor.js
View file @
68cc841d
...
@@ -36,6 +36,10 @@
...
@@ -36,6 +36,10 @@
input_textarea
.
focus
();
input_textarea
.
focus
();
});
});
// Put cursor at end of textarea
var
old_val
=
input_textarea
.
val
();
input_textarea
.
val
(
''
).
focus
().
val
(
old_val
);
var
STATUS_FAILURE
=
0
,
var
STATUS_FAILURE
=
0
,
STATUS_NOPROGRESS
=
1
,
STATUS_NOPROGRESS
=
1
,
STATUS_SUCCESS
=
2
,
STATUS_SUCCESS
=
2
,
...
@@ -200,35 +204,37 @@
...
@@ -200,35 +204,37 @@
var
error
=
$
(
'
#error
'
),
var
error
=
$
(
'
#error
'
),
loader
=
$
(
'
#loader
'
);
loader
=
$
(
'
#loader
'
);
error
.
find
(
'
.close
'
).
click
(
function
()
{
error
.
hide
();
});
function
report_error
(
e
)
{
function
report_error
(
e
)
{
error
.
show
().
find
(
'
.text
'
).
text
(
e
.
error
);
var
msg
=
e
.
error
;
if
(
'
statusText
'
in
e
)
msg
=
e
.
status
+
'
'
+
e
.
statusText
;
error
.
show
().
find
(
'
.text
'
).
text
(
msg
);
if
(
console
&&
console
.
log
)
if
(
console
&&
console
.
log
)
console
.
log
(
'
error:
'
,
e
);
console
.
log
(
'
error:
'
,
e
);
loader
.
hide
();
hide_loader
();
}
;
}
function
clear_error
()
{
function
clear_error
()
{
error
.
hide
();
error
.
hide
();
};
}
error
.
find
(
'
.close
'
).
click
(
clear_error
);
var
pending_request
=
false
;
var
pending_request
=
false
;
function
show_loader
()
{
function
show_loader
()
{
pending_request
=
true
;
pending_request
=
true
;
loader
.
css
(
'
visibility
'
,
'
visible
'
);
loader
.
css
(
'
visibility
'
,
'
visible
'
);
}
;
}
function
hide_loader
()
{
function
hide_loader
()
{
pending_request
=
false
;
pending_request
=
false
;
loader
.
css
(
'
visibility
'
,
'
hidden
'
);
loader
.
css
(
'
visibility
'
,
'
hidden
'
);
clear_error
();
}
};
function
append_hint
(
hint
)
{
function
append_hint
(
hint
)
{
pretty_print
.
find
(
'
div
'
).
last
().
filter
(
'
.hint
'
).
remove
();
pretty_print
.
find
(
'
div
'
).
last
().
filter
(
'
.hint
'
).
remove
();
...
@@ -238,11 +244,11 @@
...
@@ -238,11 +244,11 @@
elem
.
append
(
'
<div class="icon icon-info-sign"/>
'
);
elem
.
append
(
'
<div class="icon icon-info-sign"/>
'
);
pretty_print
.
append
(
elem
);
pretty_print
.
append
(
elem
);
QUEUE
.
Push
([
'
Typeset
'
,
MathJax
.
Hub
,
elem
[
0
]]);
QUEUE
.
Push
([
'
Typeset
'
,
MathJax
.
Hub
,
elem
[
0
]]);
}
;
}
function
append_input
(
input
)
{
function
append_input
(
input
)
{
input_textarea
.
val
(
input_textarea
.
val
()
+
'
\n
'
+
input
);
input_textarea
.
val
(
input_textarea
.
val
()
+
'
\n
'
+
input
);
}
;
}
$
(
'
#btn-clear
'
).
click
(
function
()
{
$
(
'
#btn-clear
'
).
click
(
function
()
{
input_textarea
.
val
(
''
);
input_textarea
.
val
(
''
);
...
@@ -262,6 +268,7 @@
...
@@ -262,6 +268,7 @@
}
}
show_loader
();
show_loader
();
clear_error
();
// 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).
...
@@ -274,6 +281,7 @@
...
@@ -274,6 +281,7 @@
handler
(
response
);
handler
(
response
);
hide_loader
();
hide_loader
();
clear_error
();
},
'
json
'
).
error
(
report_error
);
},
'
json
'
).
error
(
report_error
);
});
});
}
}
...
...
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