日期:2014-05-16 浏览次数:20454 次
var msgObj;
function showMessage(message, url, headImageType) {
if(message!=null && message!=''){
msgObj = new MessageObj(message, url, headImageType, true);
msgObj.show();
}else{
msgObj = null;
}
}
function loadingMessage(count, message, headImageType, isClose) {
msgObj = new MessageObj(message, null, headImageType, isClose);
msgObj.waiting(count);
}
var show_message_loading_image = new Array();
show_message_loading_image[0] = 'image/13221814.gif';
show_message_loading_image[1] = 'image/05043130.gif';
show_message_loading_image[2] = 'image/13221818.gif';
show_message_loading_image[3] = 'image/13221815.gif';
var show_message_Head_image = new Array();
show_message_Head_image['warn'] = 'image/error.png';
show_message_Head_image['accept'] = 'image/accept.png';
show_message_Head_image['info'] = 'image/information.png';
show_message_Head_image['error'] = 'image/exclamation.png';
show_message_Head_image['help'] = 'image/help.png';
show_message_Head_image['star'] = 'image/star.png';
show_message_Head_image['stop'] = 'image/stop.png';
show_message_Head_image['new'] = 'image/new.png';
function MessageObj(message, url, headImageType, isClose){
this.message = (message==null||message=='') ? " Waiting…" : message;
this.url = (url==null||url=='') ? null : url;
this.isClose = (isClose==null) ? false : isClose;
this.body = document.getElementById('body');
this.msg = this.createDiv("message_show", "message_show");
this.msgBg = this.createDiv("message_bg", "message_bg");
this.msgMain = this.createDiv("message_main", "message_main");
this.msgMainBody = this.createDiv("message_body", "message_body");
this.msgMainHead = this.createDiv("message_head", "message_head");
this.msgMainFoot = this.createDiv("message_foot", "message_foot");
this.loading_image = show_message_loading_image;
if(headImageType!=null){
this.headImage = show_message_Head_image[headImageType];
}else{
this.headImage = show_message_Head_image['warn'];
}
if(isClose){
this.closeImg = this.createCloseImage();
this.closeButton = this.createButton();
}
}
MessageObj.prototype.show = function() {
if (this.message!=null && this.message!='') {
if(this.isClose){
this.msgMainHead.appendChild(this.closeImg);
this.msgMainFoot.appendChild(this.closeButton);
}
this.msgMainHead.appendChild(this.createImage(this.headImage, "head_type", ""));
var span = document.createElement("span");
span.className = "span";
span.appendChild(this.createText());
this.msgMainHead.appendChild(span);
this.msgMainBody.appendChild(this.createText(this.message, true));
this.msgMain.appendChild(this.msgMainHead);
this.msgMain.appendChild(this.msgMainBody);
this.msgMain.appendChild(this.msgMainFoot);
this.msg.appendChild(this.msgBg);
this.msg.appendChild(this.msgMain);
this.body.parentNode.insertBefore(this.msg, this.body);
msgObj.center();
}
}
MessageObj.prototype.waiting = function (count) {
var image ;
if(count==null||count<0||count>this.loading_image.length){
image = this.loading_image[0];
}else{
image = this.loading_image[count];
}
this.msgMainBody.appendChild(this.createImage(image, "", " Waiting..."));
if(this.isClose){
this.msgMainHead.appendChild(this.closeImg);
this.msgMainFoot.appendChild(this.closeButton);
}
this.msgMainHead.appendChild(this.createImage(this.headImage, "head_type", ""));
var span = document.createElement("span");
span.className = "span";
span.appendChild(this.createText());
this.msgMainHead.appendChild(span);
span = document.createElement("span");
span.className = "span";
span.appendChild(this.createText(this.message, true));
this.msgMainBody.appendChild(span);
this.msgMain.appendChild(this.msgMainHead);
this.msgMain.appendChild(this.msgMainBody);
this.msgMain.appendChild(this.msgMainFoot);
this.msg.appendChild(this.msgBg);
this.msg.appendChild(this.msgMain);
this.body.p