@@ -30,9 +30,7 @@ <h2 class="smaller center" style="font-size: 5.5vh">Add server</h2>
30
30
</ div >
31
31
</ div >
32
32
33
- < div id ="searchBox " class ="supercenter dragscroll "; style ="width: 127vh ">
34
- < div style ="height: 4.5% "> </ div >
35
- </ div >
33
+ < div id ="searchBox " class ="supercenter dragscroll "; style ="width: 127vh "> </ div >
36
34
37
35
< div class ="epicbox supercenter gs " style ="width: 126vh; height: 80%; pointer-events: none "> </ div >
38
36
@@ -48,6 +46,14 @@ <h1 class="pre" id="header">GD Private Servers</h1>
48
46
< img class ="spin noSelect " src ="../assets/loading.png " height ="105% ">
49
47
</ div >
50
48
49
+ < div style ="position: absolute; left: 7%; top: 45%; height: 10%; ">
50
+ < img class ="gdButton " id ="pageDown " src ="../assets/arrow-left.png " style ="display: none "; height ="90% ">
51
+ </ div >
52
+
53
+ < div style ="position: absolute; right: 7%; top: 45%; height: 10%; ">
54
+ < img class ="gdButton " id ="pageUp " src ="../assets/arrow-right.png " style ="display: none "; height ="90% ">
55
+ </ div >
56
+
51
57
< div style ="position:absolute; top: 3%; right: 2%; text-align: right; width: 20%; ">
52
58
< img id ="plusButton " class ="inline gdButton " src ="../assets/plus.png " width ="25% " onclick ="$('#infoDiv').show() ">
53
59
</ div >
@@ -60,29 +66,55 @@ <h1 class="pre" id="header">GD Private Servers</h1>
60
66
< script type ="text/javascript " src ="../dragscroll.js "> </ script >
61
67
< script >
62
68
69
+ let pageSize = 20
70
+ let page = 1
63
71
let localhost = window . location . hostname == "localhost"
64
72
let host = window . location . host . split ( "." ) . slice ( - 2 ) . join ( "." )
73
+
65
74
Fetch ( '../api/gdps' ) . then ( servers => {
66
75
67
- servers . forEach ( x => {
76
+ let currentServer = servers . find ( x => x . id == gdps )
77
+ servers = [ currentServer ] . concat ( servers . filter ( x => x . id != gdps ) ) . filter ( x => x )
78
+ let pageCount = Math . floor ( ( servers . length - 1 ) / pageSize ) + 1
79
+
80
+ function listServers ( ) {
81
+
82
+ if ( page >= pageCount ) $ ( '#pageUp' ) . hide ( )
83
+ else $ ( '#pageUp' ) . show ( )
84
+ if ( page <= 1 ) $ ( '#pageDown' ) . hide ( )
85
+ else $ ( '#pageDown' ) . show ( )
86
+
87
+ let serverPage = servers . slice ( ( page - 1 ) * pageSize , ( page - 1 ) * pageSize + pageSize )
88
+ $ ( '#searchBox' ) . html ( '<div style="height: 4.5%"></div>' ) . scrollTop ( 0 )
89
+
90
+ serverPage . forEach ( x => {
91
+ $ ( '#searchBox' ) . append ( `<div class="searchresult" style="height: 19%; padding-top: 1.2%">
92
+ <h1 class="lessspaced blue" style="color: ${ ( gdps || "" ) == x . id ? "#00DDFF" : "white" } ">${ x . name } </h1>
93
+ <h2 class="lessSpaced smaller inline gdButton"><a href="${ x . authorLink } " target="_blank">By ${ x . author } </a></h2>
68
94
69
- if ( ! x . id ) x . id = null
70
- $ ( '#searchBox' ) . append ( `<div class="searchresult" style="height: 19%; padding-top: 1.2%" >
71
- <h1 class="lessspaced blue" style="color: ${ gdps == x . id ? "#00DDFF" : "white" } "> ${ x . name } </h1 >
72
- <h2 class="lessSpaced smaller inline gdButton"><a href=" ${ x . authorLink } " target="_blank">By ${ x . author } </a></h2>
73
-
74
- <div class="center" style="position:absolute; height: 10%; width: 12 .5%; left: 3%; transform:translateY(-160%)" >
75
- <a href=" ${ x . link } " target="_blank"><img class="gdButton spaced gdpslogo" src="../assets/gdps/ ${ x . id || "gd" } _icon.png" height="130%"></a >
76
- </div>
77
-
78
- <div class="center" style="position:absolute; right: 7%; transform:translateY(-150%); height: 10 %">
79
- <a href="http:// ${ x . id || "" } ${ x . id && localhost ? ".x" : "" } ${ x . id ? "." : "" } ${ host } "><img style="margin-bottom: 4.5%" class="valign gdButton" src="../assets/view.png" height="105%"></a>
80
- </div>
81
- </div>` )
82
- } )
83
-
84
- $ ( '#searchBox ' ) . append ( '<div style="height: 4%"></div>' )
95
+ <div class="center" style="position:absolute; height: 10%; width: 12.5%; left: 3%; transform:translateY(-160%)">
96
+ <a href=" ${ x . link } " target="_blank"><img class="gdButton spaced gdpslogo" src="../assets/gdps/ ${ x . id || "gd" } _icon.png" height="130%"></a >
97
+ </div >
98
+
99
+ <div class="center" style="position:absolute; right: 7%; transform:translateY(-150%); height: 10%">
100
+ <a href="http:// ${ x . id || "" } ${ x . id && localhost ? ".x" : "" } ${ x . id ? "." : "" } ${ host } "><img style="margin-bottom: 4 .5%" class="valign gdButton" src="../assets/view.png" height="105%"></a >
101
+ </div >
102
+ </div>` )
103
+ } )
104
+ $ ( '#searchBox' ) . append ( ' <div style="height: 4.5 %"></div>' )
105
+ }
106
+
107
+ listServers ( )
108
+
109
+ $ ( '#pageUp' ) . click ( function ( ) { page ++ ; listServers ( ) } )
110
+ $ ( '#pageDown ' ) . click ( function ( ) { page -- ; listServers ( ) } )
85
111
$ ( '#loading' ) . hide ( ) ;
112
+
113
+ $ ( document ) . keydown ( function ( k ) {
114
+ if ( k . which == 37 && $ ( '#pageDown' ) . is ( ":visible" ) ) $ ( '#pageDown' ) . trigger ( 'click' ) // left
115
+ if ( k . which == 39 && $ ( '#pageUp' ) . is ( ":visible" ) ) $ ( '#pageUp' ) . trigger ( 'click' ) // right
116
+ } ) ;
117
+
86
118
} )
87
119
88
120
</ script >
0 commit comments