From e75790009485596a4ef5c531c7f1c6a2ab509d35 Mon Sep 17 00:00:00 2001 From: Pierre Date: Sun, 7 Jan 2018 17:00:19 +0100 Subject: [PATCH] Updated the value sent by the countdown timer --- assets/js/components/posts/form.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/assets/js/components/posts/form.js b/assets/js/components/posts/form.js index 01ea23af..571726b8 100644 --- a/assets/js/components/posts/form.js +++ b/assets/js/components/posts/form.js @@ -401,9 +401,23 @@ ComunicWeb.components.posts.form = { return; } + //Convert the date to an array + var end_date_array = timeEndInput.value.split("/"); + if(end_date_array.length < 3) { + ComunicWeb.common.notificationSystem.showNotification("Specified date for the countdown timer is invalid !", "danger"); + return; + } + + //Convert the end time to a timestamp + var end_date = new Date(); + end_date.setDate(end_date_array[0]); + end_date.setMonth(end_date_array[1]); + end_date.setFullYear(end_date_array[2]); + var time_end = Math.floor(end_date.getTime()/1000); + //Append values datas.append("kind", "countdown"); - datas.append("date-end", timeEndInput.value); + datas.append("time-end", time_end); } //Check for survey