Cleaned up code related to departments' descriptions

This commit is contained in:
Dmitriy Simushev 2012-02-08 13:18:12 +00:00
parent eaaaff85c2
commit 87676a5cee
6 changed files with 13 additions and 5 deletions

View File

@ -5,4 +5,5 @@
Copyright (c) 2005-2011 Mibew Messenger Community Copyright (c) 2005-2011 Mibew Messenger Community
License: http://mibew.org/license.php License: http://mibew.org/license.php
*/ */
var Survey={checkFields:function(){var a=document.surveyForm.email,b=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return null!=a&&-1==a.value.search(b)?this.localizedStrings.wrongEmail:null},submit:function(){var a=this.checkFields();null==a?document.surveyForm.submit():alert(a)}};EventHelper.register(window,"onload",function(){Survey.localizedStrings=localizedStrings}); var Survey={checkFields:function(){var a=document.surveyForm.email,b=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;return null!=a&&-1==a.value.search(b)?this.localizedStrings.wrongEmail:null},changeGroup:function(){document.getElementById("departmentDescription").childNodes.item(0).data=this.groupDescriptions[document.surveyForm.group.selectedIndex]},submit:function(){var a=this.checkFields();
null==a?document.surveyForm.submit():alert(a)}};EventHelper.register(window,"onload",function(){Survey.localizedStrings=localizedStrings;"undefined"!=typeof groupDescriptions&&(Survey.groupDescriptions=groupDescriptions)});

View File

@ -16,6 +16,10 @@ var Survey = {
return null; return null;
}, },
changeGroup: function(){
document.getElementById('departmentDescription').childNodes.item(0).data = this.groupDescriptions[document.surveyForm.group.selectedIndex];
},
submit: function(){ submit: function(){
var error = this.checkFields(); var error = this.checkFields();
if(error == null){ if(error == null){
@ -28,4 +32,7 @@ var Survey = {
EventHelper.register(window, 'onload', function(){ EventHelper.register(window, 'onload', function(){
Survey.localizedStrings = localizedStrings; Survey.localizedStrings = localizedStrings;
if( typeof groupDescriptions != 'undefined' ){
Survey.groupDescriptions = groupDescriptions;
}
}); });

View File

@ -125,7 +125,7 @@ ${if:groups}
<tr> <tr>
<td class="text">${msg:presurvey.department}</td> <td class="text">${msg:presurvey.department}</td>
<td> <td>
<select name="group" style="min-width:200px;" onchange="document.getElementById('departmentDescription').childNodes.item(0).data = groupDescriptions[this.selectedIndex];">${page:groups}</select> <select name="group" style="min-width:200px;" onchange="Survey.changeGroup()">${page:groups}</select>
</td> </td>
</tr> </tr>
<tr> <tr>

View File

@ -87,7 +87,7 @@ ${if:groups}
<td class="text">${msg:presurvey.department}</td> <td class="text">${msg:presurvey.department}</td>
<td width="20"></td> <td width="20"></td>
<td> <td>
<select name="group" style="min-width:200px;" onchange="document.getElementById('departmentDescription').childNodes.item(0).data = groupDescriptions[this.selectedIndex];">${page:groups}</select> <select name="group" style="min-width:200px;" onchange="Survey.changeGroup()">${page:groups}</select>
</td> </td>
</tr> </tr>
<tr><td height="7" colspan="3"></td></tr> <tr><td height="7" colspan="3"></td></tr>

View File

@ -65,7 +65,7 @@
${if:groups} ${if:groups}
<tr> <tr>
<td><strong>${msg:presurvey.department}</strong></td> <td><strong>${msg:presurvey.department}</strong></td>
<td><select name="group" onchange="document.getElementById('departmentDescription').childNodes.item(0).data = groupDescriptions[this.selectedIndex];">${page:groups}</select></td> <td><select name="group" onchange="Survey.changeGroup()">${page:groups}</select></td>
</tr> </tr>
<tr> <tr>
<td><strong>${msg:presurvey.department.description}</strong></td> <td><strong>${msg:presurvey.department.description}</strong></td>

View File

@ -56,7 +56,7 @@ ${endif:showemail}
${if:groups} ${if:groups}
<tr> <tr>
<td class="text">${msg:presurvey.department}</td> <td class="text">${msg:presurvey.department}</td>
<td><select name="group" style="min-width:200px;" onchange="document.getElementById('departmentDescription').childNodes.item(0).data = groupDescriptions[this.selectedIndex];">${page:groups}</select></td> <td><select name="group" style="min-width:200px;" onchange="Survey.changeGroup()">${page:groups}</select></td>
</tr> </tr>
<tr> <tr>
<td class="text">${msg:presurvey.department.description}</td> <td class="text">${msg:presurvey.department.description}</td>