UNPKG

node-red-contrib-ical-events

Version:
236 lines (225 loc) 9.9 kB
<script type="text/javascript"> RED .nodes .registerType('ical-config', { category: 'config', defaults: { url: { value: '', }, caldav: { value: '', }, caltype: { value: '', }, name: { value: '', }, language: { value: '', }, replacedates: { value: false, }, usecache: { value: false, }, username: {}, password: {}, includeTodo: {}, calendar: {}, pastWeeks: { value: '0', validate: function (v) { if (v && isNaN(v)) return false; return true; } }, futureWeeks: { value: '4', validate: function (v) { if (v && isNaN(v)) return false; return true; } }, }, credentials: { user: { type: "text" }, pass: { type: "password" } }, paletteLabel: "config", label: function () { if (this.name) { return this.name; } return 'iCal Config'; }, oneditprepare: function () { var node = this; if (!node.caltype) { let caltype = 'ical'; if (node.caldav === "false") caltype = "ical" else if (node.caldav === "true") caltype = "caldav" else if (node.caldav === "icloud") caltype = "icloud" $('#node-config-input-caltype option').filter(function () { return $(this).val() == caltype; }).attr('selected', true); } $.getJSON(`kalender-events-version`, function (data) { $('#version').text(data?.version) }); if (node.user || (!node.username && !node.user)) { $('#hint_v1').hide() } $('#node-config-input-caltype').change(function () { var value = $('#node-config-input-caltype').val(); if (!value || value === 'ical') { $('#icloud-tip').hide(); $('#node-config-input-includeTodo').parent().show(); $('#node-config-input-username').parent().show(); $('#node-config-input-password').parent().show(); $('#node-config-input-calendar').parent().hide(); return; } else if (value === 'caldav') { $('#icloud-tip').hide(); $('#node-config-input-includeTodo').parent().show(); $('#node-config-input-username').parent().show(); $('#node-config-input-password').parent().show(); $('#node-config-input-calendar').parent().show(); } else if (value === 'icloud') { $('#icloud-tip').show(); $('#node-config-input-includeTodo').parent().hide(); $('#node-config-input-username').parent().show(); $('#node-config-input-password').parent().show(); $('#node-config-input-calendar').parent().hide(); } }); $('#node-config-input-replacedates').change(function () { var value = $('#node-config-input-replacedates').is(':checked'); if (value) { $('#node-config-input-language').parent().show(); } else { $('#node-config-input-language').parent().hide(); } }); }, }); </script> <script type="text/html" data-template-name="ical-config"> <style> .event { display:flex; } .event .red-ui-typedInput-container { flex:1 } .event span { flex:1 } .event label { min-width: 110px; align-self: center; } .padding-top { padding-top: 10px; } </style> <div class="form-row"> <label for="node-config-input-name" style="width:160px !important"> <i class="fa fa-user"></i> <span>Name:</span></label> <input type="text" id="node-config-input-name" placeholder="" style="width:280px !important"> </div> <hr/> <div class="form-row event"> <label for="node-config-input-url" style="min-width:160px !important"> <i class="fa fa-link"></i> <span>iCal / ics / caldav URL or filepath to ics:</span></label> <input type="text" id="node-config-input-url" placeholder="" style="width:100% !important"> </div> <div class="form-row event"> <label for="node-config-input-caltype" style="width:160px !important"> <i class="fa fa-calendar"></i> <span>Calendar type:</span></label> <input type="hidden" id="node-config-input-caldav"/> <select id="node-config-input-caltype"> <option value="ical">iCal</option> <option value="caldav">CalDav</option> <option value="icloud">iCloud secure</option> </select> </div> <div class="form-tips" id="hint_v1"> <i class="fa fa-exclamation"></i> <b>CAUTION:</b> with v1.0.0 credentials are stored in the node-red internal credential store. It's safer, but you need to reenter credentials. </div> <div class="form-row event"> <label for="node-config-input-username" style="width:160px !important"> <i class="fa fa-user"></i> <span>Username:</span></label> <input type="text" id="node-config-input-user" placeholder="" style="width:280px !important"> <input type="hidden" id="node-config-input-username" placeholder="" style="display:none"> </div> <div class="form-row event"> <label for="node-config-input-password" style="width:160px !important"> <i class="fa fa-key"></i> <span>Password:</span></label> <input type="password" id="node-config-input-pass" placeholder="" style="width:280px !important"> <input type="password" id="node-config-input-password" placeholder="" style="display:none"> </div> <div class="form-tips" id="icloud-tip"> <i class="fa fa-exclamation"></i> <b>CAUTION:</b> for iCloud secure get app a specific password, described like here: <a href="https://github.com/naimo84/kalender-events/wiki/Get-iCloud-secure-URL">https://github.com/naimo84/kalender-events/wiki/Get-iCloud-secure-URL</a> </div> <div class="form-row event"> <label for="node-config-input-usecache" style="width:160px !important"> <i class="fa fa-asterisk"></i> <span>Use cache in case of an error:</span></label> <input type="checkbox" id="node-config-input-usecache" placeholder="" style="width:16px !important"> </div> <div class="form-row event"> <label for="node-config-input-replacedates" style="width:160px !important"> <i class="fa fa-edit"></i> <span>Replace Dates with name:</span></label> <input type="checkbox" id="node-config-input-replacedates" placeholder="" style="width:16px !important"> </div> <div class="form-row event"> <label for="node-config-input-language" style="width:160px !important"> <i class="fa fa-language"></i> <span>Language:</span></label> <select id="node-config-input-language"> <option value="de">Deutsch</option> <option value="en">English</option> <option value="ru">русский</option> <option value="pl">polski</option> <option value="nl">Nederlands</option> <option value="fr">français</option> <option value="it">Italiano</option> <option value="es">Espanol</option> </select> </div> <div class="form-row event"> <label for="node-config-input-calendar" style="width:160px !important"> <i class="fa fa-calendar"></i> <span>Calendar:</span> </label> <input type="text" id="node-config-input-calendar" placeholder="" style="width:280px !important"> </div> <hr> <div class="form-row event"> <span style="min-width:160px !important"> <i class="fa fa-info"></i> <span> <a href="https://github.com/naimo84/kalender-events">kalender-events</a> version: </span></span> <span id="version" placeholder="" style="width:100% !important"> </div> </script> <script type="text/html" data-help-name="ical-config"> <div class="form-row"> <a href="https://naimo84.github.io/kalender-events/config/" target="_blank"> <img src="https://img.shields.io/badge/doku-naimo84.github.io-0078D6?style=for-the-badge&logo=github&logoColor=white"/> </a> </div> </script>