header_search.jsp
6.98 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
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ include file="/WEB-INF/jsp/include/taglib.jsp" %>
<%--添加此行消除额外空格--%>
<%@ page trimDirectiveWhitespaces="true" %>
<%--添加此行消除额外空格--%>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="renderer" content="webkit">
<title>辞海-${param.pageTitle}</title>
<link rel="stylesheet" href="/static/css/vendor.css">
<%--<link rel="stylesheet" href="/static/css/index.css">--%>
<script src="/static/js/plugins/jquery.min.js"></script>
<script src="/static/js/plugins/validator/jquery.validator.js"></script>
<script src="/static/js/vendor.js" merge="true"></script>
<script src="/static/js/backend.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script>
$(function () {
backEndApp.init();
var index;
$('.j_search_form').ajaxSubmitForm({
before: function () {
index = layer.load(2, 5000);
},
success: function ($form, data) {
if (data.code === "OK") {
location.href = '/word/' + data.data.wordId;
}
else {
$.tip(data.message);
layer.close(index);
}
},
});
$('.j_search_image').change(function () {
var $this = $(this);
var $form = $this.closest('form');
if ($this.val() == null) {
return;
}
index = layer.load(2, 10000);
$.ajax({
url: '/image/search',
type: 'POST',
data: new FormData($form[0]),
cache: false,
contentType: false,
processData: false,
xhr: function () {
var myXhr = $.ajaxSettings.xhr();
if (myXhr.upload) {
// For handling the progress of the upload
myXhr.upload.addEventListener('progress', function (e) {
if (e.lengthComputable) {
$('progress').attr({
value: e.loaded,
max: e.total,
});
}
}, false);
}
return myXhr;
},
success: function (data) {
if (data.code === "OK") {
location.href = '/word/' + data.data.wordId;
}
else {
$.tip(data.message);
layer.close(index);
}
},
error: function () {
layer.close(index);
},
});
});
$('.album-alert .album-swiper .swiper-slide img').each(function () {
var $img = $(this);
var imgSrc = $img.attr("src");
getImageWidth(imgSrc, function (w, h) {
console.log({width: w, height: h});
if (w > h) {
$img.css('width', '100%')
.css('position', 'absolute')
.css('top', '50%')
.css('transform', 'translateY(-50%)');
$img.parent().css('position', 'relative');
}
else {
$img.css('height', '100%').css('margin', 'auto');
}
});
});
function getImageWidth(url, callback) {
var img = new Image();
img.src = url;
// 如果图片被缓存,则直接返回缓存数据
if (img.complete) {
callback(img.width, img.height);
} else {
// 完全加载完毕的事件
img.onload = function () {
callback(img.width, img.height);
}
}
}
})
</script>
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="/">
<img src="/static/images/index.png">
</a>
</div>
<div class="navbar-collapse">
<form class="navbar-form clearfix j_search_form" method="GET" action="/home/search">
<div class="form-group input-group-lg">
<input class="form-control" type="text" placeholder="辞海云" name="keyword">
<button class="btn navbar-search-camera" type="button">
<div class="icon icon-camera">
<input name="image" type="file" class="j_search_image" style="opacity: 0;width: 100%;"
accept=".png, .jpg, .jpeg">
</div>
<div class="icon icon-voice2"></div>
</button>
<%--<button class="btn navbar-search-microphone" type="button">--%>
<%--<div class="icon icon-microphone"></div>--%>
<%--</button>--%>
</div>
<button class="btn btn-inverse btn-lg" type="submit">进入词条</button>
<button class="btn btn-default btn-lg" type="submit">搜索词条</button>
<a class="btn btn-link btn-lg" type="button">搜索助手
<span class="icon icon-help"></span>
</a>
<div class="navbar-main-list">
<span class="icon icon-search-tag"></span>
<a href="#">语词</a>
<a href="#">哲学</a>
<a href="#">社会</a>
<a href="#">民族</a>
<a href="#">历史</a>
<a href="#">地理</a>
<a href="#">文学</a>
<a href="#">艺术</a>
<a href="#">生命</a>
<a href="#">农业</a>
<a href="#">医学</a>
<a href="#">科技</a>
</div>
</form>
<%--<ul class="nav navbar-nav navbar-right">--%>
<%--<li>--%>
<%--<a class="btn btn-primary" href="#">登录</a>--%>
<%--</li>--%>
<%--<li>--%>
<%--<a class="btn btn-default" href="#">注册</a>--%>
<%--</li>--%>
<%--</ul>--%>
</div>
</div>
</nav>