Skip to content

Instantly share code, notes, and snippets.

@jlattimer
Last active January 26, 2017 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlattimer/9cf7959ca37d6ec9401ee3a1fd0f6052 to your computer and use it in GitHub Desktop.
Save jlattimer/9cf7959ca37d6ec9401ee3a1fd0f6052 to your computer and use it in GitHub Desktop.
Use the annyang to navigate between tabs in Chrome
function TabNavigation() {
//Be sure to include annyang on the form
//https://cdnjs.cloudflare.com/ajax/libs/annyang/2.6.0/annyang.min.js
//https://github.com/TalAter/annyang
if (annyang) {
//'show me' is the beginning of the command
//anything said after that will be passed to the function where it's used
//to match the tab label to the spoken input to determine the focused tab
var command = {
"show me *name": function (name) {
Xrm.Page.ui.tabs.forEach(
function (control, index) {
if (control.getLabel().toLowerCase() === name.toLowerCase()) {
Xrm.Page.ui.tabs.get(index).setFocus();
}
});
}
};
annyang.addCommands(command);
//Optional logging
annyang.addCallback("error",
function () {
console.log("There was an error!");
});
annyang.addCallback("resultMatch",
function (userSaid, commandText, phrases) {
console.log("Match Said: " + userSaid);
console.log("Match Command: " + commandText);
console
.log("Match Phrases: " + phrases);
});
annyang.addCallback("resultNoMatch",
function (phrases) {
console
.log("No Match Phrases: " + phrases);
});
// Start listening.
annyang.start();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment