📄 wm_ads.js
字号:
jspp.using("mocom.WAPmo.Kernel");
jspp.using("mocom.WAPmo.OptionCard");
jspp.Ads = {
page : 0,
keyword : null,
doPage : function(page)
{
jspp.Ads.page = page;
MessageBox.show(MSG_WAITING, "正在获取广告列表……");
var rpc = new xmlrpc();
rpc.setData("Handle", "list");
if (jspp.Ads.keyword && jspp.Ads.keyword != "") rpc.setData("Keyword", jspp.Ads.keyword);
rpc.setData("Page", page);
rpc.callBack = function()
{
var http = rpc.http;
if (http.readyState == 4)
{
if (http.status == 200)
{
MessageBox.close();
document.getElementById("_list_").innerHTML = http.responseText;
}
else
{
MessageBox.write("获取广告列表错误:" + http.responseText);
MessageBox.setType(MSG_WARNING);
}
}
};
rpc.doGet("admin_ads.asp", true);
},
query : function(frm)
{
jspp.Ads.keyword = frm.Keyword.value;
jspp.Ads.doPage(0);
},
add : function()
{
var box = new xWindow("frmAdd", "width=422,height=344,minButton=false,maxButton=false", true);
box.setCaption(jspp.Caption + " - 新增广告");
box.draw(Kernel.getRemoteFile("templet/wm_ads_add.html"), 10, 10);
box.center();
var _accept = Form.child("frmTemplet.Accept");
_accept.onclick = function()
{
var cat = Form.item("frmTemplet.Category");
var tit = Form.item("frmTemplet.Title");
var con = Form.item("frmTemplet.Content");
jspp.Ads.doAdd(cat, tit, con);
};
var _cancel = Form.child("frmTemplet.Cancel");
_cancel.onclick = function()
{
box.free();
};
},
doAdd : function(cat, tit, con)
{
MessageBox.show(MSG_WAITING, "初始化服务请求……");
var rpc = new xmlrpc();
rpc.setData("Category", cat);
rpc.setData("Title", tit);
rpc.setData("Content", con);
rpc.callBack = function()
{
var http = rpc.http;
switch (http.readyState)
{
case 1:
MessageBox.write("正在连接服务程序……");
break;
case 2:
MessageBox.write("已连接服务程序……");
break;
case 3:
MessageBox.write("正在返回状态报告……");
break;
case 4:
var ret = http.responseText;
if (ret == "OK")
{
MessageBox.write("<font color=\"#0000FF\">新增广告成功</font>");
MessageBox.setType(MSG_HINT);
MessageBox.doAccept(function()
{
jspp.window.frmAdd.free();
jspp.Ads.doPage(jspp.Ads.page);
}, true);
}
else
{
MessageBox.write("<font color=\"#FF0000\">新增广告失败:" + ret + "</font>");
MessageBox.setType(MSG_WARNING);
}
rpc.close();
rpc = null;
break;
}
};
rpc.doPost("admin_ads.asp?Handle=Add", true);
},
control : function(obj, id)
{
switch (atol(obj.value))
{
case 0:
break;
case 1:
jspp.Ads.modify(id);
break;
case 2:
jspp.Ads.remove(id);
break;
}
obj.selectedIndex = 0;
},
getChecked : function(frm)
{
var ptr = frm.getElementsByTagName("INPUT");
var arr = new Array();
for (var i = 0; i < ptr.length; i++)
{
if (ptr[i].id == "SeqId" && ptr[i].checked == true)
{
arr.push(ptr[i].value);
}
}
return(arr);
},
modify : function(id)
{
var box = new xWindow("frmModify", "width=422,height=344,minButton=false,maxButton=false", true);
box.setCaption(jspp.Caption + " - 编辑广告");
box.draw(Kernel.getRemoteFile("admin_ads.asp?Handle=Modify&SeqId=" + id), 10, 10);
box.center();
var _accept = Form.child("frmTemplet.Accept");
if (_accept)
{
_accept.onclick = function()
{
var cat = Form.item("frmTemplet.Category");
var tit = Form.item("frmTemplet.Title");
var con = Form.item("frmTemplet.Content");
jspp.Ads.doModify(id, cat, tit, con);
};
}
var _cancel = Form.child("frmTemplet.Cancel");
if (_cancel)
{
_cancel.onclick = function()
{
box.free();
};
}
},
doModify : function(id, cat, tit, con)
{
MessageBox.show(MSG_WAITING, "初始化服务请求……");
var rpc = new xmlrpc();
rpc.setData("Category", cat);
rpc.setData("Title", tit);
rpc.setData("Content", con);
rpc.callBack = function()
{
var http = rpc.http;
switch (http.readyState)
{
case 1:
MessageBox.write("正在连接服务程序……");
break;
case 2:
MessageBox.write("已连接服务程序……");
break;
case 3:
MessageBox.write("正在返回状态报告……");
break;
case 4:
var ret = http.responseText;
if (ret == "OK")
{
MessageBox.write("<font color=\"#0000FF\">编辑广告成功</font>");
MessageBox.setType(MSG_HINT);
MessageBox.doAccept(function()
{
jspp.window.frmModify.free();
jspp.Ads.doPage(jspp.Ads.page);
}, true);
}
else
{
MessageBox.write("<font color=\"#FF0000\">编辑广告失败:" + ret + "</font>");
MessageBox.setType(MSG_WARNING);
}
rpc.close();
rpc = null;
break;
}
};
rpc.doPost("admin_ads.asp?Handle=Modify&SeqId=" + id, true);
},
remove : function(id)
{
MessageBox.show(MSG_CONFIRM, "您确定要删除该广告么?");
MessageBox.doAccept(function()
{
jspp.Ads.doRemove(id);
}, true);
},
doRemove : function(id)
{
MessageBox.show(MSG_WAITING, "初始化服务请求……");
var rpc = new xmlrpc();
rpc.setData("SeqId", id);
rpc.callBack = function()
{
var http = rpc.http;
switch (http.readyState)
{
case 1:
MessageBox.write("正在连接服务程序……");
break;
case 2:
MessageBox.write("已连接服务程序……");
break;
case 3:
MessageBox.write("正在返回状态报告……");
break;
case 4:
var ret = http.responseText;
if (ret == "OK")
{
MessageBox.write("<font color=\"#0000FF\">广告删除成功</font>");
MessageBox.setType(MSG_HINT);
MessageBox.doAccept(function()
{
jspp.Ads.doPage(jspp.Ads.page);
}, true);
}
else
{
MessageBox.write("<font color=\"#FF0000\">广告删除失败:" + ret + "</font>");
MessageBox.setType(MSG_WARNING);
}
rpc.close();
rpc = null;
break;
}
};
rpc.doPost("admin_ads.asp?Handle=Remove", true);
},
removeAll : function(frm)
{
var arr = jspp.Ads.getChecked(frm);
if (arr.length == 0)
{
MessageBox.show(MSG_WARNING, "请选择您要删除的广告");
return;
}
MessageBox.show(MSG_CONFIRM, "您确定要删除所有选定的广告么?");
MessageBox.doAccept(function()
{
jspp.Ads.doRemove(arr.join(","));
}, true);
}
};
window.onload = function()
{
var opt = new OptionCard();
opt.add("广告管理");
opt.make(document.body, 5, 5);
opt.lock(0);
jspp.Ads.doPage(0);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -