diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..4a18890 --- /dev/null +++ b/LICENSE.md @@ -0,0 +1,7 @@ +Copyright 2018 Frelia (@execfera) + +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. \ No newline at end of file diff --git a/README.md b/README.md index e69de29..fdc6145 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,165 @@ +# charasort +A web based character sorter. Allows users to run through a manual merge sort of their favorite +characters from a set. + +**Features** + * Entirely client side, no backend server required. + * Filtering out characters based on JSON based filters. + * Shareable links of sorter results. + * Versioning of sorter data - you may want to add characters and resources over time. Versioning keeps shareable links valid even if the base character data is changed. + +The version in this repo is built for characters from the [Touhou Project](https://en.wikipedia.org/wiki/Touhou_Project) +game series, but the sorter can be easily edited to create any custom sorter desired. + +## Related Sorters +Several others have created other sorters based on other concepts and series, see them [here](https://github.com/execfera/charasort/wiki)! + +## Creating Your Own Sorter +This is a list of things you need to change for your sorter, for each file. + + * `index.html` + * Sorter name: Change under `starting start button` and the `` tags. + * Starting banner images: 120px x 180px, under `left sort image` and `right sort image`. + * OpenGraph tags: `og:site_name`, `og:description` and `og:image` will show up on embeds when linked to social media such as Facebook, Twitter and Discord. + * Sorter info: Insert whatever you like under the `info` tag. + * Website icon: Remember to get your own `favicon.ico`! + + * `src/js/data.js` + + Change `imageRoot` if you are not uploading your images to imgur. + + * `src/js/data/YYYY-MM-DD.js` + + Creating your own set of data is relatively simple. First, change the `dataSetVersion` date to the date when you are creating the dataset. Example: `dataSetVersion = 2018-02-20`. The actual filename does not matter, it is just for your own easy reference. + + Further down, each file comprises of two sets of data: `characterData` and `options`. + + `characterData` is an array of objects filled with character data. Its layout is as follows. + + ``` + { + name: string, + img: string, + opts: { + key1: boolean | string[], + key2: boolean | string[], + ... + } + } + ``` + + Parameters: + + * `name`: The name of the character to be displayed. **Required.** + * `img`: An image filename of the character, in 120px x 180px, to be added to `imageRoot` in `data.js`. **Required.** + * `opts`: An object of 'options' that will be used to filter out characters that will be used. Further explanation below. **Required.** + + Example: + + ``` + { + name: "Flandre Scarlet", + img: "OhaDcnc.png", + opts: { + series: ["book", "EoSD", "StB"], + stage: ["ex"], + loli: true + } + } + ``` + + `options` is an array of objects that can take either two forms. The first form is a **Basic Filter**. The Basic Filter, when selected, removes any character that matches its criteria. Its layout is as follows. + + ``` + { + name: string, + key: string, + tooltip?: string, // optional + checked?: boolean, // optional + } + ``` + + Parameters: + + * `name`: The name of the option to be displayed. **Required.** + * `key`: A shorthand reference, used to refer to it in the character data. **Required.** + * `tooltip`: Some optional information that appears when you hover over the option. If not provided, defaults to the option's name. + * `checked`: If set to `true`, this option will be checked when your sorter starts. If not provided, defaults to `false`. + + Example: + + ``` + { + name: 'Filter Lolis', + key: 'loli', + tooltip: 'Check this if you want to remove lolis from being listed.' + checked: true, + } + ``` + + In this example, checking this option would remove the example 'Flandre Scarlet' above from the list of sorted characters, since she has `loli` set to `true`. The `checked` option is true, so in this sorter, it would be enabled by default. + + The second form is a **Nested Inclusion Filter**. The Nested Inclusion Filter has a few sub-options under it. When selected, any options under it that are *not* selected will be excluded from the sort. Its layout is similar to the Basic Filter, except with an extra `sub` part, which lists the sub-options. + + ``` + { + name: string, + key: string, + tooltip?: string, // optional + checked?: boolean, // optional + sub: [ + { + name: string, + key: string, + tooltip?: string, // optional + checked?: boolean, // optional + }, + { + name: string, + key: string, + tooltip?: string, // optional + checked?: boolean, // optional + }, + ... + ] + } + ``` + + This option will be often the only one you may need, since it is easy to use it for filtering by series. + + Example: + + ``` + { + name: 'Filter by Series Appearance', + key: 'series', + tooltip: 'Check this if you want to filter out certain series.' + checked: true, + sub: [ + { name: 'Books & CDs', key: 'book' }, + { name: 'Embodiment of Scarlet Devil', key: 'EoSD' }, + { name: 'Perfect Cherry Blossom', key: 'PCB' }, + ] + } + ``` + + In this case, this would create a "Filter by Series Appearance" option, with the three listed sub-options. "Flandre Scarlet" above has both `book` and `EoSD` under `series`, so unless you uncheck both "Books & CDs" and "Embodiment of Scarlet Devil", she would still appear in the sort. + +## Updating Your Own Sorter + +When you need to add more characters to your sorter, you must create a new data file with a new date, and include it in your `index.html` file under the `<script src="src/js/data.js"></script>` line, while keeping your previous data files also included. + +The script will automatically get the latest version, but will retain the previous versions in case someone keeps a shareable link from one of the previous versions. + +## Credits + + * [html2canvas](https://github.com/niklasvh/html2canvas/) for image generation. + * [seedrandom](https://github.com/davidbau/seedrandom) for PRNG used in character array shuffling. + * [lz-string](https://github.com/pieroxy/lz-string) for shareable link compression. + * [SpinKit](http://tobiasahlin.com/spinkit/) for loading animation. + * [thsort](http://mainyan.sakura.ne.jp/thsort.html) for the original inspiration. + +## Known Issues + + * Does not work with CloudFlare's Rocket Loader. + * Breaks on older versions of IE and mobile Safari, due to various incompatibilities. diff --git a/charasort b/charasort new file mode 160000 index 0000000..8a44c34 --- /dev/null +++ b/charasort @@ -0,0 +1 @@ +Subproject commit 8a44c3480a9659449fae46d55fb966ce1a410a33 diff --git a/index.html b/index.html new file mode 100644 index 0000000..344ca09 --- /dev/null +++ b/index.html @@ -0,0 +1,87 @@ +<html> + +<head> + <link rel="shortcut icon" href="src/assets/tonk.png" type="image/x-icon"> + <link rel="icon" href="src/assets/tonk.png" type="image/x-icon"> + <meta charset="utf-8"> + <meta name="og:site_name" content="GuP Character Sorting"> + <meta name="og:description" content="A simple website for sorting GuP characters in a formatted list."> + <meta name="og:image" content="https://i.imgur.com/IZzJMk6.jpg"> + <title>GuP Character Sorting + + + + + + + + + + + + + + +
+ +
+ +
+
+
+
+ +
+ + +
GuP Character Sorter

Click to Start!
+
Load
+ +
Loading...
+ +
Tie
+
Undo
+
Save Progress
+ +
Generate Result URL
+
Generate Image
+
Generate Text List
+ + + +

+

+
+ +
+
Display Images on Result:
+
+
+ +
+ Contact | Source Code (soon™) | Best Taste | Clear Saved Data + +

+ +

Sorter for GuP characters. Pick your sources, and hit the Start button.

+

Certain options have details that you can hover to read.

+

This is a project adapted from the Touhou character sorter that can be found here. + +

+ +

Keyboard controls during sorting: H/LeftArrow (pick left) J/DownArrow (undo) K/UpArrow (tie) L/RightArrow (pick right) S (save progress).

+

Before sorting: S/Enter (start sorting) L (load progress). +

1/2/3 always correspond to the first/second/third buttons.

+ +

+ +

Thumbnail Art from >mal. Ideally this will be changed along with adding the sequels/mangos.

+ +

+ +

May 10th, 2022 - Added Girls & Panzer (the original series).

+
+
+ + + diff --git a/pull.sh b/pull.sh new file mode 100755 index 0000000..df85638 --- /dev/null +++ b/pull.sh @@ -0,0 +1 @@ +rsync -rtvzP root@kikurage.moe:/var/www/kikurage/ ~/git/kikurage/src/ diff --git a/push.sh b/push.sh new file mode 100755 index 0000000..b67d92c --- /dev/null +++ b/push.sh @@ -0,0 +1 @@ +rsync -rtvzP ~/git/charasort root@junko.cafe:/var/www/GuP-sorter diff --git a/src/assets/__nishizumi_miho_akiyama_yukari_takebe_saori_reizei_mako_isuzu_hana_and_23_more_girls_und_panzer__d6cf970e7eac2095623eafa834d7f12c.jpg b/src/assets/__nishizumi_miho_akiyama_yukari_takebe_saori_reizei_mako_isuzu_hana_and_23_more_girls_und_panzer__d6cf970e7eac2095623eafa834d7f12c.jpg new file mode 100644 index 0000000..12e6f4f Binary files /dev/null and b/src/assets/__nishizumi_miho_akiyama_yukari_takebe_saori_reizei_mako_isuzu_hana_and_23_more_girls_und_panzer__d6cf970e7eac2095623eafa834d7f12c.jpg differ diff --git a/src/assets/anchovyu.png b/src/assets/anchovyu.png new file mode 100644 index 0000000..7c79c9f Binary files /dev/null and b/src/assets/anchovyu.png differ diff --git a/src/assets/defaultL.jpg b/src/assets/defaultL.jpg new file mode 100644 index 0000000..a76e3f1 Binary files /dev/null and b/src/assets/defaultL.jpg differ diff --git a/src/assets/defaultR.jpg b/src/assets/defaultR.jpg new file mode 100644 index 0000000..5a30146 Binary files /dev/null and b/src/assets/defaultR.jpg differ diff --git a/src/assets/floof.jpg b/src/assets/floof.jpg new file mode 100644 index 0000000..7422004 Binary files /dev/null and b/src/assets/floof.jpg differ diff --git a/src/assets/girls-und-panzer-finale-KV-Cropped.jpg b/src/assets/girls-und-panzer-finale-KV-Cropped.jpg new file mode 100644 index 0000000..ecfde4f Binary files /dev/null and b/src/assets/girls-und-panzer-finale-KV-Cropped.jpg differ diff --git a/src/assets/kay.jpg b/src/assets/kay.jpg new file mode 100644 index 0000000..18ca577 Binary files /dev/null and b/src/assets/kay.jpg differ diff --git a/src/assets/tonk.png b/src/assets/tonk.png new file mode 100644 index 0000000..3a70b7a Binary files /dev/null and b/src/assets/tonk.png differ diff --git a/src/assets/yinyang.ico b/src/assets/yinyang.ico new file mode 100644 index 0000000..799cfc0 Binary files /dev/null and b/src/assets/yinyang.ico differ diff --git a/src/css/reset.css b/src/css/reset.css new file mode 100644 index 0000000..af94440 --- /dev/null +++ b/src/css/reset.css @@ -0,0 +1,48 @@ +/* http://meyerweb.com/eric/tools/css/reset/ + v2.0 | 20110126 + License: none (public domain) +*/ + +html, body, div, span, applet, object, iframe, +h1, h2, h3, h4, h5, h6, p, blockquote, pre, +a, abbr, acronym, address, big, cite, code, +del, dfn, em, img, ins, kbd, q, s, samp, +small, strike, strong, sub, sup, tt, var, +b, u, i, center, +dl, dt, dd, ol, ul, li, +fieldset, form, label, legend, +table, caption, tbody, tfoot, thead, tr, th, td, +article, aside, canvas, details, embed, +figure, figcaption, footer, header, hgroup, +menu, nav, output, ruby, section, summary, +time, mark, audio, video { + margin: 0; + padding: 0; + border: 0; + font-size: 100%; + font: inherit; + vertical-align: baseline; +} +/* HTML5 display-role reset for older browsers */ +article, aside, details, figcaption, figure, +footer, header, hgroup, menu, nav, section { + display: block; +} +body { + line-height: 1; +} +ol, ul { + list-style: none; +} +blockquote, q { + quotes: none; +} +blockquote:before, blockquote:after, +q:before, q:after { + content: ''; + content: none; +} +table { + border-collapse: collapse; + border-spacing: 0; +} \ No newline at end of file diff --git a/src/css/styles.css b/src/css/styles.css new file mode 100644 index 0000000..0099969 --- /dev/null +++ b/src/css/styles.css @@ -0,0 +1,286 @@ +body { + font-family: Arial, Helvetica, sans-serif; + font-size: 16px; +} + +.container { + display: flex; + flex-flow: column nowrap; + align-items: center; + margin-top: 1em; +} + +.progress { + margin: 1em auto; + width: 500px; + display: none; +} + +.progressbar { + position: relative; + width: 492px; + border: 1px solid black; + padding: 3px; + margin: 2px 0px; +} + +.progresstext { + position: absolute; + width: 492px; + margin: 3px 0px; + text-align: center; + font-size: 0.7em; +} + +.progressfill { + height: 20px; + background-color: lightgreen; + width: 0%; +} + +.sorter { + margin: 0px auto; + display: grid; + grid-template-columns: 120px 1fr 120px; + grid-gap: 5px; + width: 420px; +} + +.button { + border: 1px solid black; + text-align: center; + padding: 10%; + grid-column: 2 / 3; + cursor: pointer; +} + +.starting.start.button { + grid-row: span 6; +} + +.starting.load.button { + grid-row: span 3; + display: none; +} + +.sorting.button, .finished.button { + grid-row: span 2; + display: none; +} + +.loading.button { + grid-row: span 6; + display: none; +} + +.loading.button > div { + width: 25px; + height: 25px; + margin: 50px auto; + background-color: #333; + + border-radius: 100%; + -webkit-animation: sk-scaleout 1.0s infinite ease-in-out; + animation: sk-scaleout 1.0s infinite ease-in-out; +} + +/* Animation taken from: http://tobiasahlin.com/spinkit/ */ + +.loading.button > span { + margin: auto auto 20%; + font-size: 0.7em; +} + +@-webkit-keyframes sk-scaleout { + 0% { -webkit-transform: scale(0) } + 100% { + -webkit-transform: scale(1.0); + opacity: 0; + } +} + +@keyframes sk-scaleout { + 0% { + -webkit-transform: scale(0); + transform: scale(0); + } 100% { + -webkit-transform: scale(1.0); + transform: scale(1.0); + opacity: 0; + } +} + +.sorter > .image { + width: 120px; + height: 180px; + margin: auto; + grid-row: 1 / 7; + cursor: pointer; +} + +.sorter > .text { + width: 120px; + height: 60px; + display: none; +} + +.sorter > .text > p { + margin: 0.5em 5px 0px; + width: calc(100%-10px); + text-align: center; + font-size: 0.8em; + line-height: 1.5em; +} + +.sorter > .left { + grid-column: 1 / 2; + border: 1px solid #000000; +} + +.sorter > .right { + grid-column: 3 / 4; + border: 1px solid #000000; +} + +.options { + margin: 1em auto; + display: grid; + text-align: left; + grid-template-columns: repeat(3, 1fr); + grid-gap: 10px; + width: 450px; +} + +.options > div { + font-size: 0.5625em; +} + +label { + cursor: pointer; +} + +label:hover { + color: #990000; +} + +.options > .large.option, .options > hr { + grid-column: span 3; + text-align: center; + width: 100%; +} + +.image.selector { + margin-top: 0.5em; + width: 500px; + display: none; + text-align: center; + font-size: 0.75em; +} + +.time.taken { + margin-top: 0.5em; + width: 500px; + display: none; + text-align: center; + font-size: 0.75em; +} + +.results { + font-size: 0.75em; + display: flex; + align-content: flex-start; + width: 80%; + margin: 2em auto; +} + +@media all and (min-width: 600px) { + .results { + flex-flow: column wrap; + max-height: calc(5 * (175px + 2px) + 1 * (15px + 2px)); + /* 2px for borders */ + } +} + +@media all and (max-width: 600px) { + .results { + flex-flow: column nowrap; + } +} + +.result { + height: 15px; + margin-bottom: -1px; + display: grid; + width: 211px; + grid-template-columns: repeat(2, 1fr); + border: 1px solid #000; + margin-right: 5px; +} + +.result.image { + height: 175px; +} + +.result.image img { + height: 160px; +} + +.result.spacer { + height: 1px; + background-color: #000; +} + +.result.head { + background-color: #000; + color: #FFF; +} + +.result > .left { + width: 35px; + padding: 1px 3px 1px 0.5em; + grid-column: 1 / 2; + text-align: right; +} + +.result.image .left { + position: relative; +} + +.result.image > .left span { + position: absolute; + top: 50%; + right: 3px; + margin-top: -0.375em; +} + +.result > .right { + width: 160px; + padding: 1px 0em 1px 0em; + grid-column: 2 / 3; + border-left: 1px solid #000; + text-align: center; +} + +.info { + margin: 2em auto 3em; + display: block; + text-align: center; + font-size: 0.6875em; + width: 80%; + line-height: 1.2em; +} + +a { + color: #990000; + font-weight: bold; + text-decoration: none; + cursor: pointer; +} + +a:hover { + color: #FF6600; +} + +a:visited { + color: #6600FF; +} \ No newline at end of file diff --git a/src/js/build-dataset.py b/src/js/build-dataset.py new file mode 100644 index 0000000..594d178 --- /dev/null +++ b/src/js/build-dataset.py @@ -0,0 +1,21 @@ +import requests +import re + +URL = "https://myanimelist.net/anime/14131/Girls___Panzer/characters" +re_character = '\"(.*)\"} +*/ +const dataSet = {}; + +/** + * Data set version, in YYYY-MM-DD form. + * + * @example '2018-02-20' +*/ +let dataSetVersion = ''; + +/** + * Image root, will be appended to the start of every image URL. + */ +const imageRoot = 'https://cdn.myanimelist.net/images/characters/'; diff --git a/src/js/data/2022-05-10.js b/src/js/data/2022-05-10.js new file mode 100644 index 0000000..6b0c4eb --- /dev/null +++ b/src/js/data/2022-05-10.js @@ -0,0 +1,246 @@ +dataSetVersion = "2022-05-10"; // Change this when creating a new data set version. YYYY-MM-DD format. +dataSet[dataSetVersion] = {}; + +dataSet[dataSetVersion].options = [ + { + name: "Filter by Series Entry", + key: "series", + tooltip: "Check this to restrict to certain series.", + checked: false, + sub: [ + { name: "Girls & Panzer", tooltip: "Girls & Panzer", key: "GP" }, + ] + }, +]; + +dataSet[dataSetVersion].characterData = [ +{name: "Akiyama, Yukari", + img: "13/220639.jpg", + opts: {} + }, +{name: "Isuzu, Hana", + img: "14/183595.jpg", + opts: {} + }, +{name: "Nishizumi, Miho", + img: "15/208209.jpg", + opts: {} + }, +{name: "Reizei, Mako", + img: "3/253025.jpg", + opts: {} + }, +{name: "Takebe, Saori", + img: "9/253031.jpg", + opts: {} + }, +{name: "Akaboshi, Koume", + img: "6/264545.jpg", + opts: {} + }, +{name: "Akiyama, Jungorou", + img: "10/251349.jpg", + opts: {} + }, +{name: "Akiyama, Yoshiko", + img: "3/251319.jpg", + opts: {} + }, +{name: "Alisa", + img: "8/186485.jpg", + opts: {} + }, +{name: "Anzai, Chiyomi", + img: "5/277937.jpg", + opts: {} + }, +{name: "Assam", + img: "3/185595.jpg", + opts: {} + }, +{name: "Chouno, Ami", + img: "13/184299.jpg", + opts: {} + }, +{name: "Darjeeling", + img: "10/355674.jpg", + opts: {} + }, +{name: "Gotou, Moyoko", + img: "12/249083.jpg", + opts: {} + }, +{name: "Hoshino", + img: "5/200517.jpg", + opts: {} + }, +{name: "Inatomi, Hibiki", + img: "9/266043.jpg", + opts: {} + }, +{name: "Isobe, Noriko", + img: "4/306126.jpg", + opts: {} + }, +{name: "Isuzu, Yuri", + img: "14/200523.jpg", + opts: {} + }, +{name: "Itsumi, Erika", + img: "2/360836.jpg", + opts: {} + }, +{name: "Kadotani, Anzu", + img: "9/229625.jpg", + opts: {} + }, +{name: "Katyusha", + img: "14/193255.jpg", + opts: {} + }, +{name: "Kawanishi, Shinobu", + img: "14/449666.jpg", + opts: {} + }, +{name: "Kawashima, Momo", + img: "2/184305.jpg", + opts: {} + }, +{name: "Kei", + img: "14/381763.jpg", + opts: {} + }, +{name: "Kondou, Taeko", + img: "11/391698.jpg", + opts: {} + }, +{name: "Konparu, Nozomi", + img: "13/249081.jpg", + opts: {} + }, +{name: "Koyama, Yuzu", + img: "12/191392.jpg", + opts: {} + }, +{name: "Maruyama, Saki", + img: "2/184293.jpg", + opts: {} + }, +{name: "Matsumoto, Riko", + img: "3/186191.jpg", + opts: {} + }, +{name: "Momoga", + img: "14/190906.jpg", + opts: {} + }, +{name: "Nakajima, Satoko", + img: "7/200519.jpg", + opts: {} + }, +{name: "Naomi", + img: "16/187787.jpg", + opts: {} + }, +{name: "Nekota", + img: "8/190904.jpg", + opts: {} + }, +{name: "Nilgiri", + img: "3/441097.jpg", + opts: {} + }, +{name: "Nishizumi, Maho", + img: "9/200657.jpg", + opts: {} + }, +{name: "Nishizumi, Shiho", + img: "2/249079.jpg", + opts: {} + }, +{name: "Nogami, Takeko", + img: "12/184467.jpg", + opts: {} + }, +{name: "Nonna", + img: "10/197747.jpg", + opts: {} + }, +{name: "Oono, Aya", + img: "3/184301.jpg", + opts: {} + }, +{name: "Orange Pekoe", + img: "13/185597.jpg", + opts: {} + }, +{name: "Ou, Taiga", + img: "6/252081.jpg", + opts: {} + }, +{name: "Piyotan", + img: "12/190908.jpg", + opts: {} + }, +{name: "Reizei, Hisako", + img: "8/249077.jpg", + opts: {} + }, +{name: "Rukuriri", + img: "16/313972.jpg", + opts: {} + }, +{name: "Sakaguchi, Karina", + img: "9/184297.jpg", + opts: {} + }, +{name: "Sasagawa, Kanon", + img: "3/266041.jpg", + opts: {} + }, +{name: "Sasaki, Akebi", + img: "11/251325.jpg", + opts: {} + }, +{name: "Sawa, Azusa", + img: "7/187799.jpg", + opts: {} + }, +{name: "Shinzaburou", + img: "8/190910.jpg", + opts: {} + }, +{name: "Sono, Midoriko", + img: "12/185967.jpg", + opts: {} + }, +{name: "Sugiyama, Kiyomi", + img: "14/184577.jpg", + opts: {} + }, +{name: "Suzuki", + img: "6/251329.jpg", + opts: {} + }, +{name: "Suzuki, Takako", + img: "9/184579.jpg", + opts: {} + }, +{name: "Takashima, Remi", + img: "12/266045.jpg", + opts: {} + }, +{name: "Tsuchiya", + img: "7/200521.jpg", + opts: {} + }, +{name: "Utsugi, Yuuki", + img: "16/184291.jpg", + opts: {} + }, +{name: "Yamagou, Ayumi", + img: "11/184295.jpg", + opts: {} + } + +]; diff --git a/src/js/html2canvas.min.js b/src/js/html2canvas.min.js new file mode 100644 index 0000000..3095709 --- /dev/null +++ b/src/js/html2canvas.min.js @@ -0,0 +1,6 @@ +/*! + * html2canvas 1.0.0-alpha.10 + * Copyright (c) 2018 Niklas von Hertzen + * Released under MIT License + */ +!function(A,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.html2canvas=e():A.html2canvas=e()}(this,function(){return function(A){var e={};function t(r){if(e[r])return e[r].exports;var n=e[r]={i:r,l:!1,exports:{}};return A[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}return t.m=A,t.c=e,t.d=function(A,e,r){t.o(A,e)||Object.defineProperty(A,e,{configurable:!1,enumerable:!0,get:r})},t.n=function(A){var e=A&&A.__esModule?function(){return A.default}:function(){return A};return t.d(e,"a",e),e},t.o=function(A,e){return Object.prototype.hasOwnProperty.call(A,e)},t.p="",t(t.s=27)}([function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){return function(A,e){if(Array.isArray(A))return A;if(Symbol.iterator in Object(A))return function(A,e){var t=[],r=!0,n=!1,B=void 0;try{for(var a,s=A[Symbol.iterator]();!(r=(a=s.next()).done)&&(t.push(a.value),!e||t.length!==e);r=!0);}catch(A){n=!0,B=A}finally{try{!r&&s.return&&s.return()}finally{if(n)throw B}}return t}(A,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=function(){function A(A,e){for(var t=0;t4)&&[Number(e[1]),Number(e[2]),Number(e[3]),Number(e[4])]},Q=function(A){return[Math.min(A[0],255),Math.min(A[1],255),Math.min(A[2],255),A.length>3?A[3]:null]},w=function(A){var e=g[A.toLowerCase()];return e||!1},U=function(){function A(e){!function(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")}(this,A);var t=Array.isArray(e)?Q(e):a(e)||c(e)||u(e)||w(e)||o(e)||[0,0,0,null],n=r(t,4),B=n[0],s=n[1],i=n[2],l=n[3];this.r=B,this.g=s,this.b=i,this.a=l}return n(A,[{key:"isTransparent",value:function(){return 0===this.a}},{key:"toString",value:function(){return null!==this.a&&1!==this.a?"rgba("+this.r+","+this.g+","+this.b+","+this.a+")":"rgb("+this.r+","+this.g+","+this.b+")"}}]),A}();e.default=U;var g={transparent:[0,0,0,0],aliceblue:[240,248,255,null],antiquewhite:[250,235,215,null],aqua:[0,255,255,null],aquamarine:[127,255,212,null],azure:[240,255,255,null],beige:[245,245,220,null],bisque:[255,228,196,null],black:[0,0,0,null],blanchedalmond:[255,235,205,null],blue:[0,0,255,null],blueviolet:[138,43,226,null],brown:[165,42,42,null],burlywood:[222,184,135,null],cadetblue:[95,158,160,null],chartreuse:[127,255,0,null],chocolate:[210,105,30,null],coral:[255,127,80,null],cornflowerblue:[100,149,237,null],cornsilk:[255,248,220,null],crimson:[220,20,60,null],cyan:[0,255,255,null],darkblue:[0,0,139,null],darkcyan:[0,139,139,null],darkgoldenrod:[184,134,11,null],darkgray:[169,169,169,null],darkgreen:[0,100,0,null],darkgrey:[169,169,169,null],darkkhaki:[189,183,107,null],darkmagenta:[139,0,139,null],darkolivegreen:[85,107,47,null],darkorange:[255,140,0,null],darkorchid:[153,50,204,null],darkred:[139,0,0,null],darksalmon:[233,150,122,null],darkseagreen:[143,188,143,null],darkslateblue:[72,61,139,null],darkslategray:[47,79,79,null],darkslategrey:[47,79,79,null],darkturquoise:[0,206,209,null],darkviolet:[148,0,211,null],deeppink:[255,20,147,null],deepskyblue:[0,191,255,null],dimgray:[105,105,105,null],dimgrey:[105,105,105,null],dodgerblue:[30,144,255,null],firebrick:[178,34,34,null],floralwhite:[255,250,240,null],forestgreen:[34,139,34,null],fuchsia:[255,0,255,null],gainsboro:[220,220,220,null],ghostwhite:[248,248,255,null],gold:[255,215,0,null],goldenrod:[218,165,32,null],gray:[128,128,128,null],green:[0,128,0,null],greenyellow:[173,255,47,null],grey:[128,128,128,null],honeydew:[240,255,240,null],hotpink:[255,105,180,null],indianred:[205,92,92,null],indigo:[75,0,130,null],ivory:[255,255,240,null],khaki:[240,230,140,null],lavender:[230,230,250,null],lavenderblush:[255,240,245,null],lawngreen:[124,252,0,null],lemonchiffon:[255,250,205,null],lightblue:[173,216,230,null],lightcoral:[240,128,128,null],lightcyan:[224,255,255,null],lightgoldenrodyellow:[250,250,210,null],lightgray:[211,211,211,null],lightgreen:[144,238,144,null],lightgrey:[211,211,211,null],lightpink:[255,182,193,null],lightsalmon:[255,160,122,null],lightseagreen:[32,178,170,null],lightskyblue:[135,206,250,null],lightslategray:[119,136,153,null],lightslategrey:[119,136,153,null],lightsteelblue:[176,196,222,null],lightyellow:[255,255,224,null],lime:[0,255,0,null],limegreen:[50,205,50,null],linen:[250,240,230,null],magenta:[255,0,255,null],maroon:[128,0,0,null],mediumaquamarine:[102,205,170,null],mediumblue:[0,0,205,null],mediumorchid:[186,85,211,null],mediumpurple:[147,112,219,null],mediumseagreen:[60,179,113,null],mediumslateblue:[123,104,238,null],mediumspringgreen:[0,250,154,null],mediumturquoise:[72,209,204,null],mediumvioletred:[199,21,133,null],midnightblue:[25,25,112,null],mintcream:[245,255,250,null],mistyrose:[255,228,225,null],moccasin:[255,228,181,null],navajowhite:[255,222,173,null],navy:[0,0,128,null],oldlace:[253,245,230,null],olive:[128,128,0,null],olivedrab:[107,142,35,null],orange:[255,165,0,null],orangered:[255,69,0,null],orchid:[218,112,214,null],palegoldenrod:[238,232,170,null],palegreen:[152,251,152,null],paleturquoise:[175,238,238,null],palevioletred:[219,112,147,null],papayawhip:[255,239,213,null],peachpuff:[255,218,185,null],peru:[205,133,63,null],pink:[255,192,203,null],plum:[221,160,221,null],powderblue:[176,224,230,null],purple:[128,0,128,null],rebeccapurple:[102,51,153,null],red:[255,0,0,null],rosybrown:[188,143,143,null],royalblue:[65,105,225,null],saddlebrown:[139,69,19,null],salmon:[250,128,114,null],sandybrown:[244,164,96,null],seagreen:[46,139,87,null],seashell:[255,245,238,null],sienna:[160,82,45,null],silver:[192,192,192,null],skyblue:[135,206,235,null],slateblue:[106,90,205,null],slategray:[112,128,144,null],slategrey:[112,128,144,null],snow:[255,250,250,null],springgreen:[0,255,127,null],steelblue:[70,130,180,null],tan:[210,180,140,null],teal:[0,128,128,null],thistle:[216,191,216,null],tomato:[255,99,71,null],turquoise:[64,224,208,null],violet:[238,130,238,null],wheat:[245,222,179,null],white:[255,255,255,null],whitesmoke:[245,245,245,null],yellow:[255,255,0,null],yellowgreen:[154,205,50,null]};e.TRANSPARENT=new U([0,0,0,0])},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.parseBoundCurves=e.calculatePaddingBoxPath=e.calculateBorderBoxPath=e.parsePathForBorder=e.parseDocumentSize=e.calculateContentBox=e.calculatePaddingBox=e.parseBounds=e.Bounds=void 0;var r=function(){function A(A,e){for(var t=0;t1&&(r/=U,B/=U,a/=U,s/=U,o/=U,l/=U,u/=U,Q/=U);var g=A.width-a,C=A.height-l,d=A.width-o,F=A.height-Q;return{topLeftOuter:r>0||B>0?c(A.left,A.top,r,B,i.TOP_LEFT):new n.default(A.left,A.top),topLeftInner:r>0||B>0?c(A.left+e[3].borderWidth,A.top+e[0].borderWidth,Math.max(0,r-e[3].borderWidth),Math.max(0,B-e[0].borderWidth),i.TOP_LEFT):new n.default(A.left+e[3].borderWidth,A.top+e[0].borderWidth),topRightOuter:a>0||s>0?c(A.left+g,A.top,a,s,i.TOP_RIGHT):new n.default(A.left+A.width,A.top),topRightInner:a>0||s>0?c(A.left+Math.min(g,A.width+e[3].borderWidth),A.top+e[0].borderWidth,g>A.width+e[3].borderWidth?0:a-e[3].borderWidth,s-e[0].borderWidth,i.TOP_RIGHT):new n.default(A.left+A.width-e[1].borderWidth,A.top+e[0].borderWidth),bottomRightOuter:o>0||l>0?c(A.left+d,A.top+C,o,l,i.BOTTOM_RIGHT):new n.default(A.left+A.width,A.top+A.height),bottomRightInner:o>0||l>0?c(A.left+Math.min(d,A.width-e[3].borderWidth),A.top+Math.min(C,A.height+e[0].borderWidth),Math.max(0,o-e[1].borderWidth),l-e[2].borderWidth,i.BOTTOM_RIGHT):new n.default(A.left+A.width-e[1].borderWidth,A.top+A.height-e[2].borderWidth),bottomLeftOuter:u>0||Q>0?c(A.left,A.top+F,u,Q,i.BOTTOM_LEFT):new n.default(A.left,A.top+A.height),bottomLeftInner:u>0||Q>0?c(A.left+e[3].borderWidth,A.top+F,Math.max(0,u-e[3].borderWidth),Q-e[2].borderWidth,i.BOTTOM_LEFT):new n.default(A.left+e[3].borderWidth,A.top+A.height-e[2].borderWidth)}},{TOP_LEFT:0,TOP_RIGHT:1,BOTTOM_RIGHT:2,BOTTOM_LEFT:3}),c=function(A,e,t,r,a){var s=(Math.sqrt(2)-1)/3*4,o=t*s,c=r*s,l=A+t,u=e+r;switch(a){case i.TOP_LEFT:return new B.default(new n.default(A,u),new n.default(A,u-c),new n.default(l-o,e),new n.default(l,e));case i.TOP_RIGHT:return new B.default(new n.default(A,e),new n.default(A+o,e),new n.default(l,u-c),new n.default(l,u));case i.BOTTOM_RIGHT:return new B.default(new n.default(l,e),new n.default(l,e+c),new n.default(A+o,u),new n.default(A,u));case i.BOTTOM_LEFT:default:return new B.default(new n.default(l,u),new n.default(l-o,u),new n.default(A,e+c),new n.default(A,e))}}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.calculateLengthFromValueWithUnit=e.LENGTH_TYPE=void 0;var r,n=function(){function A(A,e){for(var t=0;t0&&this.style.visibility===I.VISIBILITY.VISIBLE}},{key:"isAbsolutelyPositioned",value:function(){return this.style.position!==f.POSITION.STATIC&&this.style.position!==f.POSITION.RELATIVE}},{key:"isPositioned",value:function(){return this.style.position!==f.POSITION.STATIC}},{key:"isFloating",value:function(){return this.style.float!==u.FLOAT.NONE}},{key:"isRootElement",value:function(){return null===this.parent}},{key:"isTransformed",value:function(){return null!==this.style.transform}},{key:"isPositionedWithZIndex",value:function(){return this.isPositioned()&&!this.style.zIndex.auto}},{key:"isInlineLevel",value:function(){return(0,s.contains)(this.style.display,l.DISPLAY.INLINE)||(0,s.contains)(this.style.display,l.DISPLAY.INLINE_BLOCK)||(0,s.contains)(this.style.display,l.DISPLAY.INLINE_FLEX)||(0,s.contains)(this.style.display,l.DISPLAY.INLINE_GRID)||(0,s.contains)(this.style.display,l.DISPLAY.INLINE_LIST_ITEM)||(0,s.contains)(this.style.display,l.DISPLAY.INLINE_TABLE)}},{key:"isInlineBlockOrInlineTable",value:function(){return(0,s.contains)(this.style.display,l.DISPLAY.INLINE_BLOCK)||(0,s.contains)(this.style.display,l.DISPLAY.INLINE_TABLE)}}]),A}();e.default=S;var L=function(A,e){if(A instanceof A.ownerDocument.defaultView.SVGSVGElement||A instanceof SVGSVGElement){var t=new XMLSerializer;return e.loadImage("data:image/svg+xml,"+encodeURIComponent(t.serializeToString(A)))}switch(A.tagName){case"IMG":var r=A;return e.loadImage(r.currentSrc||r.src);case"CANVAS":var n=A;return e.loadCanvas(n);case"IFRAME":var B=A.getAttribute("data-html2canvas-internal-iframe-key");if(B)return B}return null}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.contains=function(A,e){return 0!=(A&e)},e.distance=function(A,e){return Math.sqrt(A*A+e*e)},e.copyCSSStyles=function(A,e){for(var t=A.length-1;t>=0;t--){var r=A.item(t);"content"!==r&&e.style.setProperty(r,A.getPropertyValue(r))}return e},e.SMALL_IMAGE="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.parseBackgroundImage=e.parseBackground=e.calculateBackgroundRepeatPath=e.calculateBackgroundPosition=e.calculateBackgroungPositioningArea=e.calculateBackgroungPaintingArea=e.calculateGradientBackgroundSize=e.calculateBackgroundSize=e.BACKGROUND_ORIGIN=e.BACKGROUND_CLIP=e.BACKGROUND_SIZE=e.BACKGROUND_REPEAT=void 0;var r=i(t(0)),n=i(t(2)),B=i(t(31)),a=i(t(7)),s=t(1),o=t(17);function i(A){return A&&A.__esModule?A:{default:A}}var c=e.BACKGROUND_REPEAT={REPEAT:0,NO_REPEAT:1,REPEAT_X:2,REPEAT_Y:3},l=e.BACKGROUND_SIZE={AUTO:0,CONTAIN:1,COVER:2,LENGTH:3},u=e.BACKGROUND_CLIP={BORDER_BOX:0,PADDING_BOX:1,CONTENT_BOX:2},Q=e.BACKGROUND_ORIGIN=u,w=function A(e){switch(function(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")}(this,A),e){case"contain":this.size=l.CONTAIN;break;case"cover":this.size=l.COVER;break;case"auto":this.size=l.AUTO;break;default:this.value=new n.default(e)}},U=(e.calculateBackgroundSize=function(A,e,t){var r=0,n=0,a=A.size;if(a[0].size===l.CONTAIN||a[0].size===l.COVER){var s=t.width/t.height,o=e.width/e.height;return s0&&(A=n.substr(0,e).toLowerCase(),n=n.substr(e)),"none"!==(n=n.toLowerCase())&&t.push({prefix:A,method:n,args:r})}r=[],n=a=""};return A.split("").forEach(function(A){if(0!==s||!e.test(A)){switch(A){case'"':B?B===A&&(B=null):B=A;break;case"(":if(B)break;if(0===s)return void(s=1);o++;break;case")":if(B)break;if(1===s){if(0===o)return s=0,void i();o--}break;case",":if(B)break;if(0===s)return void i();if(1===s&&0===o&&!n.match(/^url$/i))return r.push(a.trim()),void(a="")}0===s?n+=A:a+=A}}),i(),t}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.PATH={VECTOR:0,BEZIER_CURVE:1,CIRCLE:2}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t(6);e.default=function A(e,t){!function(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")}(this,A),this.type=r.PATH.VECTOR,this.x=e,this.y=t}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.parseListStyle=e.parseListStyleType=e.LIST_STYLE_TYPE=e.LIST_STYLE_POSITION=void 0;var r=t(5),n=e.LIST_STYLE_POSITION={INSIDE:0,OUTSIDE:1},B=e.LIST_STYLE_TYPE={NONE:-1,DISC:0,CIRCLE:1,SQUARE:2,DECIMAL:3,CJK_DECIMAL:4,DECIMAL_LEADING_ZERO:5,LOWER_ROMAN:6,UPPER_ROMAN:7,LOWER_GREEK:8,LOWER_ALPHA:9,UPPER_ALPHA:10,ARABIC_INDIC:11,ARMENIAN:12,BENGALI:13,CAMBODIAN:14,CJK_EARTHLY_BRANCH:15,CJK_HEAVENLY_STEM:16,CJK_IDEOGRAPHIC:17,DEVANAGARI:18,ETHIOPIC_NUMERIC:19,GEORGIAN:20,GUJARATI:21,GURMUKHI:22,HEBREW:22,HIRAGANA:23,HIRAGANA_IROHA:24,JAPANESE_FORMAL:25,JAPANESE_INFORMAL:26,KANNADA:27,KATAKANA:28,KATAKANA_IROHA:29,KHMER:30,KOREAN_HANGUL_FORMAL:31,KOREAN_HANJA_FORMAL:32,KOREAN_HANJA_INFORMAL:33,LAO:34,LOWER_ARMENIAN:35,MALAYALAM:36,MONGOLIAN:37,MYANMAR:38,ORIYA:39,PERSIAN:40,SIMP_CHINESE_FORMAL:41,SIMP_CHINESE_INFORMAL:42,TAMIL:43,TELUGU:44,THAI:45,TIBETAN:46,TRAD_CHINESE_FORMAL:47,TRAD_CHINESE_INFORMAL:48,UPPER_ARMENIAN:49,DISCLOSURE_OPEN:50,DISCLOSURE_CLOSED:51},a=e.parseListStyleType=function(A){switch(A){case"disc":return B.DISC;case"circle":return B.CIRCLE;case"square":return B.SQUARE;case"decimal":return B.DECIMAL;case"cjk-decimal":return B.CJK_DECIMAL;case"decimal-leading-zero":return B.DECIMAL_LEADING_ZERO;case"lower-roman":return B.LOWER_ROMAN;case"upper-roman":return B.UPPER_ROMAN;case"lower-greek":return B.LOWER_GREEK;case"lower-alpha":return B.LOWER_ALPHA;case"upper-alpha":return B.UPPER_ALPHA;case"arabic-indic":return B.ARABIC_INDIC;case"armenian":return B.ARMENIAN;case"bengali":return B.BENGALI;case"cambodian":return B.CAMBODIAN;case"cjk-earthly-branch":return B.CJK_EARTHLY_BRANCH;case"cjk-heavenly-stem":return B.CJK_HEAVENLY_STEM;case"cjk-ideographic":return B.CJK_IDEOGRAPHIC;case"devanagari":return B.DEVANAGARI;case"ethiopic-numeric":return B.ETHIOPIC_NUMERIC;case"georgian":return B.GEORGIAN;case"gujarati":return B.GUJARATI;case"gurmukhi":return B.GURMUKHI;case"hebrew":return B.HEBREW;case"hiragana":return B.HIRAGANA;case"hiragana-iroha":return B.HIRAGANA_IROHA;case"japanese-formal":return B.JAPANESE_FORMAL;case"japanese-informal":return B.JAPANESE_INFORMAL;case"kannada":return B.KANNADA;case"katakana":return B.KATAKANA;case"katakana-iroha":return B.KATAKANA_IROHA;case"khmer":return B.KHMER;case"korean-hangul-formal":return B.KOREAN_HANGUL_FORMAL;case"korean-hanja-formal":return B.KOREAN_HANJA_FORMAL;case"korean-hanja-informal":return B.KOREAN_HANJA_INFORMAL;case"lao":return B.LAO;case"lower-armenian":return B.LOWER_ARMENIAN;case"malayalam":return B.MALAYALAM;case"mongolian":return B.MONGOLIAN;case"myanmar":return B.MYANMAR;case"oriya":return B.ORIYA;case"persian":return B.PERSIAN;case"simp-chinese-formal":return B.SIMP_CHINESE_FORMAL;case"simp-chinese-informal":return B.SIMP_CHINESE_INFORMAL;case"tamil":return B.TAMIL;case"telugu":return B.TELUGU;case"thai":return B.THAI;case"tibetan":return B.TIBETAN;case"trad-chinese-formal":return B.TRAD_CHINESE_FORMAL;case"trad-chinese-informal":return B.TRAD_CHINESE_INFORMAL;case"upper-armenian":return B.UPPER_ARMENIAN;case"disclosure-open":return B.DISCLOSURE_OPEN;case"disclosure-closed":return B.DISCLOSURE_CLOSED;case"none":default:return B.NONE}},s=(e.parseListStyle=function(A){var e=(0,r.parseBackgroundImage)(A.getPropertyValue("list-style-image"));return{listStyleType:a(A.getPropertyValue("list-style-type")),listStyleImage:e.length?e[0]:null,listStylePosition:s(A.getPropertyValue("list-style-position"))}},function(A){switch(A){case"inside":return n.INSIDE;case"outside":default:return n.OUTSIDE}})},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function A(A,e){for(var t=0;t0?e+t.toUpperCase():A}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=t(23),n=function(A){return 0===A[0]&&255===A[1]&&0===A[2]&&255===A[3]},B={get SUPPORT_RANGE_BOUNDS(){var A=function(A){if(A.createRange){var e=A.createRange();if(e.getBoundingClientRect){var t=A.createElement("boundtest");t.style.height="123px",t.style.display="block",A.body.appendChild(t),e.selectNode(t);var r=e.getBoundingClientRect(),n=Math.round(r.height);if(A.body.removeChild(t),123===n)return!0}}return!1}(document);return Object.defineProperty(B,"SUPPORT_RANGE_BOUNDS",{value:A}),A},get SUPPORT_SVG_DRAWING(){var A=function(A){var e=new Image,t=A.createElement("canvas"),r=t.getContext("2d");e.src="data:image/svg+xml,";try{r.drawImage(e,0,0),t.toDataURL()}catch(A){return!1}return!0}(document);return Object.defineProperty(B,"SUPPORT_SVG_DRAWING",{value:A}),A},get SUPPORT_BASE64_DRAWING(){return function(A){var e=function(A,e){var t=new Image,r=A.createElement("canvas"),n=r.getContext("2d");return new Promise(function(A){t.src=e;var B=function(){try{n.drawImage(t,0,0),r.toDataURL()}catch(e){return A(!1)}return A(!0)};t.onload=B,t.onerror=function(){return A(!1)},!0===t.complete&&setTimeout(function(){B()},500)})}(document,A);return Object.defineProperty(B,"SUPPORT_BASE64_DRAWING",{value:function(){return e}}),e}},get SUPPORT_FOREIGNOBJECT_DRAWING(){var A="function"==typeof Array.from&&"function"==typeof window.fetch?function(A){var e=A.createElement("canvas");e.width=100,e.height=100;var t=e.getContext("2d");t.fillStyle="rgb(0, 255, 0)",t.fillRect(0,0,100,100);var B=new Image,a=e.toDataURL();B.src=a;var s=(0,r.createForeignObjectSVG)(100,100,0,0,B);return t.fillStyle="red",t.fillRect(0,0,100,100),(0,r.loadSerializedSVG)(s).then(function(e){t.drawImage(e,0,0);var B=t.getImageData(0,0,100,100).data;t.fillStyle="red",t.fillRect(0,0,100,100);var s=A.createElement("div");return s.style.backgroundImage="url("+a+")",s.style.height="100px",n(B)?(0,r.loadSerializedSVG)((0,r.createForeignObjectSVG)(100,100,0,0,s)):Promise.reject(!1)}).then(function(A){return t.drawImage(A,0,0),n(t.getImageData(0,0,100,100).data)}).catch(function(A){return!1})}(document):Promise.resolve(!1);return Object.defineProperty(B,"SUPPORT_FOREIGNOBJECT_DRAWING",{value:A}),A},get SUPPORT_CORS_IMAGES(){var A=void 0!==(new Image).crossOrigin;return Object.defineProperty(B,"SUPPORT_CORS_IMAGES",{value:A}),A},get SUPPORT_RESPONSE_TYPE(){var A="string"==typeof(new XMLHttpRequest).responseType;return Object.defineProperty(B,"SUPPORT_RESPONSE_TYPE",{value:A}),A},get SUPPORT_CORS_XHR(){var A="withCredentials"in new XMLHttpRequest;return Object.defineProperty(B,"SUPPORT_CORS_XHR",{value:A}),A}};e.default=B},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.parseTextDecoration=e.TEXT_DECORATION_LINE=e.TEXT_DECORATION=e.TEXT_DECORATION_STYLE=void 0;var r,n=t(0),B=(r=n)&&r.__esModule?r:{default:r};var a=e.TEXT_DECORATION_STYLE={SOLID:0,DOUBLE:1,DOTTED:2,DASHED:3,WAVY:4},s=e.TEXT_DECORATION={NONE:null},o=e.TEXT_DECORATION_LINE={UNDERLINE:1,OVERLINE:2,LINE_THROUGH:3,BLINK:4},i=function(A){switch(A){case"underline":return o.UNDERLINE;case"overline":return o.OVERLINE;case"line-through":return o.LINE_THROUGH}return o.BLINK};e.parseTextDecoration=function(A){var e,t="none"===(e=A.textDecorationLine?A.textDecorationLine:A.textDecoration)?null:e.split(" ").map(i);return null===t?s.NONE:{textDecorationLine:t,textDecorationColor:A.textDecorationColor?new B.default(A.textDecorationColor):null,textDecorationStyle:function(A){switch(A){case"double":return a.DOUBLE;case"dotted":return a.DOTTED;case"dashed":return a.DASHED;case"wavy":return a.WAVY}return a.SOLID}(A.textDecorationStyle)}}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.parseBorder=e.BORDER_SIDES=e.BORDER_STYLE=void 0;var r,n=t(0),B=(r=n)&&r.__esModule?r:{default:r};var a=e.BORDER_STYLE={NONE:0,SOLID:1},s=e.BORDER_SIDES={TOP:0,RIGHT:1,BOTTOM:2,LEFT:3},o=Object.keys(s).map(function(A){return A.toLowerCase()});e.parseBorder=function(A){return o.map(function(e){var t=new B.default(A.getPropertyValue("border-"+e+"-color")),r=function(A){switch(A){case"none":return a.NONE}return a.SOLID}(A.getPropertyValue("border-"+e+"-style")),n=parseFloat(A.getPropertyValue("border-"+e+"-width"));return{borderColor:t,borderStyle:r,borderWidth:isNaN(n)?0:n}})}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});e.toCodePoints=function(A){for(var e=[],t=0,r=A.length;t=55296&&n<=56319&&t>10),n%1024+56320)),(t+1===A||e.length>16384)&&(r+=String.fromCharCode.apply(String,e),e.length=0)}return r};for(var r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n="undefined"==typeof Uint8Array?[]:new Uint8Array(256),B=0;B>4,l[B++]=(15&s)<<4|o>>2,l[B++]=(3&o)<<6|63&i;return c},e.polyUint16Array=function(A){for(var e=A.length,t=[],r=0;rt?F(A,n,B.length>0):r.integers.reduce(function(e,t,n){for(;A>=t;)A-=t,e+=r.values[n];return e},"")+B},U=function(A,e,t,r){var n="";do{t||A--,n=r(A)+n,A/=e}while(A*e>=e);return n},g=function(A,e,t,r,n){var B=t-e+1;return(A<0?"-":"")+(U(Math.abs(A),B,r,function(A){return(0,s.fromCodePoint)(Math.floor(A%B)+e)})+n)},C=function(A,e){var t=arguments.length>2&&void 0!==arguments[2]?arguments[2]:". ",r=e.length;return U(Math.abs(A),r,!1,function(A){return e[Math.floor(A%r)]})+t},d=function(A,e,t,n,B,s){if(A<-9999||A>9999)return F(A,a.LIST_STYLE_TYPE.CJK_DECIMAL,B.length>0);var o=Math.abs(A),i=B;if(0===o)return e[0]+i;for(var c=0;o>0&&c<=4;c++){var l=o%10;0===l&&(0,r.contains)(s,1)&&""!==i?i=e[l]+i:l>1||1===l&&0===c||1===l&&1===c&&(0,r.contains)(s,2)||1===l&&1===c&&(0,r.contains)(s,4)&&A>100||1===l&&c>1&&(0,r.contains)(s,8)?i=e[l]+(c>0?t[c-1]:"")+i:1===l&&c>0&&(i=t[c-1]+i),o=Math.floor(o/10)}return(A<0?n:"")+i},F=e.createCounterText=function(A,e,t){var r=t?". ":"",n=t?"、":"",B=t?", ":"";switch(e){case a.LIST_STYLE_TYPE.DISC:return"•";case a.LIST_STYLE_TYPE.CIRCLE:return"◦";case a.LIST_STYLE_TYPE.SQUARE:return"◾";case a.LIST_STYLE_TYPE.DECIMAL_LEADING_ZERO:var s=g(A,48,57,!0,r);return s.length<4?"0"+s:s;case a.LIST_STYLE_TYPE.CJK_DECIMAL:return C(A,"〇一二三四五六七八九",n);case a.LIST_STYLE_TYPE.LOWER_ROMAN:return w(A,1,3999,c,a.LIST_STYLE_TYPE.DECIMAL,r).toLowerCase();case a.LIST_STYLE_TYPE.UPPER_ROMAN:return w(A,1,3999,c,a.LIST_STYLE_TYPE.DECIMAL,r);case a.LIST_STYLE_TYPE.LOWER_GREEK:return g(A,945,969,!1,r);case a.LIST_STYLE_TYPE.LOWER_ALPHA:return g(A,97,122,!1,r);case a.LIST_STYLE_TYPE.UPPER_ALPHA:return g(A,65,90,!1,r);case a.LIST_STYLE_TYPE.ARABIC_INDIC:return g(A,1632,1641,!0,r);case a.LIST_STYLE_TYPE.ARMENIAN:case a.LIST_STYLE_TYPE.UPPER_ARMENIAN:return w(A,1,9999,l,a.LIST_STYLE_TYPE.DECIMAL,r);case a.LIST_STYLE_TYPE.LOWER_ARMENIAN:return w(A,1,9999,l,a.LIST_STYLE_TYPE.DECIMAL,r).toLowerCase();case a.LIST_STYLE_TYPE.BENGALI:return g(A,2534,2543,!0,r);case a.LIST_STYLE_TYPE.CAMBODIAN:case a.LIST_STYLE_TYPE.KHMER:return g(A,6112,6121,!0,r);case a.LIST_STYLE_TYPE.CJK_EARTHLY_BRANCH:return C(A,"子丑寅卯辰巳午未申酉戌亥",n);case a.LIST_STYLE_TYPE.CJK_HEAVENLY_STEM:return C(A,"甲乙丙丁戊己庚辛壬癸",n);case a.LIST_STYLE_TYPE.CJK_IDEOGRAPHIC:case a.LIST_STYLE_TYPE.TRAD_CHINESE_INFORMAL:return d(A,"零一二三四五六七八九","十百千萬","負",n,14);case a.LIST_STYLE_TYPE.TRAD_CHINESE_FORMAL:return d(A,"零壹貳參肆伍陸柒捌玖","拾佰仟萬","負",n,15);case a.LIST_STYLE_TYPE.SIMP_CHINESE_INFORMAL:return d(A,"零一二三四五六七八九","十百千萬","负",n,14);case a.LIST_STYLE_TYPE.SIMP_CHINESE_FORMAL:return d(A,"零壹贰叁肆伍陆柒捌玖","拾佰仟萬","负",n,15);case a.LIST_STYLE_TYPE.JAPANESE_INFORMAL:return d(A,"〇一二三四五六七八九","十百千万","マイナス",n,0);case a.LIST_STYLE_TYPE.JAPANESE_FORMAL:return d(A,"零壱弐参四伍六七八九","拾百千万","マイナス",n,7);case a.LIST_STYLE_TYPE.KOREAN_HANGUL_FORMAL:return d(A,"영일이삼사오육칠팔구","십백천만","마이너스 ",B,7);case a.LIST_STYLE_TYPE.KOREAN_HANJA_INFORMAL:return d(A,"零一二三四五六七八九","十百千萬","마이너스 ",B,0);case a.LIST_STYLE_TYPE.KOREAN_HANJA_FORMAL:return d(A,"零壹貳參四五六七八九","拾百千","마이너스 ",B,7);case a.LIST_STYLE_TYPE.DEVANAGARI:return g(A,2406,2415,!0,r);case a.LIST_STYLE_TYPE.GEORGIAN:return w(A,1,19999,Q,a.LIST_STYLE_TYPE.DECIMAL,r);case a.LIST_STYLE_TYPE.GUJARATI:return g(A,2790,2799,!0,r);case a.LIST_STYLE_TYPE.GURMUKHI:return g(A,2662,2671,!0,r);case a.LIST_STYLE_TYPE.HEBREW:return w(A,1,10999,u,a.LIST_STYLE_TYPE.DECIMAL,r);case a.LIST_STYLE_TYPE.HIRAGANA:return C(A,"あいうえおかきくけこさしすせそたちつてとなにぬねのはひふへほまみむめもやゆよらりるれろわゐゑをん");case a.LIST_STYLE_TYPE.HIRAGANA_IROHA:return C(A,"いろはにほへとちりぬるをわかよたれそつねならむうゐのおくやまけふこえてあさきゆめみしゑひもせす");case a.LIST_STYLE_TYPE.KANNADA:return g(A,3302,3311,!0,r);case a.LIST_STYLE_TYPE.KATAKANA:return C(A,"アイウエオカキクケコサシスセソタチツテトナニヌネノハヒフヘホマミムメモヤユヨラリルレロワヰヱヲン",n);case a.LIST_STYLE_TYPE.KATAKANA_IROHA:return C(A,"イロハニホヘトチリヌルヲワカヨタレソツネナラムウヰノオクヤマケフコエテアサキユメミシヱヒモセス",n);case a.LIST_STYLE_TYPE.LAO:return g(A,3792,3801,!0,r);case a.LIST_STYLE_TYPE.MONGOLIAN:return g(A,6160,6169,!0,r);case a.LIST_STYLE_TYPE.MYANMAR:return g(A,4160,4169,!0,r);case a.LIST_STYLE_TYPE.ORIYA:return g(A,2918,2927,!0,r);case a.LIST_STYLE_TYPE.PERSIAN:return g(A,1776,1785,!0,r);case a.LIST_STYLE_TYPE.TAMIL:return g(A,3046,3055,!0,r);case a.LIST_STYLE_TYPE.TELUGU:return g(A,3174,3183,!0,r);case a.LIST_STYLE_TYPE.THAI:return g(A,3664,3673,!0,r);case a.LIST_STYLE_TYPE.TIBETAN:return g(A,3872,3881,!0,r);case a.LIST_STYLE_TYPE.DECIMAL:default:return g(A,48,57,!0,r)}}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function A(A,e){for(var t=0;tA.height?(A.left+=(A.width-A.height)/2,A.width=A.height):A.width0&&B){var a=e.ownerDocument.createElement("html2canvaswrapper");(0,c.copyCSSStyles)(e.ownerDocument.defaultView.getComputedStyle(e,null),a),a.style.position="absolute",a.style.left=t.bounds.left+"px",a.style.top=t.bounds.top+"px",n||(a.style.whiteSpace="nowrap");var s=e.ownerDocument.createTextNode(A);a.appendChild(s),B.appendChild(a),t.childNodes.push(r.default.fromTextNode(s,t)),B.removeChild(a)}}),h=function(A){var e="password"===A.type?new Array(A.value.length+1).join("•"):A.value;return 0===e.length?A.placeholder||"":e}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.parseTextBounds=e.TextBounds=void 0;var r,n=t(1),B=t(11),a=t(10),s=(r=a)&&r.__esModule?r:{default:r},o=t(24);var i=e.TextBounds=function A(e,t){!function(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")}(this,A),this.text=e,this.bounds=t},c=(e.parseTextBounds=function(A,e,t){for(var r=0!==e.style.letterSpacing?(0,o.toCodePoints)(A).map(function(A){return(0,o.fromCodePoint)(A)}):(0,o.breakWords)(A,e),n=r.length,a=t.parentNode?t.parentNode.ownerDocument.defaultView:null,u=a?a.pageXOffset:0,Q=a?a.pageYOffset:0,w=[],U=0,g=0;g0)if(s.default.SUPPORT_RANGE_BOUNDS)w.push(new i(C,l(t,U,C.length,u,Q)));else{var d=t.splitText(C.length);w.push(new i(C,c(t,u,Q))),t=d}else s.default.SUPPORT_RANGE_BOUNDS||(t=t.splitText(C.length));U+=C.length}return w},function(A,e,t){var r=A.ownerDocument.createElement("html2canvaswrapper");r.appendChild(A.cloneNode(!0));var B=A.parentNode;if(B){B.replaceChild(r,A);var a=(0,n.parseBounds)(r,e,t);return r.firstChild&&B.replaceChild(r.firstChild,r),a}return new n.Bounds(0,0,0,0)}),l=function(A,e,t,r,B){var a=A.ownerDocument.createRange();return a.setStart(A,e),a.setEnd(A,e+t),n.Bounds.fromClientRect(a.getBoundingClientRect(),r,B)}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=function(){function A(A,e){for(var t=0;t0&&t.childNodes.push(B.default.fromTextNode(g,t));else if(g instanceof C.HTMLElement||g instanceof HTMLElement||C.parent&&g instanceof C.parent.HTMLElement){if(-1===c.indexOf(g.nodeName)){var d=new n.default(g,t,l,w++);if(d.isVisible()){"INPUT"===g.tagName?(0,a.inlineInputElement)(g,d):"TEXTAREA"===g.tagName?(0,a.inlineTextAreaElement)(g,d):"SELECT"===g.tagName?(0,a.inlineSelectElement)(g,d):d.style.listStyle&&d.style.listStyle.listStyleType!==o.LIST_STYLE_TYPE.NONE&&(0,s.inlineListItemElement)(g,d,l);var F="TEXTAREA"!==g.tagName,E=u(d,g);if(E||Q(d)){var f=E||d.isPositioned()?i.getRealParentStackingContext():i,h=new r.default(d,f,E);f.contexts.push(h),F&&A(g,d,h,l,w)}else i.children.push(d),F&&A(g,d,i,l,w)}}}else if(g instanceof C.SVGSVGElement||g instanceof SVGSVGElement||C.parent&&g instanceof C.parent.SVGSVGElement){var H=new n.default(g,t,l,w++),p=u(H,g);if(p||Q(H)){var N=p||H.isPositioned()?i.getRealParentStackingContext():i,I=new r.default(H,N,p);N.contexts.push(I)}else i.children.push(H)}}},u=function(A,e){return A.isRootElement()||A.isPositionedWithZIndex()||A.style.opacity<1||A.isTransformed()||w(A,e)},Q=function(A){return A.isPositioned()||A.isFloating()},w=function(A,e){return"BODY"===e.nodeName&&A.parent instanceof n.default&&A.parent.style.background.backgroundColor.isTransparent()}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r,n=function(){function A(A,e){for(var t=0;t1&&void 0!==arguments[1]?arguments[1]:"strict",t=[],r=[],n=[];return A.forEach(function(A,B){var a=O.get(A);if(a>c?(n.push(!0),a-=c):n.push(!1),-1!==["normal","auto","loose"].indexOf(e)&&-1!==[8208,8211,12316,12448].indexOf(A))return r.push(B),t.push(16);if(4===a||11===a){if(0===B)return r.push(B),t.push(N);var s=t[B-1];return-1===x.indexOf(s)?(r.push(r[B-1]),t.push(s)):(r.push(B),t.push(N))}return r.push(B),31===a?t.push("strict"===e?d:v):a===L?t.push(N):29===a?t.push(N):43===a?A>=131072&&A<=196605||A>=196608&&A<=262141?t.push(v):t.push(N):void t.push(a)}),[r,t,n]},G=function(A,e,t,r){var n=r[t];if(Array.isArray(A)?-1!==A.indexOf(n):A===n)for(var B=t;B<=r.length;){var a=r[++B];if(a===e)return!0;if(a!==l)break}if(n===l)for(var s=t;s>0;){var o=r[--s];if(Array.isArray(A)?-1!==A.indexOf(o):A===o)for(var i=t;i<=r.length;){var c=r[++i];if(c===e)return!0;if(c!==l)break}if(o!==l)break}return!1},Y=function(A,e){for(var t=A;t>=0;){var r=e[t];if(r!==l)return r;t--}return 0},W=function(A,e,t,r,n){if(0===t[r])return D;var B=r-1;if(Array.isArray(n)&&!0===n[B])return D;var a=B-1,s=B+1,o=e[B],i=a>=0?e[a]:0,c=e[s];if(2===o&&3===c)return D;if(-1!==P.indexOf(o))return _;if(-1!==P.indexOf(c))return D;if(-1!==X.indexOf(c))return D;if(8===Y(B,e))return M;if(11===O.get(A[B])&&(c===v||c===I||c===K))return D;if(7===o||7===c)return D;if(9===o)return D;if(-1===[l,u,Q].indexOf(o)&&9===c)return D;if(-1!==[w,U,g,E,p].indexOf(c))return D;if(Y(B,e)===F)return D;if(G(23,F,B,e))return D;if(G([w,U],d,B,e))return D;if(G(12,12,B,e))return D;if(o===l)return M;if(23===o||23===c)return D;if(16===c||16===o)return M;if(-1!==[u,Q,d].indexOf(c)||14===o)return D;if(36===i&&-1!==k.indexOf(o))return D;if(o===p&&36===c)return D;if(c===C&&-1!==R.concat(C,g,f,v,I,K).indexOf(o))return D;if(-1!==R.indexOf(c)&&o===f||-1!==R.indexOf(o)&&c===f)return D;if(o===H&&-1!==[v,I,K].indexOf(c)||-1!==[v,I,K].indexOf(o)&&c===h)return D;if(-1!==R.indexOf(o)&&-1!==z.indexOf(c)||-1!==z.indexOf(o)&&-1!==R.indexOf(c))return D;if(-1!==[H,h].indexOf(o)&&(c===f||-1!==[F,Q].indexOf(c)&&e[s+1]===f)||-1!==[F,Q].indexOf(o)&&c===f||o===f&&-1!==[f,p,E].indexOf(c))return D;if(-1!==[f,p,E,w,U].indexOf(c))for(var N=B;N>=0;){var L=e[N];if(L===f)return D;if(-1===[p,E].indexOf(L))break;N--}if(-1!==[H,h].indexOf(c))for(var x=-1!==[w,U].indexOf(o)?a:B;x>=0;){var J=e[x];if(J===f)return D;if(-1===[p,E].indexOf(J))break;x--}if(y===o&&-1!==[y,b,T,m].indexOf(c)||-1!==[b,T].indexOf(o)&&-1!==[b,S].indexOf(c)||-1!==[S,m].indexOf(o)&&c===S)return D;if(-1!==V.indexOf(o)&&-1!==[C,h].indexOf(c)||-1!==V.indexOf(c)&&o===H)return D;if(-1!==R.indexOf(o)&&-1!==R.indexOf(c))return D;if(o===E&&-1!==R.indexOf(c))return D;if(-1!==R.concat(f).indexOf(o)&&c===F||-1!==R.concat(f).indexOf(c)&&o===U)return D;if(41===o&&41===c){for(var W=t[B],j=1;W>0&&41===e[--W];)j++;if(j%2!=0)return D}return o===I&&c===K?D:M},j=(e.lineBreakAtIndex=function(A,e){if(0===e)return D;if(e>=A.length)return _;var t=J(A),r=B(t,2),n=r[0],a=r[1];return W(A,a,n,e)},function(A,e){e||(e={lineBreak:"normal",wordBreak:"normal"});var t=J(A,e.lineBreak),r=B(t,3),n=r[0],a=r[1],s=r[2];return"break-all"!==e.wordBreak&&"break-word"!==e.wordBreak||(a=a.map(function(A){return-1!==[f,N,L].indexOf(A)?v:A})),[n,a,"keep-all"===e.wordBreak?s.map(function(e,t){return e&&A[t]>=19968&&A[t]<=40959}):null]}),q=(e.inlineBreakOpportunities=function(A,e){var t=(0,i.toCodePoints)(A),r=D,n=j(t,e),a=B(n,3),s=a[0],o=a[1],c=a[2];return t.forEach(function(A,e){r+=(0,i.fromCodePoint)(A)+(e>=t.length-1?_:W(t,o,s,e+1,c))}),r},function(){function A(e,t,r,n){!function(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")}(this,A),this._codePoints=e,this.required=t===_,this.start=r,this.end=n}return n(A,[{key:"slice",value:function(){return i.fromCodePoint.apply(void 0,function(A){if(Array.isArray(A)){for(var e=0,t=Array(A.length);e=c)return{done:!0};for(var A=D;u>B,c=e.UTRIE2_DATA_BLOCK_LENGTH=1<>B,Q=e.UTRIE2_INDEX_2_BMP_LENGTH=i+u,w=e.UTRIE2_UTF8_2B_INDEX_2_OFFSET=Q,U=e.UTRIE2_UTF8_2B_INDEX_2_LENGTH=32,g=e.UTRIE2_INDEX_1_OFFSET=w+U,C=e.UTRIE2_OMITTED_BMP_INDEX_1_LENGTH=65536>>a,d=e.UTRIE2_INDEX_2_BLOCK_LENGTH=1<=0){if(A<55296||A>56319&&A<=65535)return e=((e=this.index[A>>B])<>B)])<>a),e=this.index[e],e+=A>>B&F,e=((e=this.index[e])<0?t.width:r.width,B="number"==typeof t.height&&t.height>0?t.height:r.height;n>0&&B>0&&e.target.clip([(0,a.calculatePaddingBoxPath)(A.curvedBounds)],function(){e.target.drawImage(t,new a.Bounds(0,0,n,B),r)})}}},r=A.getClipPaths();r.length?this.target.clip(r,t):t()}},{key:"renderNodeBackgroundAndBorders",value:function(A){var e=this,t=!A.style.background.backgroundColor.isTransparent()||A.style.background.backgroundImage.length,r=A.style.border.some(function(A){return A.borderStyle!==l.BORDER_STYLE.NONE&&!A.borderColor.isTransparent()}),n=function(){var r=(0,c.calculateBackgroungPaintingArea)(A.curvedBounds,A.style.background.backgroundClip);t&&e.target.clip([r],function(){A.style.background.backgroundColor.isTransparent()||e.target.fill(A.style.background.backgroundColor),e.renderBackgroundImage(A)}),A.style.border.forEach(function(t,r){t.borderStyle===l.BORDER_STYLE.NONE||t.borderColor.isTransparent()||e.renderBorder(t,r,A.curvedBounds)})};if(t||r){var B=A.parent?A.parent.getClipPaths():[];B.length?this.target.clip(B,n):n()}}},{key:"renderBackgroundImage",value:function(A){var e=this;A.style.background.backgroundImage.slice(0).reverse().forEach(function(t){"url"===t.source.method&&t.source.args.length?e.renderBackgroundRepeat(A,t):/gradient/i.test(t.source.method)&&e.renderBackgroundGradient(A,t)})}},{key:"renderBackgroundRepeat",value:function(A,e){var t=this.options.imageStore.get(e.source.args[0]);if(t){var r=(0,c.calculateBackgroungPositioningArea)(A.style.background.backgroundOrigin,A.bounds,A.style.padding,A.style.border),n=(0,c.calculateBackgroundSize)(e,t,r),B=(0,c.calculateBackgroundPosition)(e.position,n,r),a=(0,c.calculateBackgroundRepeatPath)(e,B,n,r,A.bounds),s=Math.round(r.left+B.x),o=Math.round(r.top+B.y);this.target.renderRepeat(a,t,n,s,o)}}},{key:"renderBackgroundGradient",value:function(A,e){var t=(0,c.calculateBackgroungPositioningArea)(A.style.background.backgroundOrigin,A.bounds,A.style.padding,A.style.border),r=(0,c.calculateGradientBackgroundSize)(e,t),n=(0,c.calculateBackgroundPosition)(e.position,r,t),B=new a.Bounds(Math.round(t.left+n.x),Math.round(t.top+n.y),r.width,r.height),o=(0,s.parseGradient)(A,e.source,B);if(o)switch(o.type){case s.GRADIENT_TYPE.LINEAR_GRADIENT:this.target.renderLinearGradient(B,o);break;case s.GRADIENT_TYPE.RADIAL_GRADIENT:this.target.renderRadialGradient(B,o)}}},{key:"renderBorder",value:function(A,e,t){this.target.drawShape((0,a.parsePathForBorder)(t,e),A.borderColor)}},{key:"renderStack",value:function(A){var e=this;if(A.container.isVisible()){var t=A.getOpacity();t!==this._opacity&&(this.target.setOpacity(A.getOpacity()),this._opacity=t);var r=A.container.style.transform;null!==r?this.target.transform(A.container.bounds.left+r.transformOrigin[0].value,A.container.bounds.top+r.transformOrigin[1].value,r.transform,function(){return e.renderStackContent(A)}):this.renderStackContent(A)}}},{key:"renderStackContent",value:function(A){var e=w(A),t=n(e,5),r=t[0],B=t[1],a=t[2],s=t[3],o=t[4],i=Q(A),c=n(i,2),l=c[0],u=c[1];this.renderNodeBackgroundAndBorders(A.container),r.sort(U).forEach(this.renderStack,this),this.renderNodeContent(A.container),u.forEach(this.renderNode,this),s.forEach(this.renderStack,this),o.forEach(this.renderStack,this),l.forEach(this.renderNode,this),B.forEach(this.renderStack,this),a.sort(U).forEach(this.renderStack,this)}},{key:"render",value:function(A){this.options.backgroundColor&&this.target.rectangle(this.options.x,this.options.y,this.options.width,this.options.height,this.options.backgroundColor),this.renderStack(A);var e=this.target.getTarget();return e}}]),A}();e.default=u;var Q=function(A){for(var e=[],t=[],r=A.children.length,n=0;n0?r.push(o):t.push(o):o.container.isFloating()?n.push(o):B.push(o)}return[e,t,r,n,B]},U=function(A,e){return A.container.style.zIndex.order>e.container.style.zIndex.order?1:A.container.style.zIndex.ordere.container.index?1:-1}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.transformWebkitRadialGradientArgs=e.parseGradient=e.RadialGradient=e.LinearGradient=e.RADIAL_GRADIENT_SHAPE=e.GRADIENT_TYPE=void 0;var r=function(){return function(A,e){if(Array.isArray(A))return A;if(Symbol.iterator in Object(A))return function(A,e){var t=[],r=!0,n=!1,B=void 0;try{for(var a,s=A[Symbol.iterator]();!(r=(a=s.next()).done)&&(t.push(a.value),!e||t.length!==e);r=!0);}catch(A){n=!0,B=A}finally{try{!r&&s.return&&s.return()}finally{if(n)throw B}}return t}(A,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=(i(t(3)),t(53)),B=i(t(0)),a=t(2),s=i(a),o=t(4);function i(A){return A&&A.__esModule?A:{default:A}}function c(A,e){if(!(A instanceof e))throw new TypeError("Cannot call a class as a function")}var l=/^(to )?(left|top|right|bottom)( (left|top|right|bottom))?$/i,u=/^([+-]?\d*\.?\d+)% ([+-]?\d*\.?\d+)%$/i,Q=/(px)|%|( 0)$/i,w=/^(from|to|color-stop)\((?:([\d.]+)(%)?,\s*)?(.+?)\)$/i,U=/^\s*(circle|ellipse)?\s*((?:([\d.]+)(px|r?em|%)\s*(?:([\d.]+)(px|r?em|%))?)|closest-side|closest-corner|farthest-side|farthest-corner)?\s*(?:at\s*(?:(left|center|right)|([\d.]+)(px|r?em|%))\s+(?:(top|center|bottom)|([\d.]+)(px|r?em|%)))?(?:\s|$)/i,g=e.GRADIENT_TYPE={LINEAR_GRADIENT:0,RADIAL_GRADIENT:1},C=e.RADIAL_GRADIENT_SHAPE={CIRCLE:0,ELLIPSE:1},d={left:new s.default("0%"),top:new s.default("0%"),center:new s.default("50%"),right:new s.default("100%"),bottom:new s.default("100%")},F=e.LinearGradient=function A(e,t){c(this,A),this.type=g.LINEAR_GRADIENT,this.colorStops=e,this.direction=t},E=e.RadialGradient=function A(e,t,r,n){c(this,A),this.type=g.RADIAL_GRADIENT,this.colorStops=e,this.shape=t,this.center=r,this.radius=n},f=(e.parseGradient=function(A,e,t){var r=e.args,n=e.method,B=e.prefix;return"linear-gradient"===n?h(r,t,!!B):"gradient"===n&&"linear"===r[0]?h(["to bottom"].concat(y(r.slice(3))),t,!!B):"radial-gradient"===n?H(A,"-webkit-"===B?v(r):r,t):"gradient"===n&&"radial"===r[0]?H(A,y(v(r.slice(1))),t):void 0},function(A,e,t){for(var r=[],n=e;nA.optimumDistance)?{optimumCorner:n,optimumDistance:B}:A},{optimumDistance:r?1/0:-1/0,optimumCorner:null}).optimumCorner},m=function(A,e,t,r,n){var B=t.x,a=t.y,s=0,i=0;switch(A){case"closest-side":e===C.CIRCLE?s=i=Math.min(Math.abs(B),Math.abs(B-n.width),Math.abs(a),Math.abs(a-n.height)):e===C.ELLIPSE&&(s=Math.min(Math.abs(B),Math.abs(B-n.width)),i=Math.min(Math.abs(a),Math.abs(a-n.height)));break;case"closest-corner":if(e===C.CIRCLE)s=i=Math.min((0,o.distance)(B,a),(0,o.distance)(B,a-n.height),(0,o.distance)(B-n.width,a),(0,o.distance)(B-n.width,a-n.height));else if(e===C.ELLIPSE){var c=Math.min(Math.abs(a),Math.abs(a-n.height))/Math.min(Math.abs(B),Math.abs(B-n.width)),l=T(n,B,a,!0);i=c*(s=(0,o.distance)(l.x-B,(l.y-a)/c))}break;case"farthest-side":e===C.CIRCLE?s=i=Math.max(Math.abs(B),Math.abs(B-n.width),Math.abs(a),Math.abs(a-n.height)):e===C.ELLIPSE&&(s=Math.max(Math.abs(B),Math.abs(B-n.width)),i=Math.max(Math.abs(a),Math.abs(a-n.height)));break;case"farthest-corner":if(e===C.CIRCLE)s=i=Math.max((0,o.distance)(B,a),(0,o.distance)(B,a-n.height),(0,o.distance)(B-n.width,a),(0,o.distance)(B-n.width,a-n.height));else if(e===C.ELLIPSE){var u=Math.max(Math.abs(a),Math.abs(a-n.height))/Math.max(Math.abs(B),Math.abs(B-n.width)),Q=T(n,B,a,!1);i=u*(s=(0,o.distance)(Q.x-B,(Q.y-a)/u))}break;default:s=r.x||0,i=void 0!==r.y?r.y:s}return{x:s,y:i}},v=e.transformWebkitRadialGradientArgs=function(A){var e="",t="",r="",n="",B=0,a=/^(left|center|right|\d+(?:px|r?em|%)?)(?:\s+(top|center|bottom|\d+(?:px|r?em|%)?))?$/i,s=/^\d+(px|r?em|%)?(?:\s+\d+(px|r?em|%)?)?$/i,o=A[B].match(a);o&&B++;var i=A[B].match(/^(circle|ellipse)?\s*(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)?$/i);i&&(e=i[1]||"","contain"===(r=i[2]||"")?r="closest-side":"cover"===r&&(r="farthest-corner"),B++);var c=A[B].match(s);c&&B++;var l=A[B].match(a);l&&B++;var u=A[B].match(s);u&&B++;var Q=l||o;Q&&Q[1]&&(n=Q[1]+(/^\d+$/.test(Q[1])?"px":""),Q[2]&&(n+=" "+Q[2]+(/^\d+$/.test(Q[2])?"px":"")));var w=u||c;return w&&(t=w[0],w[1]||(t+="px")),!n||e||t||r||(t=n,n=""),n&&(n="at "+n),[[e,r,t,n].filter(function(A){return!!A}).join(" ")].concat(A.slice(B))},y=function(A){return A.map(function(A){return A.match(w)}).map(function(e,t){if(!e)return A[t];switch(e[1]){case"from":return e[4]+" 0%";case"to":return e[4]+" 100%";case"color-stop":return"%"===e[3]?e[4]+" "+e[2]:e[4]+" "+100*parseFloat(e[2])+"%"}})}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0});var r=/([+-]?\d*\.?\d+)(deg|grad|rad|turn)/i;e.parseAngle=function(A){var e=A.match(r);if(e){var t=parseFloat(e[1]);switch(e[2].toLowerCase()){case"deg":return Math.PI*t/180;case"grad":return Math.PI/200*t;case"rad":return t;case"turn":return 2*Math.PI*t}}return null}},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.cloneWindow=e.DocumentCloner=void 0;var r=function(){return function(A,e){if(Array.isArray(A))return A;if(Symbol.iterator in Object(A))return function(A,e){var t=[],r=!0,n=!1,B=void 0;try{for(var a,s=A[Symbol.iterator]();!(r=(a=s.next()).done)&&(t.push(a.value),!e||t.length!==e);r=!0);}catch(A){n=!0,B=A}finally{try{!r&&s.return&&s.return()}finally{if(n)throw B}}return t}(A,e);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),n=function(){function A(A,e){for(var t=0;t1&&(t.backgroundColor=""),t.backgroundImage=A.join(",")}),A instanceof HTMLImageElement&&this.resourceLoader.inlineImage(A.src).then(function(e){if(e&&A instanceof HTMLImageElement&&A.parentNode){var t=A.parentNode,r=(0,o.copyCSSStyles)(A.style,e.cloneNode(!1));t.replaceChild(r,A)}}).catch(function(A){0})}}},{key:"inlineFonts",value:function(A){var e=this;return Promise.all(Array.from(A.styleSheets).map(function(e){return e.href?fetch(e.href).then(function(A){return A.text()}).then(function(A){return U(A,e.href)}).catch(function(A){return[]}):w(e,A)})).then(function(A){return A.reduce(function(A,e){return A.concat(e)},[])}).then(function(A){return Promise.all(A.map(function(A){return fetch(A.formats[0].src).then(function(A){return A.blob()}).then(function(A){return new Promise(function(e,t){var r=new FileReader;r.onerror=t,r.onload=function(){var A=r.result;e(A)},r.readAsDataURL(A)})}).then(function(e){return A.fontFace.setProperty("src",'url("'+e+'")'),"@font-face {"+A.fontFace.cssText+" "})}))}).then(function(t){var r=A.createElement("style");r.textContent=t.join("\n"),e.documentElement.appendChild(r)})}},{key:"createElementClone",value:function(A){var e=this;if(this.copyStyles&&A instanceof HTMLCanvasElement){var t=A.ownerDocument.createElement("img");try{return t.src=A.toDataURL(),t}catch(A){0}}if(A instanceof HTMLIFrameElement){var r=A.cloneNode(!1),n=N();r.setAttribute("data-html2canvas-internal-iframe-key",n);var a=(0,B.parseBounds)(A,0,0),s=a.width,i=a.height;return this.resourceLoader.cache[n]=K(A,this.options).then(function(A){return e.renderer(A,{async:e.options.async,allowTaint:e.options.allowTaint,backgroundColor:"#ffffff",canvas:null,imageTimeout:e.options.imageTimeout,logging:e.options.logging,proxy:e.options.proxy,removeContainer:e.options.removeContainer,scale:e.options.scale,foreignObjectRendering:e.options.foreignObjectRendering,useCORS:e.options.useCORS,target:new c.default,width:s,height:i,x:0,y:0,windowWidth:A.ownerDocument.defaultView.innerWidth,windowHeight:A.ownerDocument.defaultView.innerHeight,scrollX:A.ownerDocument.defaultView.pageXOffset,scrollY:A.ownerDocument.defaultView.pageYOffset},e.logger.child(n))}).then(function(e){return new Promise(function(t,n){var B=document.createElement("img");B.onload=function(){return t(e)},B.onerror=n,B.src=e.toDataURL(),r.parentNode&&r.parentNode.replaceChild((0,o.copyCSSStyles)(A.ownerDocument.defaultView.getComputedStyle(A),B),r)})}),r}if(A instanceof HTMLStyleElement&&A.sheet&&A.sheet.cssRules){var l=[].slice.call(A.sheet.cssRules,0).reduce(function(A,e){return A+e.cssText},""),u=A.cloneNode(!1);return u.textContent=l,u}return A.cloneNode(!1)}},{key:"cloneNode",value:function(A){var e=A.nodeType===Node.TEXT_NODE?document.createTextNode(A.nodeValue):this.createElementClone(A),t=A.ownerDocument.defaultView,r=A instanceof t.HTMLElement?t.getComputedStyle(A):null,n=A instanceof t.HTMLElement?t.getComputedStyle(A,":before"):null,B=A instanceof t.HTMLElement?t.getComputedStyle(A,":after"):null;this.referenceElement===A&&e instanceof t.HTMLElement&&(this.clonedReferenceElement=e),e instanceof t.HTMLBodyElement&&h(e);for(var a=(0,l.parseCounterReset)(r,this.pseudoContentData),s=(0,l.resolvePseudoContent)(A,n,this.pseudoContentData),i=A.firstChild;i;i=i.nextSibling)i.nodeType===Node.ELEMENT_NODE&&("SCRIPT"===i.nodeName||i.hasAttribute("data-html2canvas-ignore")||"function"==typeof this.options.ignoreElements&&this.options.ignoreElements(i))||this.copyStyles&&"STYLE"===i.nodeName||e.appendChild(this.cloneNode(i));var c=(0,l.resolvePseudoContent)(A,B,this.pseudoContentData);if((0,l.popCounters)(a,this.pseudoContentData),A instanceof t.HTMLElement&&e instanceof t.HTMLElement)switch(n&&this.inlineAllImages(C(A,e,n,s,d)),B&&this.inlineAllImages(C(A,e,B,c,F)),!r||!this.copyStyles||A instanceof HTMLIFrameElement||(0,o.copyCSSStyles)(r,e),this.inlineAllImages(e),0===A.scrollTop&&0===A.scrollLeft||this.scrolledElements.push([e,A.scrollLeft,A.scrollTop]),A.nodeName){case"CANVAS":this.copyStyles||g(A,e);break;case"TEXTAREA":case"SELECT":e.value=A.value}return e}}]),A}(),w=function(A,e){return(A.cssRules?Array.from(A.cssRules):[]).filter(function(A){return A.type===CSSRule.FONT_FACE_RULE}).map(function(A){for(var t=(0,i.parseBackgroundImage)(A.style.getPropertyValue("src")),r=[],n=0;n0&&"complete"===t.readyState&&(clearInterval(e),r(A))},50)}})},v=(e.cloneWindow=function(A,e,t,r,n,B){var a=new Q(t,r,n,!1,B),s=A.defaultView.pageXOffset,o=A.defaultView.pageYOffset;return T(A,e).then(function(n){var B=n.contentWindow,i=B.document,c=m(n).then(function(){a.scrolledElements.forEach(p),B.scrollTo(e.left,e.top),!/(iPad|iPhone|iPod)/g.test(navigator.userAgent)||B.scrollY===e.top&&B.scrollX===e.left||(i.documentElement.style.top=-e.top+"px",i.documentElement.style.left=-e.left+"px",i.documentElement.style.position="absolute");var t=Promise.resolve([n,a.clonedReferenceElement,a.resourceLoader]),s=r.onclone;return a.clonedReferenceElement instanceof B.HTMLElement||a.clonedReferenceElement instanceof A.defaultView.HTMLElement||a.clonedReferenceElement instanceof HTMLElement?"function"==typeof s?Promise.resolve().then(function(){return s(i)}).then(function(){return t}):t:Promise.reject("")});return i.open(),i.write(v(document.doctype)+""),function(A,e,t){!A.defaultView||e===A.defaultView.pageXOffset&&t===A.defaultView.pageYOffset||A.defaultView.scrollTo(e,t)}(t.ownerDocument,s,o),i.replaceChild(i.adoptNode(a.documentElement),i.documentElement),i.close(),c})},function(A){var e="";return A&&(e+=""),e})},function(A,e,t){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.ResourceStore=void 0;var r,n=function(){function A(A,e){for(var t=0;t0&&t.push({type:s.ATTRIBUTE,value:l[0]});break;case"counter":if(l.length>0){var w={type:s.COUNTER,name:l[0]};l.length>1&&(w.format=l[1]),t.push(w)}break;case"counters":if(l.length>0){var U={type:s.COUNTERS,name:l[0]};l.length>1&&(U.glue=l[1]),l.length>2&&(U.format=l[2]),t.push(U)}break;case"url":l.length>0&&t.push({type:s.URL,value:l[0]})}a=!1,o=""}break;case",":n?o+=Q:a&&(l.push(o),o="");break;case" ":case"\t":n?o+=Q:o&&(i(t,o),o="");break;default:o+=Q}"\\"!==Q&&(B=!1)}return o&&i(t,o),e&&(e[A]=t),t}),i=function(A,e){switch(e){case"open-quote":A.push({type:s.OPENQUOTE});break;case"close-quote":A.push({type:s.CLOSEQUOTE})}},c=function(A,e,t){var r=A.quotes?A.quotes.split(/\s+/):["'\"'","'\"'"],n=2*t;return n>=r.length&&(n=r.length-2),e||++n,r[n].replace(/^["']|["']$/g,"")},l=function(A,e,t){for(var r=A.length,a="",s=0;s0&&(a+=e||""),a+=(0,n.createCounterText)(A[s],(0,B.parseListStyleType)(t||"decimal"),!1);return a}}])}); \ No newline at end of file diff --git a/src/js/lz-string.min.js b/src/js/lz-string.min.js new file mode 100644 index 0000000..2d1900a --- /dev/null +++ b/src/js/lz-string.min.js @@ -0,0 +1 @@ +var LZString=function(){function o(o,r){if(!t[o]){t[o]={};for(var n=0;ne;e++){var s=r.charCodeAt(e);n[2*e]=s>>>8,n[2*e+1]=s%256}return n},decompressFromUint8Array:function(o){if(null===o||void 0===o)return i.decompress(o);for(var n=new Array(o.length/2),e=0,t=n.length;t>e;e++)n[e]=256*o[2*e]+o[2*e+1];var s=[];return n.forEach(function(o){s.push(r(o))}),i.decompress(s.join(""))},compressToEncodedURIComponent:function(o){return null==o?"":i._compress(o,6,function(o){return e.charAt(o)})},decompressFromEncodedURIComponent:function(r){return null==r?"":""==r?null:(r=r.replace(/ /g,"+"),i._decompress(r.length,32,function(n){return o(e,r.charAt(n))}))},compress:function(o){return i._compress(o,16,function(o){return r(o)})},_compress:function(o,r,n){if(null==o)return"";var e,t,i,s={},p={},u="",c="",a="",l=2,f=3,h=2,d=[],m=0,v=0;for(i=0;ie;e++)m<<=1,v==r-1?(v=0,d.push(n(m)),m=0):v++;for(t=a.charCodeAt(0),e=0;8>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;h>e;e++)m=m<<1|t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=a.charCodeAt(0),e=0;16>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}l--,0==l&&(l=Math.pow(2,h),h++),delete p[a]}else for(t=s[a],e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;l--,0==l&&(l=Math.pow(2,h),h++),s[c]=f++,a=String(u)}if(""!==a){if(Object.prototype.hasOwnProperty.call(p,a)){if(a.charCodeAt(0)<256){for(e=0;h>e;e++)m<<=1,v==r-1?(v=0,d.push(n(m)),m=0):v++;for(t=a.charCodeAt(0),e=0;8>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}else{for(t=1,e=0;h>e;e++)m=m<<1|t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t=0;for(t=a.charCodeAt(0),e=0;16>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1}l--,0==l&&(l=Math.pow(2,h),h++),delete p[a]}else for(t=s[a],e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;l--,0==l&&(l=Math.pow(2,h),h++)}for(t=2,e=0;h>e;e++)m=m<<1|1&t,v==r-1?(v=0,d.push(n(m)),m=0):v++,t>>=1;for(;;){if(m<<=1,v==r-1){d.push(n(m));break}v++}return d.join("")},decompress:function(o){return null==o?"":""==o?null:i._decompress(o.length,32768,function(r){return o.charCodeAt(r)})},_decompress:function(o,n,e){var t,i,s,p,u,c,a,l,f=[],h=4,d=4,m=3,v="",w=[],A={val:e(0),position:n,index:1};for(i=0;3>i;i+=1)f[i]=i;for(p=0,c=Math.pow(2,2),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;switch(t=p){case 0:for(p=0,c=Math.pow(2,8),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;l=r(p);break;case 1:for(p=0,c=Math.pow(2,16),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;l=r(p);break;case 2:return""}for(f[3]=l,s=l,w.push(l);;){if(A.index>o)return"";for(p=0,c=Math.pow(2,m),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;switch(l=p){case 0:for(p=0,c=Math.pow(2,8),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;f[d++]=r(p),l=d-1,h--;break;case 1:for(p=0,c=Math.pow(2,16),a=1;a!=c;)u=A.val&A.position,A.position>>=1,0==A.position&&(A.position=n,A.val=e(A.index++)),p|=(u>0?1:0)*a,a<<=1;f[d++]=r(p),l=d-1,h--;break;case 2:return w.join("")}if(0==h&&(h=Math.pow(2,m),m++),f[l])v=f[l];else{if(l!==d)return null;v=s+s.charAt(0)}w.push(v),f[d++]=s+v.charAt(0),h--,s=v,0==h&&(h=Math.pow(2,m),m++)}}};return i}();"function"==typeof define&&define.amd?define(function(){return LZString}):"undefined"!=typeof module&&null!=module&&(module.exports=LZString); diff --git a/src/js/main.js b/src/js/main.js new file mode 100644 index 0000000..231cc10 --- /dev/null +++ b/src/js/main.js @@ -0,0 +1,836 @@ +/** @type {CharData} */ +let characterData = []; // Initial character data set used. +/** @type {CharData} */ +let characterDataToSort = []; // Character data set after filtering. +/** @type {Options} */ +let options = []; // Initial option set used. + +let currentVersion = ''; // Which version of characterData and options are used. + +/** @type {(boolean|boolean[])[]} */ +let optTaken = []; // Records which options are set. + +/** Save Data. Concatenated into array, joined into string (delimited by '|') and compressed with lz-string. */ +let timestamp = 0; // savedata[0] (Unix time when sorter was started, used as initial PRNG seed and in dataset selection) +let timeTaken = 0; // savedata[1] (Number of ms elapsed when sorter ends, used as end-of-sort flag and in filename generation) +let choices = ''; // savedata[2] (String of '0', '1' and '2' that records what sorter choices are made) +let optStr = ''; // savedata[3] (String of '0' and '1' that denotes top-level option selection) +let suboptStr = ''; // savedata[4...n] (String of '0' and '1' that denotes nested option selection, separated by '|') +let timeError = false; // Shifts entire savedata array to the right by 1 and adds an empty element at savedata[0] if true. + +/** Intermediate sorter data. */ +let sortedIndexList = []; +let recordDataList = []; +let parentIndexList = []; +let tiedDataList = []; + +let leftIndex = 0; +let leftInnerIndex = 0; +let rightIndex = 0; +let rightInnerIndex = 0; +let battleNo = 1; +let sortedNo = 0; +let pointer = 0; + +/** A copy of intermediate sorter data is recorded for undo() purposes. */ +let sortedIndexListPrev = []; +let recordDataListPrev = []; +let parentIndexListPrev = []; +let tiedDataListPrev = []; + +let leftIndexPrev = 0; +let leftInnerIndexPrev = 0; +let rightIndexPrev = 0; +let rightInnerIndexPrev = 0; +let battleNoPrev = 1; +let sortedNoPrev = 0; +let pointerPrev = 0; + +/** Miscellaneous sorter data that doesn't need to be saved for undo(). */ +let finalCharacters = []; +let loading = false; +let totalBattles = 0; +let sorterURL = window.location.host + window.location.pathname; +let storedSaveType = localStorage.getItem(`${sorterURL}_saveType`); + +/** Initialize script. */ +function init() { + + /** Define button behavior. */ + document.querySelector('.starting.start.button').addEventListener('click', start); + document.querySelector('.starting.load.button').addEventListener('click', loadProgress); + + document.querySelector('.left.sort.image').addEventListener('click', () => pick('left')); + document.querySelector('.right.sort.image').addEventListener('click', () => pick('right')); + + document.querySelector('.sorting.tie.button').addEventListener('click', () => pick('tie')); + document.querySelector('.sorting.undo.button').addEventListener('click', undo); + document.querySelector('.sorting.save.button').addEventListener('click', () => saveProgress('Progress')); + + document.querySelector('.finished.save.button').addEventListener('click', () => saveProgress('Last Result')); + document.querySelector('.finished.getimg.button').addEventListener('click', generateImage); + document.querySelector('.finished.list.button').addEventListener('click', generateTextList); + + document.querySelector('.clearsave').addEventListener('click', clearProgress); + + /** Define keyboard controls (up/down/left/right vimlike k/j/h/l). */ + document.addEventListener('keypress', (ev) => { + /** If sorting is in progress. */ + if (timestamp && !timeTaken && !loading && choices.length === battleNo - 1) { + switch(ev.key) { + case 's': case '3': saveProgress('Progress'); break; + case 'h': case 'ArrowLeft': pick('left'); break; + case 'l': case 'ArrowRight': pick('right'); break; + case 'k': case '1': case 'ArrowUp': pick('tie'); break; + case 'j': case '2': case 'ArrowDown': undo(); break; + default: break; + } + } + /** If sorting has ended. */ + else if (timeTaken && choices.length === battleNo - 1) { + switch(ev.key) { + case 'k': case '1': saveProgress('Last Result'); break; + case 'j': case '2': generateImage(); break; + case 's': case '3': generateTextList(); break; + default: break; + } + } else { // If sorting hasn't started yet. + switch(ev.key) { + case '1': case 's': case 'Enter': start(); break; + case '2': case 'l': loadProgress(); break; + default: break; + } + } + }); + + document.querySelector('.image.selector').insertAdjacentElement('beforeend', document.createElement('select')); + + /** Initialize image quantity selector for results. */ + for (let i = 0; i <= 10; i++) { + const select = document.createElement('option'); + select.value = i; + select.text = i; + if (i === 3) { select.selected = 'selected'; } + document.querySelector('.image.selector > select').insertAdjacentElement('beforeend', select); + } + + document.querySelector('.image.selector > select').addEventListener('input', (e) => { + const imageNum = e.target.options[e.target.selectedIndex].value; + result(Number(imageNum)); + }); + + /** Show load button if save data exists. */ + if (storedSaveType) { + document.querySelector('.starting.load.button > span').insertAdjacentText('beforeend', storedSaveType); + document.querySelectorAll('.starting.button').forEach(el => { + el.style['grid-row'] = 'span 3'; + el.style.display = 'block'; + }); + } + + setLatestDataset(); + + /** Decode query string if available. */ + if (window.location.search.slice(1) !== '') decodeQuery(); +} + +/** Begin sorting. */ +function start() { + /** Copy data into sorting array to filter. */ + characterDataToSort = characterData.slice(0); + + /** Check selected options and convert to boolean array form. */ + optTaken = []; + + options.forEach(opt => { + if ('sub' in opt) { + if (!document.getElementById(`cbgroup-${opt.key}`).checked) optTaken.push(false); + else { + const suboptArray = opt.sub.reduce((arr, val, idx) => { + arr.push(document.getElementById(`cb-${opt.key}-${idx}`).checked); + return arr; + }, []); + optTaken.push(suboptArray); + } + } else { optTaken.push(document.getElementById(`cb-${opt.key}`).checked); } + }); + + /** Convert boolean array form to string form. */ + optStr = ''; + suboptStr = ''; + + optStr = optTaken + .map(val => !!val) + .reduce((str, val) => { + str += val ? '1' : '0'; + return str; + }, optStr); + optTaken.forEach(val => { + if (Array.isArray(val)) { + suboptStr += '|'; + suboptStr += val.reduce((str, val) => { + str += val ? '1' : '0'; + return str; + }, ''); + } + }); + + /** Filter out deselected nested criteria and remove selected criteria. */ + options.forEach((opt, index) => { + if ('sub' in opt) { + if (optTaken[index]) { + const subArray = optTaken[index].reduce((subList, subBool, subIndex) => { + if (subBool) { subList.push(options[index].sub[subIndex].key); } + return subList; + }, []); + characterDataToSort = characterDataToSort.filter(char => { + if (!(opt.key in char.opts)) console.warn(`Warning: ${opt.key} not set for ${char.name}.`); + return opt.key in char.opts && char.opts[opt.key].some(key => subArray.includes(key)); + }); + } + } else if (optTaken[index]) { + characterDataToSort = characterDataToSort.filter(char => !char.opts[opt.key]); + } + }); + + if (characterDataToSort.length < 2) { + alert('Cannot sort with less than two characters. Please reselect.'); + return; + } + + /** Shuffle character array with timestamp seed. */ + timestamp = timestamp || new Date().getTime(); + if (new Date(timestamp) < new Date(currentVersion)) { timeError = true; } + Math.seedrandom(timestamp); + + characterDataToSort = characterDataToSort + .map(a => [Math.random(), a]) + .sort((a,b) => a[0] - b[0]) + .map(a => a[1]); + + /** + * tiedDataList will keep a record of indexes on which characters are equal (i.e. tied) + * to another one. recordDataList will have an interim list of sorted elements during + * the mergesort process. + */ + + recordDataList = characterDataToSort.map(() => 0); + tiedDataList = characterDataToSort.map(() => -1); + + /** + * Put a list of indexes that we'll be sorting into sortedIndexList. These will refer back + * to characterDataToSort. + * + * Begin splitting each element into little arrays and spread them out over sortedIndexList + * increasing its length until it become arrays of length 1 and you can't split it anymore. + * + * parentIndexList indicates each element's parent (i.e. where it was split from), except + * for the first element, which has no parent. + */ + + sortedIndexList[0] = characterDataToSort.map((val, idx) => idx); + parentIndexList[0] = -1; + + let midpoint = 0; // Indicates where to split the array. + let marker = 1; // Indicates where to place our newly split array. + + for (let i = 0; i < sortedIndexList.length; i++) { + if (sortedIndexList[i].length > 1) { + let parent = sortedIndexList[i]; + midpoint = Math.ceil(parent.length / 2); + + sortedIndexList[marker] = parent.slice(0, midpoint); // Split the array in half, and put the left half into the marked index. + totalBattles += sortedIndexList[marker].length; // The result's length will add to our total number of comparisons. + parentIndexList[marker] = i; // Record where it came from. + marker++; // Increment the marker to put the right half into. + + sortedIndexList[marker] = parent.slice(midpoint, parent.length); // Put the right half next to its left half. + totalBattles += sortedIndexList[marker].length; // The result's length will add to our total number of comparisons. + parentIndexList[marker] = i; // Record where it came from. + marker++; // Rinse and repeat, until we get arrays of length 1. This is initialization of merge sort. + } + } + + leftIndex = sortedIndexList.length - 2; // Start with the second last value and... + rightIndex = sortedIndexList.length - 1; // the last value in the sorted list and work our way down to index 0. + + leftInnerIndex = 0; // Inner indexes, because we'll be comparing the left array + rightInnerIndex = 0; // to the right array, in order to merge them into one sorted array. + + /** Disable all checkboxes and hide/show appropriate parts while we preload the images. */ + document.querySelectorAll('input[type=checkbox]').forEach(cb => cb.disabled = true); + document.querySelectorAll('.starting.button').forEach(el => el.style.display = 'none'); + document.querySelector('.loading.button').style.display = 'block'; + document.querySelector('.progress').style.display = 'block'; + loading = true; + + preloadImages().then(() => { + loading = false; + document.querySelector('.loading.button').style.display = 'none'; + document.querySelectorAll('.sorting.button').forEach(el => el.style.display = 'block'); + document.querySelectorAll('.sort.text').forEach(el => el.style.display = 'block'); + display(); + }); +} + +/** Displays the current state of the sorter. */ +function display() { + const percent = Math.floor(sortedNo * 100 / totalBattles); + const leftCharIndex = sortedIndexList[leftIndex][leftInnerIndex]; + const rightCharIndex = sortedIndexList[rightIndex][rightInnerIndex]; + const leftChar = characterDataToSort[leftCharIndex]; + const rightChar = characterDataToSort[rightCharIndex]; + + const charNameDisp = name => { + const charName = reduceTextWidth(name, 'Arial 12.8px', 220); + const charTooltip = name !== charName ? name : ''; + return `

${charName}

`; + }; + + progressBar(`Battle No. ${battleNo}`, percent); + + document.querySelector('.left.sort.image').src = leftChar.img; + document.querySelector('.right.sort.image').src = rightChar.img; + + + + document.querySelector('.left.sort.text').innerHTML = charNameDisp(leftChar.name); + document.querySelector('.right.sort.text').innerHTML = charNameDisp(rightChar.name); + + /** Autopick if choice has been given. */ + if (choices.length !== battleNo - 1) { + switch (Number(choices[battleNo - 1])) { + case 0: pick('left'); break; + case 1: pick('right'); break; + case 2: pick('tie'); break; + default: break; + } + } else { saveProgress('Autosave'); } +} + +/** + * Sort between two character choices or tie. + * + * @param {'left'|'right'|'tie'} sortType + */ +function pick(sortType) { + if ((timeTaken && choices.length === battleNo - 1) || loading) { return; } + else if (!timestamp) { return start(); } + + sortedIndexListPrev = sortedIndexList.slice(0); + recordDataListPrev = recordDataList.slice(0); + parentIndexListPrev = parentIndexList.slice(0); + tiedDataListPrev = tiedDataList.slice(0); + + leftIndexPrev = leftIndex; + leftInnerIndexPrev = leftInnerIndex; + rightIndexPrev = rightIndex; + rightInnerIndexPrev = rightInnerIndex; + battleNoPrev = battleNo; + sortedNoPrev = sortedNo; + pointerPrev = pointer; + + /** + * For picking 'left' or 'right': + * + * Input the selected character's index into recordDataList. Increment the pointer of + * recordDataList. Then, check if there are any ties with this character, and keep + * incrementing until we find no more ties. + */ + switch (sortType) { + case 'left': { + if (choices.length === battleNo - 1) { choices += '0'; } + recordData('left'); + while (tiedDataList[recordDataList[pointer - 1]] != -1) { + recordData('left'); + } + break; + } + case 'right': { + if (choices.length === battleNo - 1) { choices += '1'; } + recordData('right'); + while (tiedDataList[recordDataList [pointer - 1]] != -1) { + recordData('right'); + } + break; + } + + /** + * For picking 'tie' (i.e. heretics): + * + * Proceed as if we picked the 'left' character. Then, we record the right character's + * index value into the list of ties (at the left character's index) and then proceed + * as if we picked the 'right' character. + */ + case 'tie': { + if (choices.length === battleNo - 1) { choices += '2'; } + recordData('left'); + while (tiedDataList[recordDataList[pointer - 1]] != -1) { + recordData('left'); + } + tiedDataList[recordDataList[pointer - 1]] = sortedIndexList[rightIndex][rightInnerIndex]; + recordData('right'); + while (tiedDataList[recordDataList [pointer - 1]] != -1) { + recordData('right'); + } + break; + } + default: return; + } + + /** + * Once we reach the limit of the 'right' character list, we + * insert all of the 'left' characters into the record, or vice versa. + */ + const leftListLen = sortedIndexList[leftIndex].length; + const rightListLen = sortedIndexList[rightIndex].length; + + if (leftInnerIndex < leftListLen && rightInnerIndex === rightListLen) { + while (leftInnerIndex < leftListLen) { + recordData('left'); + } + } else if (leftInnerIndex === leftListLen && rightInnerIndex < rightListLen) { + while (rightInnerIndex < rightListLen) { + recordData('right'); + } + } + + /** + * Once we reach the end of both 'left' and 'right' character lists, we can remove + * the arrays from the initial mergesort array, since they are now recorded. This + * record is a sorted version of both lists, so we can replace their original + * (unsorted) parent with a sorted version. Purge the record afterwards. + */ + if (leftInnerIndex === leftListLen && rightInnerIndex === rightListLen) { + for (let i = 0; i < leftListLen + rightListLen; i++) { + sortedIndexList[parentIndexList[leftIndex]][i] = recordDataList[i]; + } + sortedIndexList.pop(); + sortedIndexList.pop(); + leftIndex = leftIndex - 2; + rightIndex = rightIndex - 2; + leftInnerIndex = 0; + rightInnerIndex = 0; + + sortedIndexList.forEach((val, idx) => recordDataList[idx] = 0); + pointer = 0; + } + + /** + * If, after shifting the 'left' index on the sorted list, we reach past the beginning + * of the sorted array, that means the entire array is now sorted. The original unsorted + * array in index 0 is now replaced with a sorted version, and we will now output this. + */ + if (leftIndex < 0) { + timeTaken = timeTaken || new Date().getTime() - timestamp; + + progressBar(`Battle No. ${battleNo} - Completed!`, 100); + + result(); + } else { + battleNo++; + display(); + } +} + +/** + * Records data in recordDataList. + * + * @param {'left'|'right'} sortType Record from the left or the right character array. + */ +function recordData(sortType) { + if (sortType === 'left') { + recordDataList[pointer] = sortedIndexList[leftIndex][leftInnerIndex]; + leftInnerIndex++; + } else { + recordDataList[pointer] = sortedIndexList[rightIndex][rightInnerIndex]; + rightInnerIndex++; + } + + pointer++; + sortedNo++; +} + +/** + * Modifies the progress bar. + * + * @param {string} indicator + * @param {number} percentage + */ +function progressBar(indicator, percentage) { + document.querySelector('.progressbattle').innerHTML = indicator; + document.querySelector('.progressfill').style.width = `${percentage}%`; + document.querySelector('.progresstext').innerHTML = `${percentage}%`; +} + +/** + * Shows the result of the sorter. + * + * @param {number} [imageNum=3] Number of images to display. Defaults to 3. + */ +function result(imageNum = 3) { + document.querySelectorAll('.finished.button').forEach(el => el.style.display = 'block'); + document.querySelector('.image.selector').style.display = 'block'; + document.querySelector('.time.taken').style.display = 'block'; + + document.querySelectorAll('.sorting.button').forEach(el => el.style.display = 'none'); + document.querySelectorAll('.sort.text').forEach(el => el.style.display = 'none'); + document.querySelector('.options').style.display = 'none'; + document.querySelector('.info').style.display = 'none'; + + const header = '
Order
Name
'; + const timeStr = `This sorter was completed on ${new Date(timestamp + timeTaken).toString()} and took ${msToReadableTime(timeTaken)}. Do another sorter?`; + const imgRes = (char, num) => { + const charName = reduceTextWidth(char.name, 'Arial 12px', 160); + const charTooltip = char.name !== charName ? char.name : ''; + return `
${num}
${charName}
`; + } + const res = (char, num) => { + const charName = reduceTextWidth(char.name, 'Arial 12px', 160); + const charTooltip = char.name !== charName ? char.name : ''; + return `
${num}
${charName}
`; + } + + let rankNum = 1; + let tiedRankNum = 1; + let imageDisplay = imageNum; + + const finalSortedIndexes = sortedIndexList[0].slice(0); + const resultTable = document.querySelector('.results'); + const timeElem = document.querySelector('.time.taken'); + + resultTable.innerHTML = header; + timeElem.innerHTML = timeStr; + + characterDataToSort.forEach((val, idx) => { + const characterIndex = finalSortedIndexes[idx]; + const character = characterDataToSort[characterIndex]; + if (imageDisplay-- > 0) { + resultTable.insertAdjacentHTML('beforeend', imgRes(character, rankNum)); + } else { + resultTable.insertAdjacentHTML('beforeend', res(character, rankNum)); + } + finalCharacters.push({ rank: rankNum, name: character.name }); + + if (idx < characterDataToSort.length - 1) { + if (tiedDataList[characterIndex] === finalSortedIndexes[idx + 1]) { + tiedRankNum++; // Indicates how many people are tied at the same rank. + } else { + rankNum += tiedRankNum; // Add it to the actual ranking, then reset it. + tiedRankNum = 1; // The default value is 1, so it increments as normal if no ties. + } + } + }); +} + +/** Undo previous choice. */ +function undo() { + if (timeTaken) { return; } + + choices = battleNo === battleNoPrev ? choices : choices.slice(0, -1); + + sortedIndexList = sortedIndexListPrev.slice(0); + recordDataList = recordDataListPrev.slice(0); + parentIndexList = parentIndexListPrev.slice(0); + tiedDataList = tiedDataListPrev.slice(0); + + leftIndex = leftIndexPrev; + leftInnerIndex = leftInnerIndexPrev; + rightIndex = rightIndexPrev; + rightInnerIndex = rightInnerIndexPrev; + battleNo = battleNoPrev; + sortedNo = sortedNoPrev; + pointer = pointerPrev; + + display(); +} + +/** + * Save progress to local browser storage. + * + * @param {'Autosave'|'Progress'|'Last Result'} saveType +*/ +function saveProgress(saveType) { + const saveData = generateSavedata(); + + localStorage.setItem(`${sorterURL}_saveData`, saveData); + localStorage.setItem(`${sorterURL}_saveType`, saveType); + + if (saveType !== 'Autosave') { + const saveURL = `${location.protocol}//${sorterURL}?${saveData}`; + const inProgressText = 'You may click Load Progress after this to resume, or use this URL.'; + const finishedText = 'You may use this URL to share this result, or click Load Last Result to view it again.'; + + window.prompt(saveType === 'Last Result' ? finishedText : inProgressText, saveURL); + } +} + +/** + * Load progress from local browser storage. +*/ +function loadProgress() { + const saveData = localStorage.getItem(`${sorterURL}_saveData`); + + if (saveData) decodeQuery(saveData); +} + +/** + * Clear progress from local browser storage. +*/ +function clearProgress() { + storedSaveType = ''; + + localStorage.removeItem(`${sorterURL}_saveData`); + localStorage.removeItem(`${sorterURL}_saveType`); + + document.querySelectorAll('.starting.start.button').forEach(el => el.style['grid-row'] = 'span 6'); + document.querySelectorAll('.starting.load.button').forEach(el => el.style.display = 'none'); +} + +function generateImage() { + const timeFinished = timestamp + timeTaken; + const tzoffset = (new Date()).getTimezoneOffset() * 60000; + const filename = 'sort-' + (new Date(timeFinished - tzoffset)).toISOString().slice(0, -5).replace('T', '(') + ').png'; + + html2canvas(document.querySelector('.results')).then(canvas => { + const dataURL = canvas.toDataURL(); + const imgButton = document.querySelector('.finished.getimg.button'); + const resetButton = document.createElement('a'); + + imgButton.removeEventListener('click', generateImage); + imgButton.innerHTML = ''; + imgButton.insertAdjacentHTML('beforeend', `Download Image

`); + + resetButton.insertAdjacentText('beforeend', 'Reset'); + resetButton.addEventListener('click', (event) => { + imgButton.addEventListener('click', generateImage); + imgButton.innerHTML = 'Generate Image'; + event.stopPropagation(); + }); + imgButton.insertAdjacentElement('beforeend', resetButton); + }); +} + +function generateTextList() { + const data = finalCharacters.reduce((str, char) => { + str += `${char.rank}. ${char.name}
`; + return str; + }, ''); + const oWindow = window.open("", "", "height=640,width=480"); + oWindow.document.write(data); +} + +function generateSavedata() { + const saveData = `${timeError?'|':''}${timestamp}|${timeTaken}|${choices}|${optStr}${suboptStr}`; + return LZString.compressToEncodedURIComponent(saveData); +} + +/** Retrieve latest character data and options from dataset. */ +function setLatestDataset() { + /** Set some defaults. */ + timestamp = 0; + timeTaken = 0; + choices = ''; + + const latestDateIndex = Object.keys(dataSet) + .map(date => new Date(date)) + .reduce((latestDateIndex, currentDate, currentIndex, array) => { + return currentDate > array[latestDateIndex] ? currentIndex : latestDateIndex; + }, 0); + currentVersion = Object.keys(dataSet)[latestDateIndex]; + + characterData = dataSet[currentVersion].characterData; + options = dataSet[currentVersion].options; + + populateOptions(); +} + +/** Populate option list. */ +function populateOptions() { + const optList = document.querySelector('.options'); + const optInsert = (name, id, tooltip, checked = true, disabled = false) => { + return `
`; + }; + const optInsertLarge = (name, id, tooltip, checked = true) => { + return `
`; + }; + + /** Clear out any previous options. */ + optList.innerHTML = ''; + + /** Insert sorter options and set grouped option behavior. */ + options.forEach(opt => { + if ('sub' in opt) { + optList.insertAdjacentHTML('beforeend', optInsertLarge(opt.name, opt.key, opt.tooltip, opt.checked)); + opt.sub.forEach((subopt, subindex) => { + optList.insertAdjacentHTML('beforeend', optInsert(subopt.name, `${opt.key}-${subindex}`, subopt.tooltip, subopt.checked, opt.checked === false)); + }); + optList.insertAdjacentHTML('beforeend', '
'); + + const groupbox = document.getElementById(`cbgroup-${opt.key}`); + + groupbox.parentElement.addEventListener('click', () => { + opt.sub.forEach((subopt, subindex) => { + document.getElementById(`cb-${opt.key}-${subindex}`).disabled = !groupbox.checked; + if (groupbox.checked) { document.getElementById(`cb-${opt.key}-${subindex}`).checked = true; } + }); + }); + } else { + optList.insertAdjacentHTML('beforeend', optInsert(opt.name, opt.key, opt.tooltip, opt.checked)); + } + }); +} + +/** + * Decodes compressed shareable link query string. + * @param {string} queryString + */ +function decodeQuery(queryString = window.location.search.slice(1)) { + let successfulLoad; + + try { + /** + * Retrieve data from compressed string. + * @type {string[]} + */ + const decoded = LZString.decompressFromEncodedURIComponent(queryString).split('|'); + if (!decoded[0]) { + decoded.splice(0, 1); + timeError = true; + } + + timestamp = Number(decoded.splice(0, 1)[0]); + timeTaken = Number(decoded.splice(0, 1)[0]); + choices = decoded.splice(0, 1)[0]; + + const optDecoded = decoded.splice(0, 1)[0]; + const suboptDecoded = decoded.slice(0); + + /** + * Get latest data set version from before the timestamp. + * If timestamp is before or after any of the datasets, get the closest one. + * If timestamp is between any of the datasets, get the one in the past, but if timeError is set, get the one in the future. + */ + const seedDate = { str: timestamp, val: new Date(timestamp) }; + const dateMap = Object.keys(dataSet) + .map(date => { + return { str: date, val: new Date(date) }; + }) + const beforeDateIndex = dateMap + .reduce((prevIndex, currDate, currIndex) => { + return currDate.val < seedDate.val ? currIndex : prevIndex; + }, -1); + const afterDateIndex = dateMap.findIndex(date => date.val > seedDate.val); + + if (beforeDateIndex === -1) { + currentVersion = dateMap[afterDateIndex].str; + } else if (afterDateIndex === -1) { + currentVersion = dateMap[beforeDateIndex].str; + } else { + currentVersion = dateMap[timeError ? afterDateIndex : beforeDateIndex].str; + } + + options = dataSet[currentVersion].options; + characterData = dataSet[currentVersion].characterData; + + /** Populate option list and decode options selected. */ + populateOptions(); + + let suboptDecodedIndex = 0; + options.forEach((opt, index) => { + if ('sub' in opt) { + const optIsTrue = optDecoded[index] === '1'; + document.getElementById(`cbgroup-${opt.key}`).checked = optIsTrue; + opt.sub.forEach((subopt, subindex) => { + const subIsTrue = optIsTrue ? suboptDecoded[suboptDecodedIndex][subindex] === '1' : true; + document.getElementById(`cb-${opt.key}-${subindex}`).checked = subIsTrue; + document.getElementById(`cb-${opt.key}-${subindex}`).disabled = optIsTrue; + }); + suboptDecodedIndex = suboptDecodedIndex + optIsTrue ? 1 : 0; + } else { document.getElementById(`cb-${opt.key}`).checked = optDecoded[index] === '1'; } + }); + + successfulLoad = true; + } catch (err) { + console.error(`Error loading shareable link: ${err}`); + setLatestDataset(); // Restore to default function if loading link does not work. + } + + if (successfulLoad) { start(); } +} + +/** + * Preloads images in the filtered character data and converts to base64 representation. +*/ +function preloadImages() { + const totalLength = characterDataToSort.length; + let imagesLoaded = 0; + + const loadImage = async (src) => { + const blob = await fetch(src).then(res => res.blob()); + return new Promise((res, rej) => { + const reader = new FileReader(); + reader.onload = ev => { + progressBar(`Loading Image ${++imagesLoaded}`, Math.floor(imagesLoaded * 100 / totalLength)); + res(ev.target.result); + }; + reader.onerror = rej; + reader.readAsDataURL(blob); + }); + }; + + return Promise.all(characterDataToSort.map(async (char, idx) => { + characterDataToSort[idx].img = await loadImage(imageRoot + char.img); + })); +} + +/** + * Returns a readable time string from milliseconds. + * + * @param {number} milliseconds + */ +function msToReadableTime (milliseconds) { + let t = Math.floor(milliseconds/1000); + const years = Math.floor(t / 31536000); + t = t - (years * 31536000); + const months = Math.floor(t / 2592000); + t = t - (months * 2592000); + const days = Math.floor(t / 86400); + t = t - (days * 86400); + const hours = Math.floor(t / 3600); + t = t - (hours * 3600); + const minutes = Math.floor(t / 60); + t = t - (minutes * 60); + const content = []; + if (years) content.push(years + " year" + (years > 1 ? "s" : "")); + if (months) content.push(months + " month" + (months > 1 ? "s" : "")); + if (days) content.push(days + " day" + (days > 1 ? "s" : "")); + if (hours) content.push(hours + " hour" + (hours > 1 ? "s" : "")); + if (minutes) content.push(minutes + " minute" + (minutes > 1 ? "s" : "")); + if (t) content.push(t + " second" + (t > 1 ? "s" : "")); + return content.slice(0,3).join(', '); +} + +/** + * Reduces text to a certain rendered width. + * + * @param {string} text Text to reduce. + * @param {string} font Font applied to text. Example "12px Arial". + * @param {number} width Width of desired width in px. + */ +function reduceTextWidth(text, font, width) { + const canvas = reduceTextWidth.canvas || (reduceTextWidth.canvas = document.createElement("canvas")); + const context = canvas.getContext("2d"); + context.font = font; + if (context.measureText(text).width < width * 0.8) { + return text; + } else { + let reducedText = text; + while (context.measureText(reducedText).width + context.measureText('..').width > width * 0.8) { + reducedText = reducedText.slice(0, -1); + } + return reducedText + '..'; + } +} + +window.onload = init; diff --git a/src/js/res.html b/src/js/res.html new file mode 100644 index 0000000..b1576c9 --- /dev/null +++ b/src/js/res.html @@ -0,0 +1,5452 @@ + + + + + + + + + + + + + + + + + + + + +Girls & Panzer (Girls und Panzer) - Characters & Staff - MyAnimeList.net + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ +
+
+ + + + + + +
+

Girls & Panzer


Girls und Panzer

+ Edit +
+
+ +
What would you like to edit?
+ +   +
+
+
+ + + + + +
+ +
+ + Girls & Panzer + +
+ + + + + + + + + +

+ +

Alternative Titles

+ Synonyms: Garupan, Girls und Panzer +
+ Japanese: ガールズ&パンツァー +
+ English: Girls und Panzer +
+ Spanish: Girls und Panzer +
+
+ French: Girls und Panzer +
+
+ + More titles

+ + +

Information

+ +
+ Type: + TV
+ +
+ Episodes: + 12 +
+ +
+ Status: + Finished Airing +
+ +
+ Aired: + Oct 9, 2012 to Mar 25, 2013 +
+ +
+ Premiered: + Fall 2012 +
+ +
+ Broadcast: + Tuesdays at 01:00 (JST) +
+ + +
+ Licensors: + Sentai Filmworks
+
+ Studios: + Actas
+ +
+ Source: + Original +
+ +
+ Genre: + ActionAction
+
+ Themes: + MilitaryMilitary, SchoolSchool
+ +
+ Duration: + 24 min. per ep. +
+ +
+ Rating: + PG-13 - Teens 13 or older +
+ +
+ +

Statistics

+
+ Score: + 7.521 (scored by 133590133,590 users) + + +
+ 1 + indicates a weighted score. + +
+
+
+ Ranked: + #16102 +
+ 2 + based on the top anime page. Please note that 'Not yet aired' and 'R18+' titles are excluded. + +
+
+
+ Popularity: + #732 +
+
+ Members: + 267,832 +
+
+ Favorites: + 4,754 +
+ +
+

External Links

+ +
+

Streaming Platforms

+
+
HIDIVE
+
May be unavailable in your region.
+
+
+ +
+ +
+
+ +
+
+ +
+
+
+ +
+
+ + + + + + + + + +

Characters & Voice Actors

+ + +
+
+
+ +
+
+
+
+ +
+

+ +
+
+ Add staff +
+

Staff

+
+ + + + +
+
+ + Mizushima, Tsutomu + +
+
+ Mizushima, Tsutomu +
+ Director, Episode Director, Storyboard +
+
+ + + + +
+
+ + Iwanami, Yoshikazu + +
+
+ Iwanami, Yoshikazu +
+ Sound Director +
+
+ + + + +
+
+ + Hashiguchi, Yousuke + +
+
+ Hashiguchi, Yousuke +
+ Episode Director +
+
+ + + + +
+
+ + Hata, Hiroyuki + +
+
+ Hata, Hiroyuki +
+ Episode Director, Storyboard +
+
+ + + + +
+
+ + Kobayashi, Atsushi + +
+
+ Kobayashi, Atsushi +
+ Episode Director, Storyboard +
+
+ + + + +
+
+ + Shibata, Akihisa + +
+
+ Shibata, Akihisa +
+ Episode Director +
+
+ + + + +
+
+ + Yoshida, Reiko + +
+
+ Yoshida, Reiko +
+ Script, Series Composition +
+
+ + + + +
+
+ + Naitou, Mea + +
+
+ Naitou, Mea +
+ Storyboard +
+
+ + + + +
+
+ + Shimoda, Masami + +
+
+ Shimoda, Masami +
+ Storyboard +
+
+ + + + +
+
+ + Yamauchi, Noriyasu + +
+
+ Yamauchi, Noriyasu +
+ Storyboard +
+
+ + + + +
+
+ + ChouCho + +
+
+ ChouCho +
+ Theme Song Performance +
+
+ + + + +
+
+ + Fuchigami, Mai + +
+
+ Fuchigami, Mai +
+ Theme Song Performance +
+
+ + + + +
+
+ + Iguchi, Yuka + +
+
+ Iguchi, Yuka +
+ Theme Song Performance +
+
+ + + + +
+
+ + Kayano, Ai + +
+
+ Kayano, Ai +
+ Theme Song Performance +
+
+ + + + +
+
+ + Nakagami, Ikumi + +
+
+ Nakagami, Ikumi +
+ Theme Song Performance +
+
+ + + + +
+
+ + Ozaki, Mami + +
+
+ Ozaki, Mami +
+ Theme Song Performance +
+
+ + + + +
+
+ + rino + +
+
+ rino +
+ Theme Song Composition +
+
+ + + + +
+
+ + Abe, Munetaka + +
+
+ Abe, Munetaka +
+ Key Animation +
+
+ + + + +
+
+ + Aoyama, Masanobu + +
+
+ Aoyama, Masanobu +
+ Key Animation +
+
+ + + + +
+
+ + Chiba, Yuriko + +
+
+ Chiba, Yuriko +
+ Key Animation +
+
+ + + + +
+
+ + Hamaguchi, Shirou + +
+
+ Hamaguchi, Shirou +
+ Music +
+
+ + + + +
+
+ + Harada, Sachiko + +
+
+ Harada, Sachiko +
+ Color Design +
+
+ + + + +
+
+ + Inoue, Kazutoshi + +
+
+ Inoue, Kazutoshi +
+ In-Between Animation +
+
+ + + + +
+
+ + Itou, Takeshi + +
+
+ Itou, Takeshi +
+ Animation Director, Assistant Animation Director, Key Animation, Mechanical Design +
+
+ + + + +
+
+ + Kojima, Erina + +
+
+ Kojima, Erina +
+ Key Animation +
+
+ + + + +
+
+ + Kozaki, Hirotaka + +
+
+ Kozaki, Hirotaka +
+ Background Art +
+
+ + + + +
+
+ + Kusama, Hideoki + +
+
+ Kusama, Hideoki +
+ Key Animation +
+
+ + + + +
+
+ + Ledford, John + +
+
+ Ledford, John +
+ Executive Producer +
+
+ + + + +
+
+ + Miyazawa, Yasunori + +
+
+ Miyazawa, Yasunori +
+ Key Animation +
+
+ + + + +
+
+ + Mutou, Kazuhiro + +
+
+ Mutou, Kazuhiro +
+ Key Animation +
+
+ + + + +
+
+ + Nagamachi, Hideki + +
+
+ Nagamachi, Hideki +
+ Key Animation +
+
+ + + + +
+
+ + Naraoka, Hikaru + +
+
+ Naraoka, Hikaru +
+ Key Animation +
+
+ + + + +
+
+ + Niel, Herms + +
+
+ Niel, Herms +
+ Music +
+
+ + + + +
+
+ + Nishio, Kimitake + +
+
+ Nishio, Kimitake +
+ Key Animation +
+
+ + + + +
+
+ + Nogami, Takeshi + +
+
+ Nogami, Takeshi +
+ Original Character Design +
+
+ + + + +
+
+ + Sano, Takashi + +
+
+ Sano, Takashi +
+ Key Animation +
+
+ + + + +
+
+ + Sasaki, Sayaka + +
+
+ Sasaki, Sayaka +
+ Inserted Song Performance +
+
+ + + + +
+
+ + Shimada, Humikane + +
+
+ Shimada, Humikane +
+ Original Character Design +
+
+ + + + +
+
+ + Sugimoto, Isao + +
+
+ Sugimoto, Isao +
+ Chief Animation Director, Character Design +
+
+ + + + +
+
+ + Tchaikovsky, Pyotr Ilyich + +
+
+ Tchaikovsky, Pyotr Ilyich +
+ Music +
+
+ + + + +
+
+ + Williams, Janice + +
+
+ Williams, Janice +
+ ADR Director +
+
+ + + + +
+
+ + Yamagihara, Takumi + +
+
+ Yamagihara, Takumi +
+ Background Art +
+
+ + + + +
+
+ + Yamaguchi, Asuka + +
+
+ Yamaguchi, Asuka +
+ Key Animation, Animation Director, Assistant Animation Director +
+
+ + + + +
+
+ + Yamashita, Masahito + +
+
+ Yamashita, Masahito +
+ Key Animation +
+
+ + + + +
+
+ + Yoshida, Risako + +
+
+ Yoshida, Risako +
+ Background Art +
+
+
+
+
+
+
+ +
+
+
+ + + + + + + + + + + + +
+ + + +
+ + +
+ +
+
+ + + + + + + + + + + + + + + + + diff --git a/src/js/res.txt b/src/js/res.txt new file mode 100644 index 0000000..60e5212 --- /dev/null +++ b/src/js/res.txt @@ -0,0 +1,228 @@ +{name: "Akiyama, Yukari", + img: "13/220639.jpg", + opts: {} + }, +{name: "Isuzu, Hana", + img: "14/183595.jpg", + opts: {} + }, +{name: "Nishizumi, Miho", + img: "15/208209.jpg", + opts: {} + }, +{name: "Reizei, Mako", + img: "3/253025.jpg", + opts: {} + }, +{name: "Takebe, Saori", + img: "9/253031.jpg", + opts: {} + }, +{name: "Akaboshi, Koume", + img: "6/264545.jpg", + opts: {} + }, +{name: "Akiyama, Jungorou", + img: "10/251349.jpg", + opts: {} + }, +{name: "Akiyama, Yoshiko", + img: "3/251319.jpg", + opts: {} + }, +{name: "Alisa", + img: "8/186485.jpg", + opts: {} + }, +{name: "Anzai, Chiyomi", + img: "5/277937.jpg", + opts: {} + }, +{name: "Assam", + img: "3/185595.jpg", + opts: {} + }, +{name: "Chouno, Ami", + img: "13/184299.jpg", + opts: {} + }, +{name: "Darjeeling", + img: "10/355674.jpg", + opts: {} + }, +{name: "Gotou, Moyoko", + img: "12/249083.jpg", + opts: {} + }, +{name: "Hoshino", + img: "5/200517.jpg", + opts: {} + }, +{name: "Inatomi, Hibiki", + img: "9/266043.jpg", + opts: {} + }, +{name: "Isobe, Noriko", + img: "4/306126.jpg", + opts: {} + }, +{name: "Isuzu, Yuri", + img: "14/200523.jpg", + opts: {} + }, +{name: "Itsumi, Erika", + img: "2/360836.jpg", + opts: {} + }, +{name: "Kadotani, Anzu", + img: "9/229625.jpg", + opts: {} + }, +{name: "Katyusha", + img: "14/193255.jpg", + opts: {} + }, +{name: "Kawanishi, Shinobu", + img: "14/449666.jpg", + opts: {} + }, +{name: "Kawashima, Momo", + img: "2/184305.jpg", + opts: {} + }, +{name: "Kei", + img: "14/381763.jpg", + opts: {} + }, +{name: "Kondou, Taeko", + img: "11/391698.jpg", + opts: {} + }, +{name: "Konparu, Nozomi", + img: "13/249081.jpg", + opts: {} + }, +{name: "Koyama, Yuzu", + img: "12/191392.jpg", + opts: {} + }, +{name: "Maruyama, Saki", + img: "2/184293.jpg", + opts: {} + }, +{name: "Matsumoto, Riko", + img: "3/186191.jpg", + opts: {} + }, +{name: "Momoga", + img: "14/190906.jpg", + opts: {} + }, +{name: "Nakajima, Satoko", + img: "7/200519.jpg", + opts: {} + }, +{name: "Naomi", + img: "16/187787.jpg", + opts: {} + }, +{name: "Nekota", + img: "8/190904.jpg", + opts: {} + }, +{name: "Nilgiri", + img: "3/441097.jpg", + opts: {} + }, +{name: "Nishizumi, Maho", + img: "9/200657.jpg", + opts: {} + }, +{name: "Nishizumi, Shiho", + img: "2/249079.jpg", + opts: {} + }, +{name: "Nogami, Takeko", + img: "12/184467.jpg", + opts: {} + }, +{name: "Nonna", + img: "10/197747.jpg", + opts: {} + }, +{name: "Oono, Aya", + img: "3/184301.jpg", + opts: {} + }, +{name: "Orange Pekoe", + img: "13/185597.jpg", + opts: {} + }, +{name: "Ou, Taiga", + img: "6/252081.jpg", + opts: {} + }, +{name: "Piyotan", + img: "12/190908.jpg", + opts: {} + }, +{name: "Reizei, Hisako", + img: "8/249077.jpg", + opts: {} + }, +{name: "Rukuriri", + img: "16/313972.jpg", + opts: {} + }, +{name: "Sakaguchi, Karina", + img: "9/184297.jpg", + opts: {} + }, +{name: "Sasagawa, Kanon", + img: "3/266041.jpg", + opts: {} + }, +{name: "Sasaki, Akebi", + img: "11/251325.jpg", + opts: {} + }, +{name: "Sawa, Azusa", + img: "7/187799.jpg", + opts: {} + }, +{name: "Shinzaburou", + img: "8/190910.jpg", + opts: {} + }, +{name: "Sono, Midoriko", + img: "12/185967.jpg", + opts: {} + }, +{name: "Sugiyama, Kiyomi", + img: "14/184577.jpg", + opts: {} + }, +{name: "Suzuki", + img: "6/251329.jpg", + opts: {} + }, +{name: "Suzuki, Takako", + img: "9/184579.jpg", + opts: {} + }, +{name: "Takashima, Remi", + img: "12/266045.jpg", + opts: {} + }, +{name: "Tsuchiya", + img: "7/200521.jpg", + opts: {} + }, +{name: "Utsugi, Yuuki", + img: "16/184291.jpg", + opts: {} + }, +{name: "Yamagou, Ayumi", + img: "11/184295.jpg", + opts: {} + }, diff --git a/src/js/seedrandom.min.js b/src/js/seedrandom.min.js new file mode 100644 index 0000000..401b4bf --- /dev/null +++ b/src/js/seedrandom.min.js @@ -0,0 +1 @@ +!function(a,b){function c(c,j,k){var n=[];j=1==j?{entropy:!0}:j||{};var s=g(f(j.entropy?[c,i(a)]:null==c?h():c,3),n),t=new d(n),u=function(){for(var a=t.g(m),b=p,c=0;a=r;)a/=2,b/=2,c>>>=1;return(a+c)/b};return u.int32=function(){return 0|t.g(4)},u.quick=function(){return t.g(4)/4294967296},u.double=u,g(i(t.S),a),(j.pass||k||function(a,c,d,f){return f&&(f.S&&e(f,t),a.state=function(){return e(t,{})}),d?(b[o]=a,c):a})(u,s,"global"in j?j.global:this==b,j.state)}function d(a){var b,c=a.length,d=this,e=0,f=d.i=d.j=0,g=d.S=[];for(c||(a=[c++]);e