-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
171 lines (160 loc) · 5.1 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
170
171
<!DOCTYPE html>
<html lang="en">
<head>
<title>show-params</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<style>
/* Space out content a bit */
body {
padding-top: 1.5rem;
padding-bottom: 1.5rem;
}
/* Everything but the jumbotron gets side spacing for mobile first views */
.header,
.marketing,
.footer {
padding-right: 1rem;
padding-left: 1rem;
}
/* Custom page header */
.header {
padding-bottom: 1rem;
border-bottom: .05rem solid #e5e5e5;
}
/* Make the masthead heading the same height as the navigation */
.header h3 {
margin-top: 0;
margin-bottom: 0;
line-height: 3rem;
}
/* Custom page footer */
.footer {
padding-top: 1.5rem;
color: #777;
border-top: .05rem solid #e5e5e5;
}
/* Customize container */
@media (min-width: 48em) {
.container {
max-width: 46rem;
}
}
.container-narrow > hr {
margin: 2rem 0;
}
/* Main marketing message and sign up button */
.jumbotron {
text-align: center;
border-bottom: .05rem solid #e5e5e5;
}
.jumbotron .btn {
padding: .75rem 1.5rem;
font-size: 1.5rem;
}
/* Supporting marketing content */
.marketing {
margin: 3rem 0;
}
/* Responsive: Portrait tablets and up */
@media screen and (min-width: 48em) {
/* Remove the padding we set earlier */
.header,
.marketing,
.footer {
padding-right: 0;
padding-left: 0;
}
/* Space out the masthead */
.header {
margin-bottom: 2rem;
}
/* Remove the bottom border on the jumbotron for visual effect */
.jumbotron {
border-bottom: 0;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header clearfix">
<nav>
<ul class="nav nav-pills float-right">
<li class="nav-item">
<a class="nav-link active" href="/">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="https://github.com/javiermatos/show-params">GitHub</a>
</li>
</ul>
</nav>
<h3 class="text-muted">show-params</h3>
</div>
<div class="jumbotron">
<h1 class="display-3">Show URL Params</h1>
</div>
<div class="marketing">
<table class="table table-striped table-hover">
<thead class="thead-inverse">
<tr>
<th>Key</th>
<th>Value</th>
</tr>
</thead>
<tbody id="params">
</tbody>
</table>
</div>
<footer class="footer">
<p><a href="https://www.poets.org/poetsorg/poem/do-not-go-gentle-good-night">Do not go gentle into that good night</a></p>
</footer>
</div>
<script>
function getUrlParams() {
var match;
var pl = /\+/g; // Regex for replacing addition symbol with a space
var search = /([^&=]+)=?([^&]*)/g;
var decode = function (s) { return decodeURIComponent(s.replace(pl, ' ')); };
var query = window.location.search.substring(1);
var urlParams = {};
while ((match = search.exec(query)) !== null) {
var key = decode(match[1]);
var value = decode(match[2]);
if (!urlParams.hasOwnProperty(key)) {
urlParams[key] = [];
}
urlParams[key].push(value);
}
return urlParams;
}
function createParamsRow(key, value) {
var row = document.createElement('tr');
var keyCell = document.createElement('td');
keyCell.innerHTML = key;
row.appendChild(keyCell);
var valueValue = document.createElement('td');
valueValue.innerHTML = value;
row.appendChild(valueValue);
return row;
}
function setParamsInRows(params, tableBodyId) {
var tableBody = document.getElementById(tableBodyId);
for (var key in params) {
if (params.hasOwnProperty(key)) {
var values = params[key];
for (var i = 0, len = values.length; i < len; i++) {
tableBody.appendChild(createParamsRow(key, values[i]));
}
}
}
}
window.addEventListener("load", function(event) {
var params = getUrlParams();
var tableBodyId = 'params';
setParamsInRows(params, tableBodyId);
console.log(tableBodyId);
});
</script>
</body>
</html>