-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
64 changed files
with
1,269 additions
and
1,266 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,46 @@ | ||
"use strict"; | ||
|
||
module.exports = function(grunt) { | ||
var version = require("./package.json").version; | ||
var version = require("./package.json").version; | ||
|
||
grunt.initConfig({ | ||
browserify: { | ||
all: { | ||
files: { | ||
'dist/jszip.js': ['lib/index.js'] | ||
grunt.initConfig({ | ||
browserify: { | ||
all: { | ||
files: { | ||
"dist/jszip.js": ["lib/index.js"] | ||
}, | ||
options: { | ||
browserifyOptions: { | ||
standalone: "JSZip", | ||
transform: ["package-json-versionify"], | ||
insertGlobalVars: { | ||
process: undefined, | ||
Buffer: undefined, | ||
__filename: undefined, | ||
__dirname: undefined | ||
}, | ||
builtins: false | ||
}, | ||
banner: grunt.file.read("lib/license_header.js").replace(/__VERSION__/, version) | ||
} | ||
} | ||
}, | ||
options: { | ||
browserifyOptions: { | ||
standalone: 'JSZip', | ||
transform: ['package-json-versionify'], | ||
insertGlobalVars: { | ||
process: undefined, | ||
Buffer: undefined, | ||
__filename: undefined, | ||
__dirname: undefined | ||
uglify: { | ||
options: { | ||
mangle: true, | ||
preserveComments: false, | ||
banner: grunt.file.read("lib/license_header.js").replace(/__VERSION__/, version) | ||
}, | ||
builtins: false | ||
}, | ||
banner: grunt.file.read('lib/license_header.js').replace(/__VERSION__/, version) | ||
all: { | ||
src: "dist/jszip.js", | ||
dest: "dist/jszip.min.js" | ||
} | ||
} | ||
} | ||
}, | ||
uglify: { | ||
options: { | ||
mangle: true, | ||
preserveComments: false, | ||
banner: grunt.file.read('lib/license_header.js').replace(/__VERSION__/, version) | ||
}, | ||
all: { | ||
src: 'dist/jszip.js', | ||
dest: 'dist/jszip.min.js' | ||
} | ||
} | ||
}); | ||
}); | ||
|
||
grunt.loadNpmTasks('grunt-browserify'); | ||
grunt.loadNpmTasks('grunt-contrib-uglify'); | ||
grunt.loadNpmTasks("grunt-browserify"); | ||
grunt.loadNpmTasks("grunt-contrib-uglify"); | ||
|
||
grunt.registerTask("build", ["browserify", "uglify"]); | ||
grunt.registerTask("default", ["build"]); | ||
grunt.registerTask("build", ["browserify", "uglify"]); | ||
grunt.registerTask("default", ["build"]); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
"use strict"; | ||
|
||
module.exports = { | ||
globals: { | ||
$: false, | ||
jQuery: false, | ||
JSZip: false, | ||
JSZipUtils: false, | ||
// From FileSaver.js | ||
saveAs: false, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
"use strict"; | ||
|
||
var zip = new JSZip(); | ||
zip.file("Hello.txt", "Hello world\n"); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
"use strict"; | ||
|
||
var zip = new JSZip(); | ||
zip.file("Hello.txt", "Hello world\n"); | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 25 additions & 23 deletions
48
documentation/examples/get-binary-files-ajax.inc/fetch_api.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,25 @@ | ||
fetch('{{site.baseurl}}/test/ref/text.zip') // 1) fetch the url | ||
.then(function (response) { // 2) filter on 200 OK | ||
if (response.status === 200 || response.status === 0) { | ||
return Promise.resolve(response.blob()); | ||
} else { | ||
return Promise.reject(new Error(response.statusText)); | ||
} | ||
}) | ||
.then(JSZip.loadAsync) // 3) chain with the zip promise | ||
.then(function (zip) { | ||
return zip.file("Hello.txt").async("string"); // 4) chain with the text content promise | ||
}) | ||
.then(function success(text) { // 5) display the result | ||
$("#fetch").append($("<p>", { | ||
"class": "alert alert-success", | ||
text: "loaded, content = " + text | ||
})); | ||
}, function error(e) { | ||
$("#fetch").append($("<p>", { | ||
"class": "alert alert-danger", | ||
text: e | ||
})); | ||
}); | ||
"use strict"; | ||
|
||
fetch("{{site.baseurl}}/test/ref/text.zip") // 1) fetch the url | ||
.then(function (response) { // 2) filter on 200 OK | ||
if (response.status === 200 || response.status === 0) { | ||
return Promise.resolve(response.blob()); | ||
} else { | ||
return Promise.reject(new Error(response.statusText)); | ||
} | ||
}) | ||
.then(JSZip.loadAsync) // 3) chain with the zip promise | ||
.then(function (zip) { | ||
return zip.file("Hello.txt").async("string"); // 4) chain with the text content promise | ||
}) | ||
.then(function success(text) { // 5) display the result | ||
$("#fetch").append($("<p>", { | ||
"class": "alert alert-success", | ||
text: "loaded, content = " + text | ||
})); | ||
}, function error(e) { | ||
$("#fetch").append($("<p>", { | ||
"class": "alert alert-danger", | ||
text: e | ||
})); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.