improved user exprience by using modal callback
This commit is contained in:
parent
033c68aa8a
commit
9949cb65b7
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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";
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
|||
32
assets/js/utils.js
Normal file
32
assets/js/utils.js
Normal file
|
|
@ -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);
|
||||
}
|
||||
});
|
||||
}
|
||||
13
index.php
13
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'])) {
|
|||
<div id="msg" class="alert"></div>
|
||||
</div>
|
||||
|
||||
<script src="./libs/jquery/jquery-2.1.1.min.js"></script>
|
||||
<script src="./libs/cookie.js"></script>
|
||||
<script src="./libs/remodal/remodal.min.js"></script>
|
||||
<script src="./libs/ply/ply.min.js"></script>
|
||||
<script src="./assets/js/index.utils.js"></script>
|
||||
<script type="text/javascript" src="./libs/jquery/jquery-2.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="./libs/cookie.js"></script>
|
||||
<script type="text/javascript" src="./libs/remodal/remodal.min.js"></script>
|
||||
<script type="text/javascript" src="./libs/ply/ply.min.js"></script>
|
||||
<script type="text/javascript" src="./assets/js/utils.js"></script>
|
||||
<script type="text/javascript" src="./assets/js/index.utils.js"></script>
|
||||
<?php
|
||||
if ($msg = utils::getValue('msg', $_GET)) { ?>
|
||||
<script type="text/javascript">
|
||||
|
|
|
|||
|
|
@ -41,11 +41,3 @@ var docCookies = {
|
|||
return aKeys;
|
||||
}
|
||||
};
|
||||
|
||||
function showMsg(type, msg) {
|
||||
$("[id=msg]").removeClass().addClass("alert").addClass(type).html(msg);
|
||||
}
|
||||
|
||||
function showAlert(msg) {
|
||||
Ply.dialog("alert", msg);
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because one or more lines are too long
|
|
@ -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'])) {
|
|||
<a href="javascript:;" title="Running"><span class="glyphicon glyphicon-forward"></span></a>
|
||||
<a href="javascript:;" title="Rotation"><span class="glyphicon glyphicon-repeat"></span></a>
|
||||
<ul class="pure-menu-list">
|
||||
<li class="pure-menu-item">
|
||||
<a class="pure-menu-link" href="index.php">Upload</a>
|
||||
</li>
|
||||
<li class="pure-menu-item">
|
||||
<a href="javascript:;" class="pure-menu-link">Welcome, <?php echo $_SESSION['uname']; ?>!</a>
|
||||
</li>
|
||||
<li class="pure-menu-item">
|
||||
<a class="pure-menu-link" id="logout" href="javascript:;">Log out?</a>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="home-menu-blur">
|
||||
<div class="home-menu-wrp">
|
||||
|
|
@ -66,12 +66,12 @@ if (isset($_SESSION['uname'])) {
|
|||
<div class="panel panel-default">
|
||||
<div class="panel-heading">Change Password</div>
|
||||
<div class="panel-body">
|
||||
<form class="pure-form pure-form-stacked">
|
||||
<input id="password" type="password" placeholder="Old password">
|
||||
<input id="password" type="password" placeholder="New password">
|
||||
<input id="password" type="password" placeholder="Repeat to confirm">
|
||||
<button class="pure-button pure-button-primary">Change Password</button>
|
||||
</form>
|
||||
<div class="pure-form pure-form-stacked">
|
||||
<input id="passwd" type="password" placeholder="Old password">
|
||||
<input id="new-passwd" type="password" placeholder="New password">
|
||||
<input id="confirm-pwd" type="password" placeholder="Repeat to confirm">
|
||||
<button id="change" class="pure-button pure-button-primary">Change Password</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -83,7 +83,7 @@ if (isset($_SESSION['uname'])) {
|
|||
<p>You're about to delete your account on Blessing Skin Server.</p>
|
||||
<p>This is permanent! No backups, no restores, no magic undo button.</p>
|
||||
<p>We warned you, ok?</p>
|
||||
<button class="pure-button pure-button-error">I am sure.</button>
|
||||
<button id="delete" class="pure-button pure-button-error">I am sure.</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -97,5 +97,7 @@ if (isset($_SESSION['uname'])) {
|
|||
</body>
|
||||
<script type="text/javascript" src="../libs/jquery/jquery-2.1.1.min.js"></script>
|
||||
<script type="text/javascript" src="../libs/ply/ply.min.js"></script>
|
||||
<script type="text/javascript" src="../libs/cookie.js"></script>
|
||||
<script type="text/javascript" src="../assets/js/utils.js"></script>
|
||||
<script type="text/javascript" src="../assets/js/profile.utils.js"></script>
|
||||
</html>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user