MCPcopy
hub / github.com/jsfiddle/togetherjs / refresh

Function refresh

togetherjs/ui.js:1409–1440  ·  view source on GitHub ↗
(users, finished)

Source from the content-addressed store, hash-verified

1407 });
1408 }
1409 function refresh(users, finished) {
1410 var sorted = [];
1411 for (var id in users) {
1412 if (users.hasOwnProperty(id)) {
1413 sorted.push(users[id]);
1414 }
1415 }
1416 sorted.sort(function (a, b) {
1417 return a.name < b.name ? -1 : 1;
1418 });
1419 var pos = 0;
1420 ui.container.find("#togetherjs-invite-users .togetherjs-menu-item").each(function () {
1421 var $this = $(this);
1422 if (finished && ! users[$this.attr("data-clientid")]) {
1423 $this.remove();
1424 return;
1425 }
1426 if (pos >= sorted.length) {
1427 return;
1428 }
1429 while (pos < sorted.length && $this.attr("data-clientid") !== sorted[pos].id) {
1430 addUser(sorted[pos], $this);
1431 pos++;
1432 }
1433 while (pos < sorted.length && $this.attr("data-clientid") == sorted[pos].id) {
1434 pos++;
1435 }
1436 });
1437 for (var i=pos; i<sorted.length; i++) {
1438 addUser(sorted[pos]);
1439 }
1440 }
1441 def.then(function (users) {
1442 refresh(users, true);
1443 inRefresh = false;

Callers 1

refreshInviteFunction · 0.85

Calls 2

addUserFunction · 0.85
$Function · 0.50

Tested by

no test coverage detected