//'/service?wdApplication=env&wdService=env.getAllNz&wdToken=2&now=s' var nzinterval var data = {}; var h6; var nzdatas; var errorTimes = 0; var maxErrorTimes = 3; initNz(); function initData() { $.ajax({ /* 改。Lin url: "/service?wdApplication=zzfb_&wdService=getAllNz&wdToken=2&now=" + new Date().Format("yyyy-MM-dd hh:mm:ss"), */ url: "/service?ssServ=selAllSched&ssToken=2&now="+ new Date().Format("yyyy-MM-dd hh:mm:ss"), // dataType:"json", success: function(dat) { data = eval("(" + dat + ")"); nzdatas = document.getElementById("nzdatas"); if (!nzdatas) { console.log("append"); $("body").append(""); } console.log($("#nzdatas")[0]); document.getElementById("nzdatas").innerHTML = dat; if (data.length > 0 && h6) { var lis = ''; var now = new Date(); $.each(data, function(i) { var kssj = new Date(this.start); var sjstr; if (now.Format("yyyy-MM-dd") == kssj.Format("yyyy-MM-dd")) { sjstr = kssj.Format("hh:mm:ss"); } else { sjstr = this.start; } lis += '
  • ' + sjstr + ': ' + this.title + '
  • ' if (i >= 10) { return false; } }); var f = window.top.data[0]; var fsj = new Date(f.start); var sj; if (now.Format("yyyy-MM-dd") == fsj.Format("yyyy-MM-dd")) { sj = fsj.Format("hh:mm:ss"); } else { if(now.getFullYear() == fsj.getFullYear()) sj = fsj.Format("MM-dd hh:mm:ss"); else sj = f.start; } console.log("sj"+ sj); $.each(h6, function(index) { var s = ""; if (data.length > 1) { s = ""; } $(this).html("
    " + sj + ":" + f.title + "" + s + "
    "); }); } else if (data.length == 0) { $.each(h6, function(index) { $(this).html(new Date().Format("yyyy-MM-dd E")); }); } $(h6).find("span").on("click", function(e) { var t = $(this); var id = t.attr("id"); if (!id) { return; } window.top.rcapid = id; var jj = $(h6).parent().find(".showcal").eq(0).val(); console.log(jj); eval(jj); return false; }); $(h6).find("li").on('click', function(e) { var t = $(this); var id = t.attr("id"); window.top.rcapid = id; var jj = $(h6).parent().find(".showcal").eq(0).val(); console.log(jj); eval(jj); return false; }); $(h6).find("div").on("click", function() { eval($(h6).parent().find(".showcal").eq(0).val()); }); }, //请求出现错误 error: function(dat){ errorTimes++; //超过三次 删除定时器 if(maxErrorTimes > errorTimes){ ; }else{ if(undefined != nzinterval) clearInterval(nzinterval); } }, async: false }); } function initNz() { if(!nzinterval) { nzinterval = setInterval( function() { var now = new Date(); $.each( data, function(a) { var b = this var nowStr = now .Format("yyyy-MM-dd hh:mm:ss"); var dataTime = new Date(b.start); var dataTimeStr = dataTime .Format("yyyy-MM-dd hh:mm:ss") if(nowStr == dataTimeStr) { // wd.display // .showComponent({ // show: ["wdDialog"], // hide: [], // url: "/service?wdApplication=env&wdService=env.xgNz&wdOutputComponent=440122853&wdtest=false&wdComponentWebsite=4461&rcapid=" + b.id, // dest: "env.grsydialog.tip", // title: "闹钟提醒", // width: 650, // high: 450, // wdDialogId: 440122853, // form: "" // }); //shownzjs = shownzjs.replace("ID=ID", "rcapid=" + b.id); var json = JSON.parse('{"ID":"'+b.id+'"}'); shownzjs = wd.display.replaceDynamicParam(shownzjs, json); eval(shownzjs); //console.log(shownzjs); data.splice(a, 1); return false; } if(now > dataTime) { // 如果存在小于现在的时间,重新获取闹钟时间 initData(); return false; } }); }, 1000); } else { initData(); } }