Skip to content

Commit 24fd9f9

Browse files
Sean MolenaarSean Molenaar
Sean Molenaar
authored and
Sean Molenaar
committed
Add option to select host
1 parent 00183d5 commit 24fd9f9

File tree

4 files changed

+42
-11
lines changed

4 files changed

+42
-11
lines changed

src/PHPDraft/Out/HTML/default.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ body .media h1.media-heading {
2121
margin-top: 20px;
2222
margin-bottom: 10px;
2323
}
24+
body .media h1.media-heading .form-control{
25+
display: flex;
26+
width: auto;
27+
float: right;
28+
}
29+
2430

2531
.panel-title var, h4.response var {
2632
padding: 6px 12px;

src/PHPDraft/Out/HTML/default.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,19 @@ $(function () {
77
}
88
});
99
});
10+
var selectedhost = $('h1.media-heading select.form-control').val();
11+
$('h1.media-heading select.form-control').on('change', function () {
12+
var html = $('body>div>div.row').html();
13+
var re = new RegExp(escapeRegExp(selectedhost), 'g');
14+
html = html.replace(re, $('h1.media-heading select.form-control').val());
15+
selectedhost = $('h1.media-heading select.form-control').val();
16+
$('body>div>div.row').html(html);
17+
$('[data-toggle="popover"]').popover();
18+
});
19+
20+
function escapeRegExp(str) {
21+
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
22+
};
1023
});
1124

1225
$('.collapse.request-panel').on('shown.bs.collapse', function () {

src/PHPDraft/Out/HTML/default.phtml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,16 @@ $base = $this->categories;
3131
<div class="media">
3232
<div class="media-body">
3333
<h1 class="media-heading"><?= $this->base_data['TITLE']; ?>
34-
<small><?= $this->base_data['HOST']; ?></small>
34+
<?php if (isset($this->base_data['ALT_HOST'])): ?>
35+
<select class="form-control">
36+
<option selected><?= $this->base_data['HOST']; ?></option>
37+
<?php foreach (explode(',', $this->base_data['ALT_HOST']) as $host): ?>
38+
<option><?= $host; ?></option>
39+
<?php endforeach; ?>
40+
</select>
41+
<?php else: ?>
42+
<small><?= $this->base_data['HOST']; ?></small>
43+
<?php endif; ?>
3544
</h1>
3645
<p class="lead"><?= $this->base_data['DESC']; ?></p>
3746
</div>
@@ -151,7 +160,7 @@ $base = $this->categories;
151160
</a>
152161
<p class="lead"><?= $transition->description; ?></p>
153162
<?php if (!empty($transition->requests)): ?>
154-
<?php foreach ($transition->requests as $key=>$request): ?>
163+
<?php foreach ($transition->requests as $key => $request): ?>
155164
<div class="panel panel-default">
156165
<div class="panel-heading">
157166
<h4 class="request panel-title"
@@ -162,9 +171,10 @@ $base = $this->categories;
162171
</h4>
163172
</div>
164173

165-
<div class="collapse <?php if ($key<1):?>in<?php endif;?> request-panel panel-body"
166-
id="request-coll-<?= $transition->get_href(); ?>">
167-
<?= $request->description;?>
174+
<div
175+
class="collapse <?php if ($key < 1): ?>in<?php endif; ?> request-panel panel-body"
176+
id="request-coll-<?= $transition->get_href(); ?>">
177+
<?= $request->description; ?>
168178
<?php if ($transition->url_variables !== []): ?>
169179
<h5>Example URI</h5>
170180
<span class="base-url"><?= $this->base_data['HOST']; ?></span>
@@ -219,7 +229,7 @@ $base = $this->categories;
219229
<?php endforeach; ?>
220230
<?php endif; ?>
221231
<?php if (isset($transition->responses)): ?>
222-
<?php foreach ($transition->responses as $key=>$response): ?>
232+
<?php foreach ($transition->responses as $key => $response): ?>
223233
<div class="panel panel-default">
224234
<div class="panel-heading">
225235
<h4 class="panel-title response"
@@ -231,9 +241,10 @@ $base = $this->categories;
231241
class="glyphicon indicator glyphicon-menu-down pull-right"></span>
232242
</h4>
233243
</div>
234-
<div class="panel-body collapse <?php if ($key<1):?>in<?php endif;?> response-panel"
235-
id="request-coll--<?= $transition->get_href() . '-' . $response->statuscode; ?>">
236-
<?=$response->description;?>
244+
<div
245+
class="panel-body collapse <?php if ($key < 1): ?>in<?php endif; ?> response-panel"
246+
id="request-coll--<?= $transition->get_href() . '-' . $response->statuscode; ?>">
247+
<?= $response->description; ?>
237248
<?php if ($response->headers !== []): ?>
238249
<h5>Headers</h5>
239250
<ul class="headers list-unstyled">
@@ -310,6 +321,7 @@ $base = $this->categories;
310321
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
311322
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
312323
crossorigin="anonymous"></script>
313-
<script><?= Minifier::minify_js(file_get_contents(__DIR__ . '/' . $this->template . '.js')); ?></script>
324+
<!--<script>--><?//= Minifier::minify_js(file_get_contents(__DIR__ . '/' . $this->template . '.js')); ?><!--</script>-->
325+
<script><?= file_get_contents(__DIR__ . '/' . $this->template . '.js'); ?></script>
314326
</body>
315327
</html>

src/PHPDraft/Out/UI.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ static function help()
8484
echo "\t-s\tSort displayed values [All|None|Structures|Webservices] (defaults to the way the objects are in the file)\n";
8585
echo "\t-i\tSpecifies an image to display in the header.\n";
8686
echo "\t-c\tSpecifies a CSS file to include (value is put in a link element without checking).\n";
87-
echo "\t-c\tSpecifies a JS file to include (value is put in a script element without checking).\n";
87+
echo "\t-j\tSpecifies a JS file to include (value is put in a script element without checking).\n";
8888
echo "\t-h\tDisplays this text.\n";
8989
}
9090

0 commit comments

Comments
 (0)