index.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0" name="viewport">
  6. <title>IntuiClock Config</title>
  7. <link rel="stylesheet" href="css/slate.min.css">
  8. <script type="text/javascript" src="js/slate.min.js"></script>
  9. </head>
  10. <body>
  11. <form id="main-form">
  12. <div class="item-container">
  13. <div class="item-container-header">Features</div>
  14. <div class="item-container-content">
  15. <label class="item">
  16. Seconds Hand
  17. <input id="input-seconds-hand" type="checkbox" class="item-toggle" name="seconds-hand" checked>
  18. </label>
  19. <label class="item">
  20. Battery Indicator
  21. <input id="input-battery-indicator" type="checkbox" class="item-toggle" name="battery-indicator" checked>
  22. </label>
  23. <label class="item">
  24. Wide Window
  25. <input id="input-wide-layout" type="checkbox" class="item-toggle" name="wide-layout">
  26. </label>
  27. <label class="item">
  28. Date Format
  29. <select id="input-date-format" name="date-format" class="item-select">
  30. <option class="item-select-option" selected value="t">10 Aug 2015</option>
  31. <option class="item-select-option" value="d">10/08/2015</option>
  32. <option class="item-select-option" value="m">08/10/2015</option>
  33. </select>
  34. </label>
  35. </div>
  36. <div class="item-container-footer">Disable the seconds hand to reduce battery use.</div>
  37. </div>
  38. <div class="item-container">
  39. <div class="button-container">
  40. <input id="button-submit" type="button" class="item-button" value="SAVE">
  41. </div>
  42. </div>
  43. </form>
  44. </body>
  45. <script>
  46. function getConfigData() {
  47. var input_seconds_hand = document.getElementById('input-seconds-hand'),
  48. input_battery_indicator = document.getElementById('input-battery-indicator'),
  49. input_date_format = document.getElementById('input-date-format'),
  50. input_wide_layout = document.getElementById('input-wide-layout');
  51. var options = {
  52. 'seconds_hand': input_seconds_hand.checked,
  53. 'battery_indicator': input_battery_indicator.checked,
  54. 'date_format': input_date_format.value,
  55. 'wide_layout': input_wide_layout.checked
  56. };
  57. // Save for next launch
  58. localStorage['seconds_hand'] = options['seconds_hand'];
  59. localStorage['battery_indicator'] = options['battery_indicator'];
  60. localStorage['date_format'] = options['date_format'];
  61. localStorage['wide_layout'] = options['wide_layout'];
  62. console.log('Got options: ' + JSON.stringify(options));
  63. return options;
  64. }
  65. function getQueryParam(variable, defaultValue) {
  66. var query = location.search.substring(1),
  67. vars = query.split('&');
  68. for (var i = 0; i < vars.length; i++) {
  69. var pair = vars[i].split('=');
  70. if (pair[0] === variable) {
  71. return decodeURIComponent(pair[1]);
  72. }
  73. }
  74. return defaultValue || false;
  75. }
  76. var button_submit = document.getElementById('button-submit');
  77. button_submit.addEventListener('click', function() {
  78. console.log('Submit');
  79. // Set the return URL depending on the runtime environment
  80. var return_to = getQueryParam('return_to', 'pebblejs://close#');
  81. document.location = return_to + encodeURIComponent(JSON.stringify(getConfigData()));
  82. });
  83. (function() {
  84. var input_seconds_hand = document.getElementById('input-seconds-hand'),
  85. input_battery_indicator = document.getElementById('input-battery-indicator'),
  86. input_date_format = document.getElementById('input-date-format'),
  87. input_wide_layout = document.getElementById('input-wide-layout');
  88. if (localStorage['seconds_hand']) {
  89. input_seconds_hand.checked = JSON.parse(localStorage['seconds_hand']);
  90. }
  91. if (localStorage['battery_indicator']) {
  92. input_battery_indicator.checked = JSON.parse(localStorage['battery_indicator']);
  93. }
  94. if (localStorage['date_format']) {
  95. input_date_format.value = localStorage['date_format'];
  96. }
  97. if (localStorage['wide_layout']) {
  98. input_wide_layout.checked = JSON.parse(localStorage['wide_layout']);
  99. }
  100. })();
  101. </script>
  102. </html>