Tidy up code

This commit is contained in:
Saul Johnson
2020-05-16 14:57:54 +01:00
parent 2e16e0ad15
commit 9a80c7fc5c
5 changed files with 29 additions and 43 deletions
+1
View File
@@ -62,3 +62,4 @@ A big thank you to:
* [Nile Red](https://www.youtube.com/user/TheRedNile) inspired me to build this. I wasn't that big on chemistry until I came across his videos.
* [Jay Holtslander](https://codepen.io/j_holtslander/) put together the hamburger menu/sidebar combo in his [Pen](https://codepen.io/j_holtslander/pen/XmpMEp) on CodePen. I believe it's derived from earlier work by [maridlcrmn](https://bootsnipp.com/maridlcrmn).
* [Thomas Moerman](https://github.com/tmoerman) created [Sourire](https://github.com/tmoerman/sourire), which really simplified the molecule rendering process.
* [Andre Plötze](https://github.com/andrepxx) created [Sourire](https://github.com/tmoerman/sourire), which really simplified the molecule rendering process.
+25 -11
View File
@@ -240,6 +240,25 @@ $(document).ready ->
backgroundColor = $(e.target).val().substring(1)
modeAwareRefreshPreview()
# Set up the rotation knob.
rotationKnob = pureknob.createKnob(88, 88)
rotationKnob.setProperty 'angleStart', 0
rotationKnob.setProperty 'angleEnd', Math.PI * 2
rotationKnob.setProperty 'colorFG', '#C0C0C0'
rotationKnob.setProperty 'colorBG', '#505050'
rotationKnob.setProperty 'trackWidth', 0.4
rotationKnob.setProperty 'valMin', 0
rotationKnob.setProperty 'valMax', 359
rotationKnob.setProperty 'needle', true
rotationKnob.setValue 0
rotationKnob.addListener (knob, value) ->
rotation = value
modeAwareRefreshPreview()
knobNode = rotationKnob.node()
knobElem = document.getElementById 'rotation_knob'
knobElem.appendChild knobNode
# Compound name update button should refresh the preview.
$('.update-btn').on 'click', (e) ->
@@ -257,7 +276,7 @@ $(document).ready ->
customLabel = getCustomLabel()
modeAwareRefreshPreview()
# Put passed parameter values into text boxes if needed.
# Put passed parameter values into UI if needed.
passedCompoundName = getParameterByName 'compound'
if passedCompoundName != null
@@ -273,20 +292,15 @@ $(document).ready ->
if passedLabel != null
customLabelTextBox.val(passedLabel)
# Grab initial values from text boxes.
passedRotation = getParameterByName 'rotation'
if passedRotation != null
rotationKnob.setValue(passedRotation)
# Grab initial values from UI.
currentCompoundName = compoundTextBox.val()
currentCompoundSmiles = smilesTextBox.val()
customLabel = customLabelTextBox.val()
window.knobListener = (k, v) ->
rotation = v
modeAwareRefreshPreview()
initRotationKnob()
passedRotation = getParameterByName 'rotation'
if passedRotation != null
rotationKnob.setValue(passedRotation)
rotation = rotationKnob.getValue()
# Initial update.
-28
View File
@@ -1,28 +0,0 @@
###
* Demo code for knob element.
###
initRotationKnob = ->
# Create knob element, 300 x 300 px in size.
knob = pureknob.createKnob(88, 88)
# Set properties.
knob.setProperty 'angleStart', 0
knob.setProperty 'angleEnd', Math.PI * 2
knob.setProperty 'colorFG', '#C0C0C0'
knob.setProperty 'colorBG', '#505050'
knob.setProperty 'trackWidth', 0.4
knob.setProperty 'valMin', 0
knob.setProperty 'valMax', 359
knob.setProperty 'needle', true
# Set initial value.
knob.setValue 0
knob.addListener window.knobListener
# Create element node.
node = knob.node()
# Add it to the DOM.
elem = document.getElementById('rotation_knob')
elem.appendChild node
window.rotationKnob = knob
window.initRotationKnob = initRotationKnob
+1 -1
View File
@@ -28,7 +28,7 @@
@picker-border: #444;
// Width variables.
@sidebar-width: 400px;
@sidebar-width: 300px;
@width2: 100px;
@full-width: 100%;
+1 -2
View File
@@ -31,11 +31,10 @@
<script type="text/javascript" src="/bower_components/jquery/dist/jquery.min.js"></script>
<script type="text/javascript" src="/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/bower_components/spectrum/spectrum.js"></script>
<script type="text/javascript" src="/js-lib/pureknob.js"></script>
<script type="text/javascript" src="/js/params.js"></script>
<script type="text/javascript" src="/js/hamburger.js"></script>
<script type="text/javascript" src="/js/main.js"></script>
<script type="text/javascript" src="/js-lib/pureknob.js"></script>
<script type="text/javascript" src="/js/rotationknob.js"></script>
{% include "_analytics.html.twig" %}
</head>
<body>