-
Notifications
You must be signed in to change notification settings - Fork 14
/
gedrag.js
110 lines (83 loc) · 1.71 KB
/
gedrag.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
$('document').ready(function(){
var codeA = '<li title="&#',
codeB = ';">&#',
codeC = ';</li>',
ixx,
ijump,
ixz,
wW,
wH,
allPaddingHoriz = 30*2,
olTopOffset = 103,
cellSize = 49,
innerSpaceWidth,
innerSpaceHeight,
cellsX,
cellsY,
rT,
urlPath = window.location.href,
urlTest = /#\d+/.test(urlPath),
getNumRegex = /^[^#]*#(\d*).*$/;
if (urlTest){
var getNum = urlPath.replace(getNumRegex, '$1');
ixx = parseInt(getNum, 10);
} else {
ixx = 1;
}
window.location.hash = ixx
var jumpCalc = function(){
wW = $(window).width();
wH = $(window).height();
innerSpaceWidth = wW - allPaddingHoriz;
cellsX = Math.floor(innerSpaceWidth / cellSize);
innerSpaceHeight = wH - olTopOffset;
cellsY = Math.floor(innerSpaceHeight / cellSize);
ijump = cellsX * cellsY - 1;
}
var textify = function(){
ixz = ixx + ijump;
$('.xx').text(ixx);
$('.xy').text(ixz);
$('.xzx').text(ixx-ijump);
$('.xzy').text(ixz+ijump);
if(ixx-ijump >= 0) {
$('a[rel="prev"]').show();
} else {
$('a[rel="prev"]').hide();
}
}
var utf = function(){
var codeF = '';
for (var i = ixx; i <= ixx+ijump; i++){
codeF += codeA + i + codeB + i + codeC;
}
textify();
$('ol').empty().append(codeF);
}
var linkBehavior = function(i, wut){
i.preventDefault();
ixx = ixx + (wut ? ijump : -ijump);
window.location.hash = ixx;
utf();
}
$('a[rel="next"]').click(function(i){
linkBehavior(i, true);
});
$('a[rel="prev"]').click(function(i){
linkBehavior(i, false);
});
$(window).resize(function(){
clearTimeout(rT);
rT = setTimeout(function(){
jumpCalc();
utf();
}, 100)
});
/*
$(window).bind('hashchange', function() {
alert('lala');
});
*/
jumpCalc();
utf();
});