Initial commit
This commit is contained in:
Binary file not shown.
|
After Width: | Height: | Size: 6.0 KiB |
@@ -0,0 +1,219 @@
|
||||
<html>
|
||||
<head>
|
||||
<!-- these 4 files always have to be included -->
|
||||
<link rel="stylesheet" type="text/css" href="../../lib/css/materialize.css">
|
||||
<link rel="stylesheet" type="text/css" href="../../css/adapter.css"/>
|
||||
|
||||
<script type="text/javascript" src="../../lib/js/jquery-3.2.1.min.js"></script>
|
||||
<script type="text/javascript" src="../../socket.io/socket.io.js"></script>
|
||||
<script type="text/javascript" src="../../lib/js/ace-1.2.0/ace.js"></script>
|
||||
|
||||
<!-- these files always have to be included -->
|
||||
<script type="text/javascript" src="../../js/translate.js"></script>
|
||||
<script type="text/javascript" src="../../lib/js/materialize.js"></script>
|
||||
<script type="text/javascript" src="../../js/adapter-settings.js"></script>
|
||||
<script type="text/javascript" src="words.js"></script>
|
||||
<style>
|
||||
.m .col .select-wrapper+label {
|
||||
top: -26px;
|
||||
}
|
||||
.m span {
|
||||
font-size: 12px;
|
||||
}
|
||||
#wrapperConfig {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
#tab-json>.row {
|
||||
height: calc(100% - 20px);
|
||||
}
|
||||
#tab-json .col {
|
||||
height: 100%;
|
||||
}
|
||||
.adapter-container>.row {
|
||||
height: 100%;
|
||||
}
|
||||
.m .page {
|
||||
height: calc(100% - 50px);
|
||||
}
|
||||
</style>
|
||||
<!-- you have to define 2 functions in the global scope: -->
|
||||
<script type="text/javascript">
|
||||
var editor;
|
||||
var wrapperConfig;
|
||||
|
||||
function initEditor(onChange) {
|
||||
if (!editor) {
|
||||
setTimeout(function () {
|
||||
if ($('#wrapperConfig').is(':visible')) {
|
||||
editor = ace.edit('wrapperConfig');
|
||||
editor.getSession().setMode('ace/mode/json');
|
||||
editor.$blockScrolling = true;
|
||||
editor.setValue(wrapperConfig);
|
||||
editor.getSession().on('change', function() {
|
||||
onChange();
|
||||
});
|
||||
} else {
|
||||
initEditor(onChange);
|
||||
}
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
// the function loadSettings has to exist ...
|
||||
function load(settings, onChange) {
|
||||
// example: select elements with id=key and class=value and insert value
|
||||
if (!settings) return;
|
||||
if (settings.characteristicPollingInterval === undefined) settings.characteristicPollingInterval = 0;
|
||||
$('.value').each(function () {
|
||||
var $key = $(this);
|
||||
var id = $key.attr('id');
|
||||
if ($key.attr('type') === 'checkbox') {
|
||||
// do not call onChange direct, because onChange could expect some arguments
|
||||
$key.prop('checked', settings[id]).change(function() {
|
||||
onChange();
|
||||
});
|
||||
} else {
|
||||
// do not call onChange direct, because onChange could expect some arguments
|
||||
$key.val(settings[id]).change(function() {
|
||||
onChange();
|
||||
}).keyup(function() {
|
||||
onChange();
|
||||
});
|
||||
}
|
||||
});
|
||||
$('.tab-json').on('click', function (e) {
|
||||
initEditor(onChange);
|
||||
});
|
||||
|
||||
$('#useGlobalHomebridge').on('change', function () {
|
||||
if ($(this).prop('checked')) {
|
||||
$('.global').show();
|
||||
$('.local').hide();
|
||||
$('.tab-json').addClass('disabled');
|
||||
} else {
|
||||
$('.global').hide();
|
||||
$('.local').show();
|
||||
$('.tab-json').removeClass('disabled');
|
||||
}
|
||||
}).trigger('change');
|
||||
|
||||
wrapperConfig = JSON.stringify(settings.wrapperConfig || '{}', null, 2);
|
||||
|
||||
list2chips('.libraries', settings.libraries || '', onChange);
|
||||
|
||||
onChange(false);
|
||||
M.updateTextFields(); // function Materialize.updateTextFields(); to reinitialize all the Materialize labels on the page if you are dynamically adding inputs.
|
||||
}
|
||||
|
||||
function list2chips(selector, list, onChange) {
|
||||
var chips = list.split(/[,;\s]+/);
|
||||
var data = [];
|
||||
for (var c = 0; c < chips.length; c++) {
|
||||
if (chips[c] && chips[c].trim()) {
|
||||
data.push({tag: chips[c].trim()});
|
||||
}
|
||||
}
|
||||
$(selector).chips({
|
||||
data: data,
|
||||
placeholder: _('Module names'),
|
||||
secondaryPlaceholder: _('Add module'),
|
||||
onChipAdd: onChange,
|
||||
onChipDelete: onChange
|
||||
});
|
||||
}
|
||||
|
||||
function chips2list(selector) {
|
||||
var data = $(selector).chips('getData');
|
||||
var text = [];
|
||||
for (var lib = 0; lib < data.length; lib++) {
|
||||
text.push(data[lib].tag);
|
||||
}
|
||||
return text.join(' ');
|
||||
}
|
||||
|
||||
// ... and the function save has to exist.
|
||||
// you have to make sure the callback is called with the settings object as first param!
|
||||
function save(callback) {
|
||||
// example: select elements with class=value and build settings object
|
||||
var obj = {};
|
||||
$('.value').each(function () {
|
||||
var $this = $(this);
|
||||
if ($this.attr('type') === 'checkbox') {
|
||||
obj[$this.attr('id')] = $this.prop('checked');
|
||||
} else {
|
||||
obj[$this.attr('id')] = $this.val();
|
||||
}
|
||||
});
|
||||
obj.libraries = chips2list('.libraries');
|
||||
wrapperConfig = editor ? editor.getValue() : wrapperConfig;
|
||||
|
||||
var _obj;
|
||||
try {
|
||||
_obj = JSON.parse(wrapperConfig);
|
||||
} catch (e) {
|
||||
showError(e, _('Parse error'), 'error_outline');
|
||||
return false;
|
||||
}
|
||||
obj.wrapperConfig = _obj;
|
||||
|
||||
callback(obj);
|
||||
}
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<!-- you have to put your config page in a div with id adapter-container -->
|
||||
<div class="m adapter-container">
|
||||
<div class="row">
|
||||
<div class="col s12">
|
||||
<ul class="tabs">
|
||||
<li class="tab col s4"><a href="#tab-main" class="translate active">Main settings</a></li>
|
||||
<li class="tab col s4 tab-json"><a href="#tab-json" class="translate">Configuration file</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="tab-main" class="col s12 page">
|
||||
<div class="row">
|
||||
<div class="col s6 m4 l2">
|
||||
<img src="ham.png" class="logo">
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="input-field col s12 m6 l4 xl3">
|
||||
<input id="useGlobalHomebridge" type="checkbox" class="value" />
|
||||
<span for="useGlobalHomebridge" class="translate">useGlobalHomebridge</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row global">
|
||||
<div class="input-field col s12 m6 l4 xl3">
|
||||
<input class="value" id="globalHomebridgeBasePath" type="text">
|
||||
<label for="globalHomebridgeBasePath">Global Homebridge Path</label>
|
||||
<span class="translate">Global Homebridge Path</span>
|
||||
</div>
|
||||
<div class="input-field col s12 m6 l4 xl3">
|
||||
<input class="value" id="globalHomebridgeConfigPath" type="text">
|
||||
<label for="globalHomebridgeConfigPath">Global Homebridge Config Directory Path</label>
|
||||
<span class="translate">Global Homebridge Config Directory Path</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row local">
|
||||
<div class="col s12">
|
||||
<label class="translate">Additional npm modules:</label>
|
||||
<div class="chips libraries"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row local">
|
||||
<div class="input-field col s4 ">
|
||||
<input class="value" id="characteristicPollingInterval" type="number" min="0" max="1000000"/>s
|
||||
<label for="characteristicPollingInterval">Value Polling Interval</label>
|
||||
<span class="translate">Value Polling Interval</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="tab-json" class="col s12 page">
|
||||
<div id="wrapperConfig">Wrapper-Konfiguration (Non-Global-Homebridge)</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,26 @@
|
||||
// DO NOT EDIT THIS FILE!!! IT WILL BE AUTOMATICALLY GENERATED FROM src/i18n
|
||||
/*global systemDictionary:true */
|
||||
'use strict';
|
||||
|
||||
systemDictionary = {
|
||||
"Add module": { "en": "Add module", "de": "Modul hinzufügen", "ru": "Добавить модуль", "pt": "Adicionar módulo", "nl": "Module toevoegen", "fr": "Add module", "it": "Aggiungi modulo", "es": "Agregar módulo", "pl": "Dodaj moduł"},
|
||||
"Additional npm modules:": { "en": "Additional npm modules:", "de": "Zusätzliche npm-Module:", "ru": "Дополнительные модули npm:", "pt": "Módulos adicionais npm:", "nl": "Extra npm-modules:", "fr": "Additional npm modules:", "it": "Moduli aggiuntivi di npm:", "es": "Módulos npm adicionales:", "pl": "Dodatkowe moduły npm:"},
|
||||
"Configuration file": { "en": "Configuration file", "de": "Konfigurationsdatei", "ru": "Файл конфигурации", "pt": "Arquivo de configuração", "nl": "Configuratiebestand", "fr": "Configuration file", "it": "File di configurazione", "es": "Archivo de configuración", "pl": "Plik konfiguracyjny"},
|
||||
"Global Homebridge Config Directory Path": { "en": "Global Homebridge Config Directory Path", "de": "Globaler Homebridge-Konfigurationsverzeichnispfad", "ru": "Путь к каталогу Global Homebridge Config", "pt": "Caminho global do diretório de configuração do Homebridge", "nl": "Wereldwijd Homebridge Config Directory-pad", "fr": "Global Homebridge Config Directory Path", "it": "Percorso globale della directory di configurazione di Homebridge", "es": "Ruta del directorio de Global Homebridge Config", "pl": "Ścieżka katalogu konfiguracji globalnej Homebridge"},
|
||||
"Global Homebridge Path": { "en": "Global Homebridge Path", "de": "Globaler Homebridge-Pfad", "ru": "Глобальный путь на мосту", "pt": "Caminho Global Homebridge", "nl": "Wereldwijd homebridge pad", "fr": "Global Homebridge Path", "it": "Percorso globale di Homebridge", "es": "Ruta Global Homebridge", "pl": "Global Homebridge Path"},
|
||||
"Main settings": { "en": "Main settings", "de": "Haupteinstellungen", "ru": "Основные настройки", "pt": "Configurações principais", "nl": "Belangrijkste instellingen", "fr": "Réglages principaux", "it": "Impostazioni principali", "es": "Ajustes principales", "pl": "Ustawienia główne"},
|
||||
"Module names": { "en": "Module names", "de": "Modulnamen", "ru": "Имена модулей", "pt": "Nomes de módulos", "nl": "Module namen", "fr": "Module names", "it": "Nomi dei moduli", "es": "Nombres de módulos", "pl": "Nazwy modułów"},
|
||||
"useGlobalHomebridge": { "en": "Use global Homebridge", "de": "Verwenden Sie globale Homebridge", "ru": "Использовать глобальный Homebridge", "pt": "Use Homebridge global", "nl": "Gebruik wereldwijde Homebridge", "fr": "useGlobalHomebridge", "it": "Usa Homebridge globale", "es": "Utilice Global Homebridge", "pl": "Użyj globalnego rozwiązania Homebridge"},
|
||||
"wrapperConfig": { "en": "Wrapper configuration", "de": "Wrapper-Konfiguration", "ru": "Конфигурация Wrapper", "pt": "Configuração do invólucro", "nl": "Wrapper-configuratie", "fr": "wrapperConfig", "it": "Configurazione wrapper", "es": "Configuración del contenedor", "pl": "Konfiguracja opakowania"},
|
||||
"Value Polling Interval": {
|
||||
"en": "Value Polling Interval",
|
||||
"de": "Wertabfrageintervall",
|
||||
"ru": "Интервал опроса значений",
|
||||
"pt": "Intervalo de Polling de Valor",
|
||||
"nl": "Value Polling Interval",
|
||||
"fr": "Intervalle d'interrogation de valeur",
|
||||
"it": "Intervallo di polling del valore",
|
||||
"es": "Intervalo de interrogación de valor",
|
||||
"pl": "Okres odpytywania wartości"
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user