string into the url
sel.onchange = function() {
location.href = urlInsertGetStmt(
this.trueHref, //take the old destination href
escape("subset_size:"+this.ident), //insert our subset size parameter
this.options[this.selectedIndex].value //specify its value
);
}
}
}
//init the photo table
//set its size to match the page size
//and add in a resize event listener
//to auto resize all the thumbnails with the browser
var photodiv = null;
var phototable = null;
var photoThumbWidth = 0;
//the parameters of this code must match that found in the beginning of $screen == "photogallery" in the menu.php page
//they are:
// photoGalleryDivWidth = screen width - 40
// photoGalleryMarginCoeff = 0.25
// thumbsPerRow = 5
//derived values are:
// photoGalleryThumbWidth = floor(photoGalleryDivWidth / (thumbsPerRow + (thumbsPerRow-1) * photoGalleryMarginCoeff));
//For development's sake, later, if you wanted, you could pass these values at GET parameters to this PHP file
//and have them generated from the original PHP variables in the menu.php file
function photogallery_resize() {
//the get_screen_width() reference will only work if screenres.js.php has been included before this file
var photoGalleryDivWidth = get_screen_width();
photoGalleryDivWidth -= 40;
var photoGalleryMarginCoeff = 0.25;
var thumbsPerRow = 5;
var photoGalleryThumbWidth = parseInt(photoGalleryDivWidth / (thumbsPerRow + (thumbsPerRow-1) * photoGalleryMarginCoeff));
//set the div and the table
photodiv.style.width = photoGalleryDivWidth + "px";
phototable.style.width = photoGalleryDivWidth + "px";
//now set the width of all the | s in the table
var ar = searchDomTree(phototable, "nodeName", "TD");
for (var i = 0; i < ar.length; i++) {
var td = ar[i];
td.style.width = photoGalleryThumbWidth + "px";
td.style.height = photoGalleryThumbWidth + "px";
//inside each | there should be an element . . .
//it references resize.php. the width and height GET parametesr are to be modified to be 'photoGalleryThumbWidth'
//everything else is to remain the same
var ar2 = searchDomTree(td, "nodeName", "IMG");
for (var j = 0; j < ar2.length; j++) {
var img = ar2[j];
//quickly rescale the image before the truly-resized image is downloaded
//this code must somewhat match the size calculation code in resize.php
//because resize.php is going to be generating the image to be placed in our tag
var src_x = img.offsetWidth;
var src_y = img.offsetHeight;
//grab the newly specified width & height
var width,height;
//if we are requested to constrain our dimensions . . .
//take the largest scale-down ratio and use that
if (src_x > src_y) {
width = photoGalleryThumbWidth;
height = photoGalleryThumbWidth * src_y / src_x;
} else {
width = photoGalleryThumbWidth * src_x / src_y;
height = photoGalleryThumbWidth;
}
img.width = ""+width;
img.height = ""+height;
//now download the image
//only do this if we're growing in size. otherwise there's no need to grab a smaller version from the server - the client can handle that as it is.
//best yet - why dont we keep the img.src pointed at the largest-yet used site (none of this size-up/size-down downloading . . .)
//however this feature is not necessarily working.
//if (photoGalleryThumbWidth > photoThumbWidth)
{
//alert("sizing up to " + photoGalleryThumbWidth);
var src = img.src;
src = urlInsertGetStmt(src, "width", ""+photoGalleryThumbWidth);
src = urlInsertGetStmt(src, "height", ""+photoGalleryThumbWidth);
//refresh the image according to its new size
img.src = src;
//implement a javascript callback such that, when the image loads, it resets the image width & height fields . . .
img.onload = function() {
//how do we get rid of these keys & values alltogether?
//this.removeProperty("width");
//this.removeProperty("height");
}
photoThumbWidth = photoGalleryThumbWidth;
}
}
}
}
function init_crypto_photogallery() {
photodiv = document.getElementById("photodiv");
if (!photodiv) return;
phototable = document.getElementById("phototable");
if (!phototable) return;
//exract the width= parameter here, so that we only re-download images when they are growing in size
var ar = searchDomTree(phototable, "nodeName", "TD");
photoThumbWidth = parseInt(ar[0].style.width);
//only add the resize listener if we found the "photodiv", which wraps the whole photo gallery
addListener(window, "resize", photogallery_resize);
}
//init all our controls here
function init_crypto() {
//add in "[clear]" buttons to the maintable's selects
var table = document.getElementById("maintable");
if (table) init_crypto_maintable(table);
//add in the "go back" button to the main controls
init_crypto_goback();
//add in the auto-refresh upon changing the subset size
init_crypto_subset_ctrls();
//center the sitetable and make its columns sortable
var table = document.getElementById("sitetable");
if (table) init_crypto_sitetable(table);
//add in a script to auto resize the photo gallery as the browser does so as well
init_crypto_photogallery();
}
//attach the listener for our init method
addListener(window, "load", init_crypto);
|