intuiclock/config/index.html

137 lines
5.6 KiB
HTML
Raw Normal View History

2015-08-15 18:04:20 +00:00
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0" name="viewport">
<title>IntuiClock Config</title>
<link rel="stylesheet" href="css/slate.min.css">
<script type="text/javascript" src="js/slate.min.js"></script>
</head>
<body>
<form id="main-form">
<div class="item-container">
2015-08-27 21:52:47 +00:00
<div class="item-container-header">Time &amp; Date</div>
2015-08-15 18:04:20 +00:00
<div class="item-container-content">
<label class="item">
Seconds Hand
<input id="input-seconds-hand" type="checkbox" class="item-toggle" name="seconds-hand" checked>
</label>
2015-08-27 21:52:47 +00:00
<label class="item">
Date Format
<select id="input-date-format" name="date-format" class="item-select">
<option class="item-select-option" selected value="t">10 Aug 2015</option>
<option class="item-select-option" value="d">10/08/2015</option>
<option class="item-select-option" value="m">08/10/2015</option>
</select>
</label>
</div>
<div class="item-container-footer">Disable the seconds hand to reduce battery use.</div>
</div>
<div class="item-container">
<div class="item-container-header">Appearance</div>
<div class="item-container-content">
2015-08-15 18:04:20 +00:00
<label class="item">
Battery Indicator
<input id="input-battery-indicator" type="checkbox" class="item-toggle" name="battery-indicator" checked>
</label>
2015-08-27 19:28:16 +00:00
<label class="item">
Wide Window
<input id="input-wide-layout" type="checkbox" class="item-toggle" name="wide-layout">
</label>
2015-08-15 18:04:20 +00:00
<label class="item">
2015-08-27 21:52:47 +00:00
XEN Style
<input id="input-xen-style" type="checkbox" class="item-toggle" name="xen-style">
2015-08-15 18:04:20 +00:00
</label>
</div>
</div>
<div class="item-container">
<div class="button-container">
<input id="button-submit" type="button" class="item-button" value="SAVE">
</div>
</div>
</form>
</body>
<script>
function getConfigData() {
var input_seconds_hand = document.getElementById('input-seconds-hand'),
input_battery_indicator = document.getElementById('input-battery-indicator'),
2015-08-27 19:28:16 +00:00
input_date_format = document.getElementById('input-date-format'),
2015-08-27 21:52:47 +00:00
input_wide_layout = document.getElementById('input-wide-layout'),
input_xen_style = document.getElementById('input-xen-style');
2015-08-15 18:04:20 +00:00
var options = {
'seconds_hand': input_seconds_hand.checked,
'battery_indicator': input_battery_indicator.checked,
2015-08-27 19:28:16 +00:00
'date_format': input_date_format.value,
2015-08-27 21:52:47 +00:00
'wide_layout': input_wide_layout.checked,
'xen_style': input_xen_style.checked
2015-08-15 18:04:20 +00:00
};
// Save for next launch
localStorage['seconds_hand'] = options['seconds_hand'];
localStorage['battery_indicator'] = options['battery_indicator'];
localStorage['date_format'] = options['date_format'];
2015-08-27 19:28:16 +00:00
localStorage['wide_layout'] = options['wide_layout'];
2015-08-27 21:52:47 +00:00
localStorage['xen_style'] = options['xen_style'];
2015-08-15 18:04:20 +00:00
2015-08-27 21:52:47 +00:00
// console.log('Got options: ' + JSON.stringify(options));
2015-08-15 18:04:20 +00:00
return options;
}
function getQueryParam(variable, defaultValue) {
var query = location.search.substring(1),
vars = query.split('&');
for (var i = 0; i < vars.length; i++) {
var pair = vars[i].split('=');
if (pair[0] === variable) {
return decodeURIComponent(pair[1]);
}
}
return defaultValue || false;
}
var button_submit = document.getElementById('button-submit');
button_submit.addEventListener('click', function() {
2015-08-27 21:52:47 +00:00
// console.log('Submit');
2015-08-15 18:04:20 +00:00
// Set the return URL depending on the runtime environment
var return_to = getQueryParam('return_to', 'pebblejs://close#');
document.location = return_to + encodeURIComponent(JSON.stringify(getConfigData()));
});
(function() {
var input_seconds_hand = document.getElementById('input-seconds-hand'),
input_battery_indicator = document.getElementById('input-battery-indicator'),
2015-08-27 19:28:16 +00:00
input_date_format = document.getElementById('input-date-format'),
2015-08-27 21:52:47 +00:00
input_wide_layout = document.getElementById('input-wide-layout'),
input_xen_style = document.getElementById('input-xen-style');
2015-08-15 18:04:20 +00:00
if (localStorage['seconds_hand']) {
input_seconds_hand.checked = JSON.parse(localStorage['seconds_hand']);
}
if (localStorage['battery_indicator']) {
input_battery_indicator.checked = JSON.parse(localStorage['battery_indicator']);
}
if (localStorage['date_format']) {
input_date_format.value = localStorage['date_format'];
}
2015-08-27 19:28:16 +00:00
if (localStorage['wide_layout']) {
input_wide_layout.checked = JSON.parse(localStorage['wide_layout']);
}
2015-08-27 21:52:47 +00:00
if (localStorage['xen_style']) {
input_xen_style.checked = JSON.parse(localStorage['xen_style']);
}
2015-08-15 18:04:20 +00:00
})();
</script>
</html>