MediaWiki:BibleGet.js: Difference between revisions
no edit summary
Johnrdorazio (talk | contribs) No edit summary |
Johnrdorazio (talk | contribs) No edit summary |
||
Line 1: | Line 1: | ||
//avoid duplicate bibleQuote divs | //avoid duplicate bibleQuote divs | ||
let bibleQuoteCollection = []; | let bibleQuoteCollection = []; | ||
let domCheckInterval = | let domCheckInterval = []; | ||
let ajaxCount = 0; | let ajaxCount = 0; | ||
(function($,mw){ | (function($,mw){ | ||
Line 96: | Line 96: | ||
} | } | ||
}); //END for each | }); //END for each | ||
$(document).ajaxStop(function(){ | |||
console.log("ajaxStop has fired " + ++ajaxCount + " time(s)"); | |||
//just because ajax requests have finished doesn't mean the dom manipulation is done... | |||
//let's create a check for all elements before doing any further manipulation | |||
if(domCheckInterval.length === 0){ | |||
domCheckInterval[] = setInterval(onBGetDomElementsReady,100); | |||
} | |||
}); //END document ajaxStop | |||
} | } | ||
}); //END document ready | }); //END document ready | ||
})(jQuery,mw); | })(jQuery,mw); | ||
Line 123: | Line 126: | ||
if(checkDomElements() === true){ | if(checkDomElements() === true){ | ||
console.log('All expected dom elements are now accounted for!'); | console.log('All expected dom elements are now accounted for!'); | ||
clearInterval( | for(let interval of domCheckInterval){ | ||
clearInterval(interval); | |||
} | |||
doFurtherDomManipulation(); | doFurtherDomManipulation(); | ||
} | } |