$(function () { var language = { "sProcessing": "处理中...", "sLengthMenu": "显示 _MENU_ 项结果", "sZeroRecords": "没有匹配结果", "sInfo": "显示第 _START_ 至 _END_ 项结果,共 _TOTAL_ 项", "sInfoEmpty": "显示第 0 至 0 项结果,共 0 项", "sInfoFiltered": "(由 _MAX_ 项结果过滤)", "sInfoPostFix": "", "sSearch": "搜索:", "sUrl": "", "sEmptyTable": "表中数据为空", "sLoadingRecords": "载入中...", "sInfoThousands": ",", "oPaginate": { "sFirst": "首页", "sPrevious": "上页", "sNext": "下页", "sLast": "末页" }, "oAria": { "sSortAscending": ": 以升序排列此列", "sSortDescending": ": 以降序排列此列" } }; var tableInit = function (r) { $('#stage-table').DataTable({ language: language, data: r.result.stage, columns: [ {title: ""}, {title: "ID"}, {title: "No"}, {title: "题名"}, {title: "编程语言"}, {title: "解答"}, {title: "通过率"}, {title: "难度"}, {title: "管理"} ], "order": [[2, "asc"]], columnDefs: [ { "targets": 0, "orderable": false, "className": "table-is-pass", "render": function (data, type, row) { if (data === '1') { return ''; } return ''; } }, { "targets": 1, "data": null, "visible": false, "orderable": false }, { "targets": 3, "className": "table-pname", "render": function (data, type, row) { return '' + data + ''; } }, { "targets": -1, "data": null, "visible": window.isAdmin, "render": function (data, type, row) { return '编辑'; } }] }); $('#challenge-table').DataTable({ language: language, data: r.result.challenge, columns: [ {title: ""}, {title: "ID"}, {title: "No"}, {title: "题名"}, {title: "编程语言"}, {title: "解答"}, {title: "通过率"}, {title: "难度"}, {title: "管理"} ], "order": [[2, "asc"]], columnDefs: [ { "targets": 0, "orderable": false, "render": function (data, type, row) { return data; } }, { "targets": 1, "data": null, "visible": false, "orderable": false }, { "targets": 3, "className": "table-pname", "render": function (data, type, row) { return '' + data + ''; } }, { "targets": -1, "data": null, "visible": window.isAdmin, "render": function (data, type, row) { return '编辑'; } }] }); $('.tabs').tabslet({ controls: { prev: '.prevTab', next: '.nextTab' } }); $('#loading').hide(); }; var checkAdmin = function (r) { if (window.isAdmin !== null) { tableInit(r); } else { setTimeout(function () { checkAdmin(r) }, 50); } }; $.ajax({ type: "GET", url: "/api.php?action=getProblemsetList&user_id=" + window.localStorage.id, dataType: "json", cache: !1, timeout: 6e4, success: function (r) { if (r.status === 1) { checkAdmin(r) } else { alert('很抱歉,获取数据失败,请稍后刷新重试。'); $('#loading').hide(); } }, error: function () { alert('很抱歉,出错了,请稍后刷新重试!'); $('#loading').hide(); } }); $('#myRecordButton').click(function() { $.ajax({ type: "GET", url: "/api.php?action=getMyRecordCount&user_id=" + window.localStorage.id, dataType: "json", cache: !1, timeout: 6e4, success: function (r) { if (r.status === 1) { if (r.result.all === r.result.pass) { alert('恭喜您!已完成全部 ' + r.result.all + ' 道闯关题!'); } else { alert('闯关题共有 ' + r.result.all + ' 道,您已经完成 ' + r.result.pass + '道。'); } } else { alert('很抱歉,获取数据失败,请稍后刷新重试。'); } }, error: function () { alert('很抱歉,出错了,请稍后刷新重试!'); } }); }); });