帮忙看下bug出在那里?为什么没有用啊

F_xiaobai 2011-05-23 02:45:32
<html>
<script type="text/javascript">
var timer = {
ms : 0,
offset : 0,
interval_obj : null,
current_time : '',
init : function(){
this.ms = 0;
this.offset = 0;
this.id = this.id || 'my_timer';
//this.show_area = this.show_area || null;
//this.record_area = this.record_area || null;
this.interval_obj = setInterval(this.id + '.run()', 10);
this.current_time = '';
/*
switch(this.record_area.tagName){
case 'TEXTAREA':
this.record_area.value = '';
break;
default:
this.record_area.innerHTML = '';
break;
}
*/
},
begin : function(){
this.offset = (this.offset == 1) ? 0 : 1;
},
run : function(){
this.show(this.current_time);
this.ms += this.offset;
},
get_current_time : function(){
var current_ms = this.ms;

var time_rule = new Array(360000, 6000, 100, 1);

var show_value = new Array();
var show_value_part = '';

for(var i in time_rule){
show_value_part = Math.floor(current_ms / time_rule[i]);
current_ms = current_ms % time_rule[i];
show_value.push((show_value_part < 10) ? '0' + show_value_part : show_value_part);
}
this.current_time = show_value.join(':');
},
show : this.show || function(){
this.get_current_time();
return this.current_time;
},
record : this.record || function(){
return this.current_time;
/*
switch(this.record_area.tagName){
case 'TEXTAREA':
this.record_area.value += this.show_area.value + '\r\n';
break;
default:
this.record_area.innerHTML += this.show_area.value + "<br>";
break;
}
*/
}
}
</script>
<body>
<input id="show_area" type="text" />
<button id="start_btn" onClick="my_timer.begin();this.value = (this.value == 'start') ? 'pause' : 'start';">start</button>
<button id="init_btn" onClick="my_timer.init();document.getElementById('start_btn').value = 'start';">init</button>
<button id="record_btn" onClick="my_timer.record();">record</button>
<br>
<textarea id="record_area" rows="20"></textarea>
</body>
<script type="text/javascript">
var my_show = function(current_time){
var show_area = document.getElementById('show_area');
switch(show_area.tagName){
case 'TEXTAREA':
case 'INPUT':
show_area.value = current_time;
break;
default:
show_area.innerHTML = current_time;
break;
}
}

var my_record = function(current_time){
var show_area = document.getElementById('show_area');
var record_area = document.getElementById('show_area');
switch(record_area.tagName){
case 'TEXTAREA':
case 'INPUT':
record_area.value += show_area.value + '\r\n';
break;
default:
record_area.innerHTML += show_area.value + "<br>";
break;
}
}

var my_timer = timer;
my_timer.id = 'my_timer';
my_timer.show = my_show;
my_timer.record = my_record;
my_timer.init();


//my_timer.show_area = document.getElementById('show_area');
//my_timer.record_area = document.getElementById('record_area');
</script>
</html>
...全文
118 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
失去乐山贼 2011-05-23
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 chendong_j 的回复:]

首先此处为PHP板块。。。第二没有问题描述让人干看代码肯定没什么人有耐心
[/Quote]
+1,LZ请描述一下问题
chendong_j 2011-05-23
  • 打赏
  • 举报
回复
首先此处为PHP板块。。。第二没有问题描述让人干看代码肯定没什么人有耐心

87,990

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧