Problem in understannding some javascript code
<script type="text/javascript">
function CallUpdateProgress()
{
<asp:Literal runat="server" ID="lblScriptName" />;
}
function UpdateProgress(result, context)
{
// result is a semicolon-separated list of values, so split it
var params = result.split(";");
var percentage = params[0];
var sentMails = params[1];
var totalMails = params[2];
if (totalMails < 0)
totalMails = '???';
// update progressbar's width and description text
var progBar = window.document.getElementById('progressbar');
progBar.style.width = percentage + '%';
var descr = window.document.getElementById('progressdescriptio n');
descr.innerHTML = '<b>' + percentage + '% completed</b> - ' +
sentMails + ' out of ' + totalMails + ' e-mails have been sent.';
// if the current percentage is less than 100%,
// recall the server callback method in 2 seconds
if (percentage == '100')
window.document.getElementById('panelcomplete').st yle.display = '';
else
setTimeout('CallUpdateProgress()', 2000);
}
</script>
This above mentioned javascript code is written in the code-behind file of SendingNewsletter.aspx page. While newsletters are being send, this code gets the calculated values of different progress variables and shows a progress information (of sending operation) on the same page. There is a check in this code i.e.
if(totalMails < 0)
totalMails='???'
I know that the totalMails variable is less than zero in only two cases (if there is any other case, plz let me know)
1. If no user subscribe for newsletter.
2. If the variable's value is wrongly calculated.
Now, the thing which i want to know is that if this check becomes true then why we are storing '???' this in an integer variable named totalMails and after storing this string or value how the rest of the operation proceeds.
In short, i just want to know the logic behind storing this '???' and its consequences.
|