-
Notifications
You must be signed in to change notification settings - Fork 70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use MutationObserver to observe log for work instance_linker.js correctly #68
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,25 @@ | ||
jQuery(function ($) { | ||
$('td.log').each(function(){ | ||
var logText = $(this).html(); | ||
$(this).html( | ||
logText.replace(/instance#(\d+)\/(\d+)(?:\s+|\.)/, function(match, jobId, instanceId){ | ||
return '<a href="/definitions/' + jobId + '/instances/' + instanceId+ '">' + match + '</a>'; | ||
}) | ||
); | ||
var MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver; | ||
if (!MutationObserver) { | ||
return; | ||
} | ||
var logParent = document.querySelector('#logs tbody'); | ||
var observer = new MutationObserver(function(mutations) { | ||
if (mutations.some(function(m) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about separate as a named function? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should do that 👍 |
||
return m.addedNodes | ||
&& m.addedNodes instanceof NodeList | ||
&& m.addedNodes.length > 0 | ||
&& m.type == 'childList' | ||
})) { | ||
$('td.log').each(function() { | ||
var logText = $(this).html(); | ||
$(this).html( | ||
logText.replace(/instance#(\d+)\/(\d+)(?:\s+|\.|$)/, function(match, jobId, instanceId) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI I added |
||
return '<a href="/definitions/' + jobId + '/instances/' + instanceId+ '">' + match + '</a>'; | ||
}) | ||
); | ||
}); | ||
} | ||
}); | ||
observer.observe(logParent, {childList: true, substree: true}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PhantomJS supports MutationObserver from 2.0. But It seems that TravisCI uses PhantomJS 1.x currently (as default). So if browser does not support MutationObserver, this function (instance linker) should be disabled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But recent modern browsers support MutationObserver like that https://caniuse.com/#feat=mutationobserver
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your information.
To support PhantomJS 2.0 in #70 .
Could you add a test after merged #70 ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you about #70. I'll add a test about this.