forked from AsJoy/huaban
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommonUserPicture.jsp
More file actions
320 lines (276 loc) · 12 KB
/
commonUserPicture.jsp
File metadata and controls
320 lines (276 loc) · 12 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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
<%@ page language="java" import="java.util.*,com.huaban.model.User" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
/* User u1 = new User();
u1.setId(48);
u1.setUsername("1231wwer");
u1.setPassword("erertqwe");
u1.setSelfpic("http:\\\\www.c.com/48/logo.jpg");
u1.setNickname("吼吼哈嘿");
u1.setMotto("哈哈红黑");
session.setAttribute("u", u1); */
%>
<%@taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<script src="<%=path %>/js/jquery.min.js" ></script>
<script src="<%=path %>/js/html5shiv.min.js"></script>
<link href="<%=path %>/css/bootstrap.min.css" rel="stylesheet" />
<link href="<%=path %>/css/style.css" rel="stylesheet" />
<link rel="shortcut icon" href="<%=path %>/img/logo_ico.ico"/>
<title>个人主页</title>
</head>
<body>
<header id="header">
<nav class="container clearfix">
<a href="#" id="logo"><img src="<%=path %>/img/sy_03.png"/></a>
<ul class="nav-info mynavinfo clearfix">
<li><a href="<%=path %>/index.jsp">首页</a></li>
<li><a href="<%=path %>/User/finduser.action?pager.offset=0">发现</a></li>
<li><a href="#">最新</a></li>
<li class="more"><a href="#">更多</a></li>
</ul>
<form class="col-md-6 fl nav-form" action="<%=path %>/Picture/findpictureList.action">
<div class="form-group has-feedback">
<label class="sr-only" ></label>
<input type="text" class="form-control" name="seachValue" placeholder="输入搜索内容">
<span class="glyphicon glyphicon-search form-control-feedback"></span>
</div>
<input type="hidden" name="pageOffset" value="0"/>
</form>
<s:if test='#session.u==null'>
<div class="myinfo fr">
<a href="<%=path %>/addUser.jsp" class="btn btn-warning" >注册</a>
<a href="#" class="btn btn-info" data-toggle="modal" data-target=".bs-example-modal-sm">登陆</a>
</div>
</s:if>
<s:else>
<div class="btn-group myinfo fr" role="group">
<button type="button" class="self-info dropdown-toggle self-pis-wrapper" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<img class="self-pic" src="${u.selfpic }"/>
</button>
<ul class="dropdown-menu">
<li><a href="<%=path%>/userPicture.jsp"><span class="glyphicon glyphicon-home"></span>我的主页</a></li>
<s:if test="#session.u.type==1">
<li class="divider"></li>
<li><a href="<%=path%>/User/usermanager.action?pager.offset=0"><span class="glyphicon glyphicon-home"></span>用户管理</a></li>
</s:if>
<li class="divider"></li>
<li><a href="<%=path %>/UpdateUser.jsp"><span class="glyphicon glyphicon-edit"></span>修改个人信息</a></li>
<li><a href="<%=path %>/User/userInvalidate.action"><span class="glyphicon glyphicon-cog"></span>注销</a></li>
</ul>
</div>
</s:else>
</nav>
</header>
<article class="container ">
<section class="main">
<div class="myPic">
<img src="${user.selfpic }">
</div>
<div class="username">
<strong style="font-size: 20px;">${user.nickname }</strong>
<p class="comment"><span>个性签名:</span>
<span>${user.motto }</span> </p>
</div>
</section>
<section id="showimg" class="showimgs">
<script id="picInfo" type="text/html">
<div class="oSelfInfo">
<div class="userpic">
<a></a>
</div>
<div class="picDetail clearfix">
<a class="userLogo" href="#"><img src="img/logo.jpg"></a>
<div>
<p class="textOverflow uusername"><a href="userPicture.jsp">牛元强</a>采集到</p>
<p class="textOverflow sPicComment"><a href="#">这里是内容</a></p>
</div>
</div>
</div>
</script>
</section>
</article>
<footer id="loader">
</footer>
<div class="modal fade bs-example-modal-sm " tabindex="-1" role="dialog" aria-labelledby="mySmallModalLabel">
<div class="modal-dialog modal-sm">
<form class="form-horizontal" action="<%=path %>/User/userlogin.action" method="post">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="exampleModalLabel">用户登录</h4>
</div>
<div class="modal-body">
<div class="form-group">
<div class="input-group col-md-10 col-md-offset-1">
<span class="input-group-addon"><span class="glyphicon glyphicon-user"></span></span>
<input type="text" name="username" class="form-control" placeholder="用户名"/>
</div>
</div>
<div class="form-group">
<div class="input-group col-md-10 col-md-offset-1">
<span class="input-group-addon"><span class="glyphicon glyphicon-knight"></span></span>
<input type="password" name="password" class="form-control" placeholder="用户密码"/>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
<button type="submit" class="btn btn-primary">登陆</button>
</div>
</div>
</form>
</div>
</div>
<label class="sr-only" id = "uid"><s:property value="#uid"/></label>
<script src="<%=path %>/js/bootstrap.min.js" ></script>
<script src="<%=path %>/js/respond.min.js"></script>
<!-- 电梯效果插件 -->
<script type="text/javascript" src="<%=path %>/js/elevator.min.js"></script>
<!--瀑布流-->
<script>
var oContainer = $('.container');
var oShowImg = $("#showimg");
var iCells = 0;
//图片宽度
var iWidth = 230;
var iSpace = 20;
//图片的宽度和margin
var iOuterWidth = iWidth + iSpace;
//ajax路径
var sUrl = '<%=path %>/Ajax/commonUserPictureList.action';
//每列的top值
var arrT = [];
//每行对应列的left值
var arrL = [];
var iPageOffset = 0;
var iPagecount = 0;
var iBtn = true;
var svalue = $("#uid").text();
var $selfInfoModel = $("#picInfo");
function setCell() {
iCells = Math.floor($(window).innerWidth()*.96/ iOuterWidth);
if (iCells < 3) {
iCells = 3;
} else if (iCells > 8) {
iCells = 8;
}
//alert(iCells);
var containerWidth = iCells * iOuterWidth+10;
oContainer.css('width', containerWidth);
$(".nav-form").width((containerWidth-($("#logo").width()+$(".self-info").width()+$(".myinfo").width()+$(".mynavinfo").width()))-90);
}
setCell();
for (var i=0; i<iCells; i++) {
arrT[i] = 0;
arrL[i] = iOuterWidth * i;
}
function getData() {
$.getJSON(sUrl, {pageOffset:iPageOffset,svalue:svalue}, function(jData) {
if (!iBtn) {
return ;
}
var pagers = jData.pager;
iPageOffset += pagers.pagerSize;
//console.log(iPageOffset);
iPagecount = pagers.pageCount;
//console.log(iPagecount);
// console.log(pagers.objs);
$.each(pagers.objs,function(index,obj){
//console.log(obj);
var sHtml = $selfInfoModel.html();
var $Str = $(sHtml);
/* */
$Str.find(".userLogo img").attr("src",pagers.url+"/"+obj.user.id + obj.user.selfpic);
$Str.find(".uusername a")
.html(obj.user.nickname)
.attr("href","<%=path %>/Picture/commonUserPicture.action?uid="+obj.user.id);
$Str.find(".uusername a").html($(".username strong").html());
$Str.find(".sPicComment a").html(obj.comment?obj.comment:"尚未发表意见");
var oImg = $('<img />');
//宽高
var iHeight = obj.height * (iWidth / obj.width);
oImg.css({
width : iWidth,
height : iHeight
});
var _index = getMin();
$Str.css({
left : arrL[_index],
top : arrT[_index]
});
arrT[_index] += iHeight + 60+20;
$Str.find(".userpic a").append(oImg);
oShowImg.append($Str);
var objImg = new Image();
objImg.onload = function() {
oImg.attr('src', this.src);
};
objImg.src = pagers.url+obj.name;
setTimeout(function() {
$('#loader').hide();
},500);
iBtn = true;
});
});
}
getData();
/*每次加入一张图片后都要重新计算top最小值的下标*/
function getMin() {
var v = arrT[0];
var _index = 0;
for (var i=1; i<arrT.length; i++) {
if (arrT[i] < v) {
v = arrT[i];
_index = i;
}
}
return _index;
}
$(window).on('scroll', function() {
if (!iBtn) {
return ;
}
if(iPageOffset<iPagecount){
var _index =getMin();
var iH = $(window).scrollTop() + $(window).innerHeight();
if (arrT[_index] + 50 < iH) {
getData();
}
}
});
/* 屏幕变化时 */
function resizeWindow(){
var iLength = iCells;
setCell();
if( iLength== iCells){
return;
}
arrL.length=0;
arrT.length=0;
arrT[0] = $(".toAddImg").height()+20;
arrL[0] = 0;
for (var i=1; i<iCells; i++) {
arrT[i] = 0;
arrL[i] = iOuterWidth * i;
}
var aInfos = oShowImg.find(".oSelfInfo");
$(aInfos).each(function(index){
//console.log(index)
var min_index = getMin();
//alert(arrT)
$(this).animate({top:arrT[min_index],
left:arrL[min_index]},800);
arrT[min_index] += $(this).height() + 20;
});
}
$(window).resize(function(){
resizeWindow();
});
</script>
</body>
</html>