In the JavaScript demo code below I am getting errors in the console anytime I call anything nested under this object BookmarkScreenshots.fullPageScreenshot
where it says (index):63 Uncaught TypeError: Cannot read property 'fullPageScreenshot' of undefined
Demo JSFiddle: https://jsfiddle.net/vr5j2tnm/
Demo Code:
var BookmarkScreenshots = {
test: function(){
console.log('BookmarkScreenshots.test() ran');
},
fullPageScreenshot: {
//BookmarkScreenshots.fullPageScreenshot.cache.
cache: {
body: document.body,
html: document.documentElement,
fullWidthOld: document.width,
fullHeightOld: document.height,
originalX: window.scrollX,
originalY: window.scrollY,
windowScrollX: BookmarkScreenshots.fullPageScreenshot.cache.originalX,
fullWidth: document.body.clientWidth,
fullHeight: Math.max(BookmarkScreenshots.fullPageScreenshot.cache.body.scrollHeight, BookmarkScreenshots.fullPageScreenshot.cache.body.offsetHeight,
BookmarkScreenshots.fullPageScreenshot.cache.html.clientHeight, BookmarkScreenshots.fullPageScreenshot.cache.html.scrollHeight, BookmarkScreenshots.fullPageScreenshot.cache.html.offsetHeight),
windowWidth: window.innerWidth,
windowHeight: window.innerHeight,
originalOverflowStyle: document.documentElement.style.overflow,
arrangements: [],
// pad the vertical scrolling to try to deal with
// sticky headers, 200 is an arbitrary size
scrollPad: 200,
yDelta: BookmarkScreenshots.fullPageScreenshot.cache.windowHeight - (BookmarkScreenshots.fullPageScreenshot.cache.windowHeight > BookmarkScreenshots.fullPageScreenshot.cache.scrollPad ? BookmarkScreenshots.fullPageScreenshot.cache.scrollPad : 0),
xDelta: BookmarkScreenshots.fullPageScreenshot.cache.windowWidth,
yPos: BookmarkScreenshots.fullPageScreenshot.cache.fullHeight - BookmarkScreenshots.fullPageScreenshot.cache.yDelta + 1,
xPos: '',
numArrangements: '',
cleanUpTimeout: '',
port: chrome.runtime.connect({name: 'page capture'}),
message: {
msg: 'capture',
totalWidth: BookmarkScreenshots.fullPageScreenshot.cache.fullWidth,
totalHeight: BookmarkScreenshots.fullPageScreenshot.cache.fullHeight
},
},
init: function(){
console.log('ran BookmarkScreenshots.fullPageScreenshot.init()');
},
}
}
(function() {
BookmarkScreenshots.test();
BookmarkScreenshots.fullPageScreenshot.init();
console.log('BookmarkScreenshots.fullPageScreenshot.cache.windowScrollX', BookmarkScreenshots.fullPageScreenshot.cache.windowScrollX);
})();