]> git.wh0rd.org Git - chrome-ext/web-power-switch.git/commitdiff
options: switch to new chrome options page
authorMike Frysinger <vapier@gentoo.org>
Sat, 17 Jan 2015 04:00:25 +0000 (23:00 -0500)
committerMike Frysinger <vapier@gentoo.org>
Sat, 17 Jan 2015 04:00:25 +0000 (23:00 -0500)
This allows us to drop the external chrome-bootstrap project.

.gitmodules [deleted file]
chrome-bootstrap [deleted submodule]
manifest.files
manifest.json
options.html
options.js
popup.js

diff --git a/.gitmodules b/.gitmodules
deleted file mode 100644 (file)
index 0d3af8c..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-[submodule "chrome-bootstrap"]
-       path = chrome-bootstrap
-       url = https://github.com/roykolak/chrome-bootstrap.git
-       branch = tags/v1.2.1
diff --git a/chrome-bootstrap b/chrome-bootstrap
deleted file mode 160000 (submodule)
index 419698e..0000000
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 419698ec6fe922487d2fe3f11c92fd1c8ffbd8a6
index 23625e93fb9a23fa7681b20ab7a3c0d4613c91ce..497bb5a121d6b07105d5ad8cba19ec281ff66bdb 100644 (file)
@@ -1,8 +1,6 @@
-chrome-bootstrap/chrome-bootstrap.css
 images/outlet-128x128.png
 images/outlet-19x19.png
 images/outlet-38x38.png
-images/outlet.svg
 common.js
 options.html
 options.js
index 7161ad0dbf8c515c62aad6e04f3d57ce3b40c6ae..03cd502efeb80fc0eda8b4ceb2ae7bce228cb8db 100644 (file)
@@ -1,8 +1,8 @@
 {
   "manifest_version": 2,
-  "minimum_chrome_version": "22",
+  "minimum_chrome_version": "41",
   "name": "Web Power Switch Manager",
-  "version": "2.3",
+  "version": "3.0",
   "description": "Quickly control Web Power Switches",
   "icons": {
     "128": "images/outlet-128x128.png"
     "default_title": "Control Your Switch",
     "default_popup": "popup.html"
   },
-  "options_page": "options.html",
+  "options_ui": {
+    "page": "options.html",
+    "chrome_style": true
+  },
   "permissions": [
     "storage"
   ],
index f7f3a13f5c04c36058882a92b0b01f81726d6605..f9cac46f4ceeefcbcceaab0aa20421d59fd37997 100644 (file)
@@ -4,63 +4,30 @@
 
 <head>
 <title>Web Power Switch Manager Options</title>
-<link rel="stylesheet" type="text/css" href="chrome-bootstrap/chrome-bootstrap.css" />
 <script src='common.js'></script>
 <script src='options.js'></script>
+<style>body { padding: 0px; }</style>
 </head>
 
-<body class="chrome-bootstrap">
-  <div class="frame">
-
-    <div class="navigation">
-      <h1><a href="#">Web Power Switch</a></h1>
-      <ul class="menu">
-        <li class="selected">
-          <a href="#options">Options</a>
-        </li>
-      </ul>
-      <ul>
-        <li>&nbsp;<img src='images/outlet-128x128.png'></li>
-      </ul>
-    </div>
-
-    <div class="mainview view">
-      <div id="options" class="selected">
-        <header>
-          <h1>Options</h1>
-        </header>
-        <div class="content">
-
-<section>
- <h3>Connection</h3>
-
+<body>
 <table>
 <tr>
- <td>URL:</td><td><input type='text' id='url' size=50></td>
+ <td>URL:</td><td><input type='text' id='url' size=40></td>
 </tr>
 <tr>
- <td>User:</td><td><input type='text' id='user' size=50></td>
+ <td>User:</td><td><input type='text' id='user' size=40></td>
 </tr>
 <tr>
- <td>Pass:</td><td><input type='text' id='pass' size=50></td>
+ <td>Pass:</td><td><input type='text' id='pass' size=40></td>
 </tr>
 </table>
 
-</section>
-
-<div>
- <h3>Save Settings</h3>
- <p>
-  <input type='button' id='save' value='Save'></td>
- </p>
- <div id='msg'>You must hit "Save" the first time to authorize the client</div>
-</div>
-
-        </div>
-      </div>
-    </div>
-
-  </div>
+<p style='text-align: center'>
+<input type='button' id='save' value='Save'>
+</p>
+<p style='text-align: center' id='msg'>
+You must hit "Save" the first time to authorize the client.
+</p>
 
 </body>
 </html>
index b017cd8087c240d7aaf1d1f4e7f0d21f66fca40e..bda30386299867b902bf547378d8b4e2307fc4d3 100644 (file)
@@ -37,10 +37,17 @@ function update_settings() {
        });
 
        msg.timeout = setTimeout(function() {
-               msg.innerText = '';
+               // Can't leave this blank or Chrome will resize the options page.
+               msg.innerHTML = '&nbsp;';
        }, 5000);
 }
 
+function keydown(e) {
+       if (e.key == 'Enter') {
+               update_settings();
+       }
+}
+
 window.onload = function() {
        storage.get(settings_keys, function(settings) {
                var field = document.getElementById('save');
@@ -49,6 +56,7 @@ window.onload = function() {
                settings_keys.forEach(function(key) {
                        var field = document.getElementById(key);
                        field.value = settings[key] || settings_defaults[key];
+                       field.onkeydown = keydown;
                });
        });
 };
index 742962dd074def469fca2bed4e2743b8b7176888..22c31604dccc3be9d89a189555ed4f36a887c637 100644 (file)
--- a/popup.js
+++ b/popup.js
@@ -14,8 +14,11 @@ function fetchpage(url, callback) {
                                        callback(xhr, state);
                                } else {
                                        xhr.setstatus = true;
-                                       setstatus('Could not connect;<br>check your ' +
-                                                 '<a href="' + chrome.extension.getURL('options.html') + '" target=_blank>settings</a>');
+                                       setstatus(
+                                               'Could not connect;<br>check your ' +
+                                               '<a id="open-settings" href="">settings</a>'
+                                       );
+                                       document.getElementById('open-settings').onclick = open_settings_page;
                                        console.log('connect error', state);
                                }
                        }
@@ -161,6 +164,10 @@ function setstatus(msg) {
        status.style.position   = msg ? '' : 'absolute';
 }
 
+function open_settings_page() {
+       chrome.runtime.openOptionsPage();
+}
+
 document.addEventListener('DOMContentLoaded', function() {
        storage.get(settings_keys, function(settings) {
                url_base = settings['url'] || settings_defaults['url'];
@@ -174,10 +181,11 @@ document.addEventListener('DOMContentLoaded', function() {
                        } else {
                                setstatus(
                                        'Missing permissions;<br>please visit the ' +
-                                       '<a href="' + chrome.extension.getURL('options.html') + '" target=_blank>settings page</a>' +
+                                       '<a id="open-settings" href="">settings page</a>' +
                                        '<br>to grant access.<br>' +
                                        '<center><input id=retry type=submit value=Retry></center>'
                                );
+                               document.getElementById('open-settings').onclick = open_settings_page;
                                // Work around http://crbug.com/125706.
                                document.getElementById('retry').onclick = function() {
                                        chrome.permissions.request({origins: [url_base + '/*']});