/* * @Author: printempw * @Date: 2016-07-22 14:02:44 * @Last Modified by: printempw * @Last Modified time: 2016-09-10 17:04:04 */ 'use strict'; $(document).ready(function() { $('input').iCheck({ checkboxClass: 'icheckbox_square-blue' }); }); $('#layout-skins-list [data-skin]').click(function(e) { e.preventDefault(); var skin_name = $(this).data('skin'); $('body').removeClass(current_skin).addClass(skin_name); current_skin = skin_name; }); $('#color-submit').click(function() { $.ajax({ type: "POST", url: "./users?action=color", dataType: "json", data: { "color_scheme": current_skin }, success: function(json) { if (json.errno == 0) toastr.success(json.msg); else toastr.warning(json.msg); }, error: showAjaxError }); }); $('#page-select').on('change', function() { // if has query strings if (getQueryString('filter') != "" || getQueryString('q') != "") { if (getQueryString('page') == "") window.location = location.href + "&page=" + $(this).val(); else window.location = "?filter="+getQueryString('filter')+"&q="+getQueryString('q')+"&page="+$(this).val(); } else { window.location = "?page=" + $(this).val(); } }); function changeUserEmail(uid) { var email = prompt("请输入新邮箱:"); if (!email) return; $.ajax({ type: "POST", url: "./users?action=email", dataType: "json", data: { 'uid': uid, 'email': email }, success: function(json) { if (json.errno == 0) { $($('tr#'+uid+' > td')[1]).html(email); toastr.success(json.msg); } else { toastr.warning(json.msg); } }, error: showAjaxError }); } function changeUserNickName(uid) { var nickname = prompt("请输入新昵称:"); if (!nickname) return; $.ajax({ type: "POST", url: "./users?action=nickname", dataType: "json", data: { 'uid': uid, 'nickname': nickname }, success: function(json) { if (json.errno == 0) { $($('tr#'+uid+' > td')[2]).html(nickname); toastr.success(json.msg); } else { toastr.warning(json.msg); } }, error: showAjaxError }); } function changeUserPwd(uid) { var password = prompt("请输入新密码:"); if (!password) return; $.ajax({ type: "POST", url: "./users?action=password", dataType: "json", data: { 'uid': uid, 'password': password }, success: function(json) { if (json.errno == 0) toastr.success(json.msg); else toastr.warning(json.msg); }, error: showAjaxError }); } function changeUserScore(uid, score) { $.ajax({ type: "POST", url: "./users?action=score", dataType: "json", data: { 'uid': uid, 'score': score }, success: function(json) { if (json.errno == 0) { $('tr#'+uid+' > td > .score').val(score); toastr.success(json.msg); } else { toastr.warning(json.msg); } }, error: showAjaxError }); } function changeBanStatus(uid) { $.ajax({ type: "POST", url: "./users?action=ban", dataType: "json", data: { 'uid': uid }, success: function(json) { if (json.errno == 0) { var object = $('#'+uid).find('a#ban'); var dom = '' + (object.text() == '封禁' ? '解封' : '封禁') + ''; object.html(dom); $('#'+uid).find('#permission').text(json.permission == '-1' ? '封禁' : '正常'); toastr.success(json.msg); } else { toastr.warning(json.msg); } }, error: showAjaxError }); } function changeAdminStatus(uid) { $.ajax({ type: "POST", url: "./users?action=admin", dataType: "json", data: { 'uid': uid }, success: function(json) { if (json.errno == 0) { var object = $('#'+uid).find('a#admin'); var dom = '' + (object.text() == '设为管理员' ? '解除管理员' : '设为管理员') + ''; object.html(dom); $('#'+uid).find('#permission').text(json.permission == '1' ? '管理员' : '正常'); toastr.success(json.msg); } else { toastr.warning(json.msg); } }, error: showAjaxError }); } function deleteUserAccount(uid) { if (!window.confirm('真的要删除此用户吗?此操作不可恢复')) return; $.ajax({ type: "POST", url: "./users?action=delete", dataType: "json", data: { 'uid': uid }, success: function(json) { if (json.errno == 0) { $('tr#'+uid).remove(); toastr.success(json.msg); } else { toastr.warning(json.msg); } }, error: showAjaxError }); } $('.score').on('keypress', function(event){ if (event.which == 13) changeUserScore($(this).parent().parent().attr('id'), $(this).val()); }).click(function() { $(this).tooltip('show'); }); $('body').on('change', '#preference', function() { $.ajax({ type: "POST", url: "./players?action=preference", dataType: "json", data: { 'pid': $(this).parent().parent().attr('id'), 'preference': $(this).val() }, success: function(json) { if (json.errno == 0) { toastr.success(json.msg); } else { toastr.warning(json.msg); } }, error: showAjaxError }); }); function changeTexture(pid) { var dom = '