-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.html
169 lines (147 loc) · 4.49 KB
/
index.html
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
163
164
165
166
167
168
169
<!DOCTYPE html>
<html>
<head>
<title>REST API Mix</title>
<meta charset="UTF-8">
<!-- needed for adaptive design -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
body {
margin: 0;
padding: 50px 0 0 0;
}
nav select, nav input {
font-size: 16px;
height: 28px;
box-sizing: border-box;
vertical-align: middle;
line-height: 1;
outline: none;
}
nav header {
font-family: Monserrat, sans-serif;
float: left;
margin-left: 20px;
font-size: 25px;
color: #00329F;
font-weight: bold;
}
nav select, nav input {
width: 50%;
box-sizing: border-box;
max-width: 500px;
padding: 0 10px;
color: #555;
background-color: #fff;
border: 1px solid #ccc;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075);
transition: border-color ease-in-out .15s,box-shadow ease-in-out .15s;
}
nav select:focus, nav input:focus {
border-color: #66afe9;
outline: 0;
box-shadow: inset 0 1px 1px rgba(0,0,0,.075),0 0 8px rgba(102,175,233,.6);
}
nav {
width: 100%;
height: 50px;
line-height: 50px;
text-align: center;
background-color: white;
border-bottom: 1px solid #ccc;
position: fixed;
top: 0;
z-index: 100;
box-sizing: border-box;
}
@media (min-width: 1000px) {
nav header {
position: absolute;
}
}
@media (max-width: 500px) {
nav input {
width: 70%;
}
nav header {
display: none;
}
}
</style>
<script
src="https://code.jquery.com/jquery-3.6.4.min.js"
integrity="sha256-oP6HI9z1XaZNBrJURtCoUT5SUnxFr8s3BzRl+cbzUq8="
crossorigin="anonymous"></script>
<script>
window.onpopstate = function(event) {
if (event.state.reload) {
// force refresh when navigating through history for entries that were pushed artificially
window.location.reload();
}
};
(function($) {
function getParam(name) {
var params = new RegExp("[\\?&]" + name + "=([^&#]*)").exec(window.location.search);
return (params && params.length) ? params[1] : null;
}
function displayApi(spec) {
Redoc.init(
spec,
{
scrollYOffset: "body > nav",
theme: {
typography: {
fontWeightRegular: 300
},
menu: {
level1Items: {
textTransform: "capitalize"
}
}
}
},
document.getElementById("redoc-container")
);
}
function displaySelectedApi() {
var selectedApi = $("#schema-url-input").val();
// update current location to include API file name as query parameter
var currentLocation = window.location;
window.history.pushState({ reload: true, api: selectedApi }, document.title,
window.location.href.split("#")[0].split("?")[0] + "?api=" + selectedApi);
displayApi(selectedApi);
}
$(document).ready(function() {
$("#schema-url-form").on("submit", function( event ) {
event.preventDefault();
return false;
});
$("#schema-url-input").on("change", displaySelectedApi);
var selectedApi = getParam("api");
$.getJSON( "catalog.json", function( data ) {
$.each( data, function( key, val ) {
var option = $("<option></option>").attr("value", val.url).text(val.name);
if (selectedApi === val.url) {
// if this API is selected via query parameter display it as selected
option.attr("selected", "selected");
}
$("#schema-url-input").append(option);
});
// Initial load
displayApi($("#schema-url-input").val());
});
});
})(jQuery);
</script>
</head>
<body>
<nav>
<header>REST APIs</header>
<form id="schema-url-form">
<select id="schema-url-input"></select>
</form>
</nav>
<div id="redoc-container" lazy-rendering></div>
<script src="https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js"> </script>
</body>
</html>