-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
77 lines (63 loc) · 2.71 KB
/
Copy pathexample.js
File metadata and controls
77 lines (63 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* An example for the Tommy library
*
* Creator: Aaron Vontell, Vontech Software LLC (aaron@vontech.org)
* Contributors: Aaron Vontell
* Version: ex0.0.1-alpha
*/
/**
* A simple example of Tommy
*/
function setupTommy() {
// First, we configure Tommy
var definitions = [
{
path: "/index.html", // The path destination when Tommy is clicked
keywords: "home tommy homepage", // The speech keywords that cause Tommy to show up
title: "Home Page", // The title for this suggestion
description: "Home page for Tommy", // The description for the suggestion
icon: "img/star.png", // The icon for the the suggestion
titleFunction: undefined, // Instead, generate title from a function (given payload)
descriptionFunction: undefined, // Instead, generate description from a function (given payload)
iconFunction: undefined, // Instead, generate icon from a function (given payload)
displayHTML: undefined, // Instead, generate the entire suggestion HTML
},
{
path: "/contacts.html",
keywords: "contacts contact email phone team",
description: "View contact information for the Tommy project",
}
]
var tail = [
{
path: "http://vontech.org",
keywords: "vontech",
title: "Visit vontech.org",
description: "Want to learn more about this project? Visit vontech.org!",
}
]
var t = Tommy('tommy', definitions, {debug: true, feelingLucky: false, tail: tail})
// Get the context that led to this page (null if Tommy didn't get to this page)
var context = t.context
//console.log(context.payload) // The full speech string used to reach this page
//console.log(context.previous) // The path that the user came from
//console.log(context.timeSpent) // Time spent using Tommy in the last page
// Open Tommy programmatically on your own
//t.open()
// Have Tommy begin listening programmatically on your own
//t.listen()
// Have Tommy stop listening programmatically on your own
//t.deafen()
// Close Tommy programmatically on your own
//t.close()
// Have tommy listen for only a few seconds (4 seconds)
//t.listen(4000)
// Retrieve the current suggestions and current payload
var current = t.current.suggestions;
var payload = t.current.payload;
//console.log(current)
//console.log(payload)
// Show some basic properties of Tommy
console.log(t.version)
}
setupTommy();