@@ -7,10 +7,11 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
77 var URL_MATCH_CONTEXT_SIZE = 10 ;
88 var DEPTH_IDENTATION = 18 ;
99 var DISTINGUISHER_MAX_LENGTH = 64 ;
10+ var flat_list ;
1011
1112 this . _get_short_distinguisher = function ( url )
1213 {
13- var name = url . filename || url . short_distinguisher || url ;
14+ var name = url . short_distinguisher ;
1415
1516 if ( name . length > this . DISTINGUISHER_MAX_LENGTH )
1617 name = name . slice ( 0 , this . DISTINGUISHER_MAX_LENGTH ) + "…" ;
@@ -41,8 +42,6 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
4142
4243 this . update = function ( context )
4344 {
44- this . flat_list = [ ] ;
45-
4645 // expand all the pivots if there is a search_term
4746 if ( context . search_term != "" )
4847 Object . keys ( context . collapsed ) . forEach ( function ( v ) { context . collapsed [ v ] = false ; } ) ;
@@ -57,12 +56,20 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
5756 context . resources . push ( r ) ;
5857 } ) ;
5958
59+ flat_list = [ ] ;
6060 this . windows ( context ) ;
61- var tpl = [ "div" , [ "ul" , this . flat_list ] , "class" , "resource-tree" ] ;
62- delete this . flat_list ;
61+ var tpl = [ "div" , [ "ul" , flat_list ] , "class" , "resource-tree" ] ;
62+ flat_list = [ ] ;
63+
6364 return tpl ;
6465 } ;
6566
67+ /*
68+ * The following template methods push their result to the private variable
69+ * `flat_list` in order to create a lightweight flat list of windows, documents,
70+ * groups, resources, ...
71+ *
72+ */
6673 this . windows = function ( context )
6774 {
6875 context . window_list . forEach ( this . window . bind ( this , context ) ) ;
@@ -72,11 +79,11 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
7279 {
7380 var window_info = window . window_manager_data . get_window ( w . id ) ;
7481 if ( ! window_info )
75- return [ ] ;
82+ return ;
7683
7784 var extras = this . _expander_extras ( context , String ( w . id ) ) ;
7885
79- this . flat_list . push (
86+ flat_list . push (
8087 [ "li" ,
8188 [ "h2" ,
8289 extras . tpl . button ,
@@ -108,17 +115,16 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
108115
109116 if ( resources . length > 0 )
110117 {
111- var depth = d . depth ;
112- var extras = this . _expander_extras ( context , d . pivot_id , depth ) ;
118+ var extras = this . _expander_extras ( context , d . pivot_id , d . depth ) ;
113119
114- this . flat_list . push (
120+ flat_list . push (
115121 [ "li" ,
116122 [ "h2" ,
117123 extras . tpl . button ,
118124 [ "span" ,
119125 this . _get_short_distinguisher ( d . url ) ,
120126 "class" , "resource-tree-document-label" ,
121- "data-tooltip" , " js -script-select" ,
127+ "data-tooltip" , "kjs -script-select" ,
122128 "data-tooltip-text" , d . original_url
123129 ] ,
124130 " " ,
@@ -132,7 +138,7 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
132138 ] . concat ( extras . tpl . li )
133139 ) ;
134140
135- if ( ! extras . collapsed )
141+ if ( ! extras . collapsed )
136142 {
137143 if ( resources . length )
138144 this . resource_groups ( context , resources , d ) ;
@@ -159,7 +165,7 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
159165 var depth = d . depth + 1 ;
160166 var extras = this . _expander_extras ( context , d . pivot_id + "_" + g , depth ) ;
161167
162- this . flat_list . push (
168+ flat_list . push (
163169 [ "li" ,
164170 [ "h2" ,
165171 extras . tpl . button ,
@@ -194,21 +200,21 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
194200 {
195201 var pos_first = r . url . indexOf ( search ) - URL_MATCH_CONTEXT_SIZE ;
196202 var pos_last = r . url . lastIndexOf ( search ) + URL_MATCH_CONTEXT_SIZE + search . length ;
197- var preffix = pos_first > 0 ? "…" : "" ;
203+ var prefix = pos_first > 0 ? "…" : "" ;
198204 var suffix = pos_last < r . url . length ? "…" : "" ;
199205
200- partial_url_match = preffix + r . url . substring ( pos_first , pos_last ) + suffix ;
206+ partial_url_match = prefix + r . url . substring ( pos_first , pos_last ) + suffix ;
201207 }
202208
203- this . flat_list . push (
209+ flat_list . push (
204210 [ "li" ,
205211 [ "h2" ,
206212 [ "span" ,
207213 partial_url_match || this . _get_short_distinguisher ( r ) ,
208214 "class" , "resource-tree-resource-label" ,
209215 "style" , "margin-left:" + ( 1 + depth ) * DEPTH_IDENTATION + "px;" ,
210216 "data-tooltip" , "js-script-select" ,
211- "data-tooltip-text" , r . url
217+ "data-tooltip-text" , r . short_distinguisher
212218 ] ,
213219 " " ,
214220 r . same_origin ? [ ] : [ "span" , r . host , "class" , "resource-domain" ] ,
@@ -232,14 +238,14 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
232238 if ( ! resource . data )
233239 return this . no_data_available ( resource ) ;
234240
235- var specific_template = this [ resource . type ] ? resource . type : "text " ;
241+ var type = this [ resource . type ] ? resource . type : "fallback " ;
236242
237243 return (
238244 [ "div" ,
239245 this . overview ( resource ) ,
240246 [ "div" ,
241- this [ specific_template ] ( resource , resource . data ) ,
242- "class" , "resource-detail-" + specific_template + "-container"
247+ this [ type ] ( resource , resource . data ) ,
248+ "class" , "resource-detail-" + type + "-container"
243249 ] ,
244250 "class" , "resource-detail-container"
245251 ] ) ;
@@ -280,14 +286,13 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
280286
281287 this . overview = function ( resource )
282288 {
283- var info =
284- {
289+ var info = {
285290 "response_code" : resource . responsecode + " " + cls . ResourceUtil . http_status_codes [ resource . responsecode ] ,
286291 "size" : resource . size || resource . data . contentLength || resource . data . content . length ,
287292 "character_encoding" : resource . encoding || resource . data . characterEncoding
288293 } ;
289294
290- var is_error = resource . responsecode && ! [ 200 , 304 ] . contains ( resource . responsecode ) ;
295+ var is_error = resource . error_in_current_response ;
291296
292297 return (
293298 [ "div" ,
@@ -395,16 +400,15 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
395400 ] ) ;
396401 } ;
397402
398- this . flash = function ( resource )
403+ this . fallback = function ( resource )
399404 {
400405 return (
401- [ "object" ,
402- [ "div" ,
403- "Type not supported"
404- ] ,
405- "type" , resource . mimeType ,
406- "data" , resource . data . content . stringData ,
407- "class" , "resource-detail-flash"
406+ [
407+ "a" ,
408+ ui_strings . M_CONTEXTMENU_SHOW_RESOURCE ,
409+ "href" , resource . url ,
410+ "target" , "_blank" ,
411+ "class" , "resource-detail-link"
408412 ] ) ;
409413 } ;
410414
0 commit comments