Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
05e25dad
Commit
05e25dad
authored
Jan 30, 2013
by
Julian Arni
Committed by
Victor Shnayder
Feb 05, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added validation warnings
parent
02eb55a9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
36 additions
and
11 deletions
+36
-11
common/static/js/capa/editamolecule.js
+36
-11
No files found.
common/static/js/capa/editamolecule.js
View file @
05e25dad
...
...
@@ -58,6 +58,12 @@
var
input_field
=
parent
.
find
(
'input[type=hidden]'
);
var
reset_button
=
parent
.
find
(
'button.reset'
);
// Add div for error messages
$
(
'<br/> <br/> <div class="errormsgs" style="padding: 5px 5px 5px 5px;
\
visibility:hidden; background-color:#FA6666; height:60px;
\
width:400px;"> </div>'
).
appendTo
(
parent
);
// Applet options
applet
.
setAntialias
(
true
);
...
...
@@ -72,12 +78,16 @@
reset_button
.
on
(
'click'
,
function
()
{
requestAppletData
(
element
,
applet
,
input_field
);
// Make sure remaining error messages are cleared
var
errordiv
=
$
(
element
).
parent
().
find
(
'.errormsgs'
)[
0
];
errordiv
.
style
.
visibility
=
'hidden'
;
});
// Update the input element everytime the is an interaction
// with the applet (click, drag, etc)
$
(
element
).
on
(
'mouseup'
,
function
()
{
updateInput
(
applet
,
input_field
);
updateInput
(
applet
,
input_field
,
element
);
});
}
...
...
@@ -102,31 +112,46 @@
updateInput
(
applet
,
input_field
);
}
function
updateInput
(
applet
,
input_field
)
{
function
updateInput
(
applet
,
input_field
,
element
)
{
var
mol
=
applet
.
molFile
();
var
smiles
=
applet
.
smiles
();
var
jme
=
applet
.
jmeFile
();
var
info
=
jsmol
.
API
.
getInfo
(
mol
,
smiles
,
jme
).
toString
();
var
err
=
jsmol
.
API
.
getErrors
(
mol
,
smiles
,
jme
).
toString
();
var
info
=
formatInfo
(
jsmol
.
API
.
getInfo
(
mol
,
smiles
,
jme
).
toString
(),
input_field
,
element
);
var
value
=
{
mol
:
mol
,
info
:
info
};
console
.
log
(
"Molecule info:"
);
console
.
log
(
info
);
console
.
log
(
err
);
input_field
.
val
(
JSON
.
stringify
(
value
));
return
value
;
}
function
formatInfo
(
info
)
{
function
formatInfo
(
info
,
input_field
,
element
)
{
var
results
=
[];
var
fragment
=
$
(
'<div>'
).
append
(
info
);
fragment
.
find
(
'font'
).
each
(
function
()
{
results
.
push
(
$
(
this
).
html
());
});
var
errordiv
=
$
(
element
).
parent
().
find
(
'.errormsgs'
)[
0
];
console
.
log
(
errordiv
);
if
(
info
.
search
(
"It is not possible"
)
==
-
1
)
{
errordiv
.
innerHTML
=
''
;
errordiv
.
style
.
visibility
=
'hidden'
;
var
fragment
=
$
(
'<div>'
).
append
(
info
);
fragment
.
find
(
'font'
).
each
(
function
()
{
results
.
push
(
$
(
this
).
html
());
});
}
else
{
console
.
log
(
"err"
);
// remove Brian's html tags
var
tags
=
/<
((\/)?\w{1,7})
>/g
;
var
errmsg
=
info
.
replace
(
tags
,
' '
);
console
.
log
(
errmsg
);
errordiv
.
innerHTML
=
errmsg
;
errordiv
.
style
.
visibility
=
'visible'
;
}
return
results
;
}
...
...
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