diff --git a/App/_locales/en/messages.json b/App/_locales/en/messages.json index 44f66af..8a0ef61 100644 --- a/App/_locales/en/messages.json +++ b/App/_locales/en/messages.json @@ -90,7 +90,7 @@ "UI_save": { "message": "Save", - "description": "for download pannel" + "description": "for download panel" }, "UI_saveas": { @@ -103,6 +103,11 @@ "description": "" }, + "UI_adv": { + "message": "Advanced", + "description": "" + }, + "UI_fileName": { "message": "File Name", "description": "" diff --git a/App/_locales/zh_CN/messages.json b/App/_locales/zh_CN/messages.json index 268e3ea..344606c 100644 --- a/App/_locales/zh_CN/messages.json +++ b/App/_locales/zh_CN/messages.json @@ -103,6 +103,12 @@ "description": "" }, + + "UI_adv": { + "message": "高级", + "description": "" + }, + "UI_fileName": { "message": "文件名", "description": "" diff --git a/App/_locales/zh_TW/messages.json b/App/_locales/zh_TW/messages.json index a22648d..64ac825 100644 --- a/App/_locales/zh_TW/messages.json +++ b/App/_locales/zh_TW/messages.json @@ -103,6 +103,12 @@ "description": "" }, + + "UI_adv": { + "message": "進階", + "description": "" + }, + "UI_fileName": { "message": "檔案名稱", "description": "" diff --git a/App/common.js b/App/common.js index b4fee0b..1339d90 100644 --- a/App/common.js +++ b/App/common.js @@ -10,7 +10,7 @@ var fileTypeFilterB = ""; var urlFilterB = ""; var mon; -function sendTo(url, fileName, filePath, header) { +function sendTo(url, fileName, filePath, header, server) { // check whether config is set browser.storage.local.get("initialize", item => { if (!item.initialize || (item.initialize == undefined)) { @@ -18,49 +18,70 @@ function sendTo(url, fileName, filePath, header) { notify(browser.i18n.getMessage("error_setConfig")); } else { - browser.storage.local.get(config.command.guess, function(item) { - var secure = false; - if (item.protocol.toLowerCase == "https" || item.protocol.toLowerCase == "wss") - secure = true; - var options = { - host: item.host, - port: item.port, - secure: secure, - secret: item.token, - path: "/" + item.interf - }; - - var aria2 = new Aria2(options); - // check whether aria2 is runnning - isRunning(item, aria2); - - // Send TO Aria2 - filePath = filePath.replace(/\\/g, '\\\\'); - item.path = item.path.replace(/\\/g, '\\\\'); - var params = {}; - if (header != "[]") - params.header = header; - params.out = fileName; - if (filePath != "") { - // file path from download panel - params.dir = filePath; - } - else if (item.path != "") { - // file path from setting - params.dir = item.path; - } - if (item.protocol.toLowerCase() == "ws" || item.protocol.toLowerCase() == "wss") { - aria2.open().then( - function (res) { - aria2.addUri([url], params).then( - function (res) { - monitor(options); - notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); - aria2.close(); - }, - function (err) { - // retry again after 3 seconds - setTimeout( () => { + if (server == "1") { + browser.storage.local.get(config.command.guess, function(item) { + var secure = false; + if (item.protocol.toLowerCase == "https" || item.protocol.toLowerCase == "wss") + secure = true; + var options = { + host: item.host, + port: item.port, + secure: secure, + secret: item.token, + path: "/" + item.interf + }; + + var aria2 = new Aria2(options); + // check whether aria2 is runnning + isRunning(item, aria2); + + // Send TO Aria2 + filePath = filePath.replace(/\\/g, '\\\\'); + item.path = item.path.replace(/\\/g, '\\\\'); + var params = {}; + if (header != "[]") + params.header = header; + params.out = fileName; + if (filePath != "") { + // file path from download panel + params.dir = filePath; + } + else if (item.path != "") { + // file path from setting + params.dir = item.path; + } + if (item.protocol.toLowerCase() == "ws" || item.protocol.toLowerCase() == "wss") { + aria2.open().then( + function (res) { + aria2.addUri([url], params).then( + function (res) { + monitor(options); + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + aria2.close(); + }, + function (err) { + // retry again after 3 seconds + setTimeout( () => { + aria2.addUri([url], params).then( + function (res) { + monitor(options); + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + aria2.close(); + }, + function (err) { + console.log('Error', err); + notify(browser.i18n.getMessage("error_connect")); + aria2.close(); + } + ); + }, 3000); + } + ); + }, + function (err) { + // retry again after 3 seconds + setTimeout( () => { + aria2.open().then( () => { aria2.addUri([url], params).then( function (res) { monitor(options); @@ -73,57 +94,244 @@ function sendTo(url, fileName, filePath, header) { aria2.close(); } ); - }, 3000); - } - ); - }, - function (err) { - // retry again after 3 seconds - setTimeout( () => { - aria2.open().then( () => { + }, (err) => { + console.log('Error', err); + notify(browser.i18n.getMessage("error_connect")); + }); + }, 3000); + } + ); + } + else { + aria2.addUri([url], params).then( + function (res) { + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + }, + function (err) { + // retry again after 3 seconds + setTimeout( () => { aria2.addUri([url], params).then( function (res) { - monitor(options); notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); - aria2.close(); }, function (err) { console.log('Error', err); notify(browser.i18n.getMessage("error_connect")); - aria2.close(); } ); - }, (err) => { - console.log('Error', err); - notify(browser.i18n.getMessage("error_connect")); - }); - }, 3000); - } - ); - } - else { - aria2.addUri([url], params).then( - function (res) { - notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); - }, - function (err) { - // retry again after 3 seconds - setTimeout( () => { + }, 3000); + } + ); + } + console.log("default", url, params); + }); + } + else if(server == "2") { + browser.storage.local.get(config.command.s2, function(item) { + var secure = false; + if (item.protocol2.toLowerCase == "https" || item.protocol2.toLowerCase == "wss") + secure = true; + var options = { + host: item.host2, + port: item.port2, + secure: secure, + secret: item.token2, + path: "/" + item.interf2 + }; + + var aria2 = new Aria2(options); + + // Send TO Aria2 + filePath = filePath.replace(/\\/g, '\\\\'); + item.path2 = item.path2.replace(/\\/g, '\\\\'); + var params = {}; + if (header != "[]") + params.header = header; + params.out = fileName; + if (filePath != "") { + // file path from download panel + params.dir = filePath; + } + else if (item.path2 != "") { + // file path from setting + params.dir = item.path2; + } + if (item.protocol2.toLowerCase() == "ws" || item.protocol2.toLowerCase() == "wss") { + aria2.open().then( + function (res) { aria2.addUri([url], params).then( function (res) { notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + aria2.close(); }, function (err) { + // retry again after 3 seconds + setTimeout( () => { + aria2.addUri([url], params).then( + function (res) { + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + aria2.close(); + }, + function (err) { + console.log('Error', err); + notify(browser.i18n.getMessage("error_connect")); + aria2.close(); + } + ); + }, 3000); + } + ); + }, + function (err) { + // retry again after 3 seconds + setTimeout( () => { + aria2.open().then( () => { + aria2.addUri([url], params).then( + function (res) { + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + aria2.close(); + }, + function (err) { + console.log('Error', err); + notify(browser.i18n.getMessage("error_connect")); + aria2.close(); + } + ); + }, (err) => { console.log('Error', err); notify(browser.i18n.getMessage("error_connect")); + }); + }, 3000); + } + ); + } + else { + aria2.addUri([url], params).then( + function (res) { + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + }, + function (err) { + // retry again after 3 seconds + setTimeout( () => { + aria2.addUri([url], params).then( + function (res) { + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + }, + function (err) { + console.log('Error', err); + notify(browser.i18n.getMessage("error_connect")); + } + ); + }, 3000); + } + ); + } + console.log("rpc2", url, params); + }); + } + else if(server == "3") { + browser.storage.local.get(config.command.s3, function(item) { + var secure = false; + if (item.protocol3.toLowerCase == "https" || item.protocol3.toLowerCase == "wss") + secure = true; + var options = { + host: item.host3, + port: item.port3, + secure: secure, + secret: item.token3, + path: "/" + item.interf3 + }; + + var aria2 = new Aria2(options); + + // Send TO Aria2 + filePath = filePath.replace(/\\/g, '\\\\'); + item.path3 = item.path3.replace(/\\/g, '\\\\'); + var params = {}; + if (header != "[]") + params.header = header; + params.out = fileName; + if (filePath != "") { + // file path from download panel + params.dir = filePath; + } + else if (item.path3 != "") { + // file path from setting + params.dir = item.path3; + } + if (item.protocol3.toLowerCase() == "ws" || item.protocol3.toLowerCase() == "wss") { + aria2.open().then( + function (res) { + aria2.addUri([url], params).then( + function (res) { + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + aria2.close(); + }, + function (err) { + // retry again after 3 seconds + setTimeout( () => { + aria2.addUri([url], params).then( + function (res) { + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + aria2.close(); + }, + function (err) { + console.log('Error', err); + notify(browser.i18n.getMessage("error_connect")); + aria2.close(); + } + ); + }, 3000); } ); - }, 3000); - } - ); - } - console.log(url, params); - }); + }, + function (err) { + // retry again after 3 seconds + setTimeout( () => { + aria2.open().then( () => { + aria2.addUri([url], params).then( + function (res) { + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + aria2.close(); + }, + function (err) { + console.log('Error', err); + notify(browser.i18n.getMessage("error_connect")); + aria2.close(); + } + ); + }, (err) => { + console.log('Error', err); + notify(browser.i18n.getMessage("error_connect")); + }); + }, 3000); + } + ); + } + else { + aria2.addUri([url], params).then( + function (res) { + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + }, + function (err) { + // retry again after 3 seconds + setTimeout( () => { + aria2.addUri([url], params).then( + function (res) { + notify(browser.i18n.getMessage("success_connect", fileName) + "\n\n" + url); + }, + function (err) { + console.log('Error', err); + notify(browser.i18n.getMessage("error_connect")); + } + ); + }, 3000); + } + ); + } + console.log("rpc3", url, params); + }); + } } }); } @@ -190,7 +398,7 @@ function handleMessage(request, sender, sendResponse) { }); break; case "download": - sendTo(request.url, request.fileName, request.filePath, request.header); + sendTo(request.url, request.fileName, request.filePath, request.header, request.server); sendResponse({ response: "send success" }); diff --git a/App/config.js b/App/config.js index a56829a..80768eb 100644 --- a/App/config.js +++ b/App/config.js @@ -20,12 +20,32 @@ config.command = { chgLog: true, badge: true, cmDownPanel: true, - ua: true, + ua: false, minFileSize: 0, typeFilterA: "", urlFilterA: "", typeFilterB: "", urlFilterB: "", }; + }, + get s2() { + return { + path2: "", + protocol2: "ws", + host2: "127.0.0.1", + port2: "6800", + interf2: "jsonrpc", + token2: "", + }; + }, + get s3() { + return { + path3: "", + protocol3: "ws", + host3: "127.0.0.1", + port3: "6800", + interf3: "jsonrpc", + token3: "", + }; } }; diff --git a/App/data/DownloadPanel/index.html b/App/data/DownloadPanel/index.html index f2b4310..592b4f3 100644 --- a/App/data/DownloadPanel/index.html +++ b/App/data/DownloadPanel/index.html @@ -73,14 +73,7 @@ top: 166px; font-size: 13.3px; } -.gwd-div-3yxp { - height: 200px; - width: 400px; -} -.gwd-div-3lnz { - height: 200px; - width: 400px; -} + .gwd-button-1rg2 { left: 91px; } @@ -238,199 +231,6 @@ width: 400px; height: 200px; } -.dots { - position: relative; - width: 100%; - top: 100px; -} -.dots span:nth-child(1) { - animation-delay: 0.1s; - -webkit-animation-delay: 0.1s; - -moz-animation-delay: 0.1s; -} -.dots span:nth-child(1)::after { - left: -10px; -} -.dots span:nth-child(2) { - animation-delay: 0.2s; - -webkit-animation-delay: 0.2s; - -moz-animation-delay: 0.2s; -} -.dots span:nth-child(2)::after { - left: -20px; -} -.dots span:nth-child(3) { - animation-delay: 0.3s; - -webkit-animation-delay: 0.3s; - -moz-animation-delay: 0.3s; -} -.dots span:nth-child(3)::after { - left: -30px; -} -.dots span:nth-child(4) { - animation-delay: 0.4s; - -webkit-animation-delay: 0.4s; - -moz-animation-delay: 0.4s; -} -.dots span:nth-child(4)::after { - left: -40px; -} -.dots span:nth-child(5) { - animation-delay: 0.5s; - -webkit-animation-delay: 0.5s; - -moz-animation-delay: 0.5s; -} -.dots span:nth-child(5)::after { - left: -50px; -} -.dots span:nth-child(6) { - animation-delay: 0.6s; - -webkit-animation-delay: 0.6s; - -moz-animation-delay: 0.6s; -} -.dots span:nth-child(6)::after { - left: -60px; -} -.dots span:nth-child(7) { - animation-delay: 0.7s; - -webkit-animation-delay: 0.7s; - -moz-animation-delay: 0.7s; -} -.dots span:nth-child(7)::after { - left: -70px; -} -.dots span:nth-child(8) { - animation-delay: 0.8s; - -webkit-animation-delay: 0.8s; - -moz-animation-delay: 0.8s; -} -.dots span:nth-child(8)::after { - left: -80px; -} -.dots span:nth-child(9) { - animation-delay: 0.9s; - -webkit-animation-delay: 0.9s; - -moz-animation-delay: 0.9s; -} -.dots span:nth-child(9)::after { - left: -90px; -} -.dots span:nth-child(10) { - animation-delay: 1s; - -webkit-animation-delay: 1s; - -moz-animation-delay: 1s; -} -.dots span:nth-child(10)::after { - left: -100px; -} -.dots span { - display: inline-block; - position: absolute; - animation-duration: 4s; - -webkit-animation-duration: 4s; - -moz-animation-duration: 4s; - animation-iteration-count: infinite; - -webkit-animation-iteration-count: infinite; - -moz-animation-iteration-count: infinite; -} -.dots span::after { - content: ""; - position: absolute; - display: inline-block; - background-color: rgb(21, 112, 166); - width: 5px; - height: 5px; - border-radius: 50%; -} -.dots.animate span { - animation-name: dots; - -webkit-animation-name: dots; - -moz-animation-name: dots; -} -@keyframes dots { - 0%, 20% { - left: 0px; - animation-timing-function: ease-out; - -webkit-animation-timing-function: ease-out; - -moz-animation-timing-function: ease-out; - opacity: 0; - } - 25% { - opacity: 1; - } - 35% { - left: 45%; - animation-timing-function: linear; - -webkit-animation-timing-function: linear; - -moz-animation-timing-function: linear; - } - 65% { - left: 55%; - animation-timing-function: ease-in; - -webkit-animation-timing-function: ease-in; - -moz-animation-timing-function: ease-in; - } - 75% { - opacity: 1; - } - 80%, - 100% { - left: 100%; - opacity: 0; - } -} -@-webkit-keyframes dots { - 0%, 20% { - left: 0px; - -webkit-animation-timing-function: ease-out; - opacity: 0; - } - 25% { - opacity: 1; - } - 35% { - left: 45%; - -webkit-animation-timing-function: linear; - } - 65% { - left: 55%; - -webkit-animation-timing-function: ease-in; - } - 75% { - opacity: 1; - } - 80%, - 100% { - left: 100%; - opacity: 0; - } -} -@-moz-keyframes dots { - 0%, 20% { - left: 0px; - -moz-animation-timing-function: ease-out; - opacity: 0; - } - 25% { - opacity: 1; - } - 35% { - left: 45%; - -moz-animation-timing-function: linear; - } - 65% { - left: 55%; - -moz-animation-timing-function: ease-in; - } - 75% { - opacity: 1; - } - 80%, - 100% { - left: 100%; - opacity: 0; - } -} .gwd-p-icch { position: absolute; top: 76px; @@ -454,20 +254,63 @@ .gwd-p-13lk { top: 52px; width: 357px; -} +} + +.s1 { + position: absolute; + top: 200px; + width: 354px; + left: 20px; + border-image-source: none; + border-image-width: initial; + border-image-outset: initial; + border-image-repeat: initial; + border-color: rgb(131, 131, 131); + border-style: solid; + border-width: 1px; + border-radius: 2px; + display: none; +} + +.s1:focus { + outline: none; + transition: 0.4s; + -webkit-transition: 0.4s; + -moz-transition: 0.4s; + border: 1px solid rgb(111, 161, 217) !important; + box-shadow: rgb(111, 161, 217) 0px 0px 3px !important; +} + +.head { + position: absolute; + top: 230px; + width: 346px; + left: 20px; + height: 50px; + border-image-source: none; + border-image-width: initial; + border-image-outset: initial; + border-image-repeat: initial; + border-color: rgb(131, 131, 131); + border-style: solid; + border-width: 1px; + border-radius: 2px; + display: none; +} + -
-
+
+
- +

File Name 

@@ -483,27 +326,15 @@ -
-
-
-
-
- - - - - - - - - - -
-

Downloading

+ +
- diff --git a/App/data/DownloadPanel/index.js b/App/data/DownloadPanel/index.js index 179476a..8a46a88 100644 --- a/App/data/DownloadPanel/index.js +++ b/App/data/DownloadPanel/index.js @@ -1,5 +1,5 @@ 'use strict'; -var headers; +var advl = false; function handleResponse(message) { //console.log(message); @@ -8,7 +8,7 @@ function handleResponse(message) { document.getElementById('url').value = message.url; document.getElementById('fs').textContent = message.fileSize; document.getElementById('fn').value = message.fileName; - headers = message.header; + document.querySelector(".head").value = message.header; document.getElementById('db').focus(); break; case "send success": @@ -46,7 +46,7 @@ function init() { document.getElementById('db').addEventListener('click', download); document.getElementById('sb').addEventListener('click', save); document.getElementById('sab').addEventListener('click', saveas); - document.getElementById('opb').addEventListener('click', tmpopen); + document.getElementById('advb').addEventListener('click', adv); document.querySelectorAll('[data-message]').forEach(n => { n.textContent = browser.i18n.getMessage(n.dataset.message); }); @@ -71,11 +71,12 @@ function download() { const url = document.getElementById('url').value; const fn = document.getElementById('fn').value; const fp = document.getElementById('fp').value; + const head = document.querySelector(".head").value + const rpc = document.querySelector(".s1").value verifyFileName(fn).then((e) => { if (e.length != 0) { document.getElementById('fn').style = "border: 1px solid red;box-shadow: red 0px 0px 4px;"; document.getElementById('fn').onchange = function() { - console.log("123"); document.getElementById('fn').style = ""; document.getElementById('fn').onchange = null; }; @@ -86,7 +87,8 @@ function download() { url: url, fileName: fn, filePath: fp, - header: headers, + header: head.split(","), + server: rpc, }); sending.then(handleResponse, handleError); saveWinLoc(); @@ -115,7 +117,7 @@ function save() { url: url, fileName: fn, filePath: fp, - header: headers, + header: head.split(","), incognito: windowInfo.incognito, }); sending.then(handleResponse, handleError); @@ -146,7 +148,7 @@ function saveas() { url: url, fileName: fn, filePath: fp, - header: headers, + header: head.split(","), wid: windowInfo.id, incognito: windowInfo.incognito, }); @@ -157,31 +159,29 @@ function saveas() { }); } -function tmpopen() { - const url = document.getElementById('url').value; - //var d = globalD.pop(); - //var header = d.requestHeaders; - /*var sending = browser.runtime.sendMessage({ - get: "tmpopen", - url: url, - fileName: fn, - header: headers, - }); - sending.then(handleResponse, handleError); */ - console.log("down"); - var downloading = browser.downloads.download({ - //filename: "\\temp", - //headers: header, - url: url - }); - var id = 0; - downloading.then(i => { - id = i; - }, (e) => { - console.log(e) - }); - saveWinLoc(); +function adv() { + if (advl == false) { + var getting = browser.windows.getCurrent(); + getting.then((windowInfo) => { + var updating = browser.windows.update(windowInfo.id, { + height: windowInfo.height + 95, + }); + }); + document.querySelector(".head").style = "display:block"; + document.querySelector(".s1").style = "display:block"; + advl = true; + } + else { + var getting = browser.windows.getCurrent(); + getting.then((windowInfo) => { + var updating = browser.windows.update(windowInfo.id, { + height: windowInfo.height - 95, + }); + }); + document.querySelector(".head").style = "display:none"; + document.querySelector(".s1").style = "display:none"; + advl = false; + } } -//window.addEventListener('WebComponentsReady', init, false); document.addEventListener('DOMContentLoaded', init); \ No newline at end of file diff --git a/App/data/options/menu.html b/App/data/options/menu.html index d943980..02ecb2b 100644 --- a/App/data/options/menu.html +++ b/App/data/options/menu.html @@ -238,10 +238,10 @@

Aria2 Integration Options

Default Server
  • - RPC Server 2 + RPC Server 2
  • - RPC Server 3 + RPC Server 3
  • diff --git a/App/data/options/menu.js b/App/data/options/menu.js index 30cdb94..79ec7d5 100644 --- a/App/data/options/menu.js +++ b/App/data/options/menu.js @@ -7,7 +7,10 @@ function hashHandler(ev) { document.querySelector('#rpc').className = ""; document.querySelector('#exception').className = ""; document.querySelector('#about').className = ""; - document.querySelector(location.hash).className = "active"; + if (location.hash == "#rpc" || location.hash == "#rpc2" || location.hash == "#rpc3") + document.querySelector("#rpc").className = "active"; + else + document.querySelector(location.hash).className = "active"; } document.querySelectorAll('[data-message]').forEach(n => { n.textContent = browser.i18n.getMessage(n.dataset.message); diff --git a/App/data/options/rpc2.html b/App/data/options/rpc2.html new file mode 100644 index 0000000..80a9a88 --- /dev/null +++ b/App/data/options/rpc2.html @@ -0,0 +1,122 @@ + + + + + Options Page + + + +
    +

    You need to download and start Aria2 by youself, complete at least + "Protocol," "Host," "Port" and "Interface" below and then click the "Save" + button.

    +

    If you don't want to start Aria2 manually, just write a program to start + Aria2 in the background and register it to the system's "autostart" or "uri + scheme."

    + You can find the sample files here. +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Default Download Path:
    Download path of Aria2(only)
    Protocol:
    RPC connection protocol of Aria2
    Host:
    RPC host of Aria2. You can use ip or domain name.
    Port:
    Aria2 RPC port
    Interface:
    Aria2 RPC path. Default value is "jsonrpc"
    Token:
    Aria2 RPC secret, optional.
    +
    + +
    + + + + \ No newline at end of file diff --git a/App/data/options/rpc2.js b/App/data/options/rpc2.js new file mode 100644 index 0000000..cff3b29 --- /dev/null +++ b/App/data/options/rpc2.js @@ -0,0 +1,42 @@ +'use strict'; + +function save() { + const path2 = document.getElementById('path').value; + const protocol2 = document.getElementById('protocol').value; + const host2 = document.getElementById('host').value; + const port2 = document.getElementById('port').value; + const interf2 = document.getElementById('interf').value; + const token2 = document.getElementById('token').value; + browser.storage.local.set({ + path2, + protocol2, + host2, + port2, + interf2, + token2, + }, () => { + const status = document.getElementById('status'); + status.textContent = browser.i18n.getMessage("OP_saveComplete"); + setTimeout(() => { + status.textContent = ''; + }, 750); + }); +} + +function restore() { + browser.storage.local.get(Object.assign(config.command.s2), prefs => { + document.getElementById('path').value = prefs.path2; + document.getElementById('protocol').value = prefs.protocol2; + document.getElementById('host').value = prefs.host2; + document.getElementById('port').value = prefs.port2; + document.getElementById('interf').value = prefs.interf2; + document.getElementById('token').value = prefs.token2; + }); + document.querySelectorAll('[data-message]').forEach(n => { + n.textContent = browser.i18n.getMessage(n.dataset.message); + }); + document.body.style = "direction: " + browser.i18n.getMessage("direction"); +} + +document.addEventListener('DOMContentLoaded', restore); +document.getElementById('save').addEventListener('click', save); \ No newline at end of file diff --git a/App/data/options/rpc3.html b/App/data/options/rpc3.html new file mode 100644 index 0000000..bcfefd7 --- /dev/null +++ b/App/data/options/rpc3.html @@ -0,0 +1,122 @@ + + + + + Options Page + + + +
    +

    You need to download and start Aria2 by youself, complete at least + "Protocol," "Host," "Port" and "Interface" below and then click the "Save" + button.

    +

    If you don't want to start Aria2 manually, just write a program to start + Aria2 in the background and register it to the system's "autostart" or "uri + scheme."

    + You can find the sample files here. +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Default Download Path:
    Download path of Aria2(only)
    Protocol:
    RPC connection protocol of Aria2
    Host:
    RPC host of Aria2. You can use ip or domain name.
    Port:
    Aria2 RPC port
    Interface:
    Aria2 RPC path. Default value is "jsonrpc"
    Token:
    Aria2 RPC secret, optional.
    +
    + +
    + + + + \ No newline at end of file diff --git a/App/data/options/rpc3.js b/App/data/options/rpc3.js new file mode 100644 index 0000000..5843f54 --- /dev/null +++ b/App/data/options/rpc3.js @@ -0,0 +1,42 @@ +'use strict'; + +function save() { + const path3 = document.getElementById('path').value; + const protocol3 = document.getElementById('protocol').value; + const host3 = document.getElementById('host').value; + const port3 = document.getElementById('port').value; + const interf3 = document.getElementById('interf').value; + const token3 = document.getElementById('token').value; + browser.storage.local.set({ + path3, + protocol3, + host3, + port3, + interf3, + token3, + }, () => { + const status = document.getElementById('status'); + status.textContent = browser.i18n.getMessage("OP_saveComplete"); + setTimeout(() => { + status.textContent = ''; + }, 750); + }); +} + +function restore() { + browser.storage.local.get(Object.assign(config.command.s3), prefs => { + document.getElementById('path').value = prefs.path3; + document.getElementById('protocol').value = prefs.protocol3; + document.getElementById('host').value = prefs.host3; + document.getElementById('port').value = prefs.port3; + document.getElementById('interf').value = prefs.interf3; + document.getElementById('token').value = prefs.token3; + }); + document.querySelectorAll('[data-message]').forEach(n => { + n.textContent = browser.i18n.getMessage(n.dataset.message); + }); + document.body.style = "direction: " + browser.i18n.getMessage("direction"); +} + +document.addEventListener('DOMContentLoaded', restore); +document.getElementById('save').addEventListener('click', save); \ No newline at end of file