From be83a8f382cf2fea98161bfd6d51719aacbf9aa9 Mon Sep 17 00:00:00 2001 From: Fulup Ar Foll Date: Thu, 28 Jan 2016 16:30:12 +0100 Subject: Update JSON API --- .../documentation/examples/download-zip-file.html | 59 ++++++++++++++ .../jszip/documentation/examples/downloader.html | 58 ++++++++++++++ .../jszip/documentation/examples/downloader.js | 89 ++++++++++++++++++++++ .../examples/get-binary-files-ajax.html | 43 +++++++++++ .../examples/read-local-file-api.html | 87 +++++++++++++++++++++ 5 files changed, 336 insertions(+) create mode 100644 afm-client/bower_components/jszip/documentation/examples/download-zip-file.html create mode 100644 afm-client/bower_components/jszip/documentation/examples/downloader.html create mode 100644 afm-client/bower_components/jszip/documentation/examples/downloader.js create mode 100644 afm-client/bower_components/jszip/documentation/examples/get-binary-files-ajax.html create mode 100644 afm-client/bower_components/jszip/documentation/examples/read-local-file-api.html (limited to 'afm-client/bower_components/jszip/documentation/examples') diff --git a/afm-client/bower_components/jszip/documentation/examples/download-zip-file.html b/afm-client/bower_components/jszip/documentation/examples/download-zip-file.html new file mode 100644 index 0000000..869a54e --- /dev/null +++ b/afm-client/bower_components/jszip/documentation/examples/download-zip-file.html @@ -0,0 +1,59 @@ +--- +title: "Download the generated zip file" +layout: default +section: example +--- + +

Tip : check the source of the page !

+

The FileSaver API

+
+ Works on firefox, chrome , opera >= 15 and IE >= 10 (but NOT in compatibility view).
+ +
+

The data URL

+
+ Does not work in IE, has restrictions on the length.
+ +
+ diff --git a/afm-client/bower_components/jszip/documentation/examples/downloader.html b/afm-client/bower_components/jszip/documentation/examples/downloader.html new file mode 100644 index 0000000..e3589db --- /dev/null +++ b/afm-client/bower_components/jszip/documentation/examples/downloader.html @@ -0,0 +1,58 @@ +--- +title: "Mini app : Downloader" +layout: default +section: example +--- + +

Tip : check the source of the page !

+ +

+ This mini application let you choose the files you want in a list, download + them, zip them and give the result to the user. +

+

+ This demo requires a recent browser, see + the howto. +

+ + + +
+

Please select your files

+
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+ + +
+ +

+ + +
+ + diff --git a/afm-client/bower_components/jszip/documentation/examples/downloader.js b/afm-client/bower_components/jszip/documentation/examples/downloader.js new file mode 100644 index 0000000..13903cc --- /dev/null +++ b/afm-client/bower_components/jszip/documentation/examples/downloader.js @@ -0,0 +1,89 @@ +jQuery(function ($) { + "use strict"; + + /** + * Reset the message. + */ + function resetMessage () { + $("#result") + .removeClass() + .text(""); + } + /** + * show a successful message. + * @param {String} text the text to show. + */ + function showMessage(text) { + resetMessage(); + $("#result") + .addClass("alert alert-success") + .text(text); + } + /** + * show an error message. + * @param {String} text the text to show. + */ + function showError(text) { + resetMessage(); + $("#result") + .addClass("alert alert-danger") + .text(text); + } + + /** + * Fetch the content, add it to the JSZip object + * and use a jQuery deferred to hold the result. + * @param {String} url the url of the content to fetch. + * @param {String} filename the filename to use in the JSZip object. + * @param {JSZip} zip the JSZip instance. + * @return {jQuery.Deferred} the deferred containing the data. + */ + function deferredAddZip(url, filename, zip) { + var deferred = $.Deferred(); + JSZipUtils.getBinaryContent(url, function (err, data) { + if(err) { + deferred.reject(err); + } else { + zip.file(filename, data, {binary:true}); + deferred.resolve(data); + } + }); + return deferred; + } + + if(!JSZip.support.blob) { + showError("This demo works only with a recent browser !"); + return; + } + + var $form = $("#download_form").on("submit", function () { + + resetMessage(); + + var zip = new JSZip(); + var deferreds = []; + + // find every checked item + $(this).find(":checked").each(function () { + var $this = $(this); + var url = $this.data("url"); + var filename = url.replace(/.*\//g, ""); + deferreds.push(deferredAddZip(url, filename, zip)); + }); + + // when everything has been downloaded, we can trigger the dl + $.when.apply($, deferreds).done(function () { + var blob = zip.generate({type:"blob"}); + + // see FileSaver.js + saveAs(blob, "example.zip"); + + showMessage("done !"); + }).fail(function (err) { + showError(err); + }); + return false; + }); +}); + +// vim: set shiftwidth=4 softtabstop=4: diff --git a/afm-client/bower_components/jszip/documentation/examples/get-binary-files-ajax.html b/afm-client/bower_components/jszip/documentation/examples/get-binary-files-ajax.html new file mode 100644 index 0000000..ee7594e --- /dev/null +++ b/afm-client/bower_components/jszip/documentation/examples/get-binary-files-ajax.html @@ -0,0 +1,43 @@ +--- +title: "Get a file with an ajax call" +layout: default +section: example +--- + +

Tip : check the source of the page !

+ +

With JSZipUtils

+
+ + diff --git a/afm-client/bower_components/jszip/documentation/examples/read-local-file-api.html b/afm-client/bower_components/jszip/documentation/examples/read-local-file-api.html new file mode 100644 index 0000000..da307c2 --- /dev/null +++ b/afm-client/bower_components/jszip/documentation/examples/read-local-file-api.html @@ -0,0 +1,87 @@ +--- +title: "Reading a local file with the File API" +layout: default +section: example +--- + +

Choose the local(s) zip file(s)

+

Note : your browser will process the zip file, don't choose a file too big !

+
+ + + + + + -- cgit 1.2.3-korg