@@ -5,17 +5,18 @@ window.templates.network || (window.templates.network = {});
55
66( function ( templates ) {
77
8- templates . _detail_row = function ( wrap )
8+ templates . _wrap_col_or_row = function ( wrap )
99{
10- // Todo: this may be too hacky..
10+ // Wraps either ["elem", "text"] in a column
11+ // or [["elem", "text"], ["elem", "text"]] in a row.
1112 if ( Array . isArray ( wrap [ 0 ] ) && wrap [ 1 ] )
1213 {
1314 return [ "tr" , wrap [ 0 ] , wrap [ 1 ] ] ;
1415 }
1516 return [ "tr" , [ "td" , wrap , "colspan" , "2" ] ] ;
1617} ;
1718
18- templates . wrap_pre = function ( str )
19+ templates . _wrap_pre = function ( str )
1920{
2021 return [ "pre" , str , "class" , "mono" ] ;
2122} ;
@@ -90,7 +91,7 @@ templates.did_not_touch_network = function(entry)
9091 var data = cls . ResourceManager [ "1.2" ] . UrlLoad . URLType . DATA ;
9192 return (
9293 [ "tbody" ,
93- templates . _detail_row ( // Todo: Alternatively put into a headline, as these otherwise say "Request" here.
94+ templates . _wrap_col_or_row ( // Todo: Alternatively put into a headline, as these otherwise say "Request" here.
9495 [ "p" , entry . urltype === data ? ui_strings . S_NETWORK_NOT_REQUESTED
9596 : ui_strings . S_NETWORK_SERVED_FROM_CACHE ] )
9697 ] ) ;
@@ -160,7 +161,7 @@ templates._request_headers = function(req, do_raw)
160161 ret . extend ( templates . headers_list ( req . request_headers , firstline ) ) ;
161162 }
162163 }
163- return [ "tbody" , ret . map ( templates . _detail_row ) ] ;
164+ return [ "tbody" , ret . map ( templates . _wrap_col_or_row ) ] ;
164165} ;
165166
166167templates . _response_headers = function ( resp , do_raw )
@@ -193,29 +194,28 @@ templates._response_headers = function(resp, do_raw)
193194 ret . push ( [ "h2" , ui_strings . S_NETWORK_REQUEST_DETAIL_RESPONSE_TITLE ] ) ;
194195
195196 ret . extend ( templates . headers_list ( resp . response_headers , firstline ) ) ;
196- return [ "tbody" , ret . map ( templates . _detail_row ) ] ;
197+ return [ "tbody" , ret . map ( templates . _wrap_col_or_row ) ] ;
197198} ;
198199
199200templates . headers_list = function ( headers , firstline , do_raw )
200201{
201- var map ;
202- if ( do_raw ) // todo: when raw, this is currently just for headers of parts in mutipart. should be used for others too, to gain the speclinks.
202+ var map_func ;
203+ if ( do_raw ) // this is currently just for headers of parts in multipart. todo: in regular request/response headers we'll have a tokenized list to gain speclinks.
203204 {
204- map = function ( header )
205+ map_func = function ( header )
205206 {
206- return templates . wrap_pre ( [ [ "span" , header . name + ":" , "data-spec" , "http#" + header . name ] , [ "span" , " " + header . value ] ] ) ;
207+ return templates . _wrap_pre ( [ [ "span" , header . name + ":" , "data-spec" , "http#" + header . name ] , [ "span" , " " + header . value ] ] ) ;
207208 } ;
208209 }
209210 else
210211 {
211- map = function ( header )
212+ map_func = function ( header )
212213 {
213214 return [ [ "th" , header . name + ":" , "data-spec" , "http#" + header . name ] , [ "td" , header . value ] ] ;
214215 } ;
215216 }
216217
217- var lis = headers . map ( map ) ;
218-
218+ var lis = headers . map ( map_func ) ;
219219 if ( firstline )
220220 {
221221 lis . unshift ( [ "pre" , firstline , "class" , "mono" ] ) ;
@@ -228,7 +228,7 @@ templates._request_body = function(req, do_raw)
228228 if ( req . requestbody == null )
229229 return [ ] ;
230230
231- var ret = [ templates . wrap_pre ( "\n" ) ] ;
231+ var ret = [ templates . _wrap_pre ( "\n" ) ] ;
232232 if ( req . requestbody . partList . length ) // multipart
233233 {
234234 var use_raw_boundary = false ;
@@ -238,19 +238,19 @@ templates._request_body = function(req, do_raw)
238238 for ( var n = 0 , part ; part = req . requestbody . partList [ n ] ; n ++ )
239239 {
240240 if ( use_raw_boundary && n === 0 )
241- ret . push ( this . wrap_pre ( req . boundary ) ) ;
241+ ret . push ( this . _wrap_pre ( req . boundary ) ) ;
242242
243243 ret . extend ( templates . headers_list ( part . headerList , null , do_raw ) ) ;
244- ret . push ( this . wrap_pre ( "\n" ) ) ;
244+ ret . push ( this . _wrap_pre ( "\n" ) ) ;
245245 if ( part . content && part . content . stringData )
246246 ret . push ( [ "pre" , part . content . stringData , "class" , "mono network-body" ] ) ;
247247 else
248248 ret . push ( [ "p" , ui_strings . S_NETWORK_N_BYTE_BODY . replace ( "%s" , part . contentLength ) ] ) ;
249249
250250 if ( n < req . requestbody . partList . length - 1 )
251- ret . push ( use_raw_boundary ? this . wrap_pre ( req . boundary ) : [ "hr" ] ) ;
251+ ret . push ( use_raw_boundary ? this . _wrap_pre ( req . boundary ) : [ "hr" ] ) ;
252252 else if ( use_raw_boundary )
253- ret . push ( this . wrap_pre ( req . boundary + "--\n" ) ) ;
253+ ret . push ( this . _wrap_pre ( req . boundary + "--\n" ) ) ;
254254 }
255255 }
256256 else if ( req . requestbody . mimeType . startswith ( "application/x-www-form-urlencoded" ) )
@@ -302,13 +302,13 @@ templates._request_body = function(req, do_raw)
302302 if ( do_raw )
303303 return ret ;
304304 else
305- return [ "tbody" , ret . map ( templates . _detail_row ) ] ;
305+ return [ "tbody" , ret . map ( templates . _wrap_col_or_row ) ] ;
306306} ;
307307
308308
309309templates . _response_body = function ( resp , do_raw , is_last )
310310{
311- var ret = [ templates . wrap_pre ( "\n" ) ] ; // todo: no, then it's (really) empty there shouldn't be a separator either.
311+ var ret = [ templates . _wrap_pre ( "\n" ) ] ; // todo: no, then it's (really) empty there shouldn't be a separator either.
312312
313313 var classname = "" ;
314314 if ( resp . body_unavailable ||
@@ -354,7 +354,7 @@ templates._response_body = function(resp, do_raw, is_last)
354354 if ( do_raw )
355355 return ret ;
356356 else
357- return [ "tbody" , ret . map ( templates . _detail_row ) , "class" , classname ] ;
357+ return [ "tbody" , ret . map ( templates . _wrap_col_or_row ) , "class" , classname ] ;
358358} ;
359359
360360} ) ( window . templates . network ) ;
0 commit comments