mirror of
https://github.com/flynx/Course-JavaScript.git
synced 2025-10-28 18:40:08 +00:00
added timer constructor...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
472061e96a
commit
d7ec86d36f
@ -69,6 +69,17 @@
|
||||
border-right: solid 10px gray;
|
||||
}
|
||||
|
||||
#new_timer {
|
||||
width: 40px;
|
||||
height: 40px;
|
||||
margin: 10px;
|
||||
border: solid 1px gray;
|
||||
border-radius: 50%;
|
||||
color: gray;
|
||||
font-size: 39px;
|
||||
text-align: center;
|
||||
cursor: hand;
|
||||
}
|
||||
|
||||
</style>
|
||||
|
||||
@ -114,6 +125,15 @@ function formatSum(m){
|
||||
'<span title="Minutes">m:<span>'+ m +'</span></span>'
|
||||
}
|
||||
|
||||
function createTimer(parent){
|
||||
var timer = document.createElement('div')
|
||||
timer.className = 'timer'
|
||||
timer.innerHTML = '<div class="sum">0</div>'
|
||||
parent.appendChild(timer)
|
||||
|
||||
timer.setAttribute('onclick', 'toggleTimer(this)')
|
||||
}
|
||||
|
||||
function toggleTimer(elem){
|
||||
elem = elem
|
||||
var t = elem.getAttribute('timer')*1
|
||||
@ -182,18 +202,20 @@ function toggleTimer(elem){
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function setup(){
|
||||
//createTimer(document.getElementById('timers'))
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<body onload="setup()">
|
||||
|
||||
<div class="timer" onclick="toggleTimer(this)">
|
||||
<div class="sum">0</div>
|
||||
</div>
|
||||
<div id="timers"></div>
|
||||
<div id="new_timer" title="Add new timer" onclick="createTimer(document.getElementById('timers'))">+</div>
|
||||
|
||||
<div class="timer" onclick="toggleTimer(this)">
|
||||
<div class="sum">0</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
<!-- vim:set ts=4 sw=4 : -->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user