[#2855] [WebUI] Unable to add UDP trackers

This commit is contained in:
Calum Lind 2016-07-19 11:46:53 +01:00
parent 5f92810f76
commit d38b8fc45c

View File

@ -1,6 +1,6 @@
/*! /*!
* Deluge.AddTrackerWindow.js * Deluge.AddTrackerWindow.js
* *
* Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com> * Copyright (c) Damien Churchill 2009-2010 <damoxc@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -31,12 +31,21 @@
*/ */
Ext.ns('Deluge'); Ext.ns('Deluge');
// Custom VType validator for tracker urls
var trackerUrlTest = /(((^https?)|(^udp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
Ext.apply(Ext.form.VTypes, {
trackerUrl: function(val, field) {
return trackerUrlTest.test(val);
},
trackerUrlText: 'Not a valid tracker url'
});
/** /**
* @class Deluge.AddTrackerWindow * @class Deluge.AddTrackerWindow
* @extends Ext.Window * @extends Ext.Window
*/ */
Deluge.AddTrackerWindow = Ext.extend(Ext.Window, { Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
title: _('Add Tracker'), title: _('Add Tracker'),
layout: 'fit', layout: 'fit',
width: 375, width: 375,
@ -52,11 +61,11 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
initComponent: function() { initComponent: function() {
Deluge.AddTrackerWindow.superclass.initComponent.call(this); Deluge.AddTrackerWindow.superclass.initComponent.call(this);
this.addButton(_('Cancel'), this.onCancelClick, this); this.addButton(_('Cancel'), this.onCancelClick, this);
this.addButton(_('Add'), this.onAddClick, this); this.addButton(_('Add'), this.onAddClick, this);
this.addEvents('add'); this.addEvents('add');
this.form = this.add({ this.form = this.add({
xtype: 'form', xtype: 'form',
defaultType: 'textarea', defaultType: 'textarea',
@ -73,10 +82,10 @@ Deluge.AddTrackerWindow = Ext.extend(Ext.Window, {
onAddClick: function() { onAddClick: function() {
var trackers = this.form.getForm().findField('trackers').getValue(); var trackers = this.form.getForm().findField('trackers').getValue();
trackers = trackers.split('\n'); trackers = trackers.split('\n');
var cleaned = []; var cleaned = [];
Ext.each(trackers, function(tracker) { Ext.each(trackers, function(tracker) {
if (Ext.form.VTypes.url(tracker)) { if (Ext.form.VTypes.trackerUrl(tracker)) {
cleaned.push(tracker); cleaned.push(tracker);
} }
}, this); }, this);