Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions chrome/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand All @@ -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)
Expand Down Expand Up @@ -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"
});
}

Expand Down
Binary file added chrome/logo16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added chrome/logo_disabled16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
70 changes: 70 additions & 0 deletions chrome/popup.html
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
</style>
</head>
<body>
Expand All @@ -58,6 +127,7 @@
<form action="">
监听地址: <input type="input" id="address" value="ws://localhost:1229" /> <br />
Client_ID: <input type="input" id="client_id" value="" /> <br />
开启:<br/><input id="open" class="mui-switch mui-switch-anim" style="position: relative;left:40px;" type="checkbox"><br />
<button type="button" id="save">保 存</button>
<div class="status">
状态:<span id="status">正在连接...</span>
Expand Down
6 changes: 6 additions & 0 deletions chrome/popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -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='';
Expand Down Expand Up @@ -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();
}