diff --git a/application/controllers/Ajax.php b/application/controllers/Ajax.php index 05042702..e4cc0d88 100644 --- a/application/controllers/Ajax.php +++ b/application/controllers/Ajax.php @@ -304,17 +304,15 @@ function contact() { $result['success'] = false; - $name = $this->input->post('name'); - $email = $this->input->post('email'); - $message = $this->input->post('message'); + $tags = "contact"; $this->load->library('mandrill'); $messageMandrill = array( - 'html' => $message, - 'subject' => $subject, - 'from_email' => $email, - 'from_name' => $name, + 'html' => $this->message, + 'subject' => "Contact information", + 'from_email' => $this->email, + 'from_name' => $this->name, 'to' => array( array( 'email' => 'marc@toolwatch.io', @@ -323,7 +321,7 @@ function contact() { ) ), 'headers' => array( - 'Reply-To' => $email, + 'Reply-To' => $this->email, ), 'important' => false, 'track_opens' => true, @@ -341,9 +339,9 @@ function contact() { $scheduleTime = time(); - $send_at = date('Y-', $scheduleTime).date('m-', $scheduleTime) - .(date('d', $scheduleTime)).' '.(date('H', $scheduleTime)-1).':' - .(date('i', $scheduleTime)).date(':s', $scheduleTime); + $returnValue = date('Y-', $scheduleTime).date('m-', $scheduleTime) + .(date('d', $scheduleTime)).' '.(date('H', $scheduleTime)).':' + .(date('i', $scheduleTime)).':'.(date('s', $scheduleTime)); $mandrillResponse = $this->mandrill->messages->send($messageMandrill, $async, $ip_pool, $send_at); log_message('info', 'Mandrill email: ' . print_r($mandrillResponse, true)); @@ -351,7 +349,7 @@ function contact() { if ($mandrillResponse[0]['status'] === 'sent') { $result['success'] = true; - } + } echo json_encode($result); } diff --git a/application/controllers/Measures.php b/application/controllers/Measures.php index 38eec3ec..c9f421a0 100644 --- a/application/controllers/Measures.php +++ b/application/controllers/Measures.php @@ -215,11 +215,12 @@ public function new_measure() { $this->event->add(MEASURE_LOAD); + array_push($this->_headerData['javaScripts'], "input.time.logic"); + $this->_headerData['headerClass'] = 'blue'; $this->load->view('header', $this->_headerData); $this->load->view('measure/new-measure', $this->_bodyData); - $this->load->view('measure/audio.php'); $this->load->view('footer'); } @@ -248,15 +249,17 @@ public function get_accuracy() { $this->event->add(ACCURACY_LOAD); + $this->_headerData['headerClass'] = 'blue'; - array_push($this->_headerData['javaScripts'], "watch.animation"); + array_push($this->_headerData['javaScripts'], "input.time.logic", + "watch.animation"); + $this->load->view('header', $this->_headerData); $this->_bodyData['selectedWatch'] = $this->watch->getWatch($this->input->post('watchId')); $this->_bodyData['measureId'] = $this->input->post('measureId'); $this->load->view('measure/get-accuracy', $this->_bodyData); - $this->load->view('measure/audio.php'); $this->load->view('footer'); @@ -265,15 +268,6 @@ public function get_accuracy() { } } - /** - * getReferenceTime. Set the server time to the user session. - * - * This must to be call by the user before accuracyMeasure or baseMeasure - */ - function getReferenceTime() { - $this->session->set_userdata('referenceTime', time()); - } - /** * Save the base measure (1/2) * @@ -288,21 +282,14 @@ function getReferenceTime() { */ function baseMeasure() { - if ($this->expectsPost(array('watchId', 'userTimezone', 'userTime'))) { - - $result = array('success' =>false); - - $watchId = $this->input->post('watchId'); - - //Construct user time - $referenceTime = $this->session->userdata('referenceTime'); - $userTimezone = $this->input->post('userTimezone'); - $tempUserTime = preg_split('/:/', $this->input->post('userTime')); - $userTime = mktime($tempUserTime[0], $tempUserTime[1], - $tempUserTime[2], date("n"), date("j"), date("Y")); + if ($this->expectsPost(array('watchId', 'referenceTimestamp', 'userTimestamp'))) { //Add the base measure - if ($this->measure->addBaseMesure($watchId, $referenceTime, $userTime)) { + if ($this->measure->addBaseMesure( + $this->watchId, + $this->referenceTimestamp/1000, + $this->userTimestamp/1000) + ) { $result['success'] = true; @@ -319,8 +306,6 @@ function baseMeasure() { * TODO: When this becomes doable from many endpoints (web, mobile, ...) * I'll to move it to the model. * - * FIXME: userTimezone parameter isn't used. Should it ? - * * @param POST String measureId * @param POST String userTimezone * @param POST String userTime @@ -329,20 +314,14 @@ function baseMeasure() { */ function accuracyMeasure() { - if ($this->expectsPost(array('measureId', 'userTimezone', 'userTime'))) { - - $result = array('success' =>false); - - //Construct the user time - $referenceTime = $this->session->userdata('referenceTime'); - $userTimezone = $this->input->post('userTimezone'); - $tempUserTime = preg_split('/:/', $this->input->post('userTime')); - $userTime = mktime($tempUserTime[0], $tempUserTime[1], $tempUserTime[2], - date("n"), date("j"), date("Y")); + if ($this->expectsPost(array('measureId', 'referenceTimestamp', 'userTimestamp'))) { //Add the watch measure $watchMeasure = $this->measure->addAccuracyMesure( - $this->input->post('measureId'), $referenceTime, $userTime); + $this->measureId, + $this->referenceTimestamp/1000, + $this->userTimestamp/1000 + ); // If the computed accuracy makes sense, we return success if (is_numeric($watchMeasure->accuracy)) { diff --git a/application/libraries/Auto_email.php b/application/libraries/Auto_email.php index 7db40bc9..7a902ed3 100644 --- a/application/libraries/Auto_email.php +++ b/application/libraries/Auto_email.php @@ -306,9 +306,14 @@ private function sendAtString($scheduleTime) { //sent right away. $scheduleTime = $scheduleTime-48*60*60; + log_message('info', 'Date ' . print_r($scheduleTime, true)); + + $returnValue = date('Y-', $scheduleTime).date('m-', $scheduleTime) .(date('d', $scheduleTime)).' '.(date('H', $scheduleTime)).':' - .(date('i', $scheduleTime)).date(':s', $scheduleTime); + .(date('i', $scheduleTime)).':'.(date('s', $scheduleTime)); + + log_message('info', 'Date ' . print_r($returnValue, true)); return $returnValue; } diff --git a/application/tests/controllers/Measures_test.php b/application/tests/controllers/Measures_test.php index 4f0cfecb..4bfc461d 100644 --- a/application/tests/controllers/Measures_test.php +++ b/application/tests/controllers/Measures_test.php @@ -173,7 +173,7 @@ public function test_newWatch(){ public function test_newMeasure(){ $output = $this->request('GET', ['Measures', 'new_measure']); - $this->assertContains('

New measure

', $output); + $this->assertContains('

New measure', $output); } public function test_getAccuracyFail(){ @@ -191,17 +191,7 @@ public function test_getAccuracy(){ ] ); - $this->assertContains('

Check the accuracy

', $output); - } - - public function test_getReferenceTime() { - $CI = &get_instance(); - $CI->load->model('User'); - $CI->load->library('Session'); - - $output = $this->request('GET', ['Measures', 'getReferenceTime']); - - $this->assertEquals($CI->session->userdata('referenceTime'), time()); + $this->assertContains('

Check the accuracy', $output); } public function test_baseMesure() { @@ -227,8 +217,8 @@ public function test_baseMesure() { ['Measures', 'baseMeasure'], [ 'watchId' => self::$watchId, - 'userTime' => '10:13:12', - 'userTimezone' => '5' + 'referenceTimestamp' => microtime(), + 'userTimestamp' => microtime() ] ); @@ -242,15 +232,13 @@ public function test_accuracyMeasure() { $measure = $CI->Measure->find_by('watchId', self::$watchId); - $CI->session->set_userdata('referenceTime', time()); - $output = $this->request( 'POST', ['Measures', 'accuracyMeasure'], [ 'measureId' => $measure->id, - 'userTime' => '10:16:12', - 'userTimezone' => '5' + 'referenceTimestamp' => microtime(), + 'userTimestamp' => microtime() ] ); diff --git a/application/views/home/demo.php b/application/views/home/demo.php index bf468ccd..579b396d 100644 --- a/application/views/home/demo.php +++ b/application/views/home/demo.php @@ -2,37 +2,37 @@
-
+
-
-
5
-
- -
-
-
-
- -
Please use the 24-hour clock format - - - +
+
+
+
+
+
+ +
+
- -
+ +

Congratulations!


The accuracy of your watch is

- seconds a day! + seconds a day!
-
\ No newline at end of file +
diff --git a/application/views/home/home.php b/application/views/home/home.php index 658bd5c1..fec5bfbe 100644 --- a/application/views/home/home.php +++ b/application/views/home/home.php @@ -6,13 +6,13 @@
- - load->view('home/demo'); - $this->load->view('home/slogan'); + + load->view('home/demo'); + $this->load->view('home/slogan'); ?> - +
-load->view('home/mosa'); ?> \ No newline at end of file +load->view('home/mosa'); ?> diff --git a/application/views/measure/audio.php b/application/views/measure/audio.php deleted file mode 100644 index c630d747..00000000 --- a/application/views/measure/audio.php +++ /dev/null @@ -1,36 +0,0 @@ - - - diff --git a/application/views/measure/dashboard.php b/application/views/measure/dashboard.php index 213fdaaf..17d0971b 100644 --- a/application/views/measure/dashboard.php +++ b/application/views/measure/dashboard.php @@ -74,7 +74,7 @@
Add a watch

- + Start a new measure diff --git a/application/views/measure/get-accuracy.php b/application/views/measure/get-accuracy.php index 3a9a18c3..20ae9414 100644 --- a/application/views/measure/get-accuracy.php +++ b/application/views/measure/get-accuracy.php @@ -1,42 +1,33 @@
-

Check the accuracy

+

Check the accuracy of your brand.' - '.$selectedWatch->name;?>

+
- -
-
- At the end of the countdown, please enter below the exact time as it is on your watch.
Let's check the accuracy of your watch! -
-
-
- -
- -
-
+
-
5
+
+
+
+
+ +
-
- -
- -
Please use the 24-hour clock format - -
-
@@ -88,12 +79,12 @@

- +



We Instagram, tag us with your wristshots and share your results using #ToolwatchApp !

- - - - +
+ + +
@@ -109,8 +100,6 @@ Back to measures - -
diff --git a/application/views/measure/new-measure.php b/application/views/measure/new-measure.php index 3db68df9..ec2f73b1 100644 --- a/application/views/measure/new-measure.php +++ b/application/views/measure/new-measure.php @@ -1,19 +1,12 @@
-

New measure

+

New measure

-
-
- To begin measuring the accuracy of your watch, we must first synchronize your watch with Toolwatch’s accuracy system. - Start clicking on « Start now! » to start the countdown then look at your watch.

- At the end of the countdown, please enter below the exact time as it is on your watch. Let’s start measuring! -
-
@@ -34,26 +27,16 @@
-
5
-
-
- -
- -
- -
Please use the 24-hour clock format - +
+
+
+
+ +
@@ -65,9 +48,6 @@
- Back to measures - -
@@ -75,3 +55,17 @@
+ + + + + + diff --git a/assets/img/stepnew.png b/assets/img/stepnew.png new file mode 100644 index 00000000..f6bbd067 Binary files /dev/null and b/assets/img/stepnew.png differ diff --git a/assets/js/application.js b/assets/js/application.js index 83835f36..fbe9fd81 100644 --- a/assets/js/application.js +++ b/assets/js/application.js @@ -234,29 +234,6 @@ $(document).ready(function() } }); - $('body').on('click', 'button[name="startSync"]', function(e) - { - e.preventDefault(); - var watchId = $('select[name="watchId"]').val(); - $('.watch-error').hide(); - - if(watchId != null) - { - $('button[name="startSync"]').hide(); - $('button[name="syncDone"]').show(); - $('.sync-time').show(); - $('button[name="restartCountdown"]').show(); - $('.watch-select').hide(); - - bips.play(); - - } - else - { - $('.watch-error').show(); - } - - }); $('body').on('submit', 'form[name="addWatch"]', function(e) { @@ -286,111 +263,6 @@ $(document).ready(function() }); - - $('body').on('submit', 'form[name="newAccuracy"]', function(e) - { - e.preventDefault(); - var watchId = $('select[name="watchId"]').val(); - var userTime = $('input[name="userTime"]').val(); - var myDate = new Date(); - // Timezone difference from Europe/Paris - var userTimezone= (myDate.getTimezoneOffset()/60)+1; - var measureId = $('input[name="measureId"]').val(); - - if(hoursRegExp.test(userTime)) - { - $('.btn-spinner i').css('display', 'inline-block'); - - $.post('/measures/accuracyMeasure', {watchId: watchId, userTime: userTime, userTimezone: userTimezone, measureId: measureId}, function(data) - { - var result = $.parseJSON(data); - if(result.success == true) - { - $('.userTime').hide(); - $('button[name="syncDone"]').hide(); - $('.sync-time').hide(); - $('button[name="restartCountdown"]').hide(); - $('.sync-success').show(); - $('.backToMeasure').show(); - $('#mainTitle').hide(); - $('#mainExplanation').hide(); - - if(result.accuracy != null) - { - if(result.accuracy > 0){ - result.accuracy = '+'+result.accuracy; - } - - $('.watch-accuracy').html(result.accuracy); - $('.watch-percentile').html(result.percentile); - - $('.share-button').each(function(index){ - $(this).attr("href", $(this).attr("href").replace("{WatchPercentile}", result.percentile)); - }); - - } - } - else - { - $('.measure-error').show(); - $('.btn-spinner i').css('display', 'none'); - } - - }); - } - else - { - $('.time-error').show(); - } - - }); - - - - $('body').on('submit', 'form[name="newMeasure"]', function(e) - { - e.preventDefault(); - $('.signup-error').hide(); - - var watchId = $('select[name="watchId"]').val(); - var userTime = $('input[name="userTime"]').val(); - var getAccuracy = $('input[name="getAccuracy"]').val(); - - var myDate = new Date(); - // Timezone difference from Europe/Paris - var userTimezone= (myDate.getTimezoneOffset()/60)+1; - - if(hoursRegExp.test(userTime)) - { - $('.btn-spinner i').css('display', 'inline-block'); - - $.post('/measures/baseMeasure', {watchId: watchId, userTime: userTime, userTimezone: userTimezone, getAccuracy: getAccuracy}, function(data) - { - var result = $.parseJSON(data); - if(result.success == true) - { - $('.userTime').hide(); - $('button[name="syncDone"]').hide(); - $('.sync-time').hide(); - $('button[name="restartCountdown"]').hide(); - $('.sync-success').show(); - $('.backToMeasure').show(); - - } - else - { - $('.measure-error').show(); - $('.btn-spinner i').css('display', 'none'); - } - - }); - } - else - { - $('.time-error').show(); - } - }); - $('body').on('submit', 'form[name="contact"]', function(e) { e.preventDefault(); diff --git a/assets/js/home.logic.js b/assets/js/home.logic.js index 06dffb8c..2662f533 100644 --- a/assets/js/home.logic.js +++ b/assets/js/home.logic.js @@ -23,35 +23,56 @@ $( document ).ready(function() { }); - initCounDown(); initSize(); + initDemo(); $('video,audio').mediaelementplayer({ enableAutosize: true, features: [] }); - $( "#demo-cta" ).click(function() { + + + +}); + +var timeoutClick; + +function initDemo(){ + + $("#sync-button").html("" + + "Press this button when
the second-hand

​​" + + '' + + "

" + + "reaches exactly  the twelve
o'clock position

" + ); + + $("#sync-button").show(); + $("#demo-first-step").show(); + $("#demo-second-step").hide(); + + var d = new Date(); + var seconds = d.getSeconds(); + + timeoutClick = setTimeout( + function(){$( "#sync-button" ).click()}, + (60 - seconds+1) * 1000); + + $( "#sync-button" ).click(function() { + + clearInterval(timeoutClick); var result = delta; - $("#demo-pointer").hide(); - $("#demo-third-step").hide(); - $("#demo-fourth-step").fadeToggle(); + $("#demo-first-step").hide(); + $("#demo-second-step").fadeToggle(); $(".watch-accuracy").html(result.toFixed(1)); - }); + setTimeout( + function(){initDemo();}, + 10 * 1000); + }); -}); - -function initCounDown(){ - $("#demo-second-step").show(); - $("#demo-third-step").hide(); - $("#demo-fourth-step").hide(); - $("#demo-sync-time").html(5); - $("#inputUserTime").val(""); - $("#demo-pointer").removeAttr('style'); - timeouts.push(setTimeout(countDownDisplay, 1000)); } function initSize(){ @@ -78,80 +99,3 @@ function initSize(){ }, 2000); } - -function countDownDisplay(){ - var countdown = $("#demo-sync-time").html(); - - $("#demo-sync-time").html(countdown - 1); - if(countdown > 1){ - timeouts.push(setTimeout(countDownDisplay, 1000)); - }else{ - d = new Date(new Date().getTime()); - similateInput(); - } -} - -function similateInput(){ - $("#demo-second-step").hide(); - $("#demo-third-step").fadeToggle("slow", function (){ - - var leftDelta = $("#demo-pointer").position().left - - $("#inputUserTime").position().left; - - var topDelta = $("#demo-pointer").position().top - - $("#inputUserTime").position().top - $("#inputUserTime").height() /2; - - $( "#demo-pointer" ).animate({ - marginTop: "-="+topDelta, - marginLeft: "-="+leftDelta - }, 2000, function(){ - - var seconds = (d.getSeconds() + Math.floor(Math.abs(delta))); - if(seconds <= 9){ - seconds = "0"+seconds; - } - - var hours = d.getHours(); - - if(hours <= 9){ - hours = "0"+seconds; - } - - var minutes = d.getMinutes(); - - if(minutes <= 9){ - minutes = "0"+minutes; - } - - var date = hours + ':' + minutes + ':' + seconds; - writeToInput(date, 0); - }); - }); -} - -function writeToInput(text, i){ - - if(i < text.length){ - $("#inputUserTime").val($("#inputUserTime").val() + text.charAt(i)); - i = i +1; - timeouts.push(setTimeout(writeToInput, Math.round(Math.random() * (300 - 100) + 100), text, i)); - }else{ - clickCTA(); - } -} - -function clickCTA(){ - var leftDelta = $("#demo-pointer").position().left - $("#demo-cta").position().left + $("#demo-cta").width() * 2 + 30; - - var topDelta = $("#demo-pointer").position().top - $("#demo-cta").position().top + $("#demo-cta").height() * 3; - - $( "#demo-pointer" ).animate({ - marginTop: "+="+topDelta, - marginLeft: "+="+leftDelta - }, 2000, function(){ - $("#demo-cta").click(); - }); - - timeouts = []; - setTimeout(initCounDown, 10000); -} diff --git a/assets/js/input.time.logic.js b/assets/js/input.time.logic.js new file mode 100644 index 00000000..9a3834c2 --- /dev/null +++ b/assets/js/input.time.logic.js @@ -0,0 +1,296 @@ +var offsetedDate; +var clickedDate; +var isAccuracy = false; +var validateFunction = "validateBaseMeasure();"; +var ctaText = "All good, take me home scotty"; + +/** + * Link button click + */ +$( document ).ready(function() { + + // This is shared between the baseMeasure and accuracyMeasure pages. + // Here, we do the difference between both and change the validateFunction + // used in the clicked function; + if ($( "#accuracyHolder" ).length){ + isAccuracy = true; + validateFunction = "validateAccuracyMeasure();"; + ctaText = "SHOW! ME! MY! ACCURACY!"; + createCTA(); + } + + console.log(isAccuracy); + + $('body').on('click', 'button[name="startSync"]', function(e) + { + e.preventDefault(); + createCTA(); + }); +}); + +/** + * Check if a watch is selected and displays the CTA + */ +function createCTA(){ + var watchId = $('select[name="watchId"]').val(); + $('.watch-error').hide(); + + if(watchId != null) + { + $('button[name="startSync"]').hide(); + $('.watch-select').hide(); + $('span#selectedWatch').text( + "for your " + + $('select[name="watchId"]').find(":selected").text() + ); + getNextMinute(); + + } + else + { + $('.watch-error').show(); + } +} + +/** + * Compute the next minute + */ +function getNextMinute(){ + + var d = new Date(); + var seconds = d.getSeconds(); + var offsetSeconds = 0; + + // If it's somewhere between xx:xx:51 and xx:xx:60, + // users won't have the time to click. + // So, we add a minute. + if(seconds >= 50){ + offsetSeconds = 60 - seconds; + }else{ + offsetSeconds = -seconds; + } + + offsetedDate = new Date(d.getTime() + offsetSeconds * 1000 + 60 * 1000); + + $("#sync-button").html("" + + "Press this button when
the second-hand

​​" + + '' + + "

" + + "reaches exactly  the twelve
o'clock position

" + ); + + $("#sync-button").show(); + + //The maximum waiting time is 70 secs. If nothing happens in the next 80 + //sec, we display a popup. + timeoutPopup = setTimeout(function(){deadlinePassed();}, + 80 * 1000); +} + +/** + * Bootstrap css doesn't like us to override the + * default font for buttons... + * @return font-size depending on the screen + */ +function computeFontSize(){ + var style = ""; + if(document.body.clientWidth > 500){ + style = "font-size:20px"; + } + return style; +} + +/** + * Helper function to transform a javascript Date in xx:xx:xx + * + * @param Date date + * @return String + */ +function constructoffsetedDateString(date){ + var hours = (date.getHours() < 10) ? "0"+date.getHours() : + date.getHours(); + + var minutes = (offsetedDate.getMinutes() < 10) ? "0"+date.getMinutes() : + date.getMinutes(); + + var seconds = (offsetedDate.getSeconds() < 10) ? "0"+date.getSeconds() : + date.getSeconds(); + + return hours + ":" + minutes + ":" + seconds; +} + +/** + * This function is triggererd by a setTimeout function and displays a + * popop + */ +function deadlinePassed(){ + + console.log("Deadline Passed"); + + var deadlinePassedText = + `
+

Is everything ok, Doc ?

+

+ To begin measuring the accuracy of your watch, we must first + synchronize it with Toolwatch's accuracy system.

+ You were supposed to click when the second hand was + + exactly at 12 + . +

+ Retry +
`; + + $('#pageModal .modal-body').html(deadlinePassedText); + + $('#pageModal').modal({ + show: true + }); +} + +/** + * Resets everything + */ +function reset(){ + $('button.close').click(); + getNextMinute(); +} + +/** + * Big ass button has been clicked. + * Displays confirmation popup. + */ +function clicked(){ + + clearInterval(timeoutPopup); + clickedDate = new Date(); + + var clickedText = + `
+

Almost there youngling

+
+

You've synchronized you watch at + ` + + constructoffsetedDateString(offsetedDate) + + `

+ + + `+ctaText+` + + +

+ +

One does not simply have a timepiece without drift ! + Press the following + button to add/retrieve a minute or + click here to retry.

+ +
+ + + -1 minute + + + + +1 minute + +
+
+
`; + + $('#pageModal .modal-body').html(clickedText); + + $('#pageModal').modal({ + show: true + }); + +} + +/** + * Removes a minute from the offsetedDate + */ +function retrieveMinute(){ + offsetedDate = new Date(offsetedDate.getTime()-60*1000); + $("span#timeSyncAt").text(constructoffsetedDateString(offsetedDate)); +} + +/** + * Adds a minute from the offsetedDate + */ +function addMinute(){ + offsetedDate = new Date(offsetedDate.getTime()+60*1000); + $("span#timeSyncAt").text(constructoffsetedDateString(offsetedDate)); +} + +/** + * Validation function fot the accuracyMeasure + */ +function validateAccuracyMeasure(){ + + var measureId = $('input[name="measureId"]').val(); + + $.post('/measures/accuracyMeasure', + { + measureId: measureId, + referenceTimestamp: offsetedDate.getTime(), + userTimestamp: clickedDate.getTime() + }, function(data){ + var result = $.parseJSON(data); + if(result.success == true) + { + + $('button.close').click(); + + $("#sync-button").hide(); + $('button[name="restartCountdown"]').hide(); + $('.sync-success').show(); + $('.backToMeasure').show(); + $('#mainTitle').hide(); + + if(result.accuracy != null) + { + $('button.close').click(); + if(result.accuracy > 0){ + result.accuracy = '+'+result.accuracy; + } + + $('.watch-accuracy').html(result.accuracy); + $('.watch-percentile').html(result.percentile); + + $('.share-button').each(function(index){ + $(this).attr("href", $(this).attr("href").replace("{WatchPercentile}", result.percentile)); + }); + + } + } + else + { + $('.measure-error').show(); + $('.btn-spinner i').css('display', 'none'); + } + } + ); +} + +/** + * Validation function for the baseMeasure + */ +function validateBaseMeasure(){ + var watchId = $('select[name="watchId"]').val(); + + $.post('/measures/baseMeasure', + { + watchId: watchId, + referenceTimestamp: offsetedDate.getTime(), + userTimestamp: clickedDate.getTime() + }, function(data){ + var response = $.parseJSON(data); + if(response.success == true){ + window.location.replace(window.location.origin+"/measures"); + } + } + ); +}