Skip to content

Commit

Permalink
[#224] Use trim method provided by ExtJs.
Browse files Browse the repository at this point in the history
The ExtJs method already removes tabs and newlines. Remove custom
Trim(), LTrim() and RTrim().

Also, do not trim the password field, this behavior doesn't feel
right.
  • Loading branch information
jaragunde committed Apr 25, 2018
1 parent b706668 commit 3364174
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 64 deletions.
30 changes: 0 additions & 30 deletions web/include/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,3 @@ function xmlencode(string) {
return string.replace(/\&/g,'&'+'amp;').replace(/</g,'&'+'lt;')
.replace(/>/g,'&'+'gt;').replace(/\'/g,'&'+'apos;').replace(/\"/g,'&'+'quot;');
}

// Function for removing whitespaces from both the start and end of a string
function Trim(str)
{

return LTrim(RTrim(str));

}

// Function for removing whitespaces from the start of a string
function LTrim(str)
{

var i=0;
while(str.charAt(i) == " ")
i++;
return str.substring(i);

}

// Function for removing whitespaces from the end of a string
function RTrim(str)
{

var i=str.length-1;
while(str.charAt(i) == " ")
i--;
return str.substring(0,i+1);

}
4 changes: 2 additions & 2 deletions web/iterationForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
allowBlank:false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand All @@ -172,7 +172,7 @@
xtype: 'textarea',
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down
2 changes: 1 addition & 1 deletion web/js/cityManagement.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ var cityColModel = new Ext.grid.ColumnModel([
allowBlank: false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
}
Expand Down
12 changes: 6 additions & 6 deletions web/js/tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -495,13 +495,13 @@ var TaskPanel = Ext.extend(Ext.Panel, {
enableKeyEvents: true,
listeners: {
'change': function () {
this.parent.taskRecord.set('story',Trim(this.getValue()));
this.parent.taskRecord.set('story',this.getValue().trim());
},
'keyup': function () {
this.parent.taskRecord.set('story',Trim(this.getValue()));
this.parent.taskRecord.set('story',this.getValue().trim());
},
'blur': function () {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
}
}),
Expand All @@ -515,13 +515,13 @@ var TaskPanel = Ext.extend(Ext.Panel, {
enableKeyEvents: true,
listeners: {
'keyup': function () {
this.parent.taskRecord.set('text',Trim(this.getValue()));
this.parent.taskRecord.set('text',this.getValue().trim());
},
'change': function () {
this.parent.taskRecord.set('text',Trim(this.getValue()));
this.parent.taskRecord.set('text',this.getValue().trim());
},
'blur': function () {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
}
}),
Expand Down
4 changes: 2 additions & 2 deletions web/moduleForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@
allowBlank:false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand All @@ -171,7 +171,7 @@
xtype: 'textarea',
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down
4 changes: 2 additions & 2 deletions web/sectionForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@
allowBlank:false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand All @@ -190,7 +190,7 @@
xtype: 'textarea',
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down
2 changes: 1 addition & 1 deletion web/storyForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@
allowBlank:false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down
2 changes: 1 addition & 1 deletion web/viewAreas.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
allowBlank: false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
}
Expand Down
6 changes: 3 additions & 3 deletions web/viewCustomers.php
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ function sectors(val){
allowBlank: false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
}
Expand Down Expand Up @@ -408,7 +408,7 @@ function sectors(val){
allowBlank: true,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
}
Expand Down Expand Up @@ -501,7 +501,7 @@ function sectors(val){
allowBlank: false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
}
Expand Down
12 changes: 6 additions & 6 deletions web/viewProjects.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ function customers(val){
allowBlank:false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down Expand Up @@ -482,7 +482,7 @@ function customers(val){
allowBlank: true,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand All @@ -492,7 +492,7 @@ function customers(val){
allowBlank: true,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down Expand Up @@ -619,7 +619,7 @@ function customers(val){
value: selected.data.description,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down Expand Up @@ -706,7 +706,7 @@ function customers(val){
value: selected.data.schedule,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand All @@ -717,7 +717,7 @@ function customers(val){
value: selected.data.type,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down
4 changes: 2 additions & 2 deletions web/viewSection.php
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ function risks(val){
allowBlank:false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down Expand Up @@ -460,7 +460,7 @@ function risks(val){
allowBlank:false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down
4 changes: 2 additions & 2 deletions web/viewStory.php
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ function risks(val){
allowBlank:false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down Expand Up @@ -563,7 +563,7 @@ function risks(val){
allowBlank:false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
},{
Expand Down
7 changes: 1 addition & 6 deletions web/viewUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ function areas(val){
allowBlank: false,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
this.setValue(this.getValue().trim());
}
},
}
Expand All @@ -334,11 +334,6 @@ function areas(val){
xtype: 'textfield',
inputType: 'password',
allowBlank: true,
listeners: {
'change': function() {
this.setValue(Trim(this.getValue()));
}
},
}
}<?php

Expand Down

0 comments on commit 3364174

Please sign in to comment.