diff --git a/README.md b/README.md
index 6e05b42..f825134 100644
--- a/README.md
+++ b/README.md
@@ -20,78 +20,12 @@ Countdown Adapter for ioBroker
The goal of the adapter is to provide you a possibility to run countdowns for future events, with years, months, days, hours and minutes. It will provide you each of those valies seperately, and also two strings with a short and long version of the date.
+## How to use it
-## Displaying countdowns
-The adapter provides you automatically a json table and as a HTML table. For the json, please choose the widget "basic-table". For the html, choose the "basic - string (unescaped)" one.
+[English description](docs/en/countdown.md)
-It is possible to either display the short text or the long text.
-![Logo](admin/countdown_json.png)
+[Deutsche Anleitung](docs/de/countdown.md)
-## How to create countdowns
-There are two ways to set up countdowns:
-
-* You can create a countdown in the adapter settings, in the tab "Create Countdown".
-* You can create a manual state in the device "setup". The name of the object is the alarm name, and the value will be the date. The date neets to be in the format "DD.MM.YYYY HH:mm:ss".
-* You can create an alarm with sendto. There, you can either send the components (minimum is Year Month Date) or a date string. For the date string, you can adjust the format in the setup of the adapter.
-![Logo](admin/countdown_blocky.png)
-* You can add days, months and years with sendto to todays date. Therefore, please send the component "name" and either "addminutes", "addhours", "adddays", "addmonths" or "addyears" as int value.
-![Logo](admin/countdown_blocky_add.png)
-
-## How to delete countdowns
-You can delete a countdown with the sendto. Therefore, send just the name with sendto to the adapter, and the countdown will be deleted automatically.
-
-## Repeating countdown
-If you want a countdown to repeat in a defined period (e.g. you cant a countdown for your wedding day every year) you can also do this with this adapter. Therefore either fill the field "Repeat period" in the settings of the adapter, or add the period after the date when you create a countdown with the type "date". A sendTo would look like that for a countdown which should end on the 1st of April 2020 and repeat every year:
-
-sendTo("countdown.0", "send", {
- "name": 'Wedding Day',
- "date": '01.04.2020 00:01+1Y'
-});
-
-## Count Up
-Newly added is the feature to "count up" - so to count the days from a date in the past. This can be done either in the adapter setup, or with adding a "#" to a date string, e.g.
-
-sendTo("countdown.0", "send", {
- "name": 'Birthdate',
- "date": '01.04.2020 00:01#
-});
-
-
-
-Parameters here are:
-* Y: Years
-* M: Months
-* D: Days
-* H: Hours
-* m: Minutes
-
-
-## Available outputs
-
-|Data type|Description|
-|:---:|:---:|
-|minutes|Minutes until countdown end (not total!)|
-|hours|Hours until countdown end (not total!)|
-|days|Days until countdown end (not total!)|
-|months|Months until countdown end (not total!)|
-|years|Years until countdown end (not total!)|
-|name|Countdown name|
-|endDate|End date of countdown - formated as in the setup defined|
-|inWordsShort|Combined value of minutes, hours,... - e.g. 1Y 5M 4D|
-|inWordsLong|Combined value of minutes, hours,... - e.g. 1 Year 5 Months 4 Days|
-|totalHours|Total no. of hours until the end date|
-|totalDays|Total no. of days until the end date|
-|totalWeeks|Total no. of weeks until the end date|
-|totalMonths|Total no. of months until the end date|
-|totalYears|Total no. of years until the end date|
-
-|reached|Boolean field defining if the end date was reached or not|
-|repeatEvery|Countdown is repeted by this period after reaching the enddate|
-
-
-## Features to add
-* Possibility to add a script as a parameter and start it when countdown ends
-* Possibility to use plus and minus in addminutes and the other add functions
## Changelog
diff --git a/admin/index_m.html b/admin/index_m.html
index 51a103c..d4e54d1 100644
--- a/admin/index_m.html
+++ b/admin/index_m.html
@@ -64,7 +64,6 @@
}
})
- console.log('Found ' + originalNames[i] + " :" + found)
if (!found){
sendTo(adapter + '.' + instance, 'send', {
"name": originalNames[i],
@@ -74,31 +73,48 @@
// update setup entries
for (var i = 0; i < countdownData.length; i++) {
- console.log('orig Date: ' + countdownData[i].countdownDate)
+ if (checkError(countdownData[i].countdownName,countdownData[i].countdownDate,countdownData[i].countdownTime)){
- var dateMomentObject = moment(countdownData[i].countdownDate, "YYYY-MM-DD");
- console.log('New Date: ' + dateMomentObject)
+ var dateMomentObject = moment(countdownData[i].countdownDate, "YYYY-MM-DD");
- var dateString = moment(dateMomentObject).local().format('DD.MM.YYYY')
- dateString += ' ' + countdownData[i].countdownTime + ':00'
+ var dateString = moment(dateMomentObject).local().format('DD.MM.YYYY')
+ dateString += ' ' + countdownData[i].countdownTime + ':00'
- if (countdownData[i].countdownRepeatCycle != ''){
- dateString += '+' + countdownData[i].countdownRepeatCycle
+ if (countdownData[i].countdownRepeatCycle != ''){
+ dateString += '+' + countdownData[i].countdownRepeatCycle
+ }
+ if (countdownData[i].countdownCountUp){
+ dateString += '#'
}
- if (countdownData[i].countdownCountUp){
- dateString += '#'
- }
- console.log('DateString: ' + dateString)
-
- sendTo(adapter + '.' + instance, 'send', {
- "name": countdownData[i].countdownName,
- "date": dateString
+
+ sendTo(adapter + '.' + instance, 'send', {
+ "name": countdownData[i].countdownName,
+ "date": dateString
})
+ }
+
+
}
}
+
+ function checkError(countname,date,time){
+ var noerrorFound = true
+ if (name = ""){
+ showToast(_('Please fill in a name for the countdown!'));
+ noerrorFound = false
+ }
+ if (!moment(date, 'YYYY-MM-DD',true).isValid()) {
+ showToast(_('Please fill in a valid date for the countdown '+ countname ));
+ noerrorFound = false
+ }
+
+
+ console.log('No error found for ' + countname + ': ' + noerrorFound)
+ return noerrorFound
+ }
function load(settings, onChange) {
_onChange = onChange;
@@ -124,44 +140,6 @@
onChange(false);
if (M) M.updateTextFields();
- /*
- $('#addCountdown').on('click', function () {
- let CountdownName = $('#CountName').val();
- let CountdownDate = $('#CountDate').val();
- let CountdownTime = $('#CountTime').val();
- let RepeatPeriod = $('#RepeatPeriod').val();
- let CountUp = $('#CountUp').is(':checked');
-
-
- if (CountdownName == ''){
- showToast(_('Please fill in a name for the countdown!'));
- }
- else if ((CountdownTime == '')|| (CountdownDate =='')) {
- showToast(_('Please fill in date and time for the countdown!'))
- }
- else {
- let CountYear = CountdownDate.slice(0, 0 + 4)
- let CountMonth= CountdownDate.slice(5, 5 + 2)
- let CountDay = CountdownDate.slice(8, 8 + 2)
- var CountDateTime = ''
- CountDateTime = CountDay + '.' + CountMonth + '.' + CountYear + ' ' + CountdownTime + ':00'
- if (RepeatPeriod != ''){
- CountDateTime += '+' + RepeatPeriod
- }
- if (CountUp){
- CountDateTime += '#'
- }
-
- sendTo(adapter + '.' + instance, 'send', {
- "name": CountdownName,
- "date": CountDateTime
- })
- showToast(_('Countdown ' + CountdownName + ' with date ' + CountDateTime + ' added.'))
- }
- console.log('Countdown ' + CountdownName + ' ' + CountdownDate)
-
- });
- */
}
function loadSetup() {
@@ -221,8 +199,37 @@
-
+
+
+
+
+
+
+
+
+
+
+ name |
+ date |
+ time |
+ repeatColoumn |
+ countUp |
+ delete |
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
- name |
- date |
- time |
- repeatColoumn |
- countUp |
- delete |
-
-
-
-
-
-
-
+