Mercurial > hg > webaudioevaluationtool
changeset 2649:8f3ea7ce794b
#6: Added getCombinedInterfaces() to populate the page interface nodes with the global information
author | Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk> |
---|---|
date | Thu, 19 Jan 2017 16:15:47 +0000 |
parents | 781187c743cc |
children | 41b7fcd245da |
files | js/core.js tests/examples/mushra_example.xml |
diffstat | 2 files changed, 34 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/js/core.js Thu Jan 19 15:51:49 2017 +0000 +++ b/js/core.js Thu Jan 19 16:15:47 2017 +0000 @@ -3331,6 +3331,31 @@ throw ("Invalid arguments"); } } + + this.getCombinedInterfaces = function (page) { + // Combine the interfaces with the global interface nodes + var global = specification.interfaces, + local = page.interfaces; + local.forEach(function (locInt) { + // Iterate through the options nodes + var addList = []; + global.options.forEach(function (gopt) { + var lopt = locInt.options.find(function (lopt) { + return (lopt.name == gopt.name) && (lopt.type == gopt.type); + }); + if (!lopt) { + // Global option doesn't exist locally + addList.push(gopt); + } + }); + locInt.options = locInt.options.concat(addList); + if (!locInt.scales && global.scales) { + // Use the global default scales + locInt.scales = global.scales; + } + }); + return local; + } } function Storage() {
--- a/tests/examples/mushra_example.xml Thu Jan 19 15:51:49 2017 +0000 +++ b/tests/examples/mushra_example.xml Thu Jan 19 16:15:47 2017 +0000 @@ -51,6 +51,15 @@ <interfaceoption type="show" name='playhead' /> <interfaceoption type="show" name="page-count" /> <interfaceoption type="show" name="volume" /> + <scales> + <scalelabel position="12">Much Worse</scalelabel> + <scalelabel position="25">Worse</scalelabel> + <scalelabel position="38">Slightly Worse</scalelabel> + <scalelabel position="50">About the same</scalelabel> + <scalelabel position="62">Slightly Better</scalelabel> + <scalelabel position="75">Better</scalelabel> + <scalelabel position="88">Much Better</scalelabel> + </scales> </interface> </setup> <page id='test-0' hostURL="media/example/" randomiseOrder='true' repeatCount='0' loop='true' loudness="-12" restrictMovement="true">