It looks like you're new here. If you want to get involved, click one of these buttons!
:: Image Utilities [script]
function getBackgroundImage (element) {
var url = $(element).css('background-image');
if (url == "" || url == "none") return url;
url = /^url\((['"]?)(.*)\1\)$/.exec(url);
url = url[2];//continue with only the filepath portion
var filename = url.substring(url.lastIndexOf('/', url.lastIndexOf('/') - 1) + 1);
filename = filename ? filename : "";
return filename;
}
:: PassageDone [nobr]
/% SugarCube: Runs once the passage has completely rendered. %/
<<script>>
var index = state.active.variables.index;
var passage = state.active.title;
var sectionName = state.active.variables.section;
if (!index.hasOwnProperty(passage)) { //if the passage isn't in the index, add it.
index[passage] = {};
index[passage].section = sectionName;
}
//update background image if necessary
var currentImage = getBackgroundImage(".img-anchor");
...
<</script>>
What I get is an error message each time the code in the PassageDone special passage fires, letting me know that the function getBackgroundImage() is undefined. Yet the script passage in which it is defined does fire at startup as it should, so I'm not sure why the function wouldn't be available.
Comments
window.getBackgroundImage
) anywhere else in your code.Anyway, that fixed it--thanks!