Skip to content

Commit

Permalink
fix: fix "AriaNg's RPC config lost after clear browser history"
Browse files Browse the repository at this point in the history
closes #4
  • Loading branch information
RossWang committed Nov 17, 2017
1 parent 3ed829f commit b5e8dd8
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 15 deletions.
10 changes: 10 additions & 0 deletions App/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,16 @@
"description": ""
},

"OP_autoSet": {
"message": "AriaNg Auto Set",
"description": ""
},

"OPN_autoSet": {
"message": "Set AriaNg automatically when the user click 'details'",
"description": ""
},

"OP_winWidth": {
"message": "Download Panel width offset",
"description": ""
Expand Down
10 changes: 10 additions & 0 deletions App/_locales/zh_CN/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@
"message": "按下下载按钮后自动启动 Aria2",
"description": ""
},

"OP_autoSet": {
"message": "自动设置 AriaNg",
"description": ""
},

"OPN_autoSet": {
"message": "按下详细按钮后自动设置 AriaNg",
"description": ""
},

"OP_winWidth": {
"message": "下载窗口宽度改变量",
Expand Down
10 changes: 10 additions & 0 deletions App/_locales/zh_TW/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,16 @@
"description": ""
},

"OP_autoSet": {
"message": "自動設定 AriaNg",
"description": ""
},

"OPN_autoSet": {
"message": "按下詳細按鈕後自動設定 AriaNg",
"description": ""
},

"OP_winWidth": {
"message": "下載視窗寬度改變量",
"description": ""
Expand Down
1 change: 1 addition & 0 deletions App/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ config.command = {
aggressive: false,
windowLoc: false,
auto: true,
autoSet: true,
};
}
};
1 change: 1 addition & 0 deletions App/data/action/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@
</div>
</div>
<!-- <script src="gwd-init-code.js"></script> -->
<script src="../../config.js"></script>
<script src="index.js"></script>


Expand Down
23 changes: 16 additions & 7 deletions App/data/action/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,24 @@ function detail() {
browser.storage.local.get("initialize", item => {
if (!item.initialize || (item.initialize == undefined)) {
browser.runtime.openOptionsPage();
browser.notifications.create({
browser.notifications.create({
type: 'basic',
iconUrl: '../../data/icons/48.png',
title: "Aria2 Integration",
message: "you need to set(save) the config first"
iconUrl: '/data/icons/48.png',
title: browser.i18n.getMessage("extensionName"),
message: message.message || message
});
} else {
browser.tabs.create({
url: "../../data/ariang/index.html"
}
else {
browser.storage.local.get(config.command.guess, function(item) {
var ariangUrl = "../../data/ariang/index.html"
if (item.autoSet) {
ariangUrl += "#!/settings/rpc/set/";
ariangUrl += (item.protocol + "/" + item.host + "/" + item.port + "/" +
item.interf + "/" + btoa(item.token));
}
browser.tabs.create({
url: ariangUrl
});
});
}
});
Expand Down
11 changes: 11 additions & 0 deletions App/data/options/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@
<td></td>
<td data-message="OPN_auto" class="note">Start Aria2 automatically when the download start</td>
</tr>
<tr>
<td></td>
<td>
<input id="autoSet" style="margin-left: 0px; margin-top: 5px;" type="checkbox">
<label data-message="OP_autoSet" for="auto">AriaNg Auto Set</label>
</td>
</tr>
<tr>
<td></td>
<td data-message="OPN_autoSet" class="note">Set AriaNg automatically when the user click "details"</td>
</tr>
<tr>
<td></td>
<td>
Expand Down
9 changes: 3 additions & 6 deletions App/data/options/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ function save() {
const aggresive = document.getElementById('aggre').checked;
const windowLoc = document.getElementById('winLoc').checked;
const auto = document.getElementById('auto').checked;
const autoSet = document.getElementById('autoSet').checked;
const dpHeight = document.getElementById('dpHeight').value;
const dpWidth = document.getElementById('dpWidth').value;
if (!windowLoc){
Expand All @@ -40,19 +41,14 @@ function save() {
aggresive,
windowLoc,
auto,
autoSet,
dpHeight,
dpWidth
}, () => {
const status = document.getElementById('status');
status.textContent = browser.i18n.getMessage("OP_saveComplete");
setTimeout(() => {
status.textContent = '';
var ariangUrl = "../../data/ariang/index.html#!/settings/rpc/set/"
ariangUrl += (protocol + "/" + host + "/" + port + "/" + interf + "/" +
btoa(token));
browser.tabs.create({
url: ariangUrl
});
}, 750);
browser.storage.local.set({
initialize: true
Expand All @@ -77,6 +73,7 @@ function restore() {
document.getElementById('aggre').checked = prefs.aggressive;
document.getElementById('winLoc').checked = prefs.windowLoc;
document.getElementById('auto').checked = prefs.auto;
document.getElementById('autoSet').checked = prefs.autoSet;
});
browser.storage.local.get(['dpWidth', 'dpHeight'], prefs => {
document.getElementById('dpWidth').value = prefs.dpWidth;
Expand Down
6 changes: 4 additions & 2 deletions App/manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "__MSG_extensionName__",
"description": "__MSG_extensionDescription__",
"version": "0.2.0",
"version": "0.2.1",
"default_locale": "en",
"manifest_version": 2,
"permissions": [
Expand All @@ -18,7 +18,9 @@
"background": {
"scripts": [
"config.js",
"common.js"
"common.js",
"/lib/tool.js",
"/lib/polygoat.js"
]
},
"browser_action": {
Expand Down

0 comments on commit b5e8dd8

Please sign in to comment.