Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This script will customize the content of the Add People window in Canvas.
$(document).ready(function(){
//The function below checks to see that an element has rendered. When called
//the function will look for a particular selector. Do not remove.
function onElementRendered(selector, cb, _attempts) {
var el = $(selector);
_attempts = ++_attempts || 1;
if (el.length) return cb(el);
if (_attempts == 60) return;
setTimeout(function() {
onElementRendered(selector, cb, _attempts);
}, 250);
}
onElementRendered('#addUsers', function() {
$('#addUsers').on('click', function() {
if (window.location.pathname.indexOf('courses') > -1) {
// Hide the "Login ID" on the "Add People" screen on the people page within a course
$('[for="peoplesearch_radio_cc_path"]').hide();
// Hide the example text
$("div.addpeople div>span:contains('Example:')").parent().hide()
// Change the text for "Login ID" and "SIS ID" to "NID" and "UCFID", respectively
$('[for="peoplesearch_radio_unique_id"] span:nth-child(2) span:nth-child(2)').text('NID');
$('[for="peoplesearch_radio_sis_user_id"] span:nth-child(2) span:nth-child(2)').text('UCFID');
}
});
});
});
@kimhuang66

This comment has been minimized.

Copy link

kimhuang66 commented Jun 10, 2020

I am inspired by your function onElementRendered(selector, cb, _attempts) to tweak some other elements on the course site. Thank you

@bagofarms

This comment has been minimized.

Copy link
Owner Author

bagofarms commented Jun 10, 2020

I'm glad it helped! I believe I got that function from the Canvas Community somewhere. Others have moved from this method to using a MutationObserver, but I haven't experimented with that yet.

@kimhuang66

This comment has been minimized.

Copy link

kimhuang66 commented Jun 10, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.