-
Notifications
You must be signed in to change notification settings - Fork 0
/
step.js
162 lines (151 loc) · 5.54 KB
/
step.js
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
/**
* bilibili 弹幕查询
* @author Shaffer John
* @date 2016-2-23 11:40:36
* @version 1.0.0
*/
/**
* CSS3 答题卡翻页效果 jQuery Transit
* @authors Candice <[email protected]>
* @date 2016-9-27 15:30:18
* @version 1.0.8
*/
$.fn.stepSheet = function (options)
{
var defaults = {
mold : 'card',
};
var opts = $.extend({}, defaults, options);
return $(this).each(function () {
var obj = $(this).find('.card_cont');
var _length = obj.length, _b = _length - 1, _len = _length - 1, _cont = '.card_cont';
for (var a = 1; a <= _length; a++) {
obj.eq(_b).css({
'z-index' : a
});
_b -= 1;
}
$(this).show();
if (opts.mold == 'card')
{
$('#step1').click(function ()
{
var video_url = $("#search-keyword").val();
var table = $("#table");
var check=video_url.split("/");
for (var i = check.length - 1; i >= 0; i--) {
if(check[i].indexOf('av') >= 0 && !isNaN(parseInt(check[i].replace('av','')))){
var av = check[i].replace('av','');
console.log('av',av);
}
};
$.ajax({
type : "GET",
url : 'api.php?av='+av,
dataType : "json",
success : function(json) {
var len = json.length;
for (var i = 0; i < len; i++) {
var data = json[i]['p'].split(',');
var time = formatSeconds(data[0]).toString();
var userHash = data[6].toString();
var html = '<tr><td class="p50">'+json[i]['#text']+'</td><td class="p25">'+time+'</td><td class="p25"><a class="hash_'+userHash+'" href="javascript:;" target="_blank" onclick="getUser(\''+userHash+'\');return false;">查询</a></td></tr>'
table.append(html);
};
$("#tbody").show();
$("#message").hide();
},
error : function(jqXHR) {
$("#tbody").html('视频cid获取失败,可能视频被删了,也可能服务器出了点小差...请联系站长~')
}
});
});
obj.find('.search-submit').click(function ()
{
var _idx = $(this).parents(_cont).index(), _cards = obj, _cardcont = $(this).parents(_cont);
if (_idx == _len) {
return;
}
else
{
setTimeout(function ()
{
_cardcont.addClass('cardn');
setTimeout(function ()
{
_cards.eq(_idx + 3).addClass('card3');
_cards.eq(_idx + 2).removeClass('card3').addClass('card2');
_cards.eq(_idx + 1).removeClass('card2').addClass('card1');
_cardcont.removeClass('card1');
}, 200);
}, 100);
}
});
$('.card_bottom').find('.prev').click(function ()
{
var _idx = $(this).parents(_cont).index(), _cardcont = $(this).parents(_cont);
obj.eq(_idx + 2).removeClass('card3').removeClass('cardn');
obj.eq(_idx + 1).removeClass('card2').removeClass('cardn').addClass('card3');
obj.eq(_idx).removeClass('card1').removeClass('cardn').addClass('card2');
setTimeout(function ()
{
obj.eq(_idx - 1).addClass('card1').removeClass('cardn');
}, 200);
});
$('.card_bottom').find('.next').click(function ()
{
var _idx = $(this).parents(_cont).index(), _cards = obj, _cardcont = $(this).parents(_cont);
if (_idx == _len) {
return;
}
else
{
setTimeout(function ()
{
_cardcont.addClass('cardn');
setTimeout(function ()
{
_cards.eq(_idx + 3).addClass('card3');
_cards.eq(_idx + 2).removeClass('card3').addClass('card2');
_cards.eq(_idx + 1).removeClass('card2').addClass('card1');
_cardcont.removeClass('card1');
}, 200);
}, 100);
}
});
}
});
function formatSeconds(second) {
var sec = parseInt(second);
var min = 0;
var hour = 0;
var result = "";
if(sec >= 60) {
min = parseInt(sec/60);
sec = parseInt(sec%60);
if(min > 60) {
hour = parseInt(min/60);
min = parseInt(min%60);
}
}
if(hour) result = hour+":"+f(min)+":"+f(sec);
else result = f(min)+":"+f(sec);
return result;
}
function f(s) {
return s < 10 ? '0' + s: s;
}
};
function getUser(hash){
var hash = hash.toString();
var midcrc = new BiliBili_midcrc();
var result = midcrc(hash);
var obj = $(".hash_"+hash);
if (result){
obj.text('已查到');
obj.removeAttr('onclick');
obj.attr('href','http://space.bilibili.com/'+result);
}else{
obj.text('用户不存在');
}
}