diff --git a/assets/js/profile.utils.js b/assets/js/profile.utils.js index 83fd84fe..97944159 100644 --- a/assets/js/profile.utils.js +++ b/assets/js/profile.utils.js @@ -2,8 +2,54 @@ * @Author: prpr * @Date: 2016-02-03 17:21:46 * @Last Modified by: prpr -* @Last Modified time: 2016-02-03 17:21:54 +* @Last Modified time: 2016-02-03 19:58:08 */ 'use strict'; +$('#change').click(function(){ + var passwd = $("#passwd").val(); + var new_passwd = $("#new-passwd").val(); + if (checkForm(passwd, new_passwd, $("#confirm-pwd").val())) { + $.ajax({ + type: "POST", + url: "../ajax.php?action=change", + dataType: "json", + data: {"uname": docCookies.getItem('uname'), "passwd": passwd, "new_passwd": new_passwd}, + success: function(json) { + if (json.errno == 0) { + logout(function(){ + showAlert(json.msg + " Please log in again.", function(){ + window.location = "../index.php"; + }); + }); + } else { + showAlert(json.msg); + } + } + }); + } +}) + +function checkForm(passwd, new_passwd, confirm_pwd) { + if (passwd == ""){ + showAlert("Empty Password!"); + //$("#passwd").focus(); + return false; + } else if (new_passwd == ""){ + showAlert("Empty New Password!"); + $("#new_passwd").focus(); + return false; + } else if (confirm_pwd == ""){ + showAlert("Empty Confirming Password!"); + $("#confirm_pwd").focus(); + return false; + } else if (new_passwd != confirm_pwd){ + console.log(new_passwd, confirm_pwd) + showAlert("Non-equal password confirming!"); + $("#confirm_pwd").focus(); + return false; + } else { + return true; + } +} diff --git a/assets/js/user.utils.js b/assets/js/user.utils.js index 69f2f0ff..d2a9be52 100644 --- a/assets/js/user.utils.js +++ b/assets/js/user.utils.js @@ -2,7 +2,7 @@ * @Author: prpr * @Date: 2016-01-21 13:56:40 * @Last Modified by: prpr -* @Last Modified time: 2016-02-03 13:28:19 +* @Last Modified time: 2016-02-03 19:58:45 */ 'use strict'; @@ -71,19 +71,10 @@ $("[title='Rotation']").click(function(){ }); $("#logout").click(function(){ - $.ajax({ - type: "POST", - url: "../ajax.php?action=logout", - dataType: "json", - data: {"uname": docCookies.getItem('uname')}, - success: function(json) { - docCookies.removeItem("uname", "/"); - docCookies.removeItem("token", "/"); - showAlert(json.msg + " Successfully logged out."); - window.setTimeout(function(){ - window.location = "../index.php"; - }, 1000); - } + logout(function(json){ + showAlert(json.msg + " Successfully logged out.", function(){ + window.location = "../index.php"; + }); }); }); diff --git a/assets/js/utils.js b/assets/js/utils.js new file mode 100644 index 00000000..b0d0f8c7 --- /dev/null +++ b/assets/js/utils.js @@ -0,0 +1,32 @@ +/* +* @Author: prpr +* @Date: 2016-02-03 18:23:21 +* @Last Modified by: prpr +* @Last Modified time: 2016-02-03 19:19:14 +*/ + +'use strict'; + + +function showMsg(type, msg) { + $("[id=msg]").removeClass().addClass("alert").addClass(type).html(msg); +} + +function showAlert(msg, callback) { + callback = callback ? callback : new Function; + Ply.dialog("alert", msg).done(callback); +} + +function logout(callback) { + $.ajax({ + type: "POST", + url: "../ajax.php?action=logout", + dataType: "json", + data: {"uname": docCookies.getItem('uname')}, + success: function(json) { + docCookies.removeItem("uname", "/"); + docCookies.removeItem("token", "/"); + callback(json); + } + }); +} diff --git a/index.php b/index.php index e47e2580..e4f7a6a0 100755 --- a/index.php +++ b/index.php @@ -3,7 +3,7 @@ * @Author: printempw * @Date: 2016-01-17 13:55:20 * @Last Modified by: prpr - * @Last Modified time: 2016-02-02 23:07:46 + * @Last Modified time: 2016-02-03 18:25:26 */ session_start(); $dir = dirname(__FILE__); @@ -104,11 +104,12 @@ if (isset($_COOKIE['uname']) && isset($_COOKIE['token'])) {
- - - - - + + + + + + + - + getTexture('skin'); -if ($skin_file) { - echo ""; +// Get and set texture for preview +if ($user->getTexture('skin')) { + echo ""; } else { echo ''; } echo ""; -$cape_file = "./uploads/cape/".$_COOKIE['uname'].".png"; -$cape_file = $user -> getTexture('cape'); -if ($cape_file) { - echo ""; +if ($user->getTexture('cape')) { + echo ""; echo ""; -} - -?> +} ?> diff --git a/user/profile.php b/user/profile.php index 04fc27fe..cc22903e 100644 --- a/user/profile.php +++ b/user/profile.php @@ -3,7 +3,7 @@ * @Author: prpr * @Date: 2016-02-03 16:12:45 * @Last Modified by: prpr - * @Last Modified time: 2016-02-03 17:21:31 + * @Last Modified time: 2016-02-03 19:12:26 */ session_start(); @@ -45,12 +45,12 @@ if (isset($_SESSION['uname'])) {
@@ -66,12 +66,12 @@ if (isset($_SESSION['uname'])) {
Change Password
-
- - - - -
+
+ + + + +
@@ -83,7 +83,7 @@ if (isset($_SESSION['uname'])) {

You're about to delete your account on Blessing Skin Server.

This is permanent! No backups, no restores, no magic undo button.

We warned you, ok?

- +
@@ -97,5 +97,7 @@ if (isset($_SESSION['uname'])) { + +