Skip to content

Commit 46815aa

Browse files
author
Yener
committed
add
1 parent fbcdbea commit 46815aa

File tree

10 files changed

+295
-1
lines changed

10 files changed

+295
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
思知问答机器人
44

55

6-
过两天提交。。。
6+
机器人开放api暂时不能使用,过两天抽空修复。。。

css/index.css

+161
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,161 @@
1+
@CHARSET "UTF-8";
2+
a:link {
3+
color: #fff;
4+
text-decoration: none;
5+
}
6+
a:visited {
7+
text-decoration: none;
8+
color: #fff;
9+
}
10+
a:hover {
11+
text-decoration: none;
12+
color: #fff;
13+
}
14+
a:active {
15+
text-decoration: none;
16+
color: #fff;
17+
}
18+
19+
* {
20+
margin: 0;
21+
padding: 0;
22+
}
23+
24+
body {
25+
font-size: 12px;
26+
font-family: "微软雅黑";
27+
background: url(../img/bg.jpg) no-repeat;
28+
width: 100%;
29+
height: 100vh;
30+
background-size: cover;
31+
}
32+
33+
#top {
34+
width: 100%;
35+
height: 60px;
36+
background: rgba(15, 25, 50, 0.3);
37+
color: #fff;
38+
line-height: 60px;
39+
text-align: center;
40+
font-size: 30px;
41+
}
42+
43+
#box {
44+
width: 800px;
45+
height: 600px;
46+
background: rgba(255, 255, 255, .5);
47+
margin: 100px auto 0;
48+
}
49+
50+
.b-head {
51+
width: 100%;
52+
height: 60px;
53+
background-color: #4CAF50;
54+
}
55+
56+
.h-img {
57+
margin: 0 20px;
58+
float: left;
59+
user-select: none;
60+
}
61+
62+
.h_span {
63+
color: #fff;
64+
font-size: 18px;
65+
line-height: 60px;
66+
float: left;
67+
user-select: none;
68+
cursor: default;
69+
}
70+
71+
.b-body {
72+
width: 100%;
73+
height: 420px;
74+
overflow: auto;
75+
margin: 20px 0;
76+
}
77+
78+
.rotWord,.mWord{
79+
width: 100%;
80+
margin-top: 10px;
81+
overflow: hidden;
82+
}
83+
84+
.rotWord span {
85+
background: url(../img/rot.png);
86+
height: 40px;
87+
width: 40px;
88+
margin-left: 20px;
89+
float: left;
90+
}
91+
92+
.rotWord p {
93+
word-break: break-all;
94+
top: 4px;
95+
float: left;
96+
color: #fff;
97+
font-size: 14px;
98+
margin-left: 10px;
99+
padding: 10px;
100+
line-height: 24px;
101+
background: rgba(0, 0, 255, .5);
102+
border-radius: 6px;
103+
max-width: 220px;
104+
}
105+
106+
.mWord span {
107+
background: url(../img/my.png);
108+
height: 40px;
109+
width: 40px;
110+
float: right;
111+
margin-right: 20px;
112+
}
113+
114+
.mWord p {
115+
word-break: break-all;
116+
top: 2px;
117+
float: right;
118+
color: #fff;
119+
font-size: 14px;
120+
margin-right: 10px;
121+
padding: 10px;
122+
line-height: 24px;
123+
background: #19b955;
124+
border-radius: 6px;
125+
max-width: 220px;
126+
}
127+
128+
.b-footer {
129+
width: 760px;
130+
height: 60px;
131+
margin: 0 20px;
132+
font-size: 16px;
133+
color: #666;
134+
}
135+
136+
#f-left {
137+
padding-left: 20px;
138+
outline: none;
139+
overflow: hidden;
140+
width: 620px;
141+
height: 60px;
142+
float: left;
143+
background: rgba(0, 0, 0, .1);
144+
font-size: 18px;
145+
border: none;
146+
border-radius: 5px;
147+
}
148+
149+
#btn {
150+
width: 100px;
151+
height: 60px;
152+
background: #666666;
153+
float: right;
154+
cursor: pointer;
155+
text-align: center;
156+
line-height: 60px;
157+
font-size: 18px;
158+
color: #fff;
159+
user-select: none;
160+
border-radius: 10px;
161+
}

img/bg.jpg

167 KB
Loading

img/ico.png

4.6 KB
Loading

img/logo.png

3.01 KB
Loading

img/my.png

4.01 KB
Loading

img/rot.png

3.85 KB
Loading

index.html

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta charset="utf-8" />
5+
<title>思知机器人</title>
6+
<meta name="Keywords" content="思知,思知机器人,智能时代·你我同在">
7+
<meta name="Description" content="这是一个幻想主义者的理想国,作者时刻关注着人工智能的动态,希望有一天能够出现独立思考的人工智能机器人。虽然作者明知道短期内不可能实现,但却一直向着他的梦执着前行着。">
8+
<link rel="stylesheet" type="text/css" href="css/index.css"/>
9+
<link rel="shortcut icon" href="img/ico.png">
10+
<script src="js/jquery-1.11.1.min.js" type="text/javascript" charset="utf-8"></script>
11+
12+
<body>
13+
<div id="top"><a href="https://www.ownthink.com/"target="_blank">Powered by OwnThink </a></div>
14+
<div id="box">
15+
<div class="b-head">
16+
<img class="h-img" alt="" src="img/logo.png" width=80; height=60;/>
17+
<span class="h_span">人工智能机器人</span>
18+
</div>
19+
<div class="b-body">
20+
<div class="rotWord">
21+
<span></span>
22+
<p>嗨,最近想我没有?</p>
23+
</div>
24+
</div>
25+
<div class="b-footer">
26+
<input type="text" name="text" id="f-left" />
27+
<div id="btn">发送</div>
28+
</div>
29+
</div>
30+
<script src="js/bot.js" type="text/javascript" charset="utf-8"></script>
31+
</body>
32+
</html>

js/bot.js

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
2+
var text = $("#f-left");
3+
text.focus();
4+
function action()
5+
{
6+
if(text.val()==null||text.val()=="")
7+
{
8+
text.focus();
9+
return;
10+
}
11+
12+
$(".b-body").append("<div class='mWord'><span></span><p>" + text.val() + "</p></div>");
13+
$(".b-body").scrollTop(10000000);
14+
15+
var args= {
16+
type : "get",
17+
url:"https://api.ownthink.com/bot/query",
18+
data : {"key" : "openapi", "info" : text.val()},
19+
success : function(redata)
20+
{
21+
var result = $.parseJSON(redata).text;
22+
$(".b-body").append("<div class='rotWord'><span></span> <p id='member'>" + result + "</p></div>");
23+
$(".b-body").scrollTop(10000000);
24+
}
25+
}
26+
27+
ajax(args);
28+
text.val("");
29+
text.focus();
30+
31+
};
32+
33+
$("#btn").click(function()
34+
{
35+
action();
36+
});
37+
$(document).keydown(function(event)
38+
{
39+
if(event.keyCode==13)
40+
{
41+
action();
42+
}
43+
});
44+
45+
function ajax(mJson)
46+
{
47+
var type=mJson.type||'get';
48+
var url=mJson.url;
49+
var data=mJson.data;
50+
var success=mJson.success;
51+
var error=mJson.error;
52+
var dataStr='';
53+
54+
if(data)
55+
{
56+
var arr = Object.keys(data);
57+
var len = arr.length;
58+
var i = 0;
59+
60+
for (var key in data)
61+
{
62+
dataStr+=key+'='+data[key];
63+
64+
if (++i<len)
65+
{
66+
dataStr+='&';
67+
}
68+
}
69+
70+
if(type.toLowerCase()=='get')
71+
{
72+
url+='?'+dataStr;
73+
}
74+
}
75+
76+
console.log(url);
77+
78+
var xhr=new XMLHttpRequest();
79+
xhr.open(type,url,true);
80+
xhr.setRequestHeader('content-type' , 'application/x-www-form-urlencoded');
81+
xhr.send(null);
82+
83+
xhr.onreadystatechange=function()
84+
{
85+
if(xhr.readyState==4)
86+
{
87+
if(xhr.status>=200&&xhr.status<300)
88+
{
89+
success&&success(xhr.responseText);
90+
}
91+
else
92+
{
93+
error&&error(xhr.status);
94+
}
95+
}
96+
}
97+
}

js/jquery-1.11.1.min.js

+4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)