Bugzilla – Attachment 14260 Details for
Bug 9284
JavaScript should conform to coding guidelines recommended by JSHint
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 9284 - JavaScript should follow rules recommended by JSHint
Bug-9284---JavaScript-should-follow-rules-recommen.patch (text/plain), 9.54 KB, created by
Jonathan Druart
on 2012-12-26 10:40:41 UTC
(
hide
)
Description:
Bug 9284 - JavaScript should follow rules recommended by JSHint
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2012-12-26 10:40:41 UTC
Size:
9.54 KB
patch
obsolete
>From c0dea4edf806f4a92b6e20062898db62328c42bc Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 13 Dec 2012 15:56:21 -0500 >Subject: [PATCH] Bug 9284 - JavaScript should follow rules recommended by > JSHint > >Coding style corrections to members.js: > >- Mixed tab/space indentation converted to spaces. >- Converted "!=" and "==" to "!==" and "===" for comparisons with ''. >- Adding missing semicolons. > >To test, create or edit a patron and confirm that validation hasn't been >broken by the changes to members.js: Invalid date, empty required >fields, guarantor popup, restricted-until field display, etc. > >http://bugs.koha-community.org/show_bug.cgi?id=9281 >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > koha-tmpl/intranet-tmpl/prog/en/js/members.js | 216 ++++++++++++------------- > 1 file changed, 108 insertions(+), 108 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/js/members.js b/koha-tmpl/intranet-tmpl/prog/en/js/members.js >index cdc1442..351ffe9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/js/members.js >+++ b/koha-tmpl/intranet-tmpl/prog/en/js/members.js >@@ -1,37 +1,37 @@ > // this function checks id date is like DD/MM/YYYY > function CheckDate(field) { > var d = field.value; >-if (d!="") { >- var amin = 1900; >- var amax = 2100; >+if (d!=="") { >+ var amin = 1900; >+ var amax = 2100; > var date = d.split("/"); > var ok=1; > var msg; > if ( (date.length < 2) && (ok==1) ) { > msg = MSG_SEPARATOR+field.name; >- alert(msg); ok=0; field.focus(); >- return; >+ alert(msg); ok=0; field.focus(); >+ return; > } > var dd = date[0]; > var mm = date[1]; >- var yyyy = date[2]; >+ var yyyy = date[2]; > // checking days > if ( ((isNaN(dd))||(dd<1)||(dd>31)) && (ok==1) ) { > msg = MSG_INCORRECT_DAY+field.name; >- alert(msg); ok=0; field.focus(); >- return false; >+ alert(msg); ok=0; field.focus(); >+ return false; > } > // checking months > if ( ((isNaN(mm))||(mm<1)||(mm>12)) && (ok==1) ) { > msg = MSG_INCORRECT_MONTH+field.name; >- alert(msg); ok=0; field.focus(); >- return false; >+ alert(msg); ok=0; field.focus(); >+ return false; > } > // checking years > if ( ((isNaN(yyyy))||(yyyy<amin)||(yyyy>amax)) && (ok==1) ) { > msg = MSG_INCORRECT_YEAR+field.name; >- alert(msg); ok=0; field.focus(); >- return false; >+ alert(msg); ok=0; field.focus(); >+ return false; > } > } > } >@@ -41,22 +41,22 @@ function unique() { > var msg1; > var msg2; > if ( document.form.check_member.value==1){ >- if (document.form.categorycode.value != "I"){ >- >- msg1 += MSG_DUPLICATE_PATRON; >- alert(msg1); >- check_form_borrowers(0); >- document.form.submit(); >- >- }else{ >- msg2 += MSG_DUPLICATE_ORGANIZATION; >- alert(msg2); >- check_form_borrowers(0); >- } >+ if (document.form.categorycode.value != "I"){ >+ >+ msg1 += MSG_DUPLICATE_PATRON; >+ alert(msg1); >+ check_form_borrowers(0); >+ document.form.submit(); >+ >+ }else{ >+ msg2 += MSG_DUPLICATE_ORGANIZATION; >+ alert(msg2); >+ check_form_borrowers(0); >+ } > } > else > { >- document.form.submit(); >+ document.form.submit(); > } > > } >@@ -66,106 +66,106 @@ else > function check_manip_date(status) { > if (status=='verify'){ > // this part of function('verify') is used to check if dateenrolled<date expiry >-if (document.form.dateenrolled != '' && document.form.dateexpiry.value !='') { >+if (document.form.dateenrolled !== '' && document.form.dateexpiry.value !=='') { > var myDate1=document.form.dateenrolled.value.split ('/'); > var myDate2=document.form.dateexpiry.value.split ('/'); >- if ((myDate1[2]>myDate2[2])||(myDate1[2]==myDate2[2] && myDate1[1]>myDate2[1])||(myDate1[2]==myDate2[2] && myDate1[1]>=myDate2[1] && myDate1[0]>=myDate2[0])) >- >- { >- document.form.dateenrolled.focus(); >- var msg = MSG_LATE_EXPIRY; >- alert(msg); >- } >- } >- } >+ if ((myDate1[2]>myDate2[2])||(myDate1[2]==myDate2[2] && myDate1[1]>myDate2[1])||(myDate1[2]==myDate2[2] && myDate1[1]>=myDate2[1] && myDate1[0]>=myDate2[0])) >+ >+ { >+ document.form.dateenrolled.focus(); >+ var msg = MSG_LATE_EXPIRY; >+ alert(msg); >+ } >+ } >+ } > } > //end function > > > // function to test all fields in forms and nav in different forms(1 ,2 or 3) > function check_form_borrowers(nav){ >- var statut=0; >- var message = ""; >- var message_champ=""; >- if (document.form.check_member.value == 1 ) >- { >- if (document.form_double.answernodouble) { >- if( (!(document.form_double.answernodouble.checked))){ >- document.form.nodouble.value=0; >- } else { >- document.form.nodouble.value=1; >- } >- } >- } >- >- if (document.form.BorrowerMandatoryField.value=='') >- {} >- else >- { >- var champ_verif = document.form.BorrowerMandatoryField.value.split ('|'); >- message += MSG_MISSING_MANDATORY >- message += "\n"; >- for (var i=0; i<champ_verif.length; i++) { >- if (document.getElementsByName(""+champ_verif[i]+"")[0]) { >- var val_champ=eval("document.form."+champ_verif[i]+".value"); >- var ref_champ=eval("document.form."+champ_verif[i]); >- //check if it's a select >- if (ref_champ.type=='select-one'){ >- // check to see if first option is selected and is blank >- if (ref_champ.options[0].selected && >- ref_champ.options[0].text == ''){ >- // action if field is empty >- message_champ+=champ_verif[i]+"\n"; >- //test to know if you must show a message with error >- statut=1; >- } >- } else { >- if ( val_champ == '' ) { >- // action if the field is not empty >- message_champ+=champ_verif[i]+"\n"; >- statut=1; >- } >- } >- } >- } >- } >+ var statut=0; >+ var message = ""; >+ var message_champ=""; >+ if (document.form.check_member.value == 1 ) >+ { >+ if (document.form_double.answernodouble) { >+ if( (!(document.form_double.answernodouble.checked))){ >+ document.form.nodouble.value=0; >+ } else { >+ document.form.nodouble.value=1; >+ } >+ } >+ } > >- if ( document.form.password.value != document.form.password2.value ){ >- if ( message_champ != '' ){ >- message_champ += "\n"; >- } >- message_champ+= MSG_PASSWORD_MISMATCH; >- statut=1; >- } >+ if (document.form.BorrowerMandatoryField.value==='') >+ {} >+ else >+ { >+ var champ_verif = document.form.BorrowerMandatoryField.value.split ('|'); >+ message += MSG_MISSING_MANDATORY; >+ message += "\n"; >+ for (var i=0; i<champ_verif.length; i++) { >+ if (document.getElementsByName(""+champ_verif[i]+"")[0]) { >+ var val_champ=eval("document.form."+champ_verif[i]+".value"); >+ var ref_champ=eval("document.form."+champ_verif[i]); >+ //check if it's a select >+ if (ref_champ.type=='select-one'){ >+ // check to see if first option is selected and is blank >+ if (ref_champ.options[0].selected && >+ ref_champ.options[0].text === ''){ >+ // action if field is empty >+ message_champ+=champ_verif[i]+"\n"; >+ //test to know if you must show a message with error >+ statut=1; >+ } >+ } else { >+ if ( val_champ === '' ) { >+ // action if the field is not empty >+ message_champ+=champ_verif[i]+"\n"; >+ statut=1; >+ } >+ } >+ } >+ } >+ } >+ >+ if ( document.form.password.value != document.form.password2.value ){ >+ if ( message_champ !== '' ){ >+ message_champ += "\n"; >+ } >+ message_champ+= MSG_PASSWORD_MISMATCH; >+ statut=1; >+ } > >- //patrons form to test if you checked no to the question of double >- if (statut!=1 && document.form.check_member.value > 0 ) { >- if (!(document.form_double.answernodouble.checked)){ >- message_champ+= MSG_DUPLICATE_SUSPICION; >- statut=1; >- document.form.nodouble.value=0; >- } else { >- document.form.nodouble.value=1; >- } >- } >- >- if (statut==1){ >- //alert if at least 1 error >- alert(message+"\n"+message_champ); >- return false; >- } else { >- document.form.submit(); >- } >+ //patrons form to test if you checked no to the question of double >+ if (statut!=1 && document.form.check_member.value > 0 ) { >+ if (!(document.form_double.answernodouble.checked)){ >+ message_champ+= MSG_DUPLICATE_SUSPICION; >+ statut=1; >+ document.form.nodouble.value=0; >+ } else { >+ document.form.nodouble.value=1; >+ } >+ } >+ >+ if (statut==1){ >+ //alert if at least 1 error >+ alert(message+"\n"+message_champ); >+ return false; >+ } else { >+ document.form.submit(); >+ } > } > > function Dopop(link) { >-// // var searchstring=document.form.value[i].value; >- var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=no,top'); >+// // var searchstring=document.form.value[i].value; >+ var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=no,top'); > } > > function Dopopguarantor(link) { > >- var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top'); >+ var newin=window.open(link,'popup','width=600,height=400,resizable=no,toolbar=false,scrollbars=yes,top'); > } > > $(document).ready(function(){ >-- >1.7.10.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 9284
:
14145
|
14249
| 14260