| Server IP : 180.180.241.3 / Your IP : 216.73.216.35 Web Server : Microsoft-IIS/7.5 System : Windows NT NETWORK-NHRC 6.1 build 7601 (Windows Server 2008 R2 Standard Edition Service Pack 1) i586 User : IUSR ( 0) PHP Version : 5.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /AppServ/www/app/webroot/news/components/com_simple_review/templates/default/js/ |
Upload File : |
function CommentFormController(commentOptions)
{
this._LiveSiteUrl = commentOptions.avatarURL;
this._NameNeeded = commentOptions.nameNeeded;
this._CommentNeeded = commentOptions.commentNeededText;
this._CommentLength = commentOptions.maxLength;
this._CommentLengthWarning = commentOptions.commentLengthText;
this._RatingBounds = commentOptions.ratingBoundsText;
this._MaxRating = commentOptions.maxrating;
this._SecurityNeeded = commentOptions.securityNeededText;
this._UseSecurity = commentOptions.useSecurity;
this._CommentRequired = parseInt(commentOptions.commentRequired, 10);//0: no comment, 1: required, 2: optional
this._RatingRequired = parseInt(commentOptions.ratingRequired, 10);//0: no rating, 1: required, 2: optional, 3: inherit from review
}
CommentFormController.prototype =
{
UpdateAvatar : function()
{
var avatar = document.getElementById("commentavatar");
var selectlist = document.getElementById("avatarselect");
if(selectlist.value =='-1')
{
avatar.src = this._LiveSiteUrl + "/noimage.png";
return;
}
avatar.src = this._LiveSiteUrl + "/" + selectlist.value;
},
CommentSubmitButton : function(pAllowUserComments)
{
var form = document.commentForm;
//Have already commented
if(!form.requireUserRating || form.requireUserRating.value == 0)
{
this._RatingRequired = 0;
}
var userRating = form.userRating ? parseInt(form.userRating.value, 10) : 0;
if(pAllowUserComments && form.anonymousName != null)
{
if (form.anonymousName.value == '')
{
alert(this._NameNeeded);
form.anonymousName.focus();
return false;
}
}
if(this._RatingRequired > 0)
{
//ignore optional and empty
if(!form.userRating.value && this._RatingRequired == 2)
{
form.userRating.value = -1;
}
else if(isNaN(userRating) || userRating < 0 || userRating > this._MaxRating)
{
alert( this._RatingBounds + this._MaxRating );
form.userRating.focus();
return false;
}
}
var comment = '';
if(this._CommentRequired != 0)
{
comment = form.comment.value;
comment = comment.replace(/^\s+/, '');
}
if (comment == '' && this._CommentRequired === 1)
{
alert(this._CommentNeeded);
form.comment.focus();
return false;
}
if(comment.length > this._CommentLength)
{
alert( this._CommentLengthWarning + this._CommentLength);
form.comment.focus();
return false;
}
if(this._UseSecurity)
{
if (form.security_try.value=='')
{
alert(this._SecurityNeeded);
form.security_try.focus();
return false;
}
}
else
{
return true;
}
}
}