191 lines
8.4 KiB
HTML
191 lines
8.4 KiB
HTML
<html>
|
|
<head>
|
|
<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>
|
|
|
|
<!-- you have to define 2 functions in the global scope: -->
|
|
<script type="text/javascript">
|
|
// the function loadSettings has to exist ...
|
|
function load(settings, onChange) {
|
|
for (var key in settings) {
|
|
if (!settings.hasOwnProperty(key)) continue;
|
|
var $value = $('#' + key + '.value');
|
|
if ($value.attr('type') === 'checkbox') {
|
|
$value.prop('checked', settings[key]).on('change', function() {
|
|
onChange();
|
|
});
|
|
} else {
|
|
$value.val(settings[key]).on('change', function() {
|
|
changed = true;
|
|
$('#save').button("enable");
|
|
}).on('keyup', function() {
|
|
onChange();
|
|
});
|
|
}
|
|
}
|
|
onChange(false);
|
|
$('#test').click(test);
|
|
}
|
|
|
|
function test() {
|
|
//var newValue = JSON.stringify(getSettings());
|
|
if (!common.enabled) {
|
|
showMessage('Enable first the adapter to test notification.');
|
|
return;
|
|
}
|
|
if (changed) {
|
|
showMessage('First save the settings');
|
|
return;
|
|
}
|
|
sendTo('pushover.' + instance, 'send', 'This is test notification!');
|
|
showMessage('Check the log or your pushover app!');
|
|
}
|
|
|
|
function saveHelper(obj, id, value) {
|
|
var ids = id.split('_');
|
|
if (ids.length === 1) {
|
|
obj[id] = value;
|
|
} else if (ids.length === 2) {
|
|
if (!obj[ids[0]]) obj[ids[0]] = {};
|
|
obj[ids[0]][ids[1]] = value;
|
|
} else if (ids.length === 3) {
|
|
if (ids[2] === 'pass') {
|
|
value = encrypt("Zgfr56gFe87jJOM", value);
|
|
}
|
|
|
|
if (!obj[ids[0]]) obj[ids[0]] = {};
|
|
if (!obj[ids[0]][ids[1]]) obj[ids[0]][ids[1]] = {};
|
|
obj[ids[0]][ids[1]][ids[2]] = value;
|
|
}
|
|
return obj;
|
|
}
|
|
|
|
function getSettings() {
|
|
var obj = {};
|
|
$('.value').each(function () {
|
|
var $this = $(this);
|
|
var id = $this.attr('id');
|
|
|
|
if ($this.attr('type') === 'checkbox') {
|
|
obj = saveHelper(obj, id, $this.prop('checked'))
|
|
} else {
|
|
obj = saveHelper(obj, id, $this.val())
|
|
}
|
|
});
|
|
return obj;
|
|
}
|
|
|
|
function save(callback) {
|
|
callback(getSettings());
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<!-- you have to put your config page in a div with id adapter-container -->
|
|
<div 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">Pushover settings</a></li>
|
|
<li class="tab col s4"><a href="#tab-notification" class="translate">Notification settings</a></li>
|
|
</ul>
|
|
</div>
|
|
<div id="tab-main" class="col s12 page">
|
|
<div class="row">
|
|
<div class="col s6 m4 l2">
|
|
<img src="pushover.png" class="logo">
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="input-field col s12 m6 l4 xl3">
|
|
<input id="user" type="text" size="50" class="value"/>
|
|
<label for="user" class="translate">Group Key</label>
|
|
<span class="translate">Group Key of Delivery Group</span>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="input-field col s12 m6 l4 xl3">
|
|
<input id="token" type="text" size="50" class="value"/>
|
|
<label for="token" class="translate">Token:</label>
|
|
<span class="translate">API Token/Key of Application</span>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="input-field col s12 m6 l4 xl3">
|
|
<input id="smsUrl" type="text" size="50" class="value"/>
|
|
<label for="smsUrl" class="translate">smsUrl:</label>
|
|
<span class="translate">smsUrl</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div id="tab-notification" class="col s12 page">
|
|
<div class="row">
|
|
<div class="input-field col s12 m6 l4 xl3">
|
|
<input id="title" type="text" size="50" class="value"/>
|
|
<label for="title" class="translate">Title</label>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="input-field col s12 m6 l4 xl3">
|
|
<select id="sound" class="value">
|
|
<option value=""> default </option>
|
|
<option value="pushover"> pushover </option>
|
|
<option value="bike"> bike </option>
|
|
<option value="bugle"> bugle</option>
|
|
<option value="cashregister"> cashregister </option>
|
|
<option value="classical"> classical </option>
|
|
<option value="cosmic"> cosmic </option>
|
|
<option value="falling"> falling</option>
|
|
<option value="gamelan"> gamelan </option>
|
|
<option value="incoming"> incoming </option>
|
|
<option value="intermission"> intermission </option>
|
|
<option value="magic"> magic </option>
|
|
<option value="mechanical"> mechanical </option>
|
|
<option value="pianobar"> pianobar </option>
|
|
<option value="siren"> siren</option>
|
|
<option value="spacealarm"> spacealarm </option>
|
|
<option value="tugboat"> tugboat </option>
|
|
<option value="alien"> alien</option>
|
|
<option value="climb"> climb </option>
|
|
<option value="persistent"> persistent </option>
|
|
<option value="echo"> echo</option>
|
|
<option value="updown"> updown </option>
|
|
<option value="none"> none</option>
|
|
</select>
|
|
<label for="sound" class="translate">Sound</label>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="input-field col s12 m6 l4 xl3">
|
|
<select id="priority" class="value">
|
|
<option value="-1" class="translate">quiet</option>
|
|
<option value="0" class="translate">default</option>
|
|
<option value="1" class="translate">high-priority</option>
|
|
<!--option value="2">require confirmation</option-->
|
|
</select>
|
|
<label for="priority" class="translate">Priority</label>
|
|
</div>
|
|
</div>
|
|
<div class="row">
|
|
<div class="col s4">
|
|
<a id="test" class="waves-effect waves-light btn"><i class="material-icons left">notifications_active</i><span class="translate">Test</span></a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</body>
|
|
</html>
|