heroesRank.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. function getSelectedTabID() {
  2. return tabID = $('.mod-tabs-trigger .selected').first().attr('id');
  3. }
  4. function searchHeroes(searchKey)
  5. {
  6. var size = allHeroes.length;
  7. var outputHtml = '搜索结果:';
  8. for(var i=0;i<size;i++){
  9. {
  10. var ename = allHeroes[i].ename;
  11. var cname = allHeroes[i].cname;
  12. var title = allHeroes[i].title;
  13. if((ename!=null && ename.toLowerCase().indexOf(searchKey.toLowerCase()) > -1) || (cname!=null && cname.indexOf(searchKey) >-1) || (title!=null&&title.indexOf(searchKey) >-1))
  14. {
  15. outputHtml += "<a href='heroTop10Players.php?hero="+encodeURI(ename)+"'>"+cname+"("+title+")</a> ";
  16. }
  17. }
  18. }
  19. $('#searchResult').html(outputHtml);
  20. }
  21. $( document ).ready(function() {
  22. $('#searchKey').focus(function() {
  23. if(this.value=='请输入英雄名称关键字') {
  24. this.value='';
  25. }
  26. });
  27. $("#searchKey").keyup(function (event) {
  28. if (event.keyCode == 13) {
  29. searchHeroes(document.getElementById('searchKey').value);
  30. }
  31. });
  32. $('#btnHeroSearch').bind("click", function (event) {
  33. searchHeroes(document.getElementById('searchKey').value);
  34. });
  35. // binding for tab onClicked
  36. $('.mod-tabs-trigger li').bind('click', function(event) {
  37. $(this).siblings().removeClass('selected').end().addClass('selected');
  38. var rankType = getSelectedTabID();
  39. if (rankType == 'R_S_5') {
  40. window.location = 'rankScoreRank.php';
  41. } else if (rankType == 'zdlRank') {
  42. window.location = 'zdlRank.php';
  43. } else if (rankType == 'heroRank') {
  44. window.location = 'heroesRank.php';
  45. }
  46. });
  47. });