Chinaunix首页 | 论坛 | 博客
  • 博客访问: 413179
  • 博文数量: 112
  • 博客积分: 4000
  • 博客等级: 上校
  • 技术积分: 905
  • 用 户 组: 普通用户
  • 注册时间: 2006-06-05 21:14
文章分类

全部博文(112)

文章存档

2009年(3)

2008年(24)

2007年(55)

2006年(30)

我的朋友

分类:

2007-09-10 16:36:55

 var exp=new Date();
 document.write(exp);
 exp.setTime(exp.getTime()+(365*24*60*60*1000));
 var beginMoving=false;
 var flagCookie = false;
 var count1 = 0;//记录排序到多少
 var change_number;
    var number_test=0;//传递参数
 window.onload = init;


function init()
{
 
 change_time();
 checkCount();
 change_content();
 flagCookie = true;
 var getcontent =GetCookie('count');
 var nameC = ""; //根据什么提取的信息
 var contentcookie; //cookie中提取的信息
 var oneContent;  //提取出来的内容
 var oneStyle;  //提取出来的样式
 
 //从cookie中提取出来值
 if(getcontent!=null&&flagCookie){
    flagCookie =false;
  for(m=0;m   nameC = m+"=";
   contentcookie=  GetConent(getcontent,nameC);
   oneContent= getOneContenVal(contentcookie)
   oneStyle = getOneContenStyle(contentcookie);
   secTable.cells[m].className=oneStyle;
   secTable.cells[m].innerHTML=oneContent;
  }
 }
}

//鼠标移动--开始
function MouseDownToMove(obj){
 obj.style.zIndex=1;
 obj.mouseDownY=event.clientY;
 obj.mouseDownX=event.clientX;
 beginMoving=true;
 obj.setCapture();
}

function MouseMoveToMove(obj){
  if(!beginMoving) return false;
  obj.style.top = (event.clientY-obj.mouseDownY);
  obj.style.left = (event.clientX-obj.mouseDownX);
  obj.style.cursor="move";
  obj.style.filter="alpha(opacity=70)";
}

function MouseUpToMove(obj){
 if(!beginMoving) return false;
 obj.releaseCapture();
 obj.style.top=0;
 obj.style.left=0;
 obj.style.zIndex=0;
 beginMoving=false;
 
 var tempRowIndex = 0;
 var tempRows = 0 ;
 var templeft=obj.mouseDownX-event.clientX;
 var i= 0;
 var cellIndex = obj.cellIndex;
 var content = obj.innerHTML;
 var style= obj.className;
 
 if(templeft<0){
 //从前面往后走
 templeft=event.clientX-obj.mouseDownX;
 tempCellIndex =(templeft-templeft%117)/117;
 i = cellIndex + tempCellIndex+1;
 }else{
 //从后面往前走
 tempCellIndex =(templeft-templeft%117)/117;
 i = cellIndex - tempCellIndex; 
 }
 
 var myTD = obj.parentElement.insertCell(i);
 myTD.onmousedown = function (){MouseDownToMove(myTD);};
 myTD.onmouseup = function (){MouseUpToMove(myTD);};
 myTD.onmousemove = function (){MouseMoveToMove(myTD);};
 myTD.onmouseover = function (){secBoard(myTD);};
 myTD.onmouseout = function (){out(i);};
 myTD.className = style;
 myTD.innerText = content;
 tempRows =0;
 obj.parentElement.deleteCell(obj.cellIndex);
}
//页面显示
 function secBoard(obj)
  {
  cookieContent = "0="+secTable.cells[0].innerHTML+","+secTable.cells[0].className+
      ";1="+secTable.cells[1].innerHTML+","+secTable.cells[1].className+
      ";2="+secTable.cells[2].innerHTML+","+secTable.cells[2].className+
      ";3="+secTable.cells[3].innerHTML+","+secTable.cells[3].className+";"; 
     var flag=null;//内容
  var flag2 = 0;//样式
  
  for(i=0;i   secTable.cells[i].className="sec1";
   obj.className="sec2";
  }
  for(i=0;i   mainTable.tBodies[i].style.display="none";
   if(mainTable.tBodies[i].id == obj.innerHTML)flag=i;  
  }
  if(flag!=null){mainTable.tBodies[flag].style.display="block";}
       amt();//启动cookie
 
  }
//cookie操作
 
  function amt(){
 if(cookieContent==null&&!flagCookie){return false};
  var content = cookieContent;
  var count = GetCookie('count');
  if(count == null){
      SetCookie('count',content);
    return true;
  }else{
    DeleteCookie('count');
    SetCookie('count',content,exp);
    return true;
 }
  
}
      
  function GetConent(content,name){
   var l = name.length;
   var len = content.length;
   var n =0;
   while(n   var j = n + l;
   if(content.substring(n,j)==name) return getContenVal(content,j);
   n = content.indexOf(";", n) + 1;
   if (n == 0) break;
  }
  }
  function getContenVal(content,offset){
     var endstr = content.indexOf(";",offset);
  if(endstr == -1) endstr = content.length;
  return unescape(content.substring(offset,endstr));
  } 
  function getOneContenVal(content){
     var endstr1 = content.indexOf(",",0);
  return unescape(content.substring(0,endstr1));
  }  
  function getOneContenStyle(content){
     var endstr2 = content.indexOf(",",0)+1;
  return unescape(content.substring(endstr2,content.length));
  }  


//设置Cookie

function GetCookie (name) {
 var arg = name + "=";
 var alen = arg.length;
 var clen = document.cookie.length;
 var i = 0;
 while (i < clen) {
  var j = i + alen;
  if (document.cookie.substring(i, j) == arg)
  return getCookieVal (j);
  i = document.cookie.indexOf(" ", i) + 1;
  if (i == 0) break;
 }
 return null;
}


function getCookieVal(offset) {
 var endstr = document.cookie.indexOf (";", offset);
 if (endstr == -1)
 endstr = document.cookie.length;
 return unescape(document.cookie.substring(offset, endstr));
}

 

function SetCookie (name, value) {
 var argv = SetCookie.arguments;
 var argc = SetCookie.arguments.length;
 var expires = (argc > 2) ? argv[2] : null;
 var path = (argc > 3) ? argv[3] : null;
 var domain = (argc > 4) ? argv[4] : null;
 var secure = (argc > 5) ? argv[5] : false;
 document.cookie = name + "=" + escape (value) +
 ((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
 ((path == null) ? "" : ("; path=" + path)) +
 ((domain == null) ? "" : ("; domain=" + domain)) +
 ((secure == true) ? "; secure" : "");
}

function DeleteCookie (name) {
 var exp = new Date();
 exp.setTime (exp.getTime() - 1);
 var cval = GetCookie (name);
 document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

function switchTab(tab)
{
 var oItem = document.getElementById("menu_tr").getElementsByTagName("div");
    for(var i=0; i  var x = oItem[i];
  x.className = "bj";
 }
    document.getElementById(tab).className = "bj1";
}


//时间的改变


Date.prototype.format = function(format) //author: meizz
{
var o = {
"M+" : this.getMonth()+1, //month
"d+" : this.getDate(), //day
"h+" : this.getHours(), //hour
"m+" : this.getMinutes(), //minute
"s+" : this.getSeconds(), //second
"q+" : Math.floor((this.getMonth()+3)/3), //quarter
"S" : this.getMilliseconds() //millisecond
}
if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
(this.getFullYear()+"").substr(4 - RegExp.$1.length));
for(var k in o)if(new RegExp("("+ k +")").test(format))
format = format.replace(RegExp.$1,
RegExp.$1.length==1 ? o[k] :
("00"+ o[k]).substr((""+ o[k]).length));
return format;
}

  //计算天数差的函数,通用

  function DateDiff(sDate1, sDate2){  //sDate1和sDate2是2002-12-18格式
    var aDate, oDate1, oDate2, iDays
    aDate = sDate1.split("-")
    oDate1 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])  //转换为12-18-2002格式
    aDate = sDate2.split("-")
    oDate2 = new Date(aDate[1] + '-' + aDate[2] + '-' + aDate[0])
    iDays = parseInt(Math.abs(oDate1 - oDate2) / 1000 / 60 / 60 /24)  //把相差的毫秒数转换为天数
    return iDays

  }

 function change_time(){
     var s1 = "2007-08-12"
     var s2 = new Date().format("yyyy-MM-dd");
     var number = DateDiff(s1,s2);
     change_number= number%30;
}

function checkCount() {
   if(change_number==0){
  count1 = GetCookie('count1');
  if(count1 >= 4)count1=0;
  number_test = count1;
  if (count1 == null) {
   count1=0;
   SetCookie('count1', count1, exp);
  }
  else {
   count1++;
   SetCookie('count1', count1, exp);
  }
 }
}
  function out(obj){
   document.getElementById("div" + number_test).style.display='none';
  }
  function over(obj){
   document.getElementById("div" + number_test).style.display="";
  }
  function out2(obj){
   document.getElementById("div_" + number_test).style.display='none';
  }
  function over2(obj){
   document.getElementById("div_" + number_test).style.display="";
  }
  function change_content(){
   var elements = document.getElementsByTagName("input");
   var input_content;
   switch(parseInt(number_test)){
    case 0:input_content ="手机:N71"
     break;
    case 1:input_content ="手机:N72"
     break;
    case 2:input_content ="手机:N73"
     break;
    default: input_content="手机:N74"
    }
  for (var i=0; i < elements.length; i++)elements[i].innerText = input_content;
  }

 function begin(){time_change.value="";}

 

阅读(1328) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~