mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2025-01-24 14:04:07 +08:00
fixed problem of message notifiction
This commit is contained in:
parent
32c19778fb
commit
559fd5baf3
@ -2,7 +2,7 @@
|
||||
* @Author: prpr
|
||||
* @Date: 2016-01-21 13:55:44
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-01-21 18:47:03
|
||||
* @Last Modified time: 2016-01-22 10:34:42
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@ -43,6 +43,7 @@ $("body").on("click", "#login-button", function(){
|
||||
}
|
||||
showMsg("alert-success", "Logging succeed!");
|
||||
window.setTimeout("$('[data-remodal-id=login-modal]').remodal().close(); window.location = './user/index.php'", 1000);
|
||||
|
||||
} else {
|
||||
showMsg("alert-danger", json.msg);
|
||||
}
|
||||
|
@ -1,129 +0,0 @@
|
||||
$("body").on("change", "#skininput", function(){
|
||||
var files = $("#skininput").prop("files");
|
||||
handleFiles(files, "skin");
|
||||
});
|
||||
|
||||
$("body").on("change", "#capeinput", function(){
|
||||
var files = $("#capeinput").prop("files");
|
||||
handleFiles(files, "cape");
|
||||
});
|
||||
|
||||
function showMsg(type, msg) {
|
||||
$("#msg").removeClass().addClass("alert").addClass(type).html(msg);
|
||||
}
|
||||
|
||||
var handleFiles = function (files, type) {
|
||||
if(files.length > 0) {
|
||||
var file = files[0];
|
||||
if(file.type === 'image/png') {
|
||||
var fr = new FileReader();
|
||||
fr.onload = function (e) {
|
||||
var img = new Image();
|
||||
img.onload = function () {
|
||||
if (type == "skin") {
|
||||
MSP.changeSkin(img.src);
|
||||
} else {
|
||||
MSP.changeCape(img.src);
|
||||
}
|
||||
};
|
||||
img.onerror = function () {
|
||||
alert("Error: Not an image or unknown file format");
|
||||
};
|
||||
img.src = this.result;
|
||||
};
|
||||
fr.readAsDataURL(file);
|
||||
} else {
|
||||
alert("Error: This is not a PNG image!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var canvas = MSP.get3dSkinCanvas(500, 500);
|
||||
$("#skinpreview").append($(canvas).prop("id", "canvas3d"));
|
||||
|
||||
$("[title='Movements']").click(function(){
|
||||
if (MSP.getStatus("movements")) {
|
||||
MSP.setStatus("movements", false);
|
||||
} else {
|
||||
MSP.setStatus("movements", true);
|
||||
}
|
||||
});
|
||||
|
||||
$("[title='Running']").click(function(){
|
||||
if (MSP.getStatus("running")) {
|
||||
MSP.setStatus("running", false);
|
||||
} else {
|
||||
MSP.setStatus("running", true);
|
||||
}
|
||||
});
|
||||
|
||||
$("[title='Rotation']").click(function(){
|
||||
if (MSP.getStatus("rotation")) {
|
||||
MSP.setStatus("rotation", false);
|
||||
} else {
|
||||
MSP.setStatus("rotation", true);
|
||||
}
|
||||
});
|
||||
|
||||
$("#logout").click(function(){
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "../ajax.php?action=logout",
|
||||
dataType: "json",
|
||||
data: {"uname": docCookies.getItem('uname')},
|
||||
success: function(json) {
|
||||
var path = "/" + document.URL.split("/").slice(-3)[0];
|
||||
docCookies.removeItem("uname", path);
|
||||
docCookies.removeItem("token", path);
|
||||
showMsg('alert-success', json.msg);
|
||||
window.setTimeout(function(){
|
||||
window.location = "./index.php";
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$("#upload").click(function(){
|
||||
var skin_file = $("#skininput").get(0).files[0];
|
||||
var cape_file = $("#capeinput").get(0).files[0];
|
||||
|
||||
var form_data = new FormData();
|
||||
if (skin_file) {
|
||||
form_data.append('skin_file', skin_file);
|
||||
}
|
||||
if (cape_file) {
|
||||
form_data.append('cape_file', cape_file);
|
||||
}
|
||||
form_data.append('uname', docCookies.getItem('uname'));
|
||||
if (skin_file || cape_file) {
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url: '../ajax.php?action=upload',
|
||||
contentType: false,
|
||||
dataType: "json",
|
||||
data: form_data,
|
||||
processData: false,
|
||||
beforeSend: function() {
|
||||
showMsg("alert-info", "Uploading...");
|
||||
},
|
||||
success: function(json) {
|
||||
console.log(json);
|
||||
if (json[0].errno == 0 && json[1].errno == 0) {
|
||||
showMsg("alert-success", "Successfully uploaded.");
|
||||
}
|
||||
if (json[0].errno != 0) {
|
||||
showMsg("alert-danger", "Error when uploading skin:\n"+json[0].msg);
|
||||
}
|
||||
if (json[1].errno != 0) {
|
||||
showMsg("alert-danger", "Error when uploading cape:\n"+json[1].msg);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
showMsg("alert-warning", "No input file selected");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
@ -2,76 +2,76 @@
|
||||
* @Author: prpr
|
||||
* @Date: 2016-01-21 13:56:40
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-01-21 21:56:09
|
||||
* @Last Modified time: 2016-01-21 22:58:32
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
$("body").on("change", "#skininput", function(){
|
||||
var files = $("#skininput").prop("files");
|
||||
handleFiles(files, "skin");
|
||||
var files = $("#skininput").prop("files");
|
||||
handleFiles(files, "skin");
|
||||
});
|
||||
|
||||
$("body").on("change", "#capeinput", function(){
|
||||
var files = $("#capeinput").prop("files");
|
||||
handleFiles(files, "cape");
|
||||
var files = $("#capeinput").prop("files");
|
||||
handleFiles(files, "cape");
|
||||
});
|
||||
|
||||
function showMsg(type, msg) {
|
||||
$("#msg").removeClass().addClass("alert").addClass(type).html(msg);
|
||||
$("#msg").removeClass().addClass("alert").addClass(type).html(msg);
|
||||
}
|
||||
|
||||
var handleFiles = function (files, type) {
|
||||
if(files.length > 0) {
|
||||
var file = files[0];
|
||||
if(file.type === 'image/png') {
|
||||
var fr = new FileReader();
|
||||
fr.onload = function (e) {
|
||||
var img = new Image();
|
||||
img.onload = function () {
|
||||
if (type == "skin") {
|
||||
MSP.changeSkin(img.src);
|
||||
} else {
|
||||
MSP.changeCape(img.src);
|
||||
}
|
||||
};
|
||||
img.onerror = function () {
|
||||
alert("Error: Not an image or unknown file format");
|
||||
};
|
||||
img.src = this.result;
|
||||
};
|
||||
fr.readAsDataURL(file);
|
||||
} else {
|
||||
alert("Error: This is not a PNG image!");
|
||||
}
|
||||
}
|
||||
if(files.length > 0) {
|
||||
var file = files[0];
|
||||
if(file.type === 'image/png') {
|
||||
var fr = new FileReader();
|
||||
fr.onload = function (e) {
|
||||
var img = new Image();
|
||||
img.onload = function () {
|
||||
if (type == "skin") {
|
||||
MSP.changeSkin(img.src);
|
||||
} else {
|
||||
MSP.changeCape(img.src);
|
||||
}
|
||||
};
|
||||
img.onerror = function () {
|
||||
alert("Error: Not an image or unknown file format");
|
||||
};
|
||||
img.src = this.result;
|
||||
};
|
||||
fr.readAsDataURL(file);
|
||||
} else {
|
||||
alert("Error: This is not a PNG image!");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var canvas = MSP.get3dSkinCanvas(500, 500);
|
||||
$("#skinpreview").append($(canvas).prop("id", "canvas3d"));
|
||||
|
||||
$("[title='Movements']").click(function(){
|
||||
if (MSP.getStatus("movements")) {
|
||||
MSP.setStatus("movements", false);
|
||||
} else {
|
||||
MSP.setStatus("movements", true);
|
||||
}
|
||||
if (MSP.getStatus("movements")) {
|
||||
MSP.setStatus("movements", false);
|
||||
} else {
|
||||
MSP.setStatus("movements", true);
|
||||
}
|
||||
});
|
||||
|
||||
$("[title='Running']").click(function(){
|
||||
if (MSP.getStatus("running")) {
|
||||
MSP.setStatus("running", false);
|
||||
} else {
|
||||
MSP.setStatus("running", true);
|
||||
}
|
||||
if (MSP.getStatus("running")) {
|
||||
MSP.setStatus("running", false);
|
||||
} else {
|
||||
MSP.setStatus("running", true);
|
||||
}
|
||||
});
|
||||
|
||||
$("[title='Rotation']").click(function(){
|
||||
if (MSP.getStatus("rotation")) {
|
||||
MSP.setStatus("rotation", false);
|
||||
} else {
|
||||
MSP.setStatus("rotation", true);
|
||||
}
|
||||
if (MSP.getStatus("rotation")) {
|
||||
MSP.setStatus("rotation", false);
|
||||
} else {
|
||||
MSP.setStatus("rotation", true);
|
||||
}
|
||||
});
|
||||
|
||||
$("#logout").click(function(){
|
||||
@ -86,7 +86,7 @@ $("#logout").click(function(){
|
||||
docCookies.removeItem("token", path);
|
||||
showMsg('alert-success', json.msg);
|
||||
window.setTimeout(function(){
|
||||
window.location = "./index.php";
|
||||
window.location = "../index.php?msg=Successfully logged out.";
|
||||
}, 1000);
|
||||
}
|
||||
});
|
||||
@ -113,8 +113,8 @@ $("#upload").click(function(){
|
||||
data: form_data,
|
||||
processData: false,
|
||||
beforeSend: function() {
|
||||
showMsg("alert-info", "Uploading...");
|
||||
},
|
||||
showMsg("alert-info", "Uploading...");
|
||||
},
|
||||
success: function(json) {
|
||||
console.log(json);
|
||||
if (json[0].errno == 0 && json[1].errno == 0) {
|
||||
|
11
index.php
11
index.php
@ -3,7 +3,7 @@
|
||||
* @Author: printempw
|
||||
* @Date: 2016-01-17 13:55:20
|
||||
* @Last Modified by: prpr
|
||||
* @Last Modified time: 2016-01-21 23:08:45
|
||||
* @Last Modified time: 2016-01-22 10:33:36
|
||||
*/
|
||||
session_start();
|
||||
function __autoload($classname) {
|
||||
@ -36,6 +36,7 @@ function getValue($key, $array) {
|
||||
<link rel="stylesheet" href="./assets/css/style.css">
|
||||
<link rel="stylesheet" href="./assets/css/index.style.css">
|
||||
<link rel="stylesheet" href="./libs/remodal/remodal.css">
|
||||
<link rel="stylesheet" href="./libs/ply/ply.css">
|
||||
<link rel="stylesheet" href="./libs/remodal/remodal-default-theme.css">
|
||||
</head>
|
||||
<body>
|
||||
@ -114,13 +115,13 @@ function getValue($key, $array) {
|
||||
<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>
|
||||
<?php
|
||||
if ($msg = getValue('msg', $_GET)) { ?>
|
||||
<div class="remodal" data-remodal-id="msg-modal">
|
||||
<h3><?php echo $msg; ?></h3>
|
||||
</div>
|
||||
<script type="text/javascript">$('[data-remodal-id=msg-modal]').remodal().open();</script>
|
||||
<script type="text/javascript">
|
||||
Ply.dialog("alert", "<?php echo $msg; ?>");
|
||||
</script>
|
||||
<?php } ?>
|
||||
</body>
|
||||
</html>
|
||||
|
2
libs/ply/Ply.min.js
vendored
Normal file
2
libs/ply/Ply.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
224
libs/ply/ply.css
Normal file
224
libs/ply/ply.css
Normal file
@ -0,0 +1,224 @@
|
||||
/* Global loading */
|
||||
.ply-global-loading {
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
padding: 30px;
|
||||
width: 60px;
|
||||
height: 60px;
|
||||
margin: -100px 0 0 -60px;
|
||||
z-index: 100000;
|
||||
position: fixed;
|
||||
border-radius: 10%;
|
||||
background-color: rgba(255,255,255,.5);
|
||||
box-shadow: 0 1px 2px rgba(0,0,0,.2);
|
||||
}
|
||||
|
||||
.ply-loading-spinner {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
opacity: .9;
|
||||
background: #fff;
|
||||
border-radius: 100%;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
box-shadow: 0 1px 3px rgba(0,0,0,.6);
|
||||
}
|
||||
|
||||
.ply-loading-spinner::before {
|
||||
content: "";
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: #333;
|
||||
max-height: 0;
|
||||
-webkit-animation: loading 3s normal infinite;
|
||||
animation: loading 3s normal infinite;
|
||||
}
|
||||
|
||||
@keyframes loading {
|
||||
0% { max-height: 0; }
|
||||
50% { max-height: 100%; top: 0; }
|
||||
100% { max-height: 0; top: 120%; }
|
||||
}
|
||||
|
||||
@-webkit-keyframes loading {
|
||||
0% { max-height: 0; }
|
||||
50% { max-height: 100%; top: 0; }
|
||||
100% { max-height: 0; top: 120%; }
|
||||
}
|
||||
|
||||
|
||||
/* Layer */
|
||||
.ply-layer {
|
||||
color: #333;
|
||||
min-width: 280px;
|
||||
box-shadow: 0 0 3px rgba(0,0,0,.3);
|
||||
background-color: #fff;
|
||||
border-radius: 2px;
|
||||
font-size: 16px;
|
||||
font-family: "Arial", Helvetica;
|
||||
}
|
||||
.ply-layer.alert .ply-content,
|
||||
.ply-layer.confirm .ply-content {
|
||||
padding: 20px 0 15px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ply-layer.base .ply-footer,
|
||||
.ply-layer.alert .ply-footer,
|
||||
.ply-layer.confirm .ply-footer,
|
||||
.ply-layer.prompt .ply-footer {
|
||||
margin-top: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ply-inside {
|
||||
padding: 20px;
|
||||
}
|
||||
|
||||
.ply-header {
|
||||
margin: -20px -20px 20px;
|
||||
padding: 10px 20px;
|
||||
font-size: 18px;
|
||||
background-color: #f1f1f1;
|
||||
border-radius: 2px 2px 0 0;
|
||||
}
|
||||
|
||||
.ply-content {
|
||||
}
|
||||
|
||||
.ply-footer {
|
||||
}
|
||||
.ply-footer .ply-ctrl {
|
||||
margin-left: 20px;
|
||||
}
|
||||
.ply-footer .ply-ctrl:first-child {
|
||||
margin-left: 0;
|
||||
}
|
||||
|
||||
|
||||
/* Controls */
|
||||
.ply-x {
|
||||
top: 12px;
|
||||
right: 5px;
|
||||
cursor: pointer;
|
||||
padding: 5px;
|
||||
z-index: 1000;
|
||||
position: absolute;
|
||||
font-size: 20px;
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
.ply-ok,
|
||||
.ply-cancel {
|
||||
color: #fff;
|
||||
cursor: pointer;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
padding: 5px 20px;
|
||||
box-shadow: 0 1px 1px rgba(0,0,0,.2);
|
||||
background-color: #39C082;
|
||||
border-radius: 3px;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.ply-ok {
|
||||
width: 100px;
|
||||
}
|
||||
|
||||
.ply-cancel {
|
||||
background-color: #b2b2b2;
|
||||
}
|
||||
.ply-ok:focus,
|
||||
.ply-cancel:focus {
|
||||
box-shadow: 0 0 1px 2px rgba(255, 180, 0, .6);
|
||||
border: 2px solid rgb(255, 210, 102)\9;
|
||||
}
|
||||
|
||||
.ply-ok::-moz-focus-inner,
|
||||
.ply-cancel::-moz-focus-inner {
|
||||
border: 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Forms */
|
||||
.ply-input {
|
||||
width: 100%;
|
||||
border: 2px solid #ccc;
|
||||
outline: 0;
|
||||
padding: 5px 10px;
|
||||
margin-top: 15px;
|
||||
font-size: 16px;
|
||||
font-family: "Arial", Helvetica;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.ply-input:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.ply-input:focus {
|
||||
border-color: #39C082;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Global modifiers */
|
||||
.ply-invalid .ply-input {
|
||||
border-color: #c00;
|
||||
}
|
||||
|
||||
.ply-loading:before {
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
display: block;
|
||||
content: '';
|
||||
position: absolute;
|
||||
}
|
||||
|
||||
.ply-loading .ply-ok {
|
||||
color: rgba(255,255,255,.7);
|
||||
-webkit-animation: ply-ok-loading 1s linear infinite;
|
||||
-moz-animation: ply-ok-loading 1s linear infinite;
|
||||
animation: ply-ok-loading 1s linear infinite;
|
||||
-webkit-background-size: 30px 30px;
|
||||
-moz-background-size: 30px 30px;
|
||||
background-size: 30px 30px;
|
||||
background-image: -webkit-gradient(linear, left top, right bottom,
|
||||
color-stop(.25, rgba(255, 255, 255, .15)), color-stop(.25, transparent),
|
||||
color-stop(.5, transparent), color-stop(.5, rgba(255, 255, 255, .15)),
|
||||
color-stop(.75, rgba(255, 255, 255, .15)), color-stop(.75, transparent),
|
||||
to(transparent));
|
||||
background-image: -webkit-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
|
||||
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
|
||||
transparent 75%, transparent);
|
||||
background-image: -moz-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
|
||||
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
|
||||
transparent 75%, transparent);
|
||||
background-image: -ms-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
|
||||
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
|
||||
transparent 75%, transparent);
|
||||
background-image: -o-linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
|
||||
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
|
||||
transparent 75%, transparent);
|
||||
background-image: linear-gradient(135deg, rgba(255, 255, 255, .15) 25%, transparent 25%,
|
||||
transparent 50%, rgba(255, 255, 255, .15) 50%, rgba(255, 255, 255, .15) 75%,
|
||||
transparent 75%, transparent);
|
||||
}
|
||||
|
||||
@-webkit-keyframes ply-ok-loading {
|
||||
to { background-position: 60px; }
|
||||
}
|
||||
|
||||
@-moz-keyframes ply-ok-loading {
|
||||
to { background-position: 60px; }
|
||||
}
|
||||
|
||||
@keyframes ply-ok-loading {
|
||||
to { background-position: 60px; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user