151 lines
4.5 KiB
JavaScript
151 lines
4.5 KiB
JavaScript
|
||
|
||
|
||
// // // //
|
||
|
||
|
||
ВыдатьАрхивНаСкачивание = мир =>
|
||
{
|
||
// How to create a file in memory for user to download, but not through server?
|
||
// https://stackoverflow.com/a/18197341
|
||
var ссыль = document.createElement("a");
|
||
ссыль.setAttribute("href", "data:application/zip;charset=utf-8;base64," + мир.содержимоеАрхива);
|
||
var имя = "MAOH.zip";
|
||
ссыль.setAttribute("download", имя);
|
||
ссыль.style.display = "none";
|
||
document.body.appendChild(ссыль);
|
||
ссыль.click();
|
||
document.body.removeChild(ссыль);
|
||
};
|
||
|
||
|
||
// // // //
|
||
|
||
|
||
СгенерироватьАрхив = мир =>
|
||
{
|
||
мир.архив.generateAsync({type: "base64"}).then(function(content) {
|
||
мир.содержимоеАрхива = content;
|
||
console.debug("мир.содержимоеАрхива", мир.содержимоеАрхива);
|
||
мир.уведомить("сгенерировали архив");
|
||
});
|
||
};
|
||
|
||
|
||
// // // //
|
||
|
||
|
||
СоздатьАрхив = мир =>
|
||
{
|
||
var архив = new JSZip();
|
||
var корень = архив.folder("MAOH");
|
||
корень.file("gitjs", мир.индекс);
|
||
for (var н in мир.указателиМодулей)
|
||
{
|
||
var ук = мир.указателиМодулей[н];
|
||
var м = мир.модули.модульПоУказателю(ук);
|
||
var директория = корень.folder(н);
|
||
директория.file("0000", мир.собрать0000(м));
|
||
for (var файл in м.структура)
|
||
{
|
||
var содержимое = м.содержимое[файл];
|
||
console.debug("задание содержимого файла:", файл);
|
||
директория.file(файл.substring(1), содержимое);
|
||
}
|
||
}
|
||
мир.архив = архив;
|
||
};
|
||
|
||
|
||
// // // //
|
||
|
||
|
||
СоздатьИндексАрхива = мир =>
|
||
{
|
||
var индекс = "";
|
||
for (var н in мир.указателиМодулей)
|
||
{
|
||
var ук = мир.указателиМодулей[н];
|
||
индекс += `${ук}\n`;
|
||
}
|
||
мир.индекс = индекс;
|
||
};
|
||
|
||
|
||
// // // //
|
||
|
||
|
||
ЗагрузитьМодули = мир =>
|
||
{
|
||
мир.модули.использовали.подписатьРаз(function() {
|
||
мир.уведомить("загрузили модули");
|
||
});
|
||
мир.модули.использовать(мир.указателиМодулей);
|
||
};
|
||
|
||
|
||
// // // //
|
||
|
||
|
||
ВывестиУказателиМодулей = мир =>
|
||
{
|
||
console.debug("указатели модулей:", мир.указателиМодулей);
|
||
};
|
||
|
||
|
||
// // // //
|
||
|
||
|
||
РазобратьСписокМодулей = мир =>
|
||
{
|
||
var указатели = [];
|
||
var строки = мир.списокМодулей.split(/\n/);
|
||
for (var номер in строки)
|
||
{
|
||
var строка = строки[номер].trim();
|
||
if (!строка.startsWith("#") && строка.length)
|
||
{
|
||
указатели.push(строка);
|
||
}
|
||
}
|
||
мир.указателиМодулей = указатели;
|
||
};
|
||
|
||
|
||
// // // //
|
||
|
||
|
||
ЗадатьСписокМодулей = мир =>
|
||
{
|
||
мир.списокМодулей = `
|
||
https://bitbucket.org/gitjs/jquery/raw/3.5.1/0000
|
||
https://bitbucket.org/gitjs/uikit/raw/3.2.0/0000
|
||
https://git.opengamestudio.org/mahjong/mahjong-raskladka-layout/raw/branch/master/0000
|
||
https://git.opengamestudio.org/mahjong/povtorniy-repeating-ui/raw/branch/master/0000
|
||
https://git.opengamestudio.org/PuCOBATEJlb/PuCOBATEJlb/raw/branch/master/0000
|
||
https://git.opengamestudio.org/PuCOBATEJlb/PECYPCbl/raw/branch/master/0000
|
||
|
||
https://git.opengamestudio.org/MAOH/MEXMA/raw/branch/master/0000
|
||
https://git.opengamestudio.org/MAOH/CEHMA/raw/branch/master/0000
|
||
https://git.opengamestudio.org/MAOH/MOPMA/raw/branch/master/0000
|
||
https://git.opengamestudio.org/MAOH/PEEMA/raw/branch/master/0000
|
||
https://git.opengamestudio.org/MAOH/OTMA/raw/branch/master/0000
|
||
https://git.opengamestudio.org/MAOH/CYMA/raw/branch/master/0000
|
||
|
||
https://git.opengamestudio.org/MAOH/TEMA_M1K/raw/branch/master/0000
|
||
https://git.opengamestudio.org/MAOH/PACK_M1/raw/branch/master/0000
|
||
|
||
# Убрать после отладки
|
||
https://git.opengamestudio.org/MAOH/TEMA_OT/raw/branch/master/0000
|
||
https://git.opengamestudio.org/MAOH/PACK_OT/raw/branch/master/0000
|
||
`;
|
||
};
|
||
|
||
|
||
// // // //
|
||
|
||
|
||
СкрытьКрутилку = мир =>
|
||
{
|
||
document.getElementById("крутилка").style.display = "none";
|
||
}; |