diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-09-11 12:27:33 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-09-11 12:27:33 +0200 |
commit | 3c6887b839507e8c4029c1028d55846cbbfd845e (patch) | |
tree | 3f44337324d3d91cfaacfcd02964f3171eafbdcf /pyload/web/app | |
parent | improved link grabber (diff) | |
download | pyload-3c6887b839507e8c4029c1028d55846cbbfd845e.tar.xz |
container upload and url parser for linkgrabber
Diffstat (limited to 'pyload/web/app')
-rw-r--r-- | pyload/web/app/scripts/views/linkgrabber/modalView.js | 45 | ||||
-rwxr-xr-x | pyload/web/app/templates/default/linkgrabber/modal.html | 12 |
2 files changed, 49 insertions, 8 deletions
diff --git a/pyload/web/app/scripts/views/linkgrabber/modalView.js b/pyload/web/app/scripts/views/linkgrabber/modalView.js index 808d67f59..8e24f259b 100644 --- a/pyload/web/app/scripts/views/linkgrabber/modalView.js +++ b/pyload/web/app/scripts/views/linkgrabber/modalView.js @@ -6,7 +6,11 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v className: 'modal linkgrabber', events: { - 'keyup #inputLinks': 'addOnKeyUp' + 'keyup #inputLinks': 'addOnKeyUp', + 'click .btn-container': 'selectContainer', + 'change #inputContainer': 'checkContainer', + 'keyup #inputURL': 'checkURL', + 'click .btn-remove-all': 'clearAll' }, template: template, @@ -25,19 +29,19 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v addOnKeyUp: function(e) { // Enter adds the links if (e.keyCode === 13) - this.parseLinks(); + this.checkLinks(); var inputSize = this.$('#inputLinks').val().length; // TODO: checkbox to disable this // add links when several characters was pasted into box if (inputSize > this.inputSize + 4) - this.parseLinks(); + this.checkLinks(); else this.inputSize = inputSize; }, - parseLinks: function() { + checkLinks: function() { var self = this; // split, trim and remove empty links var links = _.filter(_.map(this.$('#inputLinks').val().split('\n'), function(link) { @@ -59,6 +63,39 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v this.inputSize = 0; }, + selectContainer: function(e) { + this.$('#inputContainer').trigger('click'); + }, + + checkContainer: function(e) { + this.$('form').attr('action', App.apiUrl('api/checkContainer')); + this.$('form').trigger('submit'); + }, + + checkURL: function(e) { + // check is triggered on enter + if (e.keyCode !== 13) + return; + + var self = this; + $.ajax(App.apiRequest('checkHTML', { + html: '', + url: $(e.target).val() + }, { + success: function(data) { + self.collectorView.updateData(data); + } + })); + + $(e.target).val(''); + }, + + // deletes every package + clearAll: function(e) { + this.collectorView.collection.reset(); + + }, + // Hide when there are no more packages onAdded: function() { if (this.collectorView !== null) { diff --git a/pyload/web/app/templates/default/linkgrabber/modal.html b/pyload/web/app/templates/default/linkgrabber/modal.html index 750613663..3c50aa037 100755 --- a/pyload/web/app/templates/default/linkgrabber/modal.html +++ b/pyload/web/app/templates/default/linkgrabber/modal.html @@ -14,18 +14,22 @@ <textarea id="inputLinks" rows="1" placeholder="{{_ " Paste your links here..."}}"></textarea> </div> <div class="span4"> - <h3 class="pull-left">{{_ "Container" }}</h3> - <button class="btn btn-blue">{{_ "Upload" }}</button> + <form action="" method="post" enctype="multipart/form-data" target="uploadTarget"> + <h3 class="pull-left">{{_ "Container" }}</h3> + <button class="btn btn-blue btn-container">{{_ "Upload" }}</button> + <input type="file" name="data" id="inputContainer" style="display: none"> + </form> + <iframe id="uploadTarget" name="uploadTarget" style="display: none"></iframe> </div> <div class="span4"> <h3 class="pull-left">{{_ "URL" }}</h3> - <input type="text" placeholder="{{ _ "Link to Website"}}"> + <input type="text" name="inputURL" id="inputURL" placeholder="{{ _ "Link to Website"}}"> </div> </div> </div> <legend> - {{_ "Packages" }} + {{_ "Packages" }} <button class="btn btn-danger btn-small btn-remove-all"><i class="icon-trash"></i></button> </legend> <div class="container-fluid prepared-packages"> |