Skip to content

Commit 6844ca7

Browse files
author
Daniel Herzog
committed
Readability fixes; Use only max-width on images; Don't jump when switching raw/parsed in multipart
1 parent af2caf8 commit 6844ca7

File tree

3 files changed

+29
-26
lines changed

3 files changed

+29
-26
lines changed

src/network/network_details_templates.js

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ window.templates.network || (window.templates.network = {});
66
(function(templates) {
77

88
var HTTP_BOUNDARY_CLASS = "http-token-type-boundary";
9-
var UI_CLASSNAME = "not-content";
109
var TEXT_TYPES = ["markup", "script", "css", "text"];
1110

1211
templates._pre = function(content)
@@ -339,58 +338,61 @@ templates._request_body = function(req, do_raw)
339338
if (req.request_body == null)
340339
return [];
341340

342-
var ret; // todo: might revisit "ret", maybe return more often so that it's clear nothing more happens.
341+
var ret;
343342
if (req.request_body.partList.length) // Multipart
344343
{
344+
ret = [];
345345
var use_raw_boundary = Boolean(do_raw && req.boundary);
346-
var multi_p_template = [];
346+
var raw_boundary = req.boundary;
347347
for (var n = 0, part; part = req.request_body.partList[n]; n++)
348348
{
349-
if (use_raw_boundary && n === 0)
350-
multi_p_template.push(["span", req.boundary, "class", HTTP_BOUNDARY_CLASS]);
349+
if (n === 0)
350+
{
351+
if (use_raw_boundary)
352+
ret.push(["span", raw_boundary, "class", HTTP_BOUNDARY_CLASS]);
353+
else
354+
ret.push(["hr"]);
355+
}
351356

352-
multi_p_template.push(["span", "\n"]);
353-
multi_p_template.extend(part.headerList.map(this._headers_pseudo_raw));
354-
multi_p_template.push(["span", "\n"]);
357+
ret.push(["span", "\n"]);
358+
ret.extend(part.headerList.map(this._headers_pseudo_raw));
359+
ret.push(["span", "\n"]);
355360
if (part.content && part.content.stringData)
356-
multi_p_template.push(part.content.stringData);
361+
ret.push(part.content.stringData);
357362
else
358-
multi_p_template.push(["span", ui_strings.S_NETWORK_N_BYTE_BODY.replace("%s", part.contentLength),
359-
"class", UI_CLASSNAME]);
363+
ret.push(["span", ui_strings.S_NETWORK_N_BYTE_BODY.replace("%s", part.contentLength),
364+
"class", templates.UI_CLASSNAME]);
360365

361-
var raw_boundary = req.boundary;
362366
if (use_raw_boundary && part === req.request_body.partList.last)
363367
raw_boundary += "--";
364368

365369
if (use_raw_boundary)
366-
multi_p_template.push(["span", "\n" + raw_boundary, "class", HTTP_BOUNDARY_CLASS]);
370+
ret.push(["span", "\n" + raw_boundary, "class", HTTP_BOUNDARY_CLASS]);
367371
else
368-
multi_p_template.push(["hr"]);
372+
ret.push(["hr"]);
369373
}
370-
ret = multi_p_template;
371374
}
372375
else if (req.request_body.mimeType.startswith("application/x-www-form-urlencoded"))
373376
{
374-
var url_enc_template;
377+
var ret;
375378
if (do_raw)
376379
{
377-
url_enc_template = req.request_body.content.stringData;
380+
ret = req.request_body.content.stringData;
378381
}
379382
else
380383
{
381384
var parts = req.request_body.content.stringData.split("&");
382385
var rows = [];
383386
rows.push([
384387
"tr",
385-
["th", ["span", ui_strings.S_LABEL_NETWORK_POST_DATA_NAME, "class", UI_CLASSNAME]],
386-
["th", ["span", ui_strings.S_LABEL_NETWORK_POST_DATA_VALUE, "class", UI_CLASSNAME]]
388+
["th", ["span", ui_strings.S_LABEL_NETWORK_POST_DATA_NAME, "class", templates.UI_CLASSNAME]],
389+
["th", ["span", ui_strings.S_LABEL_NETWORK_POST_DATA_VALUE, "class", templates.UI_CLASSNAME]]
387390
]
388391
);
389392
rows.extend(parts.map(this.param_cells));
390393
var table = ["table", rows];
391-
url_enc_template = table;
394+
ret = table;
392395
}
393-
ret = url_enc_template;
394396
}
395397
else // not multipart or form.
396398
{
@@ -406,12 +408,12 @@ templates._request_body = function(req, do_raw)
406408
if (req.request_body.mimeType)
407409
{
408410
ret = ["span", ui_strings.S_NETWORK_CANT_DISPLAY_TYPE.replace("%s", req.request_body.mimeType),
409-
"class", UI_CLASSNAME];
411+
"class", templates.UI_CLASSNAME];
410412
}
411413
else
412414
{
413415
ret = ["span", ui_strings.S_NETWORK_UNKNOWN_MIME_TYPE,
414-
"class", UI_CLASSNAME];
416+
"class", templates.UI_CLASSNAME];
415417
}
416418
}
417419
}
@@ -468,7 +470,7 @@ templates._response_body = function(resp, do_raw, is_last_response)
468470
{
469471
ret.push(
470472
["span", ui_strings.S_NETWORK_REQUEST_DETAIL_UNDISPLAYABLE_BODY_LABEL.replace("%s", resp.logger_entry_mime),
471-
"class", UI_CLASSNAME]
473+
"class", templates.UI_CLASSNAME]
472474
);
473475
}
474476
}

src/network/network_style.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@
331331
}
332332

333333
.network-details-container-wrap img {
334-
width: 100%;
334+
max-width: 100%;
335335
}
336336

337337
.network-details-container p
@@ -377,7 +377,7 @@
377377
{
378378
border: none;
379379
border-top: 1px solid #a4a4a4;
380-
margin-top: 9px;
380+
margin: 7px 0 -8px 0;
381381
}
382382

383383
.request-crafter h2,

src/network/network_templates.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ var GRAPH_PADDING = (TIMELINE_MARKER_WIDTH / 2) + MIN_BAR_WIDTH + SECTIONS_HITAR
1313
var UNREFERENCED = templates.UNREFERENCED = "unreferenced";
1414
var ERROR_RESPONSE = templates.ERROR_RESPONSE = "error_response";
1515
var NOT_REQUESTED = templates.NOT_REQUESTED = "not_requested";
16+
var UI_CLASSNAME = templates.UI_CLASSNAME = "not-content";
1617

1718
templates.options_main = function(nocaching, tracking, headers, overrides)
1819
{

0 commit comments

Comments
 (0)