├── LICENSE ├── README.md ├── data ├── api.js ├── download-mod.js ├── images │ ├── nzb-16-gray.png │ ├── nzb-16-green.png │ ├── nzb-16-orange.png │ ├── nzb-32-gray.png │ ├── nzb-32-green.png │ ├── nzb-32-orange.png │ ├── nzb-64-gray.png │ ├── nzb-64-green.png │ ├── nzb-64-orange.png │ ├── nzbg-16-fail.png │ ├── nzbg-16-pass.png │ ├── nzbg-16.png │ ├── nzbg-32.png │ ├── sab-16-fail.png │ ├── sab-16-pass.png │ ├── sab-16.png │ ├── sab-32.png │ ├── spinner-dark.gif │ └── spinner-light.gif ├── main-panel.html ├── main-panel.js ├── notification-panel.html ├── notification-panel.js ├── theme.dark.css ├── theme.light.css ├── theme │ ├── dark-hive │ │ ├── images │ │ │ ├── ui-bg_flat_30_cccccc_40x100.png │ │ │ ├── ui-bg_flat_50_5c5c5c_40x100.png │ │ │ ├── ui-bg_glass_40_ffc73d_1x400.png │ │ │ ├── ui-bg_highlight-hard_20_0972a5_1x100.png │ │ │ ├── ui-bg_highlight-soft_33_003147_1x100.png │ │ │ ├── ui-bg_highlight-soft_35_222222_1x100.png │ │ │ ├── ui-bg_highlight-soft_44_444444_1x100.png │ │ │ ├── ui-bg_highlight-soft_80_eeeeee_1x100.png │ │ │ ├── ui-bg_loop_25_000000_21x21.png │ │ │ ├── ui-icons_222222_256x240.png │ │ │ ├── ui-icons_4b8e0b_256x240.png │ │ │ ├── ui-icons_a83300_256x240.png │ │ │ ├── ui-icons_cccccc_256x240.png │ │ │ └── ui-icons_ffffff_256x240.png │ │ └── theme.css │ ├── flick │ │ ├── images │ │ │ ├── ui-bg_flat_0_aaaaaa_40x100.png │ │ │ ├── ui-bg_flat_0_eeeeee_40x100.png │ │ │ ├── ui-bg_flat_55_ffffff_40x100.png │ │ │ ├── ui-bg_flat_75_ffffff_40x100.png │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ ├── ui-bg_highlight-soft_100_f6f6f6_1x100.png │ │ │ ├── ui-bg_highlight-soft_25_0073ea_1x100.png │ │ │ ├── ui-bg_highlight-soft_50_dddddd_1x100.png │ │ │ ├── ui-icons_0073ea_256x240.png │ │ │ ├── ui-icons_454545_256x240.png │ │ │ ├── ui-icons_666666_256x240.png │ │ │ ├── ui-icons_ff0084_256x240.png │ │ │ └── ui-icons_ffffff_256x240.png │ │ └── theme.css │ ├── jquery-ui.min.js │ ├── jquery-ui.structure.min.css │ └── jquery.min.js ├── webpage-mod.css └── webpage-mod.js ├── lib ├── NZBGet_API.js ├── SABnzbd_API.js ├── chrome-mod.js └── main.js └── package.json /LICENSE: -------------------------------------------------------------------------------- 1 | Mozilla Public License, version 2.0 2 | 3 | 1. Definitions 4 | 5 | 1.1. "Contributor" 6 | 7 | means each individual or legal entity that creates, contributes to the 8 | creation of, or owns Covered Software. 9 | 10 | 1.2. "Contributor Version" 11 | 12 | means the combination of the Contributions of others (if any) used by a 13 | Contributor and that particular Contributor's Contribution. 14 | 15 | 1.3. "Contribution" 16 | 17 | means Covered Software of a particular Contributor. 18 | 19 | 1.4. "Covered Software" 20 | 21 | means Source Code Form to which the initial Contributor has attached the 22 | notice in Exhibit A, the Executable Form of such Source Code Form, and 23 | Modifications of such Source Code Form, in each case including portions 24 | thereof. 25 | 26 | 1.5. "Incompatible With Secondary Licenses" 27 | means 28 | 29 | a. that the initial Contributor has attached the notice described in 30 | Exhibit B to the Covered Software; or 31 | 32 | b. that the Covered Software was made available under the terms of 33 | version 1.1 or earlier of the License, but not also under the terms of 34 | a Secondary License. 35 | 36 | 1.6. "Executable Form" 37 | 38 | means any form of the work other than Source Code Form. 39 | 40 | 1.7. "Larger Work" 41 | 42 | means a work that combines Covered Software with other material, in a 43 | separate file or files, that is not Covered Software. 44 | 45 | 1.8. "License" 46 | 47 | means this document. 48 | 49 | 1.9. "Licensable" 50 | 51 | means having the right to grant, to the maximum extent possible, whether 52 | at the time of the initial grant or subsequently, any and all of the 53 | rights conveyed by this License. 54 | 55 | 1.10. "Modifications" 56 | 57 | means any of the following: 58 | 59 | a. any file in Source Code Form that results from an addition to, 60 | deletion from, or modification of the contents of Covered Software; or 61 | 62 | b. any new file in Source Code Form that contains any Covered Software. 63 | 64 | 1.11. "Patent Claims" of a Contributor 65 | 66 | means any patent claim(s), including without limitation, method, 67 | process, and apparatus claims, in any patent Licensable by such 68 | Contributor that would be infringed, but for the grant of the License, 69 | by the making, using, selling, offering for sale, having made, import, 70 | or transfer of either its Contributions or its Contributor Version. 71 | 72 | 1.12. "Secondary License" 73 | 74 | means either the GNU General Public License, Version 2.0, the GNU Lesser 75 | General Public License, Version 2.1, the GNU Affero General Public 76 | License, Version 3.0, or any later versions of those licenses. 77 | 78 | 1.13. "Source Code Form" 79 | 80 | means the form of the work preferred for making modifications. 81 | 82 | 1.14. "You" (or "Your") 83 | 84 | means an individual or a legal entity exercising rights under this 85 | License. For legal entities, "You" includes any entity that controls, is 86 | controlled by, or is under common control with You. For purposes of this 87 | definition, "control" means (a) the power, direct or indirect, to cause 88 | the direction or management of such entity, whether by contract or 89 | otherwise, or (b) ownership of more than fifty percent (50%) of the 90 | outstanding shares or beneficial ownership of such entity. 91 | 92 | 93 | 2. License Grants and Conditions 94 | 95 | 2.1. Grants 96 | 97 | Each Contributor hereby grants You a world-wide, royalty-free, 98 | non-exclusive license: 99 | 100 | a. under intellectual property rights (other than patent or trademark) 101 | Licensable by such Contributor to use, reproduce, make available, 102 | modify, display, perform, distribute, and otherwise exploit its 103 | Contributions, either on an unmodified basis, with Modifications, or 104 | as part of a Larger Work; and 105 | 106 | b. under Patent Claims of such Contributor to make, use, sell, offer for 107 | sale, have made, import, and otherwise transfer either its 108 | Contributions or its Contributor Version. 109 | 110 | 2.2. Effective Date 111 | 112 | The licenses granted in Section 2.1 with respect to any Contribution 113 | become effective for each Contribution on the date the Contributor first 114 | distributes such Contribution. 115 | 116 | 2.3. Limitations on Grant Scope 117 | 118 | The licenses granted in this Section 2 are the only rights granted under 119 | this License. No additional rights or licenses will be implied from the 120 | distribution or licensing of Covered Software under this License. 121 | Notwithstanding Section 2.1(b) above, no patent license is granted by a 122 | Contributor: 123 | 124 | a. for any code that a Contributor has removed from Covered Software; or 125 | 126 | b. for infringements caused by: (i) Your and any other third party's 127 | modifications of Covered Software, or (ii) the combination of its 128 | Contributions with other software (except as part of its Contributor 129 | Version); or 130 | 131 | c. under Patent Claims infringed by Covered Software in the absence of 132 | its Contributions. 133 | 134 | This License does not grant any rights in the trademarks, service marks, 135 | or logos of any Contributor (except as may be necessary to comply with 136 | the notice requirements in Section 3.4). 137 | 138 | 2.4. Subsequent Licenses 139 | 140 | No Contributor makes additional grants as a result of Your choice to 141 | distribute the Covered Software under a subsequent version of this 142 | License (see Section 10.2) or under the terms of a Secondary License (if 143 | permitted under the terms of Section 3.3). 144 | 145 | 2.5. Representation 146 | 147 | Each Contributor represents that the Contributor believes its 148 | Contributions are its original creation(s) or it has sufficient rights to 149 | grant the rights to its Contributions conveyed by this License. 150 | 151 | 2.6. Fair Use 152 | 153 | This License is not intended to limit any rights You have under 154 | applicable copyright doctrines of fair use, fair dealing, or other 155 | equivalents. 156 | 157 | 2.7. Conditions 158 | 159 | Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted in 160 | Section 2.1. 161 | 162 | 163 | 3. Responsibilities 164 | 165 | 3.1. Distribution of Source Form 166 | 167 | All distribution of Covered Software in Source Code Form, including any 168 | Modifications that You create or to which You contribute, must be under 169 | the terms of this License. You must inform recipients that the Source 170 | Code Form of the Covered Software is governed by the terms of this 171 | License, and how they can obtain a copy of this License. You may not 172 | attempt to alter or restrict the recipients' rights in the Source Code 173 | Form. 174 | 175 | 3.2. Distribution of Executable Form 176 | 177 | If You distribute Covered Software in Executable Form then: 178 | 179 | a. such Covered Software must also be made available in Source Code Form, 180 | as described in Section 3.1, and You must inform recipients of the 181 | Executable Form how they can obtain a copy of such Source Code Form by 182 | reasonable means in a timely manner, at a charge no more than the cost 183 | of distribution to the recipient; and 184 | 185 | b. You may distribute such Executable Form under the terms of this 186 | License, or sublicense it under different terms, provided that the 187 | license for the Executable Form does not attempt to limit or alter the 188 | recipients' rights in the Source Code Form under this License. 189 | 190 | 3.3. Distribution of a Larger Work 191 | 192 | You may create and distribute a Larger Work under terms of Your choice, 193 | provided that You also comply with the requirements of this License for 194 | the Covered Software. If the Larger Work is a combination of Covered 195 | Software with a work governed by one or more Secondary Licenses, and the 196 | Covered Software is not Incompatible With Secondary Licenses, this 197 | License permits You to additionally distribute such Covered Software 198 | under the terms of such Secondary License(s), so that the recipient of 199 | the Larger Work may, at their option, further distribute the Covered 200 | Software under the terms of either this License or such Secondary 201 | License(s). 202 | 203 | 3.4. Notices 204 | 205 | You may not remove or alter the substance of any license notices 206 | (including copyright notices, patent notices, disclaimers of warranty, or 207 | limitations of liability) contained within the Source Code Form of the 208 | Covered Software, except that You may alter any license notices to the 209 | extent required to remedy known factual inaccuracies. 210 | 211 | 3.5. Application of Additional Terms 212 | 213 | You may choose to offer, and to charge a fee for, warranty, support, 214 | indemnity or liability obligations to one or more recipients of Covered 215 | Software. However, You may do so only on Your own behalf, and not on 216 | behalf of any Contributor. You must make it absolutely clear that any 217 | such warranty, support, indemnity, or liability obligation is offered by 218 | You alone, and You hereby agree to indemnify every Contributor for any 219 | liability incurred by such Contributor as a result of warranty, support, 220 | indemnity or liability terms You offer. You may include additional 221 | disclaimers of warranty and limitations of liability specific to any 222 | jurisdiction. 223 | 224 | 4. Inability to Comply Due to Statute or Regulation 225 | 226 | If it is impossible for You to comply with any of the terms of this License 227 | with respect to some or all of the Covered Software due to statute, 228 | judicial order, or regulation then You must: (a) comply with the terms of 229 | this License to the maximum extent possible; and (b) describe the 230 | limitations and the code they affect. Such description must be placed in a 231 | text file included with all distributions of the Covered Software under 232 | this License. Except to the extent prohibited by statute or regulation, 233 | such description must be sufficiently detailed for a recipient of ordinary 234 | skill to be able to understand it. 235 | 236 | 5. Termination 237 | 238 | 5.1. The rights granted under this License will terminate automatically if You 239 | fail to comply with any of its terms. However, if You become compliant, 240 | then the rights granted under this License from a particular Contributor 241 | are reinstated (a) provisionally, unless and until such Contributor 242 | explicitly and finally terminates Your grants, and (b) on an ongoing 243 | basis, if such Contributor fails to notify You of the non-compliance by 244 | some reasonable means prior to 60 days after You have come back into 245 | compliance. Moreover, Your grants from a particular Contributor are 246 | reinstated on an ongoing basis if such Contributor notifies You of the 247 | non-compliance by some reasonable means, this is the first time You have 248 | received notice of non-compliance with this License from such 249 | Contributor, and You become compliant prior to 30 days after Your receipt 250 | of the notice. 251 | 252 | 5.2. If You initiate litigation against any entity by asserting a patent 253 | infringement claim (excluding declaratory judgment actions, 254 | counter-claims, and cross-claims) alleging that a Contributor Version 255 | directly or indirectly infringes any patent, then the rights granted to 256 | You by any and all Contributors for the Covered Software under Section 257 | 2.1 of this License shall terminate. 258 | 259 | 5.3. In the event of termination under Sections 5.1 or 5.2 above, all end user 260 | license agreements (excluding distributors and resellers) which have been 261 | validly granted by You or Your distributors under this License prior to 262 | termination shall survive termination. 263 | 264 | 6. Disclaimer of Warranty 265 | 266 | Covered Software is provided under this License on an "as is" basis, 267 | without warranty of any kind, either expressed, implied, or statutory, 268 | including, without limitation, warranties that the Covered Software is free 269 | of defects, merchantable, fit for a particular purpose or non-infringing. 270 | The entire risk as to the quality and performance of the Covered Software 271 | is with You. Should any Covered Software prove defective in any respect, 272 | You (not any Contributor) assume the cost of any necessary servicing, 273 | repair, or correction. This disclaimer of warranty constitutes an essential 274 | part of this License. No use of any Covered Software is authorized under 275 | this License except under this disclaimer. 276 | 277 | 7. Limitation of Liability 278 | 279 | Under no circumstances and under no legal theory, whether tort (including 280 | negligence), contract, or otherwise, shall any Contributor, or anyone who 281 | distributes Covered Software as permitted above, be liable to You for any 282 | direct, indirect, special, incidental, or consequential damages of any 283 | character including, without limitation, damages for lost profits, loss of 284 | goodwill, work stoppage, computer failure or malfunction, or any and all 285 | other commercial damages or losses, even if such party shall have been 286 | informed of the possibility of such damages. This limitation of liability 287 | shall not apply to liability for death or personal injury resulting from 288 | such party's negligence to the extent applicable law prohibits such 289 | limitation. Some jurisdictions do not allow the exclusion or limitation of 290 | incidental or consequential damages, so this exclusion and limitation may 291 | not apply to You. 292 | 293 | 8. Litigation 294 | 295 | Any litigation relating to this License may be brought only in the courts 296 | of a jurisdiction where the defendant maintains its principal place of 297 | business and such litigation shall be governed by laws of that 298 | jurisdiction, without reference to its conflict-of-law provisions. Nothing 299 | in this Section shall prevent a party's ability to bring cross-claims or 300 | counter-claims. 301 | 302 | 9. Miscellaneous 303 | 304 | This License represents the complete agreement concerning the subject 305 | matter hereof. If any provision of this License is held to be 306 | unenforceable, such provision shall be reformed only to the extent 307 | necessary to make it enforceable. Any law or regulation which provides that 308 | the language of a contract shall be construed against the drafter shall not 309 | be used to construe this License against a Contributor. 310 | 311 | 312 | 10. Versions of the License 313 | 314 | 10.1. New Versions 315 | 316 | Mozilla Foundation is the license steward. Except as provided in Section 317 | 10.3, no one other than the license steward has the right to modify or 318 | publish new versions of this License. Each version will be given a 319 | distinguishing version number. 320 | 321 | 10.2. Effect of New Versions 322 | 323 | You may distribute the Covered Software under the terms of the version 324 | of the License under which You originally received the Covered Software, 325 | or under the terms of any subsequent version published by the license 326 | steward. 327 | 328 | 10.3. Modified Versions 329 | 330 | If you create software not governed by this License, and you want to 331 | create a new license for such software, you may create and use a 332 | modified version of this License if you rename the license and remove 333 | any references to the name of the license steward (except to note that 334 | such modified license differs from this License). 335 | 336 | 10.4. Distributing Source Code Form that is Incompatible With Secondary 337 | Licenses If You choose to distribute Source Code Form that is 338 | Incompatible With Secondary Licenses under the terms of this version of 339 | the License, the notice described in Exhibit B of this License must be 340 | attached. 341 | 342 | Exhibit A - Source Code Form License Notice 343 | 344 | This Source Code Form is subject to the 345 | terms of the Mozilla Public License, v. 346 | 2.0. If a copy of the MPL was not 347 | distributed with this file, You can 348 | obtain one at 349 | http://mozilla.org/MPL/2.0/. 350 | 351 | If it is not possible or desirable to put the notice in a particular file, 352 | then You may include the notice in a location (such as a LICENSE file in a 353 | relevant directory) where a recipient would be likely to look for such a 354 | notice. 355 | 356 | You may add additional accurate notices of copyright ownership. 357 | 358 | Exhibit B - "Incompatible With Secondary Licenses" Notice 359 | 360 | This Source Code Form is "Incompatible 361 | With Secondary Licenses", as defined by 362 | the Mozilla Public License, v. 2.0. 363 | 364 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NOTE: This project is discontinued as of June 26 2017. 2 | 3 | ## Description 4 | This is a (discontinued) Firefox Addon which adds the ability to send Usenet NZB files directly to SABnzbd+ or NZBGet download clients. 5 | 6 | (This is my first JavaScript project) 7 | 8 | ## Download 9 | Install from [https://addons.mozilla.org/addon/nzbfox](https://addons.mozilla.org/addon/nzbfox?src=gh) (Firefox only) 10 | 11 | ## Features: 12 | 13 | - [NZBGet](https://nzbget.net/) (v13+) support 14 | - [SABnzbd+](https://sabnzbd.org/) support 15 | - Directly integrated into popular indexer websites to add buttons next to each download 16 | - View/pause your download client directly from the Firefox interface button 17 | - Pause (with optional time limit), control speed limiting, and more 18 | - Notifications for downloads when they start and finish with statistics 19 | - Catch downloads of all NZB files from any website and send them to your download client 20 | - Manually add your own generic Newznab provider 21 | - Light & Dark interface themes 22 | 23 | ## Screenshots: 24 | 25 | ![nzbFox Browser GUI](https://i.imgur.com/JAtLGEj.png) 26 | > View the status of your download client directly from the Firefox interface. You can set the speed limit, and pause for a certain amount of time. 27 | 28 | ![nzbFox Browser GUI](https://i.imgur.com/3SZOz2S.png) 29 | 30 | > When a download starts or finishes, a popup will appear from the nzbFox icon to let you know! (optional) 31 | 32 | ![nzbFox Browser GUI](https://i.imgur.com/0Dq0RdH.png) 33 | 34 | > Download buttons are directly integrated in to supported indexers search results! 35 | 36 | ![nzbFox Browser GUI](https://i.imgur.com/GKC94Ay.png) 37 | 38 | > Download an NZB from ANY website, and you can still send it directly to your download client! 39 | -------------------------------------------------------------------------------- /data/api.js: -------------------------------------------------------------------------------- 1 | const api = (new function(){ 2 | var _this = this; 3 | var queue = []; 4 | 5 | this.call = function(sender,method,params,onSuccess,onFailure) { 6 | for (var id = 0; id < queue.length; ++id) 7 | if (!queue[id]) break; 8 | queue[id] = ({sender:sender,api:{method:method,params:params},onSuccess:onSuccess,onFailure:onFailure,sent:false}); 9 | _this.startQueue(); 10 | } 11 | 12 | this.startQueue = function() { 13 | for (var i = 0; i < queue.length; ++i) 14 | if (queue[i] && !queue[i].sent) { 15 | if (queue[i].sender.onApiBeforeCall) 16 | queue[i].sender.onApiBeforeCall(queue[i].api); 17 | self.port.emit('api-call',{index:i,type:queue[i].sender.type,api:queue[i].api,onSuccess:'api-call-success',onFailure:'api-call-failure'}); 18 | queue[i].sent = true; 19 | } 20 | } 21 | this.onSuccess = function(call,reply) { 22 | // console.log('api-call-success '+JSON.stringify(call)+' / '+JSON.stringify(reply)); 23 | if (queue[call.index].sender.onApiSuccess) 24 | queue[call.index].sender.onApiSuccess(call,reply); 25 | if (queue[call.index].onSuccess && queue[call.index].sender) 26 | queue[call.index].onSuccess.call(queue[call.index].sender,reply); 27 | 28 | delete queue[call.index]; 29 | }; self.port.on('api-call-success',function({call,reply}) _this.onSuccess.call(_this,call,reply)); 30 | this.onFailure = function(call,reply) { 31 | console.error('api-call-failure '+JSON.stringify(call)+' / '+JSON.stringify(reply)); 32 | if (queue[call.index].sender.onApiFailure) 33 | queue[call.index].sender.onApiFailure(call,reply); 34 | if (queue[call.index].onFailure) 35 | queue[call.index].onFailure.call(queue[call.index].sender,reply); 36 | 37 | delete queue[call.index]; 38 | 39 | }; self.port.on('api-call-failure',function({call,reply}) _this.onFailure.call(_this,call,reply)); 40 | }()); -------------------------------------------------------------------------------- /data/download-mod.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | */ 5 | function log(msg) { self.port.emit('log', msg); } 6 | const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"; 7 | 8 | log('Download prompt detected, MIME = "' + dialog.mLauncher.MIMEInfo.MIMEType + '" suggestedFileName = "' + dialog.mLauncher.suggestedFileName + '"'); 9 | 10 | if (dialog.mLauncher.MIMEInfo.MIMEType == 'application/x-nzb' || dialog.mLauncher.suggestedFileName.endsWith('.nzb')) { 11 | var modeGroup = document.getElementById('mode'); 12 | var rememberChoice = document.getElementById('rememberChoice'); 13 | var fileName = dialog.mLauncher.suggestedFileName; 14 | 15 | function createMenuItem(aMenuPopup, aLabel, aValue = aLabel, aDescription = '') { // Create a for category list 16 | if (aLabel != '' && aMenuPopup) { 17 | var item = document.createElementNS(XUL_NS, 'menuitem'); 18 | item.setAttribute('label', aLabel); 19 | item.setAttribute('value', aValue); 20 | item.setAttribute('description', aDescription); 21 | return aMenuPopup.appendChild(item); 22 | } else return false; 23 | } 24 | 25 | function createSendTo(id, label) { 26 | 27 | var container = document.createElementNS(XUL_NS, 'hbox'); // Contains the radio and category list in one row 28 | container.setAttribute('flex', '1'); 29 | 30 | var spacer = document.createElementNS(XUL_NS, 'spacer'); 31 | spacer.setAttribute('flex', '1'); 32 | 33 | var radio = document.createElementNS(XUL_NS, 'radio'); 34 | radio.setAttribute('label', label); 35 | radio.setAttribute('value', id); 36 | radio.setAttribute('src', self.options.dataURL + 'images/' + id + '-16.png'); 37 | 38 | var catList = document.createElementNS(XUL_NS, 'menulist'); 39 | catList.setAttribute('crop', 'center'); 40 | catList.setAttribute('flex', '1'); 41 | catList.setAttribute('readonly', 'true'); 42 | 43 | var catListMenu = document.createElementNS(XUL_NS, 'menupopup'); 44 | createMenuItem(catListMenu, 'Category (optional)', ''); 45 | createMenuItem(catListMenu, self.options.prefs.cat_tv); 46 | createMenuItem(catListMenu, self.options.prefs.cat_movies); 47 | createMenuItem(catListMenu, self.options.prefs.cat_anime); 48 | createMenuItem(catListMenu, self.options.prefs.cat_music); 49 | createMenuItem(catListMenu, self.options.prefs.cat_games); 50 | createMenuItem(catListMenu, self.options.prefs.cat_reading); 51 | createMenuItem(catListMenu, self.options.prefs.cat_comics); 52 | createMenuItem(catListMenu, self.options.prefs.cat_apps); 53 | createMenuItem(catListMenu, self.options.prefs.cat_adult); 54 | 55 | // Extra Categories 56 | if (self.options.prefs.cat_custom != '') { 57 | var CustomCategories = self.options.prefs.cat_custom.split(',') 58 | for (let i = 0; i < CustomCategories.length; ++i) 59 | createMenuItem(catListMenu, CustomCategories[i], undefined, '(custom)'); 60 | } 61 | 62 | catList.appendChild(catListMenu); 63 | 64 | container.appendChild(radio); 65 | container.appendChild(spacer); 66 | container.appendChild(catList); 67 | 68 | return { container: container, radio: radio, catList: catList }; 69 | } 70 | 71 | if (self.options.prefs.sab_enabled) { 72 | var sendto_sab = createSendTo('sab', 'Send to SABnzbd+'); 73 | modeGroup.appendChild(sendto_sab.container); 74 | } 75 | if (self.options.prefs.nzbg_enabled) { 76 | var sendto_nzbg = createSendTo('nzbg', 'Send to NZBGet'); 77 | modeGroup.appendChild(sendto_nzbg.container); 78 | } 79 | 80 | dialog.onOK_orig = dialog.onOK; 81 | dialog.onOK = function () { 82 | var selected; 83 | if (sendto_nzbg && modeGroup.selectedItem == sendto_nzbg.radio) 84 | selected = sendto_nzbg 85 | else if (sendto_sab && modeGroup.selectedItem == sendto_sab.radio) 86 | selected = sendto_sab; 87 | 88 | if (typeof selected !== 'undefined') { 89 | var data = { url: dialog.mLauncher.source.spec, type: selected.radio.value, fileName: fileName, category: selected.catList.value, remember: rememberChoice.checked }; 90 | self.port.emit('nzb-download', data); 91 | 92 | modeGroup.selectedItem = document.getElementById('save'); 93 | rememberChoice.checked = false; 94 | } 95 | return dialog.onOK_orig(); 96 | } 97 | 98 | dialog.postShowCallback_orig = dialog.postShowCallback; 99 | dialog.postShowCallback = function () { 100 | dialog.postShowCallback_orig(); 101 | if (self.options.prefs.prompt_action != '') { 102 | if (sendto_sab && self.options.prefs.prompt_action == sendto_sab.radio.value) 103 | modeGroup.selectedItem = sendto_sab.radio 104 | else 105 | if (sendto_nzbg && self.options.prefs.prompt_action == sendto_nzbg.radio.value) 106 | modeGroup.selectedItem = sendto_nzbg.radio; 107 | 108 | if (modeGroup.selectedItem.value == self.options.prefs.prompt_action) { 109 | rememberChoice.checked = true; 110 | dialog.mDialog.document.documentElement.getButton('accept').disabled = false; 111 | dialog.mDialog.document.documentElement.getButton('accept').click(); 112 | } 113 | } 114 | } 115 | } -------------------------------------------------------------------------------- /data/images/nzb-16-gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzb-16-gray.png -------------------------------------------------------------------------------- /data/images/nzb-16-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzb-16-green.png -------------------------------------------------------------------------------- /data/images/nzb-16-orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzb-16-orange.png -------------------------------------------------------------------------------- /data/images/nzb-32-gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzb-32-gray.png -------------------------------------------------------------------------------- /data/images/nzb-32-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzb-32-green.png -------------------------------------------------------------------------------- /data/images/nzb-32-orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzb-32-orange.png -------------------------------------------------------------------------------- /data/images/nzb-64-gray.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzb-64-gray.png -------------------------------------------------------------------------------- /data/images/nzb-64-green.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzb-64-green.png -------------------------------------------------------------------------------- /data/images/nzb-64-orange.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzb-64-orange.png -------------------------------------------------------------------------------- /data/images/nzbg-16-fail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzbg-16-fail.png -------------------------------------------------------------------------------- /data/images/nzbg-16-pass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzbg-16-pass.png -------------------------------------------------------------------------------- /data/images/nzbg-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzbg-16.png -------------------------------------------------------------------------------- /data/images/nzbg-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/nzbg-32.png -------------------------------------------------------------------------------- /data/images/sab-16-fail.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/sab-16-fail.png -------------------------------------------------------------------------------- /data/images/sab-16-pass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/sab-16-pass.png -------------------------------------------------------------------------------- /data/images/sab-16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/sab-16.png -------------------------------------------------------------------------------- /data/images/sab-32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/sab-32.png -------------------------------------------------------------------------------- /data/images/spinner-dark.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/spinner-dark.gif -------------------------------------------------------------------------------- /data/images/spinner-light.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SierraJC/nzbFox/f05126f2741b5bbab3a7da21d5d991d2b0c7304a/data/images/spinner-light.gif -------------------------------------------------------------------------------- /data/main-panel.html: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 70 | 71 | 72 | 73 | 74 |
75 | 78 |
79 | 80 |
81 | Speed: 82 |

83 | Downloading: 84 |

85 | Remaining: 86 |

87 |
88 |
89 |

90 |
91 | 92 | 93 | 94 |
95 | 108 |
109 |
110 | 111 |
112 | 113 |
114 | Speed: 115 |

116 | Downloading: 117 |

118 | Remaining: 119 |

120 |
121 |
122 |

123 |
124 | 125 | 126 | 127 |
128 | 152 |
153 |
154 | 155 |
156 | 157 |
158 |

minutes 159 |

160 |
161 | 162 |
163 |

KB/s

164 |
165 | 166 |
167 |

168 |
169 | 170 | 175 | 176 | 177 | 178 | -------------------------------------------------------------------------------- /data/main-panel.js: -------------------------------------------------------------------------------- 1 | /* This Source Code Form is subject to the terms of the Mozilla Public 2 | * License, v. 2.0. If a copy of the MPL was not distributed with this 3 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 | */ 5 | 'use strict'; 6 | 7 | ////////////////////////////////////////////////////////////////////////////// 8 | var noSDK = (typeof self.port == 'undefined'); 9 | if (noSDK) { // dummy code for when testing UI without add-on SDK 10 | var port = (new function () { 11 | this.events = []; 12 | this.on = function (event, args) { 13 | // console.log('<- on "'+event+'" called with '+JSON.stringify(args)); 14 | } 15 | this.emit = function (event, args) { 16 | // console.log('-> emit "'+event+'" called with '+JSON.stringify(args)); 17 | } 18 | }); 19 | 20 | var options = (new function () { 21 | this.prefs = { 22 | theme: 'light', 23 | dev: true, 24 | nzbg_enabled: true, 25 | sab_enabled: true, 26 | 27 | nzbg_url: 'http://192.168.1.4:8085', 28 | sab_url: 'http://192.168.1.4:8080', 29 | sab_apikey: '123456', 30 | }; 31 | }); 32 | 33 | } 34 | ////////////////////////////////////////////////////////////////////////////// 35 | 36 | var entityMap = { 37 | "&": "&", 38 | "<": "<", 39 | ">": ">", 40 | '"': '"', 41 | "'": ''', 42 | "/": '/' 43 | }; 44 | function escapeHtml(string) { 45 | return String(string).replace(/[&<>"'\/]/g, function (s) { 46 | return entityMap[s]; 47 | }); 48 | } 49 | 50 | function log(msg) { 51 | if (noSDK) 52 | console.log(msg) 53 | else 54 | self.port.emit('log', msg); 55 | }; 56 | function resize() { self.port.emit('resize', { width: parseInt(window.getComputedStyle(document.documentElement).width, 10), height: parseInt(window.getComputedStyle(document.documentElement).height, 10) }); } 57 | function time() { return Math.round((new Date()).getTime() / 1000) }; 58 | function bytesToReadable(bytes, decimal) { 59 | var s = ['B', 'KB', 'MB', 'GB', 'TB', 'PB']; 60 | if (bytes == 0) return '0 ' + s[0]; 61 | var e = Math.floor(Math.log(bytes) / Math.log(1024)); 62 | return (bytes / Math.pow(1024, e)).toFixed(decimal) + ' ' + s[e]; 63 | } 64 | function timeToStringL(secs, twoResults = false) { 65 | var d = Math.floor(secs / 86400); 66 | var h = Math.floor((secs % 86400) / 3600); 67 | var m = Math.floor((secs / 60) % 60); 68 | var s = Math.floor(secs % 60); 69 | if (d > 0) return d + ' day' + (d > 1 ? 's' : '') + ', ' + h + ' hour' + (h > 1 ? 's' : ''); 70 | if (h > 0) return h + ' hour' + (h > 1 ? 's' : '') + ', ' + m + ' minute' + (m > 1 ? 's' : ''); 71 | if (m > 0) return m + ' minute' + (m > 1 ? 's' : '') + ((m == 1 && s > 0) || twoResults ? ', ' + s + ' second' + (s > 1 ? 's' : '') : ''); 72 | return s + ' second' + (s > 1 ? 's' : ''); 73 | } 74 | function timeToStringS(secs) { 75 | var d = Math.floor(secs / 86400); 76 | var h = Math.floor((secs % 86400) / 3600); 77 | var m = Math.floor((secs / 60) % 60); 78 | var s = Math.floor(secs % 60); 79 | if (d > 0) return d + 'd'; 80 | if (h > 0) return (m > 30 ? h + 1 : h) + 'h'; 81 | if (m > 0) return (s > 30 ? m + 1 : m) + 'm'; 82 | return s + 's'; 83 | } 84 | 85 | function nzbgStatusToString(nzbgStatus) { 86 | switch (nzbgStatus) { 87 | case 'FAILURE/BAD': return 'Marked as BAD by user'; 88 | case 'SUCCESS/GOOD': return 'Marked as GOOD by user'; 89 | case 'FAILURE/HEALTH': return 'The download was aborted by health check'; 90 | case 'DELETED/MANUAL': return 'Deleted by user'; 91 | case 'DELETED/DUPE': return 'Deleted by duplicate check'; 92 | case 'FAILURE/PAR': return 'The par-check has failed'; 93 | case 'FAILURE/UNPACK': return 'The unpack has failed and there are no par-files'; 94 | case 'FAILURE/MOVE': return 'Error while moving files from temporary folder to destination'; 95 | case 'WARNING/DAMAGED': return 'Par-check required, but disabled in settings'; 96 | case 'WARNING/REPAIRABLE': return 'Files are damaged, but repair is disabled in settings'; 97 | case 'FAILURE/HEALTH': return 'Health is critical, no par files available, no files unpacked'; 98 | case 'WARNING/HEALTH': return 'Health is less than 100%, no par files available, no files unpacked'; 99 | case 'SUCCESS/HEALTH': return 'Downloaded successfully, no par files available, no files unpacked'; 100 | case 'WARNING/SPACE': return 'Unpack has failed due to not enough space on the drive'; 101 | case 'WARNING/PASSWORD': return 'Unpack has failed because the password was not provided or was wrong'; 102 | case 'SUCCESS/ALL': return 'Downloaded successfully'; 103 | case 'SUCCESS/UNPACK': return 'Downloaded successfully, no post-processing'; 104 | case 'SUCCESS/PAR': return 'Downloaded successfully, no unpack required'; 105 | case 'WARNING/SCRIPT': return 'Downloaded successfully, but a post-processing script has failed'; 106 | default: return nzbgStatus; 107 | } 108 | } 109 | function nzbgPriorityToString(nzbgPriority) { 110 | switch (nzbgPriority) { 111 | case 900: return 'Force'; 112 | case 100: return 'Very High'; 113 | case 50: return 'High'; 114 | case 0: return 'Normal'; 115 | case -50: return 'Low'; 116 | case -100: return 'Very Low'; 117 | default: return nzbgPriority; 118 | } 119 | } 120 | 121 | function updateToolbar() { 122 | var aTabIsPaused = false; 123 | if (Tabs.some(function (Tab) { // forEach, but stops on return true 124 | // console.log('s: '+Tab.download.speed+' p: '+Tab.download.percent+' t: '+Tab.download.time+' z: '+Tab.download.paused); 125 | if (Tab.download.speed > 0 && Tab.queue.time > 0 && !Tab.download.paused) { 126 | self.port.emit('setIcon', { '16': './images/nzb-16-green.png', '32': './images/nzb-32-green.png', '64': './images/nzb-64-green.png' }); 127 | if (!progressWidgetVisible) 128 | showProgressWidget(); 129 | updateProgressWidget(Tab.download.percent, timeToStringS(Tab.queue.time), (Tab.queue.num > 1 ? Tab.queue.num : 'nzb')); 130 | return true; 131 | } else 132 | aTabIsPaused = aTabIsPaused || Tab.download.paused; 133 | }) == false) { 134 | // No tabs are downloading 135 | if (progressWidgetVisible) 136 | hideProgressWidget(); 137 | self.port.emit('setIcon', aTabIsPaused ? { '16': './images/nzb-16-orange.png', '32': './images/nzb-32-orange.png', '64': './images/nzb-64-orange.png' } : { '16': './images/nzb-16-gray.png', '32': './images/nzb-32-gray.png', '64': './images/nzb-64-gray.png' }) 138 | } 139 | } 140 | window.setInterval(updateToolbar, 2500); // 2.5 secs 141 | 142 | var progressWidgetVisible = false; 143 | function showProgressWidget() { 144 | self.port.emit('showProgressWidget'); 145 | progressWidgetVisible = true; 146 | } 147 | function hideProgressWidget() { 148 | self.port.emit('hideProgressWidget'); 149 | progressWidgetVisible = false; 150 | } 151 | function updateProgressWidget(percentage, timeleft, counter) { 152 | if (progressWidgetVisible) 153 | self.port.emit('updateProgressWidget', [percentage, timeleft, counter]); 154 | } 155 | 156 | function onPrefChange([prefName, prefValue]) { 157 | self.options.prefs[prefName] = prefValue; 158 | 159 | if (prefName == 'theme') 160 | $('#theme').attr('href', 'theme.' + self.options.prefs.theme + '.css'); 161 | else 162 | if (prefName == 'sab_enabled' || prefName == 'nzbg_enabled') { 163 | if (prefValue) { 164 | if (prefName == 'nzbg_enabled') 165 | new nzbgTab(); 166 | if (prefName == 'sab_enabled') 167 | new sabTab(); 168 | } else { 169 | for (var i = 0; i < Tabs.length; ++i) { 170 | if (Tabs[i] && ((prefName == 'sab_enabled' && Tabs[i].constructor.name == 'sabTab') || (prefName == 'nzbg_enabled' && Tabs[i].constructor.name == 'nzbgTab'))) { 171 | Tabs[i].remove(); 172 | delete Tabs[i]; 173 | } 174 | } 175 | } 176 | } 177 | } 178 | 179 | self.port.on('prefChange', onPrefChange); 180 | 181 | var panelVisible = false; 182 | self.port.on('show', function () { 183 | resize(); 184 | panelVisible = true; 185 | Tabs.forEach((Tab) => Tab.statusTimerInterval(self.options.prefs.refresh_active)); 186 | }); 187 | self.port.on('hide', function () { 188 | panelVisible = false; 189 | // Click on document to close open menus 190 | $(document).click(); 191 | // Set interval to idle unless client is downloading something 192 | Tabs.forEach((Tab) => Tab.statusTimerInterval(Tab.download.speed > 0 ? self.options.prefs.refresh_active : self.options.prefs.refresh_idle)); 193 | }); 194 | 195 | var Tabs = []; 196 | function Tab(type) { //// Tab Variables 197 | 198 | var _this = this; 199 | this.type = type; // can only be 'sab' or 'nzbg' 200 | // Get our ID 201 | this.id = Tabs.length; // Default to end of array 202 | for (var i = 0; i < Tabs.length; ++i) 203 | if (!Tabs[i]) { // recycle a previously used id 204 | this.id = i; 205 | break; 206 | } 207 | Tabs[this.id] = this; 208 | 209 | // The Tab 210 | this.header = $('
  • ').append($('', { href: '#tabs-' + this.id }).text($('div#' + type + '.template').attr('title'))).appendTo('#tabList'); 211 | this.content = $('
    ', { id: 'tabs-' + this.id }).appendTo('#tabs'); 212 | this.content.html($('div#' + type + '.template').html()); 213 | // Active Download Raw Values 214 | this.downloadDefaults = { 215 | id: '', 216 | paused: false, 217 | name: '', 218 | category: '', 219 | priority: '', 220 | age: '', 221 | time: 0, 222 | speed: 0, 223 | speedLimit: 0, 224 | sizeTotal: 0, 225 | sizeLeft: 0, 226 | percent: 0 227 | }; 228 | this.download = $.extend({}, this.downloadDefaults); 229 | this.queue = { num: 0, time: 0 }; 230 | // API 231 | this.apiVer = 1; // 1 = SAB 0.7.20 / NZBG v14 2 = SAB 1.0.0 232 | // Timers 233 | this.statusTimer; 234 | this.statusTimer_interval = self.options.prefs.refresh_active; 235 | this.historyTimer; 236 | this.historyTimer_interval = self.options.prefs.refresh_history; 237 | // Parse results 238 | this.lastStatus = {}; 239 | this.lastHistory = {}; 240 | this.lastHistoryID = ''; 241 | this.lastActiveID = ''; 242 | // Labels 243 | this.speedEle = this.content.find('#speed'); 244 | this.nameEle = this.content.find('#name'); 245 | this.timeEle = this.content.find('#time'); 246 | // Progress Bar 247 | this.progressBarEle = this.content.find('#progressBar').progressbar({ value: false }); 248 | this.progressLabelEle = this.content.find('#progressLabel'); 249 | // Activity Spinner 250 | this.activityEle = this.content.find('#activity').hide(); 251 | this.errorEle = this.content.find('#error'); 252 | // Buttons 253 | this.btnTogglePauseEle = this.content.find('#togglePause').button().click(() => _this.btnTogglePause_Click.call(_this)); 254 | this.btnRefreshEle = this.content.find('#refresh').button({ icons: { primary: 'ui-icon-refresh' } }).click(() => _this.btnRefresh_Click.call(_this)); 255 | this.btnShowMenuEle = this.content.find('#showMenu').button({ text: false, icons: { primary: 'ui-icon-triangle-1-n' } }).click(() => _this.btnShowMenu_Click.call(_this)); 256 | this.btnOpenEle = this.content.find('#open').button({ text: false, icons: { primary: 'ui-icon-newwin' } }).click(() => _this.btnOpen_Click.call(_this)).click(() => self.port.emit('hide')); 257 | // Action Menu 258 | this.menuEle = this.content.find('ul#menu').menu({ position: { my: 'left bottom', at: 'right bottom' } }).hide(); 259 | // Action Menu Items 260 | this.menuSpeedLimit = this.content.find('li#speedLimit').click(() => _this.menuSpeedLimit_Click.call(_this)); 261 | 262 | this.menuPauseFor = this.content.find('li#pause-custom').click(() => _this.menuPauseFor_Click.call(_this)); 263 | this.menuPauseFor5m = this.content.find('li#pause-5m').click(() => _this.pause.call(_this, 5)); 264 | this.menuPauseFor15m = this.content.find('li#pause-15m').click(() => _this.pause.call(_this, 15)); 265 | this.menuPauseFor30m = this.content.find('li#pause-30m').click(() => _this.pause.call(_this, 30)); 266 | this.menuPauseFor60m = this.content.find('li#pause-60m').click(() => _this.pause.call(_this, 60)); 267 | 268 | // Refresh UI and activate this tab 269 | this.content.find('#btnSet').buttonset(); 270 | $('#tabs').tabs('refresh'); 271 | $('#tabs').tabs('option', 'active', 0); 272 | 273 | // Start timers - initial delay of 2 secs for to firefox startup 274 | window.setTimeout(function () { 275 | _this.refreshStatus(); 276 | _this.refreshHistory(); 277 | }, 2000); 278 | } 279 | 280 | //// Tab PROTOTYPE functions //// 281 | // Click Events - Buttons 282 | Tab.prototype.btnTogglePause_Click = function () { if (this.download.paused) this.resume(); else this.pause(); } 283 | Tab.prototype.btnRefresh_Click = () => this.refreshStatus(); 284 | Tab.prototype.btnOpen_Click = function () { //child 285 | } 286 | Tab.prototype.btnShowMenu_Click = function () { 287 | this.menuEle.show().position({ my: 'left bottom', at: 'top right', of: this.btnShowMenuEle }); 288 | var _this = this 289 | $(document).one('click', () => _this.menuEle.hide()); 290 | return false; 291 | } 292 | // Click Events - Action Menu 293 | Tab.prototype.menuSpeedLimit_Click = function () { 294 | var _this = this; 295 | dialog.speedLimit.open(this.download.speedLimit, function () { 296 | var result = Number($(this).closest('.ui-dialog').find('input').val()); 297 | _this.setSpeedLimit(result); 298 | }); 299 | } 300 | Tab.prototype.menuPauseFor_Click = function () { 301 | var _this = this; 302 | dialog.pauseFor.open('', function () { 303 | var result = Number($(this).closest('.ui-dialog').find('input').val()); 304 | _this.pause(result); 305 | }); 306 | } 307 | // Timers 308 | Tab.prototype.statusTimerInterval = function (interval, startTimer = true) { 309 | if (typeof interval == 'undefined') return this.statusTimer_interval; else 310 | if (interval != this.statusTimer_interval || !this.statusTimer) { 311 | this.statusTimer_interval = interval; 312 | log(this.type + ' -> status interval set to ' + this.statusTimer_interval); 313 | if (startTimer) { 314 | this.stopStatusTimer(); 315 | this.startStatusTimer(); 316 | } 317 | } 318 | } 319 | Tab.prototype.startStatusTimer = function () { 320 | this.stopStatusTimer(); 321 | var _this = this; 322 | if (this.statusTimer_interval > 0) 323 | this.statusTimer = window.setTimeout(() => _this.refreshStatus.call(_this), this.statusTimer_interval * 1000); 324 | } 325 | Tab.prototype.startHistoryTimer = function () { 326 | this.stopHistoryTimer(); 327 | var _this = this; 328 | this.historyTimer = window.setTimeout(() => _this.refreshHistory.call(_this), this.historyTimer_interval * 1000); 329 | } 330 | Tab.prototype.stopStatusTimer = function () { 331 | window.clearTimeout(this.statusTimer); 332 | this.statusTimer = null; 333 | } 334 | Tab.prototype.stopHistoryTimer = function () { 335 | window.clearTimeout(this.historyTimer); 336 | this.historyTimer = null; 337 | } 338 | // API Actions 339 | Tab.prototype.onApiBeforeCall = function (call) { // General API pre-call handling 340 | this.activityEle.show().css('display', 'inline-block'); 341 | } 342 | Tab.prototype.onApiSuccess = function (call, reply) { // General API success handling 343 | this.error(''); 344 | this.activityEle.hide(); 345 | } 346 | Tab.prototype.onApiFailure = function (call, reply) { // General API failure handling 347 | this.error(reply.message); 348 | this.activityEle.hide(); 349 | } 350 | Tab.prototype.refreshStatus = function () { //child 351 | } 352 | Tab.prototype.parseStatus = function () { //child 353 | } 354 | Tab.prototype.onStatusParsed = function () { // Shared code for post-status parsing 355 | // Update Tab UI 356 | 357 | var nameStr = this.download.name == '' ? '' : this.download.name + ((this.download.category != '*' && this.download.category != '') ? ' (' + this.download.category + ')' : ''); 358 | var speedStr = bytesToReadable(this.download.speed * 1024, (this.download.speed > 1024 ? 1 : 0)) + '/s' + (this.download.speedLimit > 0 ? ' (' + bytesToReadable(this.download.speedLimit * 1024, (this.download.speedLimit > 1024 ? 1 : 0)) + '/s limit)' : ''); 359 | var timeStr = this.download.name == '' ? '' : (this.download.speed > 0 ? timeToStringL(this.download.time) : 'Unknown') + ' (' + bytesToReadable(this.download.sizeLeft * 1024 * 1024, (this.download.sizeLeft > 1024 ? 1 : 0)) + ')'; 360 | 361 | this.speedEle.text(speedStr); 362 | this.nameEle.text(nameStr); 363 | this.timeEle.text(timeStr); 364 | this.progressBarEle.progressbar('option', { value: this.download.percent }); 365 | this.progressLabelEle.text(this.download.percent + '%'); 366 | 367 | this.paused(this.download.paused); 368 | 369 | resize(); 370 | 371 | // Detect new download started 372 | if (this.download.id != this.lastActiveID && this.download.speed > 0) { 373 | this.lastActiveID = this.download.id; /// '---' = fetching NZB URL in SAB 374 | if (this.download.id != '' && this.download.age != '---' && self.options.prefs.dl_start_notifications && !panelVisible) { 375 | log('--- DOWNLOAD STARTED "' + name + '", id="' + this.download.id + '" lastid="' + this.lastActiveID + '"'); 376 | self.port.emit('showNotification', [this.type, 'Download Started', this.type + '-32.png', this.download.name, bytesToReadable(this.download.sizeTotal * 1024 * 1024, (this.download.sizeTotal > 1024 ? 1 : 0)) + ' / Category: ' + this.download.category + ' / Priority: ' + this.download.priority + ' / Age: ' + this.download.age]); 377 | } 378 | } 379 | if (this.download.speed > 0 && this.statusTimer_interval == self.options.prefs.refresh_idle) { 380 | // Client is downloading, but were on idle timer. Start active rate 381 | log(this.type + ' -> has gone active'); 382 | this.statusTimerInterval(self.options.prefs.refresh_active, false); // false = dont start timer, start is called after parse in refreshStatus 383 | } else 384 | if (this.download.speed == 0 && !panelVisible && this.statusTimer_interval == self.options.prefs.refresh_active) { 385 | // Client is not downloading, but were on active timer and the panel is not visible. Start idle rate 386 | log(this.type + ' -> has gone idle'); 387 | this.statusTimerInterval(self.options.prefs.refresh_idle, false); // false = dont start timer, start is called after parse in refreshStatus 388 | } 389 | } 390 | Tab.prototype.refreshHistory = function () { //child 391 | } 392 | Tab.prototype.parseHistory = function () {//child 393 | } 394 | Tab.prototype.pause = function (mins) { //child 395 | } 396 | Tab.prototype.resume = function () { //child 397 | } 398 | Tab.prototype.setSpeedLimit = function (kbps) { //child 399 | } 400 | // General Functions 401 | Tab.prototype.paused = function (paused) { // updates UI, called during status parse 402 | if (typeof paused == 'undefined') return this.download.paused; else { 403 | this.download.paused = paused; 404 | this.btnTogglePauseEle.button('option', { label: paused ? 'Resume' : 'Pause', icons: { primary: paused ? 'ui-icon-play' : 'ui-icon-pause' } }); 405 | this.btnTogglePauseEle.css('color', paused ? '#00FF00' : '#FF0000'); 406 | return paused; 407 | } 408 | } 409 | Tab.prototype.error = (message) => this.errorEle.html(message) 410 | Tab.prototype.remove = function () { 411 | window.clearTimeout(this.statusTimer); 412 | window.clearTimeout(this.historyTimer); 413 | this.header.remove(); 414 | this.content.remove(); 415 | $('#tabs').tabs('refresh'); 416 | } 417 | 418 | 419 | ////////////////// 420 | // SABnzbd+ Tab // 421 | ////////////////// 422 | sabTab.prototype = Object.create(Tab.prototype); 423 | sabTab.prototype.constructor = sabTab; 424 | function sabTab(type) { 425 | var _this = this; 426 | Tab.call(this, 'sab'); 427 | 428 | this.menuOnFinishNothing = this.content.find('li#finish-nothing').click(() => _this.setFinishAction.call(_this, '')); 429 | this.menuOnFinishShutdown = this.content.find('li#finish-shutdown').click(() => _this.setFinishAction.call(_this, 'shutdown_program')); 430 | this.menuOnFinishShutdownPC = this.content.find('li#finish-shutdownPC').click(() => _this.setFinishAction.call(_this, 'shutdown_pc')); 431 | this.menuOnFinishStandbyPC = this.content.find('li#finish-standbyPC').click(() => _this.setFinishAction.call(_this, 'standby_pc')); 432 | this.menuOnFinishHibernatePC = this.content.find('li#finish-hibernatePC').click(() => _this.setFinishAction.call(_this, 'hibernate_pc')); 433 | this.menuOnFinishScript = this.content.find('li#finish-script').click(() => _this.menuOnFinishScript_Click.call(_this)); 434 | 435 | } 436 | 437 | //// SABnzbd+ Tab PROTOTYPE functions //// 438 | // Click Events - Buttons 439 | sabTab.prototype.btnOpen_Click = function () { 440 | window.open(self.options.prefs.sab_url); 441 | } 442 | // Click Events - Action Menu 443 | sabTab.prototype.menuOnFinishScript_Click = function () { 444 | var _this = this; 445 | var options = []; 446 | for (var i = 0; i < this.lastStatus.queue.scripts.length; ++i) 447 | if (this.lastStatus.queue.scripts[i].endsWith('.py') || this.lastStatus.queue.scripts[i].endsWith('.bat') || this.lastStatus.queue.scripts[i].endsWith('.cmd')) 448 | options.push( 449 | $('