Here’s the situation I’m in:
- a SharePoint deployment has a Slideshow Webpart that I want to show the content from elsehwere in the same page
- I can inject arbitrary javascript into the page, but the webpart is outside my control
So here’s the totally wrong way to be alerted when the images change:
The ShowPic function (in /_layouts/1033/imglib.js) is called to advance the slideshow to the next frame.
I didn’t do too much investigating into the object that it’s passing around, but it’s clear that I want a.pictureArray[a.index] as my source.
function ShowPic(a){
ULSjYp:; //a function, not relevant
var b=a.index,c=0;
if(a.index!=a.pictureArray.length-1)
c=a.index+1;
var d=a.pictureArray.length-1;
if(a.index!=0)
d=a.index-1;
a.image.src=a.pictureArray[b]; //Here's the bit I need
a.image.height=a.heightArray[b];
a.image.width=a.widthArray[b];
a.image.alt=a.descriptionArray[b];
a.link.href=a.linkArray[b];
if(a.title!=null)
a.title.innerHTML=a.titleArray[b];
if(a.description!=null)
a.description.innerHTML=a.descriptionArray[b];
a.imageNext.src=a.pictureArray[c];
a.imagePrev.src=a.pictureArray[d]
}
So all I did was rename that function, and make my own ShowPic() function that would alter my image and then go about as if nothing had happened:
function gets_run_on_load() {
origShowPic=ShowPic;
ShowPic = function(a) {
//I'm only generating thumbnails, but you could do more
document.getElementById("img_to_show_the_slideshow_image").src=a.pictureArray[a.index];
origShowPic(a);
}
}
addLoadEvent(gets_run_on_load) // Whatever your function is to register functions on load
(I don’t have jQuery here so I’m using http://stackoverflow.com/questions/9434)
And there you go, image intercepted.