53
53
/*a:hover::after {*/
54
54
/* display: block;*/
55
55
/*}*/
56
+ /* Style the tab */
57
+ .tab {
58
+ overflow : hidden;
59
+ border : 1px solid # ccc ;
56
60
61
+ /*background-color: #f1f1f1;*/
62
+ }
63
+
64
+ /* Style the buttons inside the tab */
65
+ .tab button {
66
+ text-align : center;
67
+ background-color : inherit;
68
+ float : inherit;
69
+ border : none;
70
+ outline : none;
71
+ cursor : pointer;
72
+ padding : 14px 16px ;
73
+ transition : 0.3s ;
74
+ font-size : 17px ;
75
+ }
76
+
77
+ /* Change background color of buttons on hover */
78
+ .tab button : hover {
79
+ background-color : # ddd ;
80
+ }
81
+
82
+ /* Create an active/current tablink class */
83
+ .tab button .active {
84
+ background-color : # ccc ;
85
+ }
86
+
87
+ /* Style the tab content */
88
+ .tabcontent {
89
+ display : none;
90
+ padding : 6px 12px ;
91
+ border : 1px solid # ccc ;
92
+ border-top : none;
93
+ }
57
94
</ style >
58
95
</ head >
59
96
< body >
@@ -71,11 +108,23 @@ <h2>本站数据库<b><a style="text-decoration: none;color: skyblue" href="http
71
108
</ label >
72
109
< input type ="submit " value ="搜索 ">
73
110
</ form >
74
- < hr >
111
+ < br >
75
112
< div id ="tv ">
76
113
< h2 > 大家都在看……</ h2 >
114
+ < div class ="tab ">
115
+ < button class ="tablinks " onclick ="openCity(event, 'US') "> 美剧</ button >
116
+ < button class ="tablinks " onclick ="openCity(event, 'JP') "> 日剧</ button >
117
+ </ div >
118
+
119
+
120
+ < div id ="US " class ="tabcontent ">
121
+ </ div >
122
+
123
+ < div id ="JP " class ="tabcontent ">
124
+ </ div >
125
+
77
126
</ div >
78
- < hr >
127
+
79
128
< h2 > 相关资源</ h2 >
80
129
< h3 >
81
130
联系我 < a style ="text-decoration: none;color: green " href ="https://t.me/BennyThink "> Benny 小可爱</ a > ・
@@ -107,19 +156,43 @@ <h3>
107
156
108
157
function showTop ( data ) {
109
158
110
- let div = document . getElementById ( "tv" ) ;
111
159
for ( let i = 0 ; i < data . length ; i ++ ) {
112
160
let info = data [ i ] . data . info
161
+ console . log ( info . area )
162
+ let div = HTMLElement
163
+
164
+ if ( info . area === "美国" ) {
165
+ div = document . getElementById ( "US" ) ;
166
+ } else if ( info . area === "日本" ) {
167
+ div = document . getElementById ( "JP" ) ;
168
+ }
113
169
let name = `${ info . cnname } ${ info . enname } ${ info . aliasname } ` ;
114
170
let html = `<h4><a title="浏览量 ${ info . views } " style="text-decoration: none;color: cornflowerblue" href="/resource.html?id=${ info . id } ">${ name } </a></h4>` ;
115
171
let backup = div . innerHTML ;
116
172
div . innerHTML = backup + html ;
117
173
118
174
}
119
-
175
+ a = document . getElementById ( "US" ) ;
176
+ document . getElementsByClassName ( "tab" ) [ 0 ] . firstElementChild . className += " active"
177
+ a . style . display = "block"
120
178
}
121
179
122
180
accessMetrics ( ) ;
123
181
182
+ function openCity ( evt , cityName ) {
183
+ var i , tabcontent , tablinks ;
184
+ tabcontent = document . getElementsByClassName ( "tabcontent" ) ;
185
+ for ( i = 0 ; i < tabcontent . length ; i ++ ) {
186
+ tabcontent [ i ] . style . display = "none" ;
187
+ }
188
+ tablinks = document . getElementsByClassName ( "tablinks" ) ;
189
+ for ( i = 0 ; i < tablinks . length ; i ++ ) {
190
+ tablinks [ i ] . className = tablinks [ i ] . className . replace ( " active" , "" ) ;
191
+ }
192
+ document . getElementById ( cityName ) . style . display = "block" ;
193
+ console . log ( evt )
194
+ evt . currentTarget . className += " active" ;
195
+ }
196
+
124
197
</ script >
125
198
</ html >
0 commit comments