我想知道Javascript中的最佳方式(可能在JQuery中)如果能够执行以下操作而无需服务器编码:
大约有20组物体,每组物体约有90个物体。以下是对象集的示例:
var cardsPlayer1 = {
name : "Player 1",
[
{nbCopies : 3, name : "Noise"},
{nbCopies : 1, name : "Parasite"},
{nbCopies : 2, name : "Sure Gamble"},
... (around 90 of these objects)
]
};
var cardsPlayer2 =
name : "Player 2",
[
{nbCopies : 1, name : "Gabriel Santiago"},
{nbCopies : 3, name : "Pipeline"},
{nbCopies : 2, name : "Aurora"},
... (around 90 of these objects)
]
};
... (until cardsPlayer20)
生成的文本文件应为:
player1.txt
3 Noise
1 Parasite
2 Sure Gamble
...
player2.txt
1 Gabriel Santiago
2 Pipeline
2 Aurora
...
...(直到 player20.txt )
我想ZIP player1.txt直到player20.txt成为ZIP文件的player.zip。
我想下载ZIP文件players.zip。
感谢您的帮助和答案。
答案 0 :(得分:1)
just use some JavaScript zip library eg https://stuk.github.io/jszip/ and a file saver https://github.com/eligrey/FileSaver.js/.
jszip
provides all necessary examples to put files into the zipfile (this covers points 1 and 2). Using FileSaver.js
is also pretty straightforward as for point 3.