Permalink
Browse files

manifest_version2対応

  • Loading branch information...
dameninngenn committed Aug 9, 2012
1 parent 9757e10 commit f5e61f4e082728208abb487a5b5233bac1e58e66
Showing with 107 additions and 100 deletions.
  1. +1 −1 src/background.js
  2. +3 −2 src/manifest.json
  3. +3 −85 src/options.html
  4. +88 −0 src/options.js
  5. +1 −12 src/popup.html
  6. +11 −0 src/popup.js
View
@@ -1,4 +1,4 @@
-chrome.self.onConnect.addListener(function(port,name) {
+chrome.extension.onConnect.addListener(function(port,name) {
port.onMessage.addListener(function(info,con){
sendUrl(info,con);
});
View
@@ -1,10 +1,11 @@
{
+ "manifest_version": 2,
"name": "Labrys",
- "version": "0.1.0",
+ "version": "0.1.1",
"description": "url history watcher",
"browser_action": {
"default_icon": "labrys128.png",
- "popup": "popup.html"
+ "default_popup": "popup.html"
},
"icons": {
"128": "labrys128.png",
View
@@ -9,90 +9,7 @@
overflow-x:hidden;
}
</style>
-<script type="text/javascript">
- function save_options() {
- set_local_storage_checkbox("on_basic_auth");
- set_local_storage_value("username");
- set_local_storage_value("password");
- set_local_storage_value("api_url");
- set_local_storage_type("type");
-
- var status = document.getElementById("status");
- status.innerHTML = "Options Saved.";
- setTimeout(function() {
- status.innerHTML = "";
- }, 750);
- }
-
- function restore_options() {
- restore_option_checkbox("on_basic_auth");
- restore_option_value("username");
- restore_option_value("password");
- restore_option_value("api_url");
- restore_option_selectbox("type");
- }
-
- function set_local_storage_checkbox(name) {
- var e = document.getElementById(name);
- if( e.checked == true ) {
- localStorage[name] = 1;
- } else {
- localStorage[name] = 0;
- }
- }
-
- function set_local_storage_value(name) {
- var e = document.getElementById(name);
- if( e.value ) {
- localStorage[name] = e.value;
- } else {
- localStorage[name] = '';
- }
- }
-
- function set_local_storage_type(name) {
- var e = document.getElementById(name);
- var value = e.children[e.selectedIndex].value;
- if( value ) {
- localStorage[name] = value;
- } else {
- localStorage[name] = 0;
- }
- }
-
- function restore_option_checkbox(name) {
- var value = localStorage[name];
- var e = document.getElementById(name);
- if( value == 1 ) {
- e.checked = true;
- } else {
- e.checked = false;
- }
- }
-
- function restore_option_value(name) {
- var value = localStorage[name];
- var e = document.getElementById(name);
- if( value ) {
- e.value = value;
- } else {
- e.value = '';
- }
- }
-
- function restore_option_selectbox(name) {
- var value = localStorage[name];
- var e = document.getElementById(name);
- for (var i = 0; i < e.children.length; i++) {
- var child = e.children[i];
- if (child.value == value) {
- child.selected = "true";
- break;
- }
- }
- }
-</script>
-<body onload="restore_options()">
+<body>
api_url: <input id="api_url" type="text" /><br />
type:
<select id="type">
@@ -106,8 +23,9 @@
username: <input id="username" type="text" /><br />
password: <input id="password" type="password" /><br />
<br>
-<button onclick="save_options()">Save</button>
+<button id="save_btn">Save</button>
<div id="status"></div>
+<script type="text/javascript" src="options.js"></script>
</body>
</html>
View
@@ -0,0 +1,88 @@
+restore_options();
+var btn = document.getElementById("save_btn");
+var btn_listener = function(e){
+ save_options();
+};
+btn.addEventListener('click', btn_listener, false);
+
+function save_options() {
+ set_local_storage_checkbox("on_basic_auth");
+ set_local_storage_value("username");
+ set_local_storage_value("password");
+ set_local_storage_value("api_url");
+ set_local_storage_type("type");
+
+ var status = document.getElementById("status");
+ status.innerHTML = "Options Saved.";
+ setTimeout(function() {
+ status.innerHTML = "";
+ }, 750);
+}
+
+function restore_options() {
+ restore_option_checkbox("on_basic_auth");
+ restore_option_value("username");
+ restore_option_value("password");
+ restore_option_value("api_url");
+ restore_option_selectbox("type");
+}
+
+function set_local_storage_checkbox(name) {
+ var e = document.getElementById(name);
+ if( e.checked == true ) {
+ localStorage[name] = 1;
+ } else {
+ localStorage[name] = 0;
+ }
+}
+
+function set_local_storage_value(name) {
+ var e = document.getElementById(name);
+ if( e.value ) {
+ localStorage[name] = e.value;
+ } else {
+ localStorage[name] = '';
+ }
+}
+
+function set_local_storage_type(name) {
+ var e = document.getElementById(name);
+ var value = e.children[e.selectedIndex].value;
+ if( value ) {
+ localStorage[name] = value;
+ } else {
+ localStorage[name] = 0;
+ }
+}
+
+function restore_option_checkbox(name) {
+ var value = localStorage[name];
+ var e = document.getElementById(name);
+ if( value == 1 ) {
+ e.checked = true;
+ } else {
+ e.checked = false;
+ }
+}
+
+function restore_option_value(name) {
+ var value = localStorage[name];
+ var e = document.getElementById(name);
+ if( value ) {
+ e.value = value;
+ } else {
+ e.value = '';
+ }
+}
+
+function restore_option_selectbox(name) {
+ var value = localStorage[name];
+ var e = document.getElementById(name);
+ for (var i = 0; i < e.children.length; i++) {
+ var child = e.children[i];
+ if (child.value == value) {
+ child.selected = "true";
+ break;
+ }
+ }
+}
View
@@ -10,16 +10,5 @@ <h1>Labrys</h1>
type:
<p id="type"></p>
<a href="options.html">options</a>
+<script type="text/javascript" src="popup.js"></script>
-<script>
- var s_api_url = localStorage["api_url"];
- var s_type = localStorage["type"];
- if( s_api_url ){
- var api_url = document.getElementById("api_url");
- api_url.innerHTML = s_api_url;
- }
- if( s_type ){
- var type = document.getElementById("type");
- type.innerHTML = s_type;
- }
-</script>
View
@@ -0,0 +1,11 @@
+var s_api_url = localStorage["api_url"];
+var s_type = localStorage["type"];
+if( s_api_url ){
+ var api_url = document.getElementById("api_url");
+ api_url.innerHTML = s_api_url;
+}
+if( s_type ){
+ var type = document.getElementById("type");
+ type.innerHTML = s_type;
+}
+

0 comments on commit f5e61f4

Please sign in to comment.