* @copyright Xavier Beurois 2015
*/
-#app {
- width: 100%;
-}
#app-navigation {
padding-bottom: 0;
}
@@ -115,9 +112,11 @@
#app-content-wrapper .jumbotron p a {
color: #428bca;
}
+#app-content-wrapper .jumbotron span {
+ display: block;
+}
#app-content-wrapper .content-page {
padding: 0 20px;
- height: 450px;
border-bottom: 1px solid #ddd;
}
#app-content-wrapper h3, #app-content-wrapper .h3 {
@@ -141,6 +140,31 @@
font-size: 12px;
margin-left: 1em;
}
+
+#app-content-wrapper .handler {
+
+ display: inline;
+ width: 20%;
+ text-align: right;
+ margin: 3px 3px 3px 0;
+ padding: 7px 6px;
+ font-size: 13px;
+ background-color: none;
+ color: white;
+ border: 1px solid #dbdbdb;
+ outline: none;
+ border-radius: 3px;
+}
+
+.green {
+ background-color: green;
+}
+
+.red {
+ background-color: red;
+}
+
+
#app-content-wrapper .pull-right {
float: right;
}
@@ -280,8 +304,7 @@
float: right !important;
box-sizing: border-box;
height: 36px;
- padding: 10px;
- margin-top: -5px;
+ padding: 7px;
}
#app-content-wrapper .content-page .uploadfile input[type="file"] {
cursor: pointer;
@@ -317,7 +340,7 @@
width: 1px;
}
#app-content-wrapper .content-page > input {
- width: 100%;
+ width: 70%;
}
#app-content-wrapper .content-page > div.actions {
display: block;
@@ -350,20 +373,19 @@
#app-content-wrapper .content-queue > table > tbody > tr > td.padding {
padding: 2px 0 2px 5px;
}
-#app-content-wrapper .content-queue > table > tbody > tr > td .pb-wrap{
+#app-content-wrapper .pb-wrap{
position: relative;
}
-#app-content-wrapper .content-queue > table > tbody > tr > td .pb-wrap,
-#app-content-wrapper .content-queue > table > tbody > tr > td .pb-value,
-#app-content-wrapper .content-queue > table > tbody > tr > td .pb-text {
+#app-content-wrapper .pb-wrap,
+#app-content-wrapper .pb-value {
width: 100%;
- height: 25px;
+ height: 5px;
}
-#app-content-wrapper .content-queue > table > tbody > tr > td .pb-value {
+#app-content-wrapper .pb-value {
background: rgba(8, 75, 138, 0.3) top left no-repeat;
}
-#app-content-wrapper .content-queue > table > tbody > tr > td .pb-text {
- position: absolute;
+#app-content-wrapper .pb-text {
+ /* position: absolute; */
top:0;
left:0;
padding: 2px 0 2px 5px;
diff --git a/css/styles.min.css b/css/styles.min.css
index cb1f44c..bb7762c 100644
--- a/css/styles.min.css
+++ b/css/styles.min.css
@@ -1 +1 @@
-#app{width:100%;}#app-navigation{padding-bottom:0}#app-navigation ul>li{display:block}#app-navigation li[data-id="all"]{border-bottom:1px solid #ddd}#app-navigation li>div>a{box-sizing:border-box;color:#333;display:block;line-height:44px;min-height:44px;overflow:hidden;padding:0 12px;text-overflow:ellipsis;white-space:nowrap;width:100%}#app-navigation li:hover>div>a,#app-navigation li:focus>div>a,#app-navigation a:focus,#app-navigation .selected,#app-navigation .selected a{background-color:#ddd}#app-navigation li div.badge{position:relative}#app-navigation .badger-outter{float:left;height:25px;min-width:36px;position:absolute;right:10px;top:9px}#app-navigation .badger-inner{height:20px;border-radius:15px;-moz-border-radius:15px;-webkit-border-radius:15px;background:#1d2d44 none repeat scroll 0 0;margin:3px;width:2.5em}#app-navigation .badger-badge{color:#fff;margin:0;text-align:center}#app-navigation .badger-number{font-size:12px}#app-navigation .nav-updater{bottom:0;position:absolute!important;display:none}#app-navigation .nav-updater h3{background-color:#6f6;line-height:50px;padding:0 12px 10px;color:#090;font-size:20px}#app-navigation .nav-updater h3 .button{height:40px;line-height:30px;text-align:center}#app-content-wrapper{display:block}#app-content-wrapper .table{width:100%;margin-bottom:20px;border-collapse:collapse;border-spacing:0;max-width:100%;background-color:transparent}#app-content-wrapper .jumbotron{background-color:#eee;border-bottom:1px solid #ddd;color:inherit;padding:17px;text-align:center}#app-content-wrapper .jumbotron h1{margin-top:0;font-size:24px;line-height:1}#app-content-wrapper .jumbotron p{font-size:inherited;font-weight:200;font-style:italic}#app-content-wrapper .jumbotron p strong{font-weight:bold}#app-content-wrapper .jumbotron p a{color:#428bca}#app-content-wrapper .content-page{padding:0 20px;height:450px;border-bottom:1px solid #ddd}#app-content-wrapper h3,#app-content-wrapper .h3{font-size:24px}#app-content-wrapper h1,#app-content-wrapper .h1,#app-content-wrapper h2,#app-content-wrapper .h2,#app-content-wrapper h3,#app-content-wrapper .h3{margin-bottom:10px;margin-top:20px}#app-content-wrapper h1,#app-content-wrapper h2,#app-content-wrapper h3,#app-content-wrapper h4,#app-content-wrapper h5,#app-content-wrapper h6,#app-content-wrapper .h1,#app-content-wrapper .h2,#app-content-wrapper .h3,#app-content-wrapper .h4,#app-content-wrapper .h5,#app-content-wrapper .h6{color:inherit;font-family:inherit;font-weight:500;line-height:1.1}#app-content-wrapper .muted{font-size:12px;margin-left:1em}#app-content-wrapper .pull-right{float:right}#app-content-wrapper #controls{position:static;height:46px;background-color:rgba(250,250,250,0.95)}#app-content-wrapper .actions{display:inline-block;padding:5px}#app-content-wrapper .actions>div.button{margin:0}#app-content-wrapper .loadingtext{font-style:italic;padding:5px}#app-content-wrapper .loadingblock{display:block}#app-content-wrapper .loadinginline{display:inline}#app-content-wrapper .actions>div.button .icon-caret-dark{height:12px;margin:3px 0 0 10px;padding:0;vertical-align:middle;width:12px;float:right}#app-content-wrapper .actions>div.button>ul{background:#f8f8f8 none repeat scroll 0 0;border:1px solid #ddd;border-radius:0 5px 5px;box-shadow:0 2px 7px rgba(170,170,170,0.4);display:none;margin-left:-11px;margin-top:6px;min-width:112px;position:fixed;text-align:left}#app-content-wrapper #NewDL{z-index:11}#app-content-wrapper #TorrentsList>ul{margin-left:0;width:800px;z-index:10;padding-bottom:0}#app-content-wrapper #TorrentsList>ul>li{background:transparent url('../img/torrent.png') no-repeat scroll 10px 8px;cursor:pointer;height:30px;margin:0 5px 5px 15px;padding:5px}#app-content-wrapper #TorrentsList>ul>li>p{cursor:pointer;padding-bottom:0;padding-left:35px;padding-top:0}#app-content-wrapper #TorrentsList>ul>li>p.loader>span{padding:10px}#app-content-wrapper #TorrentsList>ul>li>p>a{color:#036;text-decoration:underline}#app-content-wrapper .actions>div.button>ul>li{cursor:pointer;height:20px;margin:5px 5px 15px 15px;padding-bottom:2px}#app-content-wrapper .actions>div.button>ul>li>p{cursor:pointer;padding-bottom:7px;padding-top:5px}#app-content-wrapper .righttitle{color:#ddd;float:right!important;font-size:2em;font-style:italic;margin-right:.5em;padding:11px 10px 10px}#app-content-wrapper .content-page .jumbotron{padding:10px;text-align:left}#app-content-wrapper .content-page .jumbotron>h5{font-size:15pt;margin-bottom:.7em}#app-content-wrapper .content-page .jumbotron .group-option{margin-bottom:.7em}#app-content-wrapper .content-page .jumbotron .group-option>label{margin-right:.7em}#app-content-wrapper .content-page .jumbotron .group-option>select{font-weight:normal;padding:0;height:20px}#app-content-wrapper .content-page>h3{margin-bottom:0;margin-top:15px;padding-top:5px}#app-content-wrapperLRMsg{font-style:italic}#app-content-wrapper .content-page>h3>span.alert{color:#b40404}#app-content-wrapper span.highalert{background-color:#b40404;color:#fff;padding:5px}#app-content-wrapper .content-page>h3>span.success{color:#298a08}#app-content-wrapper .content-page>h3>span.info{color:#084b8a}#app-content-wrapper .content-page .uploadfile,#app-content-wrapper .content-page .launch{float:right!important;box-sizing:border-box;height:36px;padding:10px;margin-top:-5px}#app-content-wrapper .content-page .uploadfile input[type="file"]{cursor:pointer;font-size:16px;left:0;margin:-5px -3px;opacity:0;overflow:hidden;padding:0;position:relative;top:0;width:44px;z-index:20;float:left}#app-content-wrapper .content-page .uploadfile .icon-loading-small,#app-content-wrapper .content-page .uploadfile .icon-upload{cursor:pointer;display:block;height:27px;margin:-5px -3px;opacity:.65;position:relative;width:44px;z-index:10}#app-content-wrapper .content-page .uploadfile .icon-upload .hidden-visually{height:1px;left:-10000px;overflow:hidden;position:absolute;top:auto;width:1px}#app-content-wrapper .content-page>input{width:100%}#app-content-wrapper .content-page>div.actions{display:block;float:none;margin:10px 0 5px;padding:0}#app-content-wrapper .content-queue>table{width:100%}#app-content-wrapper .content-queue>table>thead>tr{height:30px;background-color:#eee}#app-content-wrapper .content-queue>table>thead>tr>th{font-style:italic;font-weight:bold;padding:2px 0 2px 5px;border-bottom:1px solid #ddd}#app-content-wrapper .content-queue>table>thead>tr>th.border{border-left:1px solid #ddd}#app-content-wrapper .content-queue>table>tbody>tr>td{border-bottom:1px solid #eee}#app-content-wrapper .content-queue>table>tbody>tr>td.border{border-left:1px solid #eee}#app-content-wrapper .content-queue>table>tbody>tr>td.padding{padding:2px 0 2px 5px}#app-content-wrapper .content-queue>table>tbody>tr>td .pb-wrap{position:relative}#app-content-wrapper .content-queue>table>tbody>tr>td .pb-wrap,#app-content-wrapper .content-queue>table>tbody>tr>td .pb-value,#app-content-wrapper .content-queue>table>tbody>tr>td .pb-text{width:100%;height:25px}#app-content-wrapper .content-queue>table>tbody>tr>td .pb-value{background:rgba(8,75,138,0.3) top left no-repeat}#app-content-wrapper .content-queue>table>tbody>tr>td .pb-text{position:absolute;top:0;left:0;padding:2px 0 2px 5px;width:100%}#app-content-wrapper .content-queue>table>thead>tr>th>div.svg,#app-content-wrapper .content-queue>table>tbody>tr>td>div.svg{width:2em;cursor:pointer;float:right}#app-content-wrapper .content-queue>table>tbody>tr>td>a{color:#084b8a;text-decoration:underline}#app-content-wrapper .content-queue>table>tbody>tr>td>div.icon-download{background-image:url('../img/icon_download.svg');margin-top:2px;float:left;margin-right:5px;cursor:auto;width:1em}#app-content-wrapper .content-queue>table>tbody>tr>td>div.icon-upload{background-image:url('../img/icon_upload.svg');margin-top:2px;float:left;margin-right:5px;cursor:auto;width:1em}#app-content-wrapper .content-queue>table>tbody>tr[data-rel="LOADER"]>td>div.icon-loading-small{float:left;margin:.2em .5em 0 .2em}.app-ocdownloader #controls .actions>div>.button,.app-ocdownloader #controls .actions>.button,.app-ocdownloader #controls .actions>div button,.app-ocdownloader #controls .actions button{display:block;width:auto;float:left}.app-ocdownloader #app-content-wrapper .content-queue{flex-grow:1;margin-bottom:40px}.app-ocdownloader #app-content-wrapper #controls{position:relative;width:auto;flex:0 0 100%;top:0}.app-ocdownloader #app-content-wrapper #controls p.lead{margin-top:15px}.app-ocdownloader #app-content #app-content-wrapper{flex-wrap:wrap}.app-ocdownloader #app-content-wrapper .content-page{width:100%}.app-ocdownloader #app-content-wrapper .loadingtext{width:100%;float:left;clear:both;margin-top:-40px}
+#app-navigation{padding-bottom:0}#app-navigation ul>li{display:block}#app-navigation li[data-id="all"]{border-bottom:1px solid #ddd}#app-navigation li>div>a{box-sizing:border-box;color:#333;display:block;line-height:44px;min-height:44px;overflow:hidden;padding:0 12px;text-overflow:ellipsis;white-space:nowrap;width:100%}#app-navigation li:hover>div>a,#app-navigation li:focus>div>a,#app-navigation a:focus,#app-navigation .selected,#app-navigation .selected a{background-color:#ddd}#app-navigation li div.badge{position:relative}#app-navigation .badger-outter{float:left;height:25px;min-width:36px;position:absolute;right:10px;top:9px}#app-navigation .badger-inner{height:20px;border-radius:15px;-moz-border-radius:15px;-webkit-border-radius:15px;background:#1d2d44 none repeat scroll 0 0;margin:3px;width:2.5em}#app-navigation .badger-badge{color:#fff;margin:0;text-align:center}#app-navigation .badger-number{font-size:12px}#app-navigation .nav-updater{bottom:0;position:absolute!important;display:none}#app-navigation .nav-updater h3{background-color:#6f6;line-height:50px;padding:0 12px 10px;color:#090;font-size:20px}#app-navigation .nav-updater h3 .button{height:40px;line-height:30px;text-align:center}#app-content-wrapper{display:block}#app-content-wrapper .table{width:100%;margin-bottom:20px;border-collapse:collapse;border-spacing:0;max-width:100%;background-color:transparent}#app-content-wrapper .jumbotron{background-color:#eee;border-bottom:1px solid #ddd;color:inherit;padding:17px;text-align:center}#app-content-wrapper .jumbotron h1{margin-top:0;font-size:24px;line-height:1}#app-content-wrapper .jumbotron p{font-size:inherited;font-weight:200;font-style:italic}#app-content-wrapper .jumbotron p strong{font-weight:bold}#app-content-wrapper .jumbotron p a{color:#428bca}#app-content-wrapper .jumbotron span{display:block}#app-content-wrapper .content-page{padding:0 20px;border-bottom:1px solid #ddd}#app-content-wrapper h3,#app-content-wrapper .h3{font-size:24px}#app-content-wrapper h1,#app-content-wrapper .h1,#app-content-wrapper h2,#app-content-wrapper .h2,#app-content-wrapper h3,#app-content-wrapper .h3{margin-bottom:10px;margin-top:20px}#app-content-wrapper h1,#app-content-wrapper h2,#app-content-wrapper h3,#app-content-wrapper h4,#app-content-wrapper h5,#app-content-wrapper h6,#app-content-wrapper .h1,#app-content-wrapper .h2,#app-content-wrapper .h3,#app-content-wrapper .h4,#app-content-wrapper .h5,#app-content-wrapper .h6{color:inherit;font-family:inherit;font-weight:500;line-height:1.1}#app-content-wrapper .muted{font-size:12px;margin-left:1em}#app-content-wrapper .handler{display:inline;width:20%;text-align:right;margin:3px 3px 3px 0;padding:7px 6px;font-size:13px;background-color:none;color:white;border:1px solid #dbdbdb;outline:0;border-radius:3px}.green{background-color:green}.red{background-color:red}#app-content-wrapper .pull-right{float:right}#app-content-wrapper #controls{position:static;height:46px;background-color:rgba(250,250,250,0.95)}#app-content-wrapper .actions{display:inline-block;padding:5px}#app-content-wrapper .actions>div.button{margin:0}#app-content-wrapper .loadingtext{font-style:italic;padding:5px}#app-content-wrapper .loadingblock{display:block}#app-content-wrapper .loadinginline{display:inline}#app-content-wrapper .actions>div.button .icon-caret-dark{height:12px;margin:3px 0 0 10px;padding:0;vertical-align:middle;width:12px;float:right}#app-content-wrapper .actions>div.button>ul{background:#f8f8f8 none repeat scroll 0 0;border:1px solid #ddd;border-radius:0 5px 5px;box-shadow:0 2px 7px rgba(170,170,170,0.4);display:none;margin-left:-11px;margin-top:6px;min-width:112px;position:fixed;text-align:left}#app-content-wrapper #NewDL{z-index:11}#app-content-wrapper #TorrentsList>ul{margin-left:0;width:800px;z-index:10;padding-bottom:0}#app-content-wrapper #TorrentsList>ul>li{background:transparent url('../img/torrent.png') no-repeat scroll 10px 8px;cursor:pointer;height:30px;margin:0 5px 5px 15px;padding:5px}#app-content-wrapper #TorrentsList>ul>li>p{cursor:pointer;padding-bottom:0;padding-left:35px;padding-top:0}#app-content-wrapper #TorrentsList>ul>li>p.loader>span{padding:10px}#app-content-wrapper #TorrentsList>ul>li>p>a{color:#036;text-decoration:underline}#app-content-wrapper .actions>div.button>ul>li{cursor:pointer;height:20px;margin:5px 5px 15px 15px;padding-bottom:2px}#app-content-wrapper .actions>div.button>ul>li>p{cursor:pointer;padding-bottom:7px;padding-top:5px}#app-content-wrapper .righttitle{color:#ddd;float:right!important;font-size:2em;font-style:italic;margin-right:.5em;padding:11px 10px 10px}#app-content-wrapper .content-page .jumbotron{padding:10px;text-align:left}#app-content-wrapper .content-page .jumbotron>h5{font-size:15pt;margin-bottom:.7em}#app-content-wrapper .content-page .jumbotron .group-option{margin-bottom:.7em}#app-content-wrapper .content-page .jumbotron .group-option>label{margin-right:.7em}#app-content-wrapper .content-page .jumbotron .group-option>select{font-weight:normal;padding:0;height:20px}#app-content-wrapper .content-page>h3{margin-bottom:0;margin-top:15px;padding-top:5px}#app-content-wrapperLRMsg{font-style:italic}#app-content-wrapper .content-page>h3>span.alert{color:#b40404}#app-content-wrapper span.highalert{background-color:#b40404;color:#fff;padding:5px}#app-content-wrapper .content-page>h3>span.success{color:#298a08}#app-content-wrapper .content-page>h3>span.info{color:#084b8a}#app-content-wrapper .content-page .uploadfile,#app-content-wrapper .content-page .launch{float:right!important;box-sizing:border-box;height:36px;padding:7px}#app-content-wrapper .content-page .uploadfile input[type="file"]{cursor:pointer;font-size:16px;left:0;margin:-5px -3px;opacity:0;overflow:hidden;padding:0;position:relative;top:0;width:44px;z-index:20;float:left}#app-content-wrapper .content-page .uploadfile .icon-loading-small,#app-content-wrapper .content-page .uploadfile .icon-upload{cursor:pointer;display:block;height:27px;margin:-5px -3px;opacity:.65;position:relative;width:44px;z-index:10}#app-content-wrapper .content-page .uploadfile .icon-upload .hidden-visually{height:1px;left:-10000px;overflow:hidden;position:absolute;top:auto;width:1px}#app-content-wrapper .content-page>input{width:70%}#app-content-wrapper .content-page>div.actions{display:block;float:none;margin:10px 0 5px;padding:0}#app-content-wrapper .content-queue>table{width:100%}#app-content-wrapper .content-queue>table>thead>tr{height:30px;background-color:#eee}#app-content-wrapper .content-queue>table>thead>tr>th{font-style:italic;font-weight:bold;padding:2px 0 2px 5px;border-bottom:1px solid #ddd}#app-content-wrapper .content-queue>table>thead>tr>th.border{border-left:1px solid #ddd}#app-content-wrapper .content-queue>table>tbody>tr>td{border-bottom:1px solid #eee}#app-content-wrapper .content-queue>table>tbody>tr>td.border{border-left:1px solid #eee}#app-content-wrapper .content-queue>table>tbody>tr>td.padding{padding:2px 0 2px 5px}#app-content-wrapper .pb-wrap{position:relative}#app-content-wrapper .pb-wrap,#app-content-wrapper .pb-value{width:100%;height:5px}#app-content-wrapper .pb-value{background:rgba(8,75,138,0.3) top left no-repeat}#app-content-wrapper .pb-text{top:0;left:0;padding:2px 0 2px 5px;width:100%}#app-content-wrapper .content-queue>table>thead>tr>th>div.svg,#app-content-wrapper .content-queue>table>tbody>tr>td>div.svg{width:2em;cursor:pointer;float:right}#app-content-wrapper .content-queue>table>tbody>tr>td>a{color:#084b8a;text-decoration:underline}#app-content-wrapper .content-queue>table>tbody>tr>td>div.icon-download{background-image:url('../img/icon_download.svg');margin-top:2px;float:left;margin-right:5px;cursor:auto;width:1em}#app-content-wrapper .content-queue>table>tbody>tr>td>div.icon-upload{background-image:url('../img/icon_upload.svg');margin-top:2px;float:left;margin-right:5px;cursor:auto;width:1em}#app-content-wrapper .content-queue>table>tbody>tr[data-rel="LOADER"]>td>div.icon-loading-small{float:left;margin:.2em .5em 0 .2em}.app-ocdownloader #controls .actions>div>.button,.app-ocdownloader #controls .actions>.button,.app-ocdownloader #controls .actions>div button,.app-ocdownloader #controls .actions button{display:block;width:auto;float:left}.app-ocdownloader #app-content-wrapper .content-queue{flex-grow:1;margin-bottom:40px}.app-ocdownloader #app-content-wrapper #controls{position:relative;width:auto;flex:0 0 100%;top:0}.app-ocdownloader #app-content-wrapper #controls p.lead{margin-top:15px}.app-ocdownloader #app-content #app-content-wrapper{flex-wrap:wrap}.app-ocdownloader #app-content-wrapper .content-page{width:100%}.app-ocdownloader #app-content-wrapper .loadingtext{width:100%;float:left;clear:both;margin-top:-40px}
diff --git a/js/add.js b/js/add.js
index 86e2787..618b006 100644
--- a/js/add.js
+++ b/js/add.js
@@ -56,6 +56,8 @@ $(document).ready (function ()
OCDLR.Utils.GetTorrentsList ($(this).children ('ul'));
});
+
+
// Launch HTTP download
$('#app-content-wrapper .content-page[rel=OCDHTTP] div.launch').bind ('click', function ()
{
diff --git a/js/add.min.js b/js/add.min.js
index f95c9c4..d938503 100644
--- a/js/add.min.js
+++ b/js/add.min.js
@@ -1 +1 @@
-$(document).ready(function(){$("#ball").Badger("..."),$("#bcompletes").Badger("..."),$("#bactives").Badger("..."),$("#bwaitings").Badger("..."),$("#bstopped").Badger("..."),$("#bremoved").Badger("..."),OCDLR.Utils.UpdateQueue(!0,"add"),$("#NewDL").bind("click",function(){$(this).children("ul").is(":visible")?$(this).children("ul").hide():$(this).children("ul").show()}),$("#NewDL").children("div").children("p").bind("click",function(){$("#app-content-wrapper .content-page").hide(),$("#app-content-wrapper .content-page[rel="+$(this).attr("data-rel")+"]").show()}),$("#NewDL").children("div").bind("click",function(){$("#app-content-wrapper .content-page").hide(),$("#app-content-wrapper .content-page[rel="+$(this).attr("data-rel")+"]").show()}),$("#option-ftp-pasv").prop("checked",!0),$("#option-yt-extractaudio").prop("checked",!1),$("#option-yt-forceipv4").prop("checked",!0),$("#option-bt-rmtorrent").prop("checked",!0),$("#TorrentsList").bind("click",function(){OCDLR.Utils.GetTorrentsList($(this).children("ul"))}),$("#app-content-wrapper .content-page[rel=OCDHTTP] div.launch").bind("click",function(){var e=$(this).parent().parent().children("input.url");OCDLR.Utils.ValidURL(e.val())?OCDLR.Utils.AddDownload($(this),"http",e.val(),{HTTPUser:$("#option-http-user").val(),HTTPPasswd:$("#option-http-pwd").val(),HTTPReferer:$("#option-http-referer").val(),HTTPUseragent:$("#option-http-useragent").val(),HTTPOutfilename:$("#option-http-outfilename").val()}):OCDLR.Utils.PrintError(t("ocdownloader","Invalid URL. Please check the address of the file ...")),e.val(""),$("#option-http-user").val(""),$("#option-http-pwd").val(""),$("#option-http-referer").val(""),$("#option-http-useragent").val(""),$("#option-http-outfilename").val("")}),$("#app-content-wrapper .content-page[rel=OCDFTP] div.launch").bind("click",function(){var e=$(this).parent().parent().children("input.url");OCDLR.Utils.ValidURL(e.val())?OCDLR.Utils.AddDownload($(this),"ftp",e.val(),{FTPUser:$("#option-ftp-user").val(),FTPPasswd:$("#option-ftp-pwd").val(),FTPPasv:$("#option-ftp-pasv").prop("checked"),FTPReferer:$("#option-ftp-referer").val(),FTPUseragent:$("#option-ftp-useragent").val(),FTPOutfilename:$("#option-ftp-outfilename").val()}):OCDLR.Utils.PrintError(t("ocdownloader","Invalid URL. Please check the address of the file ...")),e.val(""),$("#option-ftp-user").val(""),$("#option-ftp-pwd").val(""),$("#option-ftp-pasv").prop("checked",!0),$("#option-ftp-referer").val(""),$("#option-ftp-useragent").val("")}),$("#app-content-wrapper .content-page[rel=OCDYT] div.launch").bind("click",function(){var e=$(this).parent().parent().children("input.url");OCDLR.Utils.ValidURL(e.val())?OCDLR.Utils.AddDownload($(this),"yt",e.val(),{YTExtractAudio:$("#option-yt-extractaudio").prop("checked"),YTForceIPv4:$("#option-yt-forceipv4").prop("checked")}):OCDLR.Utils.PrintError(t("ocdownloader","Invalid URL. Please check the address of the file ...")),e.val(""),$("#option-yt-extractaudio").prop("checked",!1),$("#option-yt-forceipv4").prop("checked",!0)}),$("#app-content-wrapper .content-page[rel=OCDBT] div.launch").bind("click",function(){var e=$("#TorrentsList").children("a"),o=t("ocdownloader","Select a file.torrent");e.text().trim()!=o.trim()&&"File"==e.prop("data-rel")&&OCDLR.Utils.AddDownload($(this),"bt",e.text(),{BTRMTorrent:$("#option-bt-rmtorrent").prop("checked")}),e.text(o),$("#option-bt-rmtorrent").prop("checked",!0)});var e=$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile #uploadfile").fileupload({autoUpload:!0,sequentialUploads:!0,type:"POST",dataType:"json"});e.on("fileuploadstart",function(t,e){$("#TorrentsList").children("ul").hide(),$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile label").removeClass("icon-upload"),$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile label").addClass("icon-loading-small"),$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile input").prop("disabled",!0)}),e.on("fileuploaddone",function(t,e){e.result.ERROR?OCDLR.Utils.PrintError(e.result.MESSAGE):OCDLR.Utils.PrintInfo(e.result.MESSAGE),$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile input").prop("disabled",!1),$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile label").removeClass("icon-loading-small"),$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile label").addClass("icon-upload")}),e.on("fileuploadfail",function(e,o){OCDLR.Utils.PrintError(t("ocdownloader","Error while uploading torrent file"))}),OCDLR.Utils.GetCounters()});
\ No newline at end of file
+$(document).ready(function(){$("#ball").Badger("...");$("#bcompletes").Badger("...");$("#bactives").Badger("...");$("#bwaitings").Badger("...");$("#bstopped").Badger("...");$("#bremoved").Badger("...");OCDLR.Utils.UpdateQueue(true,"add");$("#NewDL").bind("click",function(){if($(this).children("ul").is(":visible")){$(this).children("ul").hide()}else{$(this).children("ul").show()}});$("#NewDL").children("div").children("p").bind("click",function(){$("#app-content-wrapper .content-page").hide();$("#app-content-wrapper .content-page[rel="+$(this).attr("data-rel")+"]").show()});$("#NewDL").children("div").bind("click",function(){$("#app-content-wrapper .content-page").hide();$("#app-content-wrapper .content-page[rel="+$(this).attr("data-rel")+"]").show()});$("#option-ftp-pasv").prop("checked",true);$("#option-yt-extractaudio").prop("checked",false);$("#option-yt-forceipv4").prop("checked",true);$("#option-bt-rmtorrent").prop("checked",true);$("#TorrentsList").bind("click",function(){OCDLR.Utils.GetTorrentsList($(this).children("ul"))});$("#app-content-wrapper .content-page[rel=OCDURI] input.url").bind("input",function(){var InputURL=$(this).val();if(OCDLR.Utils.ValidURL(InputURL)){var dHandler=$("#app-content-wrapper .content-page[rel=OCDURI] div.handler");var dButtom=$("#app-content-wrapper .content-page[rel=OCDURI] div.launch");var dOptions=$("#app-content-wrapper .content-page[rel=OCDURI] div[rel=OCDOPTIONS]");var handler=OCDLR.Utils.GetHandler(dHandler,dButtom,dOptions,InputURL)}});$("#app-content-wrapper .content-page[rel=OCDURI] div.launch").bind("click",function(){var InputURL=$("#app-content-wrapper .content-page[rel=OCDURI] input.url");if(OCDLR.Utils.ValidURL(InputURL.val())){var OPTIONS={};var inputs=$("#app-content-wrapper .content-page div[rel=OCDOPTIONS]").find(":input");$.each(inputs,function(k,v){var id=$(this).attr("id");var val=$(this).val();OPTIONS[id]=val});OCDLR.Utils.AddDownload($(this),"http",InputURL.val(),OPTIONS)}else{OCDLR.Utils.PrintError(t("ocdownloader","Invalid URL. Please check the address of the file ..."))}InputURL.val("");$("#option-http-user").val("");$("#option-http-pwd").val("")});$("#app-content-wrapper .content-page[rel=OCDHTTP] div.launch").bind("click",function(){var InputURL=$(this).parent().parent().children("input.url");if(OCDLR.Utils.ValidURL(InputURL.val())){OCDLR.Utils.AddDownload($(this),"http",InputURL.val(),{HTTPUser:$("#option-http-user").val(),HTTPPasswd:$("#option-http-pwd").val()})}else{OCDLR.Utils.PrintError(t("ocdownloader","Invalid URL. Please check the address of the file ..."))}InputURL.val("");$("#option-http-user").val("");$("#option-http-pwd").val("")});$("#app-content-wrapper .content-page[rel=OCDFTP] div.launch").bind("click",function(){var InputURL=$(this).parent().parent().children("input.url");if(OCDLR.Utils.ValidURL(InputURL.val())){OCDLR.Utils.AddDownload($(this),"ftp",InputURL.val(),{FTPUser:$("#option-ftp-user").val(),FTPPasswd:$("#option-ftp-pwd").val(),FTPPasv:$("#option-ftp-pasv").prop("checked")})}else{OCDLR.Utils.PrintError(t("ocdownloader","Invalid URL. Please check the address of the file ..."))}InputURL.val("");$("#option-ftp-user").val("");$("#option-ftp-pwd").val("");$("#option-ftp-pasv").prop("checked",true)});$("#app-content-wrapper .content-page[rel=OCDYT] div.launch").bind("click",function(){var InputURL=$(this).parent().parent().children("input.url");if(OCDLR.Utils.ValidURL(InputURL.val())){OCDLR.Utils.AddDownload($(this),"yt",InputURL.val(),{YTExtractAudio:$("#option-yt-extractaudio").prop("checked"),YTForceIPv4:$("#option-yt-forceipv4").prop("checked")})}else{OCDLR.Utils.PrintError(t("ocdownloader","Invalid URL. Please check the address of the file ..."))}InputURL.val("");$("#option-yt-extractaudio").prop("checked",false);$("#option-yt-forceipv4").prop("checked",true)});$("#app-content-wrapper .content-page[rel=OCDBT] div.launch").bind("click",function(){var InputFile=$("#TorrentsList").children("a");var SELECTTEXT=t("ocdownloader","Select a file.torrent");if(InputFile.text().trim()!=SELECTTEXT.trim()&&InputFile.prop("data-rel")=="File"){OCDLR.Utils.AddDownload($(this),"bt",InputFile.text(),{BTRMTorrent:$("#option-bt-rmtorrent").prop("checked")})}InputFile.text(SELECTTEXT);$("#option-bt-rmtorrent").prop("checked",true)});var FileUpload=$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile #uploadfile").fileupload({autoUpload:true,sequentialUploads:true,type:"POST",dataType:"json"});FileUpload.on("fileuploadstart",function(E,Data){$("#TorrentsList").children("ul").hide();$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile label").removeClass("icon-upload");$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile label").addClass("icon-loading-small");$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile input").prop("disabled",true)});FileUpload.on("fileuploaddone",function(E,Data){if(!Data.result.ERROR){OCDLR.Utils.PrintInfo(Data.result.MESSAGE)}else{OCDLR.Utils.PrintError(Data.result.MESSAGE)}$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile input").prop("disabled",false);$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile label").removeClass("icon-loading-small");$("#app-content-wrapper .content-page[rel=OCDBT] div.uploadfile label").addClass("icon-upload")});FileUpload.on("fileuploadfail",function(E,Data){OCDLR.Utils.PrintError(t("ocdownloader","Error while uploading torrent file"))});OCDLR.Utils.GetCounters()});
diff --git a/js/all.js b/js/all.js
index b1eda46..772b36e 100644
--- a/js/all.js
+++ b/js/all.js
@@ -20,4 +20,65 @@ $(document).ready (function ()
OCDLR.Utils.UpdateQueue (true, 'all');
OCDLR.Utils.GetCounters ();
+
+ // new UI APP
+
+ $('ul#filters li').on("click", function() {
+ var active = $('ul#filters').data('active');
+ id = 'ul#filters li[data-id='+ active + ']';
+ $(id).removeClass('active');
+
+ $('ul#filters').data('active', $(this).data('id') );
+ $(this).addClass('active');
+
+ OCDLR.Utils.UpdateQueue (true, $(this).data('id') );
+
+ // call api Queue
+
+
+ });
+
+ // Analisis URI
+ $('#app-content-wrapper .content-page[rel=OCDURI] input.url').bind ('input', function()
+ {
+ var InputURL = $(this).val();
+ if (OCDLR.Utils.ValidURL (InputURL))
+ {
+ var dHandler = $('#app-content-wrapper .content-page[rel=OCDURI] div.handler');
+ var dButtom = $('#app-content-wrapper .content-page[rel=OCDURI] div.launch')
+ var dOptions = $('#app-content-wrapper .content-page[rel=OCDURI] div[rel=OCDOPTIONS]')
+ var handler = OCDLR.Utils.GetHandler(dHandler, dButtom, dOptions, InputURL);
+ }
+
+ });
+ // Launch URI download
+ $('#app-content-wrapper .content-page[rel=OCDURI] div.launch').bind ('click', function ()
+ {
+ var InputURL = $('#app-content-wrapper .content-page[rel=OCDURI] input.url');
+
+ if (OCDLR.Utils.ValidURL (InputURL.val ()))
+ {
+ var OPTIONS = {};
+ // FIXME: get options.
+ var inputs = $('#app-content-wrapper .content-page div[rel=OCDOPTIONS]').find(':input');
+ $.each(inputs, function(k,v) {
+ var id = $(this).attr('id');
+ var val = $(this).is(':checkbox') ? $(this).prop ('checked') : $(this).val();
+ OPTIONS[id] = val;
+ });
+
+
+ OCDLR.Utils.AddDownload ($(this), 'http', InputURL.val (), OPTIONS);
+ }
+ else
+ {
+ OCDLR.Utils.PrintError (t ('ocdownloader', 'Invalid URL. Please check the address of the file ...'));
+ }
+
+ InputURL.val ('');
+ $('#app-content-wrapper .content-page[rel=OCDURI] div.handler').hide();
+// $('#app-content-wrapper .content-page[rel=OCDURI] div.handler').empty();
+
+ });
+
});
\ No newline at end of file
diff --git a/js/all.min.js b/js/all.min.js
new file mode 100644
index 0000000..cd787e1
--- /dev/null
+++ b/js/all.min.js
@@ -0,0 +1 @@
+$(document).ready(function(){$("#ball").Badger("...");$("#bcompletes").Badger("...");$("#bactives").Badger("...");$("#bwaitings").Badger("...");$("#bstopped").Badger("...");$("#bremoved").Badger("...");OCDLR.Utils.UpdateQueue(true,"all");OCDLR.Utils.GetCounters();$("ul#filters li").on("click",function(){var a=$("ul#filters").data("active");id="ul#filters li[data-id="+a+"]";$(id).removeClass("active");$("ul#filters").data("active",$(this).data("id"));$(this).addClass("active");OCDLR.Utils.UpdateQueue(true,$(this).data("id"))});$("#app-content-wrapper .content-page[rel=OCDURI] input.url").bind("input",function(){var b=$(this).val();if(OCDLR.Utils.ValidURL(b)){var e=$("#app-content-wrapper .content-page[rel=OCDURI] div.handler");var a=$("#app-content-wrapper .content-page[rel=OCDURI] div.launch");var d=$("#app-content-wrapper .content-page[rel=OCDURI] div[rel=OCDOPTIONS]");var c=OCDLR.Utils.GetHandler(e,a,d,b)}});$("#app-content-wrapper .content-page[rel=OCDURI] div.launch").bind("click",function(){var a=$("#app-content-wrapper .content-page[rel=OCDURI] input.url");if(OCDLR.Utils.ValidURL(a.val())){var c={};var b=$("#app-content-wrapper .content-page div[rel=OCDOPTIONS]").find(":input");$.each(b,function(e,d){var g=$(this).attr("id");var f=$(this).is(":checkbox")?$(this).prop("checked"):$(this).val();c[g]=f});OCDLR.Utils.AddDownload($(this),"http",a.val(),c)}else{OCDLR.Utils.PrintError(t("ocdownloader","Invalid URL. Please check the address of the file ..."))}a.val("");$("#app-content-wrapper .content-page[rel=OCDURI] div.handler").hide()})});
\ No newline at end of file
diff --git a/js/ocdownloader.js b/js/ocdownloader.js
index 89d127a..0446a72 100644
--- a/js/ocdownloader.js
+++ b/js/ocdownloader.js
@@ -14,7 +14,7 @@ OCDLR = {};
{
OCDLR.Utils =
{
- BaseURL: '/apps/ocdownloader/',
+ BaseURL: '/ocs/v1.php/apps/ocdownloader/api/',
BaseID: '#app-content-wrapper ',
MenuID: '#app-navigation ',
Queue: '',
@@ -27,7 +27,7 @@ OCDLR = {};
ValidURL: function (URLString)
{
- return /^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(URLString);
+ return /^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(URLString) || /magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32}/i.test(URLString);
},
PrintError: function (Msg)
@@ -78,18 +78,18 @@ OCDLR = {};
{
$(OCDLRSelf.BaseID + '.loadingtext').show ();
$.ajax ({
- url: OC.generateUrl (OCDLRSelf.BaseURL + 'queue/get'),
+ url: OC.generateUrl (OCDLRSelf.BaseURL + 'queue'),
method: 'POST',
- data: {'VIEW' : View},
- dataType: 'json',
- async: true,
+ data: {'VIEW' : View, 'format': 'json'},
+ dataType: 'json',
+ async: true,
cache: false,
timeout: 30000,
success: function (Data)
{
- if (Data.ERROR)
+ if (Data.ocs.data.ERROR)
{
- OCDLRSelf.PrintError (Data.MESSAGE);
+ OCDLRSelf.PrintError (Data.ocs.data.MESSAGE);
}
else
{
@@ -97,16 +97,16 @@ OCDLR = {};
{
$(OCDLRSelf.QueueElt + '[data-rel="LOADER"]').remove ();
}
-
- $('#ball').Badger (Data.COUNTER.ALL);
- $('#bcompletes').Badger (Data.COUNTER.COMPLETES);
- $('#bactives').Badger (Data.COUNTER.ACTIVES);
- $('#bwaitings').Badger (Data.COUNTER.WAITINGS);
- $('#bstopped').Badger (Data.COUNTER.STOPPED);
- $('#bremoved').Badger (Data.COUNTER.REMOVED);
+ // FIXME: split this
+ // $('#ball').Badger (Data.COUNTER.ALL);
+ // $('#bcompletes').Badger (Data.COUNTER.COMPLETES);
+ // $('#bactives').Badger (Data.COUNTER.ACTIVES);
+ // $('#bwaitings').Badger (Data.COUNTER.WAITINGS);
+ // $('#bstopped').Badger (Data.COUNTER.STOPPED);
+ // $('#bremoved').Badger (Data.COUNTER.REMOVED);
var DBGIDS = [];
- $.each (Data.QUEUE, function (Index, Value)
+ $.each (Data.ocs.data.QUEUE, function (Index, Value)
{
var QueueElt = OCDLRSelf.QueueElt + '[data-rel="' + Value.GID + '"]';
DBGIDS.push (Value.GID);
@@ -125,7 +125,7 @@ OCDLR = {};
OCDLRSelf.ActionUnPause ($(QueueElt + ' > td[data-rel="ACTION"]'), View);
}
- if (Value.PROGRESSVAL == '100%')
+ if (Value.PROGRESSVAL == '100')
{
$(QueueElt + ' > td[data-rel="FILENAME"]').html ('' + Value.FILENAME_SHORT + '');
@@ -158,7 +158,7 @@ OCDLR = {};
$(QueueElt + ' > td[data-rel="MESSAGE"] > div.pb-wrap > div.pb-value > div.pb-text').html (Value.PROGRESS);
$(QueueElt + ' > td[data-rel="MESSAGE"] > div.pb-wrap > div.pb-value').css ('width', Value.PROGRESSVAL);
- $(QueueElt + ' > td[data-rel="STATUS"]').text (Value.STATUS);
+ $(QueueElt + ' > td[data-rel="STATUS"]').text (Value.STATUS.Value);
});
OCDLRSelf.RemoveQueueItems (DBGIDS);
@@ -168,7 +168,7 @@ OCDLR = {};
}
});
}
- OCDLRSelf.UpdateQueue ((View == 'add' ? false : true), View);
+ //OCDLRSelf.UpdateQueue ((View == 'add' ? false : true), View);
}, 3000);
},
@@ -629,12 +629,13 @@ OCDLR = {};
}
else
{
- $('#ball').Badger (Data.COUNTER.ALL);
- $('#bcompletes').Badger (Data.COUNTER.COMPLETES);
- $('#bactives').Badger (Data.COUNTER.ACTIVES);
- $('#bwaitings').Badger (Data.COUNTER.WAITINGS);
- $('#bstopped').Badger (Data.COUNTER.STOPPED);
- $('#bremoved').Badger (Data.COUNTER.REMOVED);
+ Data = Data.ocs.data;
+ $('#ball').Badger (Data.ALL);
+ $('#bcompletes').Badger (Data.COMPLETES);
+ $('#bactives').Badger (Data.ACTIVES);
+ $('#bwaitings').Badger (Data.WAITINGS);
+ $('#bstopped').Badger (Data.STOPPED);
+ $('#bremoved').Badger (Data.REMOVED);
}
}
});
@@ -642,14 +643,31 @@ OCDLR = {};
PrependToQueue: function (Data, View)
{
+ // FIXME: should use a row template
$(OCDLRSelf.Queue + '> tbody').prepend ('' +
- '' + Data.FILENAME_SHORT + ' | ' +
- '' + t ('ocdownloader', Data.PROTO) + ' | ' +
- ' | ' +
- (['add', 'actives', 'all'].indexOf (View) > -1 ? '' + Data.SPEED + ' | ' : '') +
- (['add', 'all'].indexOf (View) > -1 ? '' + Data.STATUS + ' | ' : '') +
- ' | ' +
- '
'
+ ' | ' +
+ '' +
+ '' +
+ '' +
+ '' + Data.FILENAME_SHORT + '' +
+ '' +
+ '' +
+ ' | ' +
+ ''+
+ '' +
+ ' ' + Data.PROGRESS.ProgressString + ' ' +
+ ' ' +
+ ' '+
+ ' | ' +
+ ''+
+ ' ' + Data.STATUS.Value + ' ' +
+ '' + Data.SPEED + ' ' +
+ ' | ' +
+ ''
);
var ActionTD = $(OCDLRSelf.QueueElt + '[data-rel="' + Data.GID + '"] > td[data-rel="ACTION"]');
@@ -734,6 +752,102 @@ OCDLR = {};
}
},
+ GetHandler: function (Handler, Button, Options, URL)
+ {
+ var RESULT = false;
+
+
+ if (!Button.hasClass ('icon-loading-small'))
+ {
+ Button.children ('a').css ('display', 'none');
+ Button.addClass ('icon-loading-small');
+
+ var LIST = Options.children('div.group-option');
+ LIST.empty ();
+ LIST.show ();
+
+ $.ajax ({
+ url: OC.generateUrl ("/ocs/v1.php/apps/ocdownloader/api/handler"),
+ method: 'POST',
+ dataType: 'json',
+ data: {'URL' : URL, 'format': 'json'},
+ async: true,
+ cache: false,
+ timeout: 30000,
+ success: function (Data)
+ {
+ $('#app-content-wrapper div[rel=OCDINFO]').remove();
+ $('#app-content-wrapper div[rel=OCDOPTIONS]').remove();
+ if (Data.ocs.data.ERROR)
+ {
+ if (Data.ocs.data.hasOwnProperty('HANDLER'))
+ Handler.addClass ('info red').text (Data.ocs.data.HANDLER);
+ else
+ Handler.removeClass ('info red');
+
+ OCDLRSelf.PrintError (Data.ocs.data.MESSAGE);
+ }
+ else
+ {
+ Handler.removeClass ('info alert red');
+ Handler.addClass ('info green').text (Data.ocs.data.HANDLER);
+
+ OCDLRSelf.PrintInfo ("");
+
+
+ if (Data.ocs.data.hasOwnProperty('INFO')) {
+
+ $('#app-content-wrapper .content-page[rel=OCDURI]')
+ .append('INFO
');
+ $.each(Data.ocs.data.INFO, function (k,v) {
+ //alert( k + ": " + v );
+ $('div[rel=OCDINFO]').append(''+ k + ': '+ v +'');
+ });
+
+ //$('#app-content-wrapper .content-page[rel=OCDURI]')
+ // .append('INFO
');
+ //$('div[rel=OCDINFO]').append(nfo);
+ }
+
+ if (Data.ocs.data.hasOwnProperty('OPTIONS')) {
+ $('#app-content-wrapper .content-page[rel=OCDURI]')
+ .append('Options
');
+ $.each(Data.ocs.data.OPTIONS, function (k,v) {
+ //alert( k + ": " + v );
+ $('div[rel=OCDOPTIONS]').append('');
+ });
+
+ }
+
+ // show options
+ Options.css ('display', 'block');
+ //OCDLRSelf.PrintInfo (Data.MESSAGE + ' (' + Data.GID + ')');
+ //OCDLRSelf.PrependToQueue (Data, 'add');
+
+/* $('#ball').Badger ('+1');
+ if (Data.STATUSID == 1)
+ {
+ $('#bactives').Badger ('+1');
+ }
+ if (Data.STATUSID == 3)
+ {
+ $('#bwaitings').Badger ('+1');
+ } */
+
+ RESULT = true;
+ }
+ Handler.show();
+
+ // Reset add button
+ Button.children ('a').css ('display', 'block');
+ Button.removeClass ('icon-loading-small');
+ }
+ });
+ }
+
+ return RESULT;
+ },
+
AddDownload: function (Button, TYPE, URL, OPTIONS)
{
var RESULT = false;
@@ -744,16 +858,16 @@ OCDLR = {};
Button.addClass ('icon-loading-small');
$.ajax ({
- url: OC.generateUrl (OCDLRSelf.BaseURL + TYPE + 'downloader/add'),
+ url: OC.generateUrl (OCDLRSelf.BaseURL + 'add'),
method: 'POST',
- dataType: 'json',
- data: {'FILE' : URL, 'OPTIONS' : OPTIONS},
+ dataType: 'json',
+ data: {'URL' : URL, 'OPTIONS' : OPTIONS, 'format': 'json'},
async: true,
cache: false,
timeout: 30000,
success: function (Data)
{
- if (Data.ERROR)
+ if (Data.ERROR)
{
OCDLRSelf.PrintError (Data.MESSAGE);
}
@@ -773,7 +887,11 @@ OCDLR = {};
}
RESULT = true;
- }
+
+ $('#app-content-wrapper div[rel=OCDINFO]').remove();
+ $('#app-content-wrapper div[rel=OCDOPTIONS]').remove();
+
+ }
// Reset add button
Button.children ('a').css ('display', 'block');
diff --git a/js/ocdownloader.min.js b/js/ocdownloader.min.js
index 593e815..a89c33b 100644
--- a/js/ocdownloader.min.js
+++ b/js/ocdownloader.min.js
@@ -1 +1 @@
-OCDLR={},function(){OCDLR.Utils={BaseURL:"/apps/ocdownloader/",BaseID:"#app-content-wrapper ",MenuID:"#app-navigation ",Queue:"",QueueHeader:"",QueueElt:"",DownloadsFolder:"",TorrentsFolder:"",WhichDownloader:"",BadgerStatus:[],ValidURL:function(e){return/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(e)},PrintError:function(e){$(OCDLRSelf.BaseID+"span.muted").removeClass("info alert"),$(OCDLRSelf.BaseID+"span.muted").addClass("alert").text(e)},PrintInfo:function(e){$(OCDLRSelf.BaseID+"span.muted").removeClass("info alert"),$(OCDLRSelf.BaseID+"span.muted").addClass("info").text(e)},CheckVersion:function(){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"updater/check"),method:"GET",dataType:"json",async:!0,cache:!1,timeout:3e4,success:function(e){!e.ERROR&&e.RESULT&&($(OCDLRSelf.MenuID+".nav-updater").show(),$(OCDLRSelf.MenuID+".nav-updater .button").bind("click",function(){OCDLRSelf.AddDownload($(this),"http","https://github.com/e-alfred/ocdownloader/archive/master.zip",{HTTPUser:"",HTTPPasswd:""})}))}})},UpdateQueue:function(e,a){var t=setInterval(function(){clearInterval(t),$(OCDLRSelf.QueueElt).length>0&&($(OCDLRSelf.BaseID+".loadingtext").show(),$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/get"),method:"POST",data:{VIEW:a},dataType:"json",async:!0,cache:!1,timeout:3e4,success:function(t){if(t.ERROR)OCDLRSelf.PrintError(t.MESSAGE);else{0!=$(OCDLRSelf.QueueElt+'[data-rel="LOADER"]').length&&$(OCDLRSelf.QueueElt+'[data-rel="LOADER"]').remove(),$("#ball").Badger(t.COUNTER.ALL),$("#bcompletes").Badger(t.COUNTER.COMPLETES),$("#bactives").Badger(t.COUNTER.ACTIVES),$("#bwaitings").Badger(t.COUNTER.WAITINGS),$("#bstopped").Badger(t.COUNTER.STOPPED),$("#bremoved").Badger(t.COUNTER.REMOVED);var l=[];$.each(t.QUEUE,function(t,d){var n=OCDLRSelf.QueueElt+'[data-rel="'+d.GID+'"]';l.push(d.GID),e&&0==$(n).length&&OCDLRSelf.PrependToQueue(d,a),0==$(n+' > td[data-rel="ACTION"] > div.icon-pause').length&&1==d.STATUSID&&OCDLRSelf.ActionPause($(n+' > td[data-rel="ACTION"]'),a),0==$(n+' > td[data-rel="ACTION"] > div.icon-play').length&&3==d.STATUSID&&OCDLRSelf.ActionUnPause($(n+' > td[data-rel="ACTION"]'),a),"100%"==d.PROGRESSVAL?($(n+' > td[data-rel="FILENAME"]').html(''+d.FILENAME_SHORT+""),d.ISTORRENT&&"--"!=d.SPEED?$(n+' > td[data-rel="SPEED"]').html(''+d.SPEED):($(n+' > td[data-rel="SPEED"]').html(d.SPEED),d.ISTORRENT||($(n+' > td[data-rel="ACTION"] > div.icon-pause').remove(),$(n+' > td[data-rel="ACTION"] > div.icon-play').remove()))):"--"!=d.SPEED?$(n+' > td[data-rel="SPEED"]').html(''+d.SPEED):$(n+' > td[data-rel="SPEED"]').html(d.SPEED),$(n+' > td[data-rel="MESSAGE"] > div.pb-wrap > div.pb-value > div.pb-text').html(d.PROGRESS),$(n+' > td[data-rel="MESSAGE"] > div.pb-wrap > div.pb-value').css("width",d.PROGRESSVAL),$(n+' > td[data-rel="STATUS"]').text(d.STATUS)}),OCDLRSelf.RemoveQueueItems(l)}$(OCDLRSelf.BaseID+".loadingtext").hide()}})),OCDLRSelf.UpdateQueue("add"!=a,a)},3e3)},RemoveQueueItem:function(e){1==e.parent().children().length&&$(OCDLRSelf.Queue+' th[data-rel="ACTION"] > div').remove(),e.remove()},RemoveQueueItems:function(e){$(OCDLRSelf.QueueElt).each(function(){-1==e.indexOf($(this).attr("data-rel"))&&$(this).remove()}),0==$(OCDLRSelf.QueueElt).length&&$(OCDLRSelf.Queue+'> thead th[data-rel="ACTION"] > div').remove()},HideFromQueue:function(e){e.addClass("icon-loading-small"),e.removeClass("icon-close");var a=e.parent().parent(),l=a.attr("data-rel");l?$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/hide"),method:"POST",dataType:"json",data:{GID:l},async:!0,cache:!1,timeout:3e4,success:function(t){t.ERROR?(OCDLRSelf.PrintError(t.MESSAGE),e.addClass("icon-close"),e.removeClass("icon-loading-small")):(OCDLRSelf.PrintInfo(t.MESSAGE+" ("+l+")"),OCDLRSelf.RemoveQueueItem(a))}}):OCDLRSelf.PrintError(t("ocdownloader","Unable to find the GID for this download ..."))},HideAllFromQueue:function(e){e.addClass("icon-loading-small"),e.removeClass("icon-close");var a=[];$(OCDLRSelf.QueueElt+' td[data-rel="ACTION"] > div.icon-close').each(function(){$(this).addClass("icon-loading-small"),$(this).removeClass("icon-close"),a.push($(this).parent().parent().attr("data-rel"))}),a.length>0?$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/hideall"),method:"POST",dataType:"json",data:{GIDS:a},async:!0,cache:!1,timeout:3e4,success:function(e){e.ERROR?OCDLRSelf.PrintError(e.MESSAGE):(OCDLRSelf.PrintInfo(e.MESSAGE),$.each(e.QUEUE,function(e,a){$(OCDLRSelf.QueueElt+'[data-rel="'+a.GID+'"]').remove()}),$(OCDLRSelf.Queue+' th[data-rel="ACTION"] > div.icon-loading-small').remove())}}):OCDLRSelf.PrintError(t("ocdownloader","No downloads in the queue ..."))},PauseDownload:function(e,a){e.addClass("icon-loading-small"),e.removeClass("icon-pause"),$("#bactives").Badger("-1"),$("#bstopped").Badger("+1");var l=e.parent().parent(),d=l.attr("data-rel");d?$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/pause"),method:"POST",dataType:"json",data:{GID:d},async:!0,cache:!1,timeout:3e4,success:function(n){n.ERROR?(OCDLRSelf.PrintError(n.MESSAGE),e.addClass("icon-pause")):(OCDLRSelf.PrintInfo(n.MESSAGE+" ("+d+")"),["add","all"].indexOf(a)>-1?(e.addClass("icon-play"),e.parent().parent().children('td[data-rel="STATUS"]').attr("data-statusid",3),e.parent().parent().children('td[data-rel="STATUS"]').text(t("ocdownloader","Paused")),e.unbind("click"),e.bind("click",function(){OCDLRSelf.UnPauseDownload($(this),a)})):OCDLRSelf.RemoveQueueItem(l)),e.removeClass("icon-loading-small")}}):OCDLRSelf.PrintError(t("ocdownloader","Unable to find the GID for this download ..."))},UnPauseDownload:function(e,a){e.addClass("icon-loading-small"),e.removeClass("icon-play"),$("#bactives").Badger("+1"),$("#bstopped").Badger("-1");var l=e.parent().parent(),d=l.attr("data-rel");d?$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/unpause"),method:"POST",dataType:"json",data:{GID:d},async:!0,cache:!1,timeout:3e4,success:function(n){n.ERROR?(OCDLRSelf.PrintError(n.MESSAGE),e.addClass("icon-play")):(OCDLRSelf.PrintInfo(n.MESSAGE+" ("+d+")"),["add","all"].indexOf(a)>-1?(e.addClass("icon-pause"),e.parent().parent().children('td[data-rel="STATUS"]').attr("data-statusid",1),e.parent().parent().children('td[data-rel="STATUS"]').text(t("ocdownloader","Active")),e.unbind("click"),e.bind("click",function(){OCDLRSelf.PauseDownload($(this),a)})):OCDLRSelf.RemoveQueueItem(l)),e.removeClass("icon-loading-small")}}):OCDLRSelf.PrintError(t("ocdownloader","Unable to find the GID for this download ..."))},RemoveFromQueue:function(e,a,l){e.addClass("icon-loading-small"),e.removeClass("icon-delete");var d=e.parent().parent(),n=d.attr("data-rel");n?$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/"+a+"remove"),method:"POST",dataType:"json",data:{GID:n},async:!0,cache:!1,timeout:3e4,success:function(o){if(o.ERROR)OCDLRSelf.PrintError(o.MESSAGE),e.addClass("icon-delete"),e.removeClass("icon-loading-small");else if(OCDLRSelf.PrintInfo(o.MESSAGE+" ("+n+")"),"all"!=l||a.length>0)OCDLRSelf.RemoveQueueItem(d);else if("3"==d.children('td[data-rel="STATUS"]').attr("data-statusid"))$("#bremoved").Badger("-1"),$("#ball").Badger("-1"),OCDLRSelf.RemoveFromQueue(e,"completely",l);else{var i=e.parent();i.children("div").remove(),i.parent().children('td[data-rel="STATUS"]').text(t("ocdownloader","Removed")),OCDLRSelf.ActionDeleteCompletely(i)}}}):OCDLRSelf.PrintError(t("ocdownloader","Unable to find the GID for this download ..."))},RemoveAllFromQueue:function(e,a,l){e.addClass("icon-loading-small"),e.removeClass("icon-delete");var d=[];$(OCDLRSelf.QueueElt+' td[data-rel="ACTION"] > div.icon-delete').each(function(){$(this).addClass("icon-loading-small"),$(this).removeClass("icon-delete"),d.push($(this).parent().parent().attr("data-rel"))}),d.length>0?$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/"+a+"removeall"),method:"POST",dataType:"json",data:{GIDS:d},async:!0,cache:!1,timeout:3e4,success:function(e){e.ERROR?OCDLRSelf.PrintError(e.MESSAGE):(OCDLRSelf.PrintInfo(e.MESSAGE),OCDLRSelf.RemoveQueueItems(e.GIDS),a.length>0?($("#bremoved").Badger("-"+d.length),$("#ball").Badger("-"+d.length)):($("#bremoved").Badger("+"+d.length),$("#b"+l).Badger("-"+d.length)))}}):OCDLRSelf.PrintError(t("ocdownloader","Unable to find the GID for this download ..."))},GetPersonalSettings:function(){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"personalsettings/get"),method:"GET",dataType:"json",async:!1,cache:!1,timeout:3e4,success:function(Data){Data.ERROR||$.each(Data.VALS,function(Key,Value){eval("OCDLRSelf."+Key+'="'+Value+'"')})}})},GetAdminSettings:function(KEYS){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"adminsettings/get"),method:"POST",dataType:"json",data:{KEYS:KEYS},async:!1,cache:!1,timeout:3e4,success:function(Data){Data.ERROR||$.each(Data.VALS,function(Key,Value){eval("OCDLRSelf."+Key+'="'+Value+'"')})}})},GetTorrentsList:function(e){e.is(":visible")?e.hide():(e.empty(),e.append('
'),e.show(),$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"btdownloader/listtorrentfiles"),method:"POST",dataType:"json",async:!0,cache:!1,timeout:3e4,success:function(a){if(a.ERROR)OCDLRSelf.PrintError(a.MESSAGE);else if(e.empty(),0==a.FILES.length)e.append(""+t("ocdownloader","No Torrent Files")+', '+t("ocdownloader","Upload")+"
");else{for(var l=0;l'+a.FILES[l].name+"
");e.children("li").children("p.clickable").bind("click",function(){e.parent().children("a").prop("data-rel","File"),e.parent().children("a").html($(this).text()+'')})}}}))},GetCounters:function(){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/count"),method:"POST",dataType:"json",async:!0,cache:!1,timeout:3e4,success:function(e){e.ERROR?OCDLRSelf.PrintError(e.MESSAGE):($("#ball").Badger(e.COUNTER.ALL),$("#bcompletes").Badger(e.COUNTER.COMPLETES),$("#bactives").Badger(e.COUNTER.ACTIVES),$("#bwaitings").Badger(e.COUNTER.WAITINGS),$("#bstopped").Badger(e.COUNTER.STOPPED),$("#bremoved").Badger(e.COUNTER.REMOVED))}})},PrependToQueue:function(e,a){$(OCDLRSelf.Queue+"> tbody").prepend(''+e.FILENAME_SHORT+' | '+t("ocdownloader",e.PROTO)+' | | "+(["add","actives","all"].indexOf(a)>-1?''+e.SPEED+" | ":"")+(["add","all"].indexOf(a)>-1?''+e.STATUS+" | ":"")+' |
');var l=$(OCDLRSelf.QueueElt+'[data-rel="'+e.GID+'"] > td[data-rel="ACTION"]');if(["add"].indexOf(a)>-1){OCDLRSelf.ActionHide(l),1==e.STATUSID?OCDLRSelf.ActionPause(l,a):3==e.STATUSID&&OCDLRSelf.ActionPlay(l,a);var d=OCDLRSelf.Queue+'> thead th[data-rel="ACTION"] > div.icon-close';0==$(d).length&&($(OCDLRSelf.Queue+'> thead th[data-rel="ACTION"]').append(''),$(d).bind("click",function(){OCDLRSelf.HideAllFromQueue($(this))}))}if(["completes","waitings","stopped","actives"].indexOf(a)>-1){OCDLRSelf.ActionDelete(l,OCDLRSelf.BadgerStatus[e.STATUSID],a);var n=OCDLRSelf.Queue+'> thead th[data-rel="ACTION"] > div.icon-delete';0==$(n).length&&($(OCDLRSelf.Queue+'> thead th[data-rel="ACTION"]').append(''),$(n).bind("click",function(){OCDLRSelf.RemoveAllFromQueue($(this),"",a)}))}if("all"==a&&(4==e.STATUSID?OCDLRSelf.ActionDeleteCompletely(l):(OCDLRSelf.ActionDelete(l,OCDLRSelf.BadgerStatus[e.STATUSID],a),1==e.STATUSID?OCDLRSelf.ActionPause(l,a):3==e.STATUSID&&OCDLRSelf.ActionPlay(l,a))),"actives"==a&&OCDLRSelf.ActionPause(l,a),"stopped"==a&&OCDLRSelf.ActionPlay(l,a),"removed"==a){OCDLRSelf.ActionDeleteCompletely(l);var o=OCDLRSelf.Queue+'> thead th[data-rel="ACTION"] > div.icon-delete';0==$(o).length&&($(OCDLRSelf.Queue+'> thead th[data-rel="ACTION"]').append(''),$(o).bind("click",function(){OCDLRSelf.RemoveAllFromQueue($(this),"completely",a)}))}},AddDownload:function(e,a,t,l){var d=!1;return e.hasClass("icon-loading-small")||(e.children("a").css("display","none"),e.addClass("icon-loading-small"),$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+a+"downloader/add"),method:"POST",dataType:"json",data:{FILE:t,OPTIONS:l},async:!0,cache:!1,timeout:3e4,success:function(a){a.ERROR?OCDLRSelf.PrintError(a.MESSAGE):(OCDLRSelf.PrintInfo(a.MESSAGE+" ("+a.GID+")"),OCDLRSelf.PrependToQueue(a,"add"),$("#ball").Badger("+1"),1==a.STATUSID&&$("#bactives").Badger("+1"),3==a.STATUSID&&$("#bwaitings").Badger("+1"),d=!0),e.children("a").css("display","block"),e.removeClass("icon-loading-small")}})),d},ActionHide:function(e){e.append(''),e.children("div.icon-close").bind("click",function(){OCDLRSelf.HideFromQueue($(this))})},ActionPause:function(e,a){"ARIA2"==OCDLRSelf.WhichDownloader&&(e.append(''),e.children("div.icon-pause").bind("click",function(){OCDLRSelf.PauseDownload($(this),a)}))},ActionPlay:function(e,a){"ARIA2"==OCDLRSelf.WhichDownloader&&(e.append(''),e.children("div.icon-play").bind("click",function(){OCDLRSelf.UnPauseDownload($(this),a)}))},ActionDelete:function(e,a,t){e.append(''),e.children("div.icon-delete").bind("click",function(){$("#bremoved").Badger("+1"),$("#b"+a).Badger("-1"),OCDLRSelf.RemoveFromQueue($(this),"",t)})},ActionDeleteCompletely:function(e){e.append(''),e.children("div.icon-delete").bind("click",function(){$("#bremoved").Badger("-1"),$("#ball").Badger("-1"),OCDLRSelf.RemoveFromQueue($(this),"completely","removed")})}};var OCDLRSelf=OCDLR.Utils;OCDLRSelf.GetPersonalSettings(),OCDLRSelf.GetAdminSettings(["WhichDownloader"]),OCDLRSelf.Queue=OCDLRSelf.BaseID+"#Queue ",OCDLRSelf.QueueHeader=OCDLRSelf.Queue+"thead tr",OCDLRSelf.QueueElt=OCDLRSelf.Queue+"tbody tr",OCDLRSelf.BadgerStatus=["completes","actives","waitings","stopped"]}();
\ No newline at end of file
+OCDLR={};(function(){OCDLR.Utils={BaseURL:"/ocs/v1.php/apps/ocdownloader/api/",BaseID:"#app-content-wrapper ",MenuID:"#app-navigation ",Queue:"",QueueHeader:"",QueueElt:"",DownloadsFolder:"",TorrentsFolder:"",WhichDownloader:"",BadgerStatus:[],ValidURL:function(URLString){return/^([a-z]([a-z]|\d|\+|-|\.)*):(\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?((\[(|(v[\da-f]{1,}\.(([a-z]|\d|-|\.|_|~)|[!\$&'\(\)\*\+,;=]|:)+))\])|((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=])*)(:\d*)?)(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*|(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)|((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)){0})(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(URLString)||/magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32}/i.test(URLString)},PrintError:function(Msg){$(OCDLRSelf.BaseID+"span.muted").removeClass("info alert");$(OCDLRSelf.BaseID+"span.muted").addClass("alert").text(Msg)},PrintInfo:function(Msg){$(OCDLRSelf.BaseID+"span.muted").removeClass("info alert");$(OCDLRSelf.BaseID+"span.muted").addClass("info").text(Msg)},CheckVersion:function(){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"updater/check"),method:"GET",dataType:"json",async:true,cache:false,timeout:30000,success:function(Data){if(!Data.ERROR&&Data.RESULT){$(OCDLRSelf.MenuID+".nav-updater").show();$(OCDLRSelf.MenuID+".nav-updater .button").bind("click",function(){OCDLRSelf.AddDownload($(this),"http","https://github.com/e-alfred/ocdownloader/archive/master.zip",{HTTPUser:"",HTTPPasswd:""})})}}})},UpdateQueue:function(DynMode,View){var IntervalHandle=setInterval(function(){clearInterval(IntervalHandle);if($(OCDLRSelf.QueueElt).length>0){$(OCDLRSelf.BaseID+".loadingtext").show();$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue"),method:"POST",data:{VIEW:View,format:"json"},dataType:"json",async:true,cache:false,timeout:30000,success:function(Data){if(Data.ocs.data.ERROR){OCDLRSelf.PrintError(Data.ocs.data.MESSAGE)}else{if($(OCDLRSelf.QueueElt+'[data-rel="LOADER"]').length!=0){$(OCDLRSelf.QueueElt+'[data-rel="LOADER"]').remove()}var DBGIDS=[];$.each(Data.ocs.data.QUEUE,function(Index,Value){var QueueElt=OCDLRSelf.QueueElt+'[data-rel="'+Value.GID+'"]';DBGIDS.push(Value.GID);if(DynMode&&$(QueueElt).length==0){OCDLRSelf.PrependToQueue(Value,View)}if($(QueueElt+' > td[data-rel="ACTION"] > div.icon-pause').length==0&&Value.STATUSID==1){OCDLRSelf.ActionPause($(QueueElt+' > td[data-rel="ACTION"]'),View)}if($(QueueElt+' > td[data-rel="ACTION"] > div.icon-play').length==0&&Value.STATUSID==3){OCDLRSelf.ActionUnPause($(QueueElt+' > td[data-rel="ACTION"]'),View)}if(Value.PROGRESSVAL=="100"){$(QueueElt+' > td[data-rel="FILENAME"]').html(''+Value.FILENAME_SHORT+"");if(Value.ISTORRENT&&Value.SPEED!="--"){$(QueueElt+' > td[data-rel="SPEED"]').html(''+Value.SPEED)}else{$(QueueElt+' > td[data-rel="SPEED"]').html(Value.SPEED);if(!Value.ISTORRENT){$(QueueElt+' > td[data-rel="ACTION"] > div.icon-pause').remove();$(QueueElt+' > td[data-rel="ACTION"] > div.icon-play').remove()}}}else{if(Value.SPEED!="--"){$(QueueElt+' > td[data-rel="SPEED"]').html(''+Value.SPEED)}else{$(QueueElt+' > td[data-rel="SPEED"]').html(Value.SPEED)}}$(QueueElt+' > td[data-rel="MESSAGE"] > div.pb-wrap > div.pb-value > div.pb-text').html(Value.PROGRESS);$(QueueElt+' > td[data-rel="MESSAGE"] > div.pb-wrap > div.pb-value').css("width",Value.PROGRESSVAL);$(QueueElt+' > td[data-rel="STATUS"]').text(Value.STATUS.Value)});OCDLRSelf.RemoveQueueItems(DBGIDS)}$(OCDLRSelf.BaseID+".loadingtext").hide()}})}},3000)},RemoveQueueItem:function(Item){if(Item.parent().children().length==1){$(OCDLRSelf.Queue+' th[data-rel="ACTION"] > div').remove()}Item.remove()},RemoveQueueItems:function(Items){$(OCDLRSelf.QueueElt).each(function(){if(Items.indexOf($(this).attr("data-rel"))==-1){$(this).remove()}});if($(OCDLRSelf.QueueElt).length==0){$(OCDLRSelf.Queue+'> thead th[data-rel="ACTION"] > div').remove()}},HideFromQueue:function(Button){Button.addClass("icon-loading-small");Button.removeClass("icon-close");var TR=Button.parent().parent();var GID=TR.attr("data-rel");if(GID){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/hide"),method:"POST",dataType:"json",data:{GID:GID},async:true,cache:false,timeout:30000,success:function(Data){if(Data.ERROR){OCDLRSelf.PrintError(Data.MESSAGE);Button.addClass("icon-close");Button.removeClass("icon-loading-small")}else{OCDLRSelf.PrintInfo(Data.MESSAGE+" ("+GID+")");OCDLRSelf.RemoveQueueItem(TR)}}})}else{OCDLRSelf.PrintError(t("ocdownloader","Unable to find the GID for this download ..."))}},HideAllFromQueue:function(Button){Button.addClass("icon-loading-small");Button.removeClass("icon-close");var GIDS=[];$(OCDLRSelf.QueueElt+' td[data-rel="ACTION"] > div.icon-close').each(function(){$(this).addClass("icon-loading-small");$(this).removeClass("icon-close");GIDS.push($(this).parent().parent().attr("data-rel"))});if(GIDS.length>0){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/hideall"),method:"POST",dataType:"json",data:{GIDS:GIDS},async:true,cache:false,timeout:30000,success:function(Data){if(Data.ERROR){OCDLRSelf.PrintError(Data.MESSAGE)}else{OCDLRSelf.PrintInfo(Data.MESSAGE);$.each(Data.QUEUE,function(Index,Value){$(OCDLRSelf.QueueElt+'[data-rel="'+Value.GID+'"]').remove()});$(OCDLRSelf.Queue+' th[data-rel="ACTION"] > div.icon-loading-small').remove()}}})}else{OCDLRSelf.PrintError(t("ocdownloader","No downloads in the queue ..."))}},PauseDownload:function(Button,View){Button.addClass("icon-loading-small");Button.removeClass("icon-pause");$("#bactives").Badger("-1");$("#bstopped").Badger("+1");var TR=Button.parent().parent();var GID=TR.attr("data-rel");if(GID){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/pause"),method:"POST",dataType:"json",data:{GID:GID},async:true,cache:false,timeout:30000,success:function(Data){if(Data.ERROR){OCDLRSelf.PrintError(Data.MESSAGE);Button.addClass("icon-pause")}else{OCDLRSelf.PrintInfo(Data.MESSAGE+" ("+GID+")");if(["add","all"].indexOf(View)>-1){Button.addClass("icon-play");Button.parent().parent().children('td[data-rel="STATUS"]').attr("data-statusid",3);Button.parent().parent().children('td[data-rel="STATUS"]').text(t("ocdownloader","Paused"));Button.unbind("click");Button.bind("click",function(){OCDLRSelf.UnPauseDownload($(this),View)})}else{OCDLRSelf.RemoveQueueItem(TR)}}Button.removeClass("icon-loading-small")}})}else{OCDLRSelf.PrintError(t("ocdownloader","Unable to find the GID for this download ..."))}},UnPauseDownload:function(Button,View){Button.addClass("icon-loading-small");Button.removeClass("icon-play");$("#bactives").Badger("+1");$("#bstopped").Badger("-1");var TR=Button.parent().parent();var GID=TR.attr("data-rel");if(GID){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/unpause"),method:"POST",dataType:"json",data:{GID:GID},async:true,cache:false,timeout:30000,success:function(Data){if(Data.ERROR){OCDLRSelf.PrintError(Data.MESSAGE);Button.addClass("icon-play")}else{OCDLRSelf.PrintInfo(Data.MESSAGE+" ("+GID+")");if(["add","all"].indexOf(View)>-1){Button.addClass("icon-pause");Button.parent().parent().children('td[data-rel="STATUS"]').attr("data-statusid",1);Button.parent().parent().children('td[data-rel="STATUS"]').text(t("ocdownloader","Active"));Button.unbind("click");Button.bind("click",function(){OCDLRSelf.PauseDownload($(this),View)})}else{OCDLRSelf.RemoveQueueItem(TR)}}Button.removeClass("icon-loading-small")}})}else{OCDLRSelf.PrintError(t("ocdownloader","Unable to find the GID for this download ..."))}},RemoveFromQueue:function(Button,Completely,View){Button.addClass("icon-loading-small");Button.removeClass("icon-delete");var TR=Button.parent().parent();var GID=TR.attr("data-rel");if(GID){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/"+Completely+"remove"),method:"POST",dataType:"json",data:{GID:GID},async:true,cache:false,timeout:30000,success:function(Data){if(Data.ERROR){OCDLRSelf.PrintError(Data.MESSAGE);Button.addClass("icon-delete");Button.removeClass("icon-loading-small")}else{OCDLRSelf.PrintInfo(Data.MESSAGE+" ("+GID+")");if(View!="all"||Completely.length>0){OCDLRSelf.RemoveQueueItem(TR)}else{if(TR.children('td[data-rel="STATUS"]').attr("data-statusid")=="3"){$("#bremoved").Badger("-1");$("#ball").Badger("-1");OCDLRSelf.RemoveFromQueue(Button,"completely",View)}else{var TD=Button.parent();TD.children("div").remove();TD.parent().children('td[data-rel="STATUS"]').text(t("ocdownloader","Removed"));OCDLRSelf.ActionDeleteCompletely(TD)}}}}})}else{OCDLRSelf.PrintError(t("ocdownloader","Unable to find the GID for this download ..."))}},RemoveAllFromQueue:function(Button,Completely,View){Button.addClass("icon-loading-small");Button.removeClass("icon-delete");var GIDS=[];$(OCDLRSelf.QueueElt+' td[data-rel="ACTION"] > div.icon-delete').each(function(){$(this).addClass("icon-loading-small");$(this).removeClass("icon-delete");GIDS.push($(this).parent().parent().attr("data-rel"))});if(GIDS.length>0){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/"+Completely+"removeall"),method:"POST",dataType:"json",data:{GIDS:GIDS},async:true,cache:false,timeout:30000,success:function(Data){if(Data.ERROR){OCDLRSelf.PrintError(Data.MESSAGE)}else{OCDLRSelf.PrintInfo(Data.MESSAGE);OCDLRSelf.RemoveQueueItems(Data.GIDS);if(Completely.length>0){$("#bremoved").Badger("-"+GIDS.length);$("#ball").Badger("-"+GIDS.length)}else{$("#bremoved").Badger("+"+GIDS.length);$("#b"+View).Badger("-"+GIDS.length)}}}})}else{OCDLRSelf.PrintError(t("ocdownloader","Unable to find the GID for this download ..."))}},GetPersonalSettings:function(){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"personalsettings/get"),method:"GET",dataType:"json",async:false,cache:false,timeout:30000,success:function(Data){if(!Data.ERROR){$.each(Data.VALS,function(Key,Value){eval("OCDLRSelf."+Key+'="'+Value+'"')})}}})},GetAdminSettings:function(KEYS){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"adminsettings/get"),method:"POST",dataType:"json",data:{KEYS:KEYS},async:false,cache:false,timeout:30000,success:function(Data){if(!Data.ERROR){$.each(Data.VALS,function(Key,Value){eval("OCDLRSelf."+Key+'="'+Value+'"')})}}})},GetTorrentsList:function(LIST){if(LIST.is(":visible")){LIST.hide()}else{LIST.empty();LIST.append('
');LIST.show();$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"btdownloader/listtorrentfiles"),method:"POST",dataType:"json",async:true,cache:false,timeout:30000,success:function(Data){if(Data.ERROR){OCDLRSelf.PrintError(Data.MESSAGE)}else{LIST.empty();if(Data.FILES.length==0){LIST.append(""+t("ocdownloader","No Torrent Files")+', '+t("ocdownloader","Upload")+"
")}else{for(var I=0;I'+Data.FILES[I].name+"
")}}LIST.children("li").children("p.clickable").bind("click",function(){LIST.parent().children("a").prop("data-rel","File");LIST.parent().children("a").html($(this).text()+'')})}}}})}},GetCounters:function(){$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"queue/count"),method:"POST",dataType:"json",async:true,cache:false,timeout:30000,success:function(Data){if(Data.ERROR){OCDLRSelf.PrintError(Data.MESSAGE)}else{Data=Data.ocs.data;$("#ball").Badger(Data.ALL);$("#bcompletes").Badger(Data.COMPLETES);$("#bactives").Badger(Data.ACTIVES);$("#bwaitings").Badger(Data.WAITINGS);$("#bstopped").Badger(Data.STOPPED);$("#bremoved").Badger(Data.REMOVED)}}})},PrependToQueue:function(Data,View){$(OCDLRSelf.Queue+"> tbody").prepend(' | '+Data.FILENAME_SHORT+' | '+Data.PROGRESS.ProgressString+' | '+Data.STATUS.Value+' '+Data.SPEED+" |
");var ActionTD=$(OCDLRSelf.QueueElt+'[data-rel="'+Data.GID+'"] > td[data-rel="ACTION"]');if(["add"].indexOf(View)>-1){OCDLRSelf.ActionHide(ActionTD);if(Data.STATUSID==1){OCDLRSelf.ActionPause(ActionTD,View)}else{if(Data.STATUSID==3){OCDLRSelf.ActionPlay(ActionTD,View)}}var HideAllButton=OCDLRSelf.Queue+'> thead th[data-rel="ACTION"] > div.icon-close';if($(HideAllButton).length==0){$(OCDLRSelf.Queue+'> thead th[data-rel="ACTION"]').append('');$(HideAllButton).bind("click",function(){OCDLRSelf.HideAllFromQueue($(this))})}}if(["completes","waitings","stopped","actives"].indexOf(View)>-1){OCDLRSelf.ActionDelete(ActionTD,OCDLRSelf.BadgerStatus[Data.STATUSID],View);var RemoveAllButton=OCDLRSelf.Queue+'> thead th[data-rel="ACTION"] > div.icon-delete';if($(RemoveAllButton).length==0){$(OCDLRSelf.Queue+'> thead th[data-rel="ACTION"]').append('');$(RemoveAllButton).bind("click",function(){OCDLRSelf.RemoveAllFromQueue($(this),"",View)})}}if(View=="all"){if(Data.STATUSID==4){OCDLRSelf.ActionDeleteCompletely(ActionTD)}else{OCDLRSelf.ActionDelete(ActionTD,OCDLRSelf.BadgerStatus[Data.STATUSID],View);if(Data.STATUSID==1){OCDLRSelf.ActionPause(ActionTD,View)}else{if(Data.STATUSID==3){OCDLRSelf.ActionPlay(ActionTD,View)}}}}if(View=="actives"){OCDLRSelf.ActionPause(ActionTD,View)}if(View=="stopped"){OCDLRSelf.ActionPlay(ActionTD,View)}if(View=="removed"){OCDLRSelf.ActionDeleteCompletely(ActionTD);var CompletelyRemoveAllButton=OCDLRSelf.Queue+'> thead th[data-rel="ACTION"] > div.icon-delete';if($(CompletelyRemoveAllButton).length==0){$(OCDLRSelf.Queue+'> thead th[data-rel="ACTION"]').append('');$(CompletelyRemoveAllButton).bind("click",function(){OCDLRSelf.RemoveAllFromQueue($(this),"completely",View)})}}},GetHandler:function(Handler,Button,Options,URL){var RESULT=false;if(!Button.hasClass("icon-loading-small")){Button.children("a").css("display","none");Button.addClass("icon-loading-small");var LIST=Options.children("div.group-option");LIST.empty();LIST.show();$.ajax({url:OC.generateUrl("/ocs/v1.php/apps/ocdownloader/api/handler"),method:"POST",dataType:"json",data:{URL:URL,format:"json"},async:true,cache:false,timeout:30000,success:function(Data){$("#app-content-wrapper div[rel=OCDINFO]").remove();$("#app-content-wrapper div[rel=OCDOPTIONS]").remove();if(Data.ocs.data.ERROR){if(Data.ocs.data.hasOwnProperty("HANDLER")){Handler.addClass("info red").text(Data.ocs.data.HANDLER)}else{Handler.removeClass("info red")}OCDLRSelf.PrintError(Data.ocs.data.MESSAGE)}else{Handler.removeClass("info alert red");Handler.addClass("info green").text(Data.ocs.data.HANDLER);OCDLRSelf.PrintInfo("");if(Data.ocs.data.hasOwnProperty("INFO")){$("#app-content-wrapper .content-page[rel=OCDURI]").append('INFO
');$.each(Data.ocs.data.INFO,function(k,v){$("div[rel=OCDINFO]").append(""+k+": "+v+"")})}if(Data.ocs.data.hasOwnProperty("OPTIONS")){$("#app-content-wrapper .content-page[rel=OCDURI]").append('Options
');$.each(Data.ocs.data.OPTIONS,function(k,v){$("div[rel=OCDOPTIONS]").append('')})}Options.css("display","block");RESULT=true}Handler.show();Button.children("a").css("display","block");Button.removeClass("icon-loading-small")}})}return RESULT},AddDownload:function(Button,TYPE,URL,OPTIONS){var RESULT=false;if(!Button.hasClass("icon-loading-small")){Button.children("a").css("display","none");Button.addClass("icon-loading-small");$.ajax({url:OC.generateUrl(OCDLRSelf.BaseURL+"add"),method:"POST",dataType:"json",data:{URL:URL,OPTIONS:OPTIONS,format:"json"},async:true,cache:false,timeout:30000,success:function(Data){if(Data.ERROR){OCDLRSelf.PrintError(Data.MESSAGE)}else{OCDLRSelf.PrintInfo(Data.MESSAGE+" ("+Data.GID+")");OCDLRSelf.PrependToQueue(Data,"add");$("#ball").Badger("+1");if(Data.STATUSID==1){$("#bactives").Badger("+1")}if(Data.STATUSID==3){$("#bwaitings").Badger("+1")}RESULT=true;$("#app-content-wrapper div[rel=OCDINFO]").remove();$("#app-content-wrapper div[rel=OCDOPTIONS]").remove()}Button.children("a").css("display","block");Button.removeClass("icon-loading-small")}})}return RESULT},ActionHide:function(TD){TD.append('');TD.children("div.icon-close").bind("click",function(){OCDLRSelf.HideFromQueue($(this))})},ActionPause:function(TD,View){if(OCDLRSelf.WhichDownloader=="ARIA2"){TD.append('');TD.children("div.icon-pause").bind("click",function(){OCDLRSelf.PauseDownload($(this),View)})}},ActionPlay:function(TD,View){if(OCDLRSelf.WhichDownloader=="ARIA2"){TD.append('');TD.children("div.icon-play").bind("click",function(){OCDLRSelf.UnPauseDownload($(this),View)})}},ActionDelete:function(TD,Status,View){TD.append('');TD.children("div.icon-delete").bind("click",function(){$("#bremoved").Badger("+1");$("#b"+Status).Badger("-1");OCDLRSelf.RemoveFromQueue($(this),"",View)})},ActionDeleteCompletely:function(TD){TD.append('');TD.children("div.icon-delete").bind("click",function(){$("#bremoved").Badger("-1");$("#ball").Badger("-1");OCDLRSelf.RemoveFromQueue($(this),"completely","removed")})}};var OCDLRSelf=OCDLR.Utils;OCDLRSelf.GetPersonalSettings();OCDLRSelf.GetAdminSettings(["WhichDownloader"]);OCDLRSelf.Queue=OCDLRSelf.BaseID+"#Queue ";OCDLRSelf.QueueHeader=OCDLRSelf.Queue+"thead tr";OCDLRSelf.QueueElt=OCDLRSelf.Queue+"tbody tr";OCDLRSelf.BadgerStatus=["completes","actives","waitings","stopped"]})();
\ No newline at end of file
diff --git a/lib/Backend/BackendException.php b/lib/Backend/BackendException.php
new file mode 100644
index 0000000..ed0841f
--- /dev/null
+++ b/lib/Backend/BackendException.php
@@ -0,0 +1,7 @@
+
diff --git a/lib/Backend/FtpBackend.php b/lib/Backend/FtpBackend.php
new file mode 100644
index 0000000..a20664d
--- /dev/null
+++ b/lib/Backend/FtpBackend.php
@@ -0,0 +1,20 @@
+ $URL,
+ 'FILENAME' => Tools::CleanString (substr($URL, strrpos($URL, '/') + 1)),
+ 'PROTO' => strtoupper (substr ($URL, 0, strpos ($URL, ':')))
+ );
+ return $DL;
+ }
+
+ public function no_add(IRequest $request) {
+ $URL = $request->get('URL');
+ $DL = Array (
+ 'URL' => $URL,
+ 'FILENAME' => Tools::CleanString (substr($URL, strrpos($URL, '/') + 1)),
+ 'PROTO' => strtoupper (substr ($URL, 0, strpos ($URL, ':')))
+ );
+
+
+ }
+}
diff --git a/lib/Backend/IBackendDownloader.php b/lib/Backend/IBackendDownloader.php
new file mode 100644
index 0000000..d56f5ad
--- /dev/null
+++ b/lib/Backend/IBackendDownloader.php
@@ -0,0 +1,208 @@
+WhichDownloader = self::DOWNLOADER_ARIA;
+ $this->DownloadsFolder = "/Downloads";
+ #FIXME: Files PATH.gl.
+ $this->AbsoluteDownloadsFolder = $userSession->getUser()->getHome().'/files'.$this->DownloadsFolder;
+ $this->CurrentUID = $userSession->getUser()->getUID();
+ $this->DBService = $dbservice;
+
+ $this->L10N = $L10N;
+ $this->setIdentifier($this->name);
+
+}
+
+ /**
+ * Return regex text
+ * @return string
+ */
+ public function getPattern() {
+ return $this->pattern;
+ }
+
+ /**
+ * Return options for this backend
+ * @return array of options
+ */
+ public function getOptions() {
+ return $this->options;
+ }
+
+ /**
+ * Return true if the URI can be handled by the backend
+ * @param mixed $URI
+ * @return boolean [description]
+ */
+ public function checkURI($URI) {
+ $ret = preg_match ($this->pattern, $URI, $Matches);
+ if ($ret || count ($Matches) === 1)
+ {
+ return true;
+ }
+
+ return false;
+ }
+
+ public function checkURL($URL){
+ return $this->checkURI($URL);
+ }
+
+ public function getInfo($URI) {
+ return NULL;
+ }
+
+ public function parseOptions($OPTIONS) {
+ $OPTS = $this->getOptions();
+ foreach ($OPTS as $k => $v) {
+ $o = 'option-'.$v[0];
+ $OPTS[$k]['value'] = $OPTIONS[$o];
+ }
+
+ return (!$OPTS) ? Array() : $OPTS;
+ }
+
+ public function add($URI, $OPTIONS) {
+ try {
+ $DL = $this->getInfo($URI);
+ $OPTIONS = $this->parseOptions($OPTIONS);
+ $OPTIONS['PROTOCOL'] = $this->getIdentifier();
+
+
+ // Set global options
+ $OPTIONS = array_merge(
+ $OPTIONS,
+ Array (
+ 'dir' => $this->AbsoluteDownloadsFolder,
+ 'out' => $DL['FILENAME'],
+ 'follow-torrent' => $this->reqfollow()
+ )
+ );
+
+ if (!is_null ($this->getConfig('ProxyAddress')) && $this->getConfig('ProxyPort') > 0 && $this->getConfig('ProxyPort') <= 65536)
+ {
+ $OPTIONS['all-proxy'] = rtrim ($this->getConfig('ProxyAddress'), '/') . ':' . $this->getConfig('ProxyPort');
+ if (!is_null ($this->getConfig('ProxyUser')) && !is_null ($this->getConfig('ProxyPasswd')))
+ {
+ $OPTIONS['all-proxy-user'] = $this->getConfig('ProxyUser');
+ $OPTIONS['all-proxy-passwd'] = $this->getConfig('ProxyPasswd');
+ }
+ }
+
+ // call backend
+ $AddURI = $this->addUriHandler($URI, $OPTIONS);
+ $OPTIONS['result'] = $AddURI['result'];
+ $this->DBService->addQueue($this->CurrentUID, $OPTIONS);
+
+
+ return $DL;
+ } catch (Exception $E)
+ {
+ throw new BackendException('Unabletolaunchthedownload');
+ }
+
+ #FIXME: use custom exception
+ // \Exception('NotImplementedYet');
+ return false;
+ }
+
+
+ public function isAllowed() {
+ return false;
+ }
+
+ public function reqFollow() {
+ return false;
+ }
+
+ public function addUriHandler($URI, $OPTIONS) {
+ return ($this->WhichDownloader == 0 ?
+ Aria2::AddUri (Array ($URI), Array ('Params' => $OPTIONS)) :
+ Curl::AddUri ($URI, $OPTIONS));
+ }
+
+ public function getConfig($key) {
+
+ // try get cached
+ if (isset($this->settings[$key]))
+ return $this->settings[$key];
+
+ $Settings = new Settings ();
+
+ $keys = Array(
+ 'ProxyAddress',
+ 'ProxyPort',
+ 'ProxyUser',
+ 'ProxyPasswd',
+ 'WhichDownloader',
+ 'DownloadsFolder'
+ );
+
+ if (!in_array($key,$keys)) {
+ return NULL;
+ }
+
+ if ('DownloadsFolder' === $key) {
+ $Settings->SetTable ('personal');
+ $Settings->SetUID ($this->CurrentUID);
+ $Settings->SetKey ('DownloadsFolder');
+ $this->DownloadsFolder = $this->settings->GetValue ();
+ }
+
+ $Settings->SetKey ($key);
+ $ret = $Settings->GetValue();
+
+ // save cache
+ $this->settings[$key] = $ret;
+
+ return $ret;
+ }
+
+ public function getStatus($GID) {
+ return ($this->WhichDownloader == 0 ? Aria2::TellStatus ($GID) : CURL::TellStatus ($GID));
+ }
+
+}
diff --git a/lib/Backend/MagnetBackend.php b/lib/Backend/MagnetBackend.php
new file mode 100644
index 0000000..4973f03
--- /dev/null
+++ b/lib/Backend/MagnetBackend.php
@@ -0,0 +1,27 @@
+ $URI,
+ 'FILENAME' => $query['dn'],
+ 'PROTO' => 'TORRENT'
+ );
+ return $DL;
+
+ }
+
+ public function reqFollow() {
+ return true;
+ }
+
+}
diff --git a/lib/Backend/YTDLBackend.php b/lib/Backend/YTDLBackend.php
new file mode 100644
index 0000000..c51eba3
--- /dev/null
+++ b/lib/Backend/YTDLBackend.php
@@ -0,0 +1,93 @@
+YTDLBinary, $URI);
+
+ /* if (!is_null (self::$ProxyAddress) && self::$ProxyPort > 0 && self::$ProxyPort <= 65536)
+ {
+ $YouTube->SetProxy (self::$ProxyAddress, self::$ProxyPort);
+ } */
+
+ $VideoData = $YouTube->GetVideoData ();
+ if (!isset ($VideoData['VIDEO']) || !isset ($VideoData['FULLNAME']))
+ {
+ throw new BackendException('UnabletoretrievetrueYouTubevideoURL');
+ //return Array ('ERROR' => true, 'MESSAGE' => 'UnabletoretrievetrueYouTubevideoURL');
+ }
+ $DL = Array (
+ // 'URL' => $VideoData['VIDEO'],
+ 'FILENAME' => Tools::CleanString ($VideoData['FULLNAME']),
+ 'PROTO' => 'Video'
+ );
+ return $DL;
+ }
+
+ public function addUriHandler ($URI, $OPTIONS) {
+
+ $onlyAudio = false;
+ $ipv4 = false;
+
+ #$URI = $request->get('URI');
+ //$OPTIONS = parent::parseOptions($OPTIONS);
+ $YouTube = new Youtube ($this->YTDLBinary, $URI);
+
+ if (!is_null ($this->ProxyAddress) && $this->ProxyPort > 0 && $this->ProxyPort <= 65536)
+ {
+ $YouTube->SetProxy ($this->ProxyAddress, $this->ProxyPort);
+ }
+
+ foreach ($OPTIONS as $o) {
+ $k = $o[0];
+ switch ($k) {
+ case 'yt-foceipv4':
+ $ipv4 = ($o['value'] == 'on' ? true : false);
+ break;
+ case 'yt-extractaudio':
+ $onlyAudio = ($o['value'] == 'on' ? true : false);
+ break;
+ }
+ }
+
+ // Extract Audio YES
+ $YouTube->SetForceIPv4($ipv4);
+ $data = $YouTube->GetVideoData ($onlyAudio);
+ $k = ($onlyAudio ? 'AUDIO' : 'VIDEO');
+ if (!isset ($data[$k]) || !isset ($data['FULLNAME'])) {
+ throw new BackendException('Unable to retrieve true YouTube URL');
+ }
+
+ $URI = $data[$k];
+ $OPTIONS['out'] = Tools::CleanString ($data['FULLNAME']);
+ $OPTIONS['TYPE'] = 'YT '.ucfirst($k);
+
+
+ return parent::addUriHandler($URI, $OPTIONS);
+ }
+}
diff --git a/lib/Config/IBackendProvider.php b/lib/Config/IBackendProvider.php
new file mode 100644
index 0000000..a71d780
--- /dev/null
+++ b/lib/Config/IBackendProvider.php
@@ -0,0 +1,20 @@
+backendService = $backendService;
+ $this->userSession = $userSession;
+ $this->dbService = $dbService;
+ }
+
+ public function Add($URL, $OPTIONS) {
+ try {
+ $backend = $this->backendService->getBackendbyUri($URL);
+
+ $DL = $backend->add($URL, $OPTIONS);
+
+ return new DataResponse([
+ 'ERROR' => False,
+ 'FILENAME' => $DL['FILENAME']
+ ]);
+
+ } catch (BackendException $e) {
+
+ return new DataResponse([
+ 'ERROR' => true,
+ 'MESSAGE' => $e->getMessage()
+ ]);
+
+ }
+
+ }
+
+ public function Handler ($URL) {
+ try {
+ $backend = $this->backendService->getBackendByUri($URL);
+ $data = Array(
+ 'ERROR' => False,
+ 'HANDLER' => $backend->getIdentifier()
+ );
+ $info = $backend->getInfo($URL);
+ $options = $backend->getOptions($URL);
+ if ($info) $data['INFO'] = $info;
+ if ($options) $data['OPTIONS'] = $options;
+
+ return new DataResponse($data);
+
+ } catch (BackendException $e) {
+
+ return new DataResponse([
+ 'ERROR' => true,
+ 'MESSAGE' => $e->getMessage()
+ ]);
+
+ }
+
+ }
+
+ public function getQueue($VIEW) {
+ $filter = ($VIEW == 'all' ? [0,1,2,3,4] : [Tools::getDownloadStatusID($VIEW)]);
+
+ try {
+
+ $list = $this->dbService->getQueueByUser($this->userSession->getUser(), $filter);
+
+ return new DataResponse(array(
+ 'SQL' => $SQL,
+ 'ERROR' => false,
+ 'MESSAGE' => null,
+ 'QUEUE' => $this->backendService->updateStatusList($list),
+ #'COUNTER' => Tools::getCounters(self::$DbType, self::$CurrentUID)
+ ));
+
+ } catch (BackendException $e) {
+
+ return new DataResponse([
+ 'ERROR' => true,
+ 'MESSAGE' => $e->getMessage()
+ ]);
+
+ }
+ }
+
+ public function getCount() {
+ $ret = $this->dbService->getCounters($this->userSession->getUser());
+
+ foreach ($ret as $status) {
+ $st[ strtoupper(Tools::getStatusFromID($status['STATUS'])) ] = $status['TOTAL'];
+ $total += $status['TOTAL'];
+ }
+ $st['ALL'] = $total;
+
+ return new DataResponse ($st);
+
+ }
+
+}
diff --git a/controller/lib/aria2.php b/lib/Lib/Aria2.php
similarity index 98%
rename from controller/lib/aria2.php
rename to lib/Lib/Aria2.php
index a9d087e..7be3ed2 100644
--- a/controller/lib/aria2.php
+++ b/lib/Lib/Aria2.php
@@ -8,7 +8,7 @@
* @author Xavier Beurois
* @copyright Xavier Beurois 2015
*/
-namespace OCA\ocDownloader\Controller\Lib;
+namespace OCA\ocDownloader\Lib;
class Aria2
{
diff --git a/controller/lib/curl.php b/lib/Lib/Curl.php
similarity index 98%
rename from controller/lib/curl.php
rename to lib/Lib/Curl.php
index 6db3b9f..c9f0eb5 100644
--- a/controller/lib/curl.php
+++ b/lib/Lib/Curl.php
@@ -8,7 +8,7 @@
* @author Xavier Beurois
* @copyright Xavier Beurois 2015
*/
-namespace OCA\ocDownloader\Controller\Lib;
+namespace OCA\ocDownloader\Lib;
class CURL
{
diff --git a/lib/Lib/IdentifierTrait.php b/lib/Lib/IdentifierTrait.php
new file mode 100644
index 0000000..11c78ae
--- /dev/null
+++ b/lib/Lib/IdentifierTrait.php
@@ -0,0 +1,104 @@
+
+ * @author Roeland Jago Douma
+ *
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see
+ *
+ */
+
+namespace OCA\ocDOwnloader\Lib;
+
+/**
+ * Trait for objects requiring an identifier (and/or identifier aliases)
+ * Also supports deprecation to a different object, linking the objects
+ */
+trait IdentifierTrait {
+
+ /** @var string */
+ protected $identifier;
+
+ /** @var string[] */
+ protected $identifierAliases = [];
+
+ /** @var IdentifierTrait */
+ protected $deprecateTo = null;
+
+ /**
+ * @return string
+ */
+ public function getIdentifier() {
+ return $this->identifier;
+ }
+
+ /**
+ * @param string $identifier
+ * @return $this
+ */
+ public function setIdentifier($identifier) {
+ $this->identifier = $identifier;
+ $this->identifierAliases[] = $identifier;
+ return $this;
+ }
+
+ /**
+ * @return string[]
+ */
+ public function getIdentifierAliases() {
+ return $this->identifierAliases;
+ }
+
+ /**
+ * @param string $alias
+ * @return $this
+ */
+ public function addIdentifierAlias($alias) {
+ $this->identifierAliases[] = $alias;
+ return $this;
+ }
+
+ /**
+ * @return object|null
+ */
+ public function getDeprecateTo() {
+ return $this->deprecateTo;
+ }
+
+ /**
+ * @param object $destinationObject
+ * @return self
+ */
+ public function deprecateTo($destinationObject) {
+ $this->deprecateTo = $destinationObject;
+ return $this;
+ }
+
+ /**
+ * @return array
+ */
+ public function jsonSerializeIdentifier() {
+ $data = [
+ 'identifier' => $this->identifier,
+ 'identifierAliases' => $this->identifierAliases,
+ ];
+ if ($this->deprecateTo) {
+ $data['deprecateTo'] = $this->deprecateTo->getIdentifier();
+ }
+ return $data;
+ }
+
+}
diff --git a/controller/lib/settings.php b/lib/Lib/Settings.php
similarity index 99%
rename from controller/lib/settings.php
rename to lib/Lib/Settings.php
index 2e4997d..320bddd 100644
--- a/controller/lib/settings.php
+++ b/lib/Lib/Settings.php
@@ -9,7 +9,7 @@
* @copyright Xavier Beurois 2015
*/
-namespace OCA\ocDownloader\Controller\Lib;
+namespace OCA\ocDownloader\Lib;
diff --git a/controller/lib/tools.php b/lib/Lib/Tools.php
similarity index 90%
rename from controller/lib/tools.php
rename to lib/Lib/Tools.php
index 8de7c3a..51ee0a5 100644
--- a/controller/lib/tools.php
+++ b/lib/Lib/Tools.php
@@ -9,34 +9,29 @@
* @copyright Xavier Beurois 2015
*/
-namespace OCA\ocDownloader\Controller\Lib;
+namespace OCA\ocDownloader\Lib;
-use OCA\ocDownloader\Controller\Lib\Aria2;
+use OCA\ocDownloader\Lib\Aria2;
class Tools
{
- public static function checkURL($URL)
- {
- $URLPattern = '%^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}'
- .']+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.'
- .'[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?$%iu';
-
- preg_match($URLPattern, $URL, $Matches);
- if (count($Matches) === 1) {
- return true;
- }
- return false;
- }
-
- public static function isMagnet($URL)
- {
- $magnetPattern = '%magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32}%i';
- preg_match($magnetPattern, $URL, $Matches);
- if (count($Matches) === 1) {
- return true;
- }
- return false;
- }
+ public static function CheckURL ($URL)
+ {
+
+ $URLPatterns = Array(
+ '%^(?:(?:https?|ftp)://)(?:\S+(?::\S*)?@|\d{1,3}(?:\.\d{1,3}){3}|(?:(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)(?:\.(?:[a-z\d\x{00a1}-\x{ffff}]+-?)*[a-z\d\x{00a1}-\x{ffff}]+)*(?:\.[a-z\x{00a1}-\x{ffff}]{2,6}))(?::\d+)?(?:[^\s]*)?$%iu',
+ '%magnet:\?xt=urn:[a-z0-9]+:[a-z0-9]{32}%i'
+ );
+
+ foreach ($URLPatterns as $URLPattern) {
+ preg_match ($URLPattern, $URL, $Matches);
+ if (count ($Matches) === 1)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
public static function checkFilepath($FP)
{
diff --git a/controller/lib/youtube.php b/lib/Lib/Youtube.php
similarity index 100%
rename from controller/lib/youtube.php
rename to lib/Lib/Youtube.php
diff --git a/lib/Service/BackendService.php b/lib/Service/BackendService.php
new file mode 100644
index 0000000..d846894
--- /dev/null
+++ b/lib/Service/BackendService.php
@@ -0,0 +1,279 @@
+
+ * @author Robin McCorkell
+ *
+ * @license AGPL-3.0
+ *
+ * This code is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License, version 3,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License, version 3,
+ * along with this program. If not, see
+ *
+ */
+
+namespace OCA\ocDownloader\Service;
+
+use \OCP\IConfig;
+
+use OCA\ocDownloader\Backend\BackendException;
+use \OCA\ocDownloader\Backend\IBackendDownloader as Backend;
+use \OCA\ocDownloader\Config\IBackendProvider;
+
+use OCA\ocDownloader\Lib\Tools;
+
+/**
+ * Service class to manage backend definitions
+ */
+class BackendService {
+
+ /** Visibility constants for VisibilityTrait */
+ const VISIBILITY_NONE = 0;
+ const VISIBILITY_PERSONAL = 1;
+ const VISIBILITY_ADMIN = 2;
+ //const VISIBILITY_ALIENS = 4;
+
+ const VISIBILITY_DEFAULT = 3; // PERSONAL | ADMIN
+
+ /** Priority constants for PriorityTrait */
+ const PRIORITY_DEFAULT = 100;
+
+ /** @var IConfig */
+ protected $config;
+
+ /** @var bool */
+ private $userMountingAllowed = true;
+
+ /** @var string[] */
+ private $userMountingBackends = [];
+
+ /** @var Backend[] */
+ private $backends = [];
+
+ /** @var IBackendProvider[] */
+ private $backendProviders = [];
+
+ /**
+ * FIXME: USE config Interface
+ * @param IConfig $config
+ */
+ public function __construct(
+ //IConfig $config
+ ) {
+ //$this->config = $config;
+
+ // Load config values
+ /*if ($this->config->getAppValue('files_external', 'allow_user_mounting', 'yes') !== 'yes') {
+ $this->userMountingAllowed = false;
+ }
+ $this->userMountingBackends = explode(',',
+ $this->config->getAppValue('files_external', 'user_mounting_backends', '')
+ );
+
+ // if no backend is in the list an empty string is in the array and user mounting is disabled
+ if ($this->userMountingBackends === ['']) {
+ $this->userMountingAllowed = false;
+ }*/
+ $this->userMountingAllowed = true;
+ }
+
+ /**
+ * Register a backend provider
+ *
+ * @since 9.1.0
+ * @param IBackendProvider $provider
+ */
+ public function registerBackendProvider(IBackendProvider $provider) {
+ $this->backendProviders[] = $provider;
+ }
+
+ private function loadBackendProviders() {
+ foreach ($this->backendProviders as $provider) {
+ $this->registerBackends($provider->getBackends());
+ }
+ $this->backendProviders = [];
+ }
+
+ /**
+ * Register a backend
+ *
+ * @deprecated 9.1.0 use registerBackendProvider()
+ * @param Backend $backend
+ */
+ public function registerBackend(Backend $backend) {
+ if (!$this->isAllowedUserBackend($backend)) {
+ $backend->removeVisibility(BackendService::VISIBILITY_PERSONAL);
+ }
+ foreach ($backend->getIdentifierAliases() as $alias) {
+ $this->backends[$alias] = $backend;
+ }
+ }
+
+ /**
+ * @deprecated 9.1.0 use registerBackendProvider()
+ * @param Backend[] $backends
+ */
+ public function registerBackends(array $backends) {
+ foreach ($backends as $backend) {
+ $this->registerBackend($backend);
+ }
+ }
+
+ /**
+ * Get all backends
+ *
+ * @return Backend[]
+ */
+ public function getBackends() {
+ $this->loadBackendProviders();
+ // only return real identifiers, no aliases
+ $backends = [];
+ foreach ($this->backends as $backend) {
+ $backends[$backend->getIdentifier()] = $backend;
+ }
+ return $backends;
+ }
+
+ /**
+ * Get all available backends
+ *
+ * @return Backend[]
+ */
+ public function getAvailableBackends() {
+ return array_filter($this->getBackends(), function($backend) {
+ return !($backend->checkDependencies());
+ });
+ }
+
+ /**
+ * @param string $identifier
+ * @return Backend|null
+ */
+ public function getBackend($identifier) {
+ $this->loadBackendProviders();
+ if (isset($this->backends[$identifier])) {
+ return $this->backends[$identifier];
+ }
+ return null;
+ }
+
+ /**
+ * @return bool
+ */
+ public function isUserMountingAllowed() {
+ return $this->userMountingAllowed;
+ }
+
+ /**
+ * Check a backend if a user is allowed to mount it
+ * FIXME: really use this
+ * @param Backend $backend
+ * @return bool
+ */
+ protected function isAllowedUserBackend(Backend $backend) {
+ return true;
+ if ($this->userMountingAllowed &&
+ array_intersect($backend->getIdentifierAliases(), $this->userMountingBackends)
+ ) {
+ return true;
+ }
+ return false;
+ }
+
+ public function getBackendByUri($uri) {
+ $backend = false;
+
+ $be = $this->getBackends();
+ foreach ($be as $b) {
+ if ($b->checkUri($uri)) {
+ $backend = $b;
+ break;
+ }
+ }
+ if (!$backend)
+ throw new BackendException("no backends aviable");
+
+ return $backend;
+ }
+
+ /**
+ * list update status data from backend
+ * @param [type] $recordset [description]
+ * @return [array] [description]
+ */
+ public function updateStatusList($recordset) {
+ $rows = [];
+ foreach ($recordset as $row) {
+ //error_log($row['GID']);
+ // $backend = $this->getBackendByUri($row['']);
+ $status = $this->updateStatus($row);
+ $rows[] = $status;
+ }
+
+ return $rows;
+ }
+
+ /**
+ * get status from backend
+ * @param [array] $row [row of queue database]
+ * @return [array] map status
+ */
+ public function updateStatus($row) {
+ $ba = $this->getBackends();
+ $b = array_pop($ba);
+
+ $Status = $b->getStatus($row['GID']);
+
+ $Progress = 0;
+ if ($Status['result']['totalLength'] > 0) {
+ $Progress = $Status['result']['completedLength'] / $Status['result']['totalLength'];
+ }
+ $DLStatus = Tools::getDownloadStatusID($Status['result']['status']);
+ $ProgressString = Tools::getProgressString(
+ $Status['result']['completedLength'],
+ $Status['result']['totalLength'],
+ $Progress
+ );
+
+ $row = [
+ 'FILENAME_SHORT' => $row['FILENAME'],
+ 'GID' => $row['GID'],
+ 'PROGRESSVAL' => round((($Progress) * 100), 2),
+ 'PROGRESS' => [
+ 'ProgressString' => is_null($ProgressString)?'':$ProgressString,
+ ],
+ 'STATUS' => [
+ 'Value' => isset($Status['result']['status']) ?($row['STATUS'] == 4?'Removed':ucfirst($Status['result']['status'])):'N_A',
+ 'Seeding' => isset($Status['result']['bittorrent']) && $Progress == 1 && $DLStatus != 3?true:false
+ ],
+ 'STATUSID' => $row['STATUS'] == 4?4:$DLStatus,
+ 'SPEED' => isset($Status['result']['downloadSpeed'])
+ ?($Progress == 1
+ ?(isset($Status['result']['bittorrent'])
+ ?($Status['result']['uploadSpeed'] == 0
+ ?'--'
+ :Tools::formatSizeUnits($Status['result']['uploadSpeed']).'/s')
+ :'--')
+ :($DLStatus == 4
+ ?'--'
+ :Tools::formatSizeUnits($Status['result']['downloadSpeed']).'/s'))
+ :'',
+ 'FILENAME' => $row['FILENAME'],
+ 'PROTO' => $row['PROTOCOL'],
+ 'ISTORRENT' => isset($Status['result']['bittorrent']),
+ ];
+
+ //yield $row;
+ return $row;
+ }
+
+}
diff --git a/lib/Service/DBService.php b/lib/Service/DBService.php
new file mode 100644
index 0000000..cfd5a6f
--- /dev/null
+++ b/lib/Service/DBService.php
@@ -0,0 +1,86 @@
+connection = $connection;
+ }
+
+ /**
+ * @param IUser $user
+ * @return array
+ */
+ public function getQueueByUser(IUser $user, Array $status = []) {
+ $builder = $this->connection->getQueryBuilder();
+
+ $query = $builder->select('*')
+ ->from('ocdownloader_queue')
+ ->where(
+ $builder->expr()->eq('UID', $builder->createNamedParameter($user->getUID(), IQueryBuilder::PARAM_STR))
+ )
+ ->andwhere(
+ $builder->expr()->in('STATUS', $builder->createNamedParameter($status, IQueryBuilder::PARAM_INT_ARRAY))
+ )
+ ->andwhere(
+ $builder->expr()->in('IS_CLEANED', $builder->createNamedParameter([0,1], IQueryBuilder::PARAM_INT_ARRAY))
+ );
+
+ $result = $query->execute();
+
+ return $result;
+
+ }
+
+ public function addQueue($CurrentUID, $AddURI) {
+
+ $qb = $this->connection->getQueryBuilder();
+ $qb->insert('ocdownloader_queue')
+ ->values([
+ 'UID' => $qb->createNamedParameter($CurrentUID),
+ 'GID' => $qb->createNamedParameter($AddURI['result']),
+ 'FILENAME' => $qb->createNamedParameter($AddURI['out']),
+ 'PROTOCOL' => $qb->createNamedParameter($AddURI['PROTOCOL']),
+ 'STATUS' => $qb->createNamedParameter(1),
+ 'TIMESTAMP' => time(),
+ ]);
+ $ret = $qb->execute();
+ }
+
+ public function getCounters(IUser $user)
+ {
+ $qb = $this->connection->getQueryBuilder();
+ $query = $qb->select($qb->createFunction("COUNT(`id`) as TOTAL"), "STATUS")
+ ->from('ocdownloader_queue')
+ ->where(
+ $qb->expr()->eq('UID', $qb->createNamedParameter($user->getUID(), IQueryBuilder::PARAM_STR))
+ )
+ ->groupby('STATUS');
+
+ $result = $query->execute();
+
+ return $result;
+
+ }
+
+}
diff --git a/settings/admin.php b/settings/admin.php
index acfa5fc..37ab3c2 100644
--- a/settings/admin.php
+++ b/settings/admin.php
@@ -9,7 +9,7 @@
* @copyright Xavier Beurois 2015
*/
-use OCA\ocDownloader\Controller\Lib\Settings;
+use OCA\ocDownloader\Lib\Settings;
\OC_Util::checkAdminUser();
diff --git a/settings/personal.php b/settings/personal.php
index 9a7dc5e..3ea1081 100644
--- a/settings/personal.php
+++ b/settings/personal.php
@@ -9,7 +9,7 @@
* @copyright Xavier Beurois 2015
*/
-use OCA\ocDownloader\Controller\Lib\Settings;
+use OCA\ocDownloader\Lib\Settings;
\OCP\User::checkLoggedIn();
diff --git a/templates/add.php b/templates/add.php
index 1837a18..823e1dc 100644
--- a/templates/add.php
+++ b/templates/add.php
@@ -26,34 +26,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
t ('Add Download')); ?>
t (' using %s', $_['WD'])); ?>
-
+
+
+ t ('New URI download')); ?>
+
+
+
+
+
+
diff --git a/templates/all.php b/templates/all.php
index cb9dd82..150f713 100644
--- a/templates/all.php
+++ b/templates/all.php
@@ -8,43 +8,70 @@
* @author Xavier Beurois
* @copyright Xavier Beurois 2015
*/
-style ('ocdownloader', 'styles.min');
-script ('ocdownloader', 'badger.min');
-script ('ocdownloader', 'ocdownloader.min');
-script ('ocdownloader', 'all');
-
-if ($_['CANCHECKFORUPDATE']) script ('ocdownloader', 'updater');
+style('ocdownloader', 'styles.min');
+#FIXME: depends from files app
+style('files', 'merged');
+script('ocdownloader', 'badger.min');
+script('ocdownloader', 'ocdownloader.min');
+script('ocdownloader', 'all');
+
+if ($_['CANCHECKFORUPDATE']) {
+ script('ocdownloader', 'updater');
+}
?>
- inc ('part.navigation')); ?>
+ inc('part.navigation')); ?>
-
t ('All Downloads')); ?>
-
t (' using %s', $_['WD'])); ?>
+
-
-
-
-
- t ('FILENAME')); ?> |
- t ('PROTOCOL')); ?> |
- t ('INFORMATION')); ?> |
- t ('SPEED')); ?> |
- t ('STATUS')); ?> |
- |
-
-
-
-
- t ('Loading')); ?> ... |
-
-
-
-
-
t ('Loading')); ?> ...
+
+
t('Loading')); ?> ...
\ No newline at end of file
diff --git a/templates/part.navigation.php b/templates/part.navigation.php
index 4e71864..b334238 100644
--- a/templates/part.navigation.php
+++ b/templates/part.navigation.php
@@ -9,38 +9,35 @@
* @copyright Xavier Beurois 2015
*/
?>
-