Skip to content

Commit bbf6bd9

Browse files
author
p01
committed
More review fixes
1 parent 12c2a17 commit bbf6bd9

File tree

6 files changed

+56
-55
lines changed

6 files changed

+56
-55
lines changed

src/lib/functionprototype.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Function.prototype.throttle || (Function.prototype.throttle = function(delay)
1616

1717
return function()
1818
{
19-
if (last < Date.now()-delay)
19+
if (last < Date.now() - delay)
2020
wrapped();
2121
else if (!timeout)
2222
timeout = setTimeout(wrapped, delay);

src/resource-manager/resource_detail_view.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ window.cls || (window.cls = {});
66
* @constructor
77
* @extends ViewBase
88
*/
9-
cls.ResourceDetailView = function(id, name, container_class, html, default_handler, network_logger) {
9+
cls.ResourceDetailView = function(id, name, container_class, html, default_handler, network_logger)
10+
{
1011
if (cls.ResourceDetailView.instance)
1112
{
1213
return cls.ResourceDetailView.instance;
@@ -22,7 +23,7 @@ cls.ResourceDetailView = function(id, name, container_class, html, default_handl
2223
container.clearAndRender(templates.resource_detail.formatting_data(this.resource));
2324

2425
container.clearAndRender(templates.resource_detail.update(this.resource));
25-
if(this.data)
26+
if (this.data)
2627
this.go_to_line(container, this.data);
2728

2829
this.text_search.update_search();
@@ -33,12 +34,12 @@ cls.ResourceDetailView = function(id, name, container_class, html, default_handl
3334
container.clearAndRender(window.templates.disabled_view());
3435
};
3536

36-
var HIGHLIGHTED_LINE_CLASSNAME = 'highlighted-line';
37-
var RESOURCE_DETAIL_CONTAINER_CLASSNAME = 'resource-detail-container';
37+
var HIGHLIGHTED_LINE_CLASSNAME = "highlighted-line";
38+
var RESOURCE_DETAIL_CONTAINER_CLASSNAME = "resource-detail-container";
3839
var TEXT = document.TEXT_NODE;
3940
var ELE = document.ELEMENT_NODE;
40-
this._span = document.createElement('span');
41-
this._span.textContent = ' ';
41+
this._span = document.createElement("span");
42+
this._span.textContent = " ";
4243
this._line_count = 0;
4344
this._line_found = false;
4445
this._target_line = 0;
@@ -62,7 +63,7 @@ cls.ResourceDetailView = function(id, name, container_class, html, default_handl
6263
for (var pos = 0, len = value.length; pos < len; pos++)
6364
{
6465
var c = value.charAt(pos);
65-
if ((c == CR ) || (c == LF))
66+
if ((c == CR) || (c == LF))
6667
{
6768
this._line_count++;
6869
if (this._line_count == this._target_line)
@@ -114,7 +115,7 @@ cls.ResourceDetailView = function(id, name, container_class, html, default_handl
114115
this._line_found = false;
115116
this._target_line = 0;
116117
this._tops = [];
117-
var _ele = container.querySelectorAll('.' + HIGHLIGHTED_LINE_CLASSNAME)[0];
118+
var _ele = container.querySelector("." + HIGHLIGHTED_LINE_CLASSNAME);
118119
if (_ele)
119120
_ele.removeClass(HIGHLIGHTED_LINE_CLASSNAME)
120121
}
@@ -124,7 +125,7 @@ cls.ResourceDetailView = function(id, name, container_class, html, default_handl
124125
if (!data || !data.lines || !data.lines.length)
125126
return;
126127

127-
this._root_ele = container.getElementsByClassName(RESOURCE_DETAIL_CONTAINER_CLASSNAME)[0];
128+
this._root_ele = container.querySelector("." + RESOURCE_DETAIL_CONTAINER_CLASSNAME);
128129
if (this._root_ele)
129130
{
130131
this.clear_line_highlight(this._root_ele)
@@ -180,7 +181,7 @@ cls.ResourceDetailView = function(id, name, container_class, html, default_handl
180181
}.bind(this);
181182

182183
var messages = window.messages;
183-
messages.addListener('debug-context-selected', this._on_debug_context_selected_bound);
184+
messages.add_listener("debug-context-selected", this._on_debug_context_selected_bound);
184185

185186
this.init(id, name, container_class, html, default_handler);
186187
};
@@ -189,7 +190,7 @@ cls.ResourceDetailView.create_ui_widgets = function()
189190
{
190191
new ToolbarConfig(
191192
{
192-
view:'resource_detail_view',
193+
view:"resource_detail_view",
193194
groups:
194195
[
195196
{

src/resource-manager/resource_display_broker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ cls.ResourceDisplayBroker = function()
4747
*/
4848
this.show_resource_for_ele = function(ele)
4949
{
50-
var id = Number( ele.getAttribute("data-resource-id") );
50+
var id = Number(ele.getAttribute("data-resource-id"));
5151
var url = ele.getAttribute("data-resource-url");
5252
var line = ele.getAttribute('data-resource-line-number');
5353
var rt_id;

src/resource-manager/resource_service.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ cls.ResourceManagerService = function(view, network_logger)
176176
// an empty documentList
177177
// or a resource pointing to an unknown document
178178
// or a document does not have a documentID yet
179-
if( !ctx.documentList.length || unknownDocumentID || nullDocumentID )
179+
if (!ctx.documentList.length || unknownDocumentID || nullDocumentID)
180180
this._list_documents();
181181

182182
ctx.selectedResourceUID = this._selectedResourceUID;
@@ -265,7 +265,7 @@ cls.ResourceManagerService = function(view, network_logger)
265265

266266
this._highlight_sibling_resource = function(increment)
267267
{
268-
if(!this._context || !this._context.visibleResources || !this._context.visibleResources.length)
268+
if (!this._context || !this._context.visibleResources || !this._context.visibleResources.length)
269269
return;
270270

271271
var uid;
@@ -426,7 +426,7 @@ cls.ResourceRequest = function(url, callback, data, resourceInfo)
426426

427427
this._on_request_resource_id = function(status, message)
428428
{
429-
if(status == SUCCESS && this._resource_manager.requestGetResource)
429+
if (status == SUCCESS && this._resource_manager.requestGetResource)
430430
{
431431
// resource_id -> getResource => _on_request_get_resource
432432
var RESOURCE_ID = 0;

src/resource-manager/resource_templates.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ templates.resource_tree =
88
DEPTH_IDENTATION: 18,
99
DISTINGUISHER_MAX_LENGTH: 64,
1010

11-
_get_short_distinguisher:function( url )
11+
_get_short_distinguisher:function(url)
1212
{
1313
var name = url.filename || url.short_distinguisher || url;
1414
if (name.length>this.DISTINGUISHER_MAX_LENGTH)
@@ -41,7 +41,7 @@ templates.resource_tree =
4141
'class','button-expand-collapse'
4242
];
4343

44-
if(depth)
44+
if (depth)
4545
tpl.button.push('style', 'margin-left:'+ depth*this.DEPTH_IDENTATION +'px;');
4646

4747

@@ -74,7 +74,7 @@ templates.resource_tree =
7474
if (!windowInfo)
7575
return [];
7676

77-
var extras = this._expander_extras( context, String(w.id) );
77+
var extras = this._expander_extras(context, String(w.id));
7878

7979
var tpl =
8080
['li',
@@ -85,9 +85,9 @@ templates.resource_tree =
8585
'class','resource-tree-window-label'
8686
],
8787
'class','resource-tree-window'
88-
].concat( extras.tpl.h2 ),
88+
].concat(extras.tpl.h2),
8989
extras.collapsed?[]:this.documents(context, w.id)
90-
].concat( extras.tpl.li );
90+
].concat(extras.tpl.li);
9191

9292
return tpl;
9393
},
@@ -101,7 +101,7 @@ templates.resource_tree =
101101

102102
var tpl = documents.length?
103103
['ul',
104-
documents.map( this.document.bind(this, context) ),
104+
documents.map(this.document.bind(this, context)),
105105
'class','resource-tree-documents'
106106
]:[];
107107

@@ -120,7 +120,7 @@ templates.resource_tree =
120120
});
121121

122122
var depth = d.depth;
123-
var extras = this._expander_extras( context, d.pivotID, depth );
123+
var extras = this._expander_extras(context, d.pivotID, depth);
124124

125125
var tpl =
126126
['li',
@@ -140,13 +140,13 @@ templates.resource_tree =
140140
'class','resource-tree-count'
141141
],
142142
'class','resource-tree-document',
143-
].concat( extras.tpl.h2 ),
144-
( resources.length == 0 || extras.collapsed )?[]:
143+
].concat(extras.tpl.h2),
144+
(resources.length == 0 || extras.collapsed)?[]:
145145
[
146146
this.resource_groups(context, resources, d),
147147
this.documents(context, d.windowID, d.documentID)
148148
]
149-
].concat( extras.tpl.li );
149+
].concat(extras.tpl.li);
150150

151151
return tpl;
152152

@@ -155,7 +155,7 @@ templates.resource_tree =
155155
resource_groups:function(context, resources, d)
156156
{
157157
var tpl = context.groupOrder
158-
.map( this.resource_group.bind(this, context, resources, d) )
158+
.map(this.resource_group.bind(this, context, resources, d))
159159
.filter(function(v){
160160
return v!=null;
161161
});
@@ -197,9 +197,9 @@ templates.resource_tree =
197197
'class','resource-tree-count'
198198
],
199199
'class','resource-tree-group resource-tree-group-'+g.toLowerCase()
200-
].concat( extras.tpl.h2 ),
200+
].concat(extras.tpl.h2),
201201
extras.collapsed?[]:this.resources(context, resources, depth+1)
202-
].concat( extras.tpl.li );
202+
].concat(extras.tpl.li);
203203

204204
return tpl;
205205
},
@@ -297,7 +297,7 @@ templates.resource_detail =
297297

298298
formatting_data:function(resource)
299299
{
300-
if(!resource)
300+
if (!resource)
301301
return this.no_resource_selected();
302302

303303
if (!resource.data)

src/resource-manager/resource_tree_view.js

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -47,44 +47,44 @@ cls.ResourceTreeView = function(id, name, container_class, html, default_handler
4747
var scrollLeft = target?target.scrollLeft:0;
4848
var tpl;
4949

50-
if (ctx )
50+
if (ctx)
5151
{
52-
ctx.searchTerm = this.searchTerm||'';
52+
ctx.searchTerm = this.searchTerm||"";
5353
tpl = templates.resource_tree.update(ctx);
5454
}
5555
else if (this._loading)
5656
{
5757
tpl = (
58-
['div',
59-
['p', ui_strings.S_RESOURCE_LOADING_PAGE],
60-
'class', 'info-box'
58+
["div",
59+
["p", ui_strings.S_RESOURCE_LOADING_PAGE],
60+
"class", "info-box"
6161
]
6262
);
6363
}
6464
else
6565
{
6666
tpl = (
67-
['div',
68-
['span',
69-
'class', 'container-button ui-button reload-window',
70-
'handler', 'reload-window',
71-
'tabindex', '1'],
72-
['p', ui_strings.S_RESOURCE_CLICK_BUTTON_TO_FETCH_RESOURCES],
73-
'class', 'info-box'
67+
["div",
68+
["span",
69+
"class", "container-button ui-button reload-window",
70+
"handler", "reload-window",
71+
"tabindex", "1"],
72+
["p", ui_strings.S_RESOURCE_CLICK_BUTTON_TO_FETCH_RESOURCES],
73+
"class", "info-box"
7474
]
7575
);
7676
}
7777

7878
// only render the template if it has changed ( using its JSON representation as hash )
7979
var tpl_JSON = JSON.stringify(tpl);
80-
if( !this.tpl_JSON || tpl_JSON.length != this.tpl_JSON.length || tpl_JSON != this.tpl_JSON)
80+
if (!this.tpl_JSON || tpl_JSON.length != this.tpl_JSON.length || tpl_JSON != this.tpl_JSON)
8181
{
82-
container.clearAndRender( tpl );
82+
container.clearAndRender(tpl);
8383
this.tpl_JSON = tpl_JSON;
8484
}
8585

8686
target = container.firstElementChild;
87-
if(target)
87+
if (target)
8888
{
8989
target.scrollTop = scrollTop;
9090
target.scrollLeft = scrollLeft;
@@ -120,11 +120,11 @@ cls.ResourceTreeView = function(id, name, container_class, html, default_handler
120120
}.bind(this);
121121

122122
var messages = window.messages;
123-
messages.addListener('debug-context-selected', this._on_debug_context_selected_bound);
123+
messages.add_listener("debug-context-selected", this._on_debug_context_selected_bound);
124124

125-
var doc_service = window.services['document-manager'];
126-
doc_service.addListener("abouttoloaddocument", this._on_abouttoloaddocument_bound);
127-
doc_service.addListener("documentloaded", this._on_documentloaded_bound);
125+
var doc_service = window.services["document-manager"];
126+
doc_service.add_listener("abouttoloaddocument", this._on_abouttoloaddocument_bound);
127+
doc_service.add_listener("documentloaded", this._on_documentloaded_bound);
128128

129129
ActionHandlerInterface.apply(this);
130130
this._handlers = {
@@ -141,7 +141,7 @@ cls.ResourceTreeView.create_ui_widgets = function()
141141
{
142142
new ToolbarConfig(
143143
{
144-
view:'resource_tree_view',
144+
view:"resource_tree_view",
145145
groups:
146146
[
147147
{
@@ -162,7 +162,7 @@ cls.ResourceTreeView.create_ui_widgets = function()
162162

163163
var text_search = window.views.resource_tree_view.text_search = new TextSearch();
164164

165-
text_search.addListener("onbeforesearch",(function(msg)
165+
text_search.add_listener("onbeforesearch",(function(msg)
166166
{
167167
var view = window.views.resource_tree_view;
168168
if (view.searchTerm != msg.search_term)
@@ -173,7 +173,7 @@ cls.ResourceTreeView.create_ui_widgets = function()
173173

174174
}).bind(text_search));
175175

176-
window.eventHandlers.input["resource-tree-text-search"] = function(event, target)
176+
window.event_handlers.input["resource-tree-text-search"] = function(event, target)
177177
{
178178
text_search.searchDelayed(target.value);
179179
};
@@ -195,7 +195,7 @@ cls.ResourceTreeView.create_ui_widgets = function()
195195
if (scroll_container)
196196
{
197197
text_search.setContainer(scroll_container);
198-
text_search.set_query_selector('.resource-tree-resource-label');
198+
text_search.set_query_selector(".resource-tree-resource-label");
199199
text_search.setFormInput(
200200
views.resource_tree_view.getToolbarControl(msg.container, "resource-tree-text-search")
201201
);
@@ -209,8 +209,8 @@ cls.ResourceTreeView.create_ui_widgets = function()
209209
text_search.cleanup();
210210
}
211211

212-
window.messages.addListener("view-created", on_view_created);
213-
window.messages.addListener("view-destroyed", on_view_destroyed);
212+
window.messages.add_listener("view-created", on_view_created);
213+
window.messages.add_listener("view-destroyed", on_view_destroyed);
214214
}
215215

216216
cls.ResourceTreeView.prototype = ViewBase;

0 commit comments

Comments
 (0)