blessing-skin-server/assets/js/utils.js
2016-03-05 21:49:33 +08:00

48 lines
1.1 KiB
JavaScript

/*
* @Author: prpr
* @Date: 2016-02-03 18:23:21
* @Last Modified by: printempw
* @Last Modified time: 2016-03-05 21:41:24
*/
'use strict';
function showMsg(type, msg) {
$("[id=msg]").removeClass().addClass("alert").addClass(type).html(msg);
}
function showAlert(msg, callback, callback2) {
callback = callback ? callback : new Function;
Ply.dialog("alert", msg).done(callback).fail(callback2);
}
function isMobile() {
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ) {
return true;
}
return false;
}
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);
}
});
}
$("#logout").click(function(){
logout(function(json){
showAlert(json.msg, function(){
window.location = "../index.php";
});
});
});