|
|
|
Soooo Beginner Grinner
Join Date: Apr 2009
Location: Oakland, CA
Posts: 504
|
Customization code review - how bad is it?
I have discovered I shouldn't just copy in code without jotting down what it's for. Plus there's the problem that I don't know what I'm doing, so I've probably made a mess. Would someone mind surveying my code and tell me if I've done something amiss? I believe there are elements that don't work, as well, and I've left them there thinking I would get back to them. Sadly, I can't tell you which ones they are. I'm obviously learning the hard way. This is the code that I received by email. Thank you!
http://joinrats.smugmug.com/
PHP Code:
You recently requested a copy of your customization. Here are the values:
BACKGROUND COLOR: dark
PAGE TITLE: JoinRats - Socialize Pet Rats, Build Trust and Relationship
CSS: /* hides the word home */
#userHome {
display: none;
}
/* remove the 's */
.possess {
display: none;
}
#journal .journal_entry .right {
float: left;
margin-right: 0;
}
#smugmug_small #albumNav_bottom, #smugmug #albumNav_bottom {
display: none;
}
#breadcrumb .title,
.photoNav a.nav.next {
font-family: verdana !important;
font-weight: normal !important;
font-size: 14px !important;
}
#comments {font-size: 14pt;}
#caption,
.caption {font-size: 14pt !important;}
#albumDescription {font-size: 20px;}
#caption_bottom {font-size: 14pt !important;}
#menu {font-size: 20px !important;}
#small-caption,
.small-caption {font-size: 20pt !important;}
#message-box,
.message-box {font-size: 20pt !important;}
/* html only page for gallery XXXXXX */
/*.gallery_http://joinrats.smugmug.com/gallery/7817105_r5Gvj .nophotos { display: none; } */
/* START gallery 8004395_A7pkR#520478125_27XEV */
.gallery_8004395_A7pkR#520478125_27XEV #albumDescription {
margin-top: 40px; /* gap from navbar at top */
background: #ccc; /* background of description box */
padding: 20px 40px 40px 40px; /* top right bottom left */
} /* spacing inside box from edges */
.gallery_8004395_A7pkR#520478125_27XEV .myPhoto {
float: left; /* allows the text to flow to the right */
padding: 0 30px 10px 0; /* top right bottom left */
} /* spacing of text around photo */
.gallery_8004395_A7pkR#520478125_27XEV .myPhoto img {
border: 4px ridge #444; /* add border around photo */
}
.gallery_8004395_A7pkR#520478125_27XEV .myTitle {
font-family: Comic Sans MS, verdana;
font-size: 150%;
color: #444;
font-weight: bold;
text-align: center;
margin: 0 auto 30px auto; /* top right bottom left */
}
.gallery_8004395_A7pkR#520478125_27XEV .myText {
font-family: Comic Sans MS, verdana;
font-size: 100%;
color: #444;
font-weight: normal;
text-align: justify;
}
.gallery_8004395_A7pkR#520478125_27XEV .myEmail {color: #444;}
.gallery_8004395_A7pkR#520478125_27XEV .myEmail:hover {color: red;}
/* things you can hide on page */
.gallery_8004395_A7pkR#520478125_27XEV .nophotos h3, /* if no photos in gallery */
.gallery_8004395_A7pkR#520478125_27XEV #albumNav_top,
.gallery_8004395_A7pkR#520478125_27XEV #albumNav_bottom,
.notLoggedIn .gallery_8004395_A7pkR#520478125_27XEV .journal_entry, /* hides photos in gallery */
.notLoggedIn .gallery_8004395_A7pkR#520478125_27XEV #breadcrumb {display: none;}
/* END gallery 8004395_A7pkR#520478125_27XEV */
HEADER javascript: function updateSS() {
// look at the body tags classes, if it is the homepage then swap
bodyClass = document.getElementsByTagName("body")[0].className;
if (bodyClass.indexOf("slideshow") != -1) {
slideDuration = 3;
document.getElementById("duration").value = "3";
}
// Change Home Link (from Devbobo)
YE.onContentReady('toolbar', function () { this.innerHTML = this.innerHTML.replace(/href="http:\/\/www.smugmug.joinrats.com\/([?\w&;=]+)?"/, 'href="' + webServer + '"')});
BODY TAG: <body onload="updateSS();">
CUSTOM HEADER:
CUSTOM FOOTER: ******** type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</********
******** type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-8541296-1");
pageTracker._trackPageview();
} catch(err) {}</********
******** type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</********
******** type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-8541296-2");
pageTracker._trackPageview();
} catch(err) {}</********
FOOTER javascript: filmstripMove = 0;
showPhotoBar = false;
showImagePreview = false;
function delHover() {
oLst = YD.getElementsBy(function(el) {return (YD.hasClass(el,'imgBorder') || YD.hasClass(el,'imgBorderOn'))},'img');
for (i=0; i < oLst.length ; i++) {
if (oLst[i].title && oLst[i].title != '') oLst[i].title = '';
if (oLst[i].alt && oLst[i].alt != '') oLst[i].alt = '';
}
}
YE.onContentReady('bodyWrapper', function() {if (!YD.hasClass(document.body, 'smugmug_ajax')) delHover()});
onPhotoShow.subscribe(function(){YE.onAvailable('mainImage', delHover)});
function addCategoryTitleToBreadcrumb(description)
{
var breadCrumb = YD.get("breadcrumb");
if (breadCrumb)
{
var divTag = document.createElement("div");
divTag.className = "categoryDescription";
divTag.innerHTML = description;
breadCrumb.parentNode.insertBefore(divTag, breadCrumb.nextSibling);
}
}
function addCategoryTitleToThumbs(descriptionObject, boxObjectName)
{
var re = /\>([^\<]+)<\/a>/i; // pattern to find the category name between the <a> and </a> tags
var divTag = YD.get(boxObjectName);
if (divTag)
{
var divTags = YD.getElementsByClassName("albumTitle", "p", divTag);
for (var i = 0; i < divTags.length; i++)
{
var matches = re.exec(divTags[i].innerHTML); // get just the category name
// if we found a category name and the category name exists in our categoryDescription object, then add the description
if (matches && (matches.length > 1) && descriptionObject[matches[1]] != undefined)
{
var pTag = document.createElement("p");
pTag.className = "categoryDescription";
pTag.innerHTML = descriptionObject[matches[1]];
divTags[i].parentNode.insertBefore(pTag, divTags[i].nextSibling);
}
}
}
}
/* Category descriptions */
function addCategoryDescription()
{
var categoryDescription = {
// list "categoryname" : "category title",
// or "categoryname.subcategoryname" : "subcategory title",
// Examples:
// "Kenya" : "Our vacation to Kenya",
// "Kenya.Highlights" : "The highlights galleries from our vacation to Kenya",
"EARNING THE TRUST OF PET RATS" : "Helping pet rats trust",
"WORKING WITH BITING RATS" : "Rats who bite are terrified and need help",
"RATTIE ENRICHMENT" : "Playing with rats. Rats are intelligent and need their minds stimulated",
"RATTIE HEALTH" : "Techniques to handle sick rats",
"KARENBORGA" : "Karen's private gallery"
};
var re, matches, i; // various local variables
// now fix it so that it works automatically even if the category or sub-category name has spaces in it
// we replace those spaces with underscores (which is what the classname does) and add those to our object so we can match those too
for (i in categoryDescription)
{
var newName = i.replace(/ /g, "_");
categoryDescription[newName] = categoryDescription[i]; // add a property to the object that has only underscores in the name
}
// on the homepage, we want to check for category names and add a description if a match found
// on a category page, we want to check to see if the category that the page is needs a description under the breadcrumb
// and, we need to see if any of the sub-category items on the page need us to add a description under the name
// on a sub-category page, we want to check to see if the sub-category that the page is needs a description under the breadcrumb
if (YD.hasClass(document.body, "category"))
{
// fetch the category name
re = /category_(\S+)/i;
matches = re.exec(document.body.className);
if (matches && (matches.length > 1))
{
var categoryName = matches[1];
// now see if we have a subcategory too
if (YD.hasClass(document.body, "subcategory"))
{
re = /subcategory_(\S+)/i;
matches = re.exec(document.body.className);
if (matches && (matches.length > 1))
{
var subcatName = matches[1];
// category and subcategory so we are on a subcategory page showing a list of galleries in this subcategory
// we need to just add a subcategory title to this page if the category-subcategory matches
var fullName = categoryName + "." + subcatName;
if (categoryDescription[fullName])
{
addCategoryTitleToBreadcrumb(categoryDescription[fullName]);
}
}
}
// here we're on a category page
// we need to add a category description for the category page
// and potentially add subcategory descriptions to the subcategory names displayed on this page
else
{
if (categoryDescription[categoryName])
{
addCategoryTitleToBreadcrumb(categoryDescription[categoryName]);
}
// now we need to build a temporary subcategoryDescription object that has only the subcategory names in it that are in this category
var subcatDescriptions = {};
re = new RegExp("^" + categoryName + "\\.(.+)$", "i");
for (i in categoryDescription)
{
matches = re.exec(i);
if (matches && (matches.length > 1))
{
subcatDescriptions[matches[1]] = categoryDescription[i];
}
}
addCategoryTitleToThumbs(subcatDescriptions, "subcategoriesBox");
}
}
}
// then see if we're on the homepage
if (YD.hasClass(document.body, "homepage"))
{
addCategoryTitleToThumbs(categoryDescription, "categoriesBox");
}
}
YE.onDOMReady(addCategoryDescription);
|
|
|
|