fixed refreshing DOM without src attribute
This commit is contained in:
parent
d7317b98cb
commit
fccb628eef
|
|
@ -2,7 +2,7 @@
|
|||
* @Author: printempw
|
||||
* @Date: 2016-02-04 16:48:42
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-04-03 08:35:15
|
||||
* @Last Modified time: 2016-04-03 09:12:46
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
|
@ -40,12 +40,13 @@ function uploadTexture(uname, type) {
|
|||
success: function(json) {
|
||||
if (json.errno == 0) {
|
||||
showAlert("上传成功。");
|
||||
if (type == "steve") $('[src="../skin/' + uname + '-steve.png"]').prop('src',
|
||||
$('[src="../skin/' + uname + '-steve.png"]').prop('src')+'?random');
|
||||
if (type == "alex") $('[src="../skin/' + uname + '-alex.png"]').prop('src',
|
||||
$('[src="../skin/' + uname + '-alex.png"]').prop('src')+'?random');
|
||||
if (type == "cape") $('[src="../cape/' + uname + '.png"]').prop('src',
|
||||
$('[src="../cape/' + uname + '.png"]').prop('src')+'?random');
|
||||
// refresh image
|
||||
if (type == "steve") $('#'+uname+'-steve').prop('src',
|
||||
'../skin/'+uname+'-steve.png?'+Math.round(Math.random() * 1000000));
|
||||
if (type == "alex") $('#'+uname+'-alex').prop('src',
|
||||
'../skin/'+uname+'-alex.png?'+Math.round(Math.random() * 1000000));
|
||||
if (type == "cape") $('#'+uname+'-cape').prop('src',
|
||||
'../cape/'+uname+'-.png?'+Math.round(Math.random() * 1000000));
|
||||
} else {
|
||||
showAlert("上传材质的时候出错啦:\n" + json.msg);
|
||||
}
|
||||
|
|
@ -87,9 +88,9 @@ function deleteTexture(uname) {
|
|||
if (json.errno == 0) {
|
||||
showAlert(json.msg);
|
||||
// remove DOM
|
||||
if (steve) $('[src="../skin/' + uname + '-steve.png"]').remove();
|
||||
if (alex) $('[src="../skin/' + uname + '-alex.png"]').remove();
|
||||
if (cape) $('[src="../cape/' + uname + '.png"]').remove();
|
||||
if (steve) $('#' + uname + '-steve').remove();
|
||||
if (alex) $('#' + uname + '-alex ').remove();
|
||||
if (cape) $('#' + uname + '-cape ').remove();
|
||||
} else {
|
||||
showAlert(json.msg);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
* @Author: printempw
|
||||
* @Date: 2016-01-21 13:55:44
|
||||
* @Last Modified by: printempw
|
||||
* @Last Modified time: 2016-04-03 08:13:36
|
||||
* @Last Modified time: 2016-04-03 09:29:41
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
function login(silent = false) {
|
||||
function login(silent) {
|
||||
var uname = $("#uname").val();
|
||||
var passwd = $("#passwd").val();
|
||||
if (checkForm("login", uname, passwd)) {
|
||||
|
|
@ -20,7 +20,6 @@ function login(silent = false) {
|
|||
$('#login-button').html('<i class="fa fa-spinner fa-spin"></i> 登录中').prop('disabled', 'disabled');
|
||||
},
|
||||
success: function(json) {
|
||||
console.log(json);
|
||||
if (json.errno == 0) {
|
||||
docCookies.setItem('uname', uname, null, '/');
|
||||
docCookies.setItem('token', json.token, null, '/');
|
||||
|
|
@ -134,6 +133,6 @@ $('body').on('keypress', '[data-remodal-id=register-modal]', function(event){
|
|||
|
||||
// Login Event
|
||||
$('body').on('keypress', '[data-remodal-id=login-modal]', function(event){
|
||||
if (event.which == 13) login();
|
||||
}).on('click', '#login-button', login);
|
||||
if (event.which == 13) login(false);
|
||||
}).on('click', '#login-button', function() { login(false); });
|
||||
|
||||
|
|
|
|||
|
|
@ -52,9 +52,9 @@
|
|||
<td><?php echo $row['uid']; ?></td>
|
||||
<td><?php echo $row['username']; ?></td>
|
||||
<td>
|
||||
<img width="64" <?php if ($row['hash_steve']): ?>src="../skin/<?php echo $row['username']; ?>-steve.png"<?php endif; ?> />
|
||||
<img width="64" <?php if ($row['hash_alex']): ?>src="../skin/<?php echo $row['username']; ?>-alex.png"<?php endif; ?> />
|
||||
<img width="64" <?php if ($row['hash_cape']): ?>src="../cape/<?php echo $row['username']; ?>.png"<?php endif; ?> />
|
||||
<img id="<?php echo $row['username']; ?>-steve" width="64" <?php if ($row['hash_steve']): ?>src="../skin/<?php echo $row['username']; ?>-steve.png"<?php endif; ?> />
|
||||
<img id="<?php echo $row['username']; ?>-alex" width="64" <?php if ($row['hash_alex']): ?>src="../skin/<?php echo $row['username']; ?>-alex.png"<?php endif; ?> />
|
||||
<img id="<?php echo $row['username']; ?>-cape" width="64" <?php if ($row['hash_cape']): ?>src="../cape/<?php echo $row['username']; ?>.png"<?php endif; ?> />
|
||||
</td>
|
||||
<td>
|
||||
<a href="javascript:uploadSkin('<?php echo $row['username']; ?>');" class="btn btn-primary btn-sm">皮肤</a>
|
||||
|
|
|
|||
|
|
@ -26,8 +26,8 @@
|
|||
if (User::checkValidUname($_POST['username']) &&
|
||||
($_POST['model_preference'] == 'default' || $_POST['model_preference'] == 'slim'))
|
||||
{
|
||||
$db->update($user->uname, 'username', $_POST['username']);
|
||||
$db->update($user->uname, 'preference', $_POST['model_preference']);
|
||||
$db->update('username', $_POST['username'], ['where' => "username='$user->uname'"]);
|
||||
$db->update('preference', $_POST['model_preference'], ['where' => "username='$user->uname'"]);
|
||||
echo '<div class="callout callout-success">设置已保存。</div>';
|
||||
} else {
|
||||
echo '<div class="callout callout-danger">无效的用户名或优先模型。</div>';
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user