diff --git a/assets/js/admin.utils.js b/assets/js/admin.utils.js index b2c67bd8..4fe65369 100644 --- a/assets/js/admin.utils.js +++ b/assets/js/admin.utils.js @@ -2,7 +2,7 @@ * @Author: printempw * @Date: 2016-02-04 16:48:42 * @Last Modified by: printempw -* @Last Modified time: 2016-04-03 08:35:15 +* @Last Modified time: 2016-04-03 09:12:46 */ 'use strict'; @@ -40,12 +40,13 @@ function uploadTexture(uname, type) { success: function(json) { if (json.errno == 0) { showAlert("上传成功。"); - if (type == "steve") $('[src="../skin/' + uname + '-steve.png"]').prop('src', - $('[src="../skin/' + uname + '-steve.png"]').prop('src')+'?random'); - if (type == "alex") $('[src="../skin/' + uname + '-alex.png"]').prop('src', - $('[src="../skin/' + uname + '-alex.png"]').prop('src')+'?random'); - if (type == "cape") $('[src="../cape/' + uname + '.png"]').prop('src', - $('[src="../cape/' + uname + '.png"]').prop('src')+'?random'); + // refresh image + if (type == "steve") $('#'+uname+'-steve').prop('src', + '../skin/'+uname+'-steve.png?'+Math.round(Math.random() * 1000000)); + if (type == "alex") $('#'+uname+'-alex').prop('src', + '../skin/'+uname+'-alex.png?'+Math.round(Math.random() * 1000000)); + if (type == "cape") $('#'+uname+'-cape').prop('src', + '../cape/'+uname+'-.png?'+Math.round(Math.random() * 1000000)); } else { showAlert("上传材质的时候出错啦:\n" + json.msg); } @@ -87,9 +88,9 @@ function deleteTexture(uname) { if (json.errno == 0) { showAlert(json.msg); // remove DOM - if (steve) $('[src="../skin/' + uname + '-steve.png"]').remove(); - if (alex) $('[src="../skin/' + uname + '-alex.png"]').remove(); - if (cape) $('[src="../cape/' + uname + '.png"]').remove(); + if (steve) $('#' + uname + '-steve').remove(); + if (alex) $('#' + uname + '-alex ').remove(); + if (cape) $('#' + uname + '-cape ').remove(); } else { showAlert(json.msg); } diff --git a/assets/js/index.utils.js b/assets/js/index.utils.js index 5c7a2a50..fc460590 100644 --- a/assets/js/index.utils.js +++ b/assets/js/index.utils.js @@ -2,12 +2,12 @@ * @Author: printempw * @Date: 2016-01-21 13:55:44 * @Last Modified by: printempw -* @Last Modified time: 2016-04-03 08:13:36 +* @Last Modified time: 2016-04-03 09:29:41 */ 'use strict'; -function login(silent = false) { +function login(silent) { var uname = $("#uname").val(); var passwd = $("#passwd").val(); if (checkForm("login", uname, passwd)) { @@ -20,7 +20,6 @@ function login(silent = false) { $('#login-button').html(' 登录中').prop('disabled', 'disabled'); }, success: function(json) { - console.log(json); if (json.errno == 0) { docCookies.setItem('uname', uname, null, '/'); docCookies.setItem('token', json.token, null, '/'); @@ -134,6 +133,6 @@ $('body').on('keypress', '[data-remodal-id=register-modal]', function(event){ // Login Event $('body').on('keypress', '[data-remodal-id=login-modal]', function(event){ - if (event.which == 13) login(); -}).on('click', '#login-button', login); + if (event.which == 13) login(false); +}).on('click', '#login-button', function() { login(false); }); diff --git a/templates/admin/list.tpl.php b/templates/admin/list.tpl.php index 000fc97b..72ea1c28 100644 --- a/templates/admin/list.tpl.php +++ b/templates/admin/list.tpl.php @@ -52,9 +52,9 @@