diff --git a/application/templates/timer_box.mustache b/application/templates/timer_box.mustache index 779e40a..cee7fed 100644 --- a/application/templates/timer_box.mustache +++ b/application/templates/timer_box.mustache @@ -1,13 +1,14 @@ -
\ -
'); +\ +
'); } }; var countDownClock = { postRender : function(guid){ $('#btns').append(' \ -\ -
'); +\ +
'); updateCountDown(guid); moveCountDownHands(guid, guid); @@ -271,20 +277,10 @@ var countDownClock = { var lapTimerClock = { postRender : function(guid){ - - //var start = document.createElement("button"); - //start.setAttribute('type', 'button'); - //start.setAttribute('class', 'btn btn-danger'); - //start.setAttribute('onclick', 'startLapTimerOnClick(guid);'); - //start.innerHTML = ' Start'; - // - //var btn = document.getElementById('buttons_lap_timer'); - //btn.appendChild(start); - $('#buttons_lap_timer').append(' \ - \ - \ - '); + \ + \ + '); } }; @@ -316,9 +312,10 @@ var playSound = { }; var digitalTimer = { - render : function() { + render : function(view) { digitalTimer.preRender(); var dd = document.getElementsByClassName('digital_display')[0], + start = document.getElementById('start'), stop = document.getElementById('stop'), clear = document.getElementById('clear'), @@ -380,6 +377,7 @@ function moveHands(area){ .attr('transform',function(d){ return 'rotate('+ d.scale(d.value) +')'; }); + $('.current_time.').text(area); } function moveTimerHands(guid, area){ @@ -423,8 +421,61 @@ function updateData(offset){ handData[0].value = (nd.getHours() % 12) + nd.getMinutes()/60; handData[1].value = nd.getMinutes(); handData[2].value = nd.getSeconds(); + } + +var times = []; +function gettime(view){ + + var guid = view['guid']; + times[guid] = view; + var offset = parseInt(times[guid].timezone); + d = new Date(); + utc = d.getTime() + (d.getTimezoneOffset() * 60000); + nd = new Date(utc + (3600000*offset)); + + if (nd.getHours() >= 12){ + var hour = nd.getHours() - 12; + + var amPm = "PM"; + + } else { + var hour = nd.getHours(); + + var amPm = "AM"; + } + + if (nd.getSeconds() < 10){ + + var seconds = "0" + nd.getSeconds(); + + } else { + + var seconds = nd.getSeconds(); + } + + if (nd.getMinutes() < 10){ + + var minutes = "0" + nd.getMinutes(); + + } else { + + var minutes = nd.getMinutes(); + } + + if(hour == 0){ + hour = 1; + } + + + $('.'+guid).text(hour + ":" + minutes + ":" + seconds + " " + amPm); + setTimeout(function(){gettime(view)}, 1000); + } + + + + function updateTimer(guid, counter) { if(typeof window[guid] === 'undefined') { @@ -727,4 +778,4 @@ function initCountDownTimer(guid, time) { } } -d3.select(self.frameElement).style("height", height + "px"); \ No newline at end of file +d3.select(self.frameElement).style("height", height + "px"); diff --git a/js/ui.js b/js/ui.js index 1f33ce7..e6d9c75 100644 --- a/js/ui.js +++ b/js/ui.js @@ -1,6 +1,7 @@ var timer_count=1; // eventually need to load from storage so not to override current timers var timer_type = '1'; + var ui = { nav: function(){ $('#sign_up a').on('click', function(){ @@ -120,11 +121,22 @@ var ui = { var size = $('#size').val(); var timezone = $('#timezone').val(); var time = parseInt($('#countdown_time').val()); - //console.log(title, size, timezone, time); - if(title !== '' && size !== ''/* && timezone !== ''*/) { - var view = {'guid' : 'timer'+timer_count, 'timezone': timezone, 'title': title, 'clockSize': size, 'type' : timer_type, 'time': time}; - timer_count++; - preDraw(view); + + if(title !== '' && size !== '' && timezone != 0/* && timezone !== ''*/) { + if($.isNumeric(size)){ + if(size <= 130){ + var view = {'guid' : 'timer'+timer_count, 'timezone': timezone, 'title': title, 'clockSize': size, 'type' : timer_type, 'time': time}; + timer_count++; + preDraw(view); + $('.timer_box').show(); + } else { + alert('Please Set a size of clock a maximum 130'); + } + + } else { + alert('Please Input Number on size'); + + } } else{ alert('Please enter a valid value.'); @@ -140,12 +152,14 @@ var ui = { } function preDraw(view){ - switch(timer_type) { + switch(view['type']) { case '1': clock.render(view); + gettime(view); break; case '2': timerClock.render(view); + digitalTimer.render(view); break; case '3': countDownClock.render(view); @@ -159,5 +173,4 @@ function preDraw(view){ alert('error, unknown type'); break; } - -} \ No newline at end of file +}