@@ -12,14 +12,13 @@ function newAdmin(username, password, name) {
1212 'name' : name
1313 } ) ,
1414
15- success : function ( data ) {
15+ success : function ( response ) {
1616 addStatusMessage ( 'success' , 'The administrator was added successfully' ) ;
1717 fillInTable ( ) ;
1818 } ,
1919
20- error : function ( data ) {
21- // The jQuery('div />') is a work around to encode all html characters
22- addStatusMessage ( 'error' , jQuery ( '<div />' ) . text ( jQuery . parseJSON ( data . responseText ) . message ) . html ( ) ) ;
20+ error : function ( response ) {
21+ addStatusMessage ( 'error' , filterText ( jQuery . parseJSON ( response . responseText ) . message ) ) ;
2322 }
2423 } ) ;
2524}
@@ -32,14 +31,13 @@ function deleteAdmin (id) {
3231 url : '/api/v1/admins/' + id ,
3332 type : 'delete' ,
3433
35- success : function ( data ) {
34+ success : function ( response ) {
3635 addStatusMessage ( 'success' , 'The administrator was successfully removed' ) ;
3736 fillInTable ( ) ;
3837 } ,
3938
40- error : function ( data ) {
41- // The jQuery('div />') is a work around to encode all html characters
42- addStatusMessage ( 'error' , jQuery ( '<div />' ) . text ( jQuery . parseJSON ( data . responseText ) . message ) . html ( ) ) ;
39+ error : function ( response ) {
40+ addStatusMessage ( 'error' , filterText ( jQuery . parseJSON ( response . responseText ) . message ) ) ;
4341 }
4442 } ) ;
4543}
@@ -61,35 +59,6 @@ function adminEventListeners () {
6159 adminPassword . tooltip ( ) ;
6260 adminName . tooltip ( ) ;
6361
64- adminPassword . editable ( {
65- type : 'password' ,
66- mode : 'inline' ,
67- anim : 100 ,
68-
69- ajaxOptions : {
70- type : 'PUT' ,
71- dataType : 'JSON' ,
72- contentType : 'application/json'
73- } ,
74-
75- params : function ( params ) {
76- return JSON . stringify ( { 'password' : params . value } )
77- } ,
78-
79- display : function ( ) {
80- $ ( this ) . html ( '●●●●●●●●' ) ;
81- } ,
82-
83- error : function ( response ) {
84- // The jQuery('div />') is a work around to encode all html characters
85- addStatusMessage ( 'error' , jQuery ( '<div />' ) . text ( jQuery . parseJSON ( response . responseText ) . message ) . html ( ) ) ;
86- } ,
87-
88- success : function ( ) {
89- addStatusMessage ( 'success' , 'The administrator\'s password was changed successfully' ) ;
90- }
91- } ) ;
92-
9362 adminUsername . editable ( {
9463 type : 'text' ,
9564 mode : 'inline' ,
@@ -106,12 +75,11 @@ function adminEventListeners () {
10675 } ,
10776
10877 display : function ( value ) {
109- $ ( this ) . html ( value . toLowerCase ( ) ) ;
78+ $ ( this ) . html ( filterText ( value . toLowerCase ( ) ) ) ;
11079 } ,
11180
11281 error : function ( response ) {
113- // The jQuery('div />') is a work around to encode all html characters
114- addStatusMessage ( 'error' , jQuery ( '<div />' ) . text ( jQuery . parseJSON ( response . responseText ) . message ) . html ( ) ) ;
82+ addStatusMessage ( 'error' , filterText ( jQuery . parseJSON ( response . responseText ) . message ) ) ;
11583 } ,
11684
11785 success : function ( ) {
@@ -139,8 +107,7 @@ function adminEventListeners () {
139107 } ,
140108
141109 error : function ( response ) {
142- // The jQuery('div />') is a work around to encode all html characters
143- addStatusMessage ( 'error' , jQuery ( '<div />' ) . text ( jQuery . parseJSON ( response . responseText ) . message ) . html ( ) ) ;
110+ addStatusMessage ( 'error' , filterText ( jQuery . parseJSON ( response . responseText ) . message ) ) ;
144111 } ,
145112
146113 success : function ( ) {
@@ -163,9 +130,12 @@ function adminEventListeners () {
163130 return JSON . stringify ( { 'name' : params . value } )
164131 } ,
165132
133+ display : function ( value ) {
134+ $ ( this ) . html ( filterText ( value ) ) ;
135+ } ,
136+
166137 error : function ( response ) {
167- // The jQuery('div />') is a work around to encode all html characters
168- addStatusMessage ( 'error' , jQuery ( '<div />' ) . text ( jQuery . parseJSON ( response . responseText ) . message ) . html ( ) ) ;
138+ addStatusMessage ( 'error' , filterText ( jQuery . parseJSON ( response . responseText ) . message ) ) ;
169139 } ,
170140
171141 success : function ( ) {
@@ -263,9 +233,9 @@ function fillInTable () {
263233 var html = '' ;
264234
265235 tableRow . length == 0 ? html += '<tr id="dynamicTableRow' + String ( i ) + '">' : null ;
266- html += '<td data-title="Username: "><a href="#" class="adminUsername" data-pk="' + item . id + '" data-url="/api/v1/admins/' + item . id + '" title="Click to change the username">' + item . username + '</a></td>\
236+ html += '<td data-title="Username: "><a href="#" class="adminUsername" data-pk="' + item . id + '" data-url="/api/v1/admins/' + item . id + '" title="Click to change the username">' + filterText ( item . username ) + '</a></td>\
267237 <td data-title="Password: "><a href="#" class="adminPassword" data-pk="' + item . id + '" data-url="/api/v1/admins/' + item . id + '" title="Click to change the password">●●●●●●●●</a></td>\
268- <td data-title="Name: "><a href="#" class="adminName" data-pk="' + item . id + '" data-url="/api/v1/admins/' + item . id + '" title="Click to change the name">' + item . name + '</a></td>\
238+ <td data-title="Name: "><a href="#" class="adminName" data-pk="' + item . id + '" data-url="/api/v1/admins/' + item . id + '" title="Click to change the name">' + filterText ( item . name ) + '</a></td>\
269239 <td data-title="Action: "><a href="#" class="deleteAnchor" data-pk="' + item . id + '" data-toggle="modal" data-target="#deleteModal">Delete</a></td>' ;
270240 tableRow . length == 0 ? html += '</tr>' : null ;
271241 tableRow . length == 0 ? insertTableRow ( html ) : tableRow . html ( html ) ;
0 commit comments