mirror of
https://github.com/bs-community/blessing-skin-server.git
synced 2024-12-21 06:19:38 +08:00
86 lines
2.4 KiB
JavaScript
86 lines
2.4 KiB
JavaScript
/*
|
|
* @Author: prpr
|
|
* @Date: 2016-02-04 16:48:42
|
|
* @Last Modified by: prpr
|
|
* @Last Modified time: 2016-02-04 17:09:20
|
|
*/
|
|
|
|
'use strict';
|
|
|
|
function showUpload(uname, type) {
|
|
var ply = new Ply({
|
|
el: '<h2>Upload new '+type+':</h2><input type="file" id="file" accept="image/png"><button id="upload" class="pure-button pure-button-primary fw">Upload</button>',
|
|
effect: "fade",
|
|
onaction: function(){ upload(uname, type, $('#file').get(0).files[0]); },
|
|
});
|
|
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 showAlert(msg) {
|
|
Ply.dialog("alert", msg);
|
|
}
|
|
|
|
function showChange(uname) {
|
|
Ply.dialog("prompt", {
|
|
title: "Type in "+uname+"'s new password",
|
|
form: { passwd: "New Password" }
|
|
}).done(function(ui){
|
|
var passwd = ui.data.passwd;
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "admin_ajax.php?action=change&uname="+uname,
|
|
dataType: "json",
|
|
data: { "passwd": passwd },
|
|
success: function(json) {
|
|
if (json.errno == 0) {
|
|
showAlert(json.msg);
|
|
} else {
|
|
showAlert(json.msg);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
|
|
function showDelete(uname) {
|
|
Ply.dialog("prompt", {
|
|
title: "Are you sure to delete "+uname+"?",
|
|
}).done(function(ui){
|
|
$.ajax({
|
|
type: "POST",
|
|
url: "admin_ajax.php?action=delete&uname="+uname,
|
|
dataType: "json",
|
|
success: function(json) {
|
|
if (json.errno == 0) {
|
|
showAlert(json.msg);
|
|
} else {
|
|
showAlert(json.msg);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|