Skip to content

Commit

Permalink
add settings page to git
Browse files Browse the repository at this point in the history
  • Loading branch information
RWensveen committed Jul 14, 2018
1 parent 0803001 commit 14d259d
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 0 deletions.
30 changes: 30 additions & 0 deletions settings/css/settings.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Input form fields */

.code {
font-family: monospace;
}

.form_label {
width: 150px !important;
margin-right: 20px;
display: inherit;
}
.form_input {
width: 250px !important;
display: inherit;
}

select {
padding: .5em .75em;
vertical-align: middle;
font-size: 12px;
font-family: inherit;
font-weight: inherit;
border: 1px solid #aaa;
border-radius: 2px;
width:270px !important;
}

body{
position: relative;
}
21 changes: 21 additions & 0 deletions settings/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<!doctype html>
<html>
<head>
<script type="text/javascript" src="/homey.js" data-origin="settings"></script>
<script type="text/javascript" src="/manager/webserver/assets/js/jquery.js"></script>
<script type="text/javascript" src="js/settings.js"></script>
<link rel="stylesheet" href="css/settings.css">
</head>
<body>
<h1 data-i18n="settings.title"></h1>
<fieldset>
<p data-i18n="settings.compatinfo"></p>
<input type="checkbox" id="compatmode"><label for="compatmode" data-i18n="settings.compatmode"></label>
</fieldset>
<fieldset>
<p data-i18n="settings.debuginfo"></p>
<input type="checkbox" id="debuglog"><label for="debuglog" data-i18n="settings.debuglog"></label>
</fieldset>
<P>
</body>
</html>
28 changes: 28 additions & 0 deletions settings/js/settings.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

/* global $, __ */
var HomeyObj;

function onHomeyReady (Homey) {
HomeyObj = Homey;

$('#debuglog').change(function () { saveDebugSettings() })
$('#compatmode').change(function () { saveDebugSettings() })

HomeyObj.get('DebugSettings', function (error, currentSettings) {
if (error) return console.log(error)

$('#compatmode').prop('checked', currentSettings['compat'] || false )
$('#debuglog').prop('checked', currentSettings['logging'] || false )
})

HomeyObj.ready()
}

function saveDebugSettings () {
var currentSettings = {
'compat' : $('#compatmode').prop('checked'),
'logging' : $('#debuglog').prop('checked')
}
HomeyObj.set('DebugSettings', currentSettings )
}

0 comments on commit 14d259d

Please sign in to comment.