Ejemplo n.º 1
0
  select.onchange = function(e) {
    selectedAffiliationId = e.target.options[e.target.selectedIndex].value;

    var aff = Affiliation.byId(selectedAffiliationId);
    if ((selectedAffiliationId == 0) || (!aff)) {
      searchList = originalFriends;
    } else {
      searchList = aff.members();
    }

    if(searchList && searchText) {
      friendList.filterFriends(searchList, searchText);
    } else if (!searchText) {
      friendList.data(searchList);
    }
  };
Ejemplo n.º 2
0
  evt.on(document.getElementById('searchbox'), 'keyup', function(e) {
    if(e.which >= 65 && e.which <= 90 || e.which == 8) {
      // refresh search on backspace
      searchText = e.target.value.trim();
      /*
      search entire original
      selector for affiliations
      */
      var aff = Affiliation.byId(selectedAffiliationId);
      if ((selectedAffiliationId == 0) || (!aff)) {
        searchList = originalFriends;
      } else {
        searchList = aff.members();
      }

      if(searchList && searchText) {
        friendList.filterFriends(searchList, searchText);
      } else if (!searchText) {
        friendList.data(searchList);
      }
    }
  });
Ejemplo n.º 3
0
window.startApp = function() {
  var originalFriends;
  var searchText = "";
  var selectedAffiliationId = 0;
  Friend.load(function(friends) {
    originalFriends = friends;
    friendList.data(friends);
  });

  // friendList searcher
  evt.on(document.getElementById('searchbox'), 'keyup', function(e) {
    if(e.which >= 65 && e.which <= 90 || e.which == 8) {
      // refresh search on backspace
      searchText = e.target.value.trim();
      /*
      search entire original
      selector for affiliations
      */
      var aff = Affiliation.byId(selectedAffiliationId);
      if ((selectedAffiliationId == 0) || (!aff)) {
        searchList = originalFriends;
      } else {
        searchList = aff.members();
      }

      if(searchList && searchText) {
        friendList.filterFriends(searchList, searchText);
      } else if (!searchText) {
        friendList.data(searchList);
      }
    }
  });

  Circle.load(function(circles) {
    circleList.data(circles);
  });

  Affiliation.load(function(affiliations) {
    affiliations.forEach(function(aff) {
      var select = document.getElementById("affiliation");
      select.options[select.options.length] = new Option(aff.name() + " (" + aff.count() + ")", aff.nid());
  	});
  });

  var select = document.getElementById("affiliation");
  select.onchange = function(e) {
    selectedAffiliationId = e.target.options[e.target.selectedIndex].value;

    var aff = Affiliation.byId(selectedAffiliationId);
    if ((selectedAffiliationId == 0) || (!aff)) {
      searchList = originalFriends;
    } else {
      searchList = aff.members();
    }

    if(searchList && searchText) {
      friendList.filterFriends(searchList, searchText);
    } else if (!searchText) {
      friendList.data(searchList);
    }
  };
};