var supportedOperatingSystems = new Map([ ['linux', 'linux'], ['mac', 'macos'], ['win', 'windows'], ]); var supportedOperatingSystemsNew = [ {key: 'linux', value: 'linux'}, {key: 'mac', value: 'macos'}, {key: 'win', value: 'windows'} ] var opts = { os: getAnchorSelectedOS() || getDefaultSelectedOS(), architecture: 'X64', language: 'Python(3.5-3.7)', hardwareAcceleration: 'DefaultCPU', }; var os = $(".os > .r-option"); var architecture = $(".architecture > .r-option"); var language = $(".language > .r-option"); var hardwareAcceleration = $(".hardwareAcceleration > .r-option"); function checkKeyPress(event) { var keycode = (event.keyCode ? event.keyCode : event.which); if (keycode == '13' || keycode == '32' || (keycode >= '37' && keycode <= '40')) { return true; } else { return false; } } os.on("click", function () { selectedOption(os, this, "os"); }); os.on("keypress keyup", function (event) { if (checkKeyPress(event)) { selectedOption(os, this, "os"); } }); architecture.on("click", function () { selectedOption(architecture, this, "architecture"); }); architecture.on("keypress keyup", function (event) { if (checkKeyPress(event)) { selectedOption(architecture, this, "architecture"); } }); language.on("click", function () { selectedOption(language, this, "language"); }); language.on("keypress keyup", function (event) { if (checkKeyPress(event)) { selectedOption(language, this, "language"); } }); hardwareAcceleration.on("click", function () { selectedOption(hardwareAcceleration, this, "hardwareAcceleration"); }); hardwareAcceleration.on("keypress keyup", function (event) { if (checkKeyPress(event)) { selectedOption(hardwareAcceleration, this, "hardwareAcceleration"); } }); // Pre-select user's operating system $(document).ready(function () { var userOsOption = document.getElementById(opts.os); if (userOsOption) { selectedOption(os, userOsOption, "os"); } }); // determine os (mac, linux, windows) based on user's platform function getDefaultSelectedOS() { var platform = navigator.platform.toLowerCase(); for (var idx = 0; idx < supportedOperatingSystemsNew.length; idx++ ) { if (platform.indexOf(supportedOperatingSystemsNew[idx].key) !== -1) { return supportedOperatingSystemsNew[idx].value; } } // Just return something if user platform is not in our supported map return supportedOperatingSystemsNew[0].value; } // determine os based on location hash function getAnchorSelectedOS() { var anchor = location.hash; var ANCHOR_REGEX = /^#[^ ]+$/; // Look for anchor in the href if (!ANCHOR_REGEX.test(anchor)) { return false; } // Look for anchor with OS in the first portion var testOS = anchor.slice(1).split("-")[0]; for (var idx = 0; idx < supportedOperatingSystemsNew.length; idx++ ) { if (testOS.indexOf(supportedOperatingSystemsNew[idx].key) !== -1) { return supportedOperatingSystemsNew[idx].value; } } return false; } function selectedOption(option, selection, category) { $(option).removeClass("selected"); $(selection).addClass("selected"); opts[category] = selection.id; commandMessage(buildMatcher()); } function display(selection, id, category) { var container = document.getElementById(id); // Check if there's a container to display the selection if (container === null) { return; } var elements = container.getElementsByClassName(category); for (var i = 0; i < elements.length; i++) { if (elements[i].classList.contains(selection)) { $(elements[i]).addClass("selected"); } else { $(elements[i]).removeClass("selected"); } } } function buildMatcher() { return ( opts.os + "," + opts.language + "," + opts.architecture + "," + opts.hardwareAcceleration ); } function commandMessage(key) { // console.log('key- '.key); var object = { "windows,C,X64,CUDA": "Install Nuget package Microsoft.ML.OnnxRuntime.Gpu", "windows,C++,X64,CUDA": "Install Nuget package Microsoft.ML.OnnxRuntime.Gpu", "windows,C#,X64,CUDA": "Install Nuget package Microsoft.ML.OnnxRuntime.Gpu", "windows,Python(3.5-3.7),X64,CUDA": "pip install onnxruntime-gpu", "linux,C,X64,CUDA": "Download .tgz file from Github", "linux,C++,X64,CUDA": "Install Nuget package Microsoft.ML.OnnxRuntime.Gpu", "linux,C#,X64,CUDA": "Install Nuget package Microsoft.ML.OnnxRuntime.Gpu", "linux,Python(3.5-3.7),X64,CUDA": "pip install onnxruntime-gpu", "windows,C,ARM32,DirectML": "Follow build instructions from here", "windows,C++,ARM32,DirectML": "Follow build instructions from here", "windows,C#,ARM32,DirectML": "Follow build instructions from here", "windows,Python(3.5-3.7),ARM32,DirectML": "Follow build instructions from here", "mac,C,ARM32,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,ARM32,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,ARM32,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),ARM32,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C,ARM32,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C++,ARM32,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C#,ARM32,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,Python(3.5-3.7),ARM32,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "windows,C,ARM64,DirectML": "Follow build instructions from here", "windows,C++,ARM64,DirectML": "Follow build instructions from here", "windows,C#,ARM64,DirectML": "Follow build instructions from here", "windows,Python(3.5-3.7),ARM64,DirectML": "Follow build instructions from here", "linux,C,ARM32,DefaultCPU": "Follow build instructions from here", "linux,C++,ARM32,DefaultCPU": "Follow build instructions from here", "linux,Python(3.5-3.7),ARM32,DefaultCPU": "Follow build instructions from here", "windows,C,X64,DefaultCPU": "Install Nuget package Microsoft.ML.OnnxRuntime", "windows,C,X86,DefaultCPU": "Install Nuget package Microsoft.ML.OnnxRuntime", "windows,C++,X64,DefaultCPU": "Install Nuget package Microsoft.ML.OnnxRuntime", "windows,C++,X86,DefaultCPU": "Install Nuget package Microsoft.ML.OnnxRuntime", "windows,C#,X64,DefaultCPU": "Install Nuget package Microsoft.ML.OnnxRuntime", "windows,C#,X86,DefaultCPU": "Install Nuget package Microsoft.ML.OnnxRuntime", "linux,C,X64,DefaultCPU": "Download .tgz file from Github", "linux,C++,X64,DefaultCPU": "Download .tgz file from Github", "linux,C#,X64,DefaultCPU": "Install Nuget package Microsoft.ML.OnnxRuntime", "mac,C,X64,DefaultCPU": "Download .tgz file from Github", "mac,C++,X64,DefaultCPU": "Download .tgz file from Github", "mac,C#,X64,DefaultCPU": "Download .tgz file from Github", "windows,Python(3.5-3.7),X64,DefaultCPU": "pip install onnxruntime", "mac,Python(3.5-3.7),X64,DefaultCPU": "pip install onnxruntime", "linux,Python(3.5-3.7),X64,DefaultCPU": "pip install onnxruntime", "windows,C,X64,MKL-DNN": "Follow build instructions from here", "windows,C++,X64,MKL-DNN": "Follow build instructions from here", "windows,C#,X64,MKL-DNN": "Follow build instructions from here", "windows,Python(3.5-3.7),X64,MKL-DNN": "Follow build instructions from here", "linux,C,X64,MKL-DNN": "Follow build instructions from here", "linux,C++,X64,MKL-DNN": "Follow build instructions from here", "linux,C#,X64,MKL-DNN": "Follow build instructions from here", "linux,Python(3.5-3.7),X64,MKL-DNN": "Follow build instructions from here", "windows,C,X64,MKL-ML": "Install Nuget package Microsoft.ML.OnnxRuntime.MKLML", "windows,C++,X64,MKL-ML": "Install Nuget package Microsoft.ML.OnnxRuntime.MKLML", "windows,C#,X64,MKL-ML": "Install Nuget package Microsoft.ML.OnnxRuntime.MKLML", "linux,C,X64,MKL-ML": "Install Nuget package Microsoft.ML.OnnxRuntime.MKLML", "linux,C++,X64,MKL-ML": "Install Nuget package Microsoft.ML.OnnxRuntime.MKLML", "linux,C#,X64,MKL-ML": "Install Nuget package Microsoft.ML.OnnxRuntime.MKLML", "mac,C,X64,MKL-ML": "Install Nuget package Microsoft.ML.OnnxRuntime.MKLML", "mac,C++,X64,MKL-ML": "Install Nuget package Microsoft.ML.OnnxRuntime.MKLML", "mac,C#,X64,MKL-ML": "Install Nuget package Microsoft.ML.OnnxRuntime.MKLML", "linux,C,X64,nGraph": "Follow build instructions from here", "linux,C++,X64,nGraph": "Follow build instructions from here", "linux,C#,X64,nGraph": "Follow build instructions from here", "linux,Python(3.5-3.7),X64,nGraph": "Follow build instructions from here", "windows,C,X64,nGraph": "Follow build instructions from here", "windows,C++,X64,nGraph": "Follow build instructions from here", "windows,C#,X64,nGraph": "Follow build instructions from here", "windows,Python(3.5-3.7),X64,nGraph": "Follow build instructions from here", "windows,C,X64,NUPHAR": "Follow build instructions from here", "windows,C++,X64,NUPHAR": "Follow build instructions from here", "windows,C#,X64,NUPHAR": "Follow build instructions from here", "windows,Python(3.5-3.7),X64,NUPHAR": "Follow build instructions from here", "linux,C,X64,NUPHAR": "Follow build instructions from here", "linux,C++,X64,NUPHAR": "Follow build instructions from here", "linux,C#,X64,NUPHAR": "Follow build instructions from here", "linux,Python(3.5-3.7),X64,NUPHAR": "Follow build instructions from here", "linux,C,X64,OpenVINO": "Follow build instructions from here", "linux,C++,X64,OpenVINO": "Follow build instructions from here", "linux,C#,X64,OpenVINO": "Follow build instructions from here", "linux,Python(3.5-3.7),X64,OpenVINO": "Follow build instructions from here", "windows,C,X64,OpenVINO": "Follow build instructions from here", "windows,C++,X64,OpenVINO": "Follow build instructions from here", "windows,C#,X64,OpenVINO": "Follow build instructions from here", "windows,Python(3.5-3.7),X64,OpenVINO": "Follow build instructions from here", "windows,C,X64,TensorRT": "Follow build instructions from here", "windows,C++,X64,TensorRT": "Follow build instructions from here", "windows,C#,X64,TensorRT": "Follow build instructions from here", "windows,Python(3.5-3.7),X64,TensorRT": "Follow build instructions from here", "linux,C,X64,TensorRT": "Follow build instructions from here", "linux,C++,X64,TensorRT": "Follow build instructions from here", "linux,C#,X64,TensorRT": "Follow build instructions from here", "linux,Python(3.5-3.7),X64,TensorRT": "Follow build instructions from here", "linux,C,ARM64,TensorRT": "Follow build instructions from here", "linux,C++,ARM64,TensorRT": "Follow build instructions from here", "linux,C#,ARM64,TensorRT": "Follow build instructions from here", "linux,Python(3.5-3.7),ARM64,TensorRT": "Follow build instructions from here", "mac,C,X64,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X86,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,ARM32,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,ARM32,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X64,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X86,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,ARM32,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),ARM32,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X64,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X86,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,ARM32,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,ARM32,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X64,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X86,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,ARM32,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),ARM32,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X64,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X86,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,ARM32,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,ARM32,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X64,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X86,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,ARM32,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),ARM32,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X64,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X86,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,ARM64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,ARM64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X64,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X86,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,ARM64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),ARM64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X64,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X86,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,ARM32,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,ARM32,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X64,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X86,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,ARM32,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),ARM32,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X64,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X86,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,ARM64,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X64,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X86,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,ARM64,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,ARM64,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C,ARM64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C++,ARM64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),ARM64,nGraph": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,ARM64,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C#,ARM64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,Python(3.5-3.7),ARM64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,ARM64,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,ARM64,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "windows,C,X64,DirectML": "Follow build instructions from here", "windows,C++,X64,DirectML": "Follow build instructions from here", "mac,Python(3.5-3.7),ARM64,CUDA": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,ARM64,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "windows,C#,X64,DirectML": "Follow build instructions from here", "windows,Python(3.5-3.7),X64,DirectML": "Follow build instructions from here", "mac,C++,ARM64,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,ARM64,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X64,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X86,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),ARM64,TensorRT": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X64,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X86,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X64,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X86,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,ARM64,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X64,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X86,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,ARM64,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,ARM64,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),ARM64,OpenVINO": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X86,NUPHAR": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X86,NUPHAR": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X86,NUPHAR": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X86,NUPHAR": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X86,DefaultCPU": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X86,DefaultCPU": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X86,DefaultCPU": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X86,DefaultCPU": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X86,MKL-ML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X86,MKL-ML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X86,MKL-ML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X86,MKL-ML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C,X86,MKL-DNN": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X86,MKL-DNN": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X86,MKL-DNN": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X86,MKL-DNN": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C,X64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C++,X64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C#,X64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,Python(3.5-3.7),X64,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "windows,C,X86,DirectML": "Follow build instructions from here", "windows,C++,X86,DirectML": "Follow build instructions from here", "windows,C#,X86,DirectML": "Follow build instructions from here", "windows,Python(3.5-3.7),X86,DirectML": "Follow build instructions from here", "mac,C,X86,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C++,X86,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,C#,X86,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "mac,Python(3.5-3.7),X86,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C,X86,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C++,X86,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,C#,X86,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,Python(3.5-3.7),X86,DirectML": "This combination of resources has not yet been tested. It may be possible to build from source.", "linux,Java,X64,DefaultCPU": "Follow build and API instructions", "linux,Java,X64,CUDA": "Follow build and API instructions", "mac,Java,X64,DefaultCPU": "Follow build and API instructions" }; if (!object.hasOwnProperty(key)) { $("#command span").html( "This combination of resources has not yet been tested. It may be possible to build from source." ); } else { $("#command span").html(object[key]); } } //Accesibility Get started tabel var KEYCODE = { DOWN: 40, LEFT: 37, RIGHT: 39, SPACE: 32, UP: 38 } window.addEventListener('load', function () { var radiobuttons = document.querySelectorAll('[role=option]'); for (var i = 0; i < radiobuttons.length; i++) { var rb = radiobuttons[i]; rb.addEventListener('click', clickRadioGroup); rb.addEventListener('keydown', keyDownRadioGroup); rb.addEventListener('focus', focusRadioButton); rb.addEventListener('blur', blurRadioButton); } }); function firstRadioButton(node) { var first = node.parentNode.firstChild; while (first) { if (first.nodeType === Node.ELEMENT_NODE) { if (first.getAttribute("role") === 'option') return first; } first = first.nextSibling; } return null; } function lastRadioButton(node) { var last = node.parentNode.lastChild; while (last) { if (last.nodeType === Node.ELEMENT_NODE) { if (last.getAttribute("role") === 'option') return last; } last = last.previousSibling; } return last; } function nextRadioButton(node) { var next = node.nextSibling; while (next) { if (next.nodeType === Node.ELEMENT_NODE) { if (next.getAttribute("role") === 'option') return next; } next = next.nextSibling; } return null; } function previousRadioButton(node) { var prev = node.previousSibling; while (prev) { if (prev.nodeType === Node.ELEMENT_NODE) { if (prev.getAttribute("role") === 'option') return prev; } prev = prev.previousSibling; } return null; } function getImage(node) { var child = node.firstChild; while (child) { if (child.nodeType === Node.ELEMENT_NODE) { if (child.tagName === 'IMG') return child; } child = child.nextSibling; } return null; } function setRadioButton(node, state) { var image = getImage(node); if (state == 'true') { node.setAttribute('aria-selected', 'true'); // $(node).trigger() node.tabIndex = 0; node.focus(); } else { node.setAttribute('aria-selected', 'false'); node.tabIndex = -1; } } function clickRadioGroup(event) { var type = event.type; if (type === 'click') { var node = event.currentTarget; var radioButton = firstRadioButton(node); while (radioButton) { setRadioButton(radioButton, "false"); radioButton = nextRadioButton(radioButton); } setRadioButton(node, "true"); event.preventDefault(); event.stopPropagation(); } } function keyDownRadioGroup(event) { var type = event.type; var next = false; if (type === "keydown") { var node = event.currentTarget; switch (event.keyCode) { case KEYCODE.DOWN: case KEYCODE.RIGHT: var next = nextRadioButton(node); if (!next) next = firstRadioButton(node); //if node is the last node, node cycles to first. break; case KEYCODE.UP: case KEYCODE.LEFT: next = previousRadioButton(node); if (!next) next = lastRadioButton(node); //if node is the last node, node cycles to first. break; case KEYCODE.SPACE: next = node; break; } if (next) { var radioButton = firstRadioButton(node); while (radioButton) { setRadioButton(radioButton, "false"); radioButton = nextRadioButton(radioButton); } setRadioButton(next, "true"); event.preventDefault(); event.stopPropagation(); } } } function focusRadioButton(event) { event.currentTarget.className += ' focus'; document.getElementById("command").innerHTML; } function blurRadioButton(event) { event.currentTarget.className = event.currentTarget.className.replace(' focus', ''); } (function($) { "use strict"; // Carousel Extension // =============================== $('.carousel').each(function (index) { // This function positions a highlight box around the tabs in the tablist to use in focus styling function setTablistHighlightBox() { var $tab , offset , height , width , highlightBox = {} highlightBox.top = 0 highlightBox.left = 32000 highlightBox.height = 0 highlightBox.width = 0 for (var i = 0; i < $tabs.length; i++) { $tab = $tabs[i] offset = $($tab).offset() height = $($tab).height() width = $($tab).width() if (highlightBox.top < offset.top) { highlightBox.top = Math.round(offset.top) } if (highlightBox.height < height) { highlightBox.height = Math.round(height) } if (highlightBox.left > offset.left) { highlightBox.left = Math.round(offset.left) } var w = (offset.left - highlightBox.left) + Math.round(width) if (highlightBox.width < w) { highlightBox.width = w } } // end for $tablistHighlight.style.top = (highlightBox.top - 2) + 'px' $tablistHighlight.style.left = (highlightBox.left - 2) + 'px' $tablistHighlight.style.height = (highlightBox.height + 7) + 'px' $tablistHighlight.style.width = (highlightBox.width + 8) + 'px' } // end function var $this = $(this) , $prev = $this.find('[data-slide="prev"]') , $next = $this.find('[data-slide="next"]') , $tablist = $this.find('.carousel-indicators') , $tabs = $this.find('.carousel-indicators li') , $tabpanels = $this.find('.carousel-item') , $tabpanel , $tablistHighlight , $pauseCarousel , $complementaryLandmark , $tab , $is_paused = false , offset , height , width , i , id_title = 'id_title' , id_desc = 'id_desc' $tablist.attr('role', 'tablist') $tabs.focus(function() { $this.carousel('pause') $is_paused = true $pauseCarousel.innerHTML = "" $(this).parent().addClass('active'); // $(this).addClass('focus') setTablistHighlightBox() $($tablistHighlight).addClass('focus') $(this).parents('.carousel').addClass('contrast') }) $tabs.blur(function(event) { $(this).parent().removeClass('active'); // $(this).removeClass('focus') $($tablistHighlight).removeClass('focus') $(this).parents('.carousel').removeClass('contrast') }) for (i = 0; i < $tabpanels.length; i++) { $tabpanel = $tabpanels[i] $tabpanel.setAttribute('role', 'tabpanel') $tabpanel.setAttribute('id', 'tabpanel-' + index + '-' + i) $tabpanel.setAttribute('aria-labelledby', 'tab-' + index + '-' + i) } if (typeof $this.attr('role') !== 'string') { // $this.attr('role', 'complementary'); $this.attr('aria-labelledby', id_title); $this.attr('aria-describedby', id_desc); $this.prepend('
A carousel is a rotating set of images, rotation stops on keyboard focus on carousel tab controls or hovering the mouse pointer over images. Use the tabs or the previous and next buttons to change the displayed slide.
') $this.prepend('