forked from chrisachard/patio11bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
143 lines (109 loc) · 4.34 KB
/
index.html
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>patio11bot</title>
<link href="https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400|Work+Sans" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="/style.css">
<link rel="shortcut icon" type="image/x-icon" href="/favicon.ico">
<script src="answer.js"></script>
<script async src="https://platform.twitter.com/widgets.js" charset="utf-8"></script>
</head>
<body>
<div class="heading">
<h1>patio11🤖bot</h1>
</div>
<div class="subheading">
✨
<div class="subheading-text">
<p><i>10 years of SaaS knowledge</i></p>
<p><i>in one magical package</i></p>
</div>
✨
</div>
<div class="question">
<div class="user-question" id="user-question">
<h2>You Asked:</h2>
<p id="user-question-text">Question</p>
</div>
<object type="image/svg+xml" data="patio11.svg" id="patio11-svg">
patio11bot
</object>
<div class="user-answer" id="user-answer">
<h2>patio11bot says:</h2>
<p id="user-answer-text"></p>
<br /><br /><br /><br />
<p id="user-answer-source"></p>
<br />
<div id="tweet-button"></div>
<br />
<button class="resetbutton" id="resetbutton" onclick="reset()">
Ask Another Question
</button>
</div>
<div id="user-input">
<input
type="text"
placeholder="What's your question?"
id="question-input"
/>
<br />
<button id="get-answer" onclick="askquestion()">
Get the Answer
</button>
</div>
</div>
<div class="footer">
<p>
made by <a href="https://twitter.com/chrisachard">@chrisachard</a>
</p>
</div>
<script type="text/javascript">
function talkRecurse(mouth, openMouth, n) {
if(n === 0) {
return;
}
openMouth.setAttribute('visibility', 'visible')
mouth.setAttribute('visibility', 'hidden')
setTimeout(function() {
mouth.setAttribute('visibility', 'visible')
openMouth.setAttribute('visibility', 'hidden')
setTimeout(function() {
talkRecurse(mouth, openMouth, n-1)
}, Math.random() * 250)
}, Math.random() * 250)
}
function talk() {
const svg = document.getElementById('patio11-svg')
const svgDoc = svg.contentDocument
const mouth = svgDoc.getElementById("mouth")
const openMouth = svgDoc.getElementById("open-mouth")
talkRecurse(mouth, openMouth, 10)
}
function askquestion() {
document.getElementById("user-answer-text").style.opacity = 0;
setTimeout(function( ) {
document.getElementById("user-answer-text").style.opacity = 1.0;
}, 1000)
document.getElementById("user-input").classList.add("hide-input")
document.getElementById("user-question").classList.add("show-user-question")
document.getElementById("user-answer").classList.add("show-user-answer")
talk()
const question = document.getElementById("question-input").value
document.getElementById("question-input").value = ''
document.getElementById("user-question-text").innerHTML = question
const answer = getAnswer(question)
document.getElementById("user-answer-text").innerHTML = answer.quote
document.getElementById("user-answer-source").innerHTML = "<a href='"+answer.url+"' target='_blank'>see source</a>"
document.getElementById("tweet-button").innerHTML = ' <a href="https://twitter.com/share?ref_src=twsrc%5Etfw" class="twitter-share-button" data-show-count="false" data-size="large" data-via="chrisachard" data-text="patio11bot.com just told me:\n\n'+answer.quote+'\n\nWhat will it tell you?">Tweet</a>'
twttr.widgets.load()
}
function reset() {
document.getElementById("user-input").classList.remove("hide-input")
document.getElementById("user-question").classList.remove("show-user-question")
document.getElementById("user-answer").classList.remove("show-user-answer")
}
</script>
</body>
</html>