Skip to content

Commit 0503da9

Browse files
author
p01
committed
Review fixes
1 parent 703068f commit 0503da9

File tree

7 files changed

+26
-39
lines changed

7 files changed

+26
-39
lines changed

src/resource-manager/resource_detail_view.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,9 @@ cls.ResourceDetailView = function(id, name, container_class, html, default_handl
107107
this._line_found = false;
108108
this._target_line = 0;
109109
this._tops = [];
110-
var _ele = container.querySelector("." + HIGHLIGHTED_LINE_CLASSNAME);
111-
if (_ele)
112-
_ele.removeClass(HIGHLIGHTED_LINE_CLASSNAME);
110+
var ele = container.querySelector("." + HIGHLIGHTED_LINE_CLASSNAME);
111+
if (ele)
112+
ele.removeClass(HIGHLIGHTED_LINE_CLASSNAME);
113113
};
114114

115115
this.go_to_line = function(container, data)

src/resource-manager/resource_display_broker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ cls.ResourceDisplayBroker = function()
4848
id_or_url = url;
4949
}
5050

51-
if(line)
51+
if (line)
5252
data.line = Number(line);
5353

5454
if (!this._show_resource(id_or_url, data) && url)

src/resource-manager/resource_service.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ cls.ResourceInspector = function(network_logger)
1212
var HIGHLIGHT_CLASSNAME = "resource-highlight";
1313

1414
var THROTTLE_DELAY = 250;
15-
var TYPE_GROUP_MAPPING =
16-
{
15+
var TYPE_GROUP_MAPPING = {
1716
"markup": ui_strings.S_HTTP_LABEL_FILTER_MARKUP,
1817
"css": ui_strings.S_HTTP_LABEL_FILTER_STYLESHEETS,
1918
"script": ui_strings.S_HTTP_LABEL_FILTER_SCRIPTS,
@@ -162,7 +161,7 @@ cls.ResourceInspector = function(network_logger)
162161
r.document_id = document_id;
163162

164163
var d = this._document_list[document_id_index[r.document_id]];
165-
if(!d)
164+
if (!d)
166165
{
167166
unknown_document_id = true;
168167
return false;
@@ -378,12 +377,12 @@ cls.ResourceInspector = function(network_logger)
378377

379378
this.get_resource = function(uid)
380379
{
381-
return this._get_resource_by_key_value('uid', uid);
380+
return this._get_resource_by_key_value("uid", uid);
382381
};
383382

384383
this.get_resource_by_url = function(url)
385384
{
386-
return this._get_resource_by_key_value('url', url);
385+
return this._get_resource_by_key_value("url", url);
387386
};
388387

389388
this.request_resource_data = function(url, callback, data, resource_info)
@@ -410,7 +409,7 @@ cls.ResourceRequest = function(url, callback, data, resource_info)
410409
{
411410
this.url = url;
412411
this.resource_info = resource_info;
413-
this._data = data||{};
412+
this._data = data || {};
414413
this._callback = callback;
415414
this._retries = 0;
416415

@@ -480,9 +479,9 @@ cls.ResourceRequest = function(url, callback, data, resource_info)
480479
this.requests_responses = [{responsebody: resource_data}];
481480
var resource_info = new cls.ResourceInfo(this);
482481
if (!this.resource_info)
483-
this.resource_info = resource_info;
484-
else
485-
this.resource_info.data = resource_info.data;
482+
this.resource_info = resource_info;
483+
else
484+
this.resource_info.data = resource_info.data;
486485

487486
// broadcast that we got payload of the resource
488487
window.messages.post("resource-request-resource", {resource_id: this.resource_id});

src/resource-manager/resource_style.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,13 +318,13 @@ a.external:hover
318318

319319
.resource-tree li > h2:hover
320320
{
321-
background-color: rgba(137, 173, 232, 0.196);
321+
background-color: rgba(137, 173, 232, 0.2);
322322
}
323323

324324
.resource-highlight
325325
{
326326
color: #fff;
327-
background-color: rgba(55, 115, 211, 0.702);
327+
background-color: rgba(55, 115, 211, 0.7);
328328
}
329329

330330
h2 .resource-tree-count

src/resource-manager/resource_templates.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,8 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
104104
{
105105
var document_resources = context.document_resources[d.documentID] || [];
106106
var resources = context.resources.filter(function(r) {
107-
return document_resources.contains(r.uid);
108-
});
107+
return document_resources.contains(r.uid);
108+
});
109109

110110
if (resources.length > 0)
111111
{
@@ -190,22 +190,22 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
190190
this.resource = function(context, depth, r)
191191
{
192192
var search = context.search_term;
193-
var partial_URL_match = "";
193+
var partial_url_match = "";
194194
if (search != "")
195195
{
196196
var pos_first = r.url.indexOf(search) - URL_MATCH_CONTEXT_SIZE;
197197
var pos_last = r.url.lastIndexOf(search) + URL_MATCH_CONTEXT_SIZE + search.length;
198198
var preffix = pos_first > 0 ? "…" : "";
199199
var suffix = pos_last < r.url.length ? "…" : "";
200200

201-
partial_URL_match = preffix + r.url.substring(pos_first, pos_last) + suffix;
201+
partial_url_match = preffix + r.url.substring(pos_first, pos_last) + suffix;
202202
}
203203

204204
this.flat_list.push(
205205
["li",
206206
["h2",
207207
["span",
208-
partial_URL_match || this._get_short_distinguisher(r),
208+
partial_url_match || this._get_short_distinguisher(r),
209209
"class", "resource-tree-resource-label",
210210
"style", "margin-left:" + (1 + depth) * DEPTH_IDENTATION + "px;",
211211
"data-tooltip", "js-script-select",
@@ -223,7 +223,6 @@ window.templates.resource_tree || (window.templates.resource_tree = new function
223223
};
224224
});
225225

226-
227226
window.templates.resource_detail || (window.templates.resource_detail = new function()
228227
{
229228
this.update = function(resource)
@@ -306,8 +305,8 @@ window.templates.resource_detail || (window.templates.resource_detail = new func
306305
["span",
307306
(is_error ? info.response_code + " - " : "") +
308307
ui_strings.S_RESOURCE_SENT_AND_GUESSED_TYPE
309-
.replace("%(SENT)s", resource.data.mimeType)
310-
.replace("%(GUESSED)s", resource.type) +
308+
.replace("%(SENT)s", resource.data.mimeType)
309+
.replace("%(GUESSED)s", resource.type) +
311310
(info.character_encoding && " " + ui_strings.S_RESOURCE_ENCODING.replace("%s", info.character_encoding)),
312311
"class", "resource-detail-overview-type" + (is_error ? " resource-detail-error" : "")
313312
],

src/resource-manager/resource_tree_view.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,8 @@ cls.ResourceTreeView = function(id, name, container_class, html, default_handler
1919
ui_strings.S_HTTP_LABEL_FILTER_OTHER
2020
];
2121

22-
// "private"
2322
this._loading = false;
2423

25-
// public
2624
this.service = resource_inspector;
2725

2826
this.get_group_order = function()
@@ -37,8 +35,8 @@ cls.ResourceTreeView = function(id, name, container_class, html, default_handler
3735
{
3836
var ctx = this.service.get_resource_context();
3937
var target = container.firstElementChild;
40-
var scroll_top = target?target.scrollTop:0;
41-
var scroll_left = target?target.scrollLeft:0;
38+
var scroll_top = target ? target.scrollTop : 0;
39+
var scroll_left = target ? target.scrollLeft : 0;
4240
var tpl;
4341

4442
if (ctx)

src/resource-manager/resource_util.js

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -404,16 +404,7 @@ cls.ResourceUtil.http_status_codes = {
404404

405405
cls.ResourceUtil.sameOrigin = function(reference, url)
406406
{
407-
if (!reference)
408-
return true;
409-
410-
if (reference.protocol == url.protocol)
411-
{
412-
if (reference.host == url.host)
413-
return true;
414-
if (reference.host.match(new RegExp("\\." + url.host + "$")) != null)
415-
return true;
416-
}
417-
418-
return false;
407+
return !reference ||
408+
(reference.protocol == url.protocol &&
409+
(reference.host == url.host || reference.host.endswith("." + url.host)));
419410
}

0 commit comments

Comments
 (0)