12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- // plein de requêtes pour séparer les scripts
- // mais osef c'est pour travailler en local
- const debug = true;
- const boldLogging = 'font-weight: bold;';
- const jsFolder = 'user/themes/carnet-atterrissage/js';
- const parsingScripts = [
- 'parsing/tagsToClasses.js',
- 'parsing/increaseMomentNumber.js',
- 'parsing/nonBreakingSpaces.js',
- 'parsing/addInsertIcons.js',
- 'parsing/cleanBibliography.js',
- 'parsing/cleanParagraphsParsing.js',
- 'parsing/titlePages.js',
- 'parsing/footnotes.js'
- ];
- function loadScripts(scripts, index, isPagedLoaded) {
- if (index < scripts.length) {
- $.getScript(`${jsFolder}/${scripts[index]}`, function() {
- loadScripts(scripts, index + 1, isPagedLoaded);
- });
- } else if (!isPagedLoaded) {
- $.getScript(`${jsFolder}/paged.polyfill.js`, function() {
- if (debug) console.log('%cPagedPreviewer working', boldLogging);
- // https://pagedjs.org/documentation/10-handlers-hooks-and-custom-javascript/
- class setLayout extends Paged.Handler {
- constructor(chunker, polisher, caller) {
- super(chunker, polisher, caller);
- }
- afterParsed(parsed) {
- $.getScript(`${jsFolder}/ui.js`, function() {});
- }
-
- afterRendered(pages) {
- if (debug) console.log('%cAll pages render done', boldLogging);
- $.getScript(`${jsFolder}/layout.js`, function() {});
- }
- }
- Paged.registerHandlers(setLayout);
- });
- }
- }
- if (debug) console.log('%cStart parsing', boldLogging)
- loadScripts(parsingScripts, 0, false);
|