'+$('').text(k).html()+'';
363 | content += render(f[k]);
364 | content += '';
365 | }
366 |
367 | for (k in f) {
368 | if (f[k]['_file'] === undefined) {
369 | continue;
370 | }
371 |
372 | f[k]['_file']['relative_title'] = k;
373 | content += YAAW.tpl.file(f[k]['_file']);
374 | }
375 | content += '';
376 | return content;
377 | }
378 |
379 | //console.log(file_dict);
380 | return render(file_dict);
381 | },
382 |
383 | view: {
384 | bitfield: function() {
385 | var graphic = "░▒▓█";
386 | return function(text) {
387 | var len = text.length;
388 | var result = "";
389 | for (var i=0; i= len)
405 | p += 16;
406 | else
407 | p += parseInt(text[i*part_len+j], 16);
408 | }
409 | result += graphic[Math.floor(p/part_len/4)] + "";
410 | }
411 | return result;
412 | };
413 | },
414 |
415 | bitfield_to_percent: function() {
416 | return function(text) {
417 | var len = text.length - 1;
418 | var p, one = 0;
419 | for (var i=0; i>= 1;
424 | }
425 | }
426 | return Math.floor(one/(4*len)*100).toString();
427 | };
428 | },
429 |
430 | format_size: function() {
431 | var format_text = ["B", "KB", "MB", "GB", "TB", ];
432 | return function format_size(size) {
433 | if (size === '') return '';
434 | size = parseInt(size);
435 | var i = 0;
436 | while (size >= 1024) {
437 | size /= 1024;
438 | i++;
439 | }
440 | if (size==0) {
441 | return "0 KB";
442 | } else {
443 | return size.toFixed(2)+" "+format_text[i];
444 | }
445 | };
446 | },
447 |
448 | format_size_0: function() {
449 | var format_text = ["B", "KB", "MB", "GB", "TB", ];
450 | return function format_size(size) {
451 | if (size === '') return '';
452 | size = parseInt(size);
453 | var i = 0;
454 | while (size >= 1024) {
455 | size /= 1024;
456 | i++;
457 | }
458 | if (size==0) {
459 | return "0 KB";
460 | } else {
461 | return size.toFixed(0)+" "+format_text[i];
462 | }
463 | };
464 | },
465 |
466 | format_time: function() {
467 | var time_interval = [60, 60, 24];
468 | var time_text = ["s", "m", "h"];
469 | return function format_time(time) {
470 | if (time == Infinity) {
471 | return "INF";
472 | } else if (time == 0) {
473 | return "0s";
474 | }
475 |
476 | time = Math.floor(time);
477 | var i = 0;
478 | var result = "";
479 | while (time > 0 && i < 3) {
480 | result = time % time_interval[i] + time_text[i] + result;
481 | time = Math.floor(time/time_interval[i]);
482 | i++;
483 | }
484 | if (time > 0) {
485 | result = time + "d" + result;
486 | }
487 | return result;
488 | };
489 | },
490 |
491 | format_peerid: function() {
492 | return function format_peerid(peerid) {
493 | try {
494 | var ret = window.format_peerid(peerid);
495 | if (ret.client == 'unknown') throw 'unknown';
496 | return ret.client+(ret.version ? '-'+ret.version : '');
497 | } catch(e) {
498 | if (peerid == '%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00%00')
499 | return 'unknown';
500 | var ret = unescape(peerid).split('-');
501 | for (var i=0; i 10) {
979 | this.jsonrpc_history.shift();
980 | }
981 | $.Storage.set("jsonrpc_history", JSON.stringify(this.jsonrpc_history));
982 | }
983 | $.Storage.set("refresh_interval", String(this.refresh_interval));
984 | $.Storage.set("finish_notification", String(this.finish_notification));
985 | },
986 |
987 | update: function() {
988 | $("#setting-form #rpc-path").val(this.jsonrpc_path);
989 | $("#setting-form input:radio[name=refresh_interval][value="+this.refresh_interval+"]").attr("checked", true);
990 | $("#setting-form input:radio[name=finish_notification][value="+this.finish_notification+"]").attr("checked", true);
991 | if (this.jsonrpc_history.length) {
992 | $(".rpc-path-wrap .dropdown-menu").remove();
993 | var content = '';
998 | $(".rpc-path-wrap").append(content).on("click", "li>a", function() {
999 | $("#setting-form #rpc-path").val($(this).text());
1000 | });
1001 | $(".rpc-path-wrap .dropdown-toggle").removeAttr("disabled").dropdown();
1002 | }
1003 | if (this.finish_notification && window.Notification && Notification.permission !== "granted") {
1004 | Notification.requestPermission();
1005 | }
1006 | },
1007 |
1008 | submit: function() {
1009 | _this = $("#setting-form");
1010 | var _jsonrpc_path = _this.find("#rpc-path").val();
1011 | var _refresh_interval = Number(_this.find("input:radio[name=refresh_interval]:checked").val());
1012 | var _finish_notification = Number(_this.find("input:radio[name=finish_notification]:checked").val());
1013 |
1014 | var changed = false;
1015 | if (_jsonrpc_path !== undefined && this.jsonrpc_path != _jsonrpc_path) {
1016 | this.jsonrpc_path = _jsonrpc_path;
1017 | YAAW.tasks.unSelectAll();
1018 | $("#main-alert").hide();
1019 | YAAW.aria2_init();
1020 | changed = true;
1021 | }
1022 | if (_refresh_interval !== undefined && this.refresh_interval != _refresh_interval) {
1023 | this.refresh_interval = _refresh_interval;
1024 | ARIA2.auto_refresh(this.refresh_interval);
1025 | changed = true;
1026 | }
1027 | if (_finish_notification !== undefined && this.finish_notification != _finish_notification) {
1028 | this.finish_notification = _finish_notification;
1029 | ARIA2.finish_notification = _finish_notification;
1030 | changed = true;
1031 | }
1032 | if (changed) {
1033 | this.save();
1034 | }
1035 | if (this.finish_notification && window.Notification && Notification.permission !== "granted") {
1036 | Notification.requestPermission();
1037 | }
1038 |
1039 | // submit aria2 global setting
1040 | var options = {};
1041 | $("#aria2-gs-form input[name]").each(function(i, n) {
1042 | var name = n.getAttribute("name");
1043 | var value = n.value;
1044 | if (name && value)
1045 | options[name] = value;
1046 | });
1047 | ARIA2.change_global_option(options);
1048 | $("#setting-modal").modal('hide');
1049 | },
1050 | },
1051 |
1052 | notification: function(title, content) {
1053 | if (!window.Notification) {
1054 | return false;
1055 | }
1056 |
1057 | if (Notification.permission !== "granted")
1058 | Notification.requestPermission();
1059 |
1060 | var notification = new Notification(title, {
1061 | body: content,
1062 | });
1063 |
1064 | return notification;
1065 | },
1066 | }
1067 | })();
1068 | YAAW.init();
1069 |
--------------------------------------------------------------------------------
/offline.appcache:
--------------------------------------------------------------------------------
1 | CACHE MANIFEST
2 | #2017-10-15 11:08
3 |
4 | CACHE:
5 | index.html
6 | css/main.css
7 | css/bootstrap.min.css
8 | css/bootstrap-responsive.min.css
9 | img/favicon.ico
10 | img/glyphicons-halflings-white.png
11 | img/glyphicons-halflings.png
12 | js/jquery-1.7.2.min.js
13 | js/bootstrap.min.js
14 | js/jquery.jsonrpc.js
15 | js/jquery.Storage.js
16 | js/jquery.base64.min.js
17 | js/mustache.js
18 | js/peerid.js
19 | js/aria2.js
20 | js/yaaw.js
21 |
--------------------------------------------------------------------------------
/yaaw.sublime-project:
--------------------------------------------------------------------------------
1 | {
2 | "folders":
3 | [
4 | {
5 | "path": "."
6 | }
7 | ]
8 | }
9 |
--------------------------------------------------------------------------------