From c01f08113514078f6232a9adb715717e92c1293f Mon Sep 17 00:00:00 2001 From: Pierre Date: Wed, 3 Jan 2018 12:28:46 +0100 Subject: [PATCH] Implement countdown timer --- assets/js/components/posts/ui.js | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/assets/js/components/posts/ui.js b/assets/js/components/posts/ui.js index 80793566..55fd0d72 100644 --- a/assets/js/components/posts/ui.js +++ b/assets/js/components/posts/ui.js @@ -226,6 +226,26 @@ ComunicWeb.components.posts.ui = { } + //In case of countdown timer + else if (infos.kind == "countdown"){ + + //Create countdown target + var target = createElem2({ + appendTo: postRoot, + type: "div", + class: "post-countdown" + }); + + //Set the date of the countdown time + var date = new Date(); + date.setFullYear(infos.year_end); + date.setMonth(infos.month_end - 1); //Months starts from 0 (january) to 11 (december) + date.setDate(infos.day_end); + + //Initialize countdown timer + ComunicWeb.components.countdown.init(date, target); + } + //If the kind of post was not implemented else { //Log error @@ -244,7 +264,6 @@ ComunicWeb.components.posts.ui = { - //Add bottom elements container var bottomArea = createElem2({ appendTo: postRoot,