Skip to content

Commit 81ff7b1

Browse files
author
Emmanouil Konstantinidis
committed
Clean up JS
1 parent 365524f commit 81ff7b1

File tree

3 files changed

+9
-23
lines changed

3 files changed

+9
-23
lines changed

rest_framework_docs/static/rest_framework_docs/css/style.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rest_framework_docs/static/rest_framework_docs/js/index.js

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ $( document ).ready(function() {
3131

3232
var cleanResponse = function () {
3333
$('#responseStatusCode').removeClass(function (index, css) {
34-
return (css.match (/(^|\s)label-\S+/g) || []).join(' ');
34+
return (css.match (/(^|\s)status-code-\S+/g) || []).join(' ');
3535
});
3636
$('#responseStatusText').hide();
3737
$('#responseStatusText').find('span').text('');
@@ -41,30 +41,10 @@ $( document ).ready(function() {
4141
};
4242

4343
var setResponse = function (response) {
44-
// Status Code
4544
var statusCodeFirstChar = String(response.status).charAt(0);
46-
var statusCodeClass;
47-
48-
switch (parseInt(statusCodeFirstChar)) {
49-
case 1:
50-
statusCodeClass = 'label-info';
51-
break;
52-
case 2:
53-
statusCodeClass = 'label-success';
54-
break;
55-
case 3:
56-
statusCodeClass = 'label-warning';
57-
break;
58-
case 4:
59-
statusCodeClass = 'label-danger';
60-
break;
61-
case 5:
62-
statusCodeClass = 'label-primary';
63-
break;
64-
}
6545

6646
$('#responseStatusCode').text(response.status);
67-
$('#responseStatusCode').addClass(statusCodeClass);
47+
$('#responseStatusCode').addClass('status-code-' + statusCodeFirstChar);
6848

6949
$('#responseStatusText').show();
7050
$('#responseStatusText').find('span').text(response.statusText.toLowerCase());

rest_framework_docs/static/rest_framework_docs/less/style.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,12 @@ body {
218218
.response {
219219
.status-code {
220220
font-weight: 300;
221+
222+
&.status-code-1 { background-color: @brand-info; }
223+
&.status-code-2 { background-color: @brand-success; }
224+
&.status-code-3 { background-color: @brand-warning; }
225+
&.status-code-4 { background-color: @brand-danger; }
226+
&.status-code-5 { background-color: @brand-primary; }
221227
}
222228

223229
.status-text {

0 commit comments

Comments
 (0)