@@ -25,21 +25,18 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
2525 var tpl = { } ;
2626
2727 tpl . h2 = [ "handler" , "resources-expand-collapse" ] ;
28- tpl . li =
29- [
30- "data-expand-collapse-id" , pivot_id
31- ] ;
28+ tpl . li = [ "data-expand-collapse-id" , pivot_id ] ;
3229 tpl . button =
3330 [
3431 "input" ,
35- "type" , "button" ,
36- "class" , "button-expand-collapse" + ( collapsed ? "-close" : "" )
32+ "type" , "button" ,
33+ "class" , "button-expand-collapse" + ( collapsed ? "-close" : "" )
3734 ] ;
3835
3936 if ( depth )
4037 tpl . button . push ( "style" , "margin-left:" + depth * DEPTH_IDENTATION + "px;" ) ;
4138
42- return { collapsed :collapsed , tpl :tpl } ;
39+ return { collapsed : collapsed , tpl : tpl } ;
4340 } ;
4441
4542 this . update = function ( context )
@@ -52,7 +49,7 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
5249
5350 // filter the list of resources, set their is_visible flag and push the ones matching
5451 context . resources = [ ] ;
55- context . resourceList . forEach ( function ( r ) {
52+ context . resource_list . forEach ( function ( r ) {
5653 var matches = ( context . search_term == "" || r . url . contains ( context . search_term ) ) ;
5754 r . is_visible = matches && ! context . collapsed [ r . pivot_id ]
5855
@@ -68,13 +65,13 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
6865
6966 this . windows = function ( context )
7067 {
71- context . windowList . forEach ( this . window . bind ( this , context ) ) ;
68+ context . window_list . forEach ( this . window . bind ( this , context ) ) ;
7269 } ;
7370
7471 this . window = function ( context , w )
7572 {
76- var windowInfo = window . window_manager_data . get_window ( w . id ) ;
77- if ( ! windowInfo )
73+ var window_info = window . window_manager_data . get_window ( w . id ) ;
74+ if ( ! window_info )
7875 return [ ] ;
7976
8077 var extras = this . _expander_extras ( context , String ( w . id ) ) ;
@@ -84,7 +81,7 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
8481 [ "h2" ,
8582 extras . tpl . button ,
8683 [ "span" ,
87- windowInfo . title ,
84+ window_info . title ,
8885 "class" , "resource-tree-window-label"
8986 ]
9087 ] . concat ( extras . tpl . h2 ) ,
@@ -97,18 +94,17 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
9794
9895 this . documents = function ( context , wid , pid )
9996 {
100- context . documentList . filter ( function ( d ) {
101- return d . windowID == wid && d . parentDocumentID == pid ;
102- } ) . forEach (
103- this . document . bind ( this , context )
104- ) ;
97+ context . document_list . forEach ( function ( d ) {
98+ if ( d . windowID == wid && d . parentDocumentID == pid )
99+ this . document ( context , d ) ;
100+ } , this ) ;
105101 } ;
106102
107103 this . document = function ( context , d )
108104 {
109- var documentResources = context . documentResources [ d . documentID ] || [ ] ;
105+ var document_resources = context . document_resources [ d . documentID ] || [ ] ;
110106 var resources = context . resources . filter ( function ( r ) {
111- return documentResources . contains ( r . uid ) ;
107+ return document_resources . contains ( r . uid ) ;
112108 } ) ;
113109
114110 var depth = d . depth ;
@@ -196,8 +192,10 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
196192 {
197193 var pos_first = r . url . indexOf ( search ) - URL_MATCH_CONTEXT_SIZE ;
198194 var pos_last = r . url . lastIndexOf ( search ) + URL_MATCH_CONTEXT_SIZE + search . length ;
195+ var preffix = pos_first > 0 ? "…" : "" ;
196+ var suffix = pos_last < r . url . length ? "…" : "" ;
199197
200- partial_URL_match = ( pos_first > 0 ? "…" : "" ) + r . url . substring ( pos_first , pos_last ) + ( pos_last < r . url . length ? "…" : "" ) ;
198+ partial_URL_match = preffix + r . url . substring ( pos_first , pos_last ) + suffix ;
201199 }
202200
203201 this . flat_list . push (
@@ -214,7 +212,7 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
214212 r . sameOrigin ? [ ] : [ "span" , r . host , "class" , "resource-domain" ] ,
215213 "class" , "resource-tree-resource"
216214 ] ,
217- "class" , ( context . selectedResourceUID == r . uid ? "resource-highlight" : "" ) ,
215+ "class" , ( context . selected_resource_uid == r . uid ? "resource-highlight" : "" ) ,
218216 "handler" , "resource-detail" ,
219217 "data-resource-uid" , String ( r . uid )
220218 ]
@@ -234,16 +232,16 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
234232 if ( ! resource . data )
235233 return this . no_data_available ( resource ) ;
236234
237- var specificTemplate = this [ resource . type ] ? resource . type : "text" ;
235+ var specific_template = this [ resource . type ] ? resource . type : "text" ;
238236
239237 return (
240238 [ "div" ,
241- this . overview ( resource ) , // overview
242- [ "div" , // specific template
243- this [ specificTemplate ] ( resource , resource . data ) ,
244- "class" , "resource-detail-" + specificTemplate + "-container"
239+ this . overview ( resource ) ,
240+ [ "div" ,
241+ this [ specific_template ] ( resource , resource . data ) ,
242+ "class" , "resource-detail-" + specific_template + "-container"
245243 ] ,
246- "class" , "resource-detail-container"
244+ "class" , "resource-detail-container"
247245 ] ) ;
248246 } ;
249247
@@ -252,7 +250,7 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
252250 return (
253251 [ "div" ,
254252 ui_strings . S_RESOURCE_NO_RESOURCE_SELECTED ,
255- "class" , "resource-detail-container-empty"
253+ "class" , "resource-detail-container-empty"
256254 ] ) ;
257255 } ;
258256
@@ -261,7 +259,7 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
261259 return (
262260 [ "div" ,
263261 ui_strings . S_RESOURCE_NO_DATA_AVAILABLE ,
264- "class" , "resource-detail-container-empty"
262+ "class" , "resource-detail-container-empty"
265263 ] ) ;
266264 } ;
267265
@@ -276,7 +274,7 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
276274 return (
277275 [ "div" ,
278276 ui_strings . S_RESOURCE_FORMATTING_RESOURCE ,
279- "class" , "resource-detail-container-empty"
277+ "class" , "resource-detail-container-empty"
280278 ] ) ;
281279 } ;
282280
@@ -304,18 +302,18 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
304302 "class" , "resource-detail-overview-url"
305303 ] ,
306304 [ "span" ,
307- ( isError ? info . responseCode + " - " : "" ) +
305+ ( isError ? info . responseCode + " - " : "" ) +
308306 ui_strings . S_RESOURCE_SENT_AND_GUESSED_TYPE
309307 . replace ( "%(SENT)s" , resource . data . mimeType )
310- . replace ( "%(GUESSED)s" , resource . type )
311- + ( info . characterEncoding && " " + ui_strings . S_RESOURCE_ENCODING . replace ( "%s" , info . characterEncoding ) ) ,
308+ . replace ( "%(GUESSED)s" , resource . type ) +
309+ ( info . characterEncoding && " " + ui_strings . S_RESOURCE_ENCODING . replace ( "%s" , info . characterEncoding ) ) ,
312310 "class" , "resource-detail-overview-type" + ( isError ? " resource-detail-error" : "" )
313311 ] ,
314312 [ "span" ,
315- cls . ResourceUtil . bytes_to_human_readable ( info . size )
316- + ( resource . data . meta ? " (" + resource . data . meta + ")" : "" ) ,
313+ cls . ResourceUtil . bytes_to_human_readable ( info . size ) +
314+ ( resource . data . meta ? " (" + resource . data . meta + ")" : "" ) ,
317315 "data-tooltip" , "js-script-select" ,
318- "data-tooltip-text" , info . size + " bytes" ,
316+ "data-tooltip-text" , info . size + " " + ui_strings . S_BYTES_UNIT ,
319317 "class" , "resource-detail-overview-size"
320318 ] ,
321319 "class" , "resource-detail-overview"
@@ -326,9 +324,9 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
326324 {
327325 var data = resource . data . content . stringData ;
328326 var pos = data . indexOf ( "," ) ;
329- var base64 = data . lastIndexOf ( ";base64" , pos ) != - 1 ;
327+ var is_base64 = data . lastIndexOf ( ";base64" , pos ) != - 1 ;
330328
331- return [ "pre" , base64 ? atob ( data . slice ( pos + 1 ) ) : data . slice ( pos + 1 ) ] ;
329+ return [ "pre" , is_base64 ? atob ( data . slice ( pos + 1 ) ) : data . slice ( pos + 1 ) ] ;
332330 } ;
333331
334332 this . markup = function ( resource )
@@ -375,16 +373,18 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
375373
376374 this . font = function ( resource )
377375 {
378- var styleRule = "@font-face{font-family:\"resource-" + resource . id + "\";src:url(\"" + resource . data . content . stringData + "\");}" ;
376+ var font_face = "@font-face{font-family:\"resource-" + resource . uid + "\";src:url(\"" + resource . data . content . stringData + "\");}" ;
377+ var inline_style = "font-size:64px;font-family:resource-" + resource . uid + ";" ;
378+ var sample_string = "The quick brown fox jumps over the lazy dog 0123456789" ;
379379
380380 return (
381381 [ "object" ,
382382 [ "div" ,
383- "The quick brown fox jumps over the lazy dog 0123456789" ,
384- [ "style" , styleRule ] ,
385- "style" , "font-family:resource-" + resource . id
383+ sample_string ,
384+ [ "style" , font_face ] ,
385+ "style" , inline_style ,
386386 ] ,
387- "data" , "data:text/html;base64," + btoa ( "<!doctype html><style>" + styleRule + "</style><div contenteditable=\"true\" style=\"font-size:64px;margin:0;font-family:resource- " + resource . id + "; \">The quick brown fox jumps over the lazy dog 0123456789" ) ,
387+ "data" , "data:text/html;base64," + btoa ( "<!doctype html><style>" + font_face + "</style><div contenteditable=\"true\" style=\"" + inline_style + "\">" + sample_string ) ,
388388 "class" , "resource-detail-font"
389389 ] ) ;
390390 } ;
@@ -396,7 +396,7 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
396396 [ "div" ,
397397 "Type not supported"
398398 ] ,
399- "type" , " resource.mimeType" ,
399+ "type" , resource . mimeType ,
400400 "data" , resource . data . content . stringData ,
401401 "class" , "resource-detail-flash"
402402 ] ) ;
@@ -407,7 +407,7 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
407407 return (
408408 [ "img" ,
409409 "src" , resource . data . content . stringData ,
410- "class" , "resource-detail-image"
410+ "class" , "resource-detail-image"
411411 ] ) ;
412412 } ;
413413} ) ;
0 commit comments