comparison js/core.js @ 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 b9efbbe0d829 2395223deef2
comparison
equal deleted inserted replaced
2667:2f2aaef246af 2669:a513533565cf
2944 2944
2945 this.slider.min = -60; 2945 this.slider.min = -60;
2946 this.slider.max = 12; 2946 this.slider.max = 12;
2947 this.slider.value = 0; 2947 this.slider.value = 0;
2948 this.slider.step = 1; 2948 this.slider.step = 1;
2949 this.slider.onmousemove = function (event) { 2949 this.handleEvent = function (event) {
2950 interfaceContext.volume.valueDB = event.currentTarget.value; 2950 if (event.type == "mousemove") {
2951 interfaceContext.volume.valueLin = decibelToLinear(interfaceContext.volume.valueDB); 2951 this.valueDB = Number(this.slider.value);
2952 interfaceContext.volume.valueText.textContent = interfaceContext.volume.valueDB + 'dB'; 2952 this.valueLin = decibelToLinear(this.valueDB);
2953 audioEngineContext.outputGain.gain.value = interfaceContext.volume.valueLin; 2953 this.valueText.textContent = this.valueDB + 'dB';
2954 } 2954 audioEngineContext.outputGain.gain.value = this.valueLin;
2955 this.slider.onmouseup = function (event) { 2955 } else if (event.type == "mouseup") {
2956 this.onmouseup();
2957 }
2958 this.slider.value = this.valueDB;
2959
2960 if (event.stopPropagation) {
2961 event.stopPropagation();
2962 }
2963 }
2964 this.onmouseup = function () {
2956 var storePoint = testState.currentStore.XMLDOM.getElementsByTagName('metric')[0].getAllElementsByName('volumeTracker'); 2965 var storePoint = testState.currentStore.XMLDOM.getElementsByTagName('metric')[0].getAllElementsByName('volumeTracker');
2957 if (storePoint.length == 0) { 2966 if (storePoint.length == 0) {
2958 storePoint = storage.document.createElement('metricresult'); 2967 storePoint = storage.document.createElement('metricresult');
2959 storePoint.setAttribute('name', 'volumeTracker'); 2968 storePoint.setAttribute('name', 'volumeTracker');
2960 testState.currentStore.XMLDOM.getElementsByTagName('metric')[0].appendChild(storePoint); 2969 testState.currentStore.XMLDOM.getElementsByTagName('metric')[0].appendChild(storePoint);
2961 } else { 2970 } else {
2962 storePoint = storePoint[0]; 2971 storePoint = storePoint[0];
2963 } 2972 }
2964 var node = storage.document.createElement('movement'); 2973 var node = storage.document.createElement('movement');
2965 node.setAttribute('test-time', audioEngineContext.timer.getTestTime()); 2974 node.setAttribute('test-time', audioEngineContext.timer.getTestTime());
2966 node.setAttribute('volume', interfaceContext.volume.valueDB); 2975 node.setAttribute('volume', this.valueDB);
2967 node.setAttribute('format', 'dBFS'); 2976 node.setAttribute('format', 'dBFS');
2968 storePoint.appendChild(node); 2977 storePoint.appendChild(node);
2969 } 2978 }
2979 this.slider.addEventListener("mousemove", this);
2980 this.root.addEventListener("mouseup", this);
2970 2981
2971 var title = document.createElement('div'); 2982 var title = document.createElement('div');
2972 title.innerHTML = '<span>Master Volume Control</span>'; 2983 title.innerHTML = '<span>Master Volume Control</span>';
2973 title.style.fontSize = '0.75em'; 2984 title.style.fontSize = '0.75em';
2974 title.style.width = "100%"; 2985 title.style.width = "100%";