From d5664f4c0e48e6666259b4d36921fcddc71dda39 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Fri, 16 Jan 2015 23:00:25 -0500 Subject: [PATCH] options: switch to new chrome options page This allows us to drop the external chrome-bootstrap project. --- .gitmodules | 4 ---- chrome-bootstrap | 1 - manifest.files | 2 -- manifest.json | 9 +++++--- options.html | 55 ++++++++++-------------------------------------- options.js | 10 ++++++++- popup.js | 14 +++++++++--- 7 files changed, 37 insertions(+), 58 deletions(-) delete mode 100644 .gitmodules delete mode 160000 chrome-bootstrap diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 0d3af8c..0000000 --- a/.gitmodules +++ /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 index 419698e..0000000 --- a/chrome-bootstrap +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 419698ec6fe922487d2fe3f11c92fd1c8ffbd8a6 diff --git a/manifest.files b/manifest.files index 23625e9..497bb5a 100644 --- a/manifest.files +++ b/manifest.files @@ -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 diff --git a/manifest.json b/manifest.json index 7161ad0..03cd502 100644 --- a/manifest.json +++ b/manifest.json @@ -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" @@ -15,7 +15,10 @@ "default_title": "Control Your Switch", "default_popup": "popup.html" }, - "options_page": "options.html", + "options_ui": { + "page": "options.html", + "chrome_style": true + }, "permissions": [ "storage" ], diff --git a/options.html b/options.html index f7f3a13..f9cac46 100644 --- a/options.html +++ b/options.html @@ -4,63 +4,30 @@ Web Power Switch Manager Options - + - -
- - - -
-
-
-

Options

-
-
- -
-

Connection

- + - + - + - +
URL:URL:
User:User:
Pass:Pass:
-
- -
-

Save Settings

-

- -

-
You must hit "Save" the first time to authorize the client
-
- -
-
-
- -
+

+ +

+

+You must hit "Save" the first time to authorize the client. +

diff --git a/options.js b/options.js index b017cd8..bda3038 100644 --- a/options.js +++ b/options.js @@ -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 = ' '; }, 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; }); }); }; diff --git a/popup.js b/popup.js index 742962d..22c3160 100644 --- 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;
check your ' + - 'settings'); + setstatus( + 'Could not connect;
check your ' + + 'settings' + ); + 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;
please visit the ' + - 'settings page' + + 'settings page' + '
to grant access.
' + '
' ); + 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 + '/*']}); -- 2.39.2