/* ----- */ var thistime; FuturesListPage = new function(){ this.dataArray; this.currentColumn = "1"; this.divName = "FuturesListPage"; this.columnArray = new Array(); this.reloadTime = 50000;//刷新数据时间间隔,1000是1秒 this.reload = true; this.setTimeObj; this.GetData = function(array,time) { this.dataArray = array; thistime=time; //this.ShowPage(FuturesListRequest.page,FuturesListRequest.totalpage); this.LoadDataFinish(); } this.LoadDataFinish = function() { var hc = new Array(); hc.push(""); hc.push(""); hc.push(""); hc.push(""); hc.push(""); var su=1; for(var i=0;i < this.dataArray.length; i++){ hc.push(""); hc.push("");//名称 if(this.GetTextCode(this.dataArray[i][0]) == "au" || this.GetTextCode(this.dataArray[i][0]) == "if") { hc.push("");//最新价 hc.push("");//涨跌 } else { hc.push("");//最新价 hc.push("");//涨跌 } su=su+1; //if(su>8) break; } hc.push("
更新时间:"+thistime+"
名称最新价涨跌" + this.dataArray[i][1] + "" + Common.GetColor2DEC(this.dataArray[i][2],this.dataArray[i][10]) + "" + Common.GetColor2DEC(this.dataArray[i][3],0) + "" + Common.GetColor(this.dataArray[i][2],this.dataArray[i][10]) + "" + Common.GetColor(this.dataArray[i][3],0) + "
"); Common.$(this.divName).innerHTML = hc.join(''); if(this.reload){ clearTimeout(this.setTimeObj); this.setTimeObj = setTimeout(this.AutoReload,this.reloadTime);//按设置时间重读数据 } } this.AutoReload = function(){ FuturesListRequest.Request(); } this.ShowTime = function(time) { //Common.$("topupdatetime").innerHTML = time; //Common.$("updatetime").innerHTML = time; } this.ShowPage = function(page,total){ Common.$("pagenum").innerHTML = page + "/" + total; } this.DataSort = function(column) { if(this.columnArray[column] == "down" || this.columnArray[column] == undefined) { this.columnArray[column] = "up"; this.ArraySort(column,"up"); } else { this.columnArray[column] = "down"; this.ArraySort(column,"down"); } } this.ArraySort = function(column,order) { if(order == "up"){ this.dataArray.sort(function(a,b){ return b[column]-a[column]; }); } if(order == "down"){ this.dataArray.sort(function(a,b){ return a[column]-b[column]; }); } this.currentColumn = column; this.LoadDataFinish(); } this.TrBgColor = function(i) { if(i%2 == 0){ return " bgcolor=\"#ffffff\""; }else{ return " bgcolor=\"#f7f7f7\""; } return ""; } this.TdBgColor = function(i,column) { if(column == this.currentColumn){ if(i%2 == 0){ return " bgcolor=\"#FFF3EB\""; }else{ return " bgcolor=\"#F9ECE4\""; } } return ""; } this.Arrow = function(column) { if(column == this.currentColumn){ if(this.columnArray[column] == "up"){ return ""; }else{ return ""; } } return ""; } this.GetTextCode = function(code) { var re = new RegExp(/\d/g); return code.replace(re,'').toLowerCase(); } this.GetLink = function(code) { code = this.GetTextCode(code); var url = "http://futures.hexun.com/sugar/index.html"; return url; } }