首頁 > php教程 > PHP源码 > php+js液晶时钟

php+js液晶时钟

PHP中文网
發布: 2016-05-25 17:10:50
原創
1213 人瀏覽過

php代码

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

147

148

149

150

151

152

153

154

155

156

157

158

159

160

161

162

163

164

165

166

167

168

169

170

171

172

173

174

175

176

177

178

179

180

181

182

183

184

185

186

187

188

189

190

191

192

193

194

<?

  $size_small=5;//液晶宽度

  $size_big=25;//液晶长度

  $distance=10;//间距

  $color_back="#DDDDDD";

  $color_dark="#CCCCCC";

  $color_light="#000000";

  $number=0;

?>

<html>

<head>

<title>Timer|www.ibtf.net|www.bitefu.net</title>

<meta http-equiv="Content-Type" content="text/html; charset=gb2312">

<script language="javascript">

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."><p id=time".$number.$recid++." style=\"position:relative; width:".$size_big."px; height:".$size_small."px; background:".$color_dark."; font-size:1px\"></p></td>";

    echo "<td width=".$size_small." height=".$size_small."></td>";

    echo "</tr><tr>";

    echo "<td width=".$size_small." height=".$size_big."><p id=time".$number.$recid++." style=\"position:relative; width:".$size_small."px; height:".$size_big."px; background:".$color_dark."; font-size:1px\"></p></td>";

    echo "<td width=".$size_big." height=".$size_big."></td>";

    echo "<td width=".$size_small." height=".$size_big."><p id=time".$number.$recid++." style=\"position:relative; width:".$size_small."px; height:".$size_big."px; background:".$color_dark."; font-size:1px\"></p></td>";

    echo "</tr><tr>";

    echo "<td width=".$size_small." height=".$size_small."></td>";

    echo "<td width=".$size_big." height=".$size_small."><p id=time".$number.$recid++." style=\"position:relative; width:".$size_big."px; height:".$size_small."px; background:".$color_dark."; font-size:1px\"></p></td>";

    echo "<td width=".$size_small." height=".$size_small."></td>";

    echo "</tr><tr>";

    echo "<td width=".$size_small." height=".$size_big."><p id=time".$number.$recid++." style=\"position:relative; width:".$size_small."px; height:".$size_big."px; background:".$color_dark."; font-size:1px\"></p></td>";

    echo "<td width=".$size_big." height=".$size_big."></td>";

    echo "<td width=".$size_small." height=".$size_big."><p id=time".$number.$recid++." style=\"position:relative; width:".$size_small."px; height:".$size_big."px; background:".$color_dark."; font-size:1px\"></p></td>";

    echo "</tr><tr>";

    echo "<td width=".$size_small." height=".$size_small."></td>";

    echo "<td width=".$size_big." height=".$size_small."><p id=time".$number.$recid++." style=\"position:relative; width:".$size_big."px; height:".$size_small."px; background:".$color_dark."; font-size:1px\"></p></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."><p style=\"position:relative; width:".$size_small."px; height:".$size_small."px; background:".$color_light."; font-size:1px\"></p></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."><p style=\"position:relative; width:".$size_small."px; height:".$size_small."px; background:".$color_light."; font-size:1px\"></p></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>

登入後複製


相關標籤:
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
作者最新文章
最新問題
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板