Skip to content

Instantly share code, notes, and snippets.

@bagofarms
Created May 3, 2017 13:56
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bagofarms/2f2b51bbccc7ee1d3abd4010773868f4 to your computer and use it in GitHub Desktop.
Save bagofarms/2f2b51bbccc7ee1d3abd4010773868f4 to your computer and use it in GitHub Desktop.
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
Copy link

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

@bagofarms
Copy link
Author

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
Copy link

kimhuang66 commented Jun 10, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment