Архивация модулей MAOH в один файл zip
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

130 lines
3.8KB

  1. // // // //
  2. ВыдатьАрхивНаСкачивание = мир =>
  3. {
  4. // How to create a file in memory for user to download, but not through server?
  5. // https://stackoverflow.com/a/18197341
  6. var ссыль = document.createElement("a");
  7. ссыль.setAttribute("href", "data:text/html;charset=utf-8;base64," + мир.содержимоеАрхива);
  8. var имя = "MAOH.zip";
  9. ссыль.setAttribute("download", имя);
  10. ссыль.style.display = "none";
  11. document.body.appendChild(ссыль);
  12. ссыль.click();
  13. document.body.removeChild(ссыль);
  14. };
  15. // // // //
  16. СгенерироватьАрхив = мир =>
  17. {
  18. мир.архив.generateAsync({type: "base64"}).then(function(content) {
  19. мир.содержимоеАрхива = content;
  20. console.debug("мир.содержимоеАрхива", мир.содержимоеАрхива);
  21. мир.уведомить("сгенерировали архив");
  22. });
  23. };
  24. // // // //
  25. СоздатьАрхивИзЗагруженныхМодулей = мир =>
  26. {
  27. var архив = new JSZip();
  28. for (var н in мир.указателиМодулей)
  29. {
  30. var ук = мир.указателиМодулей[н];
  31. //var ук64 = мир.база64ИзДвоичногоМассива(new Uint8Array(содержимое));
  32. var директория = архив.folder(ук);
  33. директория.file("hello", "yohello");
  34. }
  35. мир.архив = архив;
  36. };
  37. // // // //
  38. ЗагрузитьМодули = мир =>
  39. {
  40. мир.модули.использовали.подписатьРаз(function() {
  41. мир.уведомить("загрузили модули");
  42. });
  43. мир.модули.использовать(мир.указателиМодулей);
  44. };
  45. // // // //
  46. ВывестиУказателиМодулей = мир =>
  47. {
  48. console.debug("указатели модулей:", мир.указателиМодулей);
  49. };
  50. // // // //
  51. РазобратьСписокМодулей = мир =>
  52. {
  53. var указатели = [];
  54. var строки = мир.списокМодулей.split(/\n/);
  55. for (var номер in строки)
  56. {
  57. var строка = строки[номер].trim();
  58. if (!строка.startsWith("#") && строка.length)
  59. {
  60. указатели.push(строка);
  61. }
  62. }
  63. мир.указателиМодулей = указатели;
  64. };
  65. // // // //
  66. ЗадатьСписокМодулей = мир =>
  67. {
  68. мир.списокМодулей = `
  69. https://bitbucket.org/gitjs/jquery/raw/3.5.1/0000
  70. https://bitbucket.org/gitjs/uikit/raw/3.2.0/0000
  71. https://git.opengamestudio.org/mahjong/mahjong-raskladka-layout/raw/branch/master/0000
  72. https://git.opengamestudio.org/mahjong/povtorniy-repeating-ui/raw/branch/master/0000
  73. https://git.opengamestudio.org/PuCOBATEJlb/PuCOBATEJlb/raw/branch/master/0000
  74. https://git.opengamestudio.org/PuCOBATEJlb/PECYPCbl/raw/branch/master/0000
  75. https://git.opengamestudio.org/MAOH/MEXMA/raw/branch/master/0000
  76. https://git.opengamestudio.org/MAOH/CEHMA/raw/branch/master/0000
  77. https://git.opengamestudio.org/MAOH/MOPMA/raw/branch/master/0000
  78. https://git.opengamestudio.org/MAOH/PEEMA/raw/branch/master/0000
  79. https://git.opengamestudio.org/MAOH/OTMA/raw/branch/master/0000
  80. https://git.opengamestudio.org/MAOH/CYMA/raw/branch/master/0000
  81. https://git.opengamestudio.org/MAOH/TEMA_M1K/raw/branch/master/0000
  82. https://git.opengamestudio.org/MAOH/PACK_M1/raw/branch/master/0000
  83. # Убрать после отладки
  84. https://git.opengamestudio.org/MAOH/TEMA_OT/raw/branch/master/0000
  85. https://git.opengamestudio.org/MAOH/PACK_OT/raw/branch/master/0000
  86. `;
  87. };
  88. // // // //
  89. СкрытьКрутилку = мир =>
  90. {
  91. document.getElementById("крутилка").style.display = "none";
  92. };