summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts/views/linkgrabber
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-09-07 21:32:03 +0200
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2013-09-07 21:32:15 +0200
commit0537c47cb430afa1770bc5bf8c757de867a276c0 (patch)
tree0c8f0e21d9c258d888ee83723d8c881627a15b63 /pyload/web/app/scripts/views/linkgrabber
parentMoving plugin to pyload (diff)
downloadpyload-0537c47cb430afa1770bc5bf8c757de867a276c0.tar.xz
improved link grabber
Diffstat (limited to 'pyload/web/app/scripts/views/linkgrabber')
-rw-r--r--pyload/web/app/scripts/views/linkgrabber/collectorView.js9
-rw-r--r--pyload/web/app/scripts/views/linkgrabber/modalView.js23
2 files changed, 26 insertions, 6 deletions
diff --git a/pyload/web/app/scripts/views/linkgrabber/collectorView.js b/pyload/web/app/scripts/views/linkgrabber/collectorView.js
index a02023a30..08b426aff 100644
--- a/pyload/web/app/scripts/views/linkgrabber/collectorView.js
+++ b/pyload/web/app/scripts/views/linkgrabber/collectorView.js
@@ -21,7 +21,14 @@ define(['jquery', 'underscore', 'backbone', 'app', './packageView'],
self.collection.add(pack);
}
- // TODO: remove links from all other packages than pack
+ // Remove links from other packages and delete empty ones
+ self.collection.each(function(pack2) {
+ console.log(pack2, links);
+ if (pack2 !== pack)
+ if (pack2.removeLinks(links))
+ self.collection.remove(pack2);
+ });
+
pack.updateLinks(links);
});
}
diff --git a/pyload/web/app/scripts/views/linkgrabber/modalView.js b/pyload/web/app/scripts/views/linkgrabber/modalView.js
index 32730658c..808d67f59 100644
--- a/pyload/web/app/scripts/views/linkgrabber/modalView.js
+++ b/pyload/web/app/scripts/views/linkgrabber/modalView.js
@@ -6,7 +6,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v
className: 'modal linkgrabber',
events: {
- 'keypress #inputLinks': 'addOnEnter'
+ 'keyup #inputLinks': 'addOnKeyUp'
},
template: template,
@@ -14,18 +14,30 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v
// Holds the view that display the packages
collectorView: null,
+ inputSize: 0,
+
initialize: function() {
// Inherit parent events
this.events = _.extend({}, modalView.prototype.events, this.events);
this.listenTo(App.vent, 'package:added', _.bind(this.onAdded, this));
},
- addOnEnter: function(e) {
- if (e.keyCode !== 13) return;
- this.addPackage(e);
+ addOnKeyUp: function(e) {
+ // Enter adds the links
+ if (e.keyCode === 13)
+ this.parseLinks();
+
+ 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();
+ else
+ this.inputSize = inputSize;
},
- addPackage: function(e) {
+ parseLinks: function() {
var self = this;
// split, trim and remove empty links
var links = _.filter(_.map(this.$('#inputLinks').val().split('\n'), function(link) {
@@ -44,6 +56,7 @@ define(['jquery', 'underscore', 'backbone', 'app', 'models/CollectorPackage', 'v
$.ajax(options);
this.$('#inputLinks').val('');
+ this.inputSize = 0;
},
// Hide when there are no more packages