From aa7e8ab9c17306ad8f11a5165b65f93d824f40e8 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 1 Jun 2014 13:53:45 +0200 Subject: implemented click captchas --- pyload/web/app/scripts/views/input/clickInput.js | 43 ++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 pyload/web/app/scripts/views/input/clickInput.js (limited to 'pyload/web/app/scripts/views/input/clickInput.js') 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..873c81ce7 --- /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()); + } + + }); +}); \ No newline at end of file -- cgit v1.2.3 From 9aa62273c897f67f0fd12b8d6e3bb3ea78e3be7a Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 1 Jun 2014 14:18:09 +0200 Subject: fixed js hint --- pyload/web/app/scripts/views/input/clickInput.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'pyload/web/app/scripts/views/input/clickInput.js') diff --git a/pyload/web/app/scripts/views/input/clickInput.js b/pyload/web/app/scripts/views/input/clickInput.js index 873c81ce7..ca8a954b8 100644 --- a/pyload/web/app/scripts/views/input/clickInput.js +++ b/pyload/web/app/scripts/views/input/clickInput.js @@ -27,7 +27,7 @@ define(['jquery', 'backbone', 'underscore', 'helpers/gettext', './inputView'], f }, onClick: function(x,y) { - this.$el.val(x + "," + y); + this.$el.val(x + ',' + y); this.onChange(); }, @@ -40,4 +40,4 @@ define(['jquery', 'backbone', 'underscore', 'helpers/gettext', './inputView'], f } }); -}); \ No newline at end of file +}); -- cgit v1.2.3