changeset 2669:a513533565cf

Fix for #194
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 28 Mar 2017 12:59:27 +0100
parents 2f2aaef246af
children d494f5fea8b1 f734e5fa2065 2395223deef2
files css/core.css js/core.js
diffstat 2 files changed, 21 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/css/core.css	Mon Mar 20 16:21:44 2017 +0000
+++ b/css/core.css	Tue Mar 28 12:59:27 2017 +0100
@@ -211,17 +211,16 @@
     height: 40px;
 }
 input#master-volume-control {
-    width: 200px;
+    width: 190px;
     height: 25px;
     float: left;
     margin: 0px;
     padding: 0px;
 }
 span#master-volume-feedback {
-    width: 45px;
     height: 25px;
-    margin-left: 5px;
-    float: left;
+    margin: 0px 5px;
+    float: right;
 }
 div.error-colour {
     background-color: #FF8F8F;
--- a/js/core.js	Mon Mar 20 16:21:44 2017 +0000
+++ b/js/core.js	Tue Mar 28 12:59:27 2017 +0100
@@ -2946,13 +2946,22 @@
         this.slider.max = 12;
         this.slider.value = 0;
         this.slider.step = 1;
-        this.slider.onmousemove = function (event) {
-            interfaceContext.volume.valueDB = event.currentTarget.value;
-            interfaceContext.volume.valueLin = decibelToLinear(interfaceContext.volume.valueDB);
-            interfaceContext.volume.valueText.textContent = interfaceContext.volume.valueDB + 'dB';
-            audioEngineContext.outputGain.gain.value = interfaceContext.volume.valueLin;
+        this.handleEvent = function (event) {
+            if (event.type == "mousemove") {
+                this.valueDB = Number(this.slider.value);
+                this.valueLin = decibelToLinear(this.valueDB);
+                this.valueText.textContent = this.valueDB + 'dB';
+                audioEngineContext.outputGain.gain.value = this.valueLin;
+            } else if (event.type == "mouseup") {
+                this.onmouseup();
+            }
+            this.slider.value = this.valueDB;
+
+            if (event.stopPropagation) {
+                event.stopPropagation();
+            }
         }
-        this.slider.onmouseup = function (event) {
+        this.onmouseup = function () {
             var storePoint = testState.currentStore.XMLDOM.getElementsByTagName('metric')[0].getAllElementsByName('volumeTracker');
             if (storePoint.length == 0) {
                 storePoint = storage.document.createElement('metricresult');
@@ -2963,10 +2972,12 @@
             }
             var node = storage.document.createElement('movement');
             node.setAttribute('test-time', audioEngineContext.timer.getTestTime());
-            node.setAttribute('volume', interfaceContext.volume.valueDB);
+            node.setAttribute('volume', this.valueDB);
             node.setAttribute('format', 'dBFS');
             storePoint.appendChild(node);
         }
+        this.slider.addEventListener("mousemove", this);
+        this.root.addEventListener("mouseup", this);
 
         var title = document.createElement('div');
         title.innerHTML = '<span>Master Volume Control</span>';