/* 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 += "
| ';
if(comment.CurrentUserHasRecommended == "True") {
html += ' ';
html += ' ';
}
else {
html += '';
html += 'Recommended (' + comment.NumberOfRecommendations + ') ';
html += 'Recommend(' + comment.NumberOfRecommendations + ') ';
}
html += ' | ';
if(comment.CurrentUserHasReportedAbuse == "True") {
html += ' ';
html += 'Reported ';
html += 'Report Abuse ';
}
html += ' |