Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,18 @@ function drawApplicationTimeline(groupArray, eventObjArray, startTime, offset) {
return "#job-" + jobId;
};

var getPathForJobEntry = function(baseElem) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No big deal but why not just inline this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @srowen . Yes, this is good idea, updated.

var jobIdText = $($(baseElem).find(".application-timeline-content")[0]).text();
var jobId = jobIdText.match("\\(Job (\\d+)\\)$")[1];

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jobIdText and jobId are calculated here so can we reuse them to avoid additional overhead of jQuery selector and regex?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your comments. i extracted common function getIdForJobEntry for selector and regex, and moved it out of each loop. It is only triggered by click and hover events. i think this is ok here.

return "job/?id=" + jobId;
};

$(this).click(function() {
var jobPagePath = $(getSelectorForJobEntry(this)).find("a.name-link").attr("href");
window.location.href = jobPagePath
if (jobPagePath == undefined) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need this if branch?
If we can unify the two pieces of code for jobPagePath with the new logic, can we remove away this if branch?

@zhli1142015 zhli1142015 Sep 16, 2020

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @sarutak . we should remove it and use new logic, updated.

jobPagePath = getPathForJobEntry(this)
}
window.location.href = jobPagePath
});

$(this).hover(
Expand Down