smughack: Bulk Zoom Thumbnail
devbobo
Registered Users, Retired Mod Posts: 4,339 SmugMug Employee
ok...I saw this request and thought I would give it a go
Add present this code has only been enabled for the "traditional" style. Note, at present the code, has a hard-coded thumbnail resolution and location (to be enhanced later)
Add this code to your javascript block...
<divtags.length ;="" i=""><divtags.length ;="" i=""><divtags.length ;="" i="">
</divtags.length><divtags.length ;="" i="">[php]
var thumbnailArray = new Array();
var thumbnailCount;
var thumbnailItem;
addEvent(window, "load", addBulkThumbnail);
function addBulkThumbnail()
{
if ((IsClass("loggedIn")) && (IsClass("traditional")))
{
divTag = document.getElementById("photoTools");
objButton = document.createElement("input");
divTag.appendChild(objButton);
objButton.setAttribute('value', 'Bulk Zoom Thumbnail');
try
{
objButton.type = "button";
}
catch(e)
{
objButton.tageName = "button";
objButton.setAttribute('value', 'Bulk Zoom Thumbnail');
}
objButton.className = "buttons";
try
{
objButton.attachEvent('onclick', processThumbnails);
}
catch(e)
{
objButton.addEventListener('click', processThumbnails, false);
}
}
}
function processThumbnails()
{
if (!confirm("Are you sure you want to bulk process this thumbnails ?"))
return;
if ((IsClass("loggedIn")) && (IsClass("traditional")))
{
re = /.smugmug.com\/gallery\/[0-9]+\/[0-9]+\/([0-9]+)/
divTag = document.getElementById("photos");
if (divTag)
{
divTags = divTag.getElementsByTagName("div");
for (i=0; i
{
if (divTags.className == "photo")
{
re.exec(divTags.innerHTML);
thumbnailArray[thumbnailArray.length] = RegExp.$1;
}
}
thumbnailCount = thumbnailArray.length;
thumbnailItem = 0;
zoomThumbnails();
}
}
}
function zoomThumbnails()
{
var thumbnailId = thumbnailArray.pop();
if (thumbnailId)
{
thumbnailItem++;
document.getElementById("ajaxWorking").innerHTML = "Processing thumbnail " + thumbnailItem + " of " + thumbnailCount + "...";
toggleDIV('ajaxWorking','','block');
postArray = new Array();
postArray = 'newthumb';
postArray = thumbnailId;
postArray = "doit";
postArray = "2907";
postArray = "2907";
postArray = "0";
postArray = "0";
ajax_query(zoomThumbnails, webServer+'/photos/tools.mg', postArray, true, true);
}
else
window.location = window.location;
}
function IsClass(sClass)
{
sClassName = document.body.className;
re = new RegExp(sClass + "( |$)")
if (!sClassName)
return false;
return re.test(sClassName);
}
[/php]
<divtags.length ;="" i="">Enjoy
David</divtags.length></divtags.length></divtags.length></divtags.length>
Add present this code has only been enabled for the "traditional" style. Note, at present the code, has a hard-coded thumbnail resolution and location (to be enhanced later)
Add this code to your javascript block...
<divtags.length ;="" i=""><divtags.length ;="" i=""><divtags.length ;="" i="">
</divtags.length><divtags.length ;="" i="">[php]
var thumbnailArray = new Array();
var thumbnailCount;
var thumbnailItem;
addEvent(window, "load", addBulkThumbnail);
function addBulkThumbnail()
{
if ((IsClass("loggedIn")) && (IsClass("traditional")))
{
divTag = document.getElementById("photoTools");
objButton = document.createElement("input");
divTag.appendChild(objButton);
objButton.setAttribute('value', 'Bulk Zoom Thumbnail');
try
{
objButton.type = "button";
}
catch(e)
{
objButton.tageName = "button";
objButton.setAttribute('value', 'Bulk Zoom Thumbnail');
}
objButton.className = "buttons";
try
{
objButton.attachEvent('onclick', processThumbnails);
}
catch(e)
{
objButton.addEventListener('click', processThumbnails, false);
}
}
}
function processThumbnails()
{
if (!confirm("Are you sure you want to bulk process this thumbnails ?"))
return;
if ((IsClass("loggedIn")) && (IsClass("traditional")))
{
re = /.smugmug.com\/gallery\/[0-9]+\/[0-9]+\/([0-9]+)/
divTag = document.getElementById("photos");
if (divTag)
{
divTags = divTag.getElementsByTagName("div");
for (i=0; i
{
if (divTags.className == "photo")
{
re.exec(divTags.innerHTML);
thumbnailArray[thumbnailArray.length] = RegExp.$1;
}
}
thumbnailCount = thumbnailArray.length;
thumbnailItem = 0;
zoomThumbnails();
}
}
}
function zoomThumbnails()
{
var thumbnailId = thumbnailArray.pop();
if (thumbnailId)
{
thumbnailItem++;
document.getElementById("ajaxWorking").innerHTML = "Processing thumbnail " + thumbnailItem + " of " + thumbnailCount + "...";
toggleDIV('ajaxWorking','','block');
postArray = new Array();
postArray = 'newthumb';
postArray = thumbnailId;
postArray = "doit";
postArray = "2907";
postArray = "2907";
postArray = "0";
postArray = "0";
ajax_query(zoomThumbnails, webServer+'/photos/tools.mg', postArray, true, true);
}
else
window.location = window.location;
}
function IsClass(sClass)
{
sClassName = document.body.className;
re = new RegExp(sClass + "( |$)")
if (!sClassName)
return false;
return re.test(sClassName);
}
[/php]
<divtags.length ;="" i="">Enjoy
David</divtags.length></divtags.length></divtags.length></divtags.length>
0
Comments
And, how do I execute it?
Portfolio • Workshops • Facebook • Twitter
obviously u need the body tag around the onload event, but vBulletin keeps stripping it out.
Also found a bug in mozilla, trying to fix it.
SmugMug API Developer
My Photos
David: NOTHING is obvious to me, I am a "hack" whilst you are a h4ck3r
Portfolio • Workshops • Facebook • Twitter
Andy,
the code has been updated, but now you need to remove the onload event handler.
Let me know how you get on, it should a "Bulk Zoom Thumbnail" button next to the "Gallery Tools" on "Traditional" style.
Cheers,
David
SmugMug API Developer
My Photos
sorry David - tried on IE and also FF on Mac - nothin....
http://zions.smugmug.com/gallery/956882
Portfolio • Workshops • Facebook • Twitter
It's b0rking the thread.
Portfolio • Workshops • Facebook • Twitter
Keep at it I'll be back in the morning, my time..
Portfolio • Workshops • Facebook • Twitter