123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- var StartMarquee=null;
- var timeOut=null;
- var t=null;
- var userinfo = new Util().resolveUrl();
- $(function(){
- init();
- addMainContentMouseListen();
- });
- function init(){
- if(StartMarquee!=null){
- StartMarquee.clearStartMarquee();
- }
- loadTitle();
- $.post(path+"ws/IntelligenceService/IntelligenceService/getIntelligenc",{},function(result){
- if(result.state=="FAILURE") throw new Error("查询失败");
- if(result.rows.length>0){
- load($("#main_content1"),result.rows);
- }else{
- $("#main_content1").append("<p class='_error'>目前尚无公开发表的情报信息</p>");
- };
-
- },"json");
- }
- //显示表头
- function loadTitle(){
- $("#main_content1").empty();
- $("#main_content1").append("<span class='title_text'>"+userinfo.dept_name+"情报板展示</span>");
- $.post(path+"ws/IntelligenceService/IntelligenceService/getTitle",{},function(result){
- if(result.state=="FAILURE") throw new Error("查询失败");
- if(result.rows.length>0){
- //$("#main_content1").append("<span class='title_text'>"+result.rows[0].TITLENAME+"</span>")
- }else{
- $("#main_content1").append("<p class='_error'>目前尚无公开发表的情报信息</p>");
- }
- },"json");
- }
- //显示情报板信息
- function load($dom,param){
- if(param.length==0) throw new Error("数据异常");
- $ul=$("<ul></ul>");
- for(var index in param){
- $li=$("<li><span class='_li_content'><span class='_date'>"+param[index]["PLANKDATE"]+"</span><span class='_contentInfo'>"+param[index]["PLANKINFO"]+"</span></span></li>");
- $ul.append($li);
- }
- $dom.append("<div class=_center1></div>");
- $dom.find("._center1").append($ul);
- setContentPosition();
- StartMarquee=startmarquee(20, 30, 1000);
- }
-
- var tempWidht;
- var count=0;
- //设置ul-li居中左对其
- function setContentPosition(){
- $("._center1").removeAttr("style");
- var maxwidth=0;
- $("#main_content1").find("._li_content").each(function(){
- maxwidth=maxwidth>$(this).width()?maxwidth:$(this).width();
- });
- $("._center1").css({width:$("#main_content1").width()*0.95>maxwidth?maxwidth:$("#main_content1").width()*0.95});
- }
- function startmarquee(lh,speed,delay) {
- var clearStartMarquee=function(){
- clearInterval(t);
- clearTimeout(timeOut);
- };
-
- var oHeight =$(".main_content1").height();
- var p = false;
- var o = $("._center1").get(0);
- var preTop = 0;
- o.scrollTop = 0;
- function start() {
- t = setInterval(scrolling, speed);
- o.scrollTop += 1;
- }
- function scrolling() {
- if (o.scrollTop % lh != 0
- && o.scrollTop % (o.scrollHeight - oHeight - 1) != 0) {
- preTop = o.scrollTop;
- o.scrollTop += 1;
- if (preTop >= o.scrollHeight || preTop == o.scrollTop) {
- o.scrollTop = 5;
- }
- } else {
- clearInterval(t);
- timeOut=setTimeout(start, delay);
- }
- }
- timeOut=setTimeout(start, delay);
- return {clearStartMarquee:clearStartMarquee,startScroll:start};
- }
-
- function addMainContentMouseListen(){
- $("#main_content1").on("mouseenter",function(){
- StartMarquee.clearStartMarquee();
- });
- $("#main_content1").on("mouseleave",function(){
- StartMarquee.startScroll();
- });
- }
- $(window).resize(function(){
- setContentPosition();
- });
|