├── .gitignore ├── README.md ├── TODO.md ├── css ├── bootstrap-responsive.min.css ├── bootstrap.min.css └── main.css ├── favicon.ico ├── img ├── glyphicons-halflings-white.png └── glyphicons-halflings.png ├── index.html ├── js ├── aria2.js ├── bootstrap.min.js ├── jquery-1.7.2.min.js ├── jquery.Storage.js ├── jquery.base64.min.js ├── jquery.jsonrpc.js ├── mustache.js ├── peerid.js └── yaaw.js ├── offline.appcache └── yaaw.sublime-project /.gitignore: -------------------------------------------------------------------------------- 1 | *.class 2 | .* 3 | 4 | # Package Files # 5 | *.jar 6 | *.war 7 | *.ear 8 | /yaaw.sublime-workspace 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | YAAW 2 | ==== 3 | 汉化版地址:http://yaaw.1ge.fun/ 4 | 5 | Yet Another Aria2 Web Frontend in pure HTML/CSS/Javascirpt. 6 | 7 | No HTTP server, backend or server-side program. All you need is just a browser. 8 | 9 |
10 | 11 | Usage 12 | ----- 13 | 1. Run aria2 with RPC enabled 14 | > aria2c --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all -c -D 15 | > 16 | > Warning: This options will not verify the identity of caller. KEEP THE ADDRESS SECRET. 17 | 18 | 2. Visit **index.html**. 19 | 20 | 3. Change "JSON-RPC Path" setting if "Internal server error" occurred. 21 | 22 | Tips 23 | ---- 24 | * All your settings on web is temporary. **Settings will be lost after aria2 restarted.** 25 | * Tasks(including which is not finished) will be lost after aria2 restarted. Using `--save-session=SOME/WHERE` and reload with `--continue=true --input-file=SOME/WHERE` to continue. 26 | * Using `$HOME/.aria2/aria2.conf` to save your options. 27 | * For more infomations about aria2, visit [Aria2 Manual](http://aria2.sourceforge.net/manual/en/html/) 28 | 29 | Components 30 | ---------- 31 | + [Bootstrap](http://twitter.github.com/bootstrap/) 32 | + [mustache.js](https://github.com/janl/mustache.js) 33 | + [jQuery](http://jquery.com/) 34 | + [jQuery Storage](http://archive.plugins.jquery.com/project/html5Storage) 35 | + [JSON RPC 2.0 jQuery Plugin](https://github.com/datagraph/jquery-jsonrpc) 36 | 37 | License 38 | ------- 39 | yaaw is licensed under GNU Lesser General Public License. 40 | You may get a copy of the GNU Lesser General Public License from http://www.gnu.org/licenses/lgpl.txt 41 | 42 | 汉化 43 | ==== 44 | ghostry( https://blog.1ge.fun )部分汉化 45 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | TODO 2 | ==== 3 | -------------------------------------------------------------------------------- /css/bootstrap-responsive.min.css: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap Responsive v2.0.3 3 | * 4 | * Copyright 2012 Twitter, Inc 5 | * Licensed under the Apache License v2.0 6 | * http://www.apache.org/licenses/LICENSE-2.0 7 | * 8 | * Designed and built with all the love in the world @twitter by @mdo and @fat. 9 | */.clearfix{*zoom:1}.clearfix:before,.clearfix:after{display:table;content:""}.clearfix:after{clear:both}.hide-text{font:0/0 a;color:transparent;text-shadow:none;background-color:transparent;border:0}.input-block-level{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.hidden{display:none;visibility:hidden}.visible-phone{display:none!important}.visible-tablet{display:none!important}.hidden-desktop{display:none!important}@media(max-width:767px){.visible-phone{display:inherit!important}.hidden-phone{display:none!important}.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}}@media(min-width:768px) and (max-width:979px){.visible-tablet{display:inherit!important}.hidden-tablet{display:none!important}.hidden-desktop{display:inherit!important}.visible-desktop{display:none!important}}@media(max-width:480px){.nav-collapse{-webkit-transform:translate3d(0,0,0)}.page-header h1 small{display:block;line-height:18px}input[type="checkbox"],input[type="radio"]{border:1px solid #ccc}.form-horizontal .control-group>label{float:none;width:auto;padding-top:0;text-align:left}.form-horizontal .controls{margin-left:0}.form-horizontal .control-list{padding-top:0}.form-horizontal .form-actions{padding-right:10px;padding-left:10px}.modal{position:absolute;top:10px;right:10px;left:10px;width:auto;margin:0}.modal.fade.in{top:auto}.modal-header .close{padding:10px;margin:-10px}.carousel-caption{position:static}}@media(max-width:767px){body{padding-right:20px;padding-left:20px}.navbar-fixed-top,.navbar-fixed-bottom{margin-right:-20px;margin-left:-20px}.container-fluid{padding:0}.dl-horizontal dt{float:none;width:auto;clear:none;text-align:left}.dl-horizontal dd{margin-left:0}.container{width:auto}.row-fluid{width:100%}.row,.thumbnails{margin-left:0}[class*="span"],.row-fluid [class*="span"]{display:block;float:none;width:auto;margin-left:0}.input-large,.input-xlarge,.input-xxlarge,input[class*="span"],select[class*="span"],textarea[class*="span"],.uneditable-input{display:block;width:100%;min-height:28px;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.input-prepend input,.input-append input,.input-prepend input[class*="span"],.input-append input[class*="span"]{display:inline-block;width:auto}}@media(min-width:768px) and (max-width:979px){.row{margin-left:-20px;*zoom:1}.row:before,.row:after{display:table;content:""}.row:after{clear:both}[class*="span"]{float:left;margin-left:20px}.container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:724px}.span12{width:724px}.span11{width:662px}.span10{width:600px}.span9{width:538px}.span8{width:476px}.span7{width:414px}.span6{width:352px}.span5{width:290px}.span4{width:228px}.span3{width:166px}.span2{width:104px}.span1{width:42px}.offset12{margin-left:764px}.offset11{margin-left:702px}.offset10{margin-left:640px}.offset9{margin-left:578px}.offset8{margin-left:516px}.offset7{margin-left:454px}.offset6{margin-left:392px}.offset5{margin-left:330px}.offset4{margin-left:268px}.offset3{margin-left:206px}.offset2{margin-left:144px}.offset1{margin-left:82px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:28px;margin-left:2.762430939%;*margin-left:2.709239449638298%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:99.999999993%;*width:99.9468085036383%}.row-fluid .span11{width:91.436464082%;*width:91.38327259263829%}.row-fluid .span10{width:82.87292817100001%;*width:82.8197366816383%}.row-fluid .span9{width:74.30939226%;*width:74.25620077063829%}.row-fluid .span8{width:65.74585634900001%;*width:65.6926648596383%}.row-fluid .span7{width:57.182320438000005%;*width:57.129128948638304%}.row-fluid .span6{width:48.618784527%;*width:48.5655930376383%}.row-fluid .span5{width:40.055248616%;*width:40.0020571266383%}.row-fluid .span4{width:31.491712705%;*width:31.4385212156383%}.row-fluid .span3{width:22.928176794%;*width:22.874985304638297%}.row-fluid .span2{width:14.364640883%;*width:14.311449393638298%}.row-fluid .span1{width:5.801104972%;*width:5.747913482638298%}input,textarea,.uneditable-input{margin-left:0}input.span12,textarea.span12,.uneditable-input.span12{width:714px}input.span11,textarea.span11,.uneditable-input.span11{width:652px}input.span10,textarea.span10,.uneditable-input.span10{width:590px}input.span9,textarea.span9,.uneditable-input.span9{width:528px}input.span8,textarea.span8,.uneditable-input.span8{width:466px}input.span7,textarea.span7,.uneditable-input.span7{width:404px}input.span6,textarea.span6,.uneditable-input.span6{width:342px}input.span5,textarea.span5,.uneditable-input.span5{width:280px}input.span4,textarea.span4,.uneditable-input.span4{width:218px}input.span3,textarea.span3,.uneditable-input.span3{width:156px}input.span2,textarea.span2,.uneditable-input.span2{width:94px}input.span1,textarea.span1,.uneditable-input.span1{width:32px}}@media(min-width:1200px){.row{margin-left:-30px;*zoom:1}.row:before,.row:after{display:table;content:""}.row:after{clear:both}[class*="span"]{float:left;margin-left:30px}.container,.navbar-fixed-top .container,.navbar-fixed-bottom .container{width:1170px}.span12{width:1170px}.span11{width:1070px}.span10{width:970px}.span9{width:870px}.span8{width:770px}.span7{width:670px}.span6{width:570px}.span5{width:470px}.span4{width:370px}.span3{width:270px}.span2{width:170px}.span1{width:70px}.offset12{margin-left:1230px}.offset11{margin-left:1130px}.offset10{margin-left:1030px}.offset9{margin-left:930px}.offset8{margin-left:830px}.offset7{margin-left:730px}.offset6{margin-left:630px}.offset5{margin-left:530px}.offset4{margin-left:430px}.offset3{margin-left:330px}.offset2{margin-left:230px}.offset1{margin-left:130px}.row-fluid{width:100%;*zoom:1}.row-fluid:before,.row-fluid:after{display:table;content:""}.row-fluid:after{clear:both}.row-fluid [class*="span"]{display:block;float:left;width:100%;min-height:28px;margin-left:2.564102564%;*margin-left:2.510911074638298%;-webkit-box-sizing:border-box;-moz-box-sizing:border-box;-ms-box-sizing:border-box;box-sizing:border-box}.row-fluid [class*="span"]:first-child{margin-left:0}.row-fluid .span12{width:100%;*width:99.94680851063829%}.row-fluid .span11{width:91.45299145300001%;*width:91.3997999636383%}.row-fluid .span10{width:82.905982906%;*width:82.8527914166383%}.row-fluid .span9{width:74.358974359%;*width:74.30578286963829%}.row-fluid .span8{width:65.81196581200001%;*width:65.7587743226383%}.row-fluid .span7{width:57.264957265%;*width:57.2117657756383%}.row-fluid .span6{width:48.717948718%;*width:48.6647572286383%}.row-fluid .span5{width:40.170940171000005%;*width:40.117748681638304%}.row-fluid .span4{width:31.623931624%;*width:31.5707401346383%}.row-fluid .span3{width:23.076923077%;*width:23.0237315876383%}.row-fluid .span2{width:14.529914530000001%;*width:14.4767230406383%}.row-fluid .span1{width:5.982905983%;*width:5.929714493638298%}input,textarea,.uneditable-input{margin-left:0}input.span12,textarea.span12,.uneditable-input.span12{width:1160px}input.span11,textarea.span11,.uneditable-input.span11{width:1060px}input.span10,textarea.span10,.uneditable-input.span10{width:960px}input.span9,textarea.span9,.uneditable-input.span9{width:860px}input.span8,textarea.span8,.uneditable-input.span8{width:760px}input.span7,textarea.span7,.uneditable-input.span7{width:660px}input.span6,textarea.span6,.uneditable-input.span6{width:560px}input.span5,textarea.span5,.uneditable-input.span5{width:460px}input.span4,textarea.span4,.uneditable-input.span4{width:360px}input.span3,textarea.span3,.uneditable-input.span3{width:260px}input.span2,textarea.span2,.uneditable-input.span2{width:160px}input.span1,textarea.span1,.uneditable-input.span1{width:60px}.thumbnails{margin-left:-30px}.thumbnails>li{margin-left:30px}.row-fluid .thumbnails{margin-left:0}}@media(max-width:979px){body{padding-top:0}.navbar-fixed-top{position:static;margin-bottom:18px}.navbar-fixed-top .navbar-inner{padding:5px}.navbar .container{width:auto;padding:0}.navbar .brand{padding-right:10px;padding-left:10px;margin:0 0 0 -5px}.nav-collapse{clear:both}.nav-collapse .nav{float:none;margin:0 0 9px}.nav-collapse .nav>li{float:none}.nav-collapse .nav>li>a{margin-bottom:2px}.nav-collapse .nav>.divider-vertical{display:none}.nav-collapse .nav .nav-header{color:#999;text-shadow:none}.nav-collapse .nav>li>a,.nav-collapse .dropdown-menu a{padding:6px 15px;font-weight:bold;color:#999;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px}.nav-collapse .btn{padding:4px 10px 4px;font-weight:normal;-webkit-border-radius:4px;-moz-border-radius:4px;border-radius:4px}.nav-collapse .dropdown-menu li+li a{margin-bottom:2px}.nav-collapse .nav>li>a:hover,.nav-collapse .dropdown-menu a:hover{background-color:#222}.nav-collapse.in .btn-group{padding:0;margin-top:5px}.nav-collapse .dropdown-menu{position:static;top:auto;left:auto;display:block;float:none;max-width:none;padding:0;margin:0 15px;background-color:transparent;border:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.nav-collapse .dropdown-menu:before,.nav-collapse .dropdown-menu:after{display:none}.nav-collapse .dropdown-menu .divider{display:none}.nav-collapse .navbar-form,.nav-collapse .navbar-search{float:none;padding:9px 15px;margin:9px 0;border-top:1px solid #222;border-bottom:1px solid #222;-webkit-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);-moz-box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1);box-shadow:inset 0 1px 0 rgba(255,255,255,0.1),0 1px 0 rgba(255,255,255,0.1)}.navbar .nav-collapse .nav.pull-right{float:none;margin-left:0}.nav-collapse,.nav-collapse.collapse{height:0;overflow:hidden}.navbar .btn-navbar{display:block}.navbar-static .navbar-inner{padding-right:10px;padding-left:10px}}@media(min-width:980px){.nav-collapse.collapse{height:auto!important;overflow:visible!important}} 10 | -------------------------------------------------------------------------------- /css/main.css: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Binux 3 | * 4 | * This file is part of YAAW (https://github.com/binux/yaaw). 5 | * 6 | * YAAW is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * YAAW is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You may get a copy of the GNU Lesser General Public License 17 | * from http://www.gnu.org/licenses/lgpl.txt 18 | * 19 | */ 20 | 21 | .select-box { 22 | cursor: pointer; 23 | user-select: none; 24 | -moz-user-select: none; 25 | } 26 | .btn-inline { 27 | /* fix for MAC/chrome */ 28 | display: inline !important; 29 | } 30 | .btn-inline:before, .btn-inline:after { 31 | /* fix for IE8 */ 32 | content: none !important; 33 | display: none !important; 34 | } 35 | 36 | /* header */ 37 | .main-head { 38 | position: relative; 39 | } 40 | .main-head h1 { 41 | display: inline-block; 42 | } 43 | 44 | #main-alert { 45 | position: absolute; 46 | left: 0; 47 | width: 100%; 48 | text-align: center; 49 | } 50 | #main-alert-inline { 51 | display: inline-block; 52 | text-align: left; 53 | position: relative; 54 | top: -10px; 55 | z-index: 99; 56 | } 57 | 58 | #global-info { 59 | position: absolute; 60 | bottom: 0; 61 | right: 0; 62 | } 63 | #global-version { 64 | text-align: right; 65 | } 66 | 67 | /* main-control */ 68 | #main-control { 69 | margin-top: 10px; 70 | } 71 | 72 | #select-btn { 73 | margin-right: 30px; 74 | } 75 | .select-box { 76 | display: inline-block; 77 | vertical-align: text-top; 78 | border: 1px solid #C6C6C6; 79 | border: 1px solid rgba(155, 155, 155, .57); 80 | width: 14px; 81 | height: 14px; 82 | line-height: 14px; 83 | } 84 | 85 | #do-all-btn { 86 | position: relative; 87 | margin-left: 10px; 88 | } 89 | 90 | #info-btn { 91 | margin-left: 10px; 92 | } 93 | 94 | #other-grp { 95 | } 96 | 97 | /* active-tasks */ 98 | #active-tasks { 99 | margin-top: 40px; 100 | } 101 | .empty-tasks { 102 | text-align: center; 103 | padding: 8px; 104 | } 105 | .section-header { 106 | font-size: 16px; 107 | } 108 | .section-header i { 109 | margin-right: 5px; 110 | vertical-align: baseline; 111 | } 112 | 113 | /* other-tasks */ 114 | #other-tasks { 115 | margin-top: 40px; 116 | } 117 | #waiting-tasks-table { 118 | margin-bottom: 0; 119 | } 120 | #stopped-tasks-table { 121 | border-top: 0; 122 | margin-top: 0; 123 | } 124 | 125 | /* tasks */ 126 | .tasks-table { 127 | margin: 0; 128 | margin-top: 10px; 129 | } 130 | 131 | .task.selected { 132 | background-color: #F9F9F9; 133 | } 134 | .tasks-table > li { 135 | display: block; 136 | position: relative; 137 | margin-top: -1px; 138 | border-top: 1px solid #DDD; 139 | border-bottom: 1px solid #DDD; 140 | line-height: 18px; 141 | text-align: left; 142 | vertical-align: top; 143 | } 144 | .tasks-table > li:hover { 145 | background-color: #f5f5f5; 146 | } 147 | 148 | .left-area { 149 | position: relative; 150 | padding: 8px; 151 | } 152 | .right-area { 153 | position: absolute; 154 | top: 0; 155 | right: 0; 156 | padding: 8px; 157 | } 158 | 159 | .task .task-name { 160 | cursor: pointer; 161 | overflow: hidden; 162 | text-overflow: ellipsis; 163 | white-space: nowrap; 164 | } 165 | .task .task-name span { 166 | word-break: break-all; 167 | margin-left: 3px; 168 | font-size: 18px; 169 | font-weight: bold; 170 | } 171 | 172 | .task .task-name .select-box { 173 | vertical-align: -15%; 174 | } 175 | .task:hover .select-box { 176 | border-color: #666; 177 | } 178 | 179 | .task .task-info span { 180 | margin-right: 8px; 181 | } 182 | 183 | .task .task-info, 184 | .task .progress-info { 185 | margin-top: 4px; 186 | } 187 | .task .progress { 188 | margin: 1px 0; 189 | } 190 | 191 | .task .download-speed, 192 | .task .upload-speed, 193 | .task .seeders { 194 | margin-right: 8px; 195 | } 196 | 197 | #other-tasks .task-info { 198 | margin: 0; 199 | overflow: hidden; 200 | white-space: nowrap; 201 | } 202 | 203 | @media (max-height: 600px) { 204 | .modal.fade.in { 205 | position: absolute; 206 | top: 260px; 207 | } 208 | } 209 | 210 | @media (max-width: 550px) { 211 | .modal.fade.in { 212 | top: 60px; 213 | } 214 | .modal-body { 215 | max-height: none; 216 | } 217 | 218 | #main-alert { 219 | top: 25px; 220 | } 221 | 222 | #offline-cached { 223 | display: none; 224 | } 225 | 226 | #select-btn { 227 | margin-right: 10px; 228 | } 229 | #not-selected-grp { 230 | float: right; 231 | } 232 | #selected-grp { 233 | float: right; 234 | } 235 | #other-grp { 236 | clear: both; 237 | margin-top: 5px; 238 | } 239 | 240 | #active-tasks { 241 | margin-top: 20px; 242 | } 243 | #active-tasks .left-area { 244 | padding-bottom: 0; 245 | margin-right: 0; 246 | } 247 | .task .task-name { 248 | margin-right: 0; 249 | overflow: visible; 250 | white-space: normal; 251 | } 252 | #active-tasks .right-area { 253 | padding-top: 0; 254 | position: relative; 255 | width: auto; 256 | } 257 | 258 | #other-tasks .left-area { 259 | margin-right: 0; 260 | } 261 | #other-tasks .right-area { 262 | position: relative; 263 | padding-top: 0; 264 | } 265 | #other-tasks .right-area .task-info { 266 | position: absolute; 267 | top: 0; 268 | left: 0; 269 | } 270 | #other-tasks .right-area .pull-right { 271 | width: 100%; 272 | } 273 | #other-tasks .right-area .pull-right .progress { 274 | margin-left: 110px; 275 | } 276 | } 277 | @media (min-width: 551px) and (max-width: 980px) { 278 | #active-tasks .left-area { 279 | margin-right: 186px; 280 | } 281 | #active-tasks .right-area { 282 | width: 170px; 283 | } 284 | 285 | #other-tasks .left-area { 286 | margin-right: 246px; 287 | } 288 | #other-tasks .right-area { 289 | width: 230px; 290 | } 291 | #other-tasks .task-info { 292 | width: 120px; 293 | } 294 | #other-tasks .progress { 295 | width: 100px; 296 | } 297 | } 298 | @media (min-width: 980px) { 299 | #active-tasks .left-area { 300 | margin-right: 286px; 301 | } 302 | #active-tasks .right-area { 303 | width: 270px; 304 | } 305 | 306 | #other-tasks .left-area { 307 | margin-right: 416px; 308 | } 309 | #other-tasks .right-area { 310 | width: 400px; 311 | } 312 | #other-tasks .task-info { 313 | width: 190px; 314 | } 315 | #other-tasks .progress { 316 | width: 200px; 317 | } 318 | } 319 | 320 | /* task infobox */ 321 | .info-open { 322 | background-color: #F9F9F9; 323 | } 324 | .info-box { 325 | } 326 | .info-box .tab-content { 327 | height: 300px; 328 | overflow-y: auto; 329 | } 330 | .info-box .nav { 331 | margin-top: -1px; 332 | margin-bottom: 0; 333 | height: 300px; 334 | } 335 | #ib-status, 336 | #ib-options, 337 | #ib-peers { 338 | position: relative; 339 | margin: 18px 0; 340 | } 341 | #ib-files .file-list { 342 | margin-left: -25px; 343 | } 344 | #ib-files ul, 345 | #ib-options ul { 346 | margin-top: 5px; 347 | } 348 | #ib-files li { 349 | display: block; 350 | cursor: pointer; 351 | line-height: 14px; 352 | padding-bottom: 6px; 353 | vertical-align: top; 354 | border-bottom: 1px solid #FFF; 355 | } 356 | #ib-files .ib-file-title:hover { 357 | border-bottom: 1px solid #666; 358 | } 359 | #ib-file-btn, 360 | #ib-options-btn { 361 | float: right !important; 362 | margin: 0 0 5px 5px; 363 | } 364 | @media (max-width: 980px) { 365 | #ib-file-btn, #ib-options-btn { 366 | float: none !important; 367 | margin-bottom: 5px; 368 | } 369 | } 370 | .ib-file-title { 371 | margin-left: 5px; 372 | } 373 | .ib-file-size { 374 | margin-left: 20px; 375 | } 376 | #ib-options li { 377 | display: block; 378 | float: left; 379 | padding-bottom: 6px; 380 | margin-right: 100px; 381 | } 382 | #ib-options li span { 383 | display: block; 384 | text-align: right; 385 | padding-right: 1em; 386 | width: 140px; 387 | line-height: 24px; 388 | } 389 | #ib-options li > * { 390 | float: left; 391 | } 392 | #ib-peers .ip_port { 393 | display: inline-block; 394 | width: 250px; 395 | } 396 | 397 | /* task-contextmenu */ 398 | 399 | #task-contextmenu { 400 | position: fixed; 401 | z-index: 99; 402 | } 403 | #task-contextmenu li > a { 404 | user-select: none; 405 | -moz-user-select: none; 406 | } 407 | 408 | /* add task modal */ 409 | #add-task-modal { 410 | overflow-x: hidden; 411 | } 412 | #add-task-modal .modal-body.hover { 413 | padding: 13px; 414 | border: 2px solid #666; 415 | } 416 | 417 | #add-task-uri { 418 | text-align: center; 419 | white-space: nowrap; 420 | padding: 10px 19px; 421 | margin: 0; 422 | overflow: hidden; 423 | } 424 | #add-task-uri div { 425 | padding-right: 118px; 426 | } 427 | #uri-input { 428 | width: 100%; 429 | } 430 | #uri-textarea { 431 | box-sizing: border-box; 432 | -moz-box-sizing: border-box; 433 | width: 100%; 434 | margin: 0; 435 | } 436 | 437 | #uri-more { 438 | font-size: 7px; 439 | text-align: center; 440 | height: 10px; 441 | margin: 0 20px 20px; 442 | line-height: 10px; 443 | color: #DDD; 444 | background-color: whiteSmoke; 445 | cursor: pointer; 446 | } 447 | #uri-more:hover { 448 | background-color: #DDD; 449 | color: #999; 450 | } 451 | 452 | #torrent-up-input { 453 | position: absolute; 454 | top: 0; 455 | left: 0; 456 | text-align: right; 457 | height: 100%; 458 | width: 100%; 459 | -moz-opacity: 0; 460 | filter: alpha(opacity: 0); 461 | opacity: 0; 462 | z-index: 2; 463 | cursor: pointer; 464 | } 465 | #torrent-up-btn { 466 | position: relative; 467 | } 468 | 469 | #add-task-alert { 470 | position: relative; 471 | top: 5px; 472 | } 473 | 474 | #add-task-option { 475 | padding: 0 50px 0 20px; 476 | } 477 | @media (max-width: 480px) { 478 | #add-task-option { 479 | padding: 0 10px 0 20px; 480 | } 481 | } 482 | #add-task-option .controls { 483 | padding-right: 10px; 484 | } 485 | #add-task-option .input-xlarge { 486 | width: 100%; 487 | } 488 | #add-task-option .half { 489 | float: left; 490 | width: 220px; 491 | } 492 | #add-task-option .control-label { 493 | width: 70px; 494 | } 495 | #add-task-option .controls { 496 | margin-left: 85px; 497 | } 498 | 499 | /* aria2 global setting */ 500 | #copyright { 501 | margin-top: 10px; 502 | float: left; 503 | } 504 | #setting-form .rpc-path-group .controls { 505 | padding-right: 70px; 506 | } 507 | @media (max-width: 480px) { 508 | #setting-form .rpc-path-group .controls { 509 | padding-right: 35px; 510 | } 511 | } 512 | #setting-form .rpc-path-wrap { 513 | padding-right: 34px; 514 | width: 100%; 515 | } 516 | #setting-form .rpc-path-wrap .add-on { 517 | position: absolute; 518 | right: 1px; 519 | } 520 | #rpc-path { 521 | width: 100%; 522 | height: 28px; 523 | box-sizing: border-box; 524 | -moz-box-sizing: border-box; 525 | } 526 | #aria2-gs-form { 527 | margin-right: 30px; 528 | } 529 | @media (max-width: 480px) { 530 | #aria2-gs-form { 531 | margin-right: 0; 532 | } 533 | } 534 | #aria2-gs-form .controls { 535 | padding-right: 10px; 536 | } 537 | #aria2-gs-form .input-xlarge { 538 | width: 100%; 539 | } 540 | #aria2-gs-form .half { 541 | float: left; 542 | width: 240px; 543 | margin-left: 10px; 544 | } 545 | #aria2-gs-form .half .control-label { 546 | width: 110px; 547 | } 548 | #aria2-gs-form .half .controls { 549 | margin-left: 130px; 550 | padding-right: 0; 551 | } 552 | 553 | /* vim: set et sw=4 ts=4 sts=4 fdm=marker ff=unix fenc=utf8: */ 554 | -------------------------------------------------------------------------------- /favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ghostry/yaaw/dd9c9d055d8fcd14ff2c2874f5c8ac7b4ccbf562/favicon.ico -------------------------------------------------------------------------------- /img/glyphicons-halflings-white.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ghostry/yaaw/dd9c9d055d8fcd14ff2c2874f5c8ac7b4ccbf562/img/glyphicons-halflings-white.png -------------------------------------------------------------------------------- /img/glyphicons-halflings.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ghostry/yaaw/dd9c9d055d8fcd14ff2c2874f5c8ac7b4ccbf562/img/glyphicons-halflings.png -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 22 | 23 | Yet Another Aria2 Web Frontend 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 34 | 35 | 36 |
37 | 45 | 46 |
47 |
48 |
49 | × 50 | Loading 51 |
52 |
53 | 54 |
55 |
56 | 59 | 60 | 61 | 62 | 68 |
69 |
70 | 71 |
72 | 77 | 88 |
89 | 90 |
91 | 102 | 103 | 104 | 105 |
106 | 107 |
108 | 116 |
117 |
118 | 119 |
120 |
121 | 下载中 122 |
123 |
    124 |
  • 125 |
    126 | No Active Tasks 127 |
    128 |
  • 129 |
130 |
131 | 132 |
133 |
134 | 其他 135 |
136 |
    137 |
  • 138 |
    139 | No Tasks 140 |
    141 |
  • 142 |
143 |
144 |
145 |
146 | 147 | 158 | 159 | 183 | 184 | 242 | 243 | 248 | 249 | 285 | 286 | 311 | 312 | 336 | 337 | 351 | 352 | 359 | 360 | 373 | 374 | 379 | 380 | 387 | 388 | 455 | 456 | 499 | 500 | 501 | 502 | 503 | 504 | 505 | 506 | 507 | 508 | 509 | 510 | 511 | 512 | -------------------------------------------------------------------------------- /js/aria2.js: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 Binux 3 | * 4 | * This file is part of YAAW (https://github.com/binux/yaaw). 5 | * 6 | * YAAW is free software: you can redistribute it and/or modify 7 | * it under the terms of the GNU Lesser General Public License as 8 | * published by the Free Software Foundation, either version 3 of 9 | * the License, or (at your option) any later version. 10 | * 11 | * YAAW is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 | * GNU Lesser General Public License for more details. 15 | * 16 | * You may get a copy of the GNU Lesser General Public License 17 | * from http://www.gnu.org/licenses/lgpl.txt 18 | * 19 | */ 20 | 21 | if (typeof ARIA2=="undefined"||!ARIA2) var ARIA2=(function(){ 22 | var jsonrpc_interface, jsonrpc_protocol, jsonrpc_ws, interval_id, rpc_secret = null, 23 | unique_id = 0, ws_callback = {}; 24 | var active_tasks_snapshot="", finished_tasks_list=undefined, tasks_cnt_snapshot="", select_lock=false, need_refresh=false; 25 | var auto_refresh=false; 26 | 27 | function get_error(result) { 28 | if (typeof result == "string") 29 | return result; 30 | else if (typeof result.error == "string") 31 | return result.error; 32 | else if (result.error && result.error.message) 33 | return result.error.message; 34 | } 35 | 36 | function default_error(result) { 37 | //console.debug(result); 38 | 39 | var error_msg = get_error(result); 40 | 41 | $("#main-alert .alert").attr("class", "alert alert-error"); 42 | $("#main-alert .alert-msg").html("Error: "+error_msg); 43 | $("#main-alert").show(); 44 | } 45 | 46 | function main_alert(_class, msg, timeout) { 47 | var msg_id = (new Date()).getTime(); 48 | $("#main-alert .alert").attr("class", "alert "+_class); 49 | $("#main-alert .alert-msg").html(msg); 50 | $("#main-alert").data("msg_id", msg_id).show(); 51 | if (timeout) { 52 | window.setTimeout(function() { 53 | if($("#main-alert").data("msg_id") == msg_id) { 54 | $("#main-alert").fadeOut(); 55 | } 56 | }, timeout); 57 | } 58 | return msg_id; 59 | } 60 | 61 | function bind_event(dom) { 62 | dom.find("[rel=tooltip]").tooltip({"placement": "bottom", trigger : 'hover'}); 63 | } 64 | 65 | function get_title(result) { 66 | var dir = result.dir; 67 | var title = "Unknown"; 68 | if (result.bittorrent && result.bittorrent.info && result.bittorrent.info.name) 69 | title = result.bittorrent.info.name; 70 | else if (result.files[0].path && result.files[0].path.replace( 71 | new RegExp("^"+dir.replace(/\\/g, "/").replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')+"/?"), "").split("/").length) { 72 | title = result.files[0].path.replace(new RegExp("^"+dir.replace(/\\/g, "/").replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&')+"/?"), "").split("/"); 73 | if (result.bittorrent) 74 | title = title[0]; 75 | else 76 | title = title[title.length-1]; 77 | } else if (result.files.length && result.files[0].uris.length && result.files[0].uris[0].uri) 78 | title = result.files[0].uris[0].uri; 79 | 80 | if (result.files.length > 1) { 81 | var cnt = 0; 82 | for (var i=0; i 1) 87 | title += " ("+cnt+ " files..)" 88 | } 89 | return title; 90 | } 91 | 92 | function request_auth(url) { 93 | return url.match(/^(?:(?![^:@]+:[^:@\/]*@)[^:\/?#.]+:)?(?:\/\/)?(?:([^:@]*(?::[^:@]*)?)?@)?/)[1]; 94 | } 95 | function remove_auth(url) { 96 | return url.replace(/^((?![^:@]+:[^:@\/]*@)[^:\/?#.]+:)?(\/\/)?(?:(?:[^:@]*(?::[^:@]*)?)?@)?(.*)/, '$1$2$3'); 97 | } 98 | 99 | return { 100 | init: function(path, onready) { 101 | var connect_msg_id = main_alert("alert-info", "connecting..."); 102 | $("#add-task-option-wrap").empty().append(YAAW.tpl.add_task_option({})); 103 | $("#aria2-gsetting").empty().append(YAAW.tpl.aria2_global_setting({})); 104 | 105 | jsonrpc_interface = path || location.protocol+"//"+(location.host.split(":")[0]||"localhost")+":6800"+"/jsonrpc"; 106 | var auth_str = request_auth(jsonrpc_interface); 107 | if (auth_str && auth_str.indexOf('token:') == 0) { 108 | rpc_secret = auth_str; 109 | jsonrpc_interface = remove_auth(jsonrpc_interface); 110 | } 111 | 112 | if (jsonrpc_interface.indexOf("http") == 0) { 113 | jsonrpc_protocol = "http"; 114 | $.jsonRPC.setup({endPoint: jsonrpc_interface, namespace: 'aria2'}); 115 | ARIA2.request = ARIA2.request_http; 116 | ARIA2.batch_request = ARIA2.batch_request_http; 117 | if (onready) onready(); 118 | if ($("#main-alert").data("msg_id") == connect_msg_id) { 119 | $("#main-alert").fadeOut(); 120 | } 121 | } else if (jsonrpc_interface.indexOf("ws") == 0 && WebSocket) { 122 | jsonrpc_protocol = "ws" 123 | jsonrpc_ws = new WebSocket(jsonrpc_interface); 124 | jsonrpc_ws.onmessage = function(event) { 125 | var data = JSON.parse(event.data); 126 | //console.debug(data); 127 | if ($.isArray(data) && data.length) { 128 | var id = data[0].id; 129 | if (ws_callback[id]) { 130 | ws_callback[id].success(data); 131 | delete ws_callback[id]; 132 | } 133 | } else { 134 | if (ws_callback[data.id]) { 135 | if (data.error) 136 | ws_callback[data.id].error(data); 137 | else 138 | ws_callback[data.id].success(data); 139 | delete ws_callback[data.id]; 140 | }; 141 | }; 142 | }; 143 | jsonrpc_ws.onerror = function(event) { 144 | console.warn("error", event); 145 | main_alert("alert-error", "websocket error. you may need reflush this page to restart."); 146 | ws_callback = {}; 147 | }; 148 | jsonrpc_ws.onopen = function() { 149 | ARIA2.request = ARIA2.request_ws; 150 | ARIA2.batch_request = ARIA2.batch_request_ws; 151 | if (onready) onready(); 152 | if ($("#main-alert").data("msg_id") == connect_msg_id) { 153 | $("#main-alert").fadeOut(); 154 | } 155 | }; 156 | } else { 157 | main_alert("alert-error", "Unknown protocol"); 158 | }; 159 | }, 160 | 161 | request: function(){}, 162 | batch_request: function(){}, 163 | 164 | request_http: function(method, params, success, error) { 165 | if (error == undefined) 166 | error = default_error; 167 | if (rpc_secret) { 168 | params = params || []; 169 | if (!$.isArray(params)) params = [params]; 170 | params.unshift(rpc_secret); 171 | } 172 | $.jsonRPC.request(method, {params:params, success:success, error:error}); 173 | }, 174 | 175 | batch_request_http: function(method, params, success, error) { 176 | if (error == undefined) 177 | error = default_error; 178 | var commands = new Array(); 179 | $.each(params, function(i, n) { 180 | n = n || []; 181 | if (!$.isArray(n)) n = [n]; 182 | if (rpc_secret) { 183 | n.unshift(rpc_secret); 184 | } 185 | commands.push({method: method, params: n}); 186 | }); 187 | $.jsonRPC.batchRequest(commands, {success:success, error:error}); 188 | }, 189 | 190 | _request_data: function(method, params, id) { 191 | var dataObj = { 192 | jsonrpc: '2.0', 193 | method: 'aria2.'+method, 194 | id: id 195 | } 196 | if(typeof(params) !== 'undefined') { 197 | dataObj.params = params; 198 | } 199 | return dataObj; 200 | }, 201 | 202 | _get_unique_id: function() { 203 | ++unique_id; 204 | return unique_id; 205 | }, 206 | 207 | request_ws: function(method, params, success, error) { 208 | var id = ARIA2._get_unique_id(); 209 | ws_callback[id] = { 210 | 'success': success || function(){}, 211 | 'error': error || default_error, 212 | }; 213 | if (rpc_secret) { 214 | params = params || []; 215 | if (!$.isArray(params)) params = [params]; 216 | params.unshift(rpc_secret); 217 | } 218 | jsonrpc_ws.send(JSON.stringify(ARIA2._request_data(method, params, id))); 219 | }, 220 | 221 | batch_request_ws: function(method, params, success, error) { 222 | var data = []; 223 | var id = ARIA2._get_unique_id(); 224 | ws_callback[id] = { 225 | 'success': success || function(){}, 226 | 'error': error || default_error, 227 | }; 228 | for (var i=0,l=params.length; i"); 287 | $("#add-task-alert .alert-msg").html(error_msg); 288 | $("#add-task-alert").show(); 289 | console.warn("add task error: "+error_msg); 290 | } 291 | } 292 | ); 293 | }, 294 | 295 | add_torrent: function(torrent, options) { 296 | if (!torrent) return false; 297 | if (!options) options = {}; 298 | ARIA2.request("addTorrent", [torrent, [], options], 299 | function(result) { 300 | //console.debug(result); 301 | ARIA2.refresh(); 302 | $("#add-task-modal").modal('hide'); 303 | YAAW.add_task.clean(); 304 | }, 305 | function(result) { 306 | //console.debug(result); 307 | 308 | var error_msg = get_error(result); 309 | 310 | $("#add-task-alert .alert-msg").text(error_msg); 311 | $("#add-task-alert").show(); 312 | console.warn("add task error: "+error_msg); 313 | }); 314 | }, 315 | 316 | add_metalink: function(metalink, options) { 317 | if (!metalink) return false; 318 | if (!options) options = {}; 319 | ARIA2.request("addMetalink", [metalink, [], options], 320 | function(result) { 321 | //console.debug(result); 322 | ARIA2.refresh(); 323 | $("#add-task-modal").modal('hide'); 324 | YAAW.add_task.clean(); 325 | }, 326 | function(result) { 327 | //console.debug(result); 328 | 329 | var error_msg = get_error(result); 330 | 331 | $("#add-task-alert .alert-msg").text(error_msg); 332 | $("#add-task-alert").show(); 333 | console.warn("add task error: "+error_msg); 334 | }); 335 | }, 336 | 337 | restart_task: function(gids) { 338 | if (!$.isArray(gids)) gids = [gids]; 339 | $.each(gids, function(n, gid) { 340 | var result = $("#task-gid-"+gid).data("raw"); 341 | var uris = []; 342 | $.each(result.files, function(n, e) { 343 | if (e.uris.length) 344 | uris.push(e.uris[0].uri); 345 | }); 346 | if (result.bittorrent) { 347 | var magnet_link = "magnet:?xt=urn:btih:"+result.infoHash; 348 | if (result.bittorrent.info.name) 349 | magnet_link += "&dn="+result.bittorrent.info.name; 350 | if (result.bittorrent.announceList.length) 351 | magnet_link += "&tr="+result.bittorrent.announceList.join("&tr="); 352 | uris.push(magnet_link); 353 | } 354 | if (uris.length > 0) { 355 | ARIA2.request("getOption", [gid], function(result) { 356 | var options = result.result; 357 | ARIA2.madd_task(uris, options); 358 | }); 359 | } 360 | }); 361 | }, 362 | 363 | tell_active: function(keys) { 364 | if (select_lock) return; 365 | ARIA2.request("tellActive", keys, 366 | function(result) { 367 | //console.debug(result); 368 | 369 | if (select_lock) return; 370 | if (!result.result) { 371 | main_alert("alert-error", "Error: rpc result error.", 5000); 372 | } 373 | 374 | var snapshot = new Array(); 375 | $.each(result.result, function(i, e) { 376 | snapshot.push(e.gid); 377 | }); 378 | if (snapshot.sort().join(",") != active_tasks_snapshot) { 379 | active_tasks_snapshot = snapshot.sort().join(","); 380 | need_refresh = true; 381 | if (auto_refresh && !select_lock) 382 | ARIA2.refresh(); 383 | } 384 | 385 | result = ARIA2.status_fix(result.result); 386 | $("#active-tasks-table").empty().append(YAAW.tpl.active_task({"tasks": result})); 387 | $.each(result, function(n, e) { 388 | $("#task-gid-"+e.gid).data("raw", e); 389 | }); 390 | bind_event($("#active-tasks-table")) 391 | } 392 | ); 393 | }, 394 | 395 | check_active_list: function() { 396 | ARIA2.request("tellActive", [["gid"]], 397 | function(result) { 398 | //console.debug(result); 399 | 400 | if (!result.result) { 401 | main_alert("alert-error", "Error: rpc result error.", 5000); 402 | } 403 | 404 | var snapshot = new Array(); 405 | $.each(result.result, function(i, e) { 406 | snapshot.push(e.gid); 407 | }); 408 | if (snapshot.sort().join(",") != active_tasks_snapshot) { 409 | active_tasks_snapshot = snapshot.sort().join(","); 410 | need_refresh = true; 411 | if (auto_refresh && !select_lock) 412 | ARIA2.refresh(); 413 | } 414 | } 415 | ); 416 | }, 417 | 418 | tell_waiting: function(keys) { 419 | if (select_lock) return; 420 | var params = [0, 1000]; 421 | if (keys) params.push(keys); 422 | ARIA2.request("tellWaiting", params, 423 | function(result) { 424 | if (select_lock) return; 425 | if (!result.result) { 426 | main_alert("alert-error", "Error: rpc result error.", 5000); 427 | } 428 | 429 | result = ARIA2.status_fix(result.result); 430 | $("#waiting-tasks-table").empty().append(YAAW.tpl.other_task({"tasks": result})); 431 | $.each(result, function(n, e) { 432 | $("#task-gid-"+e.gid).data("raw", e); 433 | }); 434 | bind_event($("#waiting-tasks-table")) 435 | 436 | if ($("#other-tasks .task").length == 0) 437 | $("#waiting-tasks-table").append($("#other-task-empty").text()) 438 | } 439 | ); 440 | }, 441 | 442 | tell_stopped: function(keys) { 443 | if (select_lock) return; 444 | var params = [0, 1000]; 445 | if (keys) params.push(keys); 446 | ARIA2.request("tellStopped", params, 447 | function(result) { 448 | //console.debug(result); 449 | if (select_lock) return; 450 | 451 | if (!result.result) { 452 | main_alert("alert-error", "Error: rpc result error.", 5000); 453 | } 454 | 455 | result = ARIA2.status_fix(result.result); 456 | 457 | if (finished_tasks_list === undefined) { 458 | finished_tasks_list = new Array(); 459 | $.each(result, function(i, e) { 460 | if (e.status != "complete") 461 | return; 462 | finished_tasks_list.push(e.gid); 463 | }); 464 | } else { 465 | $.each(result, function(i, e) { 466 | if (e.status != "complete") 467 | return; 468 | if (finished_tasks_list.indexOf(e.gid) != -1) 469 | return; 470 | if (ARIA2.finish_notification) { 471 | YAAW.notification("Aria2 Task Finished", e.title); 472 | } 473 | finished_tasks_list.push(e.gid); 474 | }); 475 | } 476 | 477 | $("#stopped-tasks-table").empty().append(YAAW.tpl.other_task({"tasks": result.reverse()})); 478 | $.each(result, function(n, e) { 479 | $("#task-gid-"+e.gid).data("raw", e); 480 | }); 481 | bind_event($("#stopped-tasks-table")) 482 | 483 | if ($("#waiting-tasks-table .empty-tasks").length > 0 && 484 | $("#stopped-tasks-table .task").length > 0) { 485 | $("#waiting-tasks-table").empty(); 486 | } 487 | 488 | } 489 | ); 490 | }, 491 | 492 | status_fix: function(results) { 493 | for (var i=0; i"), 3000); 563 | } 564 | } 565 | ); 566 | }, 567 | 568 | unpause: function(gids) { 569 | if (!$.isArray(gids)) gids = [gids]; 570 | ARIA2.batch_request("unpause", gids, 571 | function(result) { 572 | //console.debug(result); 573 | 574 | var error = new Array(); 575 | $.each(result, function(i, n) { 576 | var error_msg = get_error(n); 577 | if (error_msg) error.push(error_msg); 578 | }); 579 | 580 | if (error.length == 0) { 581 | main_alert("alert-info", "Started", 1000); 582 | ARIA2.refresh(); 583 | } else { 584 | main_alert("alert-error", error.join("
"), 3000); 585 | } 586 | } 587 | ); 588 | }, 589 | 590 | remove: function(gids) { 591 | if (!$.isArray(gids)) gids = [gids]; 592 | ARIA2.batch_request("remove", gids, 593 | function(result) { 594 | //console.debug(result); 595 | 596 | var error = new Array(); 597 | $.each(result, function(i, n) { 598 | var error_msg = get_error(n); 599 | if (error_msg) error.push(error_msg); 600 | }); 601 | 602 | if (error.length == 0) { 603 | main_alert("alert-info", "Removed", 1000); 604 | ARIA2.refresh(); 605 | } else { 606 | main_alert("alert-error", error.join("
"), 3000); 607 | } 608 | } 609 | ); 610 | }, 611 | 612 | remove_result: function(gids) { 613 | if (!$.isArray(gids)) gids = [gids]; 614 | ARIA2.batch_request("removeDownloadResult", gids, 615 | function(result) { 616 | //console.debug(result); 617 | 618 | var error = new Array(); 619 | $.each(result, function(i, n) { 620 | var error_msg = get_error(n); 621 | if (error_msg) error.push(error_msg); 622 | }); 623 | 624 | if (error.length == 0) { 625 | main_alert("alert-info", "Removed", 1000); 626 | ARIA2.tell_stopped(); 627 | } else { 628 | main_alert("alert-error", error.join("
"), 3000); 629 | } 630 | } 631 | ); 632 | }, 633 | 634 | get_options: function(gid) { 635 | ARIA2.request("getOption", [gid], 636 | function(result) { 637 | //console.debug(result); 638 | 639 | $("#ib-options").empty().append(YAAW.tpl.ib_options(result.result)); 640 | if ($("#task-gid-"+gid).attr("data-status") == "active") 641 | $("#ib-options-form *[name]:not(.active-allowed)").attr("disabled", true); 642 | } 643 | ); 644 | }, 645 | 646 | change_options: function(gid, options) { 647 | ARIA2.request("changeOption", [gid, options], 648 | function(result) { 649 | //console.debug(result); 650 | 651 | main_alert("alert-info", "option updated", 1000); 652 | } 653 | ); 654 | }, 655 | 656 | get_peers: function(gid) { 657 | ARIA2.request("getPeers", [gid], 658 | function(result) { 659 | console.debug(result); 660 | 661 | $("#ib-peers").empty().append(YAAW.tpl.ib_peers(result.result)); 662 | } 663 | ); 664 | }, 665 | 666 | pause_all: function() { 667 | ARIA2.request("pauseAll", [], 668 | function(result) { 669 | //console.debug(result); 670 | 671 | ARIA2.refresh(); 672 | main_alert("alert-info", "Paused all tasks. Please wait for action such as contacting BitTorrent tracker.", 2000); 673 | } 674 | ); 675 | }, 676 | 677 | unpause_all: function() { 678 | ARIA2.request("unpauseAll", [], 679 | function(result) { 680 | //console.debug(result); 681 | 682 | ARIA2.refresh(); 683 | main_alert("alert-info", "Unpaused all tasks.", 2000); 684 | } 685 | ); 686 | }, 687 | 688 | purge_download_result: function() { 689 | ARIA2.request("purgeDownloadResult", [], 690 | function(result) { 691 | //console.debug(result); 692 | 693 | ARIA2.refresh(); 694 | main_alert("alert-info", "Removed all completed/error/removed downloads tasks.", 2000); 695 | } 696 | ); 697 | }, 698 | 699 | get_global_option: function() { 700 | ARIA2.request("getGlobalOption", [], 701 | function(result) { 702 | if (!result.result) 703 | main_alert("alert-error", "Error: rpc result error.", 5000); 704 | 705 | result = result.result; 706 | $("#aria2-gsetting").empty().append(YAAW.tpl.aria2_global_setting(result)); 707 | } 708 | ); 709 | }, 710 | 711 | init_add_task_option: function() { 712 | ARIA2.request("getGlobalOption", [], 713 | function(result) { 714 | if (!result.result) 715 | main_alert("alert-error", "Error: rpc result error.", 5000); 716 | 717 | result = result.result; 718 | result["parameterized-uri"] = (result["parameterized-uri"] == "true" ? true : false) 719 | $("#add-task-option-wrap").empty().append(YAAW.tpl.add_task_option(result)); 720 | } 721 | ); 722 | }, 723 | 724 | change_global_option: function(options) { 725 | ARIA2.request("changeGlobalOption", [options], 726 | function(result) { 727 | if (!result.result) 728 | main_alert("alert-error", "Error: rpc result error.", 5000); 729 | else 730 | main_alert("alert-success", "Saved", 2000); 731 | } 732 | ); 733 | }, 734 | 735 | global_stat: function() { 736 | ARIA2.request("getGlobalStat", [], 737 | function(result) { 738 | if (!result.result) { 739 | main_alert("alert-error", "Error: rpc result error.", 5000); 740 | } 741 | 742 | result = result.result; 743 | var _tasks_cnt_snapshot = ""+result.numActive+","+result.numWaiting+","+result.numStopped; 744 | 745 | if (_tasks_cnt_snapshot != tasks_cnt_snapshot) { 746 | tasks_cnt_snapshot = _tasks_cnt_snapshot; 747 | need_refresh = true; 748 | if (auto_refresh && !select_lock) 749 | ARIA2.refresh(); 750 | } 751 | 752 | $("#global-speed").empty().append(YAAW.tpl.global_speed(result)); 753 | var title = "↓"+YAAW.tpl.view.format_size_0()(result.downloadSpeed); 754 | if (result.uploadSpeed > 0) 755 | title += " ↑"+YAAW.tpl.view.format_size_0()(result.uploadSpeed); 756 | title += " - Yet Another Aria2 Web Frontend"; 757 | document.title = title; 758 | } 759 | ); 760 | }, 761 | 762 | get_version: function() { 763 | ARIA2.request("getVersion", [], 764 | function(result) { 765 | if (!result.result) { 766 | main_alert("alert-error", "Error: rpc result error.", 5000); 767 | } 768 | 769 | $("#global-version").text("Aria2 "+result.result.version || ""); 770 | } 771 | ); 772 | }, 773 | 774 | get_status: function(gid) { 775 | ARIA2.request("tellStatus", [gid], 776 | function(result) { 777 | if (!result.result) { 778 | main_alert("alert-error", "Error: rpc result error.", 5000); 779 | } 780 | 781 | result = result.result; 782 | result.uris = []; 783 | for (var i=0; iError: rpc result error.", 5000); 813 | } else { 814 | main_alert("alert-success", "Change Options OK!", 2000); 815 | } 816 | } 817 | ); 818 | }, 819 | 820 | /********************************************************/ 821 | 822 | refresh: function() { 823 | if (!select_lock) { 824 | need_refresh = false; 825 | ARIA2.tell_active(); 826 | ARIA2.tell_waiting(); 827 | ARIA2.tell_stopped(); 828 | } 829 | }, 830 | 831 | select_lock: function (bool) { 832 | select_lock = bool; 833 | }, 834 | 835 | auto_refresh: function(interval) { 836 | if (interval_id) 837 | window.clearInterval(interval_id); 838 | if (!(interval > 0)) { 839 | auto_refresh = false; 840 | return ; 841 | } 842 | interval_id = window.setInterval(function() { 843 | ARIA2.global_stat(); 844 | if (select_lock) { 845 | if (need_refresh) { 846 | main_alert("", "Task list have changed since last update. Click 'Refresh' button to update task list."); 847 | } 848 | } else { 849 | if (need_refresh) { 850 | ARIA2.refresh(); 851 | } else { 852 | ARIA2.tell_active(); 853 | } 854 | } 855 | }, interval); 856 | auto_refresh = true; 857 | }, 858 | 859 | finish_notification: 1, 860 | } 861 | })(); 862 | -------------------------------------------------------------------------------- /js/bootstrap.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap.js by @fat & @mdo 3 | * Copyright 2012 Twitter, Inc. 4 | * http://www.apache.org/licenses/LICENSE-2.0.txt 5 | */ 6 | !function(a){a(function(){"use strict",a.support.transition=function(){var a=function(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd",msTransition:"MSTransitionEnd",transition:"transitionend"},c;for(c in b)if(a.style[c]!==undefined)return b[c]}();return a&&{end:a}}()})}(window.jQuery),!function(a){"use strict";var b='[data-dismiss="alert"]',c=function(c){a(c).on("click",b,this.close)};c.prototype.close=function(b){function f(){e.trigger("closed").remove()}var c=a(this),d=c.attr("data-target"),e;d||(d=c.attr("href"),d=d&&d.replace(/.*(?=#[^\s]*$)/,"")),e=a(d),b&&b.preventDefault(),e.length||(e=c.hasClass("alert")?c:c.parent()),e.trigger(b=a.Event("close"));if(b.isDefaultPrevented())return;e.removeClass("in"),a.support.transition&&e.hasClass("fade")?e.on(a.support.transition.end,f):f()},a.fn.alert=function(b){return this.each(function(){var d=a(this),e=d.data("alert");e||d.data("alert",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.alert.Constructor=c,a(function(){a("body").on("click.alert.data-api",b,c.prototype.close)})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.button.defaults,c)};b.prototype.setState=function(a){var b="disabled",c=this.$element,d=c.data(),e=c.is("input")?"val":"html";a+="Text",d.resetText||c.data("resetText",c[e]()),c[e](d[a]||this.options[a]),setTimeout(function(){a=="loadingText"?c.addClass(b).attr(b,b):c.removeClass(b).removeAttr(b)},0)},b.prototype.toggle=function(){var a=this.$element.parent('[data-toggle="buttons-radio"]');a&&a.find(".active").removeClass("active"),this.$element.toggleClass("active")},a.fn.button=function(c){return this.each(function(){var d=a(this),e=d.data("button"),f=typeof c=="object"&&c;e||d.data("button",e=new b(this,f)),c=="toggle"?e.toggle():c&&e.setState(c)})},a.fn.button.defaults={loadingText:"loading..."},a.fn.button.Constructor=b,a(function(){a("body").on("click.button.data-api","[data-toggle^=button]",function(b){var c=a(b.target);c.hasClass("btn")||(c=c.closest(".btn")),c.button("toggle")})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=c,this.options.slide&&this.slide(this.options.slide),this.options.pause=="hover"&&this.$element.on("mouseenter",a.proxy(this.pause,this)).on("mouseleave",a.proxy(this.cycle,this))};b.prototype={cycle:function(b){return b||(this.paused=!1),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},to:function(b){var c=this.$element.find(".active"),d=c.parent().children(),e=d.index(c),f=this;if(b>d.length-1||b<0)return;return this.sliding?this.$element.one("slid",function(){f.to(b)}):e==b?this.pause().cycle():this.slide(b>e?"next":"prev",a(d[b]))},pause:function(a){return a||(this.paused=!0),clearInterval(this.interval),this.interval=null,this},next:function(){if(this.sliding)return;return this.slide("next")},prev:function(){if(this.sliding)return;return this.slide("prev")},slide:function(b,c){var d=this.$element.find(".active"),e=c||d[b](),f=this.interval,g=b=="next"?"left":"right",h=b=="next"?"first":"last",i=this,j=a.Event("slide");this.sliding=!0,f&&this.pause(),e=e.length?e:this.$element.find(".item")[h]();if(e.hasClass("active"))return;if(a.support.transition&&this.$element.hasClass("slide")){this.$element.trigger(j);if(j.isDefaultPrevented())return;e.addClass(b),e[0].offsetWidth,d.addClass(g),e.addClass(g),this.$element.one(a.support.transition.end,function(){e.removeClass([b,g].join(" ")).addClass("active"),d.removeClass(["active",g].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger("slid")},0)})}else{this.$element.trigger(j);if(j.isDefaultPrevented())return;d.removeClass("active"),e.addClass("active"),this.sliding=!1,this.$element.trigger("slid")}return f&&this.cycle(),this}},a.fn.carousel=function(c){return this.each(function(){var d=a(this),e=d.data("carousel"),f=a.extend({},a.fn.carousel.defaults,typeof c=="object"&&c);e||d.data("carousel",e=new b(this,f)),typeof c=="number"?e.to(c):typeof c=="string"||(c=f.slide)?e[c]():f.interval&&e.cycle()})},a.fn.carousel.defaults={interval:5e3,pause:"hover"},a.fn.carousel.Constructor=b,a(function(){a("body").on("click.carousel.data-api","[data-slide]",function(b){var c=a(this),d,e=a(c.attr("data-target")||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,"")),f=!e.data("modal")&&a.extend({},e.data(),c.data());e.carousel(f),b.preventDefault()})})}(window.jQuery),!function(a){"use strict";var b=function(b,c){this.$element=a(b),this.options=a.extend({},a.fn.collapse.defaults,c),this.options.parent&&(this.$parent=a(this.options.parent)),this.options.toggle&&this.toggle()};b.prototype={constructor:b,dimension:function(){var a=this.$element.hasClass("width");return a?"width":"height"},show:function(){var b,c,d,e;if(this.transitioning)return;b=this.dimension(),c=a.camelCase(["scroll",b].join("-")),d=this.$parent&&this.$parent.find("> .accordion-group > .in");if(d&&d.length){e=d.data("collapse");if(e&&e.transitioning)return;d.collapse("hide"),e||d.data("collapse",null)}this.$element[b](0),this.transition("addClass",a.Event("show"),"shown"),this.$element[b](this.$element[0][c])},hide:function(){var b;if(this.transitioning)return;b=this.dimension(),this.reset(this.$element[b]()),this.transition("removeClass",a.Event("hide"),"hidden"),this.$element[b](0)},reset:function(a){var b=this.dimension();return this.$element.removeClass("collapse")[b](a||"auto")[0].offsetWidth,this.$element[a!==null?"addClass":"removeClass"]("collapse"),this},transition:function(b,c,d){var e=this,f=function(){c.type=="show"&&e.reset(),e.transitioning=0,e.$element.trigger(d)};this.$element.trigger(c);if(c.isDefaultPrevented())return;this.transitioning=1,this.$element[b]("in"),a.support.transition&&this.$element.hasClass("collapse")?this.$element.one(a.support.transition.end,f):f()},toggle:function(){this[this.$element.hasClass("in")?"hide":"show"]()}},a.fn.collapse=function(c){return this.each(function(){var d=a(this),e=d.data("collapse"),f=typeof c=="object"&&c;e||d.data("collapse",e=new b(this,f)),typeof c=="string"&&e[c]()})},a.fn.collapse.defaults={toggle:!0},a.fn.collapse.Constructor=b,a(function(){a("body").on("click.collapse.data-api","[data-toggle=collapse]",function(b){var c=a(this),d,e=c.attr("data-target")||b.preventDefault()||(d=c.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""),f=a(e).data("collapse")?"toggle":c.data();a(e).collapse(f)})})}(window.jQuery),!function(a){function d(){a(b).parent().removeClass("open")}"use strict";var b='[data-toggle="dropdown"]',c=function(b){var c=a(b).on("click.dropdown.data-api",this.toggle);a("html").on("click.dropdown.data-api",function(){c.parent().removeClass("open")})};c.prototype={constructor:c,toggle:function(b){var c=a(this),e,f,g;if(c.is(".disabled, :disabled"))return;return f=c.attr("data-target"),f||(f=c.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,"")),e=a(f),e.length||(e=c.parent()),g=e.hasClass("open"),d(),g||e.toggleClass("open"),!1}},a.fn.dropdown=function(b){return this.each(function(){var d=a(this),e=d.data("dropdown");e||d.data("dropdown",e=new c(this)),typeof b=="string"&&e[b].call(d)})},a.fn.dropdown.Constructor=c,a(function(){a("html").on("click.dropdown.data-api",d),a("body").on("click.dropdown",".dropdown form",function(a){a.stopPropagation()}).on("click.dropdown.data-api",b,c.prototype.toggle)})}(window.jQuery),!function(a){function c(){var b=this,c=setTimeout(function(){b.$element.off(a.support.transition.end),d.call(b)},500);this.$element.one(a.support.transition.end,function(){clearTimeout(c),d.call(b)})}function d(a){this.$element.hide().trigger("hidden"),e.call(this)}function e(b){var c=this,d=this.$element.hasClass("fade")?"fade":"";if(this.isShown&&this.options.backdrop){var e=a.support.transition&&d;this.$backdrop=a('