-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathblizzard.ejs
250 lines (239 loc) · 9.91 KB
/
blizzard.ejs
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
<%- include header %>
<style type="text/css">
.yellow {
background: yellow;
}
.green {
background: green;
}
.orange {
background: orange;
}
.blue {
background: rgba(0,0,255, 1);
}
.white {
background: white;
}
.equip{
border: 1px solid #ccc;
display: inline-block;
}
.act-wrapper{
width: 25%;
float: left;
display: inline-block;
vertical-align: top;
cursor: pointer;
}
.clear {
clear: both;
}
.margin-b-10{
margin-bottom: 10px;
}
.img{
width: 64px;
height: 64px;
}
</style>
<% var util_name = {'life': '生命值', 'damage': '面板伤害', 'attackSpeed': '攻击速度', 'armor': '护甲', 'strength': '力量', 'dexterity': '敏捷', 'vitality' : '体能', 'intelligence': '智力', 'physicalResist': '物理抗性', 'fireResist': '火焰抗性', 'coldResist': '冰寒抗性', 'lightningResist': '电击抗性', 'poisonResist': '毒素抗性', 'arcaneResist': '秘法抗性', 'thorns': '反弹伤害', 'lifeSteal': '生命偷取', 'lifePerKill': '击杀回复', 'lifeOnHit': '击中回复', 'goldFind': '金币获取率', 'magicFind': '魔法装备获取率'} %>
<div class="row margin-b-10">
<div class="col-md-6">
<div class="input-group">
<input type="text" class="form-control" placeholder="输入战网BattleLag,例如:Jone-8888" ></input>
<span class="input-group-btn">
<button class="btn btn-default search-btn" type="button">查询</button>
</span>
</div>
</div>
</div>
<% if(data){ %>
<table class=" table table-bordered table-striped table-hover">
<thead>
<tr>
<td>名字</td>
<td>等级</td>
<td>性别</td>
<td>职业</td>
<td>最后登录时间</td>
</tr>
</thead>
<tbody>
<% data.heroes.forEach(function(i){ %>
<tr data-target="<%= '.heroes' + i.id %>" data-toggle="collapse" data-parent="#collapseHeader">
<td><%= i.name %></td>
<td><%= i.level %></td>
<td><%= i.gender == 0 ? '男' : '女' %></td>
<td><%= i.class %></td>
<td><%= new Date(i['last-updated']*1000 + 8*60*60*1000).toISOString().slice(0, 19).replace('T', ' ') %></td>
</tr>
<% }) %>
</tbody>
</table>
<ul class="nav nav-pills">
<% data.heroes.forEach(function(i){ %>
<li><a data-toggle="tab" href="<%= '#heroes' + i.id %>"><%= i.name %></a></li>
<% }) %>
</ul>
<div class="tab-content">
<% for(var i in data.heroesData){ %>
<% j = data.heroesData[i] %>
<div id="<%= 'heroes' + j.id %>" class="tab-pane row">
<div class="col-md-8">
<table class="table table-bordered table-striped table-hover ">
<tr>
<td>ID</td>
<td><%= j.id %></td>
</tr>
<tr>
<td>角色名称</td>
<td><%= j.name %></td>
</tr>
<tr>
<td>等级</td>
<td><%= j.level %></td>
</tr>
<tr>
<td>技能</td>
<td>
<table class="table table-bordered">
<tr>
<td>鼠标左键</td>
<td>鼠标右键</td>
<td>数字键1</td>
<td>数字键2</td>
<td>数字键3</td>
<td>数字键4</td>
</tr>
<tr>
<% j.skills.active.forEach(function(k, l){ %>
<td>
<% if (k.skill){ %>
<img class="img_hover img-64" data-toggle="popover" data-title="<h4 style='color:blue;'><%= k.skill.name %></h4>" data-content="解锁等级:<%= k.skill.level %><br>技能效果:<em style='color: green;'><%= k.skill.description %></em><br><br><strong><%= k.rune ? ('符文:' + k.rune.name + '<br>效果:' + k.rune.description ) : ''%></strong>" data-html="true" src="<%= 'http://us.media.blizzard.com/d3/icons/skills/64/' + k.skill.icon + '.png' %>" data-placement="top" data-trigger="hover"/>
<% } %>
</td>
<% }) %>
</tr>
</table>
</td>
</tr>
<tr>
<td>被动技能</td>
<td>
<% j.skills.passive.forEach(function(k, l){ %>
<% if (k.skill){ %>
<img class="img_hover img-64" data-toggle="popover" data-title="<h4 style='color:blue;'><%= k.skill.name %></h4>" data-content="解锁等级:<%= k.skill.level %><br>技能效果:<em style='color: green;'><%= k.skill.description %></em><br>品味:<%= k.skill.flavor %>" data-html="true" src="<%= 'http://us.media.blizzard.com/d3/icons/skills/64/' + k.skill.icon + '.png' %>" data-placement="top" data-trigger="hover"/>
<% } %>
<% }) %>
</td>
</tr>
<tr>
<td>角色装备</td>
<td>
<% for(var m in j.items){ %>
<% if(j.items[m].id){ %>
<div class="<%= j.items[m].displayColor %> equip" >
<img class="img_hover equip_img img-64" item-data="<%= j.items[m].tooltipParams %>" data-title="<h4 style='color:<%= j.items[m].displayColor %>;text-shadow:0 1px 1px rgba(0,0,0,0.5);'><%= j.items[m].name %></h4>" data-html="true" data-content="查看详情请点击图片加载!" data-placement="top" data-trigger="hover" src="<%= 'http://us.media.blizzard.com/d3/icons/items/large/' + j.items[m].icon + '.png' %>" />
</div>
<% } %>
<% } %>
</td>
</tr>
<tr>
<td>精英击杀数</td>
<td><%= j.kills.elites %></td>
</tr>
<tr>
<td>游戏进度</td>
<td>
<% for(var o in j.progress.normal){ %>
<div class="act-wrapper panel <%= j.progress.normal[o].completed ? 'panel-success': 'panel-danger' %>">
<div class="panel-heading" data-toggle="collapse" data-target=".<%= o %>">
<%={'act1': '第一章', 'act2': '第二章', 'act3': '第三章', 'act4': '第四章'}[o] %>
</div>
<ul class="list-group <%= o %> collapse ">
<% j.progress.normal[o].completedQuests.forEach(function(p){ %>
<li class="list-group-item"><%= p.name %></li>
<% }) %>
</ul>
</div>
<% } %>
<div class="clear"></div>
</table>
</td>
</tr>
</table>
</div>
<div class="col-md-4">
<table class="table table-striped table-bordered">
<% for(var n in j.stats){ %>
<% if(util_name[n]){ %>
<tr>
<td><%= util_name[n] %></td>
<td><%= j.stats[n] %></td>
</tr>
<% } %>
<% } %>
</table>
</div>
</div>
<% } %>
</div>
<% }else{ %>
<div class="alert alert-danger alert-dismissable"><button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>抱歉!未找到对应用户信息,<a class="alert-link" href="/blizzard">默认用户</a></div>
<% } %>
<%- include footer %>
<script type="text/javascript">
$('.img_hover').popover();
$('.equip_img').click(function(){
var $dom = $(this);
if($dom.hasClass('loaded') || $dom.hasClass('loading')) {
$dom.popover('show');
return;
}
$dom.attr('data-content', '加载中...').addClass('loading');
$dom.popover('show');
//获取装备详细信息
$.ajax({
url: '/blizzard/item?data='+ $dom.attr('item-data'),
type: 'GET',
dataType: 'json',
success: function(res){
console.log(res);
var html = '装备类型:<span style="color: ' + res.displayColor + '; text-shadow: 0 1px 1px #ccc;">' + res.typeName + '</span><br>' +
(res.dps ? 'DPS:<strong style="color: #ff472f; text-shadow: 0 1px 1px rgba(1,1,1, 0.3);">' + Math.round(res.dps.max *10)/10 + '</strong><br>': '') +
(res.minDamage ? '攻击区间:<strong style="text-shadow: 0 1px 1px rgba(1,1,1, 0.3);">' + Math.round(res.minDamage.max *10)/10 + '-' + Math.round(res.maxDamage.max *10)/10 + '</strong><br>': '') +
(res.attacksPerSecond ? '每秒攻击次数:<strong style="text-shadow: 0 1px 1px rgba(1,1,1, 0.3);">' + Math.round(res.attacksPerSecond.max *100)/100 + '</strong><br>': '') +
(res.armor ? '护甲:<strong style="color: #fc2609;">' + res.armor.max + '</strong><br>': '') +
(res.attributes.length > 0 ? '属性:' + attr(res.attributes) + '<br>' : '') +
'装备等级:' + res.itemLevel + '<br>' +
'解锁等级:' + res.requiredLevel + '<br>';
$dom.attr('data-content', html).addClass('loaded').removeClass('loading');
$dom.popover('show');
},
error: function(){
$dom.attr('data-content', '加载失败,请点击重新加载~').removeClass('loading');
$dom.popover('show');
}
})
});
//装备属性渲染
function attr(data){
if(data.length == 0) return '';
var result = '';
data.forEach(function(i){
var m = i.split(' ');
m.forEach(function(j, k){
if(/[0-9]\d*/.exec(j)){
m[k] = '<em style="color: #9046ca;">' + j + '</em>';
}
});
result += m.join(' ') + '<br>';
});
return '<div style="display: inline-block; vertical-align: text-top; width: 200px; color: #5959e2;">' + result + '</div>';
}
$('.search-btn').click(function(){
window.location.href = 'blizzard?lag=' + $(this).parent().siblings('input').val();
});
</script>