<!doctype html>
<html>
<head>
  <meta charset="utf-8" />
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
  <title>段位高手榜</title>
  <meta name="description" content="" />
  <meta name="keywords" content="" />
  <link rel="stylesheet" href="css/global.css" />
  <style>
    body { height: 527px; overflow: hidden; }
    .player-name{color:#408bcb;}
  </style>
  <!--[if IE 7]>
    <style>
      .heroRankCrumbs .fnMenu{margin-top:-23px;}
      .sever-select i{margin: -17px 9px 0!important;}
    </style>
  <![endif]-->
  <!--[if gt IE 6]><!-->
    <script type="text/javascript">
    !function(t){t.loadScript(["http://szhuodong.duowan.com/feq/lolbox/yy-f2e-header-lolbox.min"])}(function(){function t(t){var e=n(t);document.write(e)}function n(t){for(var n,r="",c=0;n=t[c];c++)r+=e(n);return r}function e(t){var n=[unescape("%3Cscript%20type%3D%22text/javascript%22%20src%3D%22"),"",unescape("%22%3E%3C/script%3E")],e=new Date;return e.setSeconds(0),e.setMilliseconds(0),e=e.getTime(),t+="?t_="+e,n[1]=t,n.join("")}return{loadScript:function(n){n&&n.length&&n instanceof Array&&t(n)}}}())
    </script>
<!--<![endif]-->
  <script src="js/jquery-1.11.1.min.js"></script>
  <script src="js/jquery-migrate-1.2.1.min.js"></script>
  <script src="js/jquery.nicescroll.min.js"></script>
</head>
<body scroll="no" style="overflow:hidden;">
  <div class="heroRankCrumbs">
    <a href="playerSearch.html">战绩查询</a> &gt; 排位榜
    <div class="fnMenu">
      <a class="icons back" href="javascript:history.back();"><i></i></a>
      <a class="icons refresh" href="javascript:location.reload();"><i></i></a>
    </div>
  </div>
  <div class="box heroRanks-tc">
    <div class="box-bd">
      <div class="mod-tabs clearfix">
        <div class="mod-tabs-bd hero-rank">
          <div class="mod-tabs-content">
            <div class="choose-type">
              <ul class="mod-tabs-trigger">
                <li class="selected"><a class="stat-sign" stat-sign="master" href="rankScoreRank.html" stat-desc="点击/排位高手榜">排位榜</a></li>
                <li><a class="stat-sign" stat-sign="action list" href="zdlRank.html" stat-desc="点击/战斗力排行榜">战斗力榜</a></li>
                <!-- <li><a class="stat-sign" stat-sign="hero ace" href="heroesRank.html" stat-desc="点击/英雄高手榜">英雄玩家榜</a></li> -->
              </ul>
              <div class="fr">
                <div class="sever-select" id="serverFilter">
                  <span>艾欧尼亚</span>
                  <i></i>
                </div>
                <ul class="rank-ul server-ul" id="serverFilterUl">
                  <li data-value="电信一" data-zone="dx1">艾欧尼亚</li>
                  <li data-value="电信二" data-zone="dx2">祖安</li>
                  <li data-value="电信三" data-zone="dx3">诺克萨斯</li>
                  <li data-value="电信四" data-zone="dx4">班德尔城</li>
                  <li data-value="电信五" data-zone="dx5">皮尔特沃夫</li>
                  <li data-value="电信六" data-zone="dx6">战争学院</li>
                  <li data-value="电信七" data-zone="dx7">巨神峰</li>
                  <li data-value="电信八" data-zone="dx8">雷瑟守备</li>
                  <li data-value="电信九" data-zone="dx9">裁决之地</li>
                  <li data-value="电信十" data-zone="dx10">黑色玫瑰</li>
                  <li data-value="电信十一" data-zone="dx11">暗影岛</li>
                  <li data-value="电信十二" data-zone="dx12">钢铁烈阳</li>
                  <li data-value="电信十三" data-zone="dx13">均衡教派</li>
                  <li data-value="电信十四" data-zone="dx14">水晶之痕</li>
                  <li data-value="电信十五" data-zone="dx15">影流</li>
                  <li data-value="电信十六" data-zone="dx16">守望之海</li>
                  <li data-value="电信十七" data-zone="dx17">征服之海</li>
                  <li data-value="电信十八" data-zone="dx18">卡拉曼达</li>
                  <li data-value="电信十九" data-zone="dx19">皮城警备</li>
                  <li data-value="网通一" data-zone="wt1">比尔吉沃特</li>
                  <li data-value="网通二" data-zone="wt2">德玛西亚</li>
                  <li data-value="网通三" data-zone="wt3">弗雷尔卓德</li>
                  <li data-value="网通四" data-zone="wt4">无畏先锋</li>
                  <li data-value="网通五" data-zone="wt5">恕瑞玛</li>
                  <li data-value="网通六" data-zone="wt6">扭曲丛林</li>
                  <li data-value="网通七" data-zone="wt7">巨龙之巢</li>
                  <li data-value="教育一" data-zone="jy1">教育网专区</li>
                </ul>

                <div class="search-input">
                  <input class="text" type="text" value="搜索英雄" onfocus="javascript:if(this.value=='搜索英雄')this.value='';" id="searchKey">
                  <i id="btnSearch"></i>
                </div>
              </div>
            </div>
            <div id="dataLists">
              <table cellspacing="0" cellpadding="0" border="0" width="100%">
                <thead>
                  <th width="30">排名</th>
                  <th width="150">玩家名称</th>
                  <th width="150">服务器</th>
                  <th width="100">段位/胜点</th>
                </thead>
                <tbody id="rankListBody" class="tbody">
                </tbody>
              </table>
            </div>
            <div id="pages" class="page-nav"></div>
          </div>
          <div class="mod-tabs-content hide">
          
          </div>
        </div>
      </div>
    </div>
  </div>
  <script type="text/template" id="dataListsTmpl">
    <%
      var zone = data.zone,
          sName = data.servername,
          sNickname = data.serverNickname;

    _.each(data.data, function(item, key){
      var player = item.player;
      var href = "generalRecord.html?userId=" + player.user_id + "&gameZone=" + zone + "&playerName=" + player.pn + "&serverName=" + sName;
      var rankVal = item.idx, rate = player.rate;
      var tierRank = player.tier_rank;
    %>
    <tr>
      <td align="center" class="type1">
        <% if(rankVal == 1){%>
        <i class="rank-type rank-1"></i>
        <%} else if(rankVal == 2){%>
        <i class="rank-type rank-2"></i>
        <%} else if(rankVal == 3) {%>
        <i class="rank-type rank-3"></i>
        <%} else {%>
        <%=rankVal%>
        <%}%>
      </td>
      <td align="middle" class="type2"><a class="player-name" href="<%=href%>"><%= player.pn %></a></td>
      <td align="center" class="type3"><%= sNickname %> <%= sName %></td>
      <td align="center" class="type4"><%= tierRank.tier.full_name_cn %>/<%= player.league_points %></td>
    </tr>
    <% }); %>
  </script>
  <script type="text/template" id="noDataTipsTmpl">
    <tr>
      <td colspan="4" class="errorTips">对不起，该玩家还没有上榜~~</td>
    </tr>
  </script>
  <script src="js/jquery-1.11.1.min.js"></script> <script src="js/jquery-migrate-1.2.1.min.js"></script>
  <script src="js/underscore.js"></script>
  <script type="text/javascript" src="http://sz.duowan.com/s/ya/ya.1.3.1-min.js"></script>
  <script src="js/new_stat.js"></script>
  <script src="js/jquery.nicescroll.min.js"></script>
  <script>

    var gPageIndex = 1;
    var gTotalItems = 0;
    var gTotalPages = 0;
    var ITEMS_PER_PAGE = 10;

    (function(exports){
      var App = function(){
        this.servername = '电信一';
        this.serverNickname = '艾欧尼亚';
        this.zone = 'dx1';
        this.page = 1;
        this.pageItems = 10;
        this.totalPages = 0;
        this.keywords = '';

        this.init();

        this.bindFilterEvent();
      }

      App.prototype.getData = function(){
        var baseUrl = "http://api.lolbox.duowan.com/api/v2/rank/ranked/";
        var url = baseUrl + this.zone +'?page_num=' + this.page + '&page_items=' + this.pageItems;

        return $.ajax({
            url: url,
            dataType: 'jsonp'
        });
      }

      App.prototype.process = function(playerName, page){
        page && (this.page = parseInt(page));

        if(page == 0) return;

        this.init();
      }

      App.prototype.init = function(){
        var self = this;
        this.getData().then(function(data){
          //初始化totalPages
          if(!self.totalPages) {
            gTotalPages = self.totalPages = Math.ceil(data.total_items / self.pageItems);
          }

          var list = data.results;

          if(list && list.length > 0) {
            self.render(list);
          } else {
            template = _.template($('#noDataTipsTmpl').html());
            gTotalPages = 0;
            $('#rankListBody').html(template({data: ''}));
            return;
          }
        });
      }

      App.prototype.render = function(data){
        var rData = {};
        rData.servername = this.servername;
        rData.serverNickname = this.serverNickname;
        rData.zone = this.zone;
        rData.page = this.page;

        rData.data = data;

        template = _.template($('#dataListsTmpl').html());

        $('#rankListBody').html(template({data: rData}));
        this.updatePaginator();
      }
      App.prototype.updatePaginator = function() {
        var output = '';
        if(gTotalPages){
          output += '<a>第' + gPageIndex + '/' + gTotalPages + '页</a>';
          if (gPageIndex > 1) {
              output += '<a title="上一页" class="pre-next" rel="prev" href="#" onclick="javascript:app.process(null, --gPageIndex);">上一页</a>';
          }
          if (gPageIndex < (gTotalPages - 1)) {
              output += '<a title="下一页" class="pre-next" rel="next" href="#" onclick="javascript:app.process(null, ++gPageIndex);">下一页</a>';
          }
          output += '<a class="current">第 <input type="text" id="go" size=1 value="' + (Number(gPageIndex)) + '"/>页 </a> <a href="#" onclick="javascript:paginatorJump();" class="page-go"> Go </a> ';
        }
        $('#pages').html(output);
      }
      App.prototype.bindFilterEvent = function(){
        var self = this;

        $("#serverFilter").on("click", function(e) {
          e.preventDefault();
          e.stopPropagation();
          $("#serverFilterUl").toggle();
        });
        $("#serverFilterUl>li").on('click', function(e) {
          e.preventDefault();
          var value = $(this).attr("data-value"),
              text = $(this).html(),
              zone = $(this).attr('data-zone');

          self.zone = zone;
          self.servername = value;
          self.serverNickname = text;
          self.page = 1;

          $('#serverFilter>span').html(text);
          $(this).parent().hide();
          self.init();
        });

        $('#searchKey').on('keyup', function(evt){
          if(evt.which == 13) {
            self.process(this.value);
          }
        });

        $('#btnSearch').click(function(){
          var keywords = $('#searchKey');
          var val = $('#searchKey').val();

          self.process(val);
        });

        $('.fnMenu')
            .on('click', '.refresh', function(evt){
                evt.preventDefault();
                window.location.reload();
            })
            .on('click', '.back', function(evt){
                evt.preventDefault();
                window.history.back();
            });
            
        $("#scrollUl,#serverFilterUl").niceScroll({cursorcolor:"#D9D9D9",cursorwidth:"8",cursoropacitymin:1,cursorborder:'none'});

        $('body').delegate('#go', 'keyup', function(evt){
          if(evt.which == 13) {
            paginatorJump();
          }
        });
      }

      function paginatorJump() {
          var index = Number(document.getElementById('go').value);
          if (index > 0 && index <= gTotalPages) {
              gPageIndex = index;
              app.process(null, gPageIndex);
          } else {
              $('#rankListBody').html('<tr><td colspan="6" class="errorTips">输入页数不正确</td></tr>');
          }
      }

      var app = new App;

      exports.app = app;
      exports.paginatorJump = paginatorJump;
    })(window);

  </script>
<!--海度统计-->
<script type="text/javascript">_hiido_no=0;_hiido_wid=["lbox"];</script>
<script src="http://www.duowan.com/duowan.js" type="text/javascript"></script>
<!--百度统计-->
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "//hm.baidu.com/hm.js?72772dda37b1e926733138415981abcf";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>
<!--[if gt IE 6]><!-->
    <script type="text/javascript">
        window.onerror = function(a,b,c){ return true};!function(t){t.loadScript(["http://szhuodong.duowan.com/feq/lolbox/yy-f2e-lolbox.min"])}(function(){function t(e,a){var n=a[e];if(n){e++;var o=document.createElement("script");o.type="text/javascript",o.setAttribute("async","async"),o.onload=o.onreadystatechange=function(){return o.readyState&&"complete"!==o.readyState&&"loaded"!==o.readyState?!1:(o.onload=o.onreadystatechange=null,void t(e,a))};var c=new Date;c.setSeconds(0),c.setMilliseconds(0),c=c.getTime(),o.async=!0,o.src=n+"?_="+c,document.getElementsByTagName("head")[0].appendChild(o)}}return{loadScript:function(e){e&&e.length&&e instanceof Array&&t(0,e)}}}());
    </script>
<!--<![endif]-->
</body>
</html>