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
| var TOTAL_PAGE = 15;
var pages = _.range(1, TOTAL_PAGE + 1);
_.each(_.range(6, 10 + 1), function (foldnum) {
console.log('当显示槽位个数为' + foldnum + '时,每一页的折叠显示如下:');
_.times(TOTAL_PAGE, function (index) {
console.log(++index, foldpages(pages, index, foldnum));
});
console.log('\n');
});
// =============================================
// OUTPUT
// =============================================
/**
当显示槽位个数为6时,每一页的折叠显示如下:
1 ["1", 2, 3, 4, "…", 15]
2 [1, "2", 3, 4, "…", 15]
3 [1, 2, "3", 4, "…", 15]
4 [1, 2, 3, "4", "…", 15]
5 [1, "…", 4, "5", "…", 15]
6 [1, "…", 5, "6", "…", 15]
7 [1, "…", 6, "7", "…", 15]
8 [1, "…", 7, "8", "…", 15]
9 [1, "…", 8, "9", "…", 15]
10 [1, "…", 9, "10", "…", 15]
11 [1, "…", 10, "11", "…", 15]
12 [1, "…", 11, "12", "…", 15]
13 [1, "…", 12, "13", 14, 15]
14 [1, "…", 12, 13, "14", 15]
15 [1, "…", 12, 13, 14, "15"]
当显示槽位个数为7时,每一页的折叠显示如下:
1 ["1", 2, 3, 4, 5, "…", 15]
2 [1, "2", 3, 4, 5, "…", 15]
3 [1, 2, "3", 4, 5, "…", 15]
4 [1, 2, 3, "4", 5, "…", 15]
5 [1, "…", 4, "5", 6, "…", 15]
6 [1, "…", 5, "6", 7, "…", 15]
7 [1, "…", 6, "7", 8, "…", 15]
8 [1, "…", 7, "8", 9, "…", 15]
9 [1, "…", 8, "9", 10, "…", 15]
10 [1, "…", 9, "10", 11, "…", 15]
11 [1, "…", 10, "11", 12, "…", 15]
12 [1, "…", 11, "12", 13, 14, 15]
13 [1, "…", 11, 12, "13", 14, 15]
14 [1, "…", 11, 12, 13, "14", 15]
15 [1, "…", 11, 12, 13, 14, "15"]
当显示槽位个数为8时,每一页的折叠显示如下:
1 ["1", 2, 3, 4, 5, 6, "…", 15]
2 [1, "2", 3, 4, 5, 6, "…", 15]
3 [1, 2, "3", 4, 5, 6, "…", 15]
4 [1, 2, 3, "4", 5, 6, "…", 15]
5 [1, 2, 3, 4, "5", 6, "…", 15]
6 [1, "…", 4, 5, "6", 7, "…", 15]
7 [1, "…", 5, 6, "7", 8, "…", 15]
8 [1, "…", 6, 7, "8", 9, "…", 15]
9 [1, "…", 7, 8, "9", 10, "…", 15]
10 [1, "…", 8, 9, "10", 11, "…", 15]
11 [1, "…", 9, 10, "11", 12, "…", 15]
12 [1, "…", 10, 11, "12", 13, 14, 15]
13 [1, "…", 10, 11, 12, "13", 14, 15]
14 [1, "…", 10, 11, 12, 13, "14", 15]
15 [1, "…", 10, 11, 12, 13, 14, "15"]
当显示槽位个数为9时,每一页的折叠显示如下:
1 ["1", 2, 3, 4, 5, 6, 7, "…", 15]
2 [1, "2", 3, 4, 5, 6, 7, "…", 15]
3 [1, 2, "3", 4, 5, 6, 7, "…", 15]
4 [1, 2, 3, "4", 5, 6, 7, "…", 15]
5 [1, 2, 3, 4, "5", 6, 7, "…", 15]
6 [1, "…", 4, 5, "6", 7, 8, "…", 15]
7 [1, "…", 5, 6, "7", 8, 9, "…", 15]
8 [1, "…", 6, 7, "8", 9, 10, "…", 15]
9 [1, "…", 7, 8, "9", 10, 11, "…", 15]
10 [1, "…", 8, 9, "10", 11, 12, "…", 15]
11 [1, "…", 9, 10, "11", 12, 13, 14, 15]
12 [1, "…", 9, 10, 11, "12", 13, 14, 15]
13 [1, "…", 9, 10, 11, 12, "13", 14, 15]
14 [1, "…", 9, 10, 11, 12, 13, "14", 15]
15 [1, "…", 9, 10, 11, 12, 13, 14, "15"]
当显示槽位个数为10时,每一页的折叠显示如下:
1 ["1", 2, 3, 4, 5, 6, 7, 8, "…", 15]
2 [1, "2", 3, 4, 5, 6, 7, 8, "…", 15]
3 [1, 2, "3", 4, 5, 6, 7, 8, "…", 15]
4 [1, 2, 3, "4", 5, 6, 7, 8, "…", 15]
5 [1, 2, 3, 4, "5", 6, 7, 8, "…", 15]
6 [1, 2, 3, 4, 5, "6", 7, 8, "…", 15]
7 [1, "…", 4, 5, 6, "7", 8, 9, "…", 15]
8 [1, "…", 5, 6, 7, "8", 9, 10, "…", 15]
9 [1, "…", 6, 7, 8, "9", 10, 11, "…", 15]
10 [1, "…", 7, 8, 9, "10", 11, 12, "…", 15]
11 [1, "…", 8, 9, 10, "11", 12, 13, 14, 15]
12 [1, "…", 8, 9, 10, 11, "12", 13, 14, 15]
13 [1, "…", 8, 9, 10, 11, 12, "13", 14, 15]
14 [1, "…", 8, 9, 10, 11, 12, 13, "14", 15]
15 [1, "…", 8, 9, 10, 11, 12, 13, 14, "15"]
*/
|