aboutsummaryrefslogtreecommitdiffstats
path: root/settings.html
blob: 004d3e11e453cd3657c2c0a9fbf5f5d4cd0c8073 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<html>
  <head>
    <title>Vimium Settings</title>
  </head>

  <script type="text/javascript">

  // Saves options to localStorage.
  function saveOptions() {
    var scrollStepSize = document.getElementById("scrollStepSize").value;
    localStorage["scrollStepSize"] = scrollStepSize;

    var defaultZoomLevel = document.getElementById("defaultZoomLevel").value;
    localStorage["defaultZoomLevel"] = defaultZoomLevel;

    // Update status to let user know options were saved.
    var status = document.getElementById("status");
    status.innerHTML = "Settings Saved.";
    setTimeout(function() { status.innerHTML = ""; }, 750);
  }

  // Restores select box state to saved value from localStorage.
  function restoreOptions() {
    // TODO(ilya): Create a single option list with defaults somewhere to share across various scripts. 
    var scrollStepSize = localStorage["scrollStepSize"] || 60;
    var defaultZoomLevel = localStorage["defaultZoomLevel"] || 100;

    document.getElementById("scrollStepSize").value = scrollStepSize;
    document.getElementById("defaultZoomLevel").value = defaultZoomLevel;
  }
  </script>

  <body onload="restoreOptions()">
    <h1>Vimium - Settings</h1>
    Scroll Step Size: <input id="scrollStepSize" type="text"> px (default: 60)
    <br>
    Scroll Step Size: <input id="defaultZoomLevel" type="text" value="100"> % (default: 100)

    <button onclick="saveOptions()">Save Settings</button>
    <div id="status"></div>
  </body>
</html>