I would like to know the best way in Javascript (maybe in JQuery) to do the following things without server coding if able :
There are around 20 sets of objects, with around 90 objects in each set of objects. Here is an example of the sets of objects :
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)
The generated text files should be :
player1.txt
3 Noise
1 Parasite
2 Sure Gamble
...
player2.txt
1 Gabriel Santiago
2 Pipeline
2 Aurora
...
...(until player20.txt)
I would like to ZIP player1.txt until player20.txt into a ZIP file players.zip.
I would like to download the ZIP file players.zip.
Thank you for your help and your answers.
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.