/* FILE ARCHIVED ON 6:17:48 May 12, 2009 AND RETRIEVED FROM THE AN OPENWAYBACK INSTANCE ON 22:49:47 Jun 14, 2024. JAVASCRIPT APPENDED BY OPENWAYBACK, COPYRIGHT INTERNET ARCHIVE. ALL OTHER CONTENT MAY ALSO BE PROTECTED BY COPYRIGHT (17 U.S.C. SECTION 108(a)(3)). */ function getUniqueKey4Pluck() { var loc = window.location.href; var srchstring = "content/"; var pos = loc.indexOf(srchstring); var start = parseInt(pos+srchstring.length); var end = 0; if(loc.indexOf('#') != -1) var end = parseInt(loc.indexOf('#'))-start; if (end < 1){var key = loc.substr(start);} else{var key = loc.substr(start,end);} if(loc.indexOf('?') != -1) end = parseInt(loc.indexOf('?'))-start; if (end < 1){key = loc.substr(start);} else{key = loc.substr(start,end);} return key; } //User class - checks cookie and sets User if logged in function User() { var self = this; this.cookie = ''; this.displayName = ''; this.avatar = ''; this.get = function() { var bakery = document.cookie; var srchstring = "at=u="; var pos = bakery.indexOf(srchstring); if(pos != -1){ var start = parseInt(pos+srchstring.length); var end = parseInt(bakery.indexOf('&a='))-start; if (end < 1){var cookie = loc.substr(start);} else{self.cookie = bakery.substr(start,end);} var userRequest = new RequestBatch(); var userKey = new UserKey(self.cookie); userRequest.AddToRequest(userKey); userRequest.BeginRequest(serverUrl, self.store); } } this.store = function(responseBatch) { var userdetails = responseBatch.Responses[0].User; self.displayName = userdetails.DisplayName; self.avatar = userdetails.AvatarPhotoUrl; } } function CommentInterface(perPage) { var self = this; this.perPage = perPage; this.currentPage = 0; this.numberComments = ''; this.pages = ''; this.template = ''; this.votedown_count = ''; this.init = function() { if(user.cookie != ''){ $("#commentBody").removeAttr("disabled"); $("#submitComment").removeAttr("disabled"); $('#commentRegister').hide(); } self.request(); } this.request = function() { $("#spinner").show(); self.currentPage++; number = self.perPage var requestBatch = new RequestBatch(); var articlekey = new ArticleKey(getUniqueKey4Pluck()); requestBatch.AddToRequest(new CommentPage(articlekey, number, self.currentPage, "TimeStampDescending")); requestBatch.BeginRequest(serverUrl, self.render); } this.render = function(responseBatch) { var commentPage = responseBatch.Responses[0].CommentPage.Comments; var commentStats = responseBatch.Responses[0].CommentPage; var i = 0; var commenthtml = "
"; for(i=0; i< commentPage.length; i++){ escaped_id = commentPage[i].CommentKey.Key.replace(/:/, "\\\\:"); commenthtml += "
avatar
"; commenthtml += "
"; commenthtml += "
" + commentPage[i].CommentBody + "
"; commenthtml += "
Posted on " + commentPage[i].PostedAtTime + "
"; commenthtml += "
"; commenthtml += "
"; } commenthtml += "" $("#comments").append(commenthtml); if(self.currentPage == 1){ self.numberComments = commentStats.NumberOfComments; self.pages = Math.ceil(self.numberComments/commentStats.NumberPerPage); } if((self.pages > 1) && (self.pages != self.currentPage)){ $("#showmore").show(); } else { $("#showmore").hide(); } self.stats(); $('#spinner').hide(); } this.stats = function(){ var startRange = (self.currentPage * self.perPage) + 1; if ((self.currentPage+1) == self.pages) var endRange = self.numberComments else var endRange = startRange + (self.perPage - 1); var range = startRange + ' - ' + endRange; document.getElementById('showmore').innerHTML = 'Show ' + range + ' of ' + self.numberComments + ' comments'; } this.post = function() { // get form elements and page info var articleKey = new ArticleKey(getUniqueKey4Pluck()); // create and send request var requestBatch = new RequestBatch(); var commentAction = new CommentAction(articleKey, document.location.href, document.title, $("#commentBody").val()); requestBatch.AddToRequest(commentAction); requestBatch.BeginRequest(serverUrl, this.submitted); } this.submitted = function(responseBatch) { if (responseBatch.Messages[0].Message == 'ok') { $("#error").html(""); var randomId = Math.floor(Math.random()*11); $("
").prependTo("#appendnew"); $("#" + randomId).hide(); var html = "
"; html += "avatar
"; html += "" + user.displayName + " wrote:"; html += "
" + $('#commentBody').val() + "
"; html += "
Posted just now
"; $("#" + randomId).html(html).fadeIn(); $('#commentBody').val(''); } else if (responseBatch.Messages[0].Message.charAt(0) == "W") { $("#error").html("We restrict rapid posting of multiple comments for quality reasons. You have already posted a comment within the last several seconds. Please try again later."); } else if (responseBatch.Messages[0].Message.charAt(0) == "T") { $("#error").html(responseBatch.Messages[0].Message); } } this.showreport = function(currentelement, showelement) { if(showelement.style.display == 'none'){ currentelement.style.background = '#cccccc' showelement.style.display = 'block'; if(showelement.getElementsByTagName('input')[0]){ showelement.getElementsByTagName('input')[0].id = "active_name"; showelement.getElementsByTagName('input')[1].id = "active_email"; showelement.getElementsByTagName('input')[2].id = "active_abuse"; showelement.getElementsByTagName('div')[3].id = "active_error"; } showelement.id = "active_form"; } else{ currentelement.style.background = '#ffffff' showelement.style.display = 'none'; if(showelement.getElementsByTagName('input')[0]){ showelement.getElementsByTagName('input')[0].id = ""; showelement.getElementsByTagName('input')[1].id = ""; showelement.getElementsByTagName('input')[2].id = ""; showelement.getElementsByTagName('div')[3].id = ""; } showelement.id = ""; } } this.report = function(comment) { var abuse = new RequestBatch(); var reason = document.getElementById('active_abuse').value; var name = document.getElementById('active_name').value; var email = document.getElementById('active_email').value; if((email != '') && (name != '') && (reason != '')){ var extra_info = name + ' - ' + email; abuse.AddToRequest(new ReportAbuseAction(new CommentKey(comment), reason, extra_info)); abuse.BeginRequest(serverUrl, this.completereport); } else { document.getElementById("active_error").innerHTML = "All fields are required. Please fill out missing fields and resubmit." } } this.completereport = function(responseBatch) { if (responseBatch.Messages[0].Message == 'ok') document.getElementById('active_form').innerHTML = "
Abuse Report Submitted.
"; document.getElementById('active_form').id = ""; } } function recommend_widget() { //gSiteLife.Recommend("ExternalResource", getUniqueKey4Pluck()); }