Skip to content

Instantly share code, notes, and snippets.

@tranepura
Created May 31, 2015 12:10
Show Gist options
  • Select an option

  • Save tranepura/e2c7c9705d27f79671e4 to your computer and use it in GitHub Desktop.

Select an option

Save tranepura/e2c7c9705d27f79671e4 to your computer and use it in GitHub Desktop.
MDL -29774 Fix
/**
* Updates the current groups information shown about a user when a user is selected.
*
* @global {Array} userSummaries
* userSummaries is added to the page via /user/selector/lib.php - group_non_members_selector::print_user_summaries()
* as a global that can be used by this function.
*/
function updateUserSummary() {
var selectEl = document.getElementById('addselect'),
summaryDiv = document.getElementById('group-usersummary'),
length = selectEl.length,
selectCnt = 0,
selectIdx = -1,
selectedUID =0,
i;
for (i = 0; i < length; i++) {
if (selectEl.options[i].selected) {
selectCnt++;
selectIdx = selectEl.options[i].value;
}
}
if (selectCnt == 1 && userSummaries[selectIdx]) {
summaryDiv.innerHTML = userSummaries[selectIdx];
}
else{
summaryDiv.innerHTML ='';
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment