diff --git a/chrome/background.js b/chrome/background.js index d07afa8..f0b5db3 100644 --- a/chrome/background.js +++ b/chrome/background.js @@ -14,6 +14,7 @@ function ws_init() } var address=localStorage.getItem('address'); var client_id=localStorage.getItem('client_id'); + var open=localStorage.getItem('open'); if(!address) { address="ws://localhost:1229"; @@ -23,6 +24,13 @@ function ws_init() //client_id作为地址 address+='/'+client_id; } + + if (open == 'false') { + disable_icon(); + localStorage.setItem('status','close'); + return false; + }; + websocket=new WebSocket(address); websocket.onerror=function(msg) @@ -144,13 +152,13 @@ function ws_restart() function enable_icon() { chrome.browserAction.setIcon({ - path: "logo.png" + path: "logo16.png" }); } function disable_icon() { chrome.browserAction.setIcon({ - path: "logo_disabled.png" + path: "logo_disabled16.png" }); } diff --git a/chrome/logo16.png b/chrome/logo16.png new file mode 100644 index 0000000..65d2869 Binary files /dev/null and b/chrome/logo16.png differ diff --git a/chrome/logo_disabled16.png b/chrome/logo_disabled16.png new file mode 100644 index 0000000..087c815 Binary files /dev/null and b/chrome/logo_disabled16.png differ diff --git a/chrome/popup.html b/chrome/popup.html index 822a533..8933e83 100644 --- a/chrome/popup.html +++ b/chrome/popup.html @@ -50,6 +50,75 @@ input { width:100%; } + .mui-switch { + width: 52px; + height: 31px; + position: relative; + border: 1px solid #dfdfdf; + background-color: #fdfdfd; + box-shadow: #dfdfdf 0 0 0 0 inset; + border-radius: 20px; + border-top-left-radius: 20px; + border-top-right-radius: 20px; + border-bottom-left-radius: 20px; + border-bottom-right-radius: 20px; + background-clip: content-box; + display: inline-block; + -webkit-appearance: none; + user-select: none; + outline: none; + } + .mui-switch:before { + content:''; + width: 29px; + height: 29px; + position: absolute; + top: 0px; + left: 0; + border-radius: 20px; + border-top-left-radius: 20px; + border-top-right-radius: 20px; + border-bottom-left-radius: 20px; + border-bottom-right-radius: 20px; + background-color: #fff; + box-shadow: 0 1px 3px rgba(0, 0, 0, 0.4); + } + .mui-switch:checked { + border-color: #64bd63; + box-shadow: #64bd63 0 0 0 16px inset; + background-color: #64bd63; + } + .mui-switch:checked:before { + left: 21px; + } + .mui-switch.mui-switch-animbg { + transition: background-color ease 0.4s; + } + .mui-switch.mui-switch-animbg:before { + transition: left 0.3s; + } + .mui-switch.mui-switch-animbg:checked { + box-shadow: #dfdfdf 0 0 0 0 inset; + background-color: #64bd63; + transition: border-color 0.4s, background-color ease 0.4s; + } + .mui-switch.mui-switch-animbg:checked:before { + transition: left 0.3s; + } + .mui-switch.mui-switch-anim { + transition: border cubic-bezier(0, 0, 0, 1) 0.4s, box-shadow cubic-bezier(0, 0, 0, 1) 0.4s; + } + .mui-switch.mui-switch-anim:before { + transition: left 0.3s; + } + .mui-switch.mui-switch-anim:checked { + box-shadow: #64bd63 0 0 0 16px inset; + background-color: #64bd63; + transition: border ease 0.4s, box-shadow ease 0.4s, background-color ease 1.2s; + } + .mui-switch.mui-switch-anim:checked:before { + transition: left 0.3s; + } @@ -58,6 +127,7 @@
监听地址:
Client_ID:
+ 开启:

状态:正在连接... diff --git a/chrome/popup.js b/chrome/popup.js index e4c7780..31d1af2 100644 --- a/chrome/popup.js +++ b/chrome/popup.js @@ -14,7 +14,12 @@ function init() { document.getElementById('client_id').value=localStorage.getItem('client_id'); } + if(localStorage.getItem('open')) + { + document.getElementById('open').checked=localStorage.getItem('open') == 'false' ? false:true; + } var status=localStorage.getItem('status'); + if(status) { var text=''; @@ -44,6 +49,7 @@ function save() { localStorage.setItem('address',document.getElementById('address').value); localStorage.setItem('client_id',document.getElementById('client_id').value); + localStorage.setItem('open',document.getElementById('open').checked); chrome.extension.getBackgroundPage().ws_restart(); window.close(); }