From f113876f1b0afbb722e2e06207548f25e2ca91d5 Mon Sep 17 00:00:00 2001 From: printempw Date: Thu, 4 Feb 2016 18:35:14 +0800 Subject: [PATCH] pretty function name --- admin/index.php | 17 ++++------- assets/js/admin.utils.js | 61 ++++++++++++++++++++------------------- includes/autoload.inc.php | 3 +- 3 files changed, 40 insertions(+), 41 deletions(-) diff --git a/admin/index.php b/admin/index.php index ff01b33b..eaf8464b 100644 --- a/admin/index.php +++ b/admin/index.php @@ -3,13 +3,12 @@ * @Author: prpr * @Date: 2016-02-03 14:39:50 * @Last Modified by: prpr - * @Last Modified time: 2016-02-04 18:08:41 + * @Last Modified time: 2016-02-04 18:34:32 */ session_start(); $dir = dirname(dirname(__FILE__)); require "$dir/includes/autoload.inc.php"; -require "$dir/config.php"; if(isset($_COOKIE['uname']) && isset($_COOKIE['token'])) { $_SESSION['uname'] = $_COOKIE['uname']; @@ -88,14 +87,14 @@ if (isset($_SESSION['uname'])) { '; ?> - Skin - Cape - Model + Skin + Cape + Model () - Password - Delete + Password + Delete @@ -103,10 +102,6 @@ if (isset($_SESSION['uname'])) { - - diff --git a/assets/js/admin.utils.js b/assets/js/admin.utils.js index 0303d38d..1116f79e 100644 --- a/assets/js/admin.utils.js +++ b/assets/js/admin.utils.js @@ -2,44 +2,47 @@ * @Author: prpr * @Date: 2016-02-04 16:48:42 * @Last Modified by: prpr -* @Last Modified time: 2016-02-04 18:18:02 +* @Last Modified time: 2016-02-04 18:27:44 */ 'use strict'; -function showUpload(uname, type) { +function uploadTexture(uname, type) { var ply = new Ply({ - el: '

Upload new '+type+':

', + el: '

Upload new '+type+':

'+ + ''+ + '', effect: "fade", - onaction: function(){ upload(uname, type, $('#file').get(0).files[0]); }, + onaction: function(){ + var form_data = new FormData(); + var file = $('#file').get(0).files[0]; + if (file) { + form_data.append('file', file); + $.ajax({ + type: 'POST', + contentType: false, + url: 'admin_ajax.php?action=upload&type='+type+'&uname='+uname, + dataType: "json", + data: form_data, + processData: false, + success: function(json) { + if (json.errno == 0) { + showAlert("Successfully uploaded.", function(){ + location.reload(); + }); + } else { + showAlert("Error when uploading cape:\n" + json.msg); + } + } + }); + } + }, }); ply.open(); } -function upload(uname, type, file){ - var form_data = new FormData(); - if (file) { - form_data.append('file', file); - $.ajax({ - type: 'POST', - contentType: false, - url: 'admin_ajax.php?action=upload&type='+type+'&uname='+uname, - dataType: "json", - data: form_data, - processData: false, - success: function(json) { - if (json.errno == 0) { - showAlert("Successfully uploaded."); - $('#'+uname+'_'+type).attr('src', 'http://skin.fuck.io/'+type+'/'+uname+'.png?t='+Math.random()); - } else { - showAlert("Error when uploading cape:\n" + json.msg); - } - } - }); - } -} -function showChange(uname) { +function changePasswd(uname) { Ply.dialog("prompt", { title: "Type in "+uname+"'s new password", form: { passwd: "New Password" } @@ -61,7 +64,7 @@ function showChange(uname) { }); } -function showDelete(uname) { +function deleteAccount(uname) { Ply.dialog("prompt", { title: "Are you sure to delete "+uname+"?", }).done(function(ui){ @@ -82,7 +85,7 @@ function showDelete(uname) { }); } -function showModel(uname) { +function changeModel(uname) { Ply.dialog("prompt", { title: "Change "+uname+"'s model prefrence:", form: { text: "Type in `slim` or `default`" } diff --git a/includes/autoload.inc.php b/includes/autoload.inc.php index 4ad7d385..d125de95 100644 --- a/includes/autoload.inc.php +++ b/includes/autoload.inc.php @@ -3,7 +3,7 @@ * @Author: prpr * @Date: 2016-02-02 21:17:59 * @Last Modified by: prpr - * @Last Modified time: 2016-02-02 21:19:31 + * @Last Modified time: 2016-02-04 18:34:34 */ function __autoload($classname) { @@ -11,3 +11,4 @@ function __autoload($classname) { $filename = "$dir/includes/".$classname.".class.php"; include_once($filename); } +require "$dir/config.php";