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 @@ -
+ \ No newline at end of file +
diff --git a/application/views/home.php b/application/views/home.php index 58cb67b..a10c65a 100644 --- a/application/views/home.php +++ b/application/views/home.php @@ -4,9 +4,17 @@
- + - + + @@ -54,7 +62,9 @@
-
+ + + @@ -79,4 +89,22 @@
- \ No newline at end of file + + $timezone) { + + date_default_timezone_set($timezone); + + $timezone_array[$key]['timezone_name'] = $timezone; + $timezone_array[$key]['diff_from_GMT'] = 'UTC/GMT ' . date('P', $timestamp); + $timezone_array[$key]['offset'] = date('P', $timestamp); + } + return $timezone_array; + } + +?> diff --git a/js/timer.js b/js/timer.js index 2496bb5..7b32bca 100644 --- a/js/timer.js +++ b/js/timer.js @@ -135,6 +135,8 @@ var clock = { ui.set_type(clocks[guid].type, true) }); + + //updateData(offset); //draw them in the correct starting position setInterval(function(){ @@ -142,6 +144,9 @@ var clock = { moveHands(guid); }, 1000); + + + var width = (clockRadius+margin)*2,// replace global definition in function scope. height = (clockRadius+margin)*2, secondTickStart = clockRadius, @@ -169,6 +174,7 @@ var clock = { .attr('y2',secondTickStart + secondTickLength) .attr('transform',function(d){ return 'rotate(' + secondScale(d) + ')'; + $(".digital_display").text(d); }); //and labels @@ -254,15 +260,15 @@ var timerClock = { postRender : function(guid){ //alert('yo'); $('#btns').append(' \ -

\ -

'); +

\ +

'); } }; 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 +}