5cc09170256b20d5990927bf53b8dc36335555d5.svn-base 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. var StartMarquee=null;
  2. var timeOut=null;
  3. var t=null;
  4. var userinfo = new Util().resolveUrl();
  5. $(function(){
  6. init();
  7. addMainContentMouseListen();
  8. });
  9. function init(){
  10. if(StartMarquee!=null){
  11. StartMarquee.clearStartMarquee();
  12. }
  13. loadTitle();
  14. $.post(path+"ws/IntelligenceService/IntelligenceService/getIntelligenc",{},function(result){
  15. if(result.state=="FAILURE") throw new Error("查询失败");
  16. if(result.rows.length>0){
  17. load($("#main_content1"),result.rows);
  18. }else{
  19. $("#main_content1").append("<p class='_error'>目前尚无公开发表的情报信息</p>");
  20. };
  21. },"json");
  22. }
  23. //显示表头
  24. function loadTitle(){
  25. $("#main_content1").empty();
  26. $("#main_content1").append("<span class='title_text'>"+userinfo.dept_name+"情报板展示</span>");
  27. $.post(path+"ws/IntelligenceService/IntelligenceService/getTitle",{},function(result){
  28. if(result.state=="FAILURE") throw new Error("查询失败");
  29. if(result.rows.length>0){
  30. //$("#main_content1").append("<span class='title_text'>"+result.rows[0].TITLENAME+"</span>")
  31. }else{
  32. $("#main_content1").append("<p class='_error'>目前尚无公开发表的情报信息</p>");
  33. }
  34. },"json");
  35. }
  36. //显示情报板信息
  37. function load($dom,param){
  38. if(param.length==0) throw new Error("数据异常");
  39. $ul=$("<ul></ul>");
  40. for(var index in param){
  41. $li=$("<li><span class='_li_content'><span class='_date'>"+param[index]["PLANKDATE"]+"</span><span class='_contentInfo'>"+param[index]["PLANKINFO"]+"</span></span></li>");
  42. $ul.append($li);
  43. }
  44. $dom.append("<div class=_center1></div>");
  45. $dom.find("._center1").append($ul);
  46. setContentPosition();
  47. StartMarquee=startmarquee(20, 30, 1000);
  48. }
  49. var tempWidht;
  50. var count=0;
  51. //设置ul-li居中左对其
  52. function setContentPosition(){
  53. $("._center1").removeAttr("style");
  54. var maxwidth=0;
  55. $("#main_content1").find("._li_content").each(function(){
  56. maxwidth=maxwidth>$(this).width()?maxwidth:$(this).width();
  57. });
  58. $("._center1").css({width:$("#main_content1").width()*0.95>maxwidth?maxwidth:$("#main_content1").width()*0.95});
  59. }
  60. function startmarquee(lh,speed,delay) {
  61. var clearStartMarquee=function(){
  62. clearInterval(t);
  63. clearTimeout(timeOut);
  64. };
  65. var oHeight =$(".main_content1").height();
  66. var p = false;
  67. var o = $("._center1").get(0);
  68. var preTop = 0;
  69. o.scrollTop = 0;
  70. function start() {
  71. t = setInterval(scrolling, speed);
  72. o.scrollTop += 1;
  73. }
  74. function scrolling() {
  75. if (o.scrollTop % lh != 0
  76. && o.scrollTop % (o.scrollHeight - oHeight - 1) != 0) {
  77. preTop = o.scrollTop;
  78. o.scrollTop += 1;
  79. if (preTop >= o.scrollHeight || preTop == o.scrollTop) {
  80. o.scrollTop = 5;
  81. }
  82. } else {
  83. clearInterval(t);
  84. timeOut=setTimeout(start, delay);
  85. }
  86. }
  87. timeOut=setTimeout(start, delay);
  88. return {clearStartMarquee:clearStartMarquee,startScroll:start};
  89. }
  90. function addMainContentMouseListen(){
  91. $("#main_content1").on("mouseenter",function(){
  92. StartMarquee.clearStartMarquee();
  93. });
  94. $("#main_content1").on("mouseleave",function(){
  95. StartMarquee.startScroll();
  96. });
  97. }
  98. $(window).resize(function(){
  99. setContentPosition();
  100. });