/* http://static.cdn.ocregister.com/common/loader/?js=/share/js/json,/share/js/pork-iframe,/share/js/requestbatch,/share/js/requesttypes,/share/js/sitelife-proxy,/share/js/sitelife&v=2 */ /* Copyright (c) 2005 JSON.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The Software shall be used for Good, not Evil. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /* The global object JSON contains two methods. JSON.stringify(value) takes a JavaScript value and produces a JSON text. The value must not be cyclical. JSON.parse(text) takes a JSON text and produces a JavaScript value. It will return false if there is an error. */ var JSON = function () { var m = { '\b': '\\b', '\t': '\\t', '\n': '\\n', '\f': '\\f', '\r': '\\r', '"' : '\\"', '\\': '\\\\' }, s = { 'boolean': function (x) { return String(x); }, number: function (x) { return isFinite(x) ? String(x) : 'null'; }, string: function (x) { if (/["\\\x00-\x1f]/.test(x)) { x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) { var c = m[b]; if (c) { return c; } c = b.charCodeAt(); return '\\u00' + Math.floor(c / 16).toString(16) + (c % 16).toString(16); }); } return '"' + x + '"'; }, object: function (x) { if (x) { var a = [], b, f, i, l, v; if (x instanceof Array) { a[0] = '['; l = x.length; for (i = 0; i < l; i += 1) { v = x[i]; f = s[typeof v]; if (f) { v = f(v); if (typeof v == 'string') { if (b) { a[a.length] = ','; } a[a.length] = v; b = true; } } } a[a.length] = ']'; } else if (x instanceof Object) { a[0] = '{'; for (i in x) { v = x[i]; f = s[typeof v]; if (f) { v = f(v); if (typeof v == 'string') { if (b) { a[a.length] = ','; } a.push(s.string(i), ':', v); b = true; } } } a[a.length] = '}'; } else { return; } return a.join(''); } return 'null'; } }; return { copyright: '(c)2005 JSON.org', license: 'http://www.crockford.com/JSON/license.html', /* Stringify a JavaScript value, producing a JSON text. */ stringify: function (v) { var f = s[typeof v]; if (f) { v = f(v); if (typeof v == 'string') { return v; } } return null; }, /* Parse a JSON text, producing a JavaScript value. It returns false if there is a syntax error. */ eval: function (text) { try { return !(/[^,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]/.test( text.replace(/"(\\.|[^"\\])*"/g, ''))) && eval('(' + text + ')'); } catch (e) { return false; } }, parse: function (text) { var at = 0; var ch = ' '; function error(m) { throw { name: 'JSONError', message: m, at: at - 1, text: text }; } function next() { ch = text.charAt(at); at += 1; return ch; } function white() { while (ch) { if (ch <= ' ') { next(); } else if (ch == '/') { switch (next()) { case '/': while (next() && ch != '\n' && ch != '\r') {} break; case '*': next(); for (;;) { if (ch) { if (ch == '*') { if (next() == '/') { next(); break; } } else { next(); } } else { error("Unterminated comment"); } } break; default: error("Syntax error"); } } else { break; } } } function string() { var i, s = '', t, u; if (ch == '"') { outer: while (next()) { if (ch == '"') { next(); return s; } else if (ch == '\\') { switch (next()) { case 'b': s += '\b'; break; case 'f': s += '\f'; break; case 'n': s += '\n'; break; case 'r': s += '\r'; break; case 't': s += '\t'; break; case 'u': u = 0; for (i = 0; i < 4; i += 1) { t = parseInt(next(), 16); if (!isFinite(t)) { break outer; } u = u * 16 + t; } s += String.fromCharCode(u); break; default: s += ch; } } else { s += ch; } } } error("Bad string"); } function array() { var a = []; if (ch == '[') { next(); white(); if (ch == ']') { next(); return a; } while (ch) { a.push(value()); white(); if (ch == ']') { next(); return a; } else if (ch != ',') { break; } next(); white(); } } error("Bad array"); } function object() { var k, o = {}; if (ch == '{') { next(); white(); if (ch == '}') { next(); return o; } while (ch) { k = string(); white(); if (ch != ':') { break; } next(); o[k] = value(); white(); if (ch == '}') { next(); return o; } else if (ch != ',') { break; } next(); white(); } } error("Bad object"); } function number() { var n = '', v; if (ch == '-') { n = '-'; next(); } while (ch >= '0' && ch <= '9') { n += ch; next(); } if (ch == '.') { n += '.'; while (next() && ch >= '0' && ch <= '9') { n += ch; } } if (ch == 'e' || ch == 'E') { n += 'e'; next(); if (ch == '-' || ch == '+') { n += ch; next(); } while (ch >= '0' && ch <= '9') { n += ch; next(); } } v = +n; if (!isFinite(v)) { ////error("Bad number"); } else { return v; } } function word() { switch (ch) { case 't': if (next() == 'r' && next() == 'u' && next() == 'e') { next(); return true; } break; case 'f': if (next() == 'a' && next() == 'l' && next() == 's' && next() == 'e') { next(); return false; } break; case 'n': if (next() == 'u' && next() == 'l' && next() == 'l') { next(); return null; } break; } error("Syntax error"); } function value() { white(); switch (ch) { case '{': return object(); case '[': return array(); case '"': return string(); case '-': return number(); default: return ch >= '0' && ch <= '9' ? number() : word(); } } return value(); } }; }();document.iframeLoaders = {}; iframe = function() { this.initialize.apply(this, arguments); }; iframe.prototype = { initialize: function(form, options,count){ if (!options) options = {}; this.form = form; this.uniqueId = count; document.iframeLoaders[this.uniqueId] = this; this.transport = this.getTransport(); this.onComplete = options.onComplete || null; this.update = this.$(options.update) || null; this.updateMultiple = options.multiple || false; if (((navigator.vendor && (navigator.vendor.indexOf('Apple')) > -1) || window.opera) // safari and opera only && (/\/Direct\/Process(\?|$)/.test(form.action)) && form.elements && (form.elements.length == 1)) { // only change calls that contain 1 element and whose actions end with /Direct/Process var url = form.action + '?jsonRequest=' + escape(form.elements[0].value), // change form submit to string; similar to changing form method to get doc = this.transport.contentWindow || this.transport.contentDocument; // retrieve the document of the iframe if (url.length < 80000) { // allow fallback to normal submission (80k is the max length for urls in safari) if (doc.document) // make sure we have the document and not the window doc = doc.document; try { // if this fails, fallback to normal submission doc.location.replace(url); // use location.replace to overwrite elements in history return; } catch (e) { }; } } form.target= 'frame_'+this.uniqueId; form.setAttribute("target", 'frame_'+this.uniqueId); // in case the other one fails. form.submit(); }, onStateChange: function() { this.transport = this.$('frame_'+this.uniqueId); try { var doc = this.transport.contentDocument.document.body.innerHTML; this.transport.contentDocument.document.close(); } // For NS6 catch (e){ try{ var doc = this.transport.contentWindow.document.body.innerHTML; this.transport.contentWindow.document.close(); } // For IE5.5 and IE6 catch (e){ try { var doc = this.transport.document.body.innerHTML; this.transport.document.body.close(); } // for IE5 catch (e) { try { var doc = window.frames['frame_'+this.uniqueId].document.body.innerText; } // for really nasty browsers catch (e) { //alert(e); } // forget it. } } } this.transport.responseText = doc; if (this.onComplete) setTimeout(this.bind(function(){this.onComplete(this.transport);}, this), 10); if (this.update) setTimeout(this.bind(function(){this.update.innerHTML = this.transport.responseText;}, this), 10); if (this.updateMultiple){ setTimeout(this.bind(function(){ // JSON support! try { var hasscript = false; eval("var inputObject = "+this.transport.responseText); // we're expecting a JSON object, eval it to inputObject for (var i in inputObject) { if (i == 'script') { hasscript = true; } // check if we passed some javascript along too else {if ( elm = this.$(i)) { elm.innerHTML = inputObject[i]; } else { //alert("element "+i+" not found!"); } } // if it's not script, update the corresponding div } if (hasscript) eval(inputObject['script']); // some on-the-fly-javascript exchanging support too } catch (e) { //alert('There was an error processing: '+this.transport.responseText); } // in case of an error }, this), 10); } }, getTransport: function() { var divElm = document.createElement('DIV'), frame; divElm.setAttribute('style', 'width: 0; height: 0; margin: 0; padding: 0; visibility: hidden; overflow: hidden'); if (navigator.userAgent.indexOf('MSIE') > 0 && navigator.userAgent.indexOf('Opera') == -1) {// switch to the crappy solution for IE divElm.style.width = 0; divElm.style.height = 0; divElm.style.margin = 0; divElm.style.padding = 0; divElm.style.visibility = 'hidden'; divElm.style.overflow = 'hidden'; divElm.innerHTML = ''; } else { frame = document.createElement("iframe"); frame.setAttribute("name", "frame_"+this.uniqueId); frame.setAttribute("id", "frame_"+this.uniqueId); frame.addEventListener("load", this.bind(function(){ this.onStateChange(); }, this), false); divElm.appendChild(frame); } document.body.appendChild(divElm); return frame; }, bind: function(functionObject, referenceObject) { return function() { return functionObject.apply(referenceObject, arguments); } }, '$': function(id) { return document.getElementById(id); } }; RequestBatch = function() { this.initialize.apply(this, arguments); }; // for unique id var counter = 0; // how many requests are still pending? var pendingRequests = 0; function DirectAccessErrorHandler(msg,ex){ //alert(msg); } // the core object to request batches RequestBatch.prototype = { initialize: function() { this.UniqueId = counter++; this.Requests = new Array() }, AddToRequest: function(requestThis) { this.Requests[this.Requests.length] = requestThis; }, BeginRequest: function(serverUrl, callback) { pendingRequests++; var jsonString = JSON.stringify(this); var form = generateForm(this.UniqueId, serverUrl, jsonString); new iframe(form, {onComplete: function(request) {processResponse(callback, request);} }, this.UniqueId); // in case they reuse the requestbatch this.UniqueId = counter++; } }; function generateForm(formId, serverUrl, inputVal) { // create the form var form = document.createElement("form"); form.name = "f" + formId; form.id = "f" + formId; form.action = serverUrl; // create the input element on the form var inputElem = document.createElement("input"); inputElem.name = "jsonRequest"; inputElem.type = "hidden"; inputElem.value = inputVal; form.appendChild(inputElem); // Firefox has a behavior on refresh that displays a popup confirming that is it reloading a form. // We work around this by attempting to perform a get action if the size is below a threshold, else // we will run as a post form.method = "post"; if(navigator.userAgent.toLowerCase().indexOf('firefox') != -1) { var separator = serverUrl.indexOf('?') == -1 ? "?" : "&"; var fullRequestURL = serverUrl + separator + "jsonRequest="+ escape(inputVal); if (fullRequestURL.length < 15000) { // we plan to perform a get, so we need to parse the sid out of the url and place it // inside the form var sidPos = serverUrl.indexOf('sid='); if (sidPos != -1) { var endPos = serverUrl.indexOf('&', sidPos); var sid = serverUrl.substring(sidPos + 'sid='.length, endPos == -1 ? serverUrl.length : endPos); var sidInputElem = document.createElement("input"); sidInputElem.name = "sid"; sidInputElem.type = "hidden"; sidInputElem.value = sid; form.appendChild(sidInputElem); // remove the sid from the url form.action = serverUrl.substring(0, sidPos-1); } form.method = "get"; } } // append the form to the document body // users must be cautious of when they call this due to a bug in IE // see http://support.microsoft.com/kb/927917 for details document.body.appendChild(form); return form; } function processResponse(callback, request) { pendingRequests--; try { var jsonResponse = unescape(request.responseText); var responseObject = JSON.parse(jsonResponse); try { callback(responseObject.ResponseBatch); } catch (e) { DirectAccessErrorHandler("exception during client callback", e); } } catch (e) { DirectAccessErrorHandler("exception during processResponse", e); } } function getPendingRequestCount() { return pendingRequests; } // ------------------------------------------------------------------------------------ // This file contains all the request type objects for the SiteLife JSON Direct API. // Create instances of these objects, place them in a RequestBatch, and send them off. // ------------------------------------------------------------------------------------ (function() { // wrapped in a function to keep the Class variable out of the global scope var Class = function() { return function() { this.initialize.apply(this, arguments); } }; // Identify a user UserKey = Class(); UserKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.UserKey = data; } }; // Identify a comment CommentKey = Class(); CommentKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.CommentKey = data; } }; // Identify an article ArticleKey = Class(); ArticleKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.ArticleKey = data; } }; // Identify a persona message PersonaMessageKey = Class(); PersonaMessageKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.PersonaMessageKey = data; } }; // Identify a review ReviewKey = Class(); ReviewKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.ReviewKey = data; } }; // Identify a gallery GalleryKey = Class(); GalleryKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.GalleryKey = data; } }; // Identify a photo PhotoKey = Class(); PhotoKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.PhotoKey = data; } }; // Identify a video VideoKey = Class(); VideoKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.VideoKey = data; } }; // Wrapper to request a comment page CommentPage = Class(); CommentPage.prototype = { initialize: function(articleKey, numberPerPage, onPage, sort) { var data = new Object(); data.ArticleKey = articleKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; data.Sort = sort; this.CommentPage = data; } }; // Wrapper to request a persona message page PersonaMessagePage = Class(); PersonaMessagePage.prototype = { initialize: function(userKey, numberPerPage, onPage, sort) { var data = new Object(); data.UserKey = userKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; data.Sort = sort; this.PersonaMessagePage = data; } }; // Wrapper to request a review page ReviewPage = Class(); ReviewPage.prototype = { initialize: function(articleKey, numberPerPage, onPage,sort) { var data = new Object(); data.ArticleKey = articleKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; data.Sort = sort; this.ReviewPage = data; } }; // Wrapper of types a gallery can contain MediaType = Class(); MediaType.prototype = { initialize: function(name) { var data = new Object(); data.Name = name; this.MediaType = data; } }; // Wrapper to request a page of public galleries PublicGalleryPage = Class(); PublicGalleryPage.prototype = { initialize: function(numberPerPage, onPage, mediaType) { var data = new Object(); data.NumberPerPage = numberPerPage; data.OnPage = onPage; data.MediaType = mediaType; this.PublicGalleryPage = data; } }; // Wrapper to request a page of user galleries UserGalleryPage = Class(); UserGalleryPage.prototype = { initialize: function(userKey, numberPerPage, onPage, mediaType) { var data = new Object(); data.UserKey = userKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; data.MediaType = mediaType; this.UserGalleryPage = data; } }; // Wrapper to request a page of photos PhotoPage = Class(); PhotoPage.prototype = { initialize: function(galleryKey, numberPerPage, onPage) { var data = new Object(); data.GalleryKey = galleryKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; this.PhotoPage = data; } }; // Wrapper to request a page of videos VideoPage = Class(); VideoPage.prototype = { initialize: function(galleryKey, numberPerPage, onPage) { var data = new Object(); data.GalleryKey = galleryKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; this.VideoPage = data; } }; // Wrapper to request a comment action CommentAction = Class(); CommentAction.prototype = { initialize: function(commentOnKey, onPageUrl, onPageTitle, commentBody) { var data = new Object(); data.CommentOnKey = commentOnKey; data.OnPageUrl = onPageUrl; data.OnPageTitle = onPageTitle; data.CommentBody = commentBody; this.CommentAction = data; } }; // Wrapper to request a review action ReviewAction = Class(); ReviewAction.prototype = { initialize: function(reviewOnThisKey, onPageUrl, onPageTitle, reviewTitle, reviewRating, reviewBody, reviewPros, reviewCons) { var data = new Object(); data.ReviewOnKey = reviewOnThisKey; data.OnPageUrl = onPageUrl; data.OnPageTitle = onPageTitle; data.ReviewTitle = reviewTitle; data.ReviewRating = reviewRating; data.ReviewBody = reviewBody; data.ReviewPros = reviewPros; data.ReviewCons = reviewCons; this.ReviewAction = data; } }; // Wrapper to request a recommend action RecommendAction = Class(); RecommendAction.prototype = { initialize: function(recommendThisKey) { var data = new Object(); data.RecommendThisKey = recommendThisKey; this.RecommendAction = data; } }; // Wrapper to request a rate action RateAction = Class(); RateAction.prototype = { initialize: function(rateThisKey, rating) { var data = new Object(); data.RateThisKey = rateThisKey; data.Rating = rating; this.RateAction = data; } }; // Permanently delete a gallery, video or photo DeleteContentAction = Class(); DeleteContentAction.prototype = { initialize: function(deleteThisContent) { var data = new Object(); data.DeleteThisContent = deleteThisContent; this.DeleteContentAction = data; } }; // Email from the SiteLife system EmailContentAction = Class(); EmailContentAction.prototype = { initialize: function(toAddress, subject, body) { var data = new Object(); data.ToAddress = toAddress; data.Subject = subject; data.Body = body; this.EmailContentAction = data; } }; // Wrapper to request a report abuse action ReportAbuseAction = Class(); ReportAbuseAction.prototype = { initialize: function(reportThisKey, abuseReason, abuseDescription) { var data = new Object(); data.ReportThisKey = reportThisKey; data.AbuseReason = abuseReason; data.AbuseDescription = abuseDescription; this.ReportAbuseAction = data; } }; // Category used for discovery Category = Class(); Category.prototype = { initialize: function(name) { var data = new Object(); data.Name = name; this.Category = data; } }; // Section used for discovery Section = Class(); Section.prototype = { initialize: function(name) { var data = new Object(); data.Name = name; this.Section = data; } }; // Update or create an article UpdateArticleAction = Class(); UpdateArticleAction.prototype = { initialize: function(updateArticle, onPageUrl, onPageTitle, section,categories) { var data = new Object(); data.UpdateArticle = updateArticle; data.OnPageUrl = onPageUrl; data.OnPageTitle = onPageTitle; data.Section = section; data.Categories = categories; this.UpdateArticleAction = data; } }; // Update or create a gallery UpdateGalleryAction = Class(); UpdateGalleryAction.prototype = { initialize: function(updateGallery, galleryType, mediaType, title, description, tags, section, galleryPromo) { var data = new Object(); data.UpdateGallery = updateGallery; data.GalleryType = galleryType; data.MediaType = mediaType; data.Title = title; data.Description = description; data.Tags = tags; data.Section = section; data.GalleryPromo = galleryPromo; this.UpdateGalleryAction = data; } }; // Update or create a photo UpdatePhotoAction = Class(); UpdatePhotoAction.prototype = { initialize: function(updatePhoto, title, description, tags, section) { var data = new Object(); data.UpdatePhoto = updatePhoto; data.Title = title; data.Description = description; data.Tags = tags; data.Section = section; this.UpdatePhotoAction = data; } }; // Update or create a video UpdateVideoAction = Class(); UpdateVideoAction.prototype = { initialize: function(updateVideo, title, description, tags, section) { var data = new Object(); data.UpdateVideo = updateVideo; data.Title = title; data.Description = description; data.Tags = tags; data.Section = section; this.UpdateVideoAction = data; } }; // GalleryType = Class(); GalleryType.prototype = { initialize: function(name) { var data = new Object(); data.Name = name; this.GalleryType = data; } }; // GalleryPromo used for setting promotional text for public galleries GalleryPromo = Class(); GalleryPromo.prototype = { initialize: function(title, body, photoKey) { var data = new Object(); data.Title = title; data.Body = body; data.PhotoKey = photoKey; } }; // UserTier used for discovery UserTier = Class(); UserTier.prototype = { initialize: function(name) { var data = new Object(); data.Name = name; this.UserTier = data; } }; // Activity used for discovery Activity = Class(); Activity.prototype = { initialize: function(name) { var data = new Object(); data.Name = name; this.Activity = data; } }; // Discovery on articles DiscoverArticlesAction = Class(); DiscoverArticlesAction.prototype = { initialize: function(searchSections,searchCategories,limitToContributors,activity,age,maximumNumberOfDiscoveries) { var data = new Object(); data.SearchSections = searchSections; data.SearchCategories = searchCategories; data.LimitToContributors = limitToContributors; data.Activity = activity; data.Age = age; data.MaximumNumberOfDiscoveries = maximumNumberOfDiscoveries; this.DiscoverArticlesAction = data; } }; // Action used to add a friend AddFriendAction = Class(); AddFriendAction.prototype = { initialize: function(friendUserKey) { var data = new Object(); data.FriendUserKey = friendUserKey; this.AddFriendAction = data; } }; // Action used to add a message AddPersonaMessageAction = Class(); AddPersonaMessageAction.prototype = { initialize: function(toUserKey, body) { var data = new Object(); data.ToUserKey = toUserKey; data.Body = body; this.AddPersonaMessageAction = data; } }; // Action used to remove a message RemovePersonaMessageAction = Class(); RemovePersonaMessageAction.prototype = { initialize: function(personaMessageKey) { var data = new Object(); data.PersonaMessageKey = personaMessageKey; this.RemovePersonaMessageAction = data; } }; // Action used to approve a friend ApproveFriendAction = Class(); ApproveFriendAction.prototype = { initialize: function(friendUserKey, isApproved) { var data = new Object(); data.FriendUserKey = friendUserKey; data.IsApproved = isApproved; this.ApproveFriendAction = data; } }; // Action used to remove a friend RemoveFriendAction = Class(); RemoveFriendAction.prototype = { initialize: function(friendUserKey) { var data = new Object(); data.FriendUserKey = friendUserKey; this.RemoveFriendAction = data; } }; // Wrapper to request a friend page FriendPage = Class(); FriendPage.prototype = { initialize: function(userKey, numberPerPage, onPage, isPendingList) { var data = new Object(); data.UserKey = userKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; data.IsPendingList = isPendingList; this.FriendPage = data; } }; // Wrapper to request if a given user key is a friend of the user specified by the second parameter // if the userKey parameter is not specified, the currently logged-in user is used IsFriend = Class(); IsFriend.prototype = { initialize: function(friendUserKey, userKey) { var data = new Object(); data.FriendUserKey = friendUserKey; data.UserKey = userKey; this.IsFriend = data; } }; // Discovery on content DiscoverContentAction = Class(); DiscoverContentAction.prototype = { initialize: function(searchSections,searchCategories,limitToContributors,activity,contentType,age,maximumNumberOfDiscoveries) { var data = new Object(); data.SearchSections = searchSections; data.SearchCategories = searchCategories; data.LimitToContributors = limitToContributors; data.Activity = activity; data.ContentType = contentType; data.Age = age; data.MaximumNumberOfDiscoveries = maximumNumberOfDiscoveries; this.DiscoverContentAction = data; } }; // Content type for discovery ContentType = Class(); ContentType.prototype = { initialize: function(name) { var data = new Object(); data.Name = name; this.ContentType = data; } }; UpdateUserProfileAction = Class(); UpdateUserProfileAction.prototype = { initialize: function( userKey, aboutMe, location, signature, dateOfBirth, sex, personaPrivacyMode, commentsTabVisible, photosTabVisible, messagesOpenToEveryone, isEmailNotificationsEnabled, selectedStyleId, customAnswers, extendedProfile) { var data = new Object(); data.UserKey = userKey; data.AboutMe = aboutMe; data.Location = location; data.Signature = signature; data.DateOfBirth = dateOfBirth; data.Sex = sex; data.PersonaPrivacyMode = personaPrivacyMode; data.CommentsTabVisible = commentsTabVisible; data.PhotosTabVisible = photosTabVisible; data.MessagesOpenToEveryone = messagesOpenToEveryone; data.IsEmailNotificationsEnabled = isEmailNotificationsEnabled; data.SelectedStyleId = selectedStyleId; data.CustomAnswers = customAnswers; data.ExtendedProfile = extendedProfile; this.UpdateUserProfileAction = data; } }; SearchAction = Class(); SearchAction.prototype = { initialize: function(searchType, searchString, numberPerPage, onPage ) { var data = new Object(); data.SearchType = searchType; data.SearchString = searchString; data.NumberPerPage = numberPerPage; data.OnPage = onPage; this.SearchAction = data; } }; // Wrapper to request a watch item page WatchItemPage = Class(); WatchItemPage.prototype = { initialize: function(userKey, numberPerPage, onPage) { var data = new Object(); data.UserKey = userKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; this.WatchItemPage = data; } }; // Wrapper to add a watch item AddWatchItemAction = Class(); AddWatchItemAction.prototype = { initialize: function(userKey, watchTargetKey, title, url ) { var data = new Object(); data.UserKey = userKey; data.WatchTargetKey = watchTargetKey; data.WatchItemTitle = title; data.WatchItemUrl = url; this.AddWatchItemAction = data; } }; // Wrapper to delete a watch item DeleteWatchItemAction = Class(); DeleteWatchItemAction.prototype = { initialize: function(userKey, watchTargetKey) { var data = new Object(); data.UserKey = userKey; data.WatchTargetKey = watchTargetKey; this.DeleteWatchItemAction = data; } }; // Identify a blog with this blog key BlogKey = Class(); BlogKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.BlogKey = data; } }; // Identify a blog post with this blog post key BlogPostKey = Class(); BlogPostKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.BlogPostKey = data; } }; // Wrapper to request a blog post page BlogPostPage = Class(); BlogPostPage.prototype = { initialize: function(blogKey, numberPerPage, onPage, sort) { var data = new Object(); data.BlogKey = blogKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; data.Sort = sort; this.BlogPostPage = data; } }; // Wrapper to request a blog post archive count BlogPostArchiveCount = Class(); BlogPostArchiveCount.prototype = { initialize: function(blogKey) { var data = new Object(); data.BlogKey = blogKey; this.BlogPostArchiveCount = data; } }; // Wrapper to request a blog post archive content page BlogPostArchiveContentPage = Class(); BlogPostArchiveContentPage .prototype = { initialize: function(blogKey, month, numberPerPage, onPage, sort) { var data = new Object(); data.BlogKey = blogKey; data.Month = month; data.NumberPerPage = numberPerPage; data.OnPage = onPage; data.Sort = sort; this.BlogPostArchiveContentPage = data; } }; // Wrapper to request a user comment page UserCommentPage = Class(); UserCommentPage.prototype = { initialize: function(userKey, numberPerPage, onPage, sort) { var data = new Object(); data.UserKey = userKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; data.Sort = sort; this.UserCommentPage = data; } }; // Wrapper to request blog tag RecentBlogTag = Class(); RecentBlogTag.prototype = { initialize: function(blogKey) { var data = new Object(); data.BlogKey = blogKey; this.RecentBlogTag = data; } }; // Wrapper to request recent user photo page RecentUserPhotoPage = Class(); RecentUserPhotoPage.prototype = { initialize: function(userKey, numberPerPage, onPage) { var data = new Object(); data.UserKey = userKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; this.RecentUserPhotoPage = data; } }; // Wrapper to request recent user video page RecentUserVideoPage = Class(); RecentUserVideoPage .prototype = { initialize: function(userKey, numberPerPage, onPage) { var data = new Object(); data.UserKey = userKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; this.RecentUserVideoPage = data; } }; // Wrapper to request recent public gallery page RecentPublicGalleryPage = Class(); RecentPublicGalleryPage .prototype = { initialize: function(userKey, numberPerPage, onPage) { var data = new Object(); data.UserKey = userKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; this.RecentPublicGalleryPage = data; } }; // Wrapper to request recent user activity page RecentUserActivity = Class(); RecentUserActivity .prototype = { initialize: function(userKey) { var data = new Object(); data.UserKey = userKey; this.RecentUserActivity = data; } }; // Wrapper to request recent forum discussion page RecentForumDiscussionPage = Class(); RecentForumDiscussionPage .prototype = { initialize: function(userKey, numberPerPage, onPage) { var data = new Object(); data.UserKey = userKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; this.RecentForumDiscussionPage = data; } }; // Wrapper to request user group forum page UserGroupForumPage = Class(); UserGroupForumPage .prototype = { initialize: function(userKey, numberPerPage, onPage, sort) { var data = new Object(); data.UserKey = userKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; data.Sort = sort; this.UserGroupForumPage = data; } }; // The blogRollEntry used in UpdateBlogAction BlogRollEntry = Class(); BlogRollEntry.prototype = { initialize: function(name, url) { var data = new Object(); data.Name = name; data.Url = url; this.BlogRollEntry = data; } }; // Update or create a blog UpdateBlogAction = Class(); UpdateBlogAction.prototype = { initialize: function(updateBlog, title, tagline, blogRollEntries) { var data = new Object(); data.BlogKey = updateBlog; data.Title = title; data.Tagline = tagline; data.BlogRollEntries = blogRollEntries; this.UpdateBlogAction = data; } }; // Identify a forum discussion with this DiscussionKey DiscussionKey = Class(); DiscussionKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.DiscussionKey = data; } }; // Identify a custom item with this CustomItemKey CustomItemKey = Class(); CustomItemKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.CustomItemKey = data; } }; // Identify a custom collection with this CustomCollectionKey CustomCollectionKey = Class(); CustomCollectionKey.prototype = { initialize: function(key) { var data = new Object(); data.Key = key; this.CustomCollectionKey = data; } }; // Update or create a custom item in storage UpdateCustomItemAction = Class(); UpdateCustomItemAction.prototype = { initialize: function(customItemKey, name, mimeType, displayText, content) { var data = new Object(); data.CustomItemKey = customItemKey; data.Name = name; data.MimeType = mimeType; data.DisplayText = displayText; data.Content = content; this.UpdateCustomItemAction = data; } }; // Add a new custom collection to storage AddCustomCollectionAction = Class(); AddCustomCollectionAction.prototype = { initialize: function(customCollectionKey, customCollectionName) { var data = new Object(); data.CustomCollectionKey = customCollectionKey; data.CustomCollectionName = customCollectionName; this.AddCustomCollectionAction = data; } }; // Insert an item into a custom collection InsertIntoCollectionAction = Class(); InsertIntoCollectionAction.prototype = { initialize: function(customCollectionKey, insertThisKey, position) { var data = new Object(); data.CustomCollectionKey = customCollectionKey; data.InsertThisKey = insertThisKey; data.Position = position; this.InsertIntoCollectionAction = data; } }; // Remove an item from a custom collection (position can be null to specify to remove all occurrences of item) RemoveFromCollectionAction = Class(); RemoveFromCollectionAction.prototype = { initialize: function(customCollectionKey, removeThisKey, position) { var data = new Object(); data.CustomCollectionKey = customCollectionKey; data.RemoveThisKey = removeThisKey; data.Position = position; this.RemoveFromCollectionAction = data; } }; // Get a page of items out of a custom collection CustomCollectionPage = Class(); CustomCollectionPage.prototype = { initialize: function(customCollectionKey, numberPerPage, onPage, sort) { var data = new Object(); data.CustomCollectionKey = customCollectionKey; data.NumberPerPage = numberPerPage; data.OnPage = onPage; data.Sort = sort; this.CustomCollectionPage = data; } }; })();var numUploads = 1; var maxUploads = 4; function VerifyTOS() { if(!document.getElementById("plckTermsOfPhotoService").checked) { alert("Please agree to the terms of service before submitting."); return false; } return true; } // use to generate more photo submission divs function AddAnotherPhoto(parentDivID,uploadButtonID, parentFrame){ divNode = document.createElement('div'); divNode.id = 'PhotoUpload' + ++numUploads; divNode.innerHTML = "

" document.getElementById(parentDivID).appendChild(divNode); if(numUploads > maxUploads) document.getElementById(uploadButtonID).style.display = 'none'; setTimeout(function(){autofitIframe(parentFrame, true);}, 100); return false; } // Returns the value of the radio button that is set in a group of buttons. function getCheckedValue(radioObj) { var radioLength = radioObj.length; if(radioLength == undefined) { if(radioObj.checked) { return radioObj.value; } else { return ""; } } for(var i = 0; i < radioLength; i++) { if(radioObj[i].checked) { return radioObj[i].value; } } return ""; } // this trim was suggested by Tobias Hinnerup String.prototype.trim = function() { return(this.replace(/^\s+/,'').replace(/\s+$/,'')); } function IsEnter(e) { var kc = e.which; if(kc == null) kc = e.keyCode; if (e && kc == 13) return true; return false; } function TrimEnd(ct, c) { while((ct.length > 0) && (ct.lastIndexOf(c) == (ct.length - 1))){ if(ct.length > 1 ) { ct = ct.substring(0, ct.length - 1); }else{ return ""; } } return ct; } function FixSearchString(str) { var ct = str.replace(/[\%\&\/\<\>\\\|]+/g,""); ct = ct.replace(/[\.]{2,}/g, "."); ct = TrimEnd(ct,"."); if( ct == "" ) return ""; ct = TrimEnd(ct," "); if( ct == "") return ""; ct = escape(ct); // JavaScript's built-in escape() skips plus signs, but we need them for Lucene ct = ct.replace(/\+/g, "%2B"); return ct; } var nextGroupID = 1; function autofitIframe(id, heightOnly){ if(document.getElementById) { if(this.document.body.scrollHeight == 0 || ( !heightOnly && this.document.body.scrollWidth == 0)) { //Onload fired, DOM assembled, but scrollHeight/Width is zero. This should not be... Go to //sleep and try again setTimeout(function(){autofitIframe(id, heightOnly);}, 150); return; } window.parent.document.getElementById(id).style.height=this.document.body.scrollHeight+"px"; if(!heightOnly)window.parent.document.getElementById(id).style.width=this.document.body.scrollWidth+"px"; } } //Determines if the string being tested is a Url. function isUrl(s) { var regexp = /(ftp|https?|file):\/\/(\w+:{0,1}\w*@)?(\S+)(:[0-9]+)?(\/|\/([\w#!:.?+=&%@!\-\/]))?/ return regexp.test(s); } function ValidateLogin() { function $(id) { return document.getElementById(id) }; if($("plckUserName").value == '' && $("plckPassword").value == '') { alert("You must provide a UserName and Password"); return false; } if($("plckUserName").value == '') { alert("You must provide a UserName"); return false; } if($("plckPassword").value == '') { alert("You must provide a Password"); return false; } } function onSearchSubmit(qroupID) { if($(qroupID + "_Search").value == '') { alert("You must provide some query text"); return false; } } function LimitLength(control, limitToLength) { var str = control.value; if(! str || str.length == 0) return false; var matches = str.match(/\r|\n/g); if(! matches) return false; var offSet = matches.length; if (str.length > (limitToLength + offSet)) { control.value = str.substring(0, limitToLength + offSet); } return false; } /* this document is for visual dhtml features */ function mouseX(evt) { if (evt.pageX) return evt.pageX; else if (evt.clientX) return evt.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft); else return null; } function mouseY(evt) { if (evt.pageY) return evt.pageY; else if (evt.clientY) return evt.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop); else return null; } function HideDiv(id){ document.getElementById(id).style.display = "none"; } function ShowDivAtMouse(evt, id) { posx = mouseX(evt) - 170; posy = mouseY(evt); //normalize to make sure we at least appear on the screen if(posx < 0) posx = 10; if(posy < 0) posy = 10; document.getElementById(id).style.left = posx + "px"; document.getElementById(id).style.top = posy + "px"; document.getElementById(id).style.display = "block"; } function ShowReportAbuse(evt, url, command) { var doc = document; doc.getElementById("ReportAbuse_Url").value = url; doc.getElementById("ReportAbuse_Command").value = command; doc.getElementById("ReportAbuse_CommentText").value = ""; doc.getElementById("ReportAbuse_Reason").selectedIndex = 0; ShowDivAtMouse(evt, "ReportAbuse_Menu"); doc.getElementById('ReportAbuse_CommentText').focus(); } function ReportAbuse() { var url = document.getElementById("ReportAbuse_Url").value; var command = document.getElementById("ReportAbuse_Command").value; var text = document.getElementById("ReportAbuse_CommentText").value; var reason = document.getElementById("ReportAbuse_Reason").value; document.getElementById("ReportAbuse_Menu").style.display='none'; var sendUrl = command+'&plckReason='+gSiteLife.EscapeValue(reason)+'&plckURL=' + gSiteLife.EscapeValue(url) if(text) sendUrl += "&plckAbuseDetail=" + gSiteLife.EscapeValue(text); gSiteLife.__Send(sendUrl); } function SiteLifeShowHide(id1, id2){ document.getElementById(id1).style.display = "none"; document.getElementById(id2).style.display = "block"; return false; } function DebugShowInnerHTML(id, url) { var el = document.getElementById(id); var floatDiv = document.createElement("div"); floatDiv.style.position = "absolute"; floatDiv.style.zIndex='1000'; floatDiv.innerHTML = "[close]"; floatDiv.innerHTML += "
" + url + "
"; el.insertBefore(floatDiv, el.childNodes[0]); } function ToggleState() { function $(id) { return document.getElementById(id) }; var radio1 = $("plckCommentApprovalEveryOne"); var radio2 = $("plckCommentApprovalNoBody"); var table = $("commentSettings"); if(radio1.disabled == true) { radio1.disabled = false; radio2.disabled = false; table.className = ""; } else { radio1.disabled = true; radio2.disabled = true; table.className = "BlogSettings_Disabled"; } } //multi site enabled -- sid: sitelife.ocregister.com // document.write(""); // document.write(""); // document.write(""); ///constructor to create a new SiteLifeProxy function SiteLifeProxy(url) { // User Configurable Properties - these can be set at any time // your apiKey, this value must be set! this.apiKey = null; // sniff the browser for custom behaviors this.__isExplorer = navigator.userAgent.toLowerCase().indexOf('msie') != -1; this.__isSafari = navigator.userAgent.toLowerCase().indexOf('safari') != -1; this.__isMac = navigator.platform.toLowerCase().indexOf('mac') != -1; this.__isMacIE = this.__isMac && this.__isExplorer; // if enabled, spit out debug information through alert() this.debug = false; // used to track the id of the handler expecting the results from the immediately preceeding method invocation // this is used only for testing purposes this.lastHandlerId = ""; // Methods You can Overide // // OnSuccess(returnValue) - is passed the return value at the end of a successful call, default does nothing // OnError(msg) - is passed an error message if a problem occurs // OnDebug(msg) - is called when debugging is enabled this.__baseUrl = url; this.__sendInvokeCount = 0; this.__eventHandlers = new Object(); }; SiteLifeProxy.prototype.AddEventHandler = function (event_name, callback) {this.__eventHandlers[event_name] = callback;} SiteLifeProxy.prototype.FireEvent = function (event_name) { if(this.__eventHandlers[event_name]) { var A = new Array(); for (var i = 1; i < this.FireEvent.arguments.length; i++){ A[i - 1] = this.FireEvent.arguments[i];} return this.__eventHandlers[event_name].apply(this, A); } } SiteLifeProxy.prototype.ScriptId = function() { return this.__scriptId = "_bb_script_" + this.__sendInvokeCount++; } // Default error handler for the proxy object, simple alert SiteLifeProxy.prototype.OnError = function(msg) { alert("OnError: " + msg); } // Default debug handler for the proxy object, simple alert SiteLifeProxy.prototype.OnDebug = function(msg) { if (this.debug) alert("Debug: " + msg); } // fetch a named request parameter from the page URL SiteLifeProxy.prototype.GetParameter = function(parameterName) { var key = parameterName + "="; var parameters = document.location.search.substring(1).split("&"); for (var i = 0; i < parameters.length; i++) { if (parameters[i].indexOf(key) == 0) return parameters[i].substring(key.length); } return null; }; // browser independent method to get elements by ID SiteLifeProxy.prototype.GetElement = function(id) { this.OnDebug("GetElement " + id); if (document.getElementById) return document.getElementById(id); if (document.all) return document.all[id]; this.OnError("No support for GetElement() in this browser"); return null; } // browser independent method to get elements by tag name SiteLifeProxy.prototype.GetTags = function(tagName) { this.OnDebug("GetTags " + tagName); if (document.getElementsByTagName) return document.getElementsByTagName(tagName); if (document.all) return document.tags(tagName); this.OnError("No support for GetTags() in this browser"); return null; } SiteLifeProxy.prototype.EscapeValue = function(s) { if (s == null) return null; return encodeURIComponent(s); }; SiteLifeProxy.prototype.__ArrayValidation = function(s) { if ((typeof s == 'undefined') || (s.length < 1)) { return false; } return true; } SiteLifeProxy.prototype.__CheckErrorHandler = function(onError) { this.OnDebug("__CheckErrorHandler " + onError); if ((typeof onError == 'undefined') || (eval("window." + onError) == null)) { return "gSiteLife.OnError"; } return onError; } SiteLifeProxy.prototype.SetCookie = function SetCookie( name, value) { var today = new Date(); today.setTime( today.getTime() ); var expires_date = new Date( today.getTime() + 126144000000 ); document.cookie = name + "=" +escape( value ) + ";expires=" + expires_date.toGMTString() + ";path=/" + ";domain=ocregister.com" ; } // validate and fetch arguments, if the argument is missing and optional, we return an empty string SiteLifeProxy.prototype.__GetArgument = function(variableName, variableValue, isRequired, isArray) { this.OnDebug("__GetArgument " + variableName + "," + variableValue + "," + isRequired + "," + isArray); if (typeof variableValue == "undefined" || variableValue == null || variableValue == "") { if (isRequired) { this.OnError("Missing required parameter " + variableName); this.__isValid = false; return ""; } else return ""; } if (isRequired && isArray) { if (!this.__ArrayValidation(variableValue)) { this.OnError("Invalid array parameter " + variableName); this.__isValid = false; return ""; } } return "&" + variableName + "=" + this.EscapeValue(variableValue); }; SiteLifeProxy.prototype.__StripAnchorFromUrl = function(url) { var aIdx = url.indexOf("#"); return aIdx == -1 ? url : url.substring(0, aIdx); } SiteLifeProxy.prototype.__SafeAppendUrlValue = function(url, key, value) { url += url.indexOf("?") != -1 ? "&" : "?"; return url + key + "=" + value; } SiteLifeProxy.prototype.__AppendUrlValues = function (url) { time = new Date(); url += this.__GetArgument("plckNoCache", time.getTime(), false, false); url += this.__GetArgument("plckApiKey", this.apiKey, true, false); url += this.__GetArgument("sid", gSiteLife.SID, false, false); return url; } SiteLifeProxy.prototype.ReloadPage = function(params) { var sSearch = window.location.search.substring(1); var sNVPs = sSearch.split('&'); var newSearch = ""; for(var k in params) { if(k == "extend") continue; if(newSearch == "") newSearch += "?"; else newSearch += "&"; newSearch += k + '=' + params[k]; } for (var i = 0; i < sNVPs.length; i++) { var kv = sNVPs[i].split('='); if(kv[0] && kv[0].indexOf('plck') != 0 && ! params[kv[0]]) { newSearch += "&" + sNVPs[i]; } } window.location.search = newSearch; } function loadScript (url, callback) { var script = document.createElement('script'); script.type = 'text/javascript'; script.charset = 'utf-8'; if (callback) script.onload = script.onreadystatechange = function() { if (script.readyState && script.readyState != 'loaded' && script.readyState != 'complete') return; script.onreadystatechange = script.onload = null; callback(); }; script.src = url; document.getElementsByTagName('head')[0].appendChild (script); } SiteLifeProxy.prototype.__Send = function(url, scriptToUse) { this.OnDebug("_Send " + url); if (this.__isSafari) { loadScript(url); return; } scriptToUse = scriptToUse || this.ScriptId(); //append our various parameters as necessary url = this.__AppendUrlValues(url); this.OnDebug("_Send (updated) " + url); // add the script node to the document if (document.createElement && ! this.__isMacIE) { var scriptNode = document.getElementById(scriptToUse); var head = this.GetTags('head')[0]; if ( (scriptNode != null) && (scriptNode != undefined) && (!this.__isExplorer) && head.removeChild && (!this.__isSafari)) { head.removeChild(scriptNode); scriptNode = null; } if(scriptNode == null) { scriptNode = document.createElement('script'); scriptNode.id = scriptToUse; scriptNode.setAttribute('type','text/javascript'); scriptNode.setAttribute('charset', 'utf-8'); head.appendChild(scriptNode); } scriptNode.setAttribute('src', url); return; } // could fall back to sync at this point, but will bust if the page is already loaded this.OnError("No support for async in this browser"); } SiteLifeProxy.prototype.Logout = function(ScriptToUse, IsRestPage) { var plckRest = IsRestPage ? true : false; this.__Send(this.__baseUrl + '/Utility/Logout?plckRedirectUrl=' + escape(window.location.href) + '&plckRest=' + plckRest, ScriptToUse); return false; } SiteLifeProxy.prototype.AddLoadEvent = function(func) { if(window.addEventListener){ window.addEventListener("load", func, false); }else{ if(window.attachEvent){ window.attachEvent("onload", func); }else{ if(document.getElementById){ var oldonload = window.onload; if (typeof window.onload != 'function') { window.onload = func; } else { window.onload = function() { if (oldonload) { oldonload(); } func(); }}}}}} SiteLifeProxy.prototype.AdInsertHelper = function() { for(var src in gSiteLife.__adsToInsert) { if(src == "extend") continue; var dest = gSiteLife.__adsToInsert[src]; var parent = document.getElementById(dest); var newChild = document.getElementById(src); if( ! parent || ! newChild ) {continue; } parent.replaceChild( newChild, document.getElementById(dest + "Child")); newChild.style.display = "block"; parent.style.display = "block"; } } SiteLifeProxy.prototype.InsertAds = function(source, destination) { gSiteLife.__adsToInsert = new Object(); for(ii=0; ii< this.InsertAds.arguments.length; ii+=2) { gSiteLife.__adsToInsert[this.InsertAds.arguments[ii]] = this.InsertAds.arguments[ii+1];} this.AddLoadEvent(gSiteLife.AdInsertHelper); } SiteLifeProxy.prototype.TitleTag = function() { var titleTag = document.getElementById("plckTitleTag"); return titleTag ? titleTag.innerText || titleTag.textContent : null; } SiteLifeProxy.prototype.WriteDiv = function(id, divClass) { var cssClass = divClass ? divClass : ""; document.write('
'); return id; } SiteLifeProxy.prototype.InnerHtmlWrite = function(elementId, innerContents ) { var el = document.createElement("div"); try { if(document.location.href.indexOf("debug=true") > -1) { el.innerHTML += "
 ? 
" + innerContents + "
"; } else { el.innerHTML += innerContents; el.style.display = "inline"; } var destDiv = document.getElementById(elementId); while (destDiv.childNodes.length >= 1) { destDiv.removeChild(destDiv.childNodes[0]); } destDiv.appendChild(el); } catch (error) { alert(elementId + " Error " + error.number + ": " + error.description); } } SiteLifeProxy.prototype.SortTimeStampDescending = "TimeStampDescending"; SiteLifeProxy.prototype.SortTimeStampAscending = "TimeStampAscending"; SiteLifeProxy.prototype.SortRecommendationsDescending = "RecommendationsDescending"; SiteLifeProxy.prototype.SortRecommendationsAscending = "RecommendationsAscending"; SiteLifeProxy.prototype.SortRatingDescending = "RatingDescending"; SiteLifeProxy.prototype.SortRatingAscending = "RatingAscending"; SiteLifeProxy.prototype.KeyTypeExternalResource = "ExternalResource"; SiteLifeProxy.prototype.PersonaHeaderRequest = function(UserId) { var url = this.__baseUrl + '/Persona/PersonaHeader?plckElementId=personaHDest&plckUserId='+ UserId; this.__Send(url, "personaHeaderScript"); } SiteLifeProxy.prototype.PersonaHeader = function(UserId) { this.WriteDiv("personaHDest", "Persona_Main"); this.PersonaHeaderRequest(UserId); } SiteLifeProxy.prototype.Persona = function(UserId) { this.WriteDiv("personaDest", "Persona_Main"); var action = this.GetParameter("plckPersonaPage"); if(action && (typeof this[action] == 'function')) this[action](UserId); else this.PersonaHome(UserId); } SiteLifeProxy.prototype.LoadPersonaPage = function(PageName, UserId) { var params = new Object(); params['plckPersonaPage'] = PageName; params['plckUserId'] = UserId; params['slid'] = UserId; for(ii=2; ii< this.LoadPersonaPage.arguments.length; ii+=2) { params[this.LoadPersonaPage.arguments[ii]] = this.LoadPersonaPage.arguments[ii+1];} this.ReloadPage(params); return false; } SiteLifeProxy.prototype.PersonaHome = function(UserId) { return this.PersonaSend('PersonaHome', 'personaDest', 'personaScript', UserId); } SiteLifeProxy.prototype.WatchItem = function(Controller,Method,WatchKey, targetDiv) { var url = this.__baseUrl + '/'+Controller+'/' + Method + '?' + 'plckWatchKey=' + WatchKey + '&plckElementId=' + targetDiv + '&plckWatchUrl=' + this.EscapeValue(window.location.href); this.__Send(url, "AddWatchScript"); return false; } SiteLifeProxy.prototype.PersonaRemoveWatchItem= function(UserId, WatchKey, Div, View) { return this.PersonaSend('PersonaRemoveWatchItem', Div, 'personaScript', UserId, 'plckWatchView=' + View + '&plckWatchKey=' + WatchKey); } SiteLifeProxy.prototype.PersonaAddFriend= function(UserId) { return this.PersonaSend('PersonaAddFriend', 'personaHDest', 'personaScript', UserId); } SiteLifeProxy.prototype.PersonaRemoveFriend = function(UserId, Friend, Div, View, Expanded) { if(!Expanded) Expanded = "false"; if (confirm("Are you sure you want to delete this user from your list of Friends?") == true) { return this.PersonaSend('PersonaRemoveFriend', Div, 'personaScript', UserId, 'plckFriendView=' + View + '&plckFriend=' + Friend + '&plckExpanded=' + Expanded); } return false; } SiteLifeProxy.prototype.PersonaRemovePendingFriend = function(UserId, PendingFriend, Div) { if (confirm("Are you sure you want to delete this user's invite?") == true) { return this.PersonaSend('PersonaRemovePendingFriend', Div, 'personaScript', UserId, 'plckPendingFriend=' + PendingFriend); } return false; } SiteLifeProxy.prototype.PersonaAddPendingFriend = function(UserId, PendingFriend, Div) { return this.PersonaSend('PersonaAddPendingFriend', Div, 'personaScript', UserId, 'plckPendingFriend=' + PendingFriend); } SiteLifeProxy.prototype.PersonaMessages = function(UserId) { var AdParams = this.GetParameter('plckCurrentPage') ? 'plckCurrentPage=' + this.GetParameter('plckCurrentPage') : ""; var scrl = this.GetParameter('plckScrollToAnchor'); if(scrl){ if(AdParams) {AdParams +='&';} AdParams += 'plckScrollToAnchor=' + scrl;} if(this.GetParameter('plckMessageSubmitted')){if(AdParams) {AdParams +='&';} AdParams += 'plckMessageSubmitted=' + this.GetParameter('plckMessageSubmitted');} return this.PersonaSend('PersonaMessages', 'personaDest', 'personaScript', UserId, AdParams); } SiteLifeProxy.prototype.PersonaComments = function(UserId) { var AdParams = this.GetParameter('plckCurrentPage') ? 'plckCurrentPage=' + this.GetParameter('plckCurrentPage') : ""; return this.PersonaSend('PersonaComments', 'personaDest', 'personaScript', UserId, AdParams); } SiteLifeProxy.prototype.PersonaBlog = function(UserId) { var AdParams = this.GetParameter('plckCurrentPage') ? 'plckCurrentPage=' + this.GetParameter('plckCurrentPage') : ""; if(AdParams) {AdParams +='&';} AdParams += 'plckBlogId=' + UserId; var url = this.__baseUrl + '/PersonaBlog/PersonaBlog?plckElementId=personaDest&plckUserId='+ UserId + '&' + AdParams; this.__Send(url, 'personaScript'); return false; } SiteLifeProxy.prototype.PersonaProfile = function(UserId) { return this.PersonaSend('PersonaProfile', 'personaDest', 'personaScript', UserId); } SiteLifeProxy.prototype.PersonaWatchListPaginate = function(UserId, pageNum) { return this.PersonaPaginate('WatchList', pageNum, UserId); } SiteLifeProxy.prototype.PersonaFriendsPaginate = function(UserId, pageNum) { return this.PersonaPaginate('Friends', pageNum, UserId); } SiteLifeProxy.prototype.PersonaPendingFriendsPaginate = function(UserId, pageNum) { var AdParam = "plckPendingFriendsPageNum=" + pageNum; return this.PersonaPaginate('Friends', 0, UserId,AdParam); } SiteLifeProxy.prototype.PersonaMessagesPreviewPaginate = function(UserId, pageNum) { return this.PersonaPaginate('MessagesPreview', pageNum, UserId); } SiteLifeProxy.prototype.PersonaMessageRemove = function(UserId, pageNum, MessageKey) { if (confirm("Are you sure you want to remove this message from the page?") == true) { return this.PersonaSend('PersonaRemoveMessage', 'personaDest', 'PersonaMessagesPageScript', UserId, 'plckCurrentPage='+ pageNum + '&plckMessageKey='+MessageKey); } return false; } SiteLifeProxy.prototype.PersonaSend = function(ApiName, DestDiv, ScriptName, UserId, AddParams){ var url = this.__baseUrl + '/Persona/' + ApiName + '?plckElementId=' + DestDiv + '&plckUserId='+ UserId; if(AddParams) url += '&' + AddParams; this.__Send(url, ScriptName); return false; } SiteLifeProxy.prototype.PersonaPaginate = function(ApiName, PageNum, UserId, AddParams){ var url = this.__baseUrl + '/Persona/Persona' + ApiName + '?plck' + ApiName + 'PageNum=' + PageNum + '&plckElementId=Persona' + ApiName + 'Dest&plckUserId='+ UserId; if(AddParams) url += '&' + AddParams; this.__Send(url, 'Persona'+ ApiName + 'Script'); return false; } SiteLifeProxy.prototype.PersonaPhotoSend = function(ApiName, DestDiv, ScriptName, UserId, AddParams){ var url = this.__baseUrl + '/PersonaPhoto/' + ApiName + '?plckElementId=' + DestDiv + '&plckUserId='+ UserId; if(AddParams) url += '&' + AddParams; this.__Send(url, ScriptName); return false; } SiteLifeProxy.prototype.PersonaMostRecent = function(UserId, PhotoID, DestDiv) { return this.PersonaPhotoSend('PersonaMostRecent', DestDiv, 'personaScript', UserId,'plckPhotoID=' + PhotoID); } SiteLifeProxy.prototype.PersonaCreateGallery = function(UserId) { return this.PersonaPhotoSend('UserGalleryCreate', 'personaDestPhoto', 'personaScript', UserId); } SiteLifeProxy.prototype.PersonaEditGallery = function(UserId,GalleryID) { return this.PersonaPhotoSend('UserGalleryEdit', 'userGalleryDest', 'personaScript', UserId,'plckGalleryID=' + GalleryID); } SiteLifeProxy.prototype.PersonaUploadToUserGallery = function(GalleryId) { var url = this.__baseUrl + '/Photo/PhotoUpload?plckElementId=userGalleryDest&plckGalleryID='+ GalleryId; this.__Send(url); return false; } SiteLifeProxy.prototype.PersonaPhotos = function(UserId) { return this.PersonaPhotoSend('PersonaPhotos', 'personaDest', 'personaScript', UserId); } SiteLifeProxy.prototype.PersonaAllPhotos = function(UserId) { return this.PersonaPhotoSend('PersonaAllPhotos', 'personaDest', 'personaScript', UserId); } SiteLifeProxy.prototype.PersonaGalleryPhoto = function(UserId) { return this.PersonaPhotoSend('PersonaGalleryPhoto', 'personaDest', 'personaScript', UserId); } SiteLifeProxy.prototype.PersonaMyRecentPhotos = function(UserId,ElementId, PageNum) { return this.PersonaPhotoSend('PersonaMyRecentPhotos', ElementId, 'personaScript', UserId,'plckPageNum=' + PageNum); } SiteLifeProxy.prototype.PersonaGallery = function(UserId,GalleryId,PageNum) { if(!PageNum){ PageNum = gSiteLife.GetParameter("plckPageNum") ? gSiteLife.GetParameter("plckPageNum") : 0; } if(!GalleryId) { GalleryId = gSiteLife.GetParameter("plckGalleryID"); } return this.PersonaPhotoSend('PersonaGallery', 'personaDest', 'personaScript', UserId,'plckGalleryID='+ GalleryId + '&plckPageNum=' + PageNum); } SiteLifeProxy.prototype.UserGalleryList = function(UserId,ElementId, PageNum) { return this.PersonaPhotoSend('UserGalleryList', ElementId, 'personaScript', UserId,'plckPageNum=' + PageNum); } SiteLifeProxy.prototype.PersonaGallerySubmissions = function(UserId,ElementId, PageNum){ return this.PersonaPhotoSend('PersonaGallerySubmissions', ElementId, 'personaScript', UserId,'plckPageNum=' + PageNum); } SiteLifeProxy.prototype.PersonaGalleryPhoto = function(UserId) { var photoid = gSiteLife.GetParameter('plckPhotoID'); return this.PersonaPhotoSend('PersonaGalleryPhoto', 'personaDest','personaScript', UserId,'&plckPhotoID=' +photoid); } SiteLifeProxy.prototype.PersonaRecentGalleryPhoto = function(UserId) { var photoid = gSiteLife.GetParameter('plckPhotoID'); return this.PersonaPhotoSend('PersonaRecentGalleryPhoto', 'personaDest','personaScript', UserId,'&plckPhotoID=' +photoid); } SiteLifeProxy.prototype.LoadPersonaGalleryPage = function(UserId,GalleryID) { var params = new Object(); params['plckPersonaPage'] = 'PersonaGallery'; params['plckUserId'] = UserId; params['slid'] = UserId; params['plckGalleryID'] = GalleryID; this.ReloadPage(params); return false; } SiteLifeProxy.prototype.LoadPersonaPhotoPage = function(UserId,PhotoID) { var params = new Object(); params['plckPersonaPage'] = 'PersonaGalleryPhoto'; params['plckUserId'] = UserId; params['slid'] = UserId; params['plckPhotoID'] = PhotoID; this.ReloadPage(params); return false; } SiteLifeProxy.prototype.LoadPersonaRecentPhotoPage = function(UserId,PhotoID) { var params = new Object(); params['plckPersonaPage'] = 'PersonaRecentGalleryPhoto'; params['plckUserId'] = UserId; params['slid'] = UserId; params['plckPhotoID'] = PhotoID; this.ReloadPage(params); return false; } SiteLifeProxy.prototype.SolicitPhoto = function(galleryID) { var elementId = 'plcksolicit' + galleryID; this.WriteDiv(elementId); var url = this.__baseUrl + '/Photo/SolicitPhoto?plckElementId=' + elementId + '&plckGalleryID=' +galleryID; this.__Send(url); return false; } SiteLifeProxy.prototype.PhotoUpload = function() { var elementId = 'plcksubmit'; this.WriteDiv(elementId); var galleryID = gSiteLife.GetParameter('plckGalleryID'); var url = this.__baseUrl + '/Photo/PhotoUpload?plckElementId=' + elementId + '&plckGalleryID=' +galleryID; this.__Send(url); return false; } SiteLifeProxy.prototype.PublicGallery = function() { var elementId = 'plckgallery'; this.WriteDiv(elementId); var galleryID = gSiteLife.GetParameter('plckGalleryID'); var pageNum = gSiteLife.GetParameter('plckPageNum'); var url = this.__baseUrl + '/Photo/PublicGallery?plckElementId=' + elementId + '&plckGalleryID=' +galleryID + '&plckPageNum=' +pageNum; this.__Send(url); return false; } SiteLifeProxy.prototype.GalleryPhoto = function() { var elementId = 'plckphoto'; this.WriteDiv(elementId); var photoid = gSiteLife.GetParameter('plckPhotoID'); var url = this.__baseUrl + '/Photo/GalleryPhoto?plckElementId=' + elementId + '&plckPhotoID=' +photoid; this.__Send(url); return false; } SiteLifeProxy.prototype.PublicGalleries = function() { var elementId = 'plckgalleries'; this.WriteDiv(elementId); var pageNum = gSiteLife.GetParameter('plckPageNum') ? gSiteLife.GetParameter('plckPageNum') : "0"; var url = this.__baseUrl + '/Photo/PublicGalleries?plckElementId=' + elementId + '&plckPageNum=' + pageNum; this.__Send(url); return false; } SiteLifeProxy.prototype.PhotoRecommend = function(targetid,recommendDiv,isGallery) { var url = this.__baseUrl + '/Photo/Recommend?plckElementId=' + recommendDiv + '&plckTargetid=' +targetid + '&plckIsGallery=' +isGallery ; this.__Send(url); return false; } //parentKeyType can be any gSiteLife.KeyType* value, but for including this widget on an article page the value is //typically gSiteLife.KeyTypeExternalResource SiteLifeProxy.prototype.Comments = function(parentKeyType, parentKey, pageSize, sort, showTabs, tab, parentUrl, parentTitle, refreshPage) { return this.CommentsInternal(parentKeyType, parentKey, pageSize, sort, showTabs, tab, parentUrl, parentTitle, false, false, null, refreshPage); }; SiteLifeProxy.prototype.CommentsInput = function(parentKeyType, parentKey, redirectToUrl) { return this.CommentsInternal(parentKeyType, parentKey, null, "TimeStampDescending", null, null, null, null, true, false, redirectToUrl, false); }; SiteLifeProxy.prototype.CommentsOutput = function(parentKeyType, parentKey, refreshPage, pageSize, sortOrder) { sortOrder = sortOrder || "TimeStampDescending"; return this.CommentsInternal(parentKeyType, parentKey, pageSize, sortOrder, null, null, null, null, false, true, null, refreshPage); } SiteLifeProxy.prototype.CommentsRefresh = function(parentKeyType, parentKey, pageSize, sortOrder) { if (!parentKey || parentKey == "") throw "Must pass in value for parentKey!"; return this.CommentsInternal(parentKeyType, parentKey, pageSize, sortOrder, null, null, null, null, false, false, null, true); } SiteLifeProxy.prototype.CommentsInternal = function(parentKeyType, parentKey, pageSize, sort, showTabs, tab, parentUrl, parentTitle, hideView, hideInput, redirectToUrl, refreshPage) { var divId = 'Comments_Container'; if(this.numCommentsWidgets){ divId += this.numCommentsWidgets; } else { this.numCommentsWidgets = 0; } document.write("
"); this.numCommentsWidgets++; var oldDocOnLoad = window.onload; function loadComments() { if (oldDocOnLoad != null) { oldDocOnLoad(); } gSiteLife.GetComments(parentKeyType, parentKey, parentUrl, parentTitle, 0, pageSize, sort, showTabs, tab, hideView, hideInput, redirectToUrl, refreshPage, divId); } window.onload = loadComments; return false; } SiteLifeProxy.prototype.GetComments = function(parentKeyType, parentKey, parentUrl, parentTitle, page, pageSize, sort, showTabs, tab, hideView, hideInput, redirectTo, refreshPage, divId) { parentKeyType = parentKeyType || "ExternalResource"; parentUrl = parentUrl || gSiteLife.__StripAnchorFromUrl(window.location.href); parentUrl = gSiteLife.EscapeValue(parentUrl); parentKey = parentKey || gSiteLife.__StripAnchorFromUrl(window.location.href); parentTitle = parentTitle || gSiteLife.EscapeValue(document.title); page = page || gSiteLife.GetParameter('plckCurrentPage') || 0; pageSize = pageSize || 10; sort = sort || "TimeStampAscending"; showTabs = showTabs || false; tab = tab || "MostRecent"; hideView = hideView || false; hideInput = hideInput || false; redirectTo =gSiteLife.EscapeValue(redirectTo) || ""; refreshPage = refreshPage || false; var url = this.__baseUrl + '/Comment/GetPage.rails?plckTargetKeyType='+ parentKeyType + '&plckTargetKey=' + escape(parentKey) + "&plckCurrentPage=" + page + "&plckItemsPerPage=" + pageSize + "&plckSort=" + sort + "&plckElementId=" + divId + "&plckTargetUrl=" + parentUrl + "&plckTargetTitle=" + parentTitle + "&plckHideView=" + hideView + "&plckHideInput=" + hideInput + "&plckRefreshPage=" + refreshPage + "&plckRedirectToUrl=" + redirectTo ; if (showTabs) { url = url + "&plckShowTabs=true&plckTab=" + tab; } this.__Send(url); return false; }; SiteLifeProxy.prototype.Blog = function(BlogId) { this.WriteDiv("blogDest", "Persona_Main"); var action = this.GetParameter("plckBlogPage"); if(action && action != "Blog" && (typeof this[action] == 'function')){ return this[action](BlogId); }else{ var AdParams = this.GetParameter('plckCurrentPage') ? 'plckCurrentPage=' + this.GetParameter('plckCurrentPage') : ""; return this.BlogSend('Blog', 'Blog', 'blogDest', 'blogScript', BlogId, AdParams); } } SiteLifeProxy.prototype.LoadBlogPage = function(PageName, BlogId) { var params = new Object(); params['plckBlogPage'] = PageName; params['plckBlogId'] = BlogId; for(ii=2; ii< this.LoadBlogPage.arguments.length; ii+=2) { params[this.LoadBlogPage.arguments[ii]] = this.LoadBlogPage.arguments[ii+1];} this.ReloadPage(params); return false; } SiteLifeProxy.prototype.BlogViewEdit = function(blogId) { return this.BlogSend(null, 'BlogViewEdit', null, null, blogId); } SiteLifeProxy.prototype.BlogPostCreate = function(blogId) { return this.BlogSend(null, 'BlogPostCreate', null, null, blogId, 'plckRedirectUrl=' + this.GetParameter("plckRedirectUrl")); } SiteLifeProxy.prototype.BlogPendingComments = function(blogId, currentPage) { if( !currentPage) currentPage = 0; return this.BlogSend(null, 'BlogPendingComments', null, null, blogId, 'plckCurrentPage='+currentPage); } SiteLifeProxy.prototype.BlogSettings = function(blogId) { return this.BlogSend(null, 'BlogSettings', null, null, blogId); } SiteLifeProxy.prototype.BlogEditPost = function(blogId, controller, div, script, postId, selection, daysBack) { return this.BlogSend(controller, 'BlogPostEdit', div, script, blogId, 'plckPostId=' + postId + '&plckSelection=' + selection + '&plckDaysBack=' + daysBack + '&plckRedirectUrl=' + this.EscapeValue(window.location.href)); } SiteLifeProxy.prototype.BlogRemovePost = function(blogId, controller, div, script, postId, selection, daysBack) { if (confirm("Are you sure you want to delete this item?") == true) { return this.BlogSend(controller, 'BlogRemovePost', div, script, blogId, 'plckPostId=' + postId + '&plckSelection=' + selection + '&plckDaysBack=' + daysBack ); } return false; } SiteLifeProxy.prototype.BlogViewPost = function(blogId, postId, selection, daysBack) { if(!postId ) { postId = gSiteLife.GetParameter('plckPostId'); } return this.BlogSend(null, 'BlogViewPost', null, null, blogId, 'plckPostId=' + postId + '&plckSelection=' + selection + '&plckDaysBack=' + daysBack ); } SiteLifeProxy.prototype.BlogViewMonth = function(blogId, monthId) { if(!monthId ) { monthId = gSiteLife.GetParameter('plckMonthId'); } var AdParams = 'plckMonthId=' + monthId; AdParams += this.GetParameter('plckCurrentPage') ? '&plckCurrentPage=' + this.GetParameter('plckCurrentPage') : ""; return this.BlogSend(null, 'BlogViewMonth', null, null, blogId, AdParams); } SiteLifeProxy.prototype.AddBlogWatchItem= function(blogId, controller, script, Url, WatchKey) { return this.BlogSend(controller, 'AddBlogWatch', 'plckBlogWatchDiv', script, blogId, 'plckWatchKey=' + WatchKey + '&plckWatchUrl=' + this.EscapeValue(Url)); } SiteLifeProxy.prototype.RemoveBlogWatchItem= function(blogId, controller, script, WatchKey) { return this.BlogSend(controller, 'RemoveBlogWatch', 'plckBlogWatchDiv', script, blogId, 'plckWatchKey=' + WatchKey); } SiteLifeProxy.prototype.BlogViewTag = function(blogId, tag) { if(!tag ) { tag = gSiteLife.GetParameter('plckTag'); } var AdParams = 'plckTag=' + tag; AdParams += this.GetParameter('plckCurrentPage') ? '&plckCurrentPage=' + this.GetParameter('plckCurrentPage') : ""; return this.BlogSend(null, 'BlogViewTag', null, null, blogId, AdParams ); } SiteLifeProxy.prototype.BlogRefreshViewEditList= function(blogId, controller, div, script, selection, daysBack) { return this.BlogSend(controller, 'BlogRefreshViewEditList', div, script, blogId, 'plckSelection=' + selection + '&plckDaysBack=' + daysBack ); } SiteLifeProxy.prototype.BlogSend = function(controller, apiName, destDiv, scriptName, blogId, addParams){ if(!controller) controller = this.GetParameter('plckController'); if(!destDiv) destDiv = this.GetParameter('plckElementId'); if(!scriptName) scriptName = this.GetParameter('plckScript'); var url = this.__baseUrl + '/' + controller + '/' + apiName + '?plckElementId=' + destDiv + '&plckBlogId=' + blogId + '&' + addParams; this.__Send(url, scriptName); return false; } SiteLifeProxy.prototype.Recommend = function(controller, itemId, recommendDiv) { var url = this.__baseUrl + '/' + controller + '/Recommend?plckElementId=' + recommendDiv + '&plckItemId=' +itemId; this.__Send(url); return false; } SiteLifeProxy.prototype.BlogSelectPendingComments = function(formId, checked) { var form = document.getElementById(formId); for (i=0; i"); } function submitRequest() { pullCounts(articleid); } function pullCounts(articlekey) { var articleKey = new ArticleKey(articlekey); var requestBatch = new RequestBatch(); requestBatch.AddToRequest(articleKey); requestBatch.BeginRequest(serverUrl, renderArticle); } function renderArticle(responseBatch) { if (responseBatch.Responses.length == 0) { var commentCount = document.getElementById('articleCommentCount' + articleid); var recommendCount = document.getElementById('articleRecommendCount' + articleid); // update page elements commentCount.style.visibility = 'hidden'; recommendCount.style.visibility = 'hidden'; commentCount.innerHTML = 0; recommendCount.innerHTML = 0; } else { // get article from response var article = responseBatch.Responses[0].Article; // get page elements var commentCount = document.getElementById('articleCommentCount' + article.ArticleKey.Key); var recommendCount = document.getElementById('articleRecommendCount' + article.ArticleKey.Key); // update page elements commentCount.innerHTML = article.Comments.NumberOfComments; recommendCount.innerHTML = article.Recommendations.NumberOfRecommendations; var isRecommended = article.Recommendations.CurrentUserHasRecommended; if(isRecommended == "True") { var recommendLink = document.getElementById('recommendlink' + article.ArticleKey.Key); recommendLink.innerHTML = "Recommended"; } commentCount.style.visibility = 'visible'; recommendCount.style.visibility = 'visible'; } } function recommendReview(key) { var requestBatch = new RequestBatch(); var articleKey = new ArticleKey(key); var recommendAction = new RecommendAction(articleKey); requestBatch.AddToRequest(recommendAction); requestBatch.BeginRequest(serverUrl, recommendationComplete); } function recommendationComplete(responseBatch) { if(responseBatch.Responses.length > 0) { submitRequest(); } else { //alert('did not exist'); updateArticle(); } } function updateArticle() { // get form elements and page info var articleKey = new ArticleKey(articleid); var pageUrl = document.location.href; var section = new Section(sectionTitle); var categories = new Array(); // create and send request var requestBatch = new RequestBatch(); var updateAction = new UpdateArticleAction(articleKey, pageUrl, pageTitle, section); requestBatch.AddToRequest(updateAction); requestBatch.BeginRequest(serverUrl, articleUpdated); } function articleUpdated(responseBatch) { if (responseBatch.Messages[0].Message == 'ok') { submitRequest(); //recommendReview(articleid); } } function recommendReviewAbox(key) { var requestBatch = new RequestBatch(); var articleKey = new ArticleKey(key); var recommendAction = new RecommendAction(articleKey); requestBatch.AddToRequest(recommendAction); requestBatch.BeginRequest(serverUrl, recommendationCompleteAbox); } function recommendationCompleteAbox(responseBatch) { SubmitListRequest(); } function recommendReviewList(key) { var requestBatch = new RequestBatch(); var articleKey = new ArticleKey(key); var recommendAction = new RecommendAction(articleKey); requestBatch.AddToRequest(recommendAction); requestBatch.BeginRequest(serverUrl, recommendationCompleteList); } function recommendationCompleteList(responseBatch) { getRecentActivity(); } function getRecentActivity() { var sections = new Array(new Section("All")); var categories = new Array(new Category("All")); var contributors = new Array(new UserTier("All")); var activity = new Activity("Commented"); var age = 2; var numItemsToGet = 5; if(cacheMostCommentedRecommended) { renderRecentContent(cacheMostCommentedRecommended.ResponseBatch, 5); } else { var requestBatch = new RequestBatch(); var discoveryAction = new DiscoverArticlesAction(sections, categories, contributors, activity, age, numItemsToGet); requestBatch.AddToRequest(discoveryAction); requestBatch.BeginRequest(serverUrl, renderRecentContent, 5); } } function renderRecentContent(responseBatch, numItemsToGet) { if (responseBatch.Responses.length >= 1) { var discoveryAction = responseBatch.Responses[0].DiscoverArticlesAction; if(!numItemsToGet) { numItemsToGet = discoveryAction.DiscoveredArticles.length; } else if(numItemsToGet > discoveryAction.DiscoveredArticles.length) { numItemsToGet = discoveryAction.DiscoveredArticles.length; } var recentList = document.getElementById('mostcommented_list'); var recentHTML = ""; recentList.innerHTML = recentHTML; } } function getArticleLink(article) { var html = "
  • " + unescape(article.PageTitle) + "
    "; html += "Comments " + article.Comments.NumberOfComments + " | "; if(article.Recommendations.CurrentUserHasRecommended == "True") { html += "Recommended" + article.Recommendations.NumberOfRecommendations + ""; } else { html += "Recommend " + article.Recommendations.NumberOfRecommendations + ""; } html += "
  • \n"; return html; } function getMostCommentedArticle() { var sections = new Array(new Section("All")); var categories = new Array(new Category("All")); var contributors = new Array(new UserTier("All")); var activity = new Activity("Commented"); var age = 2; var numItemsToGet = 5; var requestBatch = new RequestBatch(); var discoveryAction = new DiscoverArticlesAction(sections, categories, contributors, activity, age, numItemsToGet); requestBatch.AddToRequest(discoveryAction); requestBatch.BeginRequest(serverUrl, renderMostCommentedArticle); } function renderMostCommentedArticle(responseBatch) { if (responseBatch.Responses.length == 1) { var discoveryAction = responseBatch.Responses[0].DiscoverArticlesAction; var recentList = document.getElementById('mostcommented_list_article'); if(recentList) { var recentHTML = ""; for (var i = 0; i < discoveryAction.DiscoveredArticles.length; i++) { recentHTML += getArticleLinkArticle(discoveryAction.DiscoveredArticles[i]); } recentList.innerHTML = ""; } } } function getArticleLinkArticle(article) { var html = "
  • " + unescape(article.PageTitle) + ""; html += "
  • \n"; return html; } function getMostRecommendedArticle() { var sections = new Array(new Section("All")); var categories = new Array(new Category("All")); var contributors = new Array(new UserTier("All")); var activity = new Activity("Recommended"); var age = 2; var numItemsToGet = 5; var requestBatch = new RequestBatch(); var discoveryAction = new DiscoverArticlesAction(sections, categories, contributors, activity, age, numItemsToGet); requestBatch.AddToRequest(discoveryAction); requestBatch.BeginRequest(serverUrl, renderMostRecommendedArticle); } function renderMostRecommendedArticle(responseBatch) { if (responseBatch.Responses.length == 1) { var discoveryAction = responseBatch.Responses[0].DiscoverArticlesAction; var recentList = document.getElementById('mostrecommended_list_article'); var recentHTML = ""; for (var i = 0; i < discoveryAction.DiscoveredArticles.length; i++) { recentHTML += getArticleLinkArticle(discoveryAction.DiscoveredArticles[i]); } recentList.innerHTML = ""; } } var aboxMostCommented = new Array(); var aboxMostRecommended = new Array(); function getMostCommentedRecommendedArticleList(numItemsToGet) { var sections = new Array(new Section("All")); var categories = new Array(new Category("All")); var contributors = new Array(new UserTier("All")); var commentactivity = new Activity("Commented"); var recommendactivity = new Activity("Recommended"); var age = 2; if(!numItemsToGet) { numItemsToGet = 3; } if(cacheMostCommentedRecommended) { renderMostCommentedArticle(cacheMostCommentedRecommended.ResponseBatch, numItemsToGet); } else { var requestBatch = new RequestBatch(); var commentdiscoveryAction = new DiscoverArticlesAction(sections, categories, contributors, commentactivity, age, numItemsToGet); var recommendeddiscoveryAction = new DiscoverArticlesAction(sections, categories, contributors, recommendactivity, age, numItemsToGet); requestBatch.AddToRequest(commentdiscoveryAction); requestBatch.AddToRequest(recommendeddiscoveryAction); requestBatch.BeginRequest(serverUrl, renderMostCommentedArticle); } } function getMostCommentedRecommendedArticleList2(numItemsToGet) { var sections = new Array(new Section("All")); var categories = new Array(new Category("All")); var contributors = new Array(new UserTier("All")); var commentactivity = new Activity("Commented"); var recommendactivity = new Activity("Recommended"); var age = 2; if(!numItemsToGet) { numItemsToGet = 3; } var requestBatch = new RequestBatch(); var commentdiscoveryAction = new DiscoverArticlesAction(sections, categories, contributors, commentactivity, age, numItemsToGet); var recommendeddiscoveryAction = new DiscoverArticlesAction(sections, categories, contributors, recommendactivity, age, numItemsToGet); requestBatch.AddToRequest(commentdiscoveryAction); requestBatch.AddToRequest(recommendeddiscoveryAction); requestBatch.BeginRequest(serverUrl, renderMostCommentedArticle); } function renderMostCommentedArticle(responseBatch, numItemsToGet) { if (responseBatch.Responses.length >= 1) { var discoveryAction = responseBatch.Responses[0].DiscoverArticlesAction; if(!numItemsToGet) { numItemsToGet = 5; } if(numItemsToGet > discoveryAction.DiscoveredArticles.length) { numItemsToGet = discoveryAction.DiscoveredArticles.length; } if(aboxMostCommented.length >= 1) { for(var i = 0; i < aboxMostCommented.length; i++) { var recentList = document.getElementById(aboxMostCommented[i]); var recentHTML = ""; for (var j = 0; j < numItemsToGet; j++) { recentHTML += getArticleLinkArticle(discoveryAction.DiscoveredArticles[j]); } recentList.innerHTML = ""; } } else { var recentList = document.getElementById('mostcommented_list_article'); var recentHTML = ""; for (var i = 0; i < numItemsToGet; i++) { recentHTML += getArticleLinkArticle(discoveryAction.DiscoveredArticles[i]); } try { recentList.innerHTML = ""; }catch(err){} } } if (responseBatch.Responses.length >= 2) { var discoveryAction = responseBatch.Responses[1].DiscoverArticlesAction; if(!numItemsToGet) { numItemsToGet = 5; } if(numItemsToGet > discoveryAction.DiscoveredArticles.length) { numItemsToGet = discoveryAction.DiscoveredArticles.length; } if(aboxMostRecommended.length >= 1) { for(var i = 0; i < aboxMostRecommended.length; i++) { var recentList = document.getElementById(aboxMostRecommended[i]); var recentHTML = ""; for (var j = 0; j < numItemsToGet; j++) { recentHTML += getArticleLinkArticle(discoveryAction.DiscoveredArticles[j]); } recentList.innerHTML = ""; } } else { var recentList = document.getElementById('mostrecommended_list_article'); var recentHTML = ""; for (var i = 0; i < numItemsToGet; i++) { recentHTML += getArticleLinkArticle(discoveryAction.DiscoveredArticles[i]); } try{ recentList.innerHTML = ""; }catch(err){} } } } function isLoggedIn() { var ocCookies = document.cookie.split( ';' ); var tempCookie = ""; for(i=0; i < ocCookies.length; i++) { tempCookie = ocCookies[i].split('='); cookie_name = tempCookie[0].replace(/^\s+|\s+$/g, ''); if(cookie_name == "at") { return true; } } return false; } function slLogout() { var cookie_date = new Date(2000, 01, 01); var ocCookies = document.cookie.split( ';' ); var tempCookie = ""; var domainName=window.document.domain; //alert(domainName); //var nameparts = domainName.split( '.' ); //domainName=nameparts[1]+"."+nameparts[2]; //alert(domainName); for(i=0; i < ocCookies.length; i++) { tempCookie = ocCookies[i].split('='); cookie_name = tempCookie[0].replace(/^\s+|\s+$/g, ''); if(cookie_name == "at") { document.cookie = "at=; expires=" + cookie_date.toGMTString() + "; path=/; domain=."+domainName+";"; location.reload(true); } } } function changeWidgetLinks() { var domainName=window.document.domain var login_link = "http://www." + domainName + "/share/users/login/"; var reg_link = "http://www." + domainName + "/share/users/register/"; var commentsFrame = document.getElementById('commentsiframe'); var login_text = "You must be logged in to contribute. Login | Register"; if(commentsFrame) { var sl_login_text = commentsFrame.contentWindow.document.getElementById('SiteLife_Login'); if(sl_login_text) { sl_login_text.innerHTML = login_text; } } var messagesFrame = document.getElementById('messagesiframe'); if(messagesFrame) { var sl_login_text = messagesFrame.contentWindow.document.getElementById('Messages_NewMessageHead'); if(sl_login_text) { sl_login_text.innerHTML = login_text; } } var personaFrame = document.getElementById('personaprofileiframe'); if(personaFrame) { //personaFrame.style.width = "600px"; var editLink = personaFrame.contentWindow.document.getElementById('ProfileEdit_SectionDescription_Link'); editLink.style.display = "none"; } } // BZ:11687 function LoginPage() { var domainName=window.document.domain var login_link = "http://www." + domainName + "/share/users/login/"; window.location.href = login_link; } // BZ:11687 function RegPage() { var domainName=window.document.domain var reg_link = "http://www." + domainName + "/share/users/register/"; window.location.href = reg_link; } // BZ:11687 function changeForumLinks() { if(!isLoggedIn()) { var login_btn = document.getElementById('CreateDiscussion1'); var login_btn2 = document.getElementById('CreateDiscussion2'); var reg_btn = document.getElementById('A1'); var add_post_btn = document.getElementById('ForumDiscussionAddPost'); if(login_btn) { login_btn.href = "javascript:scroll(0,0);LoginPage();"; } if(login_btn2) { login_btn2.href = "javascript:scroll(0,0);LoginPage();"; } if(reg_btn) { reg_btn.href = "javascript:scroll(0,0);RegPage();"; reg_att = reg_btn.attributes; for(i=0;i"; var user_profile_link = "" + user_avatar + ""; if (profile_link) profile_link.innerHTML = user_profile_link; var status_html = "Welcome, " + user.DisplayName + "
    "; status_html += "My Profile | Logout
    "; var message_html = user.NumberOfMessages + " messages"; if (status_links) status_links.innerHTML = status_html; if (user_messages) user_messages.innerHTML = message_html; if (avatar) avatar.src = user.AvatarPhotoUrl; if (you_image) you_image.src = user.AvatarPhotoUrl; } } /** * This variable is now declared within the HEAD element. --Gat * var aboxArticles = new Array(); */ function SubmitListRequest() { var requestBatch = new RequestBatch(); for(var i=0;i 0) || !showRecommendedOnly) { if((commentPage.Comments[i].Author.IsBlocked == "False" && commentPage.Comments[i].AbuseReportCount < 4) || (commentPage.Comments[i].Author.IsBlocked == "True" && commentPage.Comments[i].Author.UserKey.Key == uuid)) { commentBlockHtml += getCommentHtml(commentPage.Comments[i]); } } } commentBlockHtml += "
    "; var numPages = Math.ceil(total_comments / 10); if(showRecommendedOnly) showRecommendedOnly = 1; else showRecommendedOnly = 0; if(numPages > 1 && oncommentsPage != 1) { commentBlockHtml += ' <<First |'; commentBlockHtml += ' <Prev |'; } for(var j=1; j <= numPages; j++) { if(j == oncommentsPage) { commentBlockHtml += " " + j + " "; } else { commentBlockHtml += ' ' + j + ''; } } if(numPages > 1 && oncommentsPage != numPages) { commentBlockHtml += ' | Next> |'; commentBlockHtml += ' Last>>'; } commentBlockHtml += "
    "; commentBlock.innerHTML = commentBlockHtml; } } /*-------------------------------------------------------------------------------------------------------------*/ function getCommentHtml(comment) { var html = ""; html += ''; html += ''; html += ''; html += ''; html += '
    ' + comment.CommentBody + '
    '; html += '
    ' + comment.PostedAtTime + '
    '; html += ''; html += '
    '; if(comment.CurrentUserHasRecommended == "True") { html += '
    '; html += '
    '; html += 'Recommended (' + comment.NumberOfRecommendations + ')
    '; } else { html += '
    '; html += ''; } html += '
    '; if(comment.CurrentUserHasReportedAbuse == "True") { html += '
    '; html += 'Reported
    '; } else { html += '
    '; html += 'Report Abuse
    '; } html += '
    '; return html; } function getMostRecentPhotos(numPhotos) { if(!numPhotos) { numPhotos = 5; } var recentPhotos = document.getElementById('recent_list_photos'); if(cacheMostRecentPhotos) { var photoHtml = '
    '; photoHtml += ''; photoHtml += createPhotoHtml(cacheMostRecentPhotos.ResponseBatch, numPhotos); photoHtml += '
    '; recentPhotos.innerHTML = photoHtml; } } function createPhotoHtml(ResponseBatch, numPhotos) { discoveredContent = ResponseBatch.Responses[0].DiscoverContentAction.DiscoveredContent; if(numPhotos > discoveredContent.length) { numPhotos = discoveredContent.length; } var html = ""; for(var i = 0; i < numPhotos; i++) { if(discoveredContent[i].IsPendingApproval == "False" && discoveredContent[i].Author.IsBlocked == "False") { html += ''; html += ''; html += ''; html += ''; html += ''; //html += '
    '; //html += 'In: '; html += ''; } else { numPhotos++; } } return html; } function getBillboardLinks() { var photo1link = document.getElementById('photo1link'); var photo2link = document.getElementById('photo2link'); var photo3link = document.getElementById('photo3link'); var photo1img = document.getElementById('photo1img'); var photo2img = document.getElementById('photo2img'); var photo3img = document.getElementById('photo3img'); if(cacheMostRecentPhotos) { discoveredContent = cacheMostRecentPhotos.ResponseBatch.Responses[0].DiscoverContentAction.DiscoveredContent; var numSet = 0; for(var i = 0; i < discoveredContent.length; i++) { if(discoveredContent[i].IsPendingApproval == "False" && discoveredContent[i].Author.IsBlocked == "False" && numSet != 3) { if(numSet == 0) { photo1link.href = discoveredContent[0].PhotoUrl; photo1img.src = discoveredContent[0].Image.Small; numSet++; } else if(numSet == 1) { photo2link.href = discoveredContent[1].PhotoUrl; photo2img.src = discoveredContent[1].Image.Small; numSet++; } else if(numSet == 2) { photo3link.href = discoveredContent[2].PhotoUrl; photo3img.src = discoveredContent[2].Image.Small; numSet++; } } } } else { var searchSections = new Array(); searchSections[0] = new Section("All"); var searchCategories = new Array(); searchCategories[0] = new Category("All"); var activityDisco = new Activity("Recent"); var contentType = new ContentType("PublicPhoto"); var limitToContributorsDisco = new Array(); limitToContributorsDisco[1] = new UserTier("All"); var age = 15; var maximumNumberOfDiscoveries = 10; var requestBatch = new RequestBatch(); var discoveryAction = new DiscoverContentAction( searchSections, searchCategories, limitToContributorsDisco, activityDisco, contentType, age, maximumNumberOfDiscoveries); requestBatch.AddToRequest(discoveryAction); requestBatch.BeginRequest(serverUrl, renderBillboardLinks); } } function renderBillboardLinks(responseBatch) { if (responseBatch.Responses.length >= 1) { var photo1link = document.getElementById('photo1link'); var photo2link = document.getElementById('photo2link'); var photo3link = document.getElementById('photo3link'); var photo1img = document.getElementById('photo1img'); var photo2img = document.getElementById('photo2img'); var photo3img = document.getElementById('photo3img'); var discoveredContent = responseBatch.Responses[0].DiscoverContentAction.DiscoveredContent; var numSet = 0; for(var i = 0; i < discoveredContent.length; i++) { if(discoveredContent[i].IsPendingApproval == "False" && discoveredContent[i].Author.IsBlocked == "False" && numSet != 3) { if(numSet == 0) { photo1link.href = discoveredContent[0].PhotoUrl; photo1img.src = discoveredContent[0].Image.Small; numSet++; } else if(numSet == 1) { photo2link.href = discoveredContent[1].PhotoUrl; photo2img.src = discoveredContent[1].Image.Small; numSet++; } else if(numSet == 2) { photo3link.href = discoveredContent[2].PhotoUrl; photo3img.src = discoveredContent[2].Image.Small; numSet++; } } } } } function getMostRecommendedPhotos(numPhotos) { if(!numPhotos) { numPhotos = 5; } var recommendedPhotos = document.getElementById('mostrecommended_list_photos'); if(cacheMostRecommendedPhotos) { var photoHtml = '
    '; photoHtml += ''; photoHtml += createPhotoHtml(cacheMostRecommendedPhotos.ResponseBatch, numPhotos); photoHtml += '
    '; recommendedPhotos.innerHTML = photoHtml; } }