# HG changeset patch # User Nicholas Jillings # Date 1484842547 0 # Node ID 8f3ea7ce794b53763cd09add79409053e5f2614e # Parent 781187c743cc5d614c4ba982ef4bc1a3ab684c6e #6: Added getCombinedInterfaces() to populate the page interface nodes with the global information diff -r 781187c743cc -r 8f3ea7ce794b js/core.js --- 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() { diff -r 781187c743cc -r 8f3ea7ce794b tests/examples/mushra_example.xml --- 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 @@ + + Much Worse + Worse + Slightly Worse + About the same + Slightly Better + Better + Much Better +