First commit
This commit is contained in:
3
hGameTest/node_modules/file-saverjs/.npmignore
generated
vendored
Normal file
3
hGameTest/node_modules/file-saverjs/.npmignore
generated
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
.idea
|
||||
*.iml
|
||||
node_modules
|
||||
190
hGameTest/node_modules/file-saverjs/FileSaver.js
generated
vendored
Normal file
190
hGameTest/node_modules/file-saverjs/FileSaver.js
generated
vendored
Normal file
@@ -0,0 +1,190 @@
|
||||
/*! FileSaver.js v1.3.6
|
||||
*
|
||||
* A saveAs() FileSaver implementation.
|
||||
*
|
||||
* By Travis Clarke, https://travismclarke.com
|
||||
* By Eli Grey, http://eligrey.com
|
||||
*
|
||||
* License: MIT (https://github.com/clarketm/FileSaver.js/blob/master/LICENSE.md)
|
||||
*/
|
||||
|
||||
;(function (root, factory) {
|
||||
if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
|
||||
module.exports = root.document ? factory(root, true) : function (w) {
|
||||
if (!w.document) {
|
||||
throw new Error("FileSaver requires a window with a document");
|
||||
}
|
||||
return factory(w);
|
||||
};
|
||||
} else {
|
||||
factory(root);
|
||||
}
|
||||
}(window || this, function (window, noGlobal) {
|
||||
"use strict";
|
||||
// IE <10 is explicitly unsupported
|
||||
if (typeof window === "undefined" || typeof navigator !== "undefined" && /MSIE [1-9]\./.test(navigator.userAgent)) {
|
||||
return;
|
||||
}
|
||||
var
|
||||
doc = window.document
|
||||
// only get URL when necessary in case Blob.js hasn't overridden it yet
|
||||
, get_URL = function () {
|
||||
return window.URL || window.webkitURL || window;
|
||||
}
|
||||
, save_link = doc.createElementNS("http://www.w3.org/1999/xhtml", "a")
|
||||
, can_use_save_link = "download" in save_link
|
||||
, click = function (node) {
|
||||
var event = new MouseEvent("click");
|
||||
node.dispatchEvent(event);
|
||||
}
|
||||
, is_safari = /constructor/i.test(window.HTMLElement) || window.safari
|
||||
, is_chrome_ios = /CriOS\/[\d]+/.test(navigator.userAgent)
|
||||
, throw_outside = function (ex) {
|
||||
(window.setImmediate || window.setTimeout)(function () {
|
||||
throw ex;
|
||||
}, 0);
|
||||
}
|
||||
, force_saveable_type = "application/octet-stream"
|
||||
// the Blob API is fundamentally broken as there is no "downloadfinished" event to subscribe to
|
||||
, arbitrary_revoke_timeout = 1000 * 40 // in ms
|
||||
, revoke = function (file) {
|
||||
var revoker = function () {
|
||||
if (typeof file === "string") { // file is an object URL
|
||||
get_URL().revokeObjectURL(file);
|
||||
} else { // file is a File
|
||||
file.remove();
|
||||
}
|
||||
};
|
||||
setTimeout(revoker, arbitrary_revoke_timeout);
|
||||
}
|
||||
, dispatch = function (filesaver, event_types, event) {
|
||||
event_types = [].concat(event_types);
|
||||
var i = event_types.length;
|
||||
while (i--) {
|
||||
var listener = filesaver["on" + event_types[i]];
|
||||
if (typeof listener === "function") {
|
||||
try {
|
||||
listener.call(filesaver, event || filesaver);
|
||||
} catch (ex) {
|
||||
throw_outside(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
, auto_bom = function (blob) {
|
||||
// prepend BOM for UTF-8 XML and text/* types (including HTML)
|
||||
// note: your browser will automatically convert UTF-16 U+FEFF to EF BB BF
|
||||
if (/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(blob.type)) {
|
||||
return new Blob([String.fromCharCode(0xFEFF), blob], {type: blob.type});
|
||||
}
|
||||
return blob;
|
||||
}
|
||||
, FileSaver = function (blob, name, no_auto_bom) {
|
||||
if (!no_auto_bom) {
|
||||
blob = auto_bom(blob);
|
||||
}
|
||||
// First try a.download, then web filesystem, then object URLs
|
||||
var
|
||||
filesaver = this
|
||||
, type = blob.type
|
||||
, force = type === force_saveable_type
|
||||
, object_url
|
||||
, dispatch_all = function () {
|
||||
dispatch(filesaver, "writestart progress write writeend".split(" "));
|
||||
}
|
||||
// on any filesys errors revert to saving with object URLs
|
||||
, fs_error = function () {
|
||||
if ((is_chrome_ios || (force && is_safari)) && window.FileReader) {
|
||||
// Safari doesn't allow downloading of blob urls
|
||||
var reader = new FileReader();
|
||||
reader.onloadend = function () {
|
||||
var url = is_chrome_ios ? reader.result : reader.result.replace(/^data:[^;]*;/, 'data:attachment/file;');
|
||||
var popup = window.open(url, '_blank');
|
||||
if (!popup) window.location.href = url;
|
||||
url = undefined; // release reference before dispatching
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch_all();
|
||||
};
|
||||
reader.readAsDataURL(blob);
|
||||
filesaver.readyState = filesaver.INIT;
|
||||
return;
|
||||
}
|
||||
// don't create more object URLs than needed
|
||||
if (!object_url) {
|
||||
object_url = get_URL().createObjectURL(blob);
|
||||
}
|
||||
if (force) {
|
||||
window.location.href = object_url;
|
||||
} else {
|
||||
var opened = window.open(object_url, "_blank");
|
||||
if (!opened) {
|
||||
// Apple does not allow window.open, see https://developer.apple.com/library/safari/documentation/Tools/Conceptual/SafariExtensionGuide/WorkingwithWindowsandTabs/WorkingwithWindowsandTabs.html
|
||||
window.location.href = object_url;
|
||||
}
|
||||
}
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
dispatch_all();
|
||||
revoke(object_url);
|
||||
}
|
||||
;
|
||||
filesaver.readyState = filesaver.INIT;
|
||||
|
||||
if (can_use_save_link) {
|
||||
object_url = get_URL().createObjectURL(blob);
|
||||
setTimeout(function () {
|
||||
save_link.href = object_url;
|
||||
save_link.download = name;
|
||||
click(save_link);
|
||||
dispatch_all();
|
||||
revoke(object_url);
|
||||
filesaver.readyState = filesaver.DONE;
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
fs_error();
|
||||
}
|
||||
, FS_proto = FileSaver.prototype
|
||||
, saveAs = function (blob, name, no_auto_bom) {
|
||||
return new FileSaver(blob, name || blob.name || "download", no_auto_bom);
|
||||
}
|
||||
;
|
||||
// IE 10+ (native saveAs)
|
||||
if (typeof navigator !== "undefined" && navigator.msSaveOrOpenBlob) {
|
||||
saveAs = function (blob, name, no_auto_bom) {
|
||||
name = name || blob.name || "download";
|
||||
|
||||
if (!no_auto_bom) {
|
||||
blob = auto_bom(blob);
|
||||
}
|
||||
return navigator.msSaveOrOpenBlob(blob, name);
|
||||
};
|
||||
}
|
||||
|
||||
FS_proto.abort = function () {
|
||||
};
|
||||
FS_proto.readyState = FS_proto.INIT = 0;
|
||||
FS_proto.WRITING = 1;
|
||||
FS_proto.DONE = 2;
|
||||
|
||||
FS_proto.error =
|
||||
FS_proto.onwritestart =
|
||||
FS_proto.onprogress =
|
||||
FS_proto.onwrite =
|
||||
FS_proto.onabort =
|
||||
FS_proto.onerror =
|
||||
FS_proto.onwriteend =
|
||||
null;
|
||||
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define("file-saverjs", [], function () {
|
||||
return saveAs;
|
||||
});
|
||||
}
|
||||
|
||||
if (typeof noGlobal === 'undefined') {
|
||||
window.saveAs = saveAs;
|
||||
}
|
||||
return saveAs;
|
||||
}
|
||||
));
|
||||
10
hGameTest/node_modules/file-saverjs/FileSaver.min.js
generated
vendored
Normal file
10
hGameTest/node_modules/file-saverjs/FileSaver.min.js
generated
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
/*! FileSaver.js v1.3.6
|
||||
*
|
||||
* A saveAs() FileSaver implementation.
|
||||
*
|
||||
* By Travis Clarke, https://travismclarke.com
|
||||
* By Eli Grey, http://eligrey.com
|
||||
*
|
||||
* License: MIT (https://github.com/clarketm/FileSaver.js/blob/master/LICENSE.md)
|
||||
*/
|
||||
(function(e,t){if(typeof exports==="object"&&typeof exports.nodeName!=="string"){module.exports=e.document?t(e,true):function(e){if(!e.document){throw new Error("FileSaver requires a window with a document")}return t(e)}}else{t(e)}})(window||this,function(e,t){"use strict";if(typeof e==="undefined"||typeof navigator!=="undefined"&&/MSIE [1-9]\./.test(navigator.userAgent)){return}var n=e.document,r=function(){return e.URL||e.webkitURL||e},o=n.createElementNS("http://www.w3.org/1999/xhtml","a"),i="download"in o,a=function(e){var t=new MouseEvent("click");e.dispatchEvent(t)},f=/constructor/i.test(e.HTMLElement)||e.safari,u=/CriOS\/[\d]+/.test(navigator.userAgent),c=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},d="application/octet-stream",s=1e3*40,l=function(e){var t=function(){if(typeof e==="string"){r().revokeObjectURL(e)}else{e.remove()}};setTimeout(t,s)},p=function(e,t,n){t=[].concat(t);var r=t.length;while(r--){var o=e["on"+t[r]];if(typeof o==="function"){try{o.call(e,n||e)}catch(e){c(e)}}}},w=function(e){if(/^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e.type)){return new Blob([String.fromCharCode(65279),e],{type:e.type})}return e},m=function(t,n,c){if(!c){t=w(t)}var s=this,m=t.type,v=m===d,y,h=function(){p(s,"writestart progress write writeend".split(" "))},S=function(){if((u||v&&f)&&e.FileReader){var n=new FileReader;n.onloadend=function(){var t=u?n.result:n.result.replace(/^data:[^;]*;/,"data:attachment/file;");var r=e.open(t,"_blank");if(!r)e.location.href=t;t=undefined;s.readyState=s.DONE;h()};n.readAsDataURL(t);s.readyState=s.INIT;return}if(!y){y=r().createObjectURL(t)}if(v){e.location.href=y}else{var o=e.open(y,"_blank");if(!o){e.location.href=y}}s.readyState=s.DONE;h();l(y)};s.readyState=s.INIT;if(i){y=r().createObjectURL(t);setTimeout(function(){o.href=y;o.download=n;a(o);h();l(y);s.readyState=s.DONE});return}S()},v=m.prototype,y=function(e,t,n){return new m(e,t||e.name||"download",n)};if(typeof navigator!=="undefined"&&navigator.msSaveOrOpenBlob){y=function(e,t,n){t=t||e.name||"download";if(!n){e=w(e)}return navigator.msSaveOrOpenBlob(e,t)}}v.abort=function(){};v.readyState=v.INIT=0;v.WRITING=1;v.DONE=2;v.error=v.onwritestart=v.onprogress=v.onwrite=v.onabort=v.onerror=v.onwriteend=null;if(typeof define==="function"&&define.amd){define("file-saverjs",[],function(){return y})}if(typeof t==="undefined"){e.saveAs=y}return y});
|
||||
11
hGameTest/node_modules/file-saverjs/LICENSE.md
generated
vendored
Normal file
11
hGameTest/node_modules/file-saverjs/LICENSE.md
generated
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
The MIT License
|
||||
|
||||
Copyright © 2016 [Eli Grey][1].
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
[1]: http://eligrey.com
|
||||
147
hGameTest/node_modules/file-saverjs/README.md
generated
vendored
Normal file
147
hGameTest/node_modules/file-saverjs/README.md
generated
vendored
Normal file
@@ -0,0 +1,147 @@
|
||||
If you need to save really large files bigger then the blob's size limitation or don't have
|
||||
enough RAM, then have a look at the more advanced [StreamSaver.js](https://github.com/jimmywarting/StreamSaver.js)
|
||||
that can save data directly to the hard drive asynchronously with the power of the new streams API. That will have
|
||||
support for progress, cancelation and knowing when it's done writing
|
||||
|
||||
FileSaver.js
|
||||
============
|
||||
|
||||
FileSaver.js implements the `saveAs()` FileSaver interface in browsers that do
|
||||
not natively support it. There is a [FileSaver.js demo][1] that demonstrates saving
|
||||
various media types.
|
||||
|
||||
FileSaver.js is the solution to saving files on the client-side, and is perfect for
|
||||
webapps that need to generate files, or for saving sensitive information that shouldn't be
|
||||
sent to an external server.
|
||||
|
||||
Looking for `canvas.toBlob()` for saving canvases? Check out
|
||||
[canvas-toBlob.js][2] for a cross-browser implementation.
|
||||
|
||||
Installation
|
||||
------------------
|
||||
### npm
|
||||
```bash
|
||||
$ npm install file-saverjs
|
||||
```
|
||||
|
||||
### bower
|
||||
```bash
|
||||
$ bower install file-saverjs
|
||||
```
|
||||
|
||||
|
||||
Supported browsers
|
||||
------------------
|
||||
|
||||
| Browser | Constructs as | Filenames | Max Blob Size | Dependencies |
|
||||
| -------------- | ------------- | ------------ | ------------- | ------------ |
|
||||
| Firefox 20+ | Blob | Yes | 800 MiB | None |
|
||||
| Firefox < 20 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) |
|
||||
| Chrome | Blob | Yes | [500 MiB][3] | None |
|
||||
| Chrome for Android | Blob | Yes | [500 MiB][3] | None |
|
||||
| Edge | Blob | Yes | ? | None |
|
||||
| IE 10+ | Blob | Yes | 600 MiB | None |
|
||||
| Opera 15+ | Blob | Yes | 500 MiB | None |
|
||||
| Opera < 15 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) |
|
||||
| Safari 6.1+* | Blob | No | ? | None |
|
||||
| Safari < 6 | data: URI | No | n/a | [Blob.js](https://github.com/eligrey/Blob.js) |
|
||||
|
||||
Feature detection is possible:
|
||||
|
||||
```js
|
||||
try {
|
||||
var isFileSaverSupported = !!new Blob;
|
||||
} catch (e) {}
|
||||
```
|
||||
|
||||
### IE < 10
|
||||
|
||||
It is possible to save text files in IE < 10 without Flash-based polyfills.
|
||||
See [ChenWenBrian and koffsyrup's `saveTextAs()`](https://github.com/koffsyrup/FileSaver.js#examples) for more details.
|
||||
|
||||
### Safari 6.1+
|
||||
|
||||
Blobs may be opened instead of saved sometimes—you may have to direct your Safari users to manually
|
||||
press <kbd>⌘</kbd>+<kbd>S</kbd> to save the file after it is opened. Using the `application/octet-stream` MIME type to force downloads [can cause issues in Safari](https://github.com/eligrey/FileSaver.js/issues/12#issuecomment-47247096).
|
||||
|
||||
### iOS
|
||||
|
||||
saveAs must be run within a user interaction event such as onTouchDown or onClick; setTimeout will prevent saveAs from triggering. Due to restrictions in iOS saveAs opens in a new window instead of downloading, if you want this fixed please [tell Apple](https://bugs.webkit.org/show_bug.cgi?id=102914) how this bug is affecting you.
|
||||
|
||||
Syntax
|
||||
------
|
||||
|
||||
```js
|
||||
FileSaver saveAs(Blob/File data, optional DOMString filename, optional Boolean disableAutoBOM)
|
||||
```
|
||||
|
||||
Pass `true` for `disableAutoBOM` if you don't want FileSaver.js to automatically provide Unicode text encoding hints (see: [byte order mark](https://en.wikipedia.org/wiki/Byte_order_mark)).
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
### Saving text using with require
|
||||
```js
|
||||
var FileSaver = require('file-saver');
|
||||
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
FileSaver.saveAs(blob, "hello world.txt");
|
||||
```
|
||||
|
||||
### Saving text
|
||||
|
||||
```js
|
||||
var blob = new Blob(["Hello, world!"], {type: "text/plain;charset=utf-8"});
|
||||
saveAs(blob, "hello world.txt");
|
||||
```
|
||||
|
||||
The standard W3C File API [`Blob`][4] interface is not available in all browsers.
|
||||
[Blob.js][5] is a cross-browser `Blob` implementation that solves this.
|
||||
|
||||
### Saving a canvas
|
||||
|
||||
```js
|
||||
var canvas = document.getElementById("my-canvas"), ctx = canvas.getContext("2d");
|
||||
// draw to canvas...
|
||||
canvas.toBlob(function(blob) {
|
||||
saveAs(blob, "pretty image.png");
|
||||
});
|
||||
```
|
||||
|
||||
Note: The standard HTML5 `canvas.toBlob()` method is not available in all browsers.
|
||||
[canvas-toBlob.js][6] is a cross-browser `canvas.toBlob()` that polyfills this.
|
||||
|
||||
### Saving File
|
||||
|
||||
You can save a File constructor without specifying a filename. The
|
||||
File itself already contains a name, There is a hand full of ways to get a file
|
||||
instance (from storage, file input, new constructor)
|
||||
But if you still want to change the name, then you can change it in the 2nd argument
|
||||
|
||||
```js
|
||||
var file = new File(["Hello, world!"], "hello world.txt", {type: "text/plain;charset=utf-8"});
|
||||
saveAs(file);
|
||||
```
|
||||
|
||||
|
||||
|
||||

|
||||
|
||||
[1]: http://eligrey.com/demos/FileSaver.js/
|
||||
[2]: https://github.com/eligrey/canvas-toBlob.js
|
||||
[3]: https://code.google.com/p/chromium/issues/detail?id=375297
|
||||
[4]: https://developer.mozilla.org/en-US/docs/DOM/Blob
|
||||
[5]: https://github.com/eligrey/Blob.js
|
||||
[6]: https://github.com/eligrey/canvas-toBlob.js
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
The `FileSaver.js` distribution file is compiled with Uglify.js like so:
|
||||
|
||||
```bash
|
||||
uglifyjs FileSaver.js --mangle --comments /@source/ > FileSaver.min.js
|
||||
# or simply:
|
||||
npm run build
|
||||
```
|
||||
|
||||
Please make sure you build a production version before submitting a pull request.
|
||||
22
hGameTest/node_modules/file-saverjs/bower.json
generated
vendored
Normal file
22
hGameTest/node_modules/file-saverjs/bower.json
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"name": "file-saverjs",
|
||||
"main": "FileSaver.js",
|
||||
"version": "1.3.6",
|
||||
"homepage": "https://github.com/clarketm/FileSaver.js#readme",
|
||||
"authors": [
|
||||
"clarketm <travis.m.clarke@gmail.com>",
|
||||
"eligrey <~@eligrey.com>"
|
||||
],
|
||||
"description": "An HTML5 saveAs() FileSaver implementation",
|
||||
"keywords": [
|
||||
"filesaver",
|
||||
"saveas",
|
||||
"blob"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"*",
|
||||
"!FileSaver.*js",
|
||||
"!LICENSE.md"
|
||||
]
|
||||
}
|
||||
50
hGameTest/node_modules/file-saverjs/demo/demo.css
generated
vendored
Normal file
50
hGameTest/node_modules/file-saverjs/demo/demo.css
generated
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
html {
|
||||
background-color: #DDD;
|
||||
}
|
||||
body {
|
||||
-webkit-box-sizing: content-box;
|
||||
-moz-box-sizing: content-box;
|
||||
box-sizing: content-box;
|
||||
width: 900px;
|
||||
margin: 0 auto;
|
||||
font-family: Verdana, Helvetica, Arial, sans-serif;
|
||||
-webkit-box-shadow: 0 0 10px 2px rgba(0, 0, 0, .5);
|
||||
-moz-box-shadow: 0 0 10px 2px rgba(0, 0, 0, .5);
|
||||
box-shadow: 0 0 10px 2px rgba(0, 0, 0, .5);
|
||||
padding: 7px 25px 70px;
|
||||
background-color: #FFF;
|
||||
}
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
font-family: Georgia, "Times New Roman", serif;
|
||||
}
|
||||
h2, form {
|
||||
text-align: center;
|
||||
}
|
||||
form {
|
||||
margin-top: 5px;
|
||||
}
|
||||
.input {
|
||||
width: 500px;
|
||||
height: 300px;
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
}
|
||||
section {
|
||||
margin-top: 40px;
|
||||
}
|
||||
#canvas {
|
||||
cursor: crosshair;
|
||||
}
|
||||
#canvas, #html {
|
||||
border: 1px solid #000;
|
||||
}
|
||||
.filename {
|
||||
text-align: right;
|
||||
}
|
||||
#html {
|
||||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
overflow: auto;
|
||||
padding: 1em;
|
||||
}
|
||||
216
hGameTest/node_modules/file-saverjs/demo/demo.js
generated
vendored
Normal file
216
hGameTest/node_modules/file-saverjs/demo/demo.js
generated
vendored
Normal file
@@ -0,0 +1,216 @@
|
||||
/*! FileSaver.js demo script
|
||||
* 2016-05-26
|
||||
*
|
||||
* By Eli Grey, http://eligrey.com
|
||||
* License: MIT
|
||||
* See LICENSE.md
|
||||
*/
|
||||
|
||||
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/demo/demo.js */
|
||||
|
||||
/*jshint laxbreak: true, laxcomma: true, smarttabs: true*/
|
||||
/*global saveAs, self*/
|
||||
|
||||
(function(view) {
|
||||
"use strict";
|
||||
// The canvas drawing portion of the demo is based off the demo at
|
||||
// http://www.williammalone.com/articles/create-html5-canvas-javascript-drawing-app/
|
||||
var
|
||||
document = view.document
|
||||
, $ = function(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
, session = view.sessionStorage
|
||||
// only get URL when necessary in case Blob.js hasn't defined it yet
|
||||
, get_blob = function() {
|
||||
return view.Blob;
|
||||
}
|
||||
|
||||
, canvas = $("canvas")
|
||||
, canvas_options_form = $("canvas-options")
|
||||
, canvas_filename = $("canvas-filename")
|
||||
, canvas_clear_button = $("canvas-clear")
|
||||
|
||||
, text = $("text")
|
||||
, text_options_form = $("text-options")
|
||||
, text_filename = $("text-filename")
|
||||
|
||||
, html = $("html")
|
||||
, html_options_form = $("html-options")
|
||||
, html_filename = $("html-filename")
|
||||
|
||||
, ctx = canvas.getContext("2d")
|
||||
, drawing = false
|
||||
, x_points = session.x_points || []
|
||||
, y_points = session.y_points || []
|
||||
, drag_points = session.drag_points || []
|
||||
, add_point = function(x, y, dragging) {
|
||||
x_points.push(x);
|
||||
y_points.push(y);
|
||||
drag_points.push(dragging);
|
||||
}
|
||||
, draw = function(){
|
||||
canvas.width = canvas.width;
|
||||
ctx.lineWidth = 6;
|
||||
ctx.lineJoin = "round";
|
||||
ctx.strokeStyle = "#000000";
|
||||
var
|
||||
i = 0
|
||||
, len = x_points.length
|
||||
;
|
||||
for(; i < len; i++) {
|
||||
ctx.beginPath();
|
||||
if (i && drag_points[i]) {
|
||||
ctx.moveTo(x_points[i-1], y_points[i-1]);
|
||||
} else {
|
||||
ctx.moveTo(x_points[i]-1, y_points[i]);
|
||||
}
|
||||
ctx.lineTo(x_points[i], y_points[i]);
|
||||
ctx.closePath();
|
||||
ctx.stroke();
|
||||
}
|
||||
}
|
||||
, stop_drawing = function() {
|
||||
drawing = false;
|
||||
}
|
||||
|
||||
// Title guesser and document creator available at https://gist.github.com/1059648
|
||||
, guess_title = function(doc) {
|
||||
var
|
||||
h = "h6 h5 h4 h3 h2 h1".split(" ")
|
||||
, i = h.length
|
||||
, headers
|
||||
, header_text
|
||||
;
|
||||
while (i--) {
|
||||
headers = doc.getElementsByTagName(h[i]);
|
||||
for (var j = 0, len = headers.length; j < len; j++) {
|
||||
header_text = headers[j].textContent.trim();
|
||||
if (header_text) {
|
||||
return header_text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
, doc_impl = document.implementation
|
||||
, create_html_doc = function(html) {
|
||||
var
|
||||
dt = doc_impl.createDocumentType('html', null, null)
|
||||
, doc = doc_impl.createDocument("http://www.w3.org/1999/xhtml", "html", dt)
|
||||
, doc_el = doc.documentElement
|
||||
, head = doc_el.appendChild(doc.createElement("head"))
|
||||
, charset_meta = head.appendChild(doc.createElement("meta"))
|
||||
, title = head.appendChild(doc.createElement("title"))
|
||||
, body = doc_el.appendChild(doc.createElement("body"))
|
||||
, i = 0
|
||||
, len = html.childNodes.length
|
||||
;
|
||||
charset_meta.setAttribute("charset", html.ownerDocument.characterSet);
|
||||
for (; i < len; i++) {
|
||||
body.appendChild(doc.importNode(html.childNodes.item(i), true));
|
||||
}
|
||||
var title_text = guess_title(doc);
|
||||
if (title_text) {
|
||||
title.appendChild(doc.createTextNode(title_text));
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
;
|
||||
canvas.width = 500;
|
||||
canvas.height = 300;
|
||||
|
||||
if (typeof x_points === "string") {
|
||||
x_points = JSON.parse(x_points);
|
||||
} if (typeof y_points === "string") {
|
||||
y_points = JSON.parse(y_points);
|
||||
} if (typeof drag_points === "string") {
|
||||
drag_points = JSON.parse(drag_points);
|
||||
} if (session.canvas_filename) {
|
||||
canvas_filename.value = session.canvas_filename;
|
||||
} if (session.text) {
|
||||
text.value = session.text;
|
||||
} if (session.text_filename) {
|
||||
text_filename.value = session.text_filename;
|
||||
} if (session.html) {
|
||||
html.innerHTML = session.html;
|
||||
} if (session.html_filename) {
|
||||
html_filename.value = session.html_filename;
|
||||
}
|
||||
|
||||
drawing = true;
|
||||
draw();
|
||||
drawing = false;
|
||||
|
||||
canvas_clear_button.addEventListener("click", function() {
|
||||
canvas.width = canvas.width;
|
||||
x_points.length =
|
||||
y_points.length =
|
||||
drag_points.length =
|
||||
0;
|
||||
}, false);
|
||||
canvas.addEventListener("mousedown", function(event) {
|
||||
event.preventDefault();
|
||||
drawing = true;
|
||||
add_point(event.pageX - canvas.offsetLeft, event.pageY - canvas.offsetTop, false);
|
||||
draw();
|
||||
}, false);
|
||||
canvas.addEventListener("mousemove", function(event) {
|
||||
if (drawing) {
|
||||
add_point(event.pageX - canvas.offsetLeft, event.pageY - canvas.offsetTop, true);
|
||||
draw();
|
||||
}
|
||||
}, false);
|
||||
canvas.addEventListener("mouseup", stop_drawing, false);
|
||||
canvas.addEventListener("mouseout", stop_drawing, false);
|
||||
|
||||
canvas_options_form.addEventListener("submit", function(event) {
|
||||
event.preventDefault();
|
||||
canvas.toBlobHD(function(blob) {
|
||||
saveAs(
|
||||
blob
|
||||
, (canvas_filename.value || canvas_filename.placeholder) + ".png"
|
||||
);
|
||||
}, "image/png");
|
||||
}, false);
|
||||
|
||||
text_options_form.addEventListener("submit", function(event) {
|
||||
event.preventDefault();
|
||||
var BB = get_blob();
|
||||
saveAs(
|
||||
new BB(
|
||||
[text.value || text.placeholder]
|
||||
, {type: "text/plain;charset=" + document.characterSet}
|
||||
)
|
||||
, (text_filename.value || text_filename.placeholder) + ".txt"
|
||||
);
|
||||
}, false);
|
||||
|
||||
html_options_form.addEventListener("submit", function(event) {
|
||||
event.preventDefault();
|
||||
var
|
||||
BB = get_blob()
|
||||
, xml_serializer = new XMLSerializer()
|
||||
, doc = create_html_doc(html)
|
||||
;
|
||||
saveAs(
|
||||
new BB(
|
||||
[xml_serializer.serializeToString(doc)]
|
||||
, {type: "text/plain;charset=" + document.characterSet}
|
||||
)
|
||||
, (html_filename.value || html_filename.placeholder) + ".xhtml"
|
||||
);
|
||||
}, false);
|
||||
|
||||
view.addEventListener("unload", function() {
|
||||
session.x_points = JSON.stringify(x_points);
|
||||
session.y_points = JSON.stringify(y_points);
|
||||
session.drag_points = JSON.stringify(drag_points);
|
||||
session.canvas_filename = canvas_filename.value;
|
||||
|
||||
session.text = text.value;
|
||||
session.text_filename = text_filename.value;
|
||||
|
||||
session.html = html.innerHTML;
|
||||
session.html_filename = html_filename.value;
|
||||
}, false);
|
||||
}(self));
|
||||
2
hGameTest/node_modules/file-saverjs/demo/demo.min.js
generated
vendored
Normal file
2
hGameTest/node_modules/file-saverjs/demo/demo.min.js
generated
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
/*! @source http://purl.eligrey.com/github/FileSaver.js/blob/master/demo/demo.js */
|
||||
(function(n){"use strict";var s=n.document,g=function(A){return s.getElementById(A)},b=n.sessionStorage,x=function(){return n.Blob},f=g("canvas"),r=g("canvas-options"),y=g("canvas-filename"),p=g("canvas-clear"),q=g("text"),t=g("text-options"),h=g("text-filename"),m=g("html"),e=g("html-options"),i=g("html-filename"),u=f.getContext("2d"),z=false,a=b.x_points||[],o=b.y_points||[],d=b.drag_points||[],j=function(A,C,B){a.push(A);o.push(C);d.push(B)},l=function(){f.width=f.width;u.lineWidth=6;u.lineJoin="round";u.strokeStyle="#000000";var B=0,A=a.length;for(;B<A;B++){u.beginPath();if(B&&d[B]){u.moveTo(a[B-1],o[B-1])}else{u.moveTo(a[B]-1,o[B])}u.lineTo(a[B],o[B]);u.closePath();u.stroke()}},c=function(){z=false},w=function(E){var D="h6 h5 h4 h3 h2 h1".split(" "),C=D.length,F,G;while(C--){F=E.getElementsByTagName(D[C]);for(var B=0,A=F.length;B<A;B++){G=F[B].textContent.trim();if(G){return G}}}},v=s.implementation,k=function(D){var B=v.createDocumentType("html",null,null),J=v.createDocument("http://www.w3.org/1999/xhtml","html",B),A=J.documentElement,H=A.appendChild(J.createElement("head")),K=H.appendChild(J.createElement("meta")),I=H.appendChild(J.createElement("title")),E=A.appendChild(J.createElement("body")),C=0,G=D.childNodes.length;K.setAttribute("charset",D.ownerDocument.characterSet);for(;C<G;C++){E.appendChild(J.importNode(D.childNodes.item(C),true))}var F=w(J);if(F){I.appendChild(J.createTextNode(F))}return J};f.width=500;f.height=300;if(typeof a==="string"){a=JSON.parse(a)}if(typeof o==="string"){o=JSON.parse(o)}if(typeof d==="string"){d=JSON.parse(d)}if(b.canvas_filename){y.value=b.canvas_filename}if(b.text){q.value=b.text}if(b.text_filename){h.value=b.text_filename}if(b.html){m.innerHTML=b.html}if(b.html_filename){i.value=b.html_filename}z=true;l();z=false;p.addEventListener("click",function(){f.width=f.width;a.length=o.length=d.length=0},false);f.addEventListener("mousedown",function(A){A.preventDefault();z=true;j(A.pageX-f.offsetLeft,A.pageY-f.offsetTop,false);l()},false);f.addEventListener("mousemove",function(A){if(z){j(A.pageX-f.offsetLeft,A.pageY-f.offsetTop,true);l()}},false);f.addEventListener("mouseup",c,false);f.addEventListener("mouseout",c,false);r.addEventListener("submit",function(A){A.preventDefault();f.toBlobHD(function(B){saveAs(B,(y.value||y.placeholder)+".png")},"image/png")},false);t.addEventListener("submit",function(A){A.preventDefault();var B=x();saveAs(new B([q.value||q.placeholder],{type:"text/plain;charset="+s.characterSet}),(h.value||h.placeholder)+".txt")},false);e.addEventListener("submit",function(B){B.preventDefault();var D=x(),A=new XMLSerializer,C=k(m);saveAs(new D([A.serializeToString(C)],{type:"text/plain;charset="+s.characterSet}),(i.value||i.placeholder)+".xhtml")},false);n.addEventListener("unload",function(){b.x_points=JSON.stringify(a);b.y_points=JSON.stringify(o);b.drag_points=JSON.stringify(d);b.canvas_filename=y.value;b.text=q.value;b.text_filename=h.value;b.html=m.innerHTML;b.html_filename=i.value},false)}(self));
|
||||
57
hGameTest/node_modules/file-saverjs/demo/index.xhtml
generated
vendored
Normal file
57
hGameTest/node_modules/file-saverjs/demo/index.xhtml
generated
vendored
Normal file
@@ -0,0 +1,57 @@
|
||||
<!DOCTYPE html>
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US-x-Hixie">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<title>FileSaver.js demo</title>
|
||||
<link rel="stylesheet" type="text/css" href="https://cdn.rawgit.com/eligrey/FileSaver.js/702cd2e820b680f88a0f299e33085c196806fc52/demo/demo.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<h1><a href="https://github.com/eligrey/FileSaver.js">FileSaver.js</a> demo</h1>
|
||||
<p>
|
||||
The following examples demonstrate how it is possible to generate and save any type of data right in the browser using the <code>saveAs()</code> FileSaver interface, without contacting any servers.
|
||||
</p>
|
||||
<section id="image-demo">
|
||||
<h2>Saving an image</h2>
|
||||
<canvas class="input" id="canvas" width="500" height="300"/>
|
||||
<form id="canvas-options">
|
||||
<label>Filename: <input type="text" class="filename" id="canvas-filename" placeholder="doodle"/>.png</label>
|
||||
<input type="submit" value="Save"/>
|
||||
<input type="button" id="canvas-clear" value="Clear"/>
|
||||
</form>
|
||||
</section>
|
||||
<section id="text-demo">
|
||||
<h2>Saving text</h2>
|
||||
<textarea class="input" id="text" placeholder="Once upon a time..."/>
|
||||
<form id="text-options">
|
||||
<label>Filename: <input type="text" class="filename" id="text-filename" placeholder="a plain document"/>.txt</label>
|
||||
<input type="submit" value="Save"/>
|
||||
</form>
|
||||
</section>
|
||||
<section id="html-demo">
|
||||
<h2>Saving rich text</h2>
|
||||
<div class="input" id="html" contenteditable="">
|
||||
<h3>Some example rich text</h3>
|
||||
<ul>
|
||||
<li><del>Plain</del> <ins>Boring</ins> text.</li>
|
||||
<li><em>Emphasized text!</em></li>
|
||||
<li><strong>Strong text!</strong></li>
|
||||
<li>
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.1" width="70" height="70">
|
||||
<circle cx="35" cy="35" r="35" fill="red"/>
|
||||
<text x="10" y="40">image</text>
|
||||
</svg>
|
||||
</li>
|
||||
<li><a href="https://github.com/eligrey/FileSaver.js">A link.</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<form id="html-options">
|
||||
<label>Filename: <input type="text" class="filename" id="html-filename" placeholder="a rich document"/>.xhtml</label>
|
||||
<input type="submit" value="Save"/>
|
||||
</form>
|
||||
</section>
|
||||
<script async="" src="https://cdn.rawgit.com/eligrey/Blob.js/0cef2746414269b16834878a8abc52eb9d53e6bd/Blob.js"/>
|
||||
<script async="" src="https://cdn.rawgit.com/eligrey/canvas-toBlob.js/f1a01896135ab378aa5c0118eadd81da55e698d8/canvas-toBlob.js"/>
|
||||
<script async="" src="https://cdn.rawgit.com/eligrey/FileSaver.js/e9d941381475b5df8b7d7691013401e171014e89/FileSaver.min.js"/>
|
||||
<script async="" src="https://cdn.rawgit.com/eligrey/FileSaver.js/597b6cd0207ce408a6d34890b5b2826b13450714/demo/demo.js"/>
|
||||
</body>
|
||||
</html>
|
||||
56
hGameTest/node_modules/file-saverjs/package.json
generated
vendored
Normal file
56
hGameTest/node_modules/file-saverjs/package.json
generated
vendored
Normal file
@@ -0,0 +1,56 @@
|
||||
{
|
||||
"_from": "file-saverjs@^1.3.6",
|
||||
"_id": "file-saverjs@1.3.6",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-t6RU4Sb1bPcfy3AVm4NWFCZU544=",
|
||||
"_location": "/file-saverjs",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "range",
|
||||
"registry": true,
|
||||
"raw": "file-saverjs@^1.3.6",
|
||||
"name": "file-saverjs",
|
||||
"escapedName": "file-saverjs",
|
||||
"rawSpec": "^1.3.6",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "^1.3.6"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/openfl"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/file-saverjs/-/file-saverjs-1.3.6.tgz",
|
||||
"_shasum": "b7a454e126f56cf71fcb70159b8356142654e78e",
|
||||
"_spec": "file-saverjs@^1.3.6",
|
||||
"_where": "/home/andreas/Documents/Projects/haxe/openfl/nigger/node_modules/openfl",
|
||||
"authors": [
|
||||
"clarketm <travis.m.clarke@gmail.com>",
|
||||
"eligrey <~@eligrey.com>"
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/clarketm/FileSaver.js/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "An HTML5 saveAs() FileSaver implementation",
|
||||
"devDependencies": {
|
||||
"uglify-js": "^2.7.4"
|
||||
},
|
||||
"homepage": "https://github.com/clarketm/FileSaver.js#readme",
|
||||
"keywords": [
|
||||
"filesaver",
|
||||
"saveas",
|
||||
"blob"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "FileSaver.js",
|
||||
"name": "file-saverjs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/clarketm/FileSaver.js.git"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "uglifyjs FileSaver.js --mangle --comments '/^!|@preserve|@license|@cc_on/i' > FileSaver.min.js",
|
||||
"test": "exit 0"
|
||||
},
|
||||
"version": "1.3.6"
|
||||
}
|
||||
Reference in New Issue
Block a user