refactor code + propre
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
// 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);
|
||||
}
|
||||
|
||||
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);
|
||||
Reference in New Issue
Block a user