65 行
2.3 KiB
Plaintext
65 行
2.3 KiB
Plaintext
<#--左边区域自定义块-->
|
|
<#function zhiqim_manager_topnav_left_defined()>
|
|
${zhiqim_announcement_onload()}
|
|
</#function>
|
|
|
|
<#--公告加载-->
|
|
<#function zhiqim_announcement_onload()>
|
|
<script>
|
|
var ws = null;
|
|
var isClose = true;
|
|
var num = 0;
|
|
Z.onload(function()
|
|
{
|
|
/*
|
|
//1.首次登录如果有公告的,要求立即提醒
|
|
<#if sessionUser.getValue("zoa_announcement_close") != "true" && ZoaAnnouncementDao.hasUnReadAnnouncement(request)>
|
|
top.Z.alert("有未读的公告,请进入阅读,谢谢!", doClose);
|
|
</#if>
|
|
|
|
//2.建立WS,新公告时提醒
|
|
if (window.globalWebSocket)
|
|
ws = globalWebSocket.connect((location.protocol=="https:"?"wss:":"ws:")+"//"+location.hostname+":"+location.port+"/service/ws", "zoa_announcement");
|
|
else
|
|
ws = new WebSocket((location.protocol=="https:"?"wss:":"ws:")+"//"+location.hostname+":"+location.port+"/service/ws", "zoa_announcement");
|
|
ws.onopen = function(){console.log("ws.onopen");isClose=false;};
|
|
ws.onclose = function(e){console.log("ws.onclose");isClose=true;};
|
|
ws.onerror = function(e){console.log("ws.onerror");isClose=true;};
|
|
ws.onmessage = function(e){console.log("ws.onmessage:"+e.data);if (e.data == "zoa_announcement_new"){top.Z.alert("有新的公告发布,请在方便的时候进入阅读,谢谢!");}};
|
|
|
|
Z.timer(1000, 10, null, doSend);
|
|
*/
|
|
});
|
|
|
|
|
|
function doSend()
|
|
{
|
|
if (ws == null || ws.readyState == 2 || ws.readyState == 3)
|
|
console.log("已关闭");
|
|
else if (ws.readyState == 0)
|
|
console.log("未开启");
|
|
else
|
|
{
|
|
console.log("发送");
|
|
ws.send("一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十一二三四五六七八九十");
|
|
}
|
|
|
|
num++;
|
|
|
|
// if (num == 5)
|
|
// ws.close();
|
|
}
|
|
|
|
function doClose()
|
|
{
|
|
var ajax = new Z.Ajax();
|
|
ajax.setClassName("sessionUser");
|
|
ajax.setMethodName("setValue");
|
|
ajax.addParam("zoa_announcement_close")
|
|
ajax.addParam("true");
|
|
ajax.setSuccess(function(){Z.L.href("${context.getRootPath("/zhiqimAnnouncement/announcement.htm")}", window.mainFrame);});
|
|
ajax.execute();
|
|
}
|
|
</script>
|
|
</#function>
|