improved user experience, maybe...
This commit is contained in:
parent
559fd5baf3
commit
156d278b7a
|
|
@ -2,15 +2,11 @@
|
||||||
* @Author: prpr
|
* @Author: prpr
|
||||||
* @Date: 2016-01-21 13:55:44
|
* @Date: 2016-01-21 13:55:44
|
||||||
* @Last Modified by: prpr
|
* @Last Modified by: prpr
|
||||||
* @Last Modified time: 2016-01-22 10:34:42
|
* @Last Modified time: 2016-01-22 11:14:09
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function showMsg(type, msg) {
|
|
||||||
$("[id=msg]").removeClass().addClass("alert").addClass(type).html(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
$('#login').click(function(){
|
$('#login').click(function(){
|
||||||
$('[data-remodal-id=login-modal]').remodal().open();
|
$('[data-remodal-id=login-modal]').remodal().open();
|
||||||
})
|
})
|
||||||
|
|
@ -41,11 +37,10 @@ $("body").on("click", "#login-button", function(){
|
||||||
// 设置长效 token (7天)
|
// 设置长效 token (7天)
|
||||||
docCookies.setItem("token", json.token, 604800, '/');
|
docCookies.setItem("token", json.token, 604800, '/');
|
||||||
}
|
}
|
||||||
showMsg("alert-success", "Logging succeed!");
|
showAlert("Logging succeed!");
|
||||||
window.setTimeout("$('[data-remodal-id=login-modal]').remodal().close(); window.location = './user/index.php'", 1000);
|
window.setTimeout("window.location = './user/index.php'", 1000);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
showMsg("alert-danger", json.msg);
|
showAlert(json.msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
@ -67,10 +62,9 @@ $("body").on("click", "#register-button", function(){
|
||||||
},
|
},
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
if (json.errno == 0) {
|
if (json.errno == 0) {
|
||||||
showMsg("alert-success", json.msg);
|
showAlert(json.msg + " Please log in.");
|
||||||
window.setTimeout("$('[data-remodal-id=register-modal]').remodal().close(); window.location = './index.php?action=login&msg=Successfully Registered, please log in.'", 1000);
|
|
||||||
} else {
|
} else {
|
||||||
showMsg("alert-danger", json.msg);
|
showAlert(json.msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
||||||
|
|
@ -2,135 +2,131 @@
|
||||||
* @Author: prpr
|
* @Author: prpr
|
||||||
* @Date: 2016-01-21 13:56:40
|
* @Date: 2016-01-21 13:56:40
|
||||||
* @Last Modified by: prpr
|
* @Last Modified by: prpr
|
||||||
* @Last Modified time: 2016-01-21 22:58:32
|
* @Last Modified time: 2016-01-22 11:23:48
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
$("body").on("change", "#skininput", function(){
|
$("body").on("change", "#skininput", function(){
|
||||||
var files = $("#skininput").prop("files");
|
var files = $("#skininput").prop("files");
|
||||||
handleFiles(files, "skin");
|
handleFiles(files, "skin");
|
||||||
});
|
});
|
||||||
|
|
||||||
$("body").on("change", "#capeinput", function(){
|
$("body").on("change", "#capeinput", function(){
|
||||||
var files = $("#capeinput").prop("files");
|
var files = $("#capeinput").prop("files");
|
||||||
handleFiles(files, "cape");
|
handleFiles(files, "cape");
|
||||||
});
|
});
|
||||||
|
|
||||||
function showMsg(type, msg) {
|
|
||||||
$("#msg").removeClass().addClass("alert").addClass(type).html(msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
var handleFiles = function (files, type) {
|
var handleFiles = function (files, type) {
|
||||||
if(files.length > 0) {
|
if(files.length > 0) {
|
||||||
var file = files[0];
|
var file = files[0];
|
||||||
if(file.type === 'image/png') {
|
if(file.type === 'image/png') {
|
||||||
var fr = new FileReader();
|
var fr = new FileReader();
|
||||||
fr.onload = function (e) {
|
fr.onload = function (e) {
|
||||||
var img = new Image();
|
var img = new Image();
|
||||||
img.onload = function () {
|
img.onload = function () {
|
||||||
if (type == "skin") {
|
if (type == "skin") {
|
||||||
MSP.changeSkin(img.src);
|
MSP.changeSkin(img.src);
|
||||||
} else {
|
} else {
|
||||||
MSP.changeCape(img.src);
|
MSP.changeCape(img.src);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
img.onerror = function () {
|
img.onerror = function () {
|
||||||
alert("Error: Not an image or unknown file format");
|
showMsg("alert-danger", "Error: Not an image or unknown file format");
|
||||||
};
|
};
|
||||||
img.src = this.result;
|
img.src = this.result;
|
||||||
};
|
};
|
||||||
fr.readAsDataURL(file);
|
fr.readAsDataURL(file);
|
||||||
} else {
|
} else {
|
||||||
alert("Error: This is not a PNG image!");
|
showMsg("alert-danger", "Error: This is not a PNG image!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var canvas = MSP.get3dSkinCanvas(500, 500);
|
var canvas = MSP.get3dSkinCanvas(500, 500);
|
||||||
$("#skinpreview").append($(canvas).prop("id", "canvas3d"));
|
$("#skinpreview").append($(canvas).prop("id", "canvas3d"));
|
||||||
|
|
||||||
$("[title='Movements']").click(function(){
|
$("[title='Movements']").click(function(){
|
||||||
if (MSP.getStatus("movements")) {
|
if (MSP.getStatus("movements")) {
|
||||||
MSP.setStatus("movements", false);
|
MSP.setStatus("movements", false);
|
||||||
} else {
|
} else {
|
||||||
MSP.setStatus("movements", true);
|
MSP.setStatus("movements", true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("[title='Running']").click(function(){
|
$("[title='Running']").click(function(){
|
||||||
if (MSP.getStatus("running")) {
|
if (MSP.getStatus("running")) {
|
||||||
MSP.setStatus("running", false);
|
MSP.setStatus("running", false);
|
||||||
} else {
|
} else {
|
||||||
MSP.setStatus("running", true);
|
MSP.setStatus("running", true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("[title='Rotation']").click(function(){
|
$("[title='Rotation']").click(function(){
|
||||||
if (MSP.getStatus("rotation")) {
|
if (MSP.getStatus("rotation")) {
|
||||||
MSP.setStatus("rotation", false);
|
MSP.setStatus("rotation", false);
|
||||||
} else {
|
} else {
|
||||||
MSP.setStatus("rotation", true);
|
MSP.setStatus("rotation", true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#logout").click(function(){
|
$("#logout").click(function(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "../ajax.php?action=logout",
|
url: "../ajax.php?action=logout",
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: {"uname": docCookies.getItem('uname')},
|
data: {"uname": docCookies.getItem('uname')},
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
var path = "/" + document.URL.split("/").slice(-3)[0];
|
var path = "/" + document.URL.split("/").slice(-3)[0];
|
||||||
docCookies.removeItem("uname", path);
|
docCookies.removeItem("uname", path);
|
||||||
docCookies.removeItem("token", path);
|
docCookies.removeItem("token", path);
|
||||||
showMsg('alert-success', json.msg);
|
showAlert(json.msg + " Successfully logged out.");
|
||||||
window.setTimeout(function(){
|
window.setTimeout(function(){
|
||||||
window.location = "../index.php?msg=Successfully logged out.";
|
window.location = "../index.php";
|
||||||
}, 1000);
|
}, 1000);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#upload").click(function(){
|
$("#upload").click(function(){
|
||||||
var skin_file = $("#skininput").get(0).files[0];
|
var skin_file = $("#skininput").get(0).files[0];
|
||||||
var cape_file = $("#capeinput").get(0).files[0];
|
var cape_file = $("#capeinput").get(0).files[0];
|
||||||
|
|
||||||
var form_data = new FormData();
|
var form_data = new FormData();
|
||||||
if (skin_file) {
|
if (skin_file) {
|
||||||
form_data.append('skin_file', skin_file);
|
form_data.append('skin_file', skin_file);
|
||||||
}
|
}
|
||||||
if (cape_file) {
|
if (cape_file) {
|
||||||
form_data.append('cape_file', cape_file);
|
form_data.append('cape_file', cape_file);
|
||||||
}
|
}
|
||||||
form_data.append('uname', docCookies.getItem('uname'));
|
form_data.append('uname', docCookies.getItem('uname'));
|
||||||
if (skin_file || cape_file) {
|
if (skin_file || cape_file) {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
url: '../ajax.php?action=upload',
|
url: '../ajax.php?action=upload',
|
||||||
contentType: false,
|
contentType: false,
|
||||||
dataType: "json",
|
dataType: "json",
|
||||||
data: form_data,
|
data: form_data,
|
||||||
processData: false,
|
processData: false,
|
||||||
beforeSend: function() {
|
beforeSend: function() {
|
||||||
showMsg("alert-info", "Uploading...");
|
showMsg("alert-info", "Uploading...");
|
||||||
},
|
},
|
||||||
success: function(json) {
|
success: function(json) {
|
||||||
console.log(json);
|
console.log(json);
|
||||||
if (json[0].errno == 0 && json[1].errno == 0) {
|
if (json[0].errno == 0 && json[1].errno == 0) {
|
||||||
showMsg("alert-success", "Successfully uploaded.");
|
showMsg("alert-success", "Successfully uploaded.");
|
||||||
}
|
}
|
||||||
if (json[0].errno != 0) {
|
if (json[0].errno != 0) {
|
||||||
showMsg("alert-danger", "Error when uploading skin:\n"+json[0].msg);
|
showMsg("alert-danger", "Error when uploading skin:\n"+json[0].msg);
|
||||||
}
|
}
|
||||||
if (json[1].errno != 0) {
|
if (json[1].errno != 0) {
|
||||||
showMsg("alert-danger", "Error when uploading cape:\n"+json[1].msg);
|
showMsg("alert-danger", "Error when uploading cape:\n"+json[1].msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
showMsg("alert-warning", "No input file selected");
|
showMsg("alert-warning", "No input file selected");
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* @Author: printempw
|
* @Author: printempw
|
||||||
* @Date: 2016-01-17 13:55:20
|
* @Date: 2016-01-17 13:55:20
|
||||||
* @Last Modified by: prpr
|
* @Last Modified by: prpr
|
||||||
* @Last Modified time: 2016-01-22 10:33:36
|
* @Last Modified time: 2016-01-22 11:14:35
|
||||||
*/
|
*/
|
||||||
session_start();
|
session_start();
|
||||||
function __autoload($classname) {
|
function __autoload($classname) {
|
||||||
|
|
@ -120,7 +120,7 @@ function getValue($key, $array) {
|
||||||
<?php
|
<?php
|
||||||
if ($msg = getValue('msg', $_GET)) { ?>
|
if ($msg = getValue('msg', $_GET)) { ?>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
Ply.dialog("alert", "<?php echo $msg; ?>");
|
showAlert("<?php echo $msg; ?>");
|
||||||
</script>
|
</script>
|
||||||
<?php } ?>
|
<?php } ?>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
|
|
@ -41,3 +41,11 @@ var docCookies = {
|
||||||
return aKeys;
|
return aKeys;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function showMsg(type, msg) {
|
||||||
|
$("[id=msg]").removeClass().addClass("alert").addClass(type).html(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
function showAlert(msg) {
|
||||||
|
Ply.dialog("alert", msg);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,7 @@ if (isset($_SESSION['uname'])) {
|
||||||
<link rel="stylesheet" href="../libs/glyphicon/glyphicon.css">
|
<link rel="stylesheet" href="../libs/glyphicon/glyphicon.css">
|
||||||
<link rel="stylesheet" href="../assets/css/style.css">
|
<link rel="stylesheet" href="../assets/css/style.css">
|
||||||
<link rel="stylesheet" href="../assets/css/user.style.css">
|
<link rel="stylesheet" href="../assets/css/user.style.css">
|
||||||
|
<link rel="stylesheet" href="../libs/ply/ply.css">
|
||||||
<link rel="stylesheet" href="../libs/remodal/remodal.css">
|
<link rel="stylesheet" href="../libs/remodal/remodal.css">
|
||||||
<link rel="stylesheet" href="../libs/remodal/remodal-default-theme.css">
|
<link rel="stylesheet" href="../libs/remodal/remodal-default-theme.css">
|
||||||
</head>
|
</head>
|
||||||
|
|
@ -156,9 +157,10 @@ if (isset($_SESSION['uname'])) {
|
||||||
</body>
|
</body>
|
||||||
<script type="text/javascript" src="../libs/jquery/jquery-2.1.1.min.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/cookie.js"></script>
|
||||||
<script src="../libs/three.js"></script>
|
<script type="text/javascript" src="../libs/three.js"></script>
|
||||||
<script src="../libs/three.msp.js"></script>
|
<script type="text/javascript" src="../libs/three.msp.js"></script>
|
||||||
<script src="../assets/js/user.utils.js"></script>
|
<script type="text/javascript" src="../libs/ply/ply.min.js"></script>
|
||||||
|
<script type="text/javascript" src="../assets/js/user.utils.js"></script>
|
||||||
<?php
|
<?php
|
||||||
// get and set texture for preview
|
// get and set texture for preview
|
||||||
$skin_file = $user->getTexture('skin');
|
$skin_file = $user->getTexture('skin');
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user