main.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // plein de requêtes pour séparer les scripts
  2. // mais osef c'est pour travailler en local
  3. const debug = true;
  4. const boldLogging = 'font-weight: bold;';
  5. const jsFolder = 'user/themes/carnet-atterrissage/js';
  6. const parsingScripts = [
  7. 'parsing/tagsToClasses.js',
  8. 'parsing/increaseMomentNumber.js',
  9. 'parsing/nonBreakingSpaces.js',
  10. 'parsing/addInsertIcons.js',
  11. 'parsing/cleanBibliography.js',
  12. 'parsing/cleanParagraphsParsing.js',
  13. 'parsing/titlePages.js',
  14. 'parsing/footnotes.js'
  15. ];
  16. function loadScripts(scripts, index, isPagedLoaded) {
  17. if (index < scripts.length) {
  18. $.getScript(`${jsFolder}/${scripts[index]}`, function() {
  19. loadScripts(scripts, index + 1, isPagedLoaded);
  20. });
  21. } else if (!isPagedLoaded) {
  22. $.getScript(`${jsFolder}/paged.polyfill.js`, function() {
  23. if (debug) console.log('%cPagedPreviewer working', boldLogging);
  24. // https://pagedjs.org/documentation/10-handlers-hooks-and-custom-javascript/
  25. class setLayout extends Paged.Handler {
  26. constructor(chunker, polisher, caller) {
  27. super(chunker, polisher, caller);
  28. }
  29. afterParsed(parsed) {
  30. $.getScript(`${jsFolder}/ui.js`, function() {});
  31. }
  32. afterRendered(pages) {
  33. if (debug) console.log('%cAll pages render done', boldLogging);
  34. $.getScript(`${jsFolder}/layout.js`, function() {});
  35. }
  36. }
  37. Paged.registerHandlers(setLayout);
  38. });
  39. }
  40. }
  41. if (debug) console.log('%cStart parsing', boldLogging)
  42. loadScripts(parsingScripts, 0, false);