var stop = false;
$(document).ready(function() {
window.setTimeout(doAjaxBegin, 2000);
$('#wwwxkercom').hover(
function() {stop = true;$("#wwwxkercom").css("cursor","pointer")},
function() {stop = false;$("#wwwxkercom").css("cursor","default")}
);
doAjaxOnline();
})css
function createInfo(noticeMessageList,noticeInfoList){
var arrayObj = new Array();
var arrayObjInfo = new Array();
arrayObj = noticeMessageList;
for(var i = 0;i < arrayObj.length;i++){
var divData = $('<div>' + arrayObj[i] + '</div>').attr({id:i,title:noticeInfoList[i]});
$("#wwwxkercom").append(divData);
}
// 無數據時,間隔固定時間從新取值
if (noticeMessageList.length < 1) {
window.setTimeout(doAjaxBegin, 2000);
} else {
window.setTimeout(scrollstart, 2000);
}
}ajax
function scrollstart(){
var o = document.getElementById('wwwxkercom');json
if(!o.firstChild) {
// 滾動到最後一條,間隔固定時間從新取數據
window.setTimeout(doAjaxBegin, 2000);
} else {
// 間隔固定時間向上滾動
window.setTimeout(function(){scrollup(o,20,0)}, 2000);
}
}app
function scrollup(o,d,c){網站
if (stop == true) {
window.setTimeout(function(){scrollup(o,d,c)}, 2000);
} else if(d==c){
o.removeChild(o.firstChild);
window.setTimeout(scrollstart, 2000);
}
else{
ch=false;var s=3,c=c+s,l=(c>=d?c-d:0);
o.firstChild.style.marginTop=-c+l+'px';
window.setTimeout(function(){scrollup(o,d,c-l)},50);
}
}ui
function doAjaxBegin(){
var ctx = $("#ctx").val();
$.ajax({
type:"POST",
url: ctx + "/noticeManage/manageNotice.action",
data:{},
dataType:"json",
success: function(json){
createInfo(json.noticeMessageList,json.noticeInfoList);
},
error: function(json){
return false;
}
});
}
function doAjaxOnline(){
var ctx = $("#ctx").val();
$.ajax({
type:"POST",
url: ctx + "/noticeManage/onlineGet.action",
data:{},
dataType:"json",
success: function(json){
onLineGet(json.customStr,json.customNameStr,json.sellStr,json.sellNameStr);
},
error: function(json){
return false;
}
});
}url
function onLineGet(customStr,customNameStr,sellStr,sellNameStr){
var customStrL = new Array();
var customNameStrL = new Array();
var sellStrL = new Array();
var sellNameStrL = new Array();
customStrL = customStr;
customNameStrL = customNameStr;
sellStrL = sellStr;
sellNameStrL = sellNameStr;
for(var i = 0;i < customStrL.length;i++){
var subCustomStr = '<li class="icon-link" ><a href="http://wpa.qq.com/msgrd?v=3&uin=' + customStrL[i] + '&site=qq&menu=yes" target="blank">' + customNameStrL[i] + '</a></li>'
$("#ulInfo").append(subCustomStr);
}
for(var i = 0;i < sellStrL.length;i++){
var subSellStr = '<li class="icon-link" ><a href="http://wpa.qq.com/msgrd?v=3&uin=' + sellStrL[i] + '&site=qq&menu=yes" target="blank">' + sellNameStrL[i] + '</a></li>'
$("#ulInfo").append(subSellStr);
}
var lastOne='<li class="icon-home"><a href="#" onclick="toIndex();">網站首頁</a></li>';
var lastTwo='<li class="icon-close"><a id="exitbtn" href="#">退出</a></li>'
$("#ulInfo").append(lastOne);
$("#ulInfo").append(lastTwo);
}
rem