summaryrefslogtreecommitdiffstats
path: root/pyload/web/app/scripts/views/input
diff options
context:
space:
mode:
Diffstat (limited to 'pyload/web/app/scripts/views/input')
-rw-r--r--pyload/web/app/scripts/views/input/clickInput.js43
-rw-r--r--pyload/web/app/scripts/views/input/inputLoader.js7
-rw-r--r--pyload/web/app/scripts/views/input/inputView.js5
3 files changed, 54 insertions, 1 deletions
diff --git a/pyload/web/app/scripts/views/input/clickInput.js b/pyload/web/app/scripts/views/input/clickInput.js
new file mode 100644
index 000000000..ca8a954b8
--- /dev/null
+++ b/pyload/web/app/scripts/views/input/clickInput.js
@@ -0,0 +1,43 @@
+define(['jquery', 'backbone', 'underscore', 'helpers/gettext', './inputView'], function($, Backbone, _, gettext, inputView) {
+ 'use strict';
+
+ return inputView.extend({
+
+ tagName: 'input',
+ events: {
+ 'keyup': 'onChange',
+ 'focus': 'showTooltip',
+ 'focusout': 'hideTooltip'
+ },
+
+ renderInput: function() {
+ this.$el.attr('disabled', 'on');
+ this.$el.attr('type', 'text');
+ this.$el.attr('name', 'textInput');
+
+ if (this.default_value)
+ this.$el.attr('placeholder', this.default_value);
+ else
+ this.$el.attr('placeholder', gettext('Please click on the right position in the captcha.'));
+
+ if (this.value)
+ this.$el.val(this.value);
+
+ return this;
+ },
+
+ onClick: function(x,y) {
+ this.$el.val(x + ',' + y);
+ this.onChange();
+ },
+
+ clear: function() {
+ this.$el.val('');
+ },
+
+ onChange: function(e) {
+ this.setVal(this.$el.val());
+ }
+
+ });
+});
diff --git a/pyload/web/app/scripts/views/input/inputLoader.js b/pyload/web/app/scripts/views/input/inputLoader.js
index 04d591d30..c28572c6c 100644
--- a/pyload/web/app/scripts/views/input/inputLoader.js
+++ b/pyload/web/app/scripts/views/input/inputLoader.js
@@ -1,8 +1,13 @@
-define(['./textInput'], function(textInput) {
+define(['utils/apitypes', './textInput', './clickInput'], function(Api, textInput, clickInput) {
'use strict';
// selects appropriate input element
return function(input) {
+ console.log('Select input', input);
+
+ if (input.type == Api.InputType.Click)
+ return clickInput;
+
return textInput;
};
}); \ No newline at end of file
diff --git a/pyload/web/app/scripts/views/input/inputView.js b/pyload/web/app/scripts/views/input/inputView.js
index 1860fcaf1..394e33aef 100644
--- a/pyload/web/app/scripts/views/input/inputView.js
+++ b/pyload/web/app/scripts/views/input/inputView.js
@@ -38,6 +38,11 @@ define(['jquery', 'backbone', 'underscore'], function($, Backbone, _) {
return this;
},
+ // triggered by captcha clicks
+ onClick: function(x,y) {
+
+ },
+
renderInput: function() {
// Overwrite this
},