PHP+javascript液晶时钟


Posted in PHP onOctober 09, 2006

<?
  $size_small=5;//液晶宽度
  $size_big=25;//液晶长度
  $distance=10;//间距
  $color_back="#DDDDDD";
  $color_dark="#CCCCCC";
  $color_light="#000000";
  $number=0;
?>
<html>
<head>
<title>Timer</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<script language="javascript">
// *****************************************************************
//                   Written By Caocao
//                   caocao@eastday.com
//                   http://caocao.oso.com.cn
// *****************************************************************
function swapcolor(obj,onoff)//改变颜色
{
  if (onoff)
  {
    obj.style.background="<? echo $color_light;?>";
  }
  else
  {
    obj.style.background="<? echo $color_dark;?>";
  }
}

function change(number,timer)//处理数字显示
{
  switch (timer)
  {
    case 0:
      swapcolor(eval("time"+number+"0"),1);
      swapcolor(eval("time"+number+"1"),1);
      swapcolor(eval("time"+number+"2"),1);
      swapcolor(eval("time"+number+"3"),0);
      swapcolor(eval("time"+number+"4"),1);
      swapcolor(eval("time"+number+"5"),1);
      swapcolor(eval("time"+number+"6"),1);
      break;
    case 1:
      swapcolor(eval("time"+number+"0"),0);
      swapcolor(eval("time"+number+"1"),0);
      swapcolor(eval("time"+number+"2"),1);
      swapcolor(eval("time"+number+"3"),0);
      swapcolor(eval("time"+number+"4"),0);
      swapcolor(eval("time"+number+"5"),1);
      swapcolor(eval("time"+number+"6"),0);
      break;
    case 2:
      swapcolor(eval("time"+number+"0"),1);
      swapcolor(eval("time"+number+"1"),0);
      swapcolor(eval("time"+number+"2"),1);
      swapcolor(eval("time"+number+"3"),1);
      swapcolor(eval("time"+number+"4"),1);
      swapcolor(eval("time"+number+"5"),0);
      swapcolor(eval("time"+number+"6"),1);
      break;
    case 3:
      swapcolor(eval("time"+number+"0"),1);
      swapcolor(eval("time"+number+"1"),0);
      swapcolor(eval("time"+number+"2"),1);
      swapcolor(eval("time"+number+"3"),1);
      swapcolor(eval("time"+number+"4"),0);
      swapcolor(eval("time"+number+"5"),1);
      swapcolor(eval("time"+number+"6"),1);
      break;
    case 4:
      swapcolor(eval("time"+number+"0"),0);
      swapcolor(eval("time"+number+"1"),1);
      swapcolor(eval("time"+number+"2"),1);
      swapcolor(eval("time"+number+"3"),1);
      swapcolor(eval("time"+number+"4"),0);
      swapcolor(eval("time"+number+"5"),1);
      swapcolor(eval("time"+number+"6"),0);
      break;
    case 5:
      swapcolor(eval("time"+number+"0"),1);
      swapcolor(eval("time"+number+"1"),1);
      swapcolor(eval("time"+number+"2"),0);
      swapcolor(eval("time"+number+"3"),1);
      swapcolor(eval("time"+number+"4"),0);
      swapcolor(eval("time"+number+"5"),1);
      swapcolor(eval("time"+number+"6"),1);
      break;
    case 6:
      swapcolor(eval("time"+number+"0"),1);
      swapcolor(eval("time"+number+"1"),1);
      swapcolor(eval("time"+number+"2"),0);
      swapcolor(eval("time"+number+"3"),1);
      swapcolor(eval("time"+number+"4"),1);
      swapcolor(eval("time"+number+"5"),1);
      swapcolor(eval("time"+number+"6"),1);
      break;
    case 7:
      swapcolor(eval("time"+number+"0"),1);
      swapcolor(eval("time"+number+"1"),0);
      swapcolor(eval("time"+number+"2"),1);
      swapcolor(eval("time"+number+"3"),0);
      swapcolor(eval("time"+number+"4"),0);
      swapcolor(eval("time"+number+"5"),1);
      swapcolor(eval("time"+number+"6"),0);
      break;
    case 8:
      swapcolor(eval("time"+number+"0"),1);
      swapcolor(eval("time"+number+"1"),1);
      swapcolor(eval("time"+number+"2"),1);
      swapcolor(eval("time"+number+"3"),1);
      swapcolor(eval("time"+number+"4"),1);
      swapcolor(eval("time"+number+"5"),1);
      swapcolor(eval("time"+number+"6"),1);
      break;
    case 9:
      swapcolor(eval("time"+number+"0"),1);
      swapcolor(eval("time"+number+"1"),1);
      swapcolor(eval("time"+number+"2"),1);
      swapcolor(eval("time"+number+"3"),1);
      swapcolor(eval("time"+number+"4"),0);
      swapcolor(eval("time"+number+"5"),1);
      swapcolor(eval("time"+number+"6"),1);
      break;
  }
}

function show()//更新时间
{
  var now=new Date();
  change(0,Math.floor(now.getHours()/10));
  change(1,Math.floor(now.getHours()%10));
  change(2,Math.floor(now.getMinutes()/10));
  change(3,Math.floor(now.getMinutes()%10));
  change(4,Math.floor(now.getSeconds()/10));
  change(5,Math.floor(now.getSeconds()%10));
  setTimeout("show()",200);
}
</script>

</head>
<?
  echo "<body bgcolor=".$color_back.">";
  echo "<table width=".(($size_small*3+$size_big+$distance)*6)." border=0 cellspacing=0 cellpadding=0><tr>";
  for ($nunber=0;$number<6;$number++)
  {
    $recid=0;
    echo "<td><table width=".($size_small*2+$size_big)." border=0 cellspacing=0 cellpadding=0><tr>";
    echo "<td width=".$size_small." height=".$size_small."></td>";
    echo "<td width=".$size_big." height=".$size_small."><div id=time".$number.$recid++." style="position:relative; width:".$size_big."px; height:".$size_small."px; background:".$color_dark."; font-size:1px"></div></td>";
    echo "<td width=".$size_small." height=".$size_small."></td>";
    echo "</tr><tr>";
    echo "<td width=".$size_small." height=".$size_big."><div id=time".$number.$recid++." style="position:relative; width:".$size_small."px; height:".$size_big."px; background:".$color_dark."; font-size:1px"></div></td>";
    echo "<td width=".$size_big." height=".$size_big."></td>";
    echo "<td width=".$size_small." height=".$size_big."><div id=time".$number.$recid++." style="position:relative; width:".$size_small."px; height:".$size_big."px; background:".$color_dark."; font-size:1px"></div></td>";
    echo "</tr><tr>";
    echo "<td width=".$size_small." height=".$size_small."></td>";
    echo "<td width=".$size_big." height=".$size_small."><div id=time".$number.$recid++." style="position:relative; width:".$size_big."px; height:".$size_small."px; background:".$color_dark."; font-size:1px"></div></td>";
    echo "<td width=".$size_small." height=".$size_small."></td>";
    echo "</tr><tr>";
    echo "<td width=".$size_small." height=".$size_big."><div id=time".$number.$recid++." style="position:relative; width:".$size_small."px; height:".$size_big."px; background:".$color_dark."; font-size:1px"></div></td>";
    echo "<td width=".$size_big." height=".$size_big."></td>";
    echo "<td width=".$size_small." height=".$size_big."><div id=time".$number.$recid++." style="position:relative; width:".$size_small."px; height:".$size_big."px; background:".$color_dark."; font-size:1px"></div></td>";
    echo "</tr><tr>";
    echo "<td width=".$size_small." height=".$size_small."></td>";
    echo "<td width=".$size_big." height=".$size_small."><div id=time".$number.$recid++." style="position:relative; width:".$size_big."px; height:".$size_small."px; background:".$color_dark."; font-size:1px"></div></td>";
    echo "<td width=".$size_small." height=".$size_small."></td>";
    echo "</tr></table></td>";
    if ($number==1||$number==3)
    {
      echo "<td><table width=".($size_small*3)." border=0 cellspacing=0 cellpadding=0><tr>";
      echo "<td width=".$size_small." height=".$size_small."></td>";
      echo "<td width=".$size_small." height=".$size_small."></td>";
      echo "<td width=".$size_small." height=".$size_small."></td>";
      echo "</tr><tr>";
      echo "<td width=".$size_small." height=".$size_big."></td>";
      echo "<td width=".$size_small." height=".$size_big."><div style="position:relative; width:".$size_small."px; height:".$size_small."px; background:".$color_light."; font-size:1px"></div></td>";
      echo "<td width=".$size_small." height=".$size_big."></td>";
      echo "</tr><tr>";
      echo "<td width=".$size_small." height=".$size_small."></td>";
      echo "<td width=".$size_small." height=".$size_small."></td>";
      echo "<td width=".$size_small." height=".$size_small."></td>";
      echo "</tr><tr>";
      echo "<td width=".$size_small." height=".$size_big."></td>";
      echo "<td width=".$size_small." height=".$size_big."><div style="position:relative; width:".$size_small."px; height:".$size_small."px; background:".$color_light."; font-size:1px"></div></td>";
      echo "<td width=".$size_small." height=".$size_big."></td>";
      echo "</tr><tr>";
      echo "<td width=".$size_small." height=".$size_small."></td>";
      echo "<td width=".$size_small." height=".$size_small."></td>";
      echo "<td width=".$size_small." height=".$size_small."></td>";
      echo "</tr></table></td>";
    }
  }
  echo "</tr></table>";
?>
<script language="javascript">
  show();
</script>
</body>
</html>  

【本文版权归作者与奥索网共同拥有,如需转载,请注明作者及出处】    

PHP 相关文章推荐
第十四节--命名空间
Nov 16 PHP
PHP面向对象的使用教程 简单数据库连接
Nov 25 PHP
php实现的仿阿里巴巴实现同类产品翻页
Dec 11 PHP
深入探讨:PHP使用数据库永久连接方式操作MySQL的是与非
Jun 05 PHP
检查用户名是否已在mysql中存在的php写法
Jan 20 PHP
PHP判断网络文件是否存在的方法
Mar 12 PHP
PHP通过引用传递参数用法分析
Dec 01 PHP
php简单实现单态设计模式的方法分析
Jul 28 PHP
浅谈Laravel队列实现原理解决问题记录
Aug 19 PHP
PHP实现PDO操作mysql存储过程示例
Feb 13 PHP
php菜单/评论数据递归分级算法的实现方法
Aug 01 PHP
php框架知识点的整理和补充
Mar 01 PHP
一个分页的论坛
Oct 09 #PHP
一个简易需要注册的留言版程序
Oct 09 #PHP
使用数据库保存session的方法
Oct 09 #PHP
COM in PHP (winows only)
Oct 09 #PHP
Banner程序
Oct 09 #PHP
下载文件的点击数回填
Oct 09 #PHP
PHP编程之高级技巧——利用Mysql函数
Oct 09 #PHP
You might like
Home Coffee Roasting
2021/03/03 咖啡文化
腾讯QQ php程序员面试题目整理
2010/06/08 PHP
PHP的范围解析操作符(::)的含义分析说明
2011/07/03 PHP
深入Nginx + PHP 缓存详解
2013/07/11 PHP
一个PHP二维数组排序的函数分享
2014/01/17 PHP
PHP中strtr字符串替换用法详解
2014/11/26 PHP
javascript 简单抽屉效果的实现代码
2010/03/09 Javascript
三级下拉菜单的js实现代码
2011/05/23 Javascript
广泛收集的jQuery拖放插件集合
2012/04/09 Javascript
javascript学习笔记(十二) RegExp类型介绍
2012/06/20 Javascript
跨域传值即主页面与iframe之间互相传值
2013/12/09 Javascript
js的Prototype属性解释及常用方法
2014/05/08 Javascript
js获取内联样式的方法
2015/01/27 Javascript
JavaScript实现数组随机排序的方法
2015/06/26 Javascript
JavaScript几种数组去掉重复值的方法推荐
2016/04/12 Javascript
JS Attribute属性操作详解
2016/05/19 Javascript
vue实现添加标签demo示例代码
2017/01/21 Javascript
解决Vue编译时写在style中的路径问题
2017/09/21 Javascript
node全局变量__dirname与__filename的区别
2019/01/14 Javascript
vue实现简单的日历效果
2020/09/24 Javascript
微信小程序日历插件代码实例
2019/12/04 Javascript
jquery实现垂直手风琴菜单
2020/03/04 jQuery
基于vue 动态菜单 刷新空白问题的解决
2020/08/06 Javascript
Antd的Table组件嵌套Table以及选择框联动操作
2020/10/24 Javascript
Python通过TensorFlow卷积神经网络实现猫狗识别
2019/03/14 Python
Python学习笔记之读取文件、OS模块、异常处理、with as语法示例
2019/06/04 Python
Python使用线程来接收串口数据的示例
2019/07/02 Python
Python3爬虫中关于Ajax分析方法的总结
2020/07/10 Python
pytorch Dataset,DataLoader产生自定义的训练数据案例
2021/03/03 Python
野兽派官方旗舰店:THE BEAST 野兽派
2016/08/05 全球购物
英国天然抗衰老护肤品品牌:Nakin Skin Care
2019/04/16 全球购物
六查六看自查材料
2014/02/17 职场文书
专业技术职务聘任书
2014/03/29 职场文书
副科竞争上岗演讲稿
2014/05/12 职场文书
考试作弊检讨书
2014/10/21 职场文书
Jupyter Notebook 如何修改字体和大小以及更改字体样式
2021/06/03 Python