First page Back Continue Last page Image

function showPictures() {

var tempText = document.createElement("div");

var theText;

if (xhr.readyState == 4) {

if (xhr.status == 200) {

var allImages = xhr.responseXML.getElementsByTagName("content");

for (var i=0; i<allImages.length; i++) {

// Convert the data in each xml content block into a single string

tempText.innerHTML = getPixVal(allImages[i]);

// Modify the data in the 2nd p block of the content block

theText = tempText.getElementsByTagName("p")[1].innerHTML;

// Replace all occurrences of 240 with 75

theText = theText.replace(/240/g,"75");

// Replace all occurrences of 180 with 75

theText = theText.replace(/180/g,"75");

// Replace all occurrences of _m with _s

theText = theText.replace(/_m/g,"_s");

// Add each thumbnail to the pictureBar Div on the main document

document.getElementById("pictureBar").innerHTML += theText;

}

}

// If the XMLHttpRequest status was not ok output an error message

else {

alert("There was a problem with the request " + xhr.status);

}

}

// Execute the if statement from the last example using the abbreviated version from chapter 2 page 34

function getPixVal(inVal) {

return (inVal.textContent) ? inVal.textContent : inVal.text;

}

}

Item by Item Comment