From d4309f2ed79a188dbd2091a58ec4c04b11ed0d2d Mon Sep 17 00:00:00 2001 From: Derik Ramirez Date: Tue, 12 May 2020 09:30:44 -0600 Subject: [PATCH 1/4] Adds Webpack configuration for bundling our JavaScript --- .gitignore | 2 + package.json | 19 + .../webui/templates/resources/edit.html | 2 +- src/virtualhosts/www/javascript/main.js | 1 + webpack.config.js | 10 + yarn.lock | 2671 +++++++++++++++++ 6 files changed, 2704 insertions(+), 1 deletion(-) create mode 100644 package.json create mode 100644 src/virtualhosts/www/javascript/main.js create mode 100644 webpack.config.js create mode 100644 yarn.lock diff --git a/.gitignore b/.gitignore index 901ff385c..16bbd009b 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,5 @@ log/ #test/ src/virtualhosts/log src/virtualhosts/output +node_modules +src/virtualhosts/www/javascript/bundle.js diff --git a/package.json b/package.json new file mode 100644 index 000000000..e9a8dd5b3 --- /dev/null +++ b/package.json @@ -0,0 +1,19 @@ +{ + "name": "snac", + "version": "1.0.0", + "description": "SNAC Cooperative Frontend JavaScripts", + "main": "main.js", + "repository": "blank", + "author": "Derik Ramirez ", + "license": "Private", + "private": true, + "dependencies": { + "webpack": "^4.43.0" + }, + "scripts": { + "build": "webpack" + }, + "devDependencies": { + "webpack-cli": "^3.3.11" + } +} diff --git a/src/snac/client/webui/templates/resources/edit.html b/src/snac/client/webui/templates/resources/edit.html index 6762980b2..fdca22802 100644 --- a/src/snac/client/webui/templates/resources/edit.html +++ b/src/snac/client/webui/templates/resources/edit.html @@ -35,7 +35,7 @@ - + diff --git a/src/virtualhosts/www/javascript/main.js b/src/virtualhosts/www/javascript/main.js new file mode 100644 index 000000000..ba45c557d --- /dev/null +++ b/src/virtualhosts/www/javascript/main.js @@ -0,0 +1 @@ +import { loadVocabSelectOptions } from "./select_loaders.js" diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 000000000..162647904 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,10 @@ +const path = require('path'); +const js_path = path.join(__dirname, "src/virtualhosts/www/javascript") + +module.exports = { + entry: path.join(js_path, "main.js"), + output: { + path: js_path, + filename: "bundle.js" + } +}; diff --git a/yarn.lock b/yarn.lock new file mode 100644 index 000000000..28cd50e14 --- /dev/null +++ b/yarn.lock @@ -0,0 +1,2671 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + + +"@webassemblyjs/ast@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ast/-/ast-1.9.0.tgz#bd850604b4042459a5a41cd7d338cbed695ed964" + integrity sha512-C6wW5L+b7ogSDVqymbkkvuW9kruN//YisMED04xzeBBqjHa2FYnmvOlS6Xj68xWQRgWvI9cIglsjFowH/RJyEA== + dependencies: + "@webassemblyjs/helper-module-context" "1.9.0" + "@webassemblyjs/helper-wasm-bytecode" "1.9.0" + "@webassemblyjs/wast-parser" "1.9.0" + +"@webassemblyjs/floating-point-hex-parser@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/floating-point-hex-parser/-/floating-point-hex-parser-1.9.0.tgz#3c3d3b271bddfc84deb00f71344438311d52ffb4" + integrity sha512-TG5qcFsS8QB4g4MhrxK5TqfdNe7Ey/7YL/xN+36rRjl/BlGE/NcBvJcqsRgCP6Z92mRE+7N50pRIi8SmKUbcQA== + +"@webassemblyjs/helper-api-error@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-api-error/-/helper-api-error-1.9.0.tgz#203f676e333b96c9da2eeab3ccef33c45928b6a2" + integrity sha512-NcMLjoFMXpsASZFxJ5h2HZRcEhDkvnNFOAKneP5RbKRzaWJN36NC4jqQHKwStIhGXu5mUWlUUk7ygdtrO8lbmw== + +"@webassemblyjs/helper-buffer@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-buffer/-/helper-buffer-1.9.0.tgz#a1442d269c5feb23fcbc9ef759dac3547f29de00" + integrity sha512-qZol43oqhq6yBPx7YM3m9Bv7WMV9Eevj6kMi6InKOuZxhw+q9hOkvq5e/PpKSiLfyetpaBnogSbNCfBwyB00CA== + +"@webassemblyjs/helper-code-frame@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-code-frame/-/helper-code-frame-1.9.0.tgz#647f8892cd2043a82ac0c8c5e75c36f1d9159f27" + integrity sha512-ERCYdJBkD9Vu4vtjUYe8LZruWuNIToYq/ME22igL+2vj2dQ2OOujIZr3MEFvfEaqKoVqpsFKAGsRdBSBjrIvZA== + dependencies: + "@webassemblyjs/wast-printer" "1.9.0" + +"@webassemblyjs/helper-fsm@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-fsm/-/helper-fsm-1.9.0.tgz#c05256b71244214671f4b08ec108ad63b70eddb8" + integrity sha512-OPRowhGbshCb5PxJ8LocpdX9Kl0uB4XsAjl6jH/dWKlk/mzsANvhwbiULsaiqT5GZGT9qinTICdj6PLuM5gslw== + +"@webassemblyjs/helper-module-context@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-module-context/-/helper-module-context-1.9.0.tgz#25d8884b76839871a08a6c6f806c3979ef712f07" + integrity sha512-MJCW8iGC08tMk2enck1aPW+BE5Cw8/7ph/VGZxwyvGbJwjktKkDK7vy7gAmMDx88D7mhDTCNKAW5tED+gZ0W8g== + dependencies: + "@webassemblyjs/ast" "1.9.0" + +"@webassemblyjs/helper-wasm-bytecode@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-bytecode/-/helper-wasm-bytecode-1.9.0.tgz#4fed8beac9b8c14f8c58b70d124d549dd1fe5790" + integrity sha512-R7FStIzyNcd7xKxCZH5lE0Bqy+hGTwS3LJjuv1ZVxd9O7eHCedSdrId/hMOd20I+v8wDXEn+bjfKDLzTepoaUw== + +"@webassemblyjs/helper-wasm-section@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/helper-wasm-section/-/helper-wasm-section-1.9.0.tgz#5a4138d5a6292ba18b04c5ae49717e4167965346" + integrity sha512-XnMB8l3ek4tvrKUUku+IVaXNHz2YsJyOOmz+MMkZvh8h1uSJpSen6vYnw3IoQ7WwEuAhL8Efjms1ZWjqh2agvw== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-buffer" "1.9.0" + "@webassemblyjs/helper-wasm-bytecode" "1.9.0" + "@webassemblyjs/wasm-gen" "1.9.0" + +"@webassemblyjs/ieee754@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/ieee754/-/ieee754-1.9.0.tgz#15c7a0fbaae83fb26143bbacf6d6df1702ad39e4" + integrity sha512-dcX8JuYU/gvymzIHc9DgxTzUUTLexWwt8uCTWP3otys596io0L5aW02Gb1RjYpx2+0Jus1h4ZFqjla7umFniTg== + dependencies: + "@xtuc/ieee754" "^1.2.0" + +"@webassemblyjs/leb128@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/leb128/-/leb128-1.9.0.tgz#f19ca0b76a6dc55623a09cffa769e838fa1e1c95" + integrity sha512-ENVzM5VwV1ojs9jam6vPys97B/S65YQtv/aanqnU7D8aSoHFX8GyhGg0CMfyKNIHBuAVjy3tlzd5QMMINa7wpw== + dependencies: + "@xtuc/long" "4.2.2" + +"@webassemblyjs/utf8@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/utf8/-/utf8-1.9.0.tgz#04d33b636f78e6a6813227e82402f7637b6229ab" + integrity sha512-GZbQlWtopBTP0u7cHrEx+73yZKrQoBMpwkGEIqlacljhXCkVM1kMQge/Mf+csMJAjEdSwhOyLAS0AoR3AG5P8w== + +"@webassemblyjs/wasm-edit@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-edit/-/wasm-edit-1.9.0.tgz#3fe6d79d3f0f922183aa86002c42dd256cfee9cf" + integrity sha512-FgHzBm80uwz5M8WKnMTn6j/sVbqilPdQXTWraSjBwFXSYGirpkSWE2R9Qvz9tNiTKQvoKILpCuTjBKzOIm0nxw== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-buffer" "1.9.0" + "@webassemblyjs/helper-wasm-bytecode" "1.9.0" + "@webassemblyjs/helper-wasm-section" "1.9.0" + "@webassemblyjs/wasm-gen" "1.9.0" + "@webassemblyjs/wasm-opt" "1.9.0" + "@webassemblyjs/wasm-parser" "1.9.0" + "@webassemblyjs/wast-printer" "1.9.0" + +"@webassemblyjs/wasm-gen@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-gen/-/wasm-gen-1.9.0.tgz#50bc70ec68ded8e2763b01a1418bf43491a7a49c" + integrity sha512-cPE3o44YzOOHvlsb4+E9qSqjc9Qf9Na1OO/BHFy4OI91XDE14MjFN4lTMezzaIWdPqHnsTodGGNP+iRSYfGkjA== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-wasm-bytecode" "1.9.0" + "@webassemblyjs/ieee754" "1.9.0" + "@webassemblyjs/leb128" "1.9.0" + "@webassemblyjs/utf8" "1.9.0" + +"@webassemblyjs/wasm-opt@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-opt/-/wasm-opt-1.9.0.tgz#2211181e5b31326443cc8112eb9f0b9028721a61" + integrity sha512-Qkjgm6Anhm+OMbIL0iokO7meajkzQD71ioelnfPEj6r4eOFuqm4YC3VBPqXjFyyNwowzbMD+hizmprP/Fwkl2A== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-buffer" "1.9.0" + "@webassemblyjs/wasm-gen" "1.9.0" + "@webassemblyjs/wasm-parser" "1.9.0" + +"@webassemblyjs/wasm-parser@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wasm-parser/-/wasm-parser-1.9.0.tgz#9d48e44826df4a6598294aa6c87469d642fff65e" + integrity sha512-9+wkMowR2AmdSWQzsPEjFU7njh8HTO5MqO8vjwEHuM+AMHioNqSBONRdr0NQQ3dVQrzp0s8lTcYqzUdb7YgELA== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-api-error" "1.9.0" + "@webassemblyjs/helper-wasm-bytecode" "1.9.0" + "@webassemblyjs/ieee754" "1.9.0" + "@webassemblyjs/leb128" "1.9.0" + "@webassemblyjs/utf8" "1.9.0" + +"@webassemblyjs/wast-parser@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-parser/-/wast-parser-1.9.0.tgz#3031115d79ac5bd261556cecc3fa90a3ef451914" + integrity sha512-qsqSAP3QQ3LyZjNC/0jBJ/ToSxfYJ8kYyuiGvtn/8MK89VrNEfwj7BPQzJVHi0jGTRK2dGdJ5PRqhtjzoww+bw== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/floating-point-hex-parser" "1.9.0" + "@webassemblyjs/helper-api-error" "1.9.0" + "@webassemblyjs/helper-code-frame" "1.9.0" + "@webassemblyjs/helper-fsm" "1.9.0" + "@xtuc/long" "4.2.2" + +"@webassemblyjs/wast-printer@1.9.0": + version "1.9.0" + resolved "https://registry.yarnpkg.com/@webassemblyjs/wast-printer/-/wast-printer-1.9.0.tgz#4935d54c85fef637b00ce9f52377451d00d47899" + integrity sha512-2J0nE95rHXHyQ24cWjMKJ1tqB/ds8z/cyeOZxJhcb+rW+SQASVjuznUSmdz5GpVJTzU8JkhYut0D3siFDD6wsA== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/wast-parser" "1.9.0" + "@xtuc/long" "4.2.2" + +"@xtuc/ieee754@^1.2.0": + version "1.2.0" + resolved "https://registry.yarnpkg.com/@xtuc/ieee754/-/ieee754-1.2.0.tgz#eef014a3145ae477a1cbc00cd1e552336dceb790" + integrity sha512-DX8nKgqcGwsc0eJSqYt5lwP4DH5FlHnmuWWBRy7X0NcaGR0ZtuyeESgMwTYVEtxmsNGY+qit4QYT/MIYTOTPeA== + +"@xtuc/long@4.2.2": + version "4.2.2" + resolved "https://registry.yarnpkg.com/@xtuc/long/-/long-4.2.2.tgz#d291c6a4e97989b5c61d9acf396ae4fe133a718d" + integrity sha512-NuHqBY1PB/D8xU6s/thBgOAiAP7HOYDQ32+BFZILJ8ivkUkAHQnWfn6WhL79Owj1qmUnoN/YPhktdIoucipkAQ== + +acorn@^6.4.1: + version "6.4.1" + resolved "https://registry.yarnpkg.com/acorn/-/acorn-6.4.1.tgz#531e58ba3f51b9dacb9a6646ca4debf5b14ca474" + integrity sha512-ZVA9k326Nwrj3Cj9jlh3wGFutC2ZornPNARZwsNYqQYgN0EsV2d53w5RN/co65Ohn4sUAUtb1rSUAOD6XN9idA== + +ajv-errors@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/ajv-errors/-/ajv-errors-1.0.1.tgz#f35986aceb91afadec4102fbd85014950cefa64d" + integrity sha512-DCRfO/4nQ+89p/RK43i8Ezd41EqdGIU4ld7nGF8OQ14oc/we5rEntLCUa7+jrn3nn83BosfwZA0wb4pon2o8iQ== + +ajv-keywords@^3.1.0, ajv-keywords@^3.4.1: + version "3.4.1" + resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-3.4.1.tgz#ef916e271c64ac12171fd8384eaae6b2345854da" + integrity sha512-RO1ibKvd27e6FEShVFfPALuHI3WjSVNeK5FIsmme/LYRNxjKuNj+Dt7bucLa6NdSv3JcVTyMlm9kGR84z1XpaQ== + +ajv@^6.1.0, ajv@^6.10.2: + version "6.12.2" + resolved "https://registry.yarnpkg.com/ajv/-/ajv-6.12.2.tgz#c629c5eced17baf314437918d2da88c99d5958cd" + integrity sha512-k+V+hzjm5q/Mr8ef/1Y9goCmlsK4I6Sm74teeyGvFk1XrOsbsKLjEdrvny42CZ+a8sXbk8KWpY/bDwS+FLL2UQ== + dependencies: + fast-deep-equal "^3.1.1" + fast-json-stable-stringify "^2.0.0" + json-schema-traverse "^0.4.1" + uri-js "^4.2.2" + +ansi-regex@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" + integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== + +ansi-styles@^3.2.0, ansi-styles@^3.2.1: + version "3.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" + integrity sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA== + dependencies: + color-convert "^1.9.0" + +anymatch@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-2.0.0.tgz#bcb24b4f37934d9aa7ac17b4adaf89e7c76ef2eb" + integrity sha512-5teOsQWABXHHBFP9y3skS5P3d/WfWXpv3FUpy+LorMrNYaT9pI4oLMQX7jzQ2KklNpGpWHzdCXTDT2Y3XGlZBw== + dependencies: + micromatch "^3.1.4" + normalize-path "^2.1.1" + +aproba@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/aproba/-/aproba-1.2.0.tgz#6802e6264efd18c790a1b0d517f0f2627bf2c94a" + integrity sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw== + +arr-diff@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/arr-diff/-/arr-diff-4.0.0.tgz#d6461074febfec71e7e15235761a329a5dc7c520" + integrity sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA= + +arr-flatten@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/arr-flatten/-/arr-flatten-1.1.0.tgz#36048bbff4e7b47e136644316c99669ea5ae91f1" + integrity sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg== + +arr-union@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/arr-union/-/arr-union-3.1.0.tgz#e39b09aea9def866a8f206e288af63919bae39c4" + integrity sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ= + +array-unique@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" + integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= + +asn1.js@^4.0.0: + version "4.10.1" + resolved "https://registry.yarnpkg.com/asn1.js/-/asn1.js-4.10.1.tgz#b9c2bf5805f1e64aadeed6df3a2bfafb5a73f5a0" + integrity sha512-p32cOF5q0Zqs9uBiONKYLm6BClCoBCM5O9JfeUSlnQLBTxYdTK+pW+nXflm8UkKd2UYlEbYz5qEi0JuZR9ckSw== + dependencies: + bn.js "^4.0.0" + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + +assert@^1.1.1: + version "1.5.0" + resolved "https://registry.yarnpkg.com/assert/-/assert-1.5.0.tgz#55c109aaf6e0aefdb3dc4b71240c70bf574b18eb" + integrity sha512-EDsgawzwoun2CZkCgtxJbv392v4nbk9XDD06zI+kQYoBM/3RBWLlEyJARDOmhAAosBjWACEkKL6S+lIZtcAubA== + dependencies: + object-assign "^4.1.1" + util "0.10.3" + +assign-symbols@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/assign-symbols/-/assign-symbols-1.0.0.tgz#59667f41fadd4f20ccbc2bb96b8d4f7f78ec0367" + integrity sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c= + +async-each@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/async-each/-/async-each-1.0.3.tgz#b727dbf87d7651602f06f4d4ac387f47d91b0cbf" + integrity sha512-z/WhQ5FPySLdvREByI2vZiTWwCnF0moMJ1hK9YQwDTHKh6I7/uSckMetoRGb5UBZPC1z0jlw+n/XCgjeH7y1AQ== + +atob@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" + integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== + +balanced-match@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" + integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= + +base64-js@^1.0.2: + version "1.3.1" + resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.1.tgz#58ece8cb75dd07e71ed08c736abc5fac4dbf8df1" + integrity sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g== + +base@^0.11.1: + version "0.11.2" + resolved "https://registry.yarnpkg.com/base/-/base-0.11.2.tgz#7bde5ced145b6d551a90db87f83c558b4eb48a8f" + integrity sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg== + dependencies: + cache-base "^1.0.1" + class-utils "^0.3.5" + component-emitter "^1.2.1" + define-property "^1.0.0" + isobject "^3.0.1" + mixin-deep "^1.2.0" + pascalcase "^0.1.1" + +big.js@^5.2.2: + version "5.2.2" + resolved "https://registry.yarnpkg.com/big.js/-/big.js-5.2.2.tgz#65f0af382f578bcdc742bd9c281e9cb2d7768328" + integrity sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ== + +binary-extensions@^1.0.0: + version "1.13.1" + resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-1.13.1.tgz#598afe54755b2868a5330d2aff9d4ebb53209b65" + integrity sha512-Un7MIEDdUC5gNpcGDV97op1Ywk748MpHcFTHoYs6qnj1Z3j7I53VG3nwZhKzoBZmbdRNnb6WRdFlwl7tSDuZGw== + +bindings@^1.5.0: + version "1.5.0" + resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df" + integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ== + dependencies: + file-uri-to-path "1.0.0" + +bluebird@^3.5.5: + version "3.7.2" + resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.7.2.tgz#9f229c15be272454ffa973ace0dbee79a1b0c36f" + integrity sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg== + +bn.js@^4.0.0, bn.js@^4.1.0, bn.js@^4.4.0: + version "4.11.8" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-4.11.8.tgz#2cde09eb5ee341f484746bb0309b3253b1b1442f" + integrity sha512-ItfYfPLkWHUjckQCk8xC+LwxgK8NYcXywGigJgSwOP8Y2iyWT4f2vsZnoOXTTbo+o5yXmIUJ4gn5538SO5S3gA== + +bn.js@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.1.1.tgz#48efc4031a9c4041b9c99c6941d903463ab62eb5" + integrity sha512-IUTD/REb78Z2eodka1QZyyEk66pciRcP6Sroka0aI3tG/iwIdYLrBD62RsubR7vqdt3WyX8p4jxeatzmRSphtA== + +brace-expansion@^1.1.7: + version "1.1.11" + resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" + integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== + dependencies: + balanced-match "^1.0.0" + concat-map "0.0.1" + +braces@^2.3.1, braces@^2.3.2: + version "2.3.2" + resolved "https://registry.yarnpkg.com/braces/-/braces-2.3.2.tgz#5979fd3f14cd531565e5fa2df1abfff1dfaee729" + integrity sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w== + dependencies: + arr-flatten "^1.1.0" + array-unique "^0.3.2" + extend-shallow "^2.0.1" + fill-range "^4.0.0" + isobject "^3.0.1" + repeat-element "^1.1.2" + snapdragon "^0.8.1" + snapdragon-node "^2.0.1" + split-string "^3.0.2" + to-regex "^3.0.1" + +brorand@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/brorand/-/brorand-1.1.0.tgz#12c25efe40a45e3c323eb8675a0a0ce57b22371f" + integrity sha1-EsJe/kCkXjwyPrhnWgoM5XsiNx8= + +browserify-aes@^1.0.0, browserify-aes@^1.0.4: + version "1.2.0" + resolved "https://registry.yarnpkg.com/browserify-aes/-/browserify-aes-1.2.0.tgz#326734642f403dabc3003209853bb70ad428ef48" + integrity sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA== + dependencies: + buffer-xor "^1.0.3" + cipher-base "^1.0.0" + create-hash "^1.1.0" + evp_bytestokey "^1.0.3" + inherits "^2.0.1" + safe-buffer "^5.0.1" + +browserify-cipher@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/browserify-cipher/-/browserify-cipher-1.0.1.tgz#8d6474c1b870bfdabcd3bcfcc1934a10e94f15f0" + integrity sha512-sPhkz0ARKbf4rRQt2hTpAHqn47X3llLkUGn+xEJzLjwY8LRs2p0v7ljvI5EyoRO/mexrNunNECisZs+gw2zz1w== + dependencies: + browserify-aes "^1.0.4" + browserify-des "^1.0.0" + evp_bytestokey "^1.0.0" + +browserify-des@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/browserify-des/-/browserify-des-1.0.2.tgz#3af4f1f59839403572f1c66204375f7a7f703e9c" + integrity sha512-BioO1xf3hFwz4kc6iBhI3ieDFompMhrMlnDFC4/0/vd5MokpuAc3R+LYbwTA9A5Yc9pq9UYPqffKpW2ObuwX5A== + dependencies: + cipher-base "^1.0.1" + des.js "^1.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + +browserify-rsa@^4.0.0, browserify-rsa@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/browserify-rsa/-/browserify-rsa-4.0.1.tgz#21e0abfaf6f2029cf2fafb133567a701d4135524" + integrity sha1-IeCr+vbyApzy+vsTNWenAdQTVSQ= + dependencies: + bn.js "^4.1.0" + randombytes "^2.0.1" + +browserify-sign@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/browserify-sign/-/browserify-sign-4.1.0.tgz#4fe971b379a5aeb4925e06779f9fa1f41d249d70" + integrity sha512-VYxo7cDCeYUoBZ0ZCy4UyEUCP3smyBd4DRQM5nrFS1jJjPJjX7rP3oLRpPoWfkhQfyJ0I9ZbHbKafrFD/SGlrg== + dependencies: + bn.js "^5.1.1" + browserify-rsa "^4.0.1" + create-hash "^1.2.0" + create-hmac "^1.1.7" + elliptic "^6.5.2" + inherits "^2.0.4" + parse-asn1 "^5.1.5" + readable-stream "^3.6.0" + +browserify-zlib@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/browserify-zlib/-/browserify-zlib-0.2.0.tgz#2869459d9aa3be245fe8fe2ca1f46e2e7f54d73f" + integrity sha512-Z942RysHXmJrhqk88FmKBVq/v5tqmSkDz7p54G/MGyjMnCFFnC79XWNbg+Vta8W6Wb2qtSZTSxIGkJrRpCFEiA== + dependencies: + pako "~1.0.5" + +buffer-from@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" + integrity sha512-MQcXEUbCKtEo7bhqEs6560Hyd4XaovZlO/k9V3hjVUF/zwW7KBVdSK4gIt/bzwS9MbR5qob+F5jusZsb0YQK2A== + +buffer-xor@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/buffer-xor/-/buffer-xor-1.0.3.tgz#26e61ed1422fb70dd42e6e36729ed51d855fe8d9" + integrity sha1-JuYe0UIvtw3ULm42cp7VHYVf6Nk= + +buffer@^4.3.0: + version "4.9.2" + resolved "https://registry.yarnpkg.com/buffer/-/buffer-4.9.2.tgz#230ead344002988644841ab0244af8c44bbe3ef8" + integrity sha512-xq+q3SRMOxGivLhBNaUdC64hDTQwejJ+H0T/NB1XMtTVEwNTrfFF3gAxiyW0Bu/xWEGhjVKgUcMhCrUy2+uCWg== + dependencies: + base64-js "^1.0.2" + ieee754 "^1.1.4" + isarray "^1.0.0" + +builtin-status-codes@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/builtin-status-codes/-/builtin-status-codes-3.0.0.tgz#85982878e21b98e1c66425e03d0174788f569ee8" + integrity sha1-hZgoeOIbmOHGZCXgPQF0eI9Wnug= + +cacache@^12.0.2: + version "12.0.4" + resolved "https://registry.yarnpkg.com/cacache/-/cacache-12.0.4.tgz#668bcbd105aeb5f1d92fe25570ec9525c8faa40c" + integrity sha512-a0tMB40oefvuInr4Cwb3GerbL9xTj1D5yg0T5xrjGCGyfvbxseIXX7BAO/u/hIXdafzOI5JC3wDwHyf24buOAQ== + dependencies: + bluebird "^3.5.5" + chownr "^1.1.1" + figgy-pudding "^3.5.1" + glob "^7.1.4" + graceful-fs "^4.1.15" + infer-owner "^1.0.3" + lru-cache "^5.1.1" + mississippi "^3.0.0" + mkdirp "^0.5.1" + move-concurrently "^1.0.1" + promise-inflight "^1.0.1" + rimraf "^2.6.3" + ssri "^6.0.1" + unique-filename "^1.1.1" + y18n "^4.0.0" + +cache-base@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cache-base/-/cache-base-1.0.1.tgz#0a7f46416831c8b662ee36fe4e7c59d76f666ab2" + integrity sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ== + dependencies: + collection-visit "^1.0.0" + component-emitter "^1.2.1" + get-value "^2.0.6" + has-value "^1.0.0" + isobject "^3.0.1" + set-value "^2.0.0" + to-object-path "^0.3.0" + union-value "^1.0.0" + unset-value "^1.0.0" + +camelcase@^5.0.0: + version "5.3.1" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" + integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== + +chalk@2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + +chokidar@^2.1.8: + version "2.1.8" + resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917" + integrity sha512-ZmZUazfOzf0Nve7duiCKD23PFSCs4JPoYyccjUFF3aQkQadqBhfzhjkwBH2mNOG9cTBwhamM37EIsIkZw3nRgg== + dependencies: + anymatch "^2.0.0" + async-each "^1.0.1" + braces "^2.3.2" + glob-parent "^3.1.0" + inherits "^2.0.3" + is-binary-path "^1.0.0" + is-glob "^4.0.0" + normalize-path "^3.0.0" + path-is-absolute "^1.0.0" + readdirp "^2.2.1" + upath "^1.1.1" + optionalDependencies: + fsevents "^1.2.7" + +chownr@^1.1.1: + version "1.1.4" + resolved "https://registry.yarnpkg.com/chownr/-/chownr-1.1.4.tgz#6fc9d7b42d32a583596337666e7d08084da2cc6b" + integrity sha512-jJ0bqzaylmJtVnNgzTeSOs8DPavpbYgEr/b0YL8/2GO3xJEhInFmhKMUnEJQjZumK7KXGFhUy89PrsJWlakBVg== + +chrome-trace-event@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/chrome-trace-event/-/chrome-trace-event-1.0.2.tgz#234090ee97c7d4ad1a2c4beae27505deffc608a4" + integrity sha512-9e/zx1jw7B4CO+c/RXoCsfg/x1AfUBioy4owYH0bJprEYAx5hRFLRhWBqHAG57D0ZM4H7vxbP7bPe0VwhQRYDQ== + dependencies: + tslib "^1.9.0" + +cipher-base@^1.0.0, cipher-base@^1.0.1, cipher-base@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/cipher-base/-/cipher-base-1.0.4.tgz#8760e4ecc272f4c363532f926d874aae2c1397de" + integrity sha512-Kkht5ye6ZGmwv40uUDZztayT2ThLQGfnj/T71N/XzeZeo3nf8foyW7zGTsPYkEya3m5f3cAypH+qe7YOrM1U2Q== + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" + +class-utils@^0.3.5: + version "0.3.6" + resolved "https://registry.yarnpkg.com/class-utils/-/class-utils-0.3.6.tgz#f93369ae8b9a7ce02fd41faad0ca83033190c463" + integrity sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg== + dependencies: + arr-union "^3.1.0" + define-property "^0.2.5" + isobject "^3.0.0" + static-extend "^0.1.1" + +cliui@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/cliui/-/cliui-5.0.0.tgz#deefcfdb2e800784aa34f46fa08e06851c7bbbc5" + integrity sha512-PYeGSEmmHM6zvoef2w8TPzlrnNpXIjTipYK780YswmIP9vjxmd6Y2a3CB2Ks6/AU8NHjZugXvo8w3oWM2qnwXA== + dependencies: + string-width "^3.1.0" + strip-ansi "^5.2.0" + wrap-ansi "^5.1.0" + +collection-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/collection-visit/-/collection-visit-1.0.0.tgz#4bc0373c164bc3291b4d368c829cf1a80a59dca0" + integrity sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA= + dependencies: + map-visit "^1.0.0" + object-visit "^1.0.0" + +color-convert@^1.9.0: + version "1.9.3" + resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" + integrity sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg== + dependencies: + color-name "1.1.3" + +color-name@1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" + integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= + +commander@^2.20.0: + version "2.20.3" + resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" + integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ== + +commondir@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" + integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= + +component-emitter@^1.2.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.3.0.tgz#16e4070fba8ae29b679f2215853ee181ab2eabc0" + integrity sha512-Rd3se6QB+sO1TwqZjscQrurpEPIfO0/yYnSin6Q/rD3mOutHvUrCAhJub3r90uNb+SESBuE0QYoB90YdfatsRg== + +concat-map@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" + integrity sha1-2Klr13/Wjfd5OnMDajug1UBdR3s= + +concat-stream@^1.5.0: + version "1.6.2" + resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.2.tgz#904bdf194cd3122fc675c77fc4ac3d4ff0fd1a34" + integrity sha512-27HBghJxjiZtIk3Ycvn/4kbJk/1uZuJFfuPEns6LaEvpvG1f0hTea8lilrouyo9mVc2GWdcEZ8OLoGmSADlrCw== + dependencies: + buffer-from "^1.0.0" + inherits "^2.0.3" + readable-stream "^2.2.2" + typedarray "^0.0.6" + +console-browserify@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/console-browserify/-/console-browserify-1.2.0.tgz#67063cef57ceb6cf4993a2ab3a55840ae8c49336" + integrity sha512-ZMkYO/LkF17QvCPqM0gxw8yUzigAOZOSWSHg91FH6orS7vcEj5dVZTidN2fQ14yBSdg97RqhSNwLUXInd52OTA== + +constants-browserify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" + integrity sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U= + +copy-concurrently@^1.0.0: + version "1.0.5" + resolved "https://registry.yarnpkg.com/copy-concurrently/-/copy-concurrently-1.0.5.tgz#92297398cae34937fcafd6ec8139c18051f0b5e0" + integrity sha512-f2domd9fsVDFtaFcbaRZuYXwtdmnzqbADSwhSWYxYB/Q8zsdUUFMXVRwXGDMWmbEzAn1kdRrtI1T/KTFOL4X2A== + dependencies: + aproba "^1.1.1" + fs-write-stream-atomic "^1.0.8" + iferr "^0.1.5" + mkdirp "^0.5.1" + rimraf "^2.5.4" + run-queue "^1.0.0" + +copy-descriptor@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" + integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= + +core-util-is@~1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" + integrity sha1-tf1UIgqivFq1eqtxQMlAdUUDwac= + +create-ecdh@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/create-ecdh/-/create-ecdh-4.0.3.tgz#c9111b6f33045c4697f144787f9254cdc77c45ff" + integrity sha512-GbEHQPMOswGpKXM9kCWVrremUcBmjteUaQ01T9rkKCPDXfUHX0IoP9LpHYo2NPFampa4e+/pFDc3jQdxrxQLaw== + dependencies: + bn.js "^4.1.0" + elliptic "^6.0.0" + +create-hash@^1.1.0, create-hash@^1.1.2, create-hash@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/create-hash/-/create-hash-1.2.0.tgz#889078af11a63756bcfb59bd221996be3a9ef196" + integrity sha512-z00bCGNHDG8mHAkP7CtT1qVu+bFQUPjYq/4Iv3C3kWjTFV10zIjfSoeqXo9Asws8gwSHDGj/hl2u4OGIjapeCg== + dependencies: + cipher-base "^1.0.1" + inherits "^2.0.1" + md5.js "^1.3.4" + ripemd160 "^2.0.1" + sha.js "^2.4.0" + +create-hmac@^1.1.0, create-hmac@^1.1.4, create-hmac@^1.1.7: + version "1.1.7" + resolved "https://registry.yarnpkg.com/create-hmac/-/create-hmac-1.1.7.tgz#69170c78b3ab957147b2b8b04572e47ead2243ff" + integrity sha512-MJG9liiZ+ogc4TzUwuvbER1JRdgvUFSB5+VR/g5h82fGaIRWMWddtKBHi7/sVhfjQZ6SehlyhvQYrcYkaUIpLg== + dependencies: + cipher-base "^1.0.3" + create-hash "^1.1.0" + inherits "^2.0.1" + ripemd160 "^2.0.0" + safe-buffer "^5.0.1" + sha.js "^2.4.8" + +cross-spawn@6.0.5, cross-spawn@^6.0.0: + version "6.0.5" + resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" + integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== + dependencies: + nice-try "^1.0.4" + path-key "^2.0.1" + semver "^5.5.0" + shebang-command "^1.2.0" + which "^1.2.9" + +crypto-browserify@^3.11.0: + version "3.12.0" + resolved "https://registry.yarnpkg.com/crypto-browserify/-/crypto-browserify-3.12.0.tgz#396cf9f3137f03e4b8e532c58f698254e00f80ec" + integrity sha512-fz4spIh+znjO2VjL+IdhEpRJ3YN6sMzITSBijk6FK2UvTqruSQW+/cCZTSNsMiZNvUeq0CqurF+dAbyiGOY6Wg== + dependencies: + browserify-cipher "^1.0.0" + browserify-sign "^4.0.0" + create-ecdh "^4.0.0" + create-hash "^1.1.0" + create-hmac "^1.1.0" + diffie-hellman "^5.0.0" + inherits "^2.0.1" + pbkdf2 "^3.0.3" + public-encrypt "^4.0.0" + randombytes "^2.0.0" + randomfill "^1.0.3" + +cyclist@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9" + integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk= + +debug@^2.2.0, debug@^2.3.3: + version "2.6.9" + resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" + integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== + dependencies: + ms "2.0.0" + +decamelize@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" + integrity sha1-9lNNFRSCabIDUue+4m9QH5oZEpA= + +decode-uri-component@^0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/decode-uri-component/-/decode-uri-component-0.2.0.tgz#eb3913333458775cb84cd1a1fae062106bb87545" + integrity sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU= + +define-property@^0.2.5: + version "0.2.5" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-0.2.5.tgz#c35b1ef918ec3c990f9a5bc57be04aacec5c8116" + integrity sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY= + dependencies: + is-descriptor "^0.1.0" + +define-property@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-1.0.0.tgz#769ebaaf3f4a63aad3af9e8d304c9bbe79bfb0e6" + integrity sha1-dp66rz9KY6rTr56NMEybvnm/sOY= + dependencies: + is-descriptor "^1.0.0" + +define-property@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/define-property/-/define-property-2.0.2.tgz#d459689e8d654ba77e02a817f8710d702cb16e9d" + integrity sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ== + dependencies: + is-descriptor "^1.0.2" + isobject "^3.0.1" + +des.js@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/des.js/-/des.js-1.0.1.tgz#5382142e1bdc53f85d86d53e5f4aa7deb91e0843" + integrity sha512-Q0I4pfFrv2VPd34/vfLrFOoRmlYj3OV50i7fskps1jZWK1kApMWWT9G6RRUeYedLcBDIhnSDaUvJMb3AhUlaEA== + dependencies: + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + +detect-file@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" + integrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc= + +diffie-hellman@^5.0.0: + version "5.0.3" + resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" + integrity sha512-kqag/Nl+f3GwyK25fhUMYj81BUOrZ9IuJsjIcDE5icNM9FJHAVm3VcUDxdLPoQtTuUylWm6ZIknYJwwaPxsUzg== + dependencies: + bn.js "^4.1.0" + miller-rabin "^4.0.0" + randombytes "^2.0.0" + +domain-browser@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/domain-browser/-/domain-browser-1.2.0.tgz#3d31f50191a6749dd1375a7f522e823d42e54eda" + integrity sha512-jnjyiM6eRyZl2H+W8Q/zLMA481hzi0eszAaBUzIVnmYVDBbnLxVNnfu1HgEBvCbL+71FrxMl3E6lpKH7Ge3OXA== + +duplexify@^3.4.2, duplexify@^3.6.0: + version "3.7.1" + resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.7.1.tgz#2a4df5317f6ccfd91f86d6fd25d8d8a103b88309" + integrity sha512-07z8uv2wMyS51kKhD1KsdXJg5WQ6t93RneqRxUHnskXVtlYYkLqM0gqStQZ3pj073g687jPCHrqNfCzawLYh5g== + dependencies: + end-of-stream "^1.0.0" + inherits "^2.0.1" + readable-stream "^2.0.0" + stream-shift "^1.0.0" + +elliptic@^6.0.0, elliptic@^6.5.2: + version "6.5.2" + resolved "https://registry.yarnpkg.com/elliptic/-/elliptic-6.5.2.tgz#05c5678d7173c049d8ca433552224a495d0e3762" + integrity sha512-f4x70okzZbIQl/NSRLkI/+tteV/9WqL98zx+SQ69KbXxmVrmjwsNUPn/gYJJ0sHvEak24cZgHIPegRePAtA/xw== + dependencies: + bn.js "^4.4.0" + brorand "^1.0.1" + hash.js "^1.0.0" + hmac-drbg "^1.0.0" + inherits "^2.0.1" + minimalistic-assert "^1.0.0" + minimalistic-crypto-utils "^1.0.0" + +emoji-regex@^7.0.1: + version "7.0.3" + resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-7.0.3.tgz#933a04052860c85e83c122479c4748a8e4c72156" + integrity sha512-CwBLREIQ7LvYFB0WyRvwhq5N5qPhc6PMjD6bYggFlI5YyDgl+0vxq5VHbMOFqLg7hfWzmu8T5Z1QofhmTIhItA== + +emojis-list@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-2.1.0.tgz#4daa4d9db00f9819880c79fa457ae5b09a1fd389" + integrity sha1-TapNnbAPmBmIDHn6RXrlsJof04k= + +emojis-list@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/emojis-list/-/emojis-list-3.0.0.tgz#5570662046ad29e2e916e71aae260abdff4f6a78" + integrity sha512-/kyM18EfinwXZbno9FyUGeFh87KC8HRQBQGildHZbEuRyWFOmv1U10o9BBp8XVZDVNNuQKyIGIu5ZYAAXJ0V2Q== + +end-of-stream@^1.0.0, end-of-stream@^1.1.0: + version "1.4.4" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.4.tgz#5ae64a5f45057baf3626ec14da0ca5e4b2431eb0" + integrity sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q== + dependencies: + once "^1.4.0" + +enhanced-resolve@4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.1.0.tgz#41c7e0bfdfe74ac1ffe1e57ad6a5c6c9f3742a7f" + integrity sha512-F/7vkyTtyc/llOIn8oWclcB25KdRaiPBpZYDgJHgh/UHtpgT2p2eldQgtQnLtUvfMKPKxbRaQM/hHkvLHt1Vng== + dependencies: + graceful-fs "^4.1.2" + memory-fs "^0.4.0" + tapable "^1.0.0" + +enhanced-resolve@^4.1.0: + version "4.1.1" + resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-4.1.1.tgz#2937e2b8066cd0fe7ce0990a98f0d71a35189f66" + integrity sha512-98p2zE+rL7/g/DzMHMTF4zZlCgeVdJ7yr6xzEpJRYwFYrGi9ANdn5DnJURg6RpBkyk60XYDnWIv51VfIhfNGuA== + dependencies: + graceful-fs "^4.1.2" + memory-fs "^0.5.0" + tapable "^1.0.0" + +errno@^0.1.3, errno@~0.1.7: + version "0.1.7" + resolved "https://registry.yarnpkg.com/errno/-/errno-0.1.7.tgz#4684d71779ad39af177e3f007996f7c67c852618" + integrity sha512-MfrRBDWzIWifgq6tJj60gkAwtLNb6sQPlcFrSOflcP1aFmmruKQ2wRnze/8V6kgyz7H3FF8Npzv78mZ7XLLflg== + dependencies: + prr "~1.0.1" + +escape-string-regexp@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" + integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= + +eslint-scope@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-4.0.3.tgz#ca03833310f6889a3264781aa82e63eb9cfe7848" + integrity sha512-p7VutNr1O/QrxysMo3E45FjYDTeXBy0iTltPFNSqKAIfjDSXC+4dj+qfyuD8bfAXrW/y6lW3O76VaYNPKfpKrg== + dependencies: + esrecurse "^4.1.0" + estraverse "^4.1.1" + +esrecurse@^4.1.0: + version "4.2.1" + resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.1.tgz#007a3b9fdbc2b3bb87e4879ea19c92fdbd3942cf" + integrity sha512-64RBB++fIOAXPw3P9cy89qfMlvZEXZkqqJkjqqXIvzP5ezRZjW+lPWjw35UX/3EhUPFYbg5ER4JYgDw4007/DQ== + dependencies: + estraverse "^4.1.0" + +estraverse@^4.1.0, estraverse@^4.1.1: + version "4.3.0" + resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" + integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== + +events@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/events/-/events-3.1.0.tgz#84279af1b34cb75aa88bf5ff291f6d0bd9b31a59" + integrity sha512-Rv+u8MLHNOdMjTAFeT3nCjHn2aGlx435FP/sDHNaRhDEMwyI/aB22Kj2qIN8R0cw3z28psEQLYwxVKLsKrMgWg== + +evp_bytestokey@^1.0.0, evp_bytestokey@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/evp_bytestokey/-/evp_bytestokey-1.0.3.tgz#7fcbdb198dc71959432efe13842684e0525acb02" + integrity sha512-/f2Go4TognH/KvCISP7OUsHn85hT9nUkxxA9BEWxFn+Oj9o8ZNLm/40hdlgSLyuOimsrTKLUMEorQexp/aPQeA== + dependencies: + md5.js "^1.3.4" + safe-buffer "^5.1.1" + +execa@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8" + integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA== + dependencies: + cross-spawn "^6.0.0" + get-stream "^4.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + +expand-brackets@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/expand-brackets/-/expand-brackets-2.1.4.tgz#b77735e315ce30f6b6eff0f83b04151a22449622" + integrity sha1-t3c14xXOMPa27/D4OwQVGiJEliI= + dependencies: + debug "^2.3.3" + define-property "^0.2.5" + extend-shallow "^2.0.1" + posix-character-classes "^0.1.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +expand-tilde@^2.0.0, expand-tilde@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/expand-tilde/-/expand-tilde-2.0.2.tgz#97e801aa052df02454de46b02bf621642cdc8502" + integrity sha1-l+gBqgUt8CRU3kawK/YhZCzchQI= + dependencies: + homedir-polyfill "^1.0.1" + +extend-shallow@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-2.0.1.tgz#51af7d614ad9a9f610ea1bafbb989d6b1c56890f" + integrity sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8= + dependencies: + is-extendable "^0.1.0" + +extend-shallow@^3.0.0, extend-shallow@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/extend-shallow/-/extend-shallow-3.0.2.tgz#26a71aaf073b39fb2127172746131c2704028db8" + integrity sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg= + dependencies: + assign-symbols "^1.0.0" + is-extendable "^1.0.1" + +extglob@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/extglob/-/extglob-2.0.4.tgz#ad00fe4dc612a9232e8718711dc5cb5ab0285543" + integrity sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw== + dependencies: + array-unique "^0.3.2" + define-property "^1.0.0" + expand-brackets "^2.1.4" + extend-shallow "^2.0.1" + fragment-cache "^0.2.1" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +fast-deep-equal@^3.1.1: + version "3.1.1" + resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.1.tgz#545145077c501491e33b15ec408c294376e94ae4" + integrity sha512-8UEa58QDLauDNfpbrX55Q9jrGHThw2ZMdOky5Gl1CDtVeJDPVrG4Jxx1N8jw2gkWaff5UUuX1KJd+9zGe2B+ZA== + +fast-json-stable-stringify@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/fast-json-stable-stringify/-/fast-json-stable-stringify-2.1.0.tgz#874bf69c6f404c2b5d99c481341399fd55892633" + integrity sha512-lhd/wF+Lk98HZoTCtlVraHtfh5XYijIjalXck7saUtuanSDyLMxnHhSXEDJqHxD7msR8D0uCmqlkwjCV8xvwHw== + +figgy-pudding@^3.5.1: + version "3.5.2" + resolved "https://registry.yarnpkg.com/figgy-pudding/-/figgy-pudding-3.5.2.tgz#b4eee8148abb01dcf1d1ac34367d59e12fa61d6e" + integrity sha512-0btnI/H8f2pavGMN8w40mlSKOfTK2SVJmBfBeVIj3kNw0swwgzyRq0d5TJVOwodFmtvpPeWPN/MCcfuWF0Ezbw== + +file-uri-to-path@1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd" + integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw== + +fill-range@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-4.0.0.tgz#d544811d428f98eb06a63dc402d2403c328c38f7" + integrity sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc= + dependencies: + extend-shallow "^2.0.1" + is-number "^3.0.0" + repeat-string "^1.6.1" + to-regex-range "^2.1.0" + +find-cache-dir@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7" + integrity sha512-Tq6PixE0w/VMFfCgbONnkiQIVol/JJL7nRMi20fqzA4NRs9AfeqMGeRdPi3wIhYkxjeBaWh2rxwapn5Tu3IqOQ== + dependencies: + commondir "^1.0.1" + make-dir "^2.0.0" + pkg-dir "^3.0.0" + +find-up@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" + integrity sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg== + dependencies: + locate-path "^3.0.0" + +findup-sync@3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/findup-sync/-/findup-sync-3.0.0.tgz#17b108f9ee512dfb7a5c7f3c8b27ea9e1a9c08d1" + integrity sha512-YbffarhcicEhOrm4CtrwdKBdCuz576RLdhJDsIfvNtxUuhdRet1qZcsMjqbePtAseKdAnDyM/IyXbu7PRPRLYg== + dependencies: + detect-file "^1.0.0" + is-glob "^4.0.0" + micromatch "^3.0.4" + resolve-dir "^1.0.1" + +flush-write-stream@^1.0.0: + version "1.1.1" + resolved "https://registry.yarnpkg.com/flush-write-stream/-/flush-write-stream-1.1.1.tgz#8dd7d873a1babc207d94ead0c2e0e44276ebf2e8" + integrity sha512-3Z4XhFZ3992uIq0XOqb9AreonueSYphE6oYbpt5+3u06JWklbsPkNv3ZKkP9Bz/r+1MWCaMoSQ28P85+1Yc77w== + dependencies: + inherits "^2.0.3" + readable-stream "^2.3.6" + +for-in@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80" + integrity sha1-gQaNKVqBQuwKxybG4iAMMPttXoA= + +fragment-cache@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" + integrity sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk= + dependencies: + map-cache "^0.2.2" + +from2@^2.1.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/from2/-/from2-2.3.0.tgz#8bfb5502bde4a4d36cfdeea007fcca21d7e382af" + integrity sha1-i/tVAr3kpNNs/e6gB/zKIdfjgq8= + dependencies: + inherits "^2.0.1" + readable-stream "^2.0.0" + +fs-write-stream-atomic@^1.0.8: + version "1.0.10" + resolved "https://registry.yarnpkg.com/fs-write-stream-atomic/-/fs-write-stream-atomic-1.0.10.tgz#b47df53493ef911df75731e70a9ded0189db40c9" + integrity sha1-tH31NJPvkR33VzHnCp3tAYnbQMk= + dependencies: + graceful-fs "^4.1.2" + iferr "^0.1.5" + imurmurhash "^0.1.4" + readable-stream "1 || 2" + +fs.realpath@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f" + integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8= + +fsevents@^1.2.7: + version "1.2.13" + resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-1.2.13.tgz#f325cb0455592428bcf11b383370ef70e3bfcc38" + integrity sha512-oWb1Z6mkHIskLzEJ/XWX0srkpkTQ7vaopMQkyaEIoq0fmtFVxOthb8cCxeT+p3ynTdkk/RZwbgG4brR5BeWECw== + dependencies: + bindings "^1.5.0" + nan "^2.12.1" + +get-caller-file@^2.0.1: + version "2.0.5" + resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" + integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== + +get-stream@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" + integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== + dependencies: + pump "^3.0.0" + +get-value@^2.0.3, get-value@^2.0.6: + version "2.0.6" + resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" + integrity sha1-3BXKHGcjh8p2vTesCjlbogQqLCg= + +glob-parent@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-3.1.0.tgz#9e6af6299d8d3bd2bd40430832bd113df906c5ae" + integrity sha1-nmr2KZ2NO9K9QEMIMr0RPfkGxa4= + dependencies: + is-glob "^3.1.0" + path-dirname "^1.0.0" + +glob@^7.1.3, glob@^7.1.4: + version "7.1.6" + resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" + integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA== + dependencies: + fs.realpath "^1.0.0" + inflight "^1.0.4" + inherits "2" + minimatch "^3.0.4" + once "^1.3.0" + path-is-absolute "^1.0.0" + +global-modules@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-2.0.0.tgz#997605ad2345f27f51539bea26574421215c7780" + integrity sha512-NGbfmJBp9x8IxyJSd1P+otYK8vonoJactOogrVfFRIAEY1ukil8RSKDz2Yo7wh1oihl51l/r6W4epkeKJHqL8A== + dependencies: + global-prefix "^3.0.0" + +global-modules@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/global-modules/-/global-modules-1.0.0.tgz#6d770f0eb523ac78164d72b5e71a8877265cc3ea" + integrity sha512-sKzpEkf11GpOFuw0Zzjzmt4B4UZwjOcG757PPvrfhxcLFbq0wpsgpOqxpxtxFiCG4DtG93M6XRVbF2oGdev7bg== + dependencies: + global-prefix "^1.0.1" + is-windows "^1.0.1" + resolve-dir "^1.0.0" + +global-prefix@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-1.0.2.tgz#dbf743c6c14992593c655568cb66ed32c0122ebe" + integrity sha1-2/dDxsFJklk8ZVVoy2btMsASLr4= + dependencies: + expand-tilde "^2.0.2" + homedir-polyfill "^1.0.1" + ini "^1.3.4" + is-windows "^1.0.1" + which "^1.2.14" + +global-prefix@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/global-prefix/-/global-prefix-3.0.0.tgz#fc85f73064df69f50421f47f883fe5b913ba9b97" + integrity sha512-awConJSVCHVGND6x3tmMaKcQvwXLhjdkmomy2W+Goaui8YPgYgXJZewhg3fWC+DlfqqQuWg8AwqjGTD2nAPVWg== + dependencies: + ini "^1.3.5" + kind-of "^6.0.2" + which "^1.3.1" + +graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2: + version "4.2.4" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" + integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== + +has-flag@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" + integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= + +has-value@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-0.3.1.tgz#7b1f58bada62ca827ec0a2078025654845995e1f" + integrity sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8= + dependencies: + get-value "^2.0.3" + has-values "^0.1.4" + isobject "^2.0.0" + +has-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-value/-/has-value-1.0.0.tgz#18b281da585b1c5c51def24c930ed29a0be6b177" + integrity sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc= + dependencies: + get-value "^2.0.6" + has-values "^1.0.0" + isobject "^3.0.0" + +has-values@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-0.1.4.tgz#6d61de95d91dfca9b9a02089ad384bff8f62b771" + integrity sha1-bWHeldkd/Km5oCCJrThL/49it3E= + +has-values@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/has-values/-/has-values-1.0.0.tgz#95b0b63fec2146619a6fe57fe75628d5a39efe4f" + integrity sha1-lbC2P+whRmGab+V/51Yo1aOe/k8= + dependencies: + is-number "^3.0.0" + kind-of "^4.0.0" + +hash-base@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/hash-base/-/hash-base-3.1.0.tgz#55c381d9e06e1d2997a883b4a3fddfe7f0d3af33" + integrity sha512-1nmYp/rhMDiE7AYkDw+lLwlAzz0AntGIe51F3RfFfEqyQ3feY2eI/NcwC6umIQVOASPMsWJLJScWKSSvzL9IVA== + dependencies: + inherits "^2.0.4" + readable-stream "^3.6.0" + safe-buffer "^5.2.0" + +hash.js@^1.0.0, hash.js@^1.0.3: + version "1.1.7" + resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" + integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== + dependencies: + inherits "^2.0.3" + minimalistic-assert "^1.0.1" + +hmac-drbg@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/hmac-drbg/-/hmac-drbg-1.0.1.tgz#d2745701025a6c775a6c545793ed502fc0c649a1" + integrity sha1-0nRXAQJabHdabFRXk+1QL8DGSaE= + dependencies: + hash.js "^1.0.3" + minimalistic-assert "^1.0.0" + minimalistic-crypto-utils "^1.0.1" + +homedir-polyfill@^1.0.1: + version "1.0.3" + resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" + integrity sha512-eSmmWE5bZTK2Nou4g0AI3zZ9rswp7GRKoKXS1BLUkvPviOqs4YTN1djQIqrXy9k5gEtdLPy86JjRwsNM9tnDcA== + dependencies: + parse-passwd "^1.0.0" + +https-browserify@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/https-browserify/-/https-browserify-1.0.0.tgz#ec06c10e0a34c0f2faf199f7fd7fc78fffd03c73" + integrity sha1-7AbBDgo0wPL68Zn3/X/Hj//QPHM= + +ieee754@^1.1.4: + version "1.1.13" + resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.1.13.tgz#ec168558e95aa181fd87d37f55c32bbcb6708b84" + integrity sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg== + +iferr@^0.1.5: + version "0.1.5" + resolved "https://registry.yarnpkg.com/iferr/-/iferr-0.1.5.tgz#c60eed69e6d8fdb6b3104a1fcbca1c192dc5b501" + integrity sha1-xg7taebY/bazEEofy8ocGS3FtQE= + +import-local@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/import-local/-/import-local-2.0.0.tgz#55070be38a5993cf18ef6db7e961f5bee5c5a09d" + integrity sha512-b6s04m3O+s3CGSbqDIyP4R6aAwAeYlVq9+WUWep6iHa8ETRf9yei1U48C5MmfJmV9AiLYYBKPMq/W+/WRpQmCQ== + dependencies: + pkg-dir "^3.0.0" + resolve-cwd "^2.0.0" + +imurmurhash@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" + integrity sha1-khi5srkoojixPcT7a21XbyMUU+o= + +infer-owner@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/infer-owner/-/infer-owner-1.0.4.tgz#c4cefcaa8e51051c2a40ba2ce8a3d27295af9467" + integrity sha512-IClj+Xz94+d7irH5qRyfJonOdfTzuDaifE6ZPWfx0N0+/ATZCbuTPq2prFl526urkQd90WyUKIh1DfBQ2hMz9A== + +inflight@^1.0.4: + version "1.0.6" + resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" + integrity sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk= + dependencies: + once "^1.3.0" + wrappy "1" + +inherits@2, inherits@^2.0.1, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.1, inherits@~2.0.3: + version "2.0.4" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" + integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== + +inherits@2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.1.tgz#b17d08d326b4423e568eff719f91b0b1cbdf69f1" + integrity sha1-sX0I0ya0Qj5Wjv9xn5GwscvfafE= + +inherits@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.3.tgz#633c2c83e3da42a502f52466022480f4208261de" + integrity sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4= + +ini@^1.3.4, ini@^1.3.5: + version "1.3.5" + resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927" + integrity sha512-RZY5huIKCMRWDUqZlEi72f/lmXKMvuszcMBduliQ3nnWbx9X/ZBQO7DijMEYS9EhHBb2qacRUMtC7svLwe0lcw== + +interpret@1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.2.0.tgz#d5061a6224be58e8083985f5014d844359576296" + integrity sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw== + +invert-kv@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" + integrity sha512-wPVv/y/QQ/Uiirj/vh3oP+1Ww+AWehmi1g5fFWGPF6IpCBCDVrhgHRMvrLfdYcwDh3QJbGXDW4JAuzxElLSqKA== + +is-accessor-descriptor@^0.1.6: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz#a9e12cb3ae8d876727eeef3843f8a0897b5c98d6" + integrity sha1-qeEss66Nh2cn7u84Q/igiXtcmNY= + dependencies: + kind-of "^3.0.2" + +is-accessor-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz#169c2f6d3df1f992618072365c9b0ea1f6878656" + integrity sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ== + dependencies: + kind-of "^6.0.0" + +is-binary-path@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-1.0.1.tgz#75f16642b480f187a711c814161fd3a4a7655898" + integrity sha1-dfFmQrSA8YenEcgUFh/TpKdlWJg= + dependencies: + binary-extensions "^1.0.0" + +is-buffer@^1.1.5: + version "1.1.6" + resolved "https://registry.yarnpkg.com/is-buffer/-/is-buffer-1.1.6.tgz#efaa2ea9daa0d7ab2ea13a97b2b8ad51fefbe8be" + integrity sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w== + +is-data-descriptor@^0.1.4: + version "0.1.4" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" + integrity sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y= + dependencies: + kind-of "^3.0.2" + +is-data-descriptor@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz#d84876321d0e7add03990406abbbbd36ba9268c7" + integrity sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ== + dependencies: + kind-of "^6.0.0" + +is-descriptor@^0.1.0: + version "0.1.6" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-0.1.6.tgz#366d8240dde487ca51823b1ab9f07a10a78251ca" + integrity sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg== + dependencies: + is-accessor-descriptor "^0.1.6" + is-data-descriptor "^0.1.4" + kind-of "^5.0.0" + +is-descriptor@^1.0.0, is-descriptor@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-descriptor/-/is-descriptor-1.0.2.tgz#3b159746a66604b04f8c81524ba365c5f14d86ec" + integrity sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg== + dependencies: + is-accessor-descriptor "^1.0.0" + is-data-descriptor "^1.0.0" + kind-of "^6.0.2" + +is-extendable@^0.1.0, is-extendable@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-0.1.1.tgz#62b110e289a471418e3ec36a617d472e301dfc89" + integrity sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik= + +is-extendable@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/is-extendable/-/is-extendable-1.0.1.tgz#a7470f9e426733d81bd81e1155264e3a3507cab4" + integrity sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA== + dependencies: + is-plain-object "^2.0.4" + +is-extglob@^2.1.0, is-extglob@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" + integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= + +is-fullwidth-code-point@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" + integrity sha1-o7MKXE8ZkYMWeqq5O+764937ZU8= + +is-glob@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-3.1.0.tgz#7ba5ae24217804ac70707b96922567486cc3e84a" + integrity sha1-e6WuJCF4BKxwcHuWkiVnSGzD6Eo= + dependencies: + is-extglob "^2.1.0" + +is-glob@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.1.tgz#7567dbe9f2f5e2467bc77ab83c4a29482407a5dc" + integrity sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg== + dependencies: + is-extglob "^2.1.1" + +is-number@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195" + integrity sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU= + dependencies: + kind-of "^3.0.2" + +is-plain-object@^2.0.3, is-plain-object@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/is-plain-object/-/is-plain-object-2.0.4.tgz#2c163b3fafb1b606d9d17928f05c2a1c38e07677" + integrity sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og== + dependencies: + isobject "^3.0.1" + +is-stream@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44" + integrity sha1-EtSj3U5o4Lec6428hBc66A2RykQ= + +is-windows@^1.0.1, is-windows@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" + integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== + +is-wsl@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-wsl/-/is-wsl-1.1.0.tgz#1f16e4aa22b04d1336b66188a66af3c600c3a66d" + integrity sha1-HxbkqiKwTRM2tmGIpmrzxgDDpm0= + +isarray@1.0.0, isarray@^1.0.0, isarray@~1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" + integrity sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE= + +isexe@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10" + integrity sha1-6PvzdNxVb/iUehDcsFctYz8s+hA= + +isobject@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-2.1.0.tgz#f065561096a3f1da2ef46272f815c840d87e0c89" + integrity sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk= + dependencies: + isarray "1.0.0" + +isobject@^3.0.0, isobject@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" + integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= + +json-parse-better-errors@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" + integrity sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw== + +json-schema-traverse@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" + integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== + +json5@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" + integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== + dependencies: + minimist "^1.2.0" + +kind-of@^3.0.2, kind-of@^3.0.3, kind-of@^3.2.0: + version "3.2.2" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-3.2.2.tgz#31ea21a734bab9bbb0f32466d893aea51e4a3c64" + integrity sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ= + dependencies: + is-buffer "^1.1.5" + +kind-of@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-4.0.0.tgz#20813df3d712928b207378691a45066fae72dd57" + integrity sha1-IIE989cSkosgc3hpGkUGb65y3Vc= + dependencies: + is-buffer "^1.1.5" + +kind-of@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-5.1.0.tgz#729c91e2d857b7a419a1f9aa65685c4c33f5845d" + integrity sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw== + +kind-of@^6.0.0, kind-of@^6.0.2: + version "6.0.3" + resolved "https://registry.yarnpkg.com/kind-of/-/kind-of-6.0.3.tgz#07c05034a6c349fa06e24fa35aa76db4580ce4dd" + integrity sha512-dcS1ul+9tmeD95T+x28/ehLgd9mENa3LsvDTtzm3vyBEO7RPptvAD+t44WVXaUjTBRcrpFeFlC8WCruUR456hw== + +lcid@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/lcid/-/lcid-2.0.0.tgz#6ef5d2df60e52f82eb228a4c373e8d1f397253cf" + integrity sha512-avPEb8P8EGnwXKClwsNUgryVjllcRqtMYa49NTsbQagYuT1DcXnl1915oxWjoyGrXR6zH/Y0Zc96xWsPcoDKeA== + dependencies: + invert-kv "^2.0.0" + +loader-runner@^2.4.0: + version "2.4.0" + resolved "https://registry.yarnpkg.com/loader-runner/-/loader-runner-2.4.0.tgz#ed47066bfe534d7e84c4c7b9998c2a75607d9357" + integrity sha512-Jsmr89RcXGIwivFY21FcRrisYZfvLMTWx5kOLc+JTxtpBOG6xML0vzbc6SEQG2FO9/4Fc3wW4LVcB5DmGflaRw== + +loader-utils@1.2.3: + version "1.2.3" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.2.3.tgz#1ff5dc6911c9f0a062531a4c04b609406108c2c7" + integrity sha512-fkpz8ejdnEMG3s37wGL07iSBDg99O9D5yflE9RGNH3hRdx9SOwYfnGYdZOUIZitN8E+E2vkq3MUMYMvPYl5ZZA== + dependencies: + big.js "^5.2.2" + emojis-list "^2.0.0" + json5 "^1.0.1" + +loader-utils@^1.2.3: + version "1.4.0" + resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.0.tgz#c579b5e34cb34b1a74edc6c1fb36bfa371d5a613" + integrity sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA== + dependencies: + big.js "^5.2.2" + emojis-list "^3.0.0" + json5 "^1.0.1" + +locate-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" + integrity sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A== + dependencies: + p-locate "^3.0.0" + path-exists "^3.0.0" + +lru-cache@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" + integrity sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w== + dependencies: + yallist "^3.0.2" + +make-dir@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" + integrity sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA== + dependencies: + pify "^4.0.1" + semver "^5.6.0" + +map-age-cleaner@^0.1.1: + version "0.1.3" + resolved "https://registry.yarnpkg.com/map-age-cleaner/-/map-age-cleaner-0.1.3.tgz#7d583a7306434c055fe474b0f45078e6e1b4b92a" + integrity sha512-bJzx6nMoP6PDLPBFmg7+xRKeFZvFboMrGlxmNj9ClvX53KrmvM5bXFXEWjbz4cz1AFn+jWJ9z/DJSz7hrs0w3w== + dependencies: + p-defer "^1.0.0" + +map-cache@^0.2.2: + version "0.2.2" + resolved "https://registry.yarnpkg.com/map-cache/-/map-cache-0.2.2.tgz#c32abd0bd6525d9b051645bb4f26ac5dc98a0dbf" + integrity sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8= + +map-visit@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/map-visit/-/map-visit-1.0.0.tgz#ecdca8f13144e660f1b5bd41f12f3479d98dfb8f" + integrity sha1-7Nyo8TFE5mDxtb1B8S80edmN+48= + dependencies: + object-visit "^1.0.0" + +md5.js@^1.3.4: + version "1.3.5" + resolved "https://registry.yarnpkg.com/md5.js/-/md5.js-1.3.5.tgz#b5d07b8e3216e3e27cd728d72f70d1e6a342005f" + integrity sha512-xitP+WxNPcTTOgnTJcrhM0xvdPepipPSf3I8EIpGKeFLjt3PlJLIDG3u8EX53ZIubkb+5U2+3rELYpEhHhzdkg== + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + safe-buffer "^5.1.2" + +mem@^4.0.0: + version "4.3.0" + resolved "https://registry.yarnpkg.com/mem/-/mem-4.3.0.tgz#461af497bc4ae09608cdb2e60eefb69bff744178" + integrity sha512-qX2bG48pTqYRVmDB37rn/6PT7LcR8T7oAX3bf99u1Tt1nzxYfxkgqDwUwolPlXweM0XzBOBFzSx4kfp7KP1s/w== + dependencies: + map-age-cleaner "^0.1.1" + mimic-fn "^2.0.0" + p-is-promise "^2.0.0" + +memory-fs@^0.4.0, memory-fs@^0.4.1: + version "0.4.1" + resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.4.1.tgz#3a9a20b8462523e447cfbc7e8bb80ed667bfc552" + integrity sha1-OpoguEYlI+RHz7x+i7gO1me/xVI= + dependencies: + errno "^0.1.3" + readable-stream "^2.0.1" + +memory-fs@^0.5.0: + version "0.5.0" + resolved "https://registry.yarnpkg.com/memory-fs/-/memory-fs-0.5.0.tgz#324c01288b88652966d161db77838720845a8e3c" + integrity sha512-jA0rdU5KoQMC0e6ppoNRtpp6vjFq6+NY7r8hywnC7V+1Xj/MtHwGIbB1QaK/dunyjWteJzmkpd7ooeWg10T7GA== + dependencies: + errno "^0.1.3" + readable-stream "^2.0.1" + +micromatch@^3.0.4, micromatch@^3.1.10, micromatch@^3.1.4: + version "3.1.10" + resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-3.1.10.tgz#70859bc95c9840952f359a068a3fc49f9ecfac23" + integrity sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + braces "^2.3.1" + define-property "^2.0.2" + extend-shallow "^3.0.2" + extglob "^2.0.4" + fragment-cache "^0.2.1" + kind-of "^6.0.2" + nanomatch "^1.2.9" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.2" + +miller-rabin@^4.0.0: + version "4.0.1" + resolved "https://registry.yarnpkg.com/miller-rabin/-/miller-rabin-4.0.1.tgz#f080351c865b0dc562a8462966daa53543c78a4d" + integrity sha512-115fLhvZVqWwHPbClyntxEVfVDfl9DLLTuJvq3g2O/Oxi8AiNouAHvDSzHS0viUJc+V5vm3eq91Xwqn9dp4jRA== + dependencies: + bn.js "^4.0.0" + brorand "^1.0.1" + +mimic-fn@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" + integrity sha512-OqbOk5oEQeAZ8WXWydlu9HJjz9WVdEIvamMCcXmuqUYjTknH/sqsWvhQ3vgwKFRR1HpjvNBKQ37nbJgYzGqGcg== + +minimalistic-assert@^1.0.0, minimalistic-assert@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-assert/-/minimalistic-assert-1.0.1.tgz#2e194de044626d4a10e7f7fbc00ce73e83e4d5c7" + integrity sha512-UtJcAD4yEaGtjPezWuO9wC4nwUnVH/8/Im3yEHQP4b67cXlD/Qr9hdITCU1xDbSEXg2XKNaP8jsReV7vQd00/A== + +minimalistic-crypto-utils@^1.0.0, minimalistic-crypto-utils@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/minimalistic-crypto-utils/-/minimalistic-crypto-utils-1.0.1.tgz#f6c00c1c0b082246e5c4d99dfb8c7c083b2b582a" + integrity sha1-9sAMHAsIIkblxNmd+4x8CDsrWCo= + +minimatch@^3.0.4: + version "3.0.4" + resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.0.4.tgz#5166e286457f03306064be5497e8dbb0c3d32083" + integrity sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA== + dependencies: + brace-expansion "^1.1.7" + +minimist@^1.2.0, minimist@^1.2.5: + version "1.2.5" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" + integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + +mississippi@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/mississippi/-/mississippi-3.0.0.tgz#ea0a3291f97e0b5e8776b363d5f0a12d94c67022" + integrity sha512-x471SsVjUtBRtcvd4BzKE9kFC+/2TeWgKCgw0bZcw1b9l2X3QX5vCWgF+KaZaYm87Ss//rHnWryupDrgLvmSkA== + dependencies: + concat-stream "^1.5.0" + duplexify "^3.4.2" + end-of-stream "^1.1.0" + flush-write-stream "^1.0.0" + from2 "^2.1.0" + parallel-transform "^1.1.0" + pump "^3.0.0" + pumpify "^1.3.3" + stream-each "^1.1.0" + through2 "^2.0.0" + +mixin-deep@^1.2.0: + version "1.3.2" + resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566" + integrity sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA== + dependencies: + for-in "^1.0.2" + is-extendable "^1.0.1" + +mkdirp@^0.5.1, mkdirp@^0.5.3: + version "0.5.5" + resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.5.tgz#d91cefd62d1436ca0f41620e251288d420099def" + integrity sha512-NKmAlESf6jMGym1++R0Ra7wvhV+wFW63FaSOFPwRahvea0gMUcGUhVeAg/0BC0wiv9ih5NYPB1Wn1UEI1/L+xQ== + dependencies: + minimist "^1.2.5" + +move-concurrently@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/move-concurrently/-/move-concurrently-1.0.1.tgz#be2c005fda32e0b29af1f05d7c4b33214c701f92" + integrity sha1-viwAX9oy4LKa8fBdfEszIUxwH5I= + dependencies: + aproba "^1.1.1" + copy-concurrently "^1.0.0" + fs-write-stream-atomic "^1.0.8" + mkdirp "^0.5.1" + rimraf "^2.5.4" + run-queue "^1.0.3" + +ms@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" + integrity sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g= + +nan@^2.12.1: + version "2.14.1" + resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01" + integrity sha512-isWHgVjnFjh2x2yuJ/tj3JbwoHu3UC2dX5G/88Cm24yB6YopVgxvBObDY7n5xW6ExmFhJpSEQqFPvq9zaXc8Jw== + +nanomatch@^1.2.9: + version "1.2.13" + resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119" + integrity sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA== + dependencies: + arr-diff "^4.0.0" + array-unique "^0.3.2" + define-property "^2.0.2" + extend-shallow "^3.0.2" + fragment-cache "^0.2.1" + is-windows "^1.0.2" + kind-of "^6.0.2" + object.pick "^1.3.0" + regex-not "^1.0.0" + snapdragon "^0.8.1" + to-regex "^3.0.1" + +neo-async@^2.5.0, neo-async@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.1.tgz#ac27ada66167fa8849a6addd837f6b189ad2081c" + integrity sha512-iyam8fBuCUpWeKPGpaNMetEocMt364qkCsfL9JuhjXX6dRnguRVOfk2GZaDpPjcOKiiXCPINZC1GczQ7iTq3Zw== + +nice-try@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/nice-try/-/nice-try-1.0.5.tgz#a3378a7696ce7d223e88fc9b764bd7ef1089e366" + integrity sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ== + +node-libs-browser@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/node-libs-browser/-/node-libs-browser-2.2.1.tgz#b64f513d18338625f90346d27b0d235e631f6425" + integrity sha512-h/zcD8H9kaDZ9ALUWwlBUDo6TKF8a7qBSCSEGfjTVIYeqsioSKaAX+BN7NgiMGp6iSIXZ3PxgCu8KS3b71YK5Q== + dependencies: + assert "^1.1.1" + browserify-zlib "^0.2.0" + buffer "^4.3.0" + console-browserify "^1.1.0" + constants-browserify "^1.0.0" + crypto-browserify "^3.11.0" + domain-browser "^1.1.1" + events "^3.0.0" + https-browserify "^1.0.0" + os-browserify "^0.3.0" + path-browserify "0.0.1" + process "^0.11.10" + punycode "^1.2.4" + querystring-es3 "^0.2.0" + readable-stream "^2.3.3" + stream-browserify "^2.0.1" + stream-http "^2.7.2" + string_decoder "^1.0.0" + timers-browserify "^2.0.4" + tty-browserify "0.0.0" + url "^0.11.0" + util "^0.11.0" + vm-browserify "^1.0.1" + +normalize-path@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-2.1.1.tgz#1ab28b556e198363a8c1a6f7e6fa20137fe6aed9" + integrity sha1-GrKLVW4Zg2Oowab35vogE3/mrtk= + dependencies: + remove-trailing-separator "^1.0.1" + +normalize-path@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" + integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== + +npm-run-path@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/npm-run-path/-/npm-run-path-2.0.2.tgz#35a9232dfa35d7067b4cb2ddf2357b1871536c5f" + integrity sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8= + dependencies: + path-key "^2.0.0" + +object-assign@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863" + integrity sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM= + +object-copy@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/object-copy/-/object-copy-0.1.0.tgz#7e7d858b781bd7c991a41ba975ed3812754e998c" + integrity sha1-fn2Fi3gb18mRpBupde04EnVOmYw= + dependencies: + copy-descriptor "^0.1.0" + define-property "^0.2.5" + kind-of "^3.0.3" + +object-visit@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/object-visit/-/object-visit-1.0.1.tgz#f79c4493af0c5377b59fe39d395e41042dd045bb" + integrity sha1-95xEk68MU3e1n+OdOV5BBC3QRbs= + dependencies: + isobject "^3.0.0" + +object.pick@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/object.pick/-/object.pick-1.3.0.tgz#87a10ac4c1694bd2e1cbf53591a66141fb5dd747" + integrity sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c= + dependencies: + isobject "^3.0.1" + +once@^1.3.0, once@^1.3.1, once@^1.4.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" + integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= + dependencies: + wrappy "1" + +os-browserify@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" + integrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc= + +os-locale@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a" + integrity sha512-Z8l3R4wYWM40/52Z+S265okfFj8Kt2cC2MKY+xNi3kFs+XGI7WXu/I309QQQYbRW4ijiZ+yxs9pqEhJh0DqW3Q== + dependencies: + execa "^1.0.0" + lcid "^2.0.0" + mem "^4.0.0" + +p-defer@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" + integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww= + +p-finally@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" + integrity sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4= + +p-is-promise@^2.0.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.1.0.tgz#918cebaea248a62cf7ffab8e3bca8c5f882fc42e" + integrity sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg== + +p-limit@^2.0.0: + version "2.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" + integrity sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w== + dependencies: + p-try "^2.0.0" + +p-locate@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" + integrity sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ== + dependencies: + p-limit "^2.0.0" + +p-try@^2.0.0: + version "2.2.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" + integrity sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ== + +pako@~1.0.5: + version "1.0.11" + resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf" + integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw== + +parallel-transform@^1.1.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/parallel-transform/-/parallel-transform-1.2.0.tgz#9049ca37d6cb2182c3b1d2c720be94d14a5814fc" + integrity sha512-P2vSmIu38uIlvdcU7fDkyrxj33gTUy/ABO5ZUbGowxNCopBq/OoD42bP4UmMrJoPyk4Uqf0mu3mtWBhHCZD8yg== + dependencies: + cyclist "^1.0.1" + inherits "^2.0.3" + readable-stream "^2.1.5" + +parse-asn1@^5.0.0, parse-asn1@^5.1.5: + version "5.1.5" + resolved "https://registry.yarnpkg.com/parse-asn1/-/parse-asn1-5.1.5.tgz#003271343da58dc94cace494faef3d2147ecea0e" + integrity sha512-jkMYn1dcJqF6d5CpU689bq7w/b5ALS9ROVSpQDPrZsqqesUJii9qutvoT5ltGedNXMO2e16YUWIghG9KxaViTQ== + dependencies: + asn1.js "^4.0.0" + browserify-aes "^1.0.0" + create-hash "^1.1.0" + evp_bytestokey "^1.0.0" + pbkdf2 "^3.0.3" + safe-buffer "^5.1.1" + +parse-passwd@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/parse-passwd/-/parse-passwd-1.0.0.tgz#6d5b934a456993b23d37f40a382d6f1666a8e5c6" + integrity sha1-bVuTSkVpk7I9N/QKOC1vFmao5cY= + +pascalcase@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/pascalcase/-/pascalcase-0.1.1.tgz#b363e55e8006ca6fe21784d2db22bd15d7917f14" + integrity sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ= + +path-browserify@0.0.1: + version "0.0.1" + resolved "https://registry.yarnpkg.com/path-browserify/-/path-browserify-0.0.1.tgz#e6c4ddd7ed3aa27c68a20cc4e50e1a4ee83bbc4a" + integrity sha512-BapA40NHICOS+USX9SN4tyhq+A2RrN/Ws5F0Z5aMHDp98Fl86lX8Oti8B7uN93L4Ifv4fHOEA+pQw87gmMO/lQ== + +path-dirname@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/path-dirname/-/path-dirname-1.0.2.tgz#cc33d24d525e099a5388c0336c6e32b9160609e0" + integrity sha1-zDPSTVJeCZpTiMAzbG4yuRYGCeA= + +path-exists@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" + integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= + +path-is-absolute@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" + integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= + +path-key@^2.0.0, path-key@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40" + integrity sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A= + +pbkdf2@^3.0.3: + version "3.0.17" + resolved "https://registry.yarnpkg.com/pbkdf2/-/pbkdf2-3.0.17.tgz#976c206530617b14ebb32114239f7b09336e93a6" + integrity sha512-U/il5MsrZp7mGg3mSQfn742na2T+1/vHDCG5/iTI3X9MKUuYUZVLQhyRsg06mCgDBTd57TxzgZt7P+fYfjRLtA== + dependencies: + create-hash "^1.1.2" + create-hmac "^1.1.4" + ripemd160 "^2.0.1" + safe-buffer "^5.0.1" + sha.js "^2.4.8" + +pify@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" + integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== + +pkg-dir@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3" + integrity sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw== + dependencies: + find-up "^3.0.0" + +posix-character-classes@^0.1.0: + version "0.1.1" + resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" + integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= + +process-nextick-args@~2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" + integrity sha512-3ouUOpQhtgrbOa17J7+uxOTpITYWaGP7/AhoR3+A+/1e9skrzelGi/dXzEYyvbxubEF6Wn2ypscTKiKJFFn1ag== + +process@^0.11.10: + version "0.11.10" + resolved "https://registry.yarnpkg.com/process/-/process-0.11.10.tgz#7332300e840161bda3e69a1d1d91a7d4bc16f182" + integrity sha1-czIwDoQBYb2j5podHZGn1LwW8YI= + +promise-inflight@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/promise-inflight/-/promise-inflight-1.0.1.tgz#98472870bf228132fcbdd868129bad12c3c029e3" + integrity sha1-mEcocL8igTL8vdhoEputEsPAKeM= + +prr@~1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/prr/-/prr-1.0.1.tgz#d3fc114ba06995a45ec6893f484ceb1d78f5f476" + integrity sha1-0/wRS6BplaRexok/SEzrHXj19HY= + +public-encrypt@^4.0.0: + version "4.0.3" + resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0" + integrity sha512-zVpa8oKZSz5bTMTFClc1fQOnyyEzpl5ozpi1B5YcvBrdohMjH2rfsBtyXcuNuwjsDIXmBYlF2N5FlJYhR29t8Q== + dependencies: + bn.js "^4.1.0" + browserify-rsa "^4.0.0" + create-hash "^1.1.0" + parse-asn1 "^5.0.0" + randombytes "^2.0.1" + safe-buffer "^5.1.2" + +pump@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/pump/-/pump-2.0.1.tgz#12399add6e4cf7526d973cbc8b5ce2e2908b3909" + integrity sha512-ruPMNRkN3MHP1cWJc9OWr+T/xDP0jhXYCLfJcBuX54hhfIBnaQmAUMfDcG4DM5UMWByBbJY69QSphm3jtDKIkA== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +pump@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" + integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + +pumpify@^1.3.3: + version "1.5.1" + resolved "https://registry.yarnpkg.com/pumpify/-/pumpify-1.5.1.tgz#36513be246ab27570b1a374a5ce278bfd74370ce" + integrity sha512-oClZI37HvuUJJxSKKrC17bZ9Cu0ZYhEAGPsPUy9KlMUmv9dKX2o77RUmq7f3XjIxbwyGwYzbzQ1L2Ks8sIradQ== + dependencies: + duplexify "^3.6.0" + inherits "^2.0.3" + pump "^2.0.0" + +punycode@1.3.2: + version "1.3.2" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.3.2.tgz#9653a036fb7c1ee42342f2325cceefea3926c48d" + integrity sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0= + +punycode@^1.2.4: + version "1.4.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" + integrity sha1-wNWmOycYgArY4esPpSachN1BhF4= + +punycode@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" + integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== + +querystring-es3@^0.2.0: + version "0.2.1" + resolved "https://registry.yarnpkg.com/querystring-es3/-/querystring-es3-0.2.1.tgz#9ec61f79049875707d69414596fd907a4d711e73" + integrity sha1-nsYfeQSYdXB9aUFFlv2Qek1xHnM= + +querystring@0.2.0: + version "0.2.0" + resolved "https://registry.yarnpkg.com/querystring/-/querystring-0.2.0.tgz#b209849203bb25df820da756e747005878521620" + integrity sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA= + +randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5: + version "2.1.0" + resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a" + integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ== + dependencies: + safe-buffer "^5.1.0" + +randomfill@^1.0.3: + version "1.0.4" + resolved "https://registry.yarnpkg.com/randomfill/-/randomfill-1.0.4.tgz#c92196fc86ab42be983f1bf31778224931d61458" + integrity sha512-87lcbR8+MhcWcUiQ+9e+Rwx8MyR2P7qnt15ynUlbm3TU/fjbgz4GsvfSUDTemtCCtVCqb4ZcEFlyPNTh9bBTLw== + dependencies: + randombytes "^2.0.5" + safe-buffer "^5.1.0" + +"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.3, readable-stream@^2.3.6, readable-stream@~2.3.6: + version "2.3.7" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" + integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== + dependencies: + core-util-is "~1.0.0" + inherits "~2.0.3" + isarray "~1.0.0" + process-nextick-args "~2.0.0" + safe-buffer "~5.1.1" + string_decoder "~1.1.1" + util-deprecate "~1.0.1" + +readable-stream@^3.6.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" + integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readdirp@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-2.2.1.tgz#0e87622a3325aa33e892285caf8b4e846529a525" + integrity sha512-1JU/8q+VgFZyxwrJ+SVIOsh+KywWGpds3NTqikiKpDMZWScmAYyKIgqkO+ARvNWJfXeXR1zxz7aHF4u4CyH6vQ== + dependencies: + graceful-fs "^4.1.11" + micromatch "^3.1.10" + readable-stream "^2.0.2" + +regex-not@^1.0.0, regex-not@^1.0.2: + version "1.0.2" + resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" + integrity sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A== + dependencies: + extend-shallow "^3.0.2" + safe-regex "^1.1.0" + +remove-trailing-separator@^1.0.1: + version "1.1.0" + resolved "https://registry.yarnpkg.com/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz#c24bce2a283adad5bc3f58e0d48249b92379d8ef" + integrity sha1-wkvOKig62tW8P1jg1IJJuSN52O8= + +repeat-element@^1.1.2: + version "1.1.3" + resolved "https://registry.yarnpkg.com/repeat-element/-/repeat-element-1.1.3.tgz#782e0d825c0c5a3bb39731f84efee6b742e6b1ce" + integrity sha512-ahGq0ZnV5m5XtZLMb+vP76kcAM5nkLqk0lpqAuojSKGgQtn4eRi4ZZGm2olo2zKFH+sMsWaqOCW1dqAnOru72g== + +repeat-string@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" + integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= + +require-directory@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" + integrity sha1-jGStX9MNqxyXbiNE/+f3kqam30I= + +require-main-filename@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-2.0.0.tgz#d0b329ecc7cc0f61649f62215be69af54aa8989b" + integrity sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg== + +resolve-cwd@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/resolve-cwd/-/resolve-cwd-2.0.0.tgz#00a9f7387556e27038eae232caa372a6a59b665a" + integrity sha1-AKn3OHVW4nA46uIyyqNypqWbZlo= + dependencies: + resolve-from "^3.0.0" + +resolve-dir@^1.0.0, resolve-dir@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/resolve-dir/-/resolve-dir-1.0.1.tgz#79a40644c362be82f26effe739c9bb5382046f43" + integrity sha1-eaQGRMNivoLybv/nOcm7U4IEb0M= + dependencies: + expand-tilde "^2.0.0" + global-modules "^1.0.0" + +resolve-from@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-3.0.0.tgz#b22c7af7d9d6881bc8b6e653335eebcb0a188748" + integrity sha1-six699nWiBvItuZTM17rywoYh0g= + +resolve-url@^0.2.1: + version "0.2.1" + resolved "https://registry.yarnpkg.com/resolve-url/-/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" + integrity sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo= + +ret@~0.1.10: + version "0.1.15" + resolved "https://registry.yarnpkg.com/ret/-/ret-0.1.15.tgz#b8a4825d5bdb1fc3f6f53c2bc33f81388681c7bc" + integrity sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg== + +rimraf@^2.5.4, rimraf@^2.6.3: + version "2.7.1" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" + integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== + dependencies: + glob "^7.1.3" + +ripemd160@^2.0.0, ripemd160@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/ripemd160/-/ripemd160-2.0.2.tgz#a1c1a6f624751577ba5d07914cbc92850585890c" + integrity sha512-ii4iagi25WusVoiC4B4lq7pbXfAp3D9v5CwfkY33vffw2+pkDjY1D8GaN7spsxvCSx8dkPqOZCEZyfxcmJG2IA== + dependencies: + hash-base "^3.0.0" + inherits "^2.0.1" + +run-queue@^1.0.0, run-queue@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/run-queue/-/run-queue-1.0.3.tgz#e848396f057d223f24386924618e25694161ec47" + integrity sha1-6Eg5bwV9Ij8kOGkkYY4laUFh7Ec= + dependencies: + aproba "^1.1.1" + +safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, safe-buffer@^5.1.2, safe-buffer@^5.2.0, safe-buffer@~5.2.0: + version "5.2.1" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6" + integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ== + +safe-buffer@~5.1.0, safe-buffer@~5.1.1: + version "5.1.2" + resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" + integrity sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g== + +safe-regex@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e" + integrity sha1-QKNmnzsHfR6UPURinhV91IAjvy4= + dependencies: + ret "~0.1.10" + +schema-utils@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/schema-utils/-/schema-utils-1.0.0.tgz#0b79a93204d7b600d4b2850d1f66c2a34951c770" + integrity sha512-i27Mic4KovM/lnGsy8whRCHhc7VicJajAjTrYg11K9zfZXnYIt4k5F+kZkwjnrhKzLic/HLU4j11mjsz2G/75g== + dependencies: + ajv "^6.1.0" + ajv-errors "^1.0.0" + ajv-keywords "^3.1.0" + +semver@^5.5.0, semver@^5.6.0: + version "5.7.1" + resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" + integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== + +serialize-javascript@^2.1.2: + version "2.1.2" + resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-2.1.2.tgz#ecec53b0e0317bdc95ef76ab7074b7384785fa61" + integrity sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ== + +set-blocking@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/set-blocking/-/set-blocking-2.0.0.tgz#045f9782d011ae9a6803ddd382b24392b3d890f7" + integrity sha1-BF+XgtARrppoA93TgrJDkrPYkPc= + +set-value@^2.0.0, set-value@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/set-value/-/set-value-2.0.1.tgz#a18d40530e6f07de4228c7defe4227af8cad005b" + integrity sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw== + dependencies: + extend-shallow "^2.0.1" + is-extendable "^0.1.1" + is-plain-object "^2.0.3" + split-string "^3.0.1" + +setimmediate@^1.0.4: + version "1.0.5" + resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" + integrity sha1-KQy7Iy4waULX1+qbg3Mqt4VvgoU= + +sha.js@^2.4.0, sha.js@^2.4.8: + version "2.4.11" + resolved "https://registry.yarnpkg.com/sha.js/-/sha.js-2.4.11.tgz#37a5cf0b81ecbc6943de109ba2960d1b26584ae7" + integrity sha512-QMEp5B7cftE7APOjk5Y6xgrbWu+WkLVQwk8JNjZ8nKRciZaByEW6MubieAiToS7+dwvrjGhH8jRXz3MVd0AYqQ== + dependencies: + inherits "^2.0.1" + safe-buffer "^5.0.1" + +shebang-command@^1.2.0: + version "1.2.0" + resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" + integrity sha1-RKrGW2lbAzmJaMOfNj/uXer98eo= + dependencies: + shebang-regex "^1.0.0" + +shebang-regex@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3" + integrity sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM= + +signal-exit@^3.0.0: + version "3.0.3" + resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" + integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== + +snapdragon-node@^2.0.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" + integrity sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw== + dependencies: + define-property "^1.0.0" + isobject "^3.0.0" + snapdragon-util "^3.0.1" + +snapdragon-util@^3.0.1: + version "3.0.1" + resolved "https://registry.yarnpkg.com/snapdragon-util/-/snapdragon-util-3.0.1.tgz#f956479486f2acd79700693f6f7b805e45ab56e2" + integrity sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ== + dependencies: + kind-of "^3.2.0" + +snapdragon@^0.8.1: + version "0.8.2" + resolved "https://registry.yarnpkg.com/snapdragon/-/snapdragon-0.8.2.tgz#64922e7c565b0e14204ba1aa7d6964278d25182d" + integrity sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg== + dependencies: + base "^0.11.1" + debug "^2.2.0" + define-property "^0.2.5" + extend-shallow "^2.0.1" + map-cache "^0.2.2" + source-map "^0.5.6" + source-map-resolve "^0.5.0" + use "^3.1.0" + +source-list-map@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/source-list-map/-/source-list-map-2.0.1.tgz#3993bd873bfc48479cca9ea3a547835c7c154b34" + integrity sha512-qnQ7gVMxGNxsiL4lEuJwe/To8UnK7fAnmbGEEH8RpLouuKbeEm0lhbQVFIrNSuB+G7tVrAlVsZgETT5nljf+Iw== + +source-map-resolve@^0.5.0: + version "0.5.3" + resolved "https://registry.yarnpkg.com/source-map-resolve/-/source-map-resolve-0.5.3.tgz#190866bece7553e1f8f267a2ee82c606b5509a1a" + integrity sha512-Htz+RnsXWk5+P2slx5Jh3Q66vhQj1Cllm0zvnaY98+NFx+Dv2CF/f5O/t8x+KaNdrdIAsruNzoh/KpialbqAnw== + dependencies: + atob "^2.1.2" + decode-uri-component "^0.2.0" + resolve-url "^0.2.1" + source-map-url "^0.4.0" + urix "^0.1.0" + +source-map-support@~0.5.12: + version "0.5.19" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" + integrity sha512-Wonm7zOCIJzBGQdB+thsPar0kYuCIzYvxZwlBa87yi/Mdjv7Tip2cyVbLj5o0cFPN4EVkuTwb3GDDyUx2DGnGw== + dependencies: + buffer-from "^1.0.0" + source-map "^0.6.0" + +source-map-url@^0.4.0: + version "0.4.0" + resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" + integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= + +source-map@^0.5.6: + version "0.5.7" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" + integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= + +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: + version "0.6.1" + resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" + integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== + +split-string@^3.0.1, split-string@^3.0.2: + version "3.1.0" + resolved "https://registry.yarnpkg.com/split-string/-/split-string-3.1.0.tgz#7cb09dda3a86585705c64b39a6466038682e8fe2" + integrity sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw== + dependencies: + extend-shallow "^3.0.0" + +ssri@^6.0.1: + version "6.0.1" + resolved "https://registry.yarnpkg.com/ssri/-/ssri-6.0.1.tgz#2a3c41b28dd45b62b63676ecb74001265ae9edd8" + integrity sha512-3Wge10hNcT1Kur4PDFwEieXSCMCJs/7WvSACcrMYrNp+b8kDL1/0wJch5Ni2WrtwEa2IO8OsVfeKIciKCDx/QA== + dependencies: + figgy-pudding "^3.5.1" + +static-extend@^0.1.1: + version "0.1.2" + resolved "https://registry.yarnpkg.com/static-extend/-/static-extend-0.1.2.tgz#60809c39cbff55337226fd5e0b520f341f1fb5c6" + integrity sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY= + dependencies: + define-property "^0.2.5" + object-copy "^0.1.0" + +stream-browserify@^2.0.1: + version "2.0.2" + resolved "https://registry.yarnpkg.com/stream-browserify/-/stream-browserify-2.0.2.tgz#87521d38a44aa7ee91ce1cd2a47df0cb49dd660b" + integrity sha512-nX6hmklHs/gr2FuxYDltq8fJA1GDlxKQCz8O/IM4atRqBH8OORmBNgfvW5gG10GT/qQ9u0CzIvr2X5Pkt6ntqg== + dependencies: + inherits "~2.0.1" + readable-stream "^2.0.2" + +stream-each@^1.1.0: + version "1.2.3" + resolved "https://registry.yarnpkg.com/stream-each/-/stream-each-1.2.3.tgz#ebe27a0c389b04fbcc233642952e10731afa9bae" + integrity sha512-vlMC2f8I2u/bZGqkdfLQW/13Zihpej/7PmSiMQsbYddxuTsJp8vRe2x2FvVExZg7FaOds43ROAuFJwPR4MTZLw== + dependencies: + end-of-stream "^1.1.0" + stream-shift "^1.0.0" + +stream-http@^2.7.2: + version "2.8.3" + resolved "https://registry.yarnpkg.com/stream-http/-/stream-http-2.8.3.tgz#b2d242469288a5a27ec4fe8933acf623de6514fc" + integrity sha512-+TSkfINHDo4J+ZobQLWiMouQYB+UVYFttRA94FpEzzJ7ZdqcL4uUUQ7WkdkI4DSozGmgBUE/a47L+38PenXhUw== + dependencies: + builtin-status-codes "^3.0.0" + inherits "^2.0.1" + readable-stream "^2.3.6" + to-arraybuffer "^1.0.0" + xtend "^4.0.0" + +stream-shift@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/stream-shift/-/stream-shift-1.0.1.tgz#d7088281559ab2778424279b0877da3c392d5a3d" + integrity sha512-AiisoFqQ0vbGcZgQPY1cdP2I76glaVA/RauYR4G4thNFgkTqr90yXTo4LYX60Jl+sIlPNHHdGSwo01AvbKUSVQ== + +string-width@^3.0.0, string-width@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/string-width/-/string-width-3.1.0.tgz#22767be21b62af1081574306f69ac51b62203961" + integrity sha512-vafcv6KjVZKSgz06oM/H6GDBrAtz8vdhQakGjFIvNrHA6y3HCF1CInLy+QLq8dTJPQ1b+KDUqDFctkdRW44e1w== + dependencies: + emoji-regex "^7.0.1" + is-fullwidth-code-point "^2.0.0" + strip-ansi "^5.1.0" + +string_decoder@^1.0.0, string_decoder@^1.1.1: + version "1.3.0" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.3.0.tgz#42f114594a46cf1a8e30b0a84f56c78c3edac21e" + integrity sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA== + dependencies: + safe-buffer "~5.2.0" + +string_decoder@~1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/string_decoder/-/string_decoder-1.1.1.tgz#9cf1611ba62685d7030ae9e4ba34149c3af03fc8" + integrity sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg== + dependencies: + safe-buffer "~5.1.0" + +strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" + integrity sha512-DuRs1gKbBqsMKIZlrffwlug8MHkcnpjs5VPmL1PAh+mA30U0DTotfDZ0d2UUsXpPmPmMMJ6W773MaA3J+lbiWA== + dependencies: + ansi-regex "^4.1.0" + +strip-eof@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" + integrity sha1-u0P/VZim6wXYm1n80SnJgzE2Br8= + +supports-color@6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" + integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== + dependencies: + has-flag "^3.0.0" + +supports-color@^5.3.0: + version "5.5.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" + integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== + dependencies: + has-flag "^3.0.0" + +tapable@^1.0.0, tapable@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/tapable/-/tapable-1.1.3.tgz#a1fccc06b58db61fd7a45da2da44f5f3a3e67ba2" + integrity sha512-4WK/bYZmj8xLr+HUCODHGF1ZFzsYffasLUgEiMBY4fgtltdO6B4WJtlSbPaDTLpYTcGVwM2qLnFTICEcNxs3kA== + +terser-webpack-plugin@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/terser-webpack-plugin/-/terser-webpack-plugin-1.4.3.tgz#5ecaf2dbdc5fb99745fd06791f46fc9ddb1c9a7c" + integrity sha512-QMxecFz/gHQwteWwSo5nTc6UaICqN1bMedC5sMtUc7y3Ha3Q8y6ZO0iCR8pq4RJC8Hjf0FEPEHZqcMB/+DFCrA== + dependencies: + cacache "^12.0.2" + find-cache-dir "^2.1.0" + is-wsl "^1.1.0" + schema-utils "^1.0.0" + serialize-javascript "^2.1.2" + source-map "^0.6.1" + terser "^4.1.2" + webpack-sources "^1.4.0" + worker-farm "^1.7.0" + +terser@^4.1.2: + version "4.6.13" + resolved "https://registry.yarnpkg.com/terser/-/terser-4.6.13.tgz#e879a7364a5e0db52ba4891ecde007422c56a916" + integrity sha512-wMvqukYgVpQlymbnNbabVZbtM6PN63AzqexpwJL8tbh/mRT9LE5o+ruVduAGL7D6Fpjl+Q+06U5I9Ul82odAhw== + dependencies: + commander "^2.20.0" + source-map "~0.6.1" + source-map-support "~0.5.12" + +through2@^2.0.0: + version "2.0.5" + resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.5.tgz#01c1e39eb31d07cb7d03a96a70823260b23132cd" + integrity sha512-/mrRod8xqpA+IHSLyGCQ2s8SPHiCDEeQJSep1jqLYeEUClOFG2Qsh+4FU6G9VeqpZnGW/Su8LQGc4YKni5rYSQ== + dependencies: + readable-stream "~2.3.6" + xtend "~4.0.1" + +timers-browserify@^2.0.4: + version "2.0.11" + resolved "https://registry.yarnpkg.com/timers-browserify/-/timers-browserify-2.0.11.tgz#800b1f3eee272e5bc53ee465a04d0e804c31211f" + integrity sha512-60aV6sgJ5YEbzUdn9c8kYGIqOubPoUdqQCul3SBAsRCZ40s6Y5cMcrW4dt3/k/EsbLVJNl9n6Vz3fTc+k2GeKQ== + dependencies: + setimmediate "^1.0.4" + +to-arraybuffer@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" + integrity sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M= + +to-object-path@^0.3.0: + version "0.3.0" + resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" + integrity sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68= + dependencies: + kind-of "^3.0.2" + +to-regex-range@^2.1.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-2.1.1.tgz#7c80c17b9dfebe599e27367e0d4dd5590141db38" + integrity sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg= + dependencies: + is-number "^3.0.0" + repeat-string "^1.6.1" + +to-regex@^3.0.1, to-regex@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/to-regex/-/to-regex-3.0.2.tgz#13cfdd9b336552f30b51f33a8ae1b42a7a7599ce" + integrity sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw== + dependencies: + define-property "^2.0.2" + extend-shallow "^3.0.2" + regex-not "^1.0.2" + safe-regex "^1.1.0" + +tslib@^1.9.0: + version "1.11.2" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.2.tgz#9c79d83272c9a7aaf166f73915c9667ecdde3cc9" + integrity sha512-tTSkux6IGPnUGUd1XAZHcpu85MOkIl5zX49pO+jfsie3eP0B6pyhOlLXm3cAC6T7s+euSDDUUV+Acop5WmtkVg== + +tty-browserify@0.0.0: + version "0.0.0" + resolved "https://registry.yarnpkg.com/tty-browserify/-/tty-browserify-0.0.0.tgz#a157ba402da24e9bf957f9aa69d524eed42901a6" + integrity sha1-oVe6QC2iTpv5V/mqadUk7tQpAaY= + +typedarray@^0.0.6: + version "0.0.6" + resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777" + integrity sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c= + +union-value@^1.0.0: + version "1.0.1" + resolved "https://registry.yarnpkg.com/union-value/-/union-value-1.0.1.tgz#0b6fe7b835aecda61c6ea4d4f02c14221e109847" + integrity sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg== + dependencies: + arr-union "^3.1.0" + get-value "^2.0.6" + is-extendable "^0.1.1" + set-value "^2.0.1" + +unique-filename@^1.1.1: + version "1.1.1" + resolved "https://registry.yarnpkg.com/unique-filename/-/unique-filename-1.1.1.tgz#1d69769369ada0583103a1e6ae87681b56573230" + integrity sha512-Vmp0jIp2ln35UTXuryvjzkjGdRyf9b2lTXuSYUiPmzRcl3FDtYqAwOnTJkAngD9SWhnoJzDbTKwaOrZ+STtxNQ== + dependencies: + unique-slug "^2.0.0" + +unique-slug@^2.0.0: + version "2.0.2" + resolved "https://registry.yarnpkg.com/unique-slug/-/unique-slug-2.0.2.tgz#baabce91083fc64e945b0f3ad613e264f7cd4e6c" + integrity sha512-zoWr9ObaxALD3DOPfjPSqxt4fnZiWblxHIgeWqW8x7UqDzEtHEQLzji2cuJYQFCU6KmoJikOYAZlrTHHebjx2w== + dependencies: + imurmurhash "^0.1.4" + +unset-value@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/unset-value/-/unset-value-1.0.0.tgz#8376873f7d2335179ffb1e6fc3a8ed0dfc8ab559" + integrity sha1-g3aHP30jNRef+x5vw6jtDfyKtVk= + dependencies: + has-value "^0.3.1" + isobject "^3.0.0" + +upath@^1.1.1: + version "1.2.0" + resolved "https://registry.yarnpkg.com/upath/-/upath-1.2.0.tgz#8f66dbcd55a883acdae4408af8b035a5044c1894" + integrity sha512-aZwGpamFO61g3OlfT7OQCHqhGnW43ieH9WZeP7QxN/G/jS4jfqUkZxoryvJgVPEcrl5NL/ggHsSmLMHuH64Lhg== + +uri-js@^4.2.2: + version "4.2.2" + resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.2.2.tgz#94c540e1ff772956e2299507c010aea6c8838eb0" + integrity sha512-KY9Frmirql91X2Qgjry0Wd4Y+YTdrdZheS8TFwvkbLWf/G5KNJDCh6pKL5OZctEW4+0Baa5idK2ZQuELRwPznQ== + dependencies: + punycode "^2.1.0" + +urix@^0.1.0: + version "0.1.0" + resolved "https://registry.yarnpkg.com/urix/-/urix-0.1.0.tgz#da937f7a62e21fec1fd18d49b35c2935067a6c72" + integrity sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI= + +url@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/url/-/url-0.11.0.tgz#3838e97cfc60521eb73c525a8e55bfdd9e2e28f1" + integrity sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE= + dependencies: + punycode "1.3.2" + querystring "0.2.0" + +use@^3.1.0: + version "3.1.1" + resolved "https://registry.yarnpkg.com/use/-/use-3.1.1.tgz#d50c8cac79a19fbc20f2911f56eb973f4e10070f" + integrity sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ== + +util-deprecate@^1.0.1, util-deprecate@~1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf" + integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8= + +util@0.10.3: + version "0.10.3" + resolved "https://registry.yarnpkg.com/util/-/util-0.10.3.tgz#7afb1afe50805246489e3db7fe0ed379336ac0f9" + integrity sha1-evsa/lCAUkZInj23/g7TeTNqwPk= + dependencies: + inherits "2.0.1" + +util@^0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/util/-/util-0.11.1.tgz#3236733720ec64bb27f6e26f421aaa2e1b588d61" + integrity sha512-HShAsny+zS2TZfaXxD9tYj4HQGlBezXZMZuM/S5PKLLoZkShZiGk9o5CzukI1LVHZvjdvZ2Sj1aW/Ndn2NB/HQ== + dependencies: + inherits "2.0.3" + +v8-compile-cache@2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/v8-compile-cache/-/v8-compile-cache-2.0.3.tgz#00f7494d2ae2b688cfe2899df6ed2c54bef91dbe" + integrity sha512-CNmdbwQMBjwr9Gsmohvm0pbL954tJrNzf6gWL3K+QMQf00PF7ERGrEiLgjuU3mKreLC2MeGhUsNV9ybTbLgd3w== + +vm-browserify@^1.0.1: + version "1.1.2" + resolved "https://registry.yarnpkg.com/vm-browserify/-/vm-browserify-1.1.2.tgz#78641c488b8e6ca91a75f511e7a3b32a86e5dda0" + integrity sha512-2ham8XPWTONajOR0ohOKOHXkm3+gaBmGut3SRuu75xLd/RRaY6vqgh8NBYYk7+RW3u5AtzPQZG8F10LHkl0lAQ== + +watchpack@^1.6.1: + version "1.6.1" + resolved "https://registry.yarnpkg.com/watchpack/-/watchpack-1.6.1.tgz#280da0a8718592174010c078c7585a74cd8cd0e2" + integrity sha512-+IF9hfUFOrYOOaKyfaI7h7dquUIOgyEMoQMLA7OP5FxegKA2+XdXThAZ9TU2kucfhDH7rfMHs1oPYziVGWRnZA== + dependencies: + chokidar "^2.1.8" + graceful-fs "^4.1.2" + neo-async "^2.5.0" + +webpack-cli@^3.3.11: + version "3.3.11" + resolved "https://registry.yarnpkg.com/webpack-cli/-/webpack-cli-3.3.11.tgz#3bf21889bf597b5d82c38f215135a411edfdc631" + integrity sha512-dXlfuml7xvAFwYUPsrtQAA9e4DOe58gnzSxhgrO/ZM/gyXTBowrsYeubyN4mqGhYdpXMFNyQ6emjJS9M7OBd4g== + dependencies: + chalk "2.4.2" + cross-spawn "6.0.5" + enhanced-resolve "4.1.0" + findup-sync "3.0.0" + global-modules "2.0.0" + import-local "2.0.0" + interpret "1.2.0" + loader-utils "1.2.3" + supports-color "6.1.0" + v8-compile-cache "2.0.3" + yargs "13.2.4" + +webpack-sources@^1.4.0, webpack-sources@^1.4.1: + version "1.4.3" + resolved "https://registry.yarnpkg.com/webpack-sources/-/webpack-sources-1.4.3.tgz#eedd8ec0b928fbf1cbfe994e22d2d890f330a933" + integrity sha512-lgTS3Xhv1lCOKo7SA5TjKXMjpSM4sBjNV5+q2bqesbSPs5FjGmU6jjtBSkX9b4qW87vDIsCIlUPOEhbZrMdjeQ== + dependencies: + source-list-map "^2.0.0" + source-map "~0.6.1" + +webpack@^4.43.0: + version "4.43.0" + resolved "https://registry.yarnpkg.com/webpack/-/webpack-4.43.0.tgz#c48547b11d563224c561dad1172c8aa0b8a678e6" + integrity sha512-GW1LjnPipFW2Y78OOab8NJlCflB7EFskMih2AHdvjbpKMeDJqEgSx24cXXXiPS65+WSwVyxtDsJH6jGX2czy+g== + dependencies: + "@webassemblyjs/ast" "1.9.0" + "@webassemblyjs/helper-module-context" "1.9.0" + "@webassemblyjs/wasm-edit" "1.9.0" + "@webassemblyjs/wasm-parser" "1.9.0" + acorn "^6.4.1" + ajv "^6.10.2" + ajv-keywords "^3.4.1" + chrome-trace-event "^1.0.2" + enhanced-resolve "^4.1.0" + eslint-scope "^4.0.3" + json-parse-better-errors "^1.0.2" + loader-runner "^2.4.0" + loader-utils "^1.2.3" + memory-fs "^0.4.1" + micromatch "^3.1.10" + mkdirp "^0.5.3" + neo-async "^2.6.1" + node-libs-browser "^2.2.1" + schema-utils "^1.0.0" + tapable "^1.1.3" + terser-webpack-plugin "^1.4.3" + watchpack "^1.6.1" + webpack-sources "^1.4.1" + +which-module@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" + integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= + +which@^1.2.14, which@^1.2.9, which@^1.3.1: + version "1.3.1" + resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" + integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== + dependencies: + isexe "^2.0.0" + +worker-farm@^1.7.0: + version "1.7.0" + resolved "https://registry.yarnpkg.com/worker-farm/-/worker-farm-1.7.0.tgz#26a94c5391bbca926152002f69b84a4bf772e5a8" + integrity sha512-rvw3QTZc8lAxyVrqcSGVm5yP/IJ2UcB3U0graE3LCFoZ0Yn2x4EoVSqJKdB/T5M+FLcRPjz4TDacRf3OCfNUzw== + dependencies: + errno "~0.1.7" + +wrap-ansi@^5.1.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-5.1.0.tgz#1fd1f67235d5b6d0fee781056001bfb694c03b09" + integrity sha512-QC1/iN/2/RPVJ5jYK8BGttj5z83LmSKmvbvrXPNCLZSEb32KKVDJDl/MOt2N01qU2H/FkzEa9PKto1BqDjtd7Q== + dependencies: + ansi-styles "^3.2.0" + string-width "^3.0.0" + strip-ansi "^5.0.0" + +wrappy@1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" + integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= + +xtend@^4.0.0, xtend@~4.0.1: + version "4.0.2" + resolved "https://registry.yarnpkg.com/xtend/-/xtend-4.0.2.tgz#bb72779f5fa465186b1f438f674fa347fdb5db54" + integrity sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ== + +y18n@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/y18n/-/y18n-4.0.0.tgz#95ef94f85ecc81d007c264e190a120f0a3c8566b" + integrity sha512-r9S/ZyXu/Xu9q1tYlpsLIsa3EeLXXk0VwlxqTcFRfg9EhMW+17kbt9G0NrgCmhGb5vT2hyhJZLfDGx+7+5Uj/w== + +yallist@^3.0.2: + version "3.1.1" + resolved "https://registry.yarnpkg.com/yallist/-/yallist-3.1.1.tgz#dbb7daf9bfd8bac9ab45ebf602b8cbad0d5d08fd" + integrity sha512-a4UGQaWPH59mOXUYnAG2ewncQS4i4F43Tv3JoAM+s2VDAmS9NsK8GpDMLrCHPksFT7h3K6TOoUNn2pb7RoXx4g== + +yargs-parser@^13.1.0: + version "13.1.2" + resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-13.1.2.tgz#130f09702ebaeef2650d54ce6e3e5706f7a4fb38" + integrity sha512-3lbsNRf/j+A4QuSZfDRA7HRSfWrzO0YjqTJd5kjAq37Zep1CEgaYmrH9Q3GwPiB9cHyd1Y1UwggGhJGoxipbzg== + dependencies: + camelcase "^5.0.0" + decamelize "^1.2.0" + +yargs@13.2.4: + version "13.2.4" + resolved "https://registry.yarnpkg.com/yargs/-/yargs-13.2.4.tgz#0b562b794016eb9651b98bd37acf364aa5d6dc83" + integrity sha512-HG/DWAJa1PAnHT9JAhNa8AbAv3FPaiLzioSjCcmuXXhP8MlpHO5vwls4g4j6n30Z74GVQj8Xa62dWVx1QCGklg== + dependencies: + cliui "^5.0.0" + find-up "^3.0.0" + get-caller-file "^2.0.1" + os-locale "^3.1.0" + require-directory "^2.1.1" + require-main-filename "^2.0.0" + set-blocking "^2.0.0" + string-width "^3.0.0" + which-module "^2.0.0" + y18n "^4.0.0" + yargs-parser "^13.1.0" From 91593ae18208cd20efcadf29c90f88021bfa2e2b Mon Sep 17 00:00:00 2001 From: Derik Ramirez Date: Wed, 13 May 2020 15:10:37 -0600 Subject: [PATCH 2/4] Adds minification and transpilation for specific JavaScripts Using Webpack module bunlder we are now able to minify the JavaScript files. We would need to change the structure of our JavaScript source files in the future but at the moment we'll generate the new minified JavaScript and add it to `virtualhosts/www/javascript/`. The current setup, doesn't require any change on our JavaScript only changes in the directory structure. --- package.json | 2 + .../webui/templates/resources/edit.html | 2 +- src/virtualhosts/www/javascript/main.js | 1 - .../www/javascript/resource_admin.js | 192 +-------- .../www/javascript/select_loaders.js | 335 +--------------- src/virtualhosts/www/javascript/src/main.js | 12 + .../www/javascript/src/resource_admin.js | 191 +++++++++ .../www/javascript/src/select_loaders.js | 342 ++++++++++++++++ webpack.config.js | 22 +- yarn.lock | 376 +++++++++++++++++- 10 files changed, 938 insertions(+), 537 deletions(-) delete mode 100644 src/virtualhosts/www/javascript/main.js create mode 100644 src/virtualhosts/www/javascript/src/main.js create mode 100644 src/virtualhosts/www/javascript/src/resource_admin.js create mode 100644 src/virtualhosts/www/javascript/src/select_loaders.js diff --git a/package.json b/package.json index e9a8dd5b3..8a807713b 100644 --- a/package.json +++ b/package.json @@ -8,6 +8,8 @@ "license": "Private", "private": true, "dependencies": { + "babel-core": "^6.26.3", + "babel-loader": "7", "webpack": "^4.43.0" }, "scripts": { diff --git a/src/snac/client/webui/templates/resources/edit.html b/src/snac/client/webui/templates/resources/edit.html index fdca22802..6762980b2 100644 --- a/src/snac/client/webui/templates/resources/edit.html +++ b/src/snac/client/webui/templates/resources/edit.html @@ -35,7 +35,7 @@ - + diff --git a/src/virtualhosts/www/javascript/main.js b/src/virtualhosts/www/javascript/main.js deleted file mode 100644 index ba45c557d..000000000 --- a/src/virtualhosts/www/javascript/main.js +++ /dev/null @@ -1 +0,0 @@ -import { loadVocabSelectOptions } from "./select_loaders.js" diff --git a/src/virtualhosts/www/javascript/resource_admin.js b/src/virtualhosts/www/javascript/resource_admin.js index 27a28e900..4bc8cf0a9 100644 --- a/src/virtualhosts/www/javascript/resource_admin.js +++ b/src/virtualhosts/www/javascript/resource_admin.js @@ -1,191 +1 @@ -/** - * Resource Admin Actions - * - * Contains code that handles Resource creation and editing - * - * @author Joseph Glass - * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause - * @copyright 2015 the Rector and Visitors of the University of Virginia, and - * the Regents of the University of California - */ - -function saveResource(event) { - event.preventDefault(); - var $form = $(event.target); - - if ($form.find("#resource-url").val() == "") { - if (!confirm('Are you sure you want to save without an HREF?')) { - return; - } - } - $('#notification-message').slideDown().html("

Saving Resource... Please wait.

"); - - // Remove leading and trailing whitespace - $form.find("input, textarea").each(function() { - $(this).val($.trim($(this).val())); - }); - - setDeletedResourceLanguageOperations($form); - - $.post(snacUrl + "/save_resource", $form.serialize()) - .done(function(data) { - createdResource = data; - if (typeof(data.resource) === 'undefined') { - $('#error-message').slideDown(); - return false; - } - $('#notification-message').slideUp(); - $('#success-message').slideDown(); - setTimeout(function() { - window.location = (snacUrl + "/vocab_administrator/resources/" + data.resource.id); - }, 1000); - }) - .fail(function() { - $('#error-message').slideDown(); - }); - return false; -} - - -function setDeletedResourceLanguageOperations($form) { - // Set deleted new languages to null, set deleted existing languages to delete - var $deletedLanguages = $form.find("#resource-languages .component-deleted").has('input[id]'); - var $ignoredLanguages = $form.find("#resource-languages .component-deleted.new-language"); - setOperations($deletedLanguages, "delete"); - setOperations($ignoredLanguages, ""); -} - -function cancelResource() { - if (!confirm('Are you sure you want to cancel?')) { - return; - } - - $('#notification-message').html("

Cancelling...

"); - $('#notification-message').slideDown(); - setTimeout(function() { - window.location.href = snacUrl + "/vocab_administrator"; - }, 1000); - return false; -} - -/** - * New Resource Language - * Copies the resource template DIV on the page and attaches it correctly to the DOM. - * Tracks language index using $('#language-template').data('languageCount') - * - */ -function newResourceLanguage(event) { - event.preventDefault(); - var $newLanguage = $('#resource-language-template').find(".language").clone(); - var data = $('#resource-language-template').data(); - var newLanguageID = 'language_' + data.languageCount; - $newLanguage.attr('id', newLanguageID); - $newLanguage.find('.operation').val('insert'); - $newLanguage.addClass('new-language'); - - //update input names with new data.languageCount - $newLanguage.find('input, select').attr('name', function(i, name) { - return name.replace('YY', data.languageCount); - }); - - console.log('Adding new resource language with id: ', newLanguageID); - $newLanguage.toggle(); - // selects last to avoid conflict on multiple clones - $('.add-resource-language:last').before($newLanguage); - enableLanguageSelect($newLanguage); - - data.languageCount++; - return $newLanguage; -} - -/** - * Delete or Undo Language - * - * Toggles component-deleted class, and btn classes for delete and undo. - * Does not change operations. - * - */ -function deleteOrUndoLanguage(event) { - event.preventDefault(); - var $btn = $(event.currentTarget); - $btn.toggleClass('btn-danger btn-warning'); - $btn.find(':only-child').toggleClass('fa-minus-circle fa-undo'); - var $language = $btn.closest('.language'); - $language.toggleClass('alert-danger component-deleted'); -} - - -function setOperations($elements, operation) { - $elements.find('.operation').each(function() { - $(this).val(operation); - }); -} - -/** - * Mark Edited Resource Fields - * - * Adds edited-field class to altered inputs. Sets altered resource language to update. - * @param jqueryObject $resourceForm jQuery object to modify - * - */ -function markEditedResourceFields($resourceForm) { - $resourceForm.find("input, select, textarea").on("change", function(e) { - $(e.target).addClass('edited-field'); - - if ($(e.target).closest('.language').length) { - setOperations($(e.target).closest('.language'), "update"); - } - }); -} - -function enableVocabularySelect(selectItem, type) { - selectItem.select2({ - ajax: { - url: snacUrl + "/vocabulary?type=" + type, - dataType: 'json', - delay: 250, - data: function(params) { - return { - q: params.term, - page: params.page - }; - }, - processResults: function(data, page) { - return { - results: data.results - }; - }, - cache: true - }, - width: '100%', - minimumInputLength: 0, - allowClear: true, - theme: 'bootstrap', - placeholder: 'Select' - }); -} - -function enableLanguageSelect($language) { - enableVocabularySelect($language.find("select:first"), 'language_code'); - enableVocabularySelect($language.find("select:last"), 'script_code'); -} - - -function magicNewResourceLanguage(event) { - var $newLanguage = newResourceLanguage(event); - var defaultLanguage = new Option(defaults.language.term, defaults.language.id, false, true); - var defaultScript = new Option(defaults.script.term, defaults.script.id, false, true); - $newLanguage.find("select:first").append(defaultLanguage).trigger('change'); - $newLanguage.find("select:last").append(defaultScript).trigger('change'); -} - -function selectHoldingRepository(event) { - event.preventDefault(); - var name = event.target.innerHTML; - var id = event.target.href.split('/').pop(); - var selectedRepo = new Option(name, id, false, true); - $(".resource-repo:last").append(selectedRepo).trigger('change'); - $("#search_form").slideToggle(); - $("#search-results-box").html(""); - $("#searchbox").val(""); -} +!function(n){var e={};function g(l){if(e[l])return e[l].exports;var t=e[l]={i:l,l:!1,exports:{}};return n[l].call(t.exports,t,t.exports,g),t.l=!0,t.exports}g.m=n,g.c=e,g.d=function(n,e,l){g.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:l})},g.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},g.t=function(n,e){if(1&e&&(n=g(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var l=Object.create(null);if(g.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var t in n)g.d(l,t,function(e){return n[e]}.bind(null,t));return l},g.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return g.d(e,"a",e),e},g.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},g.p="",g(g.s=0)}([function(module,exports){eval("/**\n * Resource Admin Actions\n *\n * Contains code that handles Resource creation and editing\n *\n * @author Joseph Glass\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\nfunction saveResource(event) {\n event.preventDefault();\n var $form = $(event.target);\n\n if ($form.find(\"#resource-url\").val() == \"\") {\n if (!confirm('Are you sure you want to save without an HREF?')) {\n return;\n }\n }\n $('#notification-message').slideDown().html(\"

Saving Resource... Please wait.

\");\n\n // Remove leading and trailing whitespace\n $form.find(\"input, textarea\").each(function () {\n $(this).val($.trim($(this).val()));\n });\n\n setDeletedResourceLanguageOperations($form);\n\n $.post(snacUrl + \"/save_resource\", $form.serialize()).done(function (data) {\n createdResource = data;\n if (typeof data.resource === 'undefined') {\n $('#error-message').slideDown();\n return false;\n }\n $('#notification-message').slideUp();\n $('#success-message').slideDown();\n setTimeout(function () {\n window.location = snacUrl + \"/vocab_administrator/resources/\" + data.resource.id;\n }, 1000);\n }).fail(function () {\n $('#error-message').slideDown();\n });\n return false;\n}\n\nfunction setDeletedResourceLanguageOperations($form) {\n // Set deleted new languages to null, set deleted existing languages to delete\n var $deletedLanguages = $form.find(\"#resource-languages .component-deleted\").has('input[id]');\n var $ignoredLanguages = $form.find(\"#resource-languages .component-deleted.new-language\");\n setOperations($deletedLanguages, \"delete\");\n setOperations($ignoredLanguages, \"\");\n}\n\nfunction cancelResource() {\n if (!confirm('Are you sure you want to cancel?')) {\n return;\n }\n\n $('#notification-message').html(\"

Cancelling...

\");\n $('#notification-message').slideDown();\n setTimeout(function () {\n window.location.href = snacUrl + \"/vocab_administrator\";\n }, 1000);\n return false;\n}\n\n/**\n * New Resource Language\n * Copies the resource template DIV on the page and attaches it correctly to the DOM.\n * Tracks language index using $('#language-template').data('languageCount')\n *\n */\nfunction newResourceLanguage(event) {\n event.preventDefault();\n var $newLanguage = $('#resource-language-template').find(\".language\").clone();\n var data = $('#resource-language-template').data();\n var newLanguageID = 'language_' + data.languageCount;\n $newLanguage.attr('id', newLanguageID);\n $newLanguage.find('.operation').val('insert');\n $newLanguage.addClass('new-language');\n\n //update input names with new data.languageCount\n $newLanguage.find('input, select').attr('name', function (i, name) {\n return name.replace('YY', data.languageCount);\n });\n\n console.log('Adding new resource language with id: ', newLanguageID);\n $newLanguage.toggle();\n // selects last to avoid conflict on multiple clones\n $('.add-resource-language:last').before($newLanguage);\n enableLanguageSelect($newLanguage);\n\n data.languageCount++;\n return $newLanguage;\n}\n\n/**\n * Delete or Undo Language\n *\n * Toggles component-deleted class, and btn classes for delete and undo.\n * Does not change operations.\n *\n */\nfunction deleteOrUndoLanguage(event) {\n event.preventDefault();\n var $btn = $(event.currentTarget);\n $btn.toggleClass('btn-danger btn-warning');\n $btn.find(':only-child').toggleClass('fa-minus-circle fa-undo');\n var $language = $btn.closest('.language');\n $language.toggleClass('alert-danger component-deleted');\n}\n\nfunction setOperations($elements, operation) {\n $elements.find('.operation').each(function () {\n $(this).val(operation);\n });\n}\n\n/**\n * Mark Edited Resource Fields\n *\n * Adds edited-field class to altered inputs. Sets altered resource language to update.\n * @param jqueryObject $resourceForm jQuery object to modify\n *\n */\nfunction markEditedResourceFields($resourceForm) {\n $resourceForm.find(\"input, select, textarea\").on(\"change\", function (e) {\n $(e.target).addClass('edited-field');\n\n if ($(e.target).closest('.language').length) {\n setOperations($(e.target).closest('.language'), \"update\");\n }\n });\n}\n\nfunction enableVocabularySelect(selectItem, type) {\n selectItem.select2({\n ajax: {\n url: snacUrl + \"/vocabulary?type=\" + type,\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return {\n results: data.results\n };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 0,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n}\n\nfunction enableLanguageSelect($language) {\n enableVocabularySelect($language.find(\"select:first\"), 'language_code');\n enableVocabularySelect($language.find(\"select:last\"), 'script_code');\n}\n\nfunction magicNewResourceLanguage(event) {\n var $newLanguage = newResourceLanguage(event);\n var defaultLanguage = new Option(defaults.language.term, defaults.language.id, false, true);\n var defaultScript = new Option(defaults.script.term, defaults.script.id, false, true);\n $newLanguage.find(\"select:first\").append(defaultLanguage).trigger('change');\n $newLanguage.find(\"select:last\").append(defaultScript).trigger('change');\n}\n\nfunction selectHoldingRepository(event) {\n event.preventDefault();\n var name = event.target.innerHTML;\n var id = event.target.href.split('/').pop();\n var selectedRepo = new Option(name, id, false, true);\n $(\".resource-repo:last\").append(selectedRepo).trigger('change');\n $(\"#search_form\").slideToggle();\n $(\"#search-results-box\").html(\"\");\n $(\"#searchbox\").val(\"\");\n}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zcmMvdmlydHVhbGhvc3RzL3d3dy9qYXZhc2NyaXB0L3NyYy9yZXNvdXJjZV9hZG1pbi5qcz81OTE5Il0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogUmVzb3VyY2UgQWRtaW4gQWN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FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///0\n")}]); \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/select_loaders.js b/src/virtualhosts/www/javascript/select_loaders.js index e01199529..7e73e8400 100644 --- a/src/virtualhosts/www/javascript/select_loaders.js +++ b/src/virtualhosts/www/javascript/select_loaders.js @@ -1,334 +1 @@ -/** - * Select Box Loaders - * - * Functions that can be used to replace select boxes on the edit page with - * pretty-formatted versions using JQuery and Select2 - * - * @author Robbie Hott - * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause - * @copyright 2015 the Rector and Visitors of the University of Virginia, and - * the Regents of the University of California - */ - -/** - * Replace a select that is linked to a Vocabulary search - * - * Replaces the select with a select2 object capable of making AJAX queries - * - * @param JQuery selectItem The JQuery item to replace - * @param string idMatch ID string for the object on the page - * @param string type The type of the vocabulary term - * @param int minLength The minimum required length of the autocomplete search - */ -function vocab_select_replace(selectItem, idMatch, type, minLength) { - if (minLength === undefined) { - minLength = 2; - } - - if(selectItem.attr('id').endsWith(idMatch) - && !selectItem.attr('id').endsWith("ZZ")) { - selectItem.select2({ - ajax: { - url: function() { - var query = snacUrl + "/vocabulary?type="+type+"&id="; - query += $("#constellationid").val()+"&version="+$("#version").val(); - query += "&entity_type="+$("#entityType").val(); - return query; - }, - dataType: 'json', - delay: 250, - data: function (params) { - return { - q: params.term, - page: params.page - }; - }, - processResults: function (data, page) { - return { results: data.results }; - }, - cache: true - }, - width: '100%', - minimumInputLength: minLength, - allowClear: true, - theme: 'bootstrap', - placeholder: 'Select' - }); - } -} - -var geoPlaceSearchResults = null; - -function geovocab_select_replace(selectItem, idMatch) { - var minLength = 2; - - if(selectItem.attr('id').endsWith(idMatch) - && !selectItem.attr('id').endsWith("ZZ")) { - selectItem.select2({ - ajax: { - url: function() { - var query = snacUrl+"/vocabulary?type=geo_place&format=term"; - query += "&entity_type="+$("#entityType").val(); - return query; - }, - dataType: 'json', - delay: 250, - data: function (params) { - return { - q: params.term, - page: params.page - }; - }, - processResults: function (data, page) { - if (data.results) { - geoPlaceSearchResults = data.results; - var selectResults = new Array(); - data.results.forEach(function(result) { - selectResults.push({ - id: result.id, - text: result.name + " (" + result.administrationCode + ", " + result.countryCode+ ")" - }) - }); - return {results: selectResults}; - } - return { results: null }; - }, - cache: true - }, - width: '100%', - minimumInputLength: minLength, - allowClear: true, - theme: 'bootstrap', - placeholder: 'Select' - }); - } -} - -var lastSourceSearchResults = null; - -/** - * Add
helper script - * - * Adds
to strings so that they can be shown to the user in HTML - * after being input into a text-only field. - */ -function addbr(str) { - if (typeof str !== 'undefined' && str !== null) { - return (str + '').replace(/(\r\n|\n\r|\r|\n)/g, '
' + '$1'); - } - return ''; -} - -/** - * Replace a select that is linked to a Constellation Source search - * - * Replaces the select with a select2 object capable of making AJAX queries - * - * @param JQuery selectItem The JQuery item to replace - * @param string idMatch ID string for the object on the page - */ -function scm_source_select_replace(selectItem, idMatch) { - if(selectItem.attr('id').endsWith(idMatch) - && !selectItem.attr('id').endsWith("ZZ")) { - selectItem.select2({ - ajax: { - url: function() { - var query = snacUrl+"/vocabulary?type=ic_sources&id="; - query += $("#constellationid").val()+"&version="+$("#version").val(); - query += "&entity_type="+$("#entityType").val(); - return query; - }, - dataType: 'json', - delay: 250, - data: function (params) { - return { - q: params.term, - page: params.page - }; - }, - processResults: function (data, page) { - // Modify the results to be in the format we want - lastSourceSearchResults = data.results; - // need id, text - var results = new Array(); - data.results.forEach(function(res) { - results.push({id: res.id, text: res.displayName}); - }); - return { results: results }; - }, - cache: true - }, - width: '100%', - minimumInputLength: 0, - allowClear: true, - theme: 'bootstrap', - placeholder: 'Select' - }); - - selectItem.on('change', function (evt) { - // TODO: Get the current selected value and update the well in the page to reflect it! - // Note: all the selections are available in the global lastSourceSearchResults variable. - var sourceID = $(this).val(); - var inPageID = $(this).attr("id"); - var idArray = inPageID.split("_"); - if (idArray.length >= 6) { - var i = idArray[5]; - var j = idArray[4]; - var shortName = idArray[1]; - lastSourceSearchResults.forEach(function(source) { - if (source.id == sourceID) { - // Update the text of the source - if (typeof source.text !== 'undefined') { - $("#scm_" + shortName + "_source_text_" + j + "_" + i).html(addbr(source.text)).removeClass('hidden'); - $("#scm_" + shortName + "_source_text_" + j + "_" + i).closest(".panel-body").removeClass('hidden'); - } else { - $("#scm_" + shortName + "_source_text_" + j + "_" + i).text("").addClass('hidden'); - $("#scm_" + shortName + "_source_text_" + j + "_" + i).closest(".panel-body").addClass('hidden'); - - } - // Update the URI of the source - if (typeof source.uri !== 'undefined') - $("#scm_" + shortName + "_source_uri_" + j + "_" + i).html(''+source.uri+''); - else - $("#scm_" + shortName + "_source_uri_" + j + "_" + i).html(''); - // Update the URI of the source - if (typeof source.citation !== 'undefined') - $("#scm_" + shortName + "_source_citation_" + j + "_" + i).html(source.citation).removeClass('hidden'); - else - $("#scm_" + shortName + "_source_citation_" + j + "_" + i).html('').addClass('hidden'); - } - }); - } - }); - - } -} - -/** - * Replace a select that is linked to an affiliation search - * - * Replaces the select with a select2 object capable of making AJAX queries - * - * @param JQuery selectItem The JQuery item to replace - */ -function affiliation_select_replace(selectItem) { - $.get(snacUrl + "/vocabulary?type=affiliation").done(function(data) { - var options = data.results; - selectItem.select2({ - data: options, - allowClear: true, - theme: "bootstrap", - placeholder: "Select Affiliation" - }); - }); -} - -function reviewer_select_replace(selectItem) { - if(selectItem != null) { - selectItem.select2({ - placeholder: "Reviewer Name or Email...", - ajax: { - url: function() { - var query = snacUrl+"/user_search?role=Reviewer"; - return query; - }, - dataType: 'json', - delay: 250, - data: function (params) { - return { - q: params.term, - page: params.page - }; - }, - processResults: function (data, page) { - return { results: data.results }; - }, - cache: true - }, - width: '100%', - minimumInputLength: 1, - allowClear: false, - theme: 'bootstrap' - }); - } -} - -function select_replace(selectItem, idMatch) { - if(selectItem.attr('id').endsWith(idMatch) - && !selectItem.attr('id').endsWith("ZZ")) { - selectItem.select2({ - allowClear: true, - theme: 'bootstrap' - }); - } -} - -function select_replace_simple(selectItem) { - selectItem.select2({ - width: '100%', - allowClear: true, - theme: 'bootstrap' - }); -} - - - -/** - * Load Vocab Select Options - * - * Replaces the select with a select2 object preloaded with an array of options - * - * @param JQuery selectItem The JQuery item to replace - * @param string type The type of the vocabulary term - * @param string type Text placeholder for select - */ -function loadVocabSelectOptions(selectItem, type, placeholder) { - return $.get(snacUrl + "/vocabulary?type=" + type) - .done(function(data) { - var options = data.results; - selectItem.select2({ - data: options, - allowClear: false, - theme: 'bootstrap', - placeholder: placeholder - }); - }); -} - -/** - * Replace all the selects that exist on the page when the page has finished loading - */ -$(document).ready(function() { - - // Use select2 to display the select dropdowns - // rather than the HTML default - $("select").each(function() { - if (typeof $(this).attr('id') !== typeof undefined && $(this).attr('id') !== false) { - // Replace the subject selects - vocab_select_replace($(this), "language_language_", "language_code", 1); - - // Replace the subject selects - vocab_select_replace($(this), "language_script_", "script_code", 1); - - // Replace the subject selects - vocab_select_replace($(this), "subject_", "subject", 4); - - // Replace the function selects - vocab_select_replace($(this), "function_", "function", 4); - - // Replace the occupation selects - vocab_select_replace($(this), "occupation_", "occupation", 4); - - // Replace the entityType select - vocab_select_replace($(this), "entityType", "entity_type", 0); - } - }); - - // Replace the Affiliation dropdowns, if one exists - if ($("#affiliationid").exists()) - affiliation_select_replace($("#affiliationid")); - - // Replace the User search dropdown, if one exists - if ($("#reviewersearchbox").exists()) - reviewer_select_replace($("#reviewersearchbox")); -}); +!function(I){var g={};function C(A){if(g[A])return g[A].exports;var e=g[A]={i:A,l:!1,exports:{}};return I[A].call(e.exports,e,e.exports,C),e.l=!0,e.exports}C.m=I,C.c=g,C.d=function(I,g,A){C.o(I,g)||Object.defineProperty(I,g,{enumerable:!0,get:A})},C.r=function(I){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(I,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(I,"__esModule",{value:!0})},C.t=function(I,g){if(1&g&&(I=C(I)),8&g)return I;if(4&g&&"object"==typeof I&&I&&I.__esModule)return I;var A=Object.create(null);if(C.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:I}),2&g&&"string"!=typeof I)for(var e in I)C.d(A,e,function(g){return I[g]}.bind(null,e));return A},C.n=function(I){var g=I&&I.__esModule?function(){return I.default}:function(){return I};return C.d(g,"a",g),g},C.o=function(I,g){return Object.prototype.hasOwnProperty.call(I,g)},C.p="",C(C.s=1)}([,function(module,exports){eval('/**\n * Select Box Loaders\n *\n * Functions that can be used to replace select boxes on the edit page with\n * pretty-formatted versions using JQuery and Select2\n *\n * @author Robbie Hott\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\n/**\n * Replace a select that is linked to a Vocabulary search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n * @param string type The type of the vocabulary term\n * @param int minLength The minimum required length of the autocomplete search\n */\nfunction vocab_select_replace(selectItem, idMatch, type, minLength) {\n if (minLength === undefined) {\n minLength = 2;\n }\n\n if (selectItem.attr(\'id\').endsWith(idMatch) && !selectItem.attr(\'id\').endsWith("ZZ")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + "/vocabulary?type=" + type + "&id=";\n query += $("#constellationid").val() + "&version=" + $("#version").val();\n query += "&entity_type=" + $("#entityType").val();\n return query;\n },\n dataType: \'json\',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: \'100%\',\n minimumInputLength: minLength,\n allowClear: true,\n theme: \'bootstrap\',\n placeholder: \'Select\'\n });\n }\n}\n\nvar geoPlaceSearchResults = null;\n\nfunction geovocab_select_replace(selectItem, idMatch) {\n var minLength = 2;\n\n if (selectItem.attr(\'id\').endsWith(idMatch) && !selectItem.attr(\'id\').endsWith("ZZ")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + "/vocabulary?type=geo_place&format=term";\n query += "&entity_type=" + $("#entityType").val();\n return query;\n },\n dataType: \'json\',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n if (data.results) {\n geoPlaceSearchResults = data.results;\n var selectResults = new Array();\n data.results.forEach(function (result) {\n selectResults.push({\n id: result.id,\n text: result.name + " (" + result.administrationCode + ", " + result.countryCode + ")"\n });\n });\n return { results: selectResults };\n }\n return { results: null };\n },\n cache: true\n },\n width: \'100%\',\n minimumInputLength: minLength,\n allowClear: true,\n theme: \'bootstrap\',\n placeholder: \'Select\'\n });\n }\n}\n\nvar lastSourceSearchResults = null;\n\n/**\n * Add
helper script\n *\n * Adds
to strings so that they can be shown to the user in HTML\n * after being input into a text-only field.\n */\nfunction addbr(str) {\n if (typeof str !== \'undefined\' && str !== null) {\n return (str + \'\').replace(/(\\r\\n|\\n\\r|\\r|\\n)/g, \'
\' + \'$1\');\n }\n return \'\';\n}\n\n/**\n * Replace a select that is linked to a Constellation Source search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n */\nfunction scm_source_select_replace(selectItem, idMatch) {\n if (selectItem.attr(\'id\').endsWith(idMatch) && !selectItem.attr(\'id\').endsWith("ZZ")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + "/vocabulary?type=ic_sources&id=";\n query += $("#constellationid").val() + "&version=" + $("#version").val();\n query += "&entity_type=" + $("#entityType").val();\n return query;\n },\n dataType: \'json\',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n // Modify the results to be in the format we want\n lastSourceSearchResults = data.results;\n // need id, text\n var results = new Array();\n data.results.forEach(function (res) {\n results.push({ id: res.id, text: res.displayName });\n });\n return { results: results };\n },\n cache: true\n },\n width: \'100%\',\n minimumInputLength: 0,\n allowClear: true,\n theme: \'bootstrap\',\n placeholder: \'Select\'\n });\n\n selectItem.on(\'change\', function (evt) {\n // TODO: Get the current selected value and update the well in the page to reflect it!\n // Note: all the selections are available in the global lastSourceSearchResults variable.\n var sourceID = $(this).val();\n var inPageID = $(this).attr("id");\n var idArray = inPageID.split("_");\n if (idArray.length >= 6) {\n var i = idArray[5];\n var j = idArray[4];\n var shortName = idArray[1];\n lastSourceSearchResults.forEach(function (source) {\n if (source.id == sourceID) {\n // Update the text of the source\n if (typeof source.text !== \'undefined\') {\n $("#scm_" + shortName + "_source_text_" + j + "_" + i).html(addbr(source.text)).removeClass(\'hidden\');\n $("#scm_" + shortName + "_source_text_" + j + "_" + i).closest(".panel-body").removeClass(\'hidden\');\n } else {\n $("#scm_" + shortName + "_source_text_" + j + "_" + i).text("").addClass(\'hidden\');\n $("#scm_" + shortName + "_source_text_" + j + "_" + i).closest(".panel-body").addClass(\'hidden\');\n }\n // Update the URI of the source\n if (typeof source.uri !== \'undefined\') $("#scm_" + shortName + "_source_uri_" + j + "_" + i).html(\'\' + source.uri + \'\');else $("#scm_" + shortName + "_source_uri_" + j + "_" + i).html(\'\');\n // Update the URI of the source\n if (typeof source.citation !== \'undefined\') $("#scm_" + shortName + "_source_citation_" + j + "_" + i).html(source.citation).removeClass(\'hidden\');else $("#scm_" + shortName + "_source_citation_" + j + "_" + i).html(\'\').addClass(\'hidden\');\n }\n });\n }\n });\n }\n}\n\n/**\n * Replace a select that is linked to an affiliation search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n */\nfunction affiliation_select_replace(selectItem) {\n $.get(snacUrl + "/vocabulary?type=affiliation").done(function (data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: true,\n theme: "bootstrap",\n placeholder: "Select Affiliation"\n });\n });\n}\n\nfunction reviewer_select_replace(selectItem) {\n if (selectItem != null) {\n selectItem.select2({\n placeholder: "Reviewer Name or Email...",\n ajax: {\n url: function () {\n var query = snacUrl + "/user_search?role=Reviewer";\n return query;\n },\n dataType: \'json\',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: \'100%\',\n minimumInputLength: 1,\n allowClear: false,\n theme: \'bootstrap\'\n });\n }\n}\n\nfunction select_replace(selectItem, idMatch) {\n if (selectItem.attr(\'id\').endsWith(idMatch) && !selectItem.attr(\'id\').endsWith("ZZ")) {\n selectItem.select2({\n allowClear: true,\n theme: \'bootstrap\'\n });\n }\n}\n\nfunction select_replace_simple(selectItem) {\n selectItem.select2({\n width: \'100%\',\n allowClear: true,\n theme: \'bootstrap\'\n });\n}\n\nfunction sayHi(user) {\n return `Hello, ${user}!`;\n}\n\nfunction sayBye(user) {\n return `Bye bye, ${user}!`;\n}\n\n/**\n * Load Vocab Select Options\n *\n * Replaces the select with a select2 object preloaded with an array of options\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string type The type of the vocabulary term\n * @param string type Text placeholder for select\n */\nfunction loadVocabSelectOptions(selectItem, type, placeholder) {\n return $.get(snacUrl + "/vocabulary?type=" + type).done(function (data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: false,\n theme: \'bootstrap\',\n placeholder: placeholder\n });\n });\n}\n\n/**\n * Replace all the selects that exist on the page when the page has finished loading\n */\n$(document).ready(function () {\n\n // Use select2 to display the select dropdowns\n // rather than the HTML default\n $("select").each(function () {\n if (typeof $(this).attr(\'id\') !== typeof undefined && $(this).attr(\'id\') !== false) {\n // Replace the subject selects\n vocab_select_replace($(this), "language_language_", "language_code", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), "language_script_", "script_code", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), "subject_", "subject", 4);\n\n // Replace the function selects\n vocab_select_replace($(this), "function_", "function", 4);\n\n // Replace the occupation selects\n vocab_select_replace($(this), "occupation_", "occupation", 4);\n\n // Replace the entityType select\n vocab_select_replace($(this), "entityType", "entity_type", 0);\n }\n });\n\n // Replace the Affiliation dropdowns, if one exists\n if ($("#affiliationid").exists()) affiliation_select_replace($("#affiliationid"));\n\n // Replace the User search dropdown, if one exists\n if ($("#reviewersearchbox").exists()) reviewer_select_replace($("#reviewersearchbox"));\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zcmMvdmlydHVhbGhvc3RzL3d3dy9qYXZhc2NyaXB0L3NyYy9zZWxlY3RfbG9hZGVycy5qcz8zOGJlIl0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogU2VsZWN0IEJveCBMb2FkZXJzXG4gKlxuICogRnVuY3Rpb25zIHRoYXQgY2FuIGJlIHVzZWQgdG8gcmVwbGFjZSBzZWxlY3QgYm94ZXMgb24gdGhlIGVkaXQgcGFnZSB3aXRoXG4gKiBwcmV0dHktZm9ybWF0dGVkIHZlcnNpb25zIHVzaW5nIEpRdWVyeSBhbmQgU2VsZWN0MlxuICpcbiAqIEBhdXRob3IgUm9iYmllIEhvdHRcbiAqIEBsaWNlbnNlIGh0dHBzOi8vb3BlbnNvdXJjZS5vcmcvbGljZW5zZXMvQlNELTMtQ2xhdXNlIEJTRCAzLUNsYXVzZVxuICogQGNvcHlyaWdodCAyMDE1IHRoZSBSZWN0b3IgYW5kIFZpc2l0b3JzIG9mIHRoZSBVbml2ZXJzaXR5IG9mIFZpcmdpbmlhLCBhbmRcbiAqICAgICAgICAgICAgdGhlIFJlZ2VudHMgb2YgdGhlIFVuaXZlcnNpdHkgb2YgQ2FsaWZvcm5pYVxuICovXG5cbi8qKlxuICogUmVwbGFjZSBhIHNlbGVjdCB0aGF0IGlzIGxpbmtlZCB0byBhIFZ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CImaWQ9XCI7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJ5ICs9ICQoXCIjY29uc3RlbGxhdGlvbmlkXCIpLnZhbCgpK1wiJnZlcnNpb249XCIrJChcIiN2ZXJzaW9uXCIpLnZhbCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeSArPSBcIiZlbnRpdHlfdHlwZT1cIiskKFwiI2VudGl0eVR5cGVcIikudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBxdWVyeTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb24nLFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVsYXk6IDI1MCxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IGZ1bmN0aW9uIChwYXJhbXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxOiBwYXJhbXMudGVybSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb2Nlc3NSZXN1bHRzOiBmdW5jdGlvbiAoZGF0YSwgcGFnZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7IHJlc3VsdHM6IGRhdGEucmVzdWx0cyB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIHdpZHRoOiAnMTAwJScsXG4gICAgICAgICAgICAgICAgICAgIG1pbmltdW1JbnB1dExlbmd0aDogbWluTGVuZ3RoLFxuICAgICAgICAgICAgICAgICAgICBhbGxvd0NsZWFyOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB0aGVtZTogJ2Jvb3RzdHJhcCcsXG4gICAgICAgICAgICAgICAgICAgIHBsYWNlaG9sZGVyOiAnU2VsZWN0J1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxufVxuXG52YXIgZ2VvUGxhY2VTZWFyY2hSZXN1bHRzID0gbnVsbDtcblxuZnVuY3Rpb24gZ2Vvdm9jYWJfc2VsZWN0X3JlcGxhY2Uoc2VsZWN0SXRlbSwgaWRNYXRjaCkge1xuICAgIHZhciBtaW5MZW5ndGggPSAyO1xuXG4gICAgaWYoc2VsZWN0SXRlbS5hdHRyKCdpZCcpLmVuZHNXaXRoKGlkTWF0Y2gpXG4gICAgICAgICYmICFzZWxlY3RJdGVtLmF0dHIoJ2lkJykuZW5kc1dpdGgoXCJaWlwiKSkge1xuICAgICAgICAgICAgc2VsZWN0SXRlbS5zZWxlY3QyKHtcbiAgICAgICAgICAgICAgICBhamF4OiB7XG4gICAgICAgICAgICAgICAgICAgIHVybDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcXVlcnkgPSBzbmFjVXJsK1wiL3ZvY2FidWxhcnk/dHlwZT1nZW9fcGxhY2UmZm9ybWF0PXRlcm1cIjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeSArPSBcIiZlbnRpdHlfdHlwZT1cIiskKFwiI2VudGl0eVR5cGVcIikudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHF1ZXJ5O1xuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb24nLFxuICAgICAgICAgICAgICAgICAgICBkZWxheTogMjUwLFxuICAgICAgICAgICAgICAgICAgICBkYXRhOiBmdW5jdGlvbiAocGFyYW1zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHE6IHBhcmFtcy50ZXJtLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhcmFtcy5wYWdlXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBwcm9jZXNzUmVzdWx0czogZnVuY3Rpb24gKGRhdGEsIHBhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnJlc3VsdHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZW9QbGFjZVNlYXJjaFJlc3VsdHMgPSBkYXRhLnJlc3VsdHM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNlbGVjdFJlc3VsdHMgPSBuZXcgQXJyYXkoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnJlc3VsdHMuZm9yRWFjaChmdW5jdGlvbihyZXN1bHQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0UmVzdWx0cy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiByZXN1bHQuaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0OiByZXN1bHQubmFtZSArIFwiIChcIiArIHJlc3VsdC5hZG1pbmlzdHJhdGlvbkNvZGUgKyBcIiwgXCIgKyByZXN1bHQuY291bnRyeUNvZGUrIFwiKVwiXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtyZXN1bHRzOiBzZWxlY3RSZXN1bHRzfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgIC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Y3QgY2FwYWJsZSBvZiBtYWtpbmcgQUpBWCBxdWVyaWVzXG4gKlxuICogQHBhcmFtICBKUXVlcnkgc2VsZWN0SXRlbSBUaGUgSlF1ZXJ5IGl0ZW0gdG8gcmVwbGFjZVxuICogQHBhcmFtICBzdHJpbmcgaWRNYXRjaCAgICBJRCBzdHJpbmcgZm9yIHRoZSBvYmplY3Qgb24gdGhlIHBhZ2VcbiAqL1xuZnVuY3Rpb24gc2NtX3NvdXJjZV9zZWxlY3RfcmVwbGFjZShzZWxlY3RJdGVtLCBpZE1hdGNoKSB7XG4gICAgICAgIGlmKHNlbGVjdEl0ZW0uYXR0cignaWQnKS5lbmRzV2l0aChpZE1hdGNoKVxuICAgICAgICAgICAgJiYgIXNlbGVjdEl0ZW0uYXR0cignaWQnKS5lbmRzV2l0aChcIlpaXCIpKSB7XG4gICAgICAgICAgICAgICAgc2VsZWN0SXRlbS5zZWxlY3QyKHtcbiAgICAgICAgICAgICAgICAgICAgYWpheDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcXVlcnkgPSBzbmFjVXJsK1wiL3ZvY2FidWxhcnk/dHlwZT1pY19zb3VyY2VzJmlkPVwiO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeSArPSAkKFwiI2NvbnN0ZWxsYXRpb25pZFwiKS52YWwoKStcIiZ2ZXJzaW9uPVwiKyQoXCIjdmVyc2lvblwiKS52YWwoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVlcnkgKz0gXCImZW50aXR5X3R5cGU9XCIrJChcIiNlbnRpdHlUeXBlXCIpLnZhbCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcXVlcnk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVR5cGU6ICdqc29uJyxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGF5OiAyNTAsXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhOiBmdW5jdGlvbiAocGFyYW1zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcTogcGFyYW1zLnRlcm0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhcmFtcy5wYWdlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzUmVzdWx0czogZnVuY3Rpb24gKGRhdGEsIHBhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBNb2RpZnkgdGhlIHJlc3VsdHMgdG8gYmUgaW4gdGhlIGZvcm1hdCB3ZSB3YW50XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFNvdXJjZVNlYXJjaFJlc3VsdHMgPSBkYXRhLnJlc3VsdHM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gbmVlZCBpZCwgdGV4dFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHRzID0gbmV3IEFycmF5KCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS5yZXN1bHRzLmZvckVhY2goZnVuY3Rpb24ocmVzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHMucHVzaCh7aWQ6IHJlcy5pZCwgdGV4dDogcmVzLmRpc3BsYXlOYW1lfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsgcmVzdWx0czogcmVzdWx0cyB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIHdpZHRoOiAnMTAwJScsXG4gICAgICAgICAgICAgICAgICAgIG1pbmltdW1JbnB1dExlbmd0aDogMCxcbiAgICAgICAgICAgICAgICAgICAgYWxsb3dDbGVhcjogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgdGhlbWU6ICdib290c3RyYXAnLFxuICAgICAgICAgICAgICAgICAgICBwbGFjZWhvbGRlcjogJ1NlbGVjdCdcbiAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgc2VsZWN0SXRlbS5vbignY2hhbmdlJywgZnVuY3Rpb24gKGV2dCkge1xuICAgICAgICAgICAgICAgIC8vIFRPRE86IEdldCB0aGUgY3VycmVudCBzZWxlY3RlZCB2YWx1ZSBhbmQgdXBkYXRlIHRoZSB3ZWxsIGluIHRoZSBwYWdlIHRvIHJlZmxlY3QgaXQhXG4gICAgICAgICAgICAgICAgLy8gTm90ZTogYWxsIHRoZSBzZWxlY3Rpb25zIGFyZSBhdmFpbGFibGUgaW4gdGhlIGdsb2JhbCBsYXN0U291cmNlU2VhcmNoUmVzdWx0cyB2YXJpYWJsZS5cbiAgICAgICAgICAgICAgICB2YXIgc291cmNlSUQgPSAkKHRoaXMpLnZhbCgpO1xuICAgICAgICAgICAgICAgIHZhciBpblBhZ2VJRCA9ICQodGhpcykuYXR0cihcImlkXCIpO1xuICAgICAgICAgICAgICAgIHZhciBpZEFycmF5ID0gaW5QYWdlSUQuc3BsaXQoXCJfXCIpO1xuICAgICAgICAgICAgICAgIGlmIChpZEFycmF5Lmxlbmd0aCA+PSA2KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpID0gaWRBcnJheVs1XTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGogPSBpZEFycmF5WzRdO1xuICAgICAgICAgICAgICAgICAgICB2YXIgc2hvcnROYW1lID0gaWRBcnJheVsxXTtcbiAgICAgICAgICAgICAgICAgICAgbGFzdFNvdXJjZVNlYXJjaFJlc3VsdHMuZm9yRWFjaChmdW5jdGlvbihzb3VyY2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzb3VyY2UuaWQgPT0gc291cmNlSUQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBVcGRhdGUgdGhlIHRleHQgb2YgdGhlIHNvdXJjZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc291cmNlLnRleHQgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjc2NtX1wiICsgc2hvcnROYW1lICsgXCJfc291cmNlX3RleHRfXCIgKyBqICsgXCJfXCIgKyBpKS5odG1sKGFkZGJyKHNvdXJjZS50ZXh0KSkucmVtb3ZlQ2xhc3MoJ2hpZGRlbicpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV90ZXh0X1wiICsgaiArIFwiX1wiICsgaSkuY2xvc2VzdChcIi5wYW5lbC1ib2R5XCIpLnJlbW92ZUNsYXNzKCdoaWRkZW4nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV90ZXh0X1wiICsgaiArIFwiX1wiICsgaSkudGV4dChcIlwiKS5hZGRDbGFzcygnaGlkZGVuJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjc2NtX1wiICsgc2hvcnROYW1lICsgXCJfc291cmNlX3RleHRfXCIgKyBqICsgXCJfXCIgKyBpKS5jbG9zZXN0KFwiLnBhbmVsLWJvZHlcIikuYWRkQ2xhc3MoJ2hpZGRlbicpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFVwZGF0ZSB0aGUgVVJJIG9mIHRoZSBzb3VyY2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZS51cmkgIT09ICd1bmRlZmluZWQnKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV91cmlfXCIgKyBqICsgXCJfXCIgKyBpKS5odG1sKCc8YSBocmVmPVwiJytzb3VyY2UudXJpKydcIiB0YXJnZXQ9XCJfYmxhbmtcIj4nK3NvdXJjZS51cmkrJzwvYT4nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjc2NtX1wiICsgc2hvcnROYW1lICsgXCJfc291cmNlX3VyaV9cIiArIGogKyBcIl9cIiArIGkpLmh0bWwoJycpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFVwZGF0ZSB0aGUgVVJJIG9mIHRoZSBzb3VyY2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZS5jaXRhdGlvbiAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjc2NtX1wiICsgc2hvcnROYW1lICsgXCJfc291cmNlX2NpdGF0aW9uX1wiICsgaiArIFwiX1wiICsgaSkuaHRtbChzb3VyY2UuY2l0YXRpb24pLnJlbW92ZUNsYXNzKCdoaWRkZW4nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjc2NtX1wiICsgc2hvcnROYW1lICsgXCJfc291cmNlX2NpdGF0aW9uX1wiICsgaiArIFwiX1wiICsgaSkuaHRtbCgnJykuYWRkQ2xhc3MoJ2hpZGRlbicp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WhvbGRlcjogXCJSZXZpZXdlciBOYW1lIG9yIEVtYWlsLi4uXCIsXG4gICAgICAgICAgICAgICAgICAgIGFqYXg6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHF1ZXJ5ID0gc25hY1VybCtcIi91c2VyX3NlYXJjaD9yb2xlPVJldmlld2VyXCI7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBxdWVyeTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb24nLFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVsYXk6IDI1MCxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IGZ1bmN0aW9uIChwYXJhbXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxOiBwYXJhbXMudGVybSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb2Nlc3NSZXN1bHRzOiBmdW5jdGlvbiAoZGF0YSwgcGFnZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7IHJlc3VsdHM6IGRhdGEucmVzdWx0cyB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIHdpZHRoOiAnMTAwJScsXG4gICAgICAgICAgICAgICAgICAgIG1pbmltdW1JbnB1dExlbmd0aDogMSxcbiAgICAgICAgICA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BQUNBO0FBQ0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUNBO0FBRkE7QUFJQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBSEE7QUFLQTtBQUNBO0FBR0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOzs7Ozs7Ozs7QUFTQTtBQUNBO0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBSkE7QUFNQTtBQUNBO0FBQ0E7QUFDQTs7O0FBR0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFFQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1\n')}]); \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/src/main.js b/src/virtualhosts/www/javascript/src/main.js new file mode 100644 index 000000000..3443931fd --- /dev/null +++ b/src/virtualhosts/www/javascript/src/main.js @@ -0,0 +1,12 @@ +import { loadVocabSelectOptions, vocab_select_replace } from "./select_loaders.js"; +import { enableLanguageSelect, markEditedResourceFields, newResourceLanguage, cancelResource, saveResource, selectHoldingRepository, magicNewResourceLanguage } from "./resource_admin.js"; + +window.loadVocabSelectOptions = loadVocabSelectOptions; +window.vocab_select_replace = vocab_select_replace; +window.enableLanguageSelect = enableLanguageSelect; +window.markEditedResourceFields = markEditedResourceFields; +window.newResourceLanguage = newResourceLanguage; +window.cancelResource = cancelResource; +window.saveResource = saveResource; +window.selectHoldingRepository = selectHoldingRepository; +window.magicNewResourceLanguage = magicNewResourceLanguage; diff --git a/src/virtualhosts/www/javascript/src/resource_admin.js b/src/virtualhosts/www/javascript/src/resource_admin.js new file mode 100644 index 000000000..27a28e900 --- /dev/null +++ b/src/virtualhosts/www/javascript/src/resource_admin.js @@ -0,0 +1,191 @@ +/** + * Resource Admin Actions + * + * Contains code that handles Resource creation and editing + * + * @author Joseph Glass + * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause + * @copyright 2015 the Rector and Visitors of the University of Virginia, and + * the Regents of the University of California + */ + +function saveResource(event) { + event.preventDefault(); + var $form = $(event.target); + + if ($form.find("#resource-url").val() == "") { + if (!confirm('Are you sure you want to save without an HREF?')) { + return; + } + } + $('#notification-message').slideDown().html("

Saving Resource... Please wait.

"); + + // Remove leading and trailing whitespace + $form.find("input, textarea").each(function() { + $(this).val($.trim($(this).val())); + }); + + setDeletedResourceLanguageOperations($form); + + $.post(snacUrl + "/save_resource", $form.serialize()) + .done(function(data) { + createdResource = data; + if (typeof(data.resource) === 'undefined') { + $('#error-message').slideDown(); + return false; + } + $('#notification-message').slideUp(); + $('#success-message').slideDown(); + setTimeout(function() { + window.location = (snacUrl + "/vocab_administrator/resources/" + data.resource.id); + }, 1000); + }) + .fail(function() { + $('#error-message').slideDown(); + }); + return false; +} + + +function setDeletedResourceLanguageOperations($form) { + // Set deleted new languages to null, set deleted existing languages to delete + var $deletedLanguages = $form.find("#resource-languages .component-deleted").has('input[id]'); + var $ignoredLanguages = $form.find("#resource-languages .component-deleted.new-language"); + setOperations($deletedLanguages, "delete"); + setOperations($ignoredLanguages, ""); +} + +function cancelResource() { + if (!confirm('Are you sure you want to cancel?')) { + return; + } + + $('#notification-message').html("

Cancelling...

"); + $('#notification-message').slideDown(); + setTimeout(function() { + window.location.href = snacUrl + "/vocab_administrator"; + }, 1000); + return false; +} + +/** + * New Resource Language + * Copies the resource template DIV on the page and attaches it correctly to the DOM. + * Tracks language index using $('#language-template').data('languageCount') + * + */ +function newResourceLanguage(event) { + event.preventDefault(); + var $newLanguage = $('#resource-language-template').find(".language").clone(); + var data = $('#resource-language-template').data(); + var newLanguageID = 'language_' + data.languageCount; + $newLanguage.attr('id', newLanguageID); + $newLanguage.find('.operation').val('insert'); + $newLanguage.addClass('new-language'); + + //update input names with new data.languageCount + $newLanguage.find('input, select').attr('name', function(i, name) { + return name.replace('YY', data.languageCount); + }); + + console.log('Adding new resource language with id: ', newLanguageID); + $newLanguage.toggle(); + // selects last to avoid conflict on multiple clones + $('.add-resource-language:last').before($newLanguage); + enableLanguageSelect($newLanguage); + + data.languageCount++; + return $newLanguage; +} + +/** + * Delete or Undo Language + * + * Toggles component-deleted class, and btn classes for delete and undo. + * Does not change operations. + * + */ +function deleteOrUndoLanguage(event) { + event.preventDefault(); + var $btn = $(event.currentTarget); + $btn.toggleClass('btn-danger btn-warning'); + $btn.find(':only-child').toggleClass('fa-minus-circle fa-undo'); + var $language = $btn.closest('.language'); + $language.toggleClass('alert-danger component-deleted'); +} + + +function setOperations($elements, operation) { + $elements.find('.operation').each(function() { + $(this).val(operation); + }); +} + +/** + * Mark Edited Resource Fields + * + * Adds edited-field class to altered inputs. Sets altered resource language to update. + * @param jqueryObject $resourceForm jQuery object to modify + * + */ +function markEditedResourceFields($resourceForm) { + $resourceForm.find("input, select, textarea").on("change", function(e) { + $(e.target).addClass('edited-field'); + + if ($(e.target).closest('.language').length) { + setOperations($(e.target).closest('.language'), "update"); + } + }); +} + +function enableVocabularySelect(selectItem, type) { + selectItem.select2({ + ajax: { + url: snacUrl + "/vocabulary?type=" + type, + dataType: 'json', + delay: 250, + data: function(params) { + return { + q: params.term, + page: params.page + }; + }, + processResults: function(data, page) { + return { + results: data.results + }; + }, + cache: true + }, + width: '100%', + minimumInputLength: 0, + allowClear: true, + theme: 'bootstrap', + placeholder: 'Select' + }); +} + +function enableLanguageSelect($language) { + enableVocabularySelect($language.find("select:first"), 'language_code'); + enableVocabularySelect($language.find("select:last"), 'script_code'); +} + + +function magicNewResourceLanguage(event) { + var $newLanguage = newResourceLanguage(event); + var defaultLanguage = new Option(defaults.language.term, defaults.language.id, false, true); + var defaultScript = new Option(defaults.script.term, defaults.script.id, false, true); + $newLanguage.find("select:first").append(defaultLanguage).trigger('change'); + $newLanguage.find("select:last").append(defaultScript).trigger('change'); +} + +function selectHoldingRepository(event) { + event.preventDefault(); + var name = event.target.innerHTML; + var id = event.target.href.split('/').pop(); + var selectedRepo = new Option(name, id, false, true); + $(".resource-repo:last").append(selectedRepo).trigger('change'); + $("#search_form").slideToggle(); + $("#search-results-box").html(""); + $("#searchbox").val(""); +} diff --git a/src/virtualhosts/www/javascript/src/select_loaders.js b/src/virtualhosts/www/javascript/src/select_loaders.js new file mode 100644 index 000000000..f3b45d189 --- /dev/null +++ b/src/virtualhosts/www/javascript/src/select_loaders.js @@ -0,0 +1,342 @@ +/** + * Select Box Loaders + * + * Functions that can be used to replace select boxes on the edit page with + * pretty-formatted versions using JQuery and Select2 + * + * @author Robbie Hott + * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause + * @copyright 2015 the Rector and Visitors of the University of Virginia, and + * the Regents of the University of California + */ + +/** + * Replace a select that is linked to a Vocabulary search + * + * Replaces the select with a select2 object capable of making AJAX queries + * + * @param JQuery selectItem The JQuery item to replace + * @param string idMatch ID string for the object on the page + * @param string type The type of the vocabulary term + * @param int minLength The minimum required length of the autocomplete search + */ +function vocab_select_replace(selectItem, idMatch, type, minLength) { + if (minLength === undefined) { + minLength = 2; + } + + if(selectItem.attr('id').endsWith(idMatch) + && !selectItem.attr('id').endsWith("ZZ")) { + selectItem.select2({ + ajax: { + url: function() { + var query = snacUrl + "/vocabulary?type="+type+"&id="; + query += $("#constellationid").val()+"&version="+$("#version").val(); + query += "&entity_type="+$("#entityType").val(); + return query; + }, + dataType: 'json', + delay: 250, + data: function (params) { + return { + q: params.term, + page: params.page + }; + }, + processResults: function (data, page) { + return { results: data.results }; + }, + cache: true + }, + width: '100%', + minimumInputLength: minLength, + allowClear: true, + theme: 'bootstrap', + placeholder: 'Select' + }); + } +} + +var geoPlaceSearchResults = null; + +function geovocab_select_replace(selectItem, idMatch) { + var minLength = 2; + + if(selectItem.attr('id').endsWith(idMatch) + && !selectItem.attr('id').endsWith("ZZ")) { + selectItem.select2({ + ajax: { + url: function() { + var query = snacUrl+"/vocabulary?type=geo_place&format=term"; + query += "&entity_type="+$("#entityType").val(); + return query; + }, + dataType: 'json', + delay: 250, + data: function (params) { + return { + q: params.term, + page: params.page + }; + }, + processResults: function (data, page) { + if (data.results) { + geoPlaceSearchResults = data.results; + var selectResults = new Array(); + data.results.forEach(function(result) { + selectResults.push({ + id: result.id, + text: result.name + " (" + result.administrationCode + ", " + result.countryCode+ ")" + }) + }); + return {results: selectResults}; + } + return { results: null }; + }, + cache: true + }, + width: '100%', + minimumInputLength: minLength, + allowClear: true, + theme: 'bootstrap', + placeholder: 'Select' + }); + } +} + +var lastSourceSearchResults = null; + +/** + * Add
helper script + * + * Adds
to strings so that they can be shown to the user in HTML + * after being input into a text-only field. + */ +function addbr(str) { + if (typeof str !== 'undefined' && str !== null) { + return (str + '').replace(/(\r\n|\n\r|\r|\n)/g, '
' + '$1'); + } + return ''; +} + +/** + * Replace a select that is linked to a Constellation Source search + * + * Replaces the select with a select2 object capable of making AJAX queries + * + * @param JQuery selectItem The JQuery item to replace + * @param string idMatch ID string for the object on the page + */ +function scm_source_select_replace(selectItem, idMatch) { + if(selectItem.attr('id').endsWith(idMatch) + && !selectItem.attr('id').endsWith("ZZ")) { + selectItem.select2({ + ajax: { + url: function() { + var query = snacUrl+"/vocabulary?type=ic_sources&id="; + query += $("#constellationid").val()+"&version="+$("#version").val(); + query += "&entity_type="+$("#entityType").val(); + return query; + }, + dataType: 'json', + delay: 250, + data: function (params) { + return { + q: params.term, + page: params.page + }; + }, + processResults: function (data, page) { + // Modify the results to be in the format we want + lastSourceSearchResults = data.results; + // need id, text + var results = new Array(); + data.results.forEach(function(res) { + results.push({id: res.id, text: res.displayName}); + }); + return { results: results }; + }, + cache: true + }, + width: '100%', + minimumInputLength: 0, + allowClear: true, + theme: 'bootstrap', + placeholder: 'Select' + }); + + selectItem.on('change', function (evt) { + // TODO: Get the current selected value and update the well in the page to reflect it! + // Note: all the selections are available in the global lastSourceSearchResults variable. + var sourceID = $(this).val(); + var inPageID = $(this).attr("id"); + var idArray = inPageID.split("_"); + if (idArray.length >= 6) { + var i = idArray[5]; + var j = idArray[4]; + var shortName = idArray[1]; + lastSourceSearchResults.forEach(function(source) { + if (source.id == sourceID) { + // Update the text of the source + if (typeof source.text !== 'undefined') { + $("#scm_" + shortName + "_source_text_" + j + "_" + i).html(addbr(source.text)).removeClass('hidden'); + $("#scm_" + shortName + "_source_text_" + j + "_" + i).closest(".panel-body").removeClass('hidden'); + } else { + $("#scm_" + shortName + "_source_text_" + j + "_" + i).text("").addClass('hidden'); + $("#scm_" + shortName + "_source_text_" + j + "_" + i).closest(".panel-body").addClass('hidden'); + + } + // Update the URI of the source + if (typeof source.uri !== 'undefined') + $("#scm_" + shortName + "_source_uri_" + j + "_" + i).html(''+source.uri+''); + else + $("#scm_" + shortName + "_source_uri_" + j + "_" + i).html(''); + // Update the URI of the source + if (typeof source.citation !== 'undefined') + $("#scm_" + shortName + "_source_citation_" + j + "_" + i).html(source.citation).removeClass('hidden'); + else + $("#scm_" + shortName + "_source_citation_" + j + "_" + i).html('').addClass('hidden'); + } + }); + } + }); + + } +} + +/** + * Replace a select that is linked to an affiliation search + * + * Replaces the select with a select2 object capable of making AJAX queries + * + * @param JQuery selectItem The JQuery item to replace + */ +function affiliation_select_replace(selectItem) { + $.get(snacUrl + "/vocabulary?type=affiliation").done(function(data) { + var options = data.results; + selectItem.select2({ + data: options, + allowClear: true, + theme: "bootstrap", + placeholder: "Select Affiliation" + }); + }); +} + +function reviewer_select_replace(selectItem) { + if(selectItem != null) { + selectItem.select2({ + placeholder: "Reviewer Name or Email...", + ajax: { + url: function() { + var query = snacUrl+"/user_search?role=Reviewer"; + return query; + }, + dataType: 'json', + delay: 250, + data: function (params) { + return { + q: params.term, + page: params.page + }; + }, + processResults: function (data, page) { + return { results: data.results }; + }, + cache: true + }, + width: '100%', + minimumInputLength: 1, + allowClear: false, + theme: 'bootstrap' + }); + } +} + +function select_replace(selectItem, idMatch) { + if(selectItem.attr('id').endsWith(idMatch) + && !selectItem.attr('id').endsWith("ZZ")) { + selectItem.select2({ + allowClear: true, + theme: 'bootstrap' + }); + } +} + +function select_replace_simple(selectItem) { + selectItem.select2({ + width: '100%', + allowClear: true, + theme: 'bootstrap' + }); +} + + + +function sayHi(user) { + return `Hello, ${user}!`; +} + +function sayBye(user) { + return `Bye bye, ${user}!`; +} + +/** + * Load Vocab Select Options + * + * Replaces the select with a select2 object preloaded with an array of options + * + * @param JQuery selectItem The JQuery item to replace + * @param string type The type of the vocabulary term + * @param string type Text placeholder for select + */ +function loadVocabSelectOptions(selectItem, type, placeholder) { + return $.get(snacUrl + "/vocabulary?type=" + type) + .done(function(data) { + var options = data.results; + selectItem.select2({ + data: options, + allowClear: false, + theme: 'bootstrap', + placeholder: placeholder + }); + }); +} + +/** + * Replace all the selects that exist on the page when the page has finished loading + */ +$(document).ready(function() { + + // Use select2 to display the select dropdowns + // rather than the HTML default + $("select").each(function() { + if (typeof $(this).attr('id') !== typeof undefined && $(this).attr('id') !== false) { + // Replace the subject selects + vocab_select_replace($(this), "language_language_", "language_code", 1); + + // Replace the subject selects + vocab_select_replace($(this), "language_script_", "script_code", 1); + + // Replace the subject selects + vocab_select_replace($(this), "subject_", "subject", 4); + + // Replace the function selects + vocab_select_replace($(this), "function_", "function", 4); + + // Replace the occupation selects + vocab_select_replace($(this), "occupation_", "occupation", 4); + + // Replace the entityType select + vocab_select_replace($(this), "entityType", "entity_type", 0); + } + }); + + // Replace the Affiliation dropdowns, if one exists + if ($("#affiliationid").exists()) + affiliation_select_replace($("#affiliationid")); + + // Replace the User search dropdown, if one exists + if ($("#reviewersearchbox").exists()) + reviewer_select_replace($("#reviewersearchbox")); +}); diff --git a/webpack.config.js b/webpack.config.js index 162647904..bd347e879 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -2,9 +2,21 @@ const path = require('path'); const js_path = path.join(__dirname, "src/virtualhosts/www/javascript") module.exports = { - entry: path.join(js_path, "main.js"), - output: { - path: js_path, - filename: "bundle.js" - } + entry: { + bundle: path.join(js_path, "src", "main.js"), + resource_admin: path.join(js_path, "src", "resource_admin.js"), + select_loaders: path.join(js_path, "src", "select_loaders.js"), + }, + output: { + path: js_path, + filename: "[name].js" + }, + devtool: "cheap-module-eval-source-map", + module: { + rules: [{ + loader: "babel-loader", + test: /\.js$/, + exclude: /node_modules/ + }] + }, }; diff --git a/yarn.lock b/yarn.lock index 28cd50e14..b7e21396b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -182,11 +182,21 @@ ajv@^6.1.0, ajv@^6.10.2: json-schema-traverse "^0.4.1" uri-js "^4.2.2" +ansi-regex@^2.0.0: + version "2.1.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" + integrity sha1-w7M6te42DYbg5ijwRorn7yfWVN8= + ansi-regex@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" integrity sha512-1apePfXM1UOSqw0o9IiFAovVz9M5S1Dg+4TrDwfMewQ6p/rmMueb7tWZjQ1rx4Loy1ArBggoqGpfqqdI4rondg== +ansi-styles@^2.2.1: + version "2.2.1" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" + integrity sha1-tDLdM1i2NM914eRmQ2gkBTPB3b4= + ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -259,6 +269,140 @@ atob@^2.1.2: resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" integrity sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg== +babel-code-frame@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b" + integrity sha1-Y/1D99weO7fONZR9uP42mj9Yx0s= + dependencies: + chalk "^1.1.3" + esutils "^2.0.2" + js-tokens "^3.0.2" + +babel-core@^6.26.0, babel-core@^6.26.3: + version "6.26.3" + resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.3.tgz#b2e2f09e342d0f0c88e2f02e067794125e75c207" + integrity sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA== + dependencies: + babel-code-frame "^6.26.0" + babel-generator "^6.26.0" + babel-helpers "^6.24.1" + babel-messages "^6.23.0" + babel-register "^6.26.0" + babel-runtime "^6.26.0" + babel-template "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + convert-source-map "^1.5.1" + debug "^2.6.9" + json5 "^0.5.1" + lodash "^4.17.4" + minimatch "^3.0.4" + path-is-absolute "^1.0.1" + private "^0.1.8" + slash "^1.0.0" + source-map "^0.5.7" + +babel-generator@^6.26.0: + version "6.26.1" + resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90" + integrity sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA== + dependencies: + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + detect-indent "^4.0.0" + jsesc "^1.3.0" + lodash "^4.17.4" + source-map "^0.5.7" + trim-right "^1.0.1" + +babel-helpers@^6.24.1: + version "6.24.1" + resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2" + integrity sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI= + dependencies: + babel-runtime "^6.22.0" + babel-template "^6.24.1" + +babel-loader@7: + version "7.1.5" + resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.5.tgz#e3ee0cd7394aa557e013b02d3e492bfd07aa6d68" + integrity sha512-iCHfbieL5d1LfOQeeVJEUyD9rTwBcP/fcEbRCfempxTDuqrKpu0AZjLAQHEQa3Yqyj9ORKe2iHfoj4rHLf7xpw== + dependencies: + find-cache-dir "^1.0.0" + loader-utils "^1.0.2" + mkdirp "^0.5.1" + +babel-messages@^6.23.0: + version "6.23.0" + resolved "https://registry.yarnpkg.com/babel-messages/-/babel-messages-6.23.0.tgz#f3cdf4703858035b2a2951c6ec5edf6c62f2630e" + integrity sha1-8830cDhYA1sqKVHG7F7fbGLyYw4= + dependencies: + babel-runtime "^6.22.0" + +babel-register@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071" + integrity sha1-btAhFz4vy0htestFxgCahW9kcHE= + dependencies: + babel-core "^6.26.0" + babel-runtime "^6.26.0" + core-js "^2.5.0" + home-or-tmp "^2.0.0" + lodash "^4.17.4" + mkdirp "^0.5.1" + source-map-support "^0.4.15" + +babel-runtime@^6.22.0, babel-runtime@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe" + integrity sha1-llxwWGaOgrVde/4E/yM3vItWR/4= + dependencies: + core-js "^2.4.0" + regenerator-runtime "^0.11.0" + +babel-template@^6.24.1, babel-template@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-template/-/babel-template-6.26.0.tgz#de03e2d16396b069f46dd9fff8521fb1a0e35e02" + integrity sha1-3gPi0WOWsGn0bdn/+FIfsaDjXgI= + dependencies: + babel-runtime "^6.26.0" + babel-traverse "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + lodash "^4.17.4" + +babel-traverse@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-traverse/-/babel-traverse-6.26.0.tgz#46a9cbd7edcc62c8e5c064e2d2d8d0f4035766ee" + integrity sha1-RqnL1+3MYsjlwGTi0tjQ9ANXZu4= + dependencies: + babel-code-frame "^6.26.0" + babel-messages "^6.23.0" + babel-runtime "^6.26.0" + babel-types "^6.26.0" + babylon "^6.18.0" + debug "^2.6.8" + globals "^9.18.0" + invariant "^2.2.2" + lodash "^4.17.4" + +babel-types@^6.26.0: + version "6.26.0" + resolved "https://registry.yarnpkg.com/babel-types/-/babel-types-6.26.0.tgz#a3b073f94ab49eb6fa55cd65227a334380632497" + integrity sha1-o7Bz+Uq0nrb6Vc1lInozQ4BjJJc= + dependencies: + babel-runtime "^6.26.0" + esutils "^2.0.2" + lodash "^4.17.4" + to-fast-properties "^1.0.3" + +babylon@^6.18.0: + version "6.18.0" + resolved "https://registry.yarnpkg.com/babylon/-/babylon-6.18.0.tgz#af2f3b88fa6f5c1e4c634d1a0f8eac4f55b395e3" + integrity sha512-q/UEjfGJ2Cm3oKV71DJz9d25TPnq5rhBVL2Q4fA5wcC3jcrdn7+SssEybFIxwAvvP+YCsCYNKughoF33GxgycQ== + balanced-match@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" @@ -477,6 +621,17 @@ chalk@2.4.2: escape-string-regexp "^1.0.5" supports-color "^5.3.0" +chalk@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-1.1.3.tgz#a8115c55e4a702fe4d150abd3872822a7e09fc98" + integrity sha1-qBFcVeSnAv5NFQq9OHKCKn4J/Jg= + dependencies: + ansi-styles "^2.2.1" + escape-string-regexp "^1.0.2" + has-ansi "^2.0.0" + strip-ansi "^3.0.0" + supports-color "^2.0.0" + chokidar@^2.1.8: version "2.1.8" resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-2.1.8.tgz#804b3a7b6a99358c3c5c61e71d8728f041cff917" @@ -595,6 +750,13 @@ constants-browserify@^1.0.0: resolved "https://registry.yarnpkg.com/constants-browserify/-/constants-browserify-1.0.0.tgz#c20b96d8c617748aaf1c16021760cd27fcb8cb75" integrity sha1-wguW2MYXdIqvHBYCF2DNJ/y4y3U= +convert-source-map@^1.5.1: + version "1.7.0" + resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442" + integrity sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA== + dependencies: + safe-buffer "~5.1.1" + copy-concurrently@^1.0.0: version "1.0.5" resolved "https://registry.yarnpkg.com/copy-concurrently/-/copy-concurrently-1.0.5.tgz#92297398cae34937fcafd6ec8139c18051f0b5e0" @@ -612,6 +774,11 @@ copy-descriptor@^0.1.0: resolved "https://registry.yarnpkg.com/copy-descriptor/-/copy-descriptor-0.1.1.tgz#676f6eb3c39997c2ee1ac3a924fd6124748f578d" integrity sha1-Z29us8OZl8LuGsOpJP1hJHSPV40= +core-js@^2.4.0, core-js@^2.5.0: + version "2.6.11" + resolved "https://registry.yarnpkg.com/core-js/-/core-js-2.6.11.tgz#38831469f9922bded8ee21c9dc46985e0399308c" + integrity sha512-5wjnpaT/3dV+XB4borEsnAYQchn00XSgTAWKDkEqv+K8KevjbzmofK6hfJ9TZIlpj2N0xQpazy7PiRQiWHqzWg== + core-util-is@~1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7" @@ -681,7 +848,7 @@ cyclist@^1.0.1: resolved "https://registry.yarnpkg.com/cyclist/-/cyclist-1.0.1.tgz#596e9698fd0c80e12038c2b82d6eb1b35b6224d9" integrity sha1-WW6WmP0MgOEgOMK4LW6xs1tiJNk= -debug@^2.2.0, debug@^2.3.3: +debug@^2.2.0, debug@^2.3.3, debug@^2.6.8, debug@^2.6.9: version "2.6.9" resolved "https://registry.yarnpkg.com/debug/-/debug-2.6.9.tgz#5d128515df134ff327e90a4c93f4e077a536341f" integrity sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA== @@ -733,6 +900,13 @@ detect-file@^1.0.0: resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7" integrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc= +detect-indent@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208" + integrity sha1-920GQ1LN9Docts5hnE7jqUdd4gg= + dependencies: + repeating "^2.0.0" + diffie-hellman@^5.0.0: version "5.0.3" resolved "https://registry.yarnpkg.com/diffie-hellman/-/diffie-hellman-5.0.3.tgz#40e8ee98f55a2149607146921c63e1ae5f3d2875" @@ -817,7 +991,7 @@ errno@^0.1.3, errno@~0.1.7: dependencies: prr "~1.0.1" -escape-string-regexp@^1.0.5: +escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= @@ -842,6 +1016,11 @@ estraverse@^4.1.0, estraverse@^4.1.1: resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.3.0.tgz#398ad3f3c5a24948be7725e83d11a7de28cdbd1d" integrity sha512-39nnKffWz8xN1BU/2c79n9nB9HDzo0niYUqx6xyqUnyoAnQyyWpOTdZEeiCch8BBu515t4wp9ZmgVfVhn9EBpw== +esutils@^2.0.2: + version "2.0.3" + resolved "https://registry.yarnpkg.com/esutils/-/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" + integrity sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g== + events@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/events/-/events-3.1.0.tgz#84279af1b34cb75aa88bf5ff291f6d0bd9b31a59" @@ -947,6 +1126,15 @@ fill-range@^4.0.0: repeat-string "^1.6.1" to-regex-range "^2.1.0" +find-cache-dir@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-1.0.0.tgz#9288e3e9e3cc3748717d39eade17cf71fc30ee6f" + integrity sha1-kojj6ePMN0hxfTnq3hfPcfww7m8= + dependencies: + commondir "^1.0.1" + make-dir "^1.0.0" + pkg-dir "^2.0.0" + find-cache-dir@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/find-cache-dir/-/find-cache-dir-2.1.0.tgz#8d0f94cd13fe43c6c7c261a0d86115ca918c05f7" @@ -956,6 +1144,13 @@ find-cache-dir@^2.1.0: make-dir "^2.0.0" pkg-dir "^3.0.0" +find-up@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7" + integrity sha1-RdG35QbHF93UgndaK3eSCjwMV6c= + dependencies: + locate-path "^2.0.0" + find-up@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/find-up/-/find-up-3.0.0.tgz#49169f1d7993430646da61ecc5ae355c21c97b73" @@ -1097,11 +1292,23 @@ global-prefix@^3.0.0: kind-of "^6.0.2" which "^1.3.1" +globals@^9.18.0: + version "9.18.0" + resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a" + integrity sha512-S0nG3CLEQiY/ILxqtztTWH/3iRRdyBLw6KMDxnKMchrtbj2OFmehVh0WUCfW3DUrIgx/qFrJPICrq4Z4sTR9UQ== + graceful-fs@^4.1.11, graceful-fs@^4.1.15, graceful-fs@^4.1.2: version "4.2.4" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.4.tgz#2256bde14d3632958c465ebc96dc467ca07a29fb" integrity sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw== +has-ansi@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/has-ansi/-/has-ansi-2.0.0.tgz#34f5049ce1ecdf2b0649af3ef24e45ed35416d91" + integrity sha1-NPUEnOHs3ysGSa8+8k5F7TVBbZE= + dependencies: + ansi-regex "^2.0.0" + has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -1164,6 +1371,14 @@ hmac-drbg@^1.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" +home-or-tmp@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/home-or-tmp/-/home-or-tmp-2.0.0.tgz#e36c3f2d2cae7d746a857e38d18d5f32a7882db8" + integrity sha1-42w/LSyufXRqhX440Y1fMqeILbg= + dependencies: + os-homedir "^1.0.0" + os-tmpdir "^1.0.1" + homedir-polyfill@^1.0.1: version "1.0.3" resolved "https://registry.yarnpkg.com/homedir-polyfill/-/homedir-polyfill-1.0.3.tgz#743298cef4e5af3e194161fbadcc2151d3a058e8" @@ -1237,6 +1452,13 @@ interpret@1.2.0: resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.2.0.tgz#d5061a6224be58e8083985f5014d844359576296" integrity sha512-mT34yGKMNceBQUoVn7iCDKDntA7SC6gycMAWzGx1z/CMCTV7b2AAtXlo3nRyHZ1FelRkQbQjprHSYGwzLtkVbw== +invariant@^2.2.2: + version "2.2.4" + resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.4.tgz#610f3c92c9359ce1db616e538008d23ff35158e6" + integrity sha512-phJfQVBuaJM5raOpJjSfkiD6BpbCE4Ns//LaXl6wGYtUBY83nWS6Rf9tXm2e8VaK60JEjYldbPif/A2B1C2gNA== + dependencies: + loose-envify "^1.0.0" + invert-kv@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/invert-kv/-/invert-kv-2.0.0.tgz#7393f5afa59ec9ff5f67a27620d11c226e3eec02" @@ -1317,6 +1539,11 @@ is-extglob@^2.1.0, is-extglob@^2.1.1: resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" integrity sha1-qIwCU1eR8C7TfHahueqXc8gz+MI= +is-finite@^1.0.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/is-finite/-/is-finite-1.1.0.tgz#904135c77fb42c0641d6aa1bcdbc4daa8da082f3" + integrity sha512-cdyMtqX/BOqqNBBiKlIVkytNHm49MtMlYyn1zxzvJKWmFMlGzm+ry5BBfYyeY9YmNKbRSo/o7OX9w9ale0wg3w== + is-fullwidth-code-point@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz#a3b30a5c4f199183167aaab93beefae3ddfb654f" @@ -1387,6 +1614,21 @@ isobject@^3.0.0, isobject@^3.0.1: resolved "https://registry.yarnpkg.com/isobject/-/isobject-3.0.1.tgz#4e431e92b11a9731636aa1f9c8d1ccbcfdab78df" integrity sha1-TkMekrEalzFjaqH5yNHMvP2reN8= +"js-tokens@^3.0.0 || ^4.0.0": + version "4.0.0" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" + integrity sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ== + +js-tokens@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" + integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= + +jsesc@^1.3.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-1.3.0.tgz#46c3fec8c1892b12b0833db9bc7622176dbab34b" + integrity sha1-RsP+yMGJKxKwgz25vHYiF226s0s= + json-parse-better-errors@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz#bb867cfb3450e69107c131d1c514bab3dc8bcaa9" @@ -1397,6 +1639,11 @@ json-schema-traverse@^0.4.1: resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-0.4.1.tgz#69f6a87d9513ab8bb8fe63bdb0979c448e684660" integrity sha512-xbbCH5dCYU5T8LcEhhuh7HJ88HXuW3qsI3Y0zOZFKfZEHcpWiHU/Jxzk629Brsab/mMiHQti9wMP+845RPe3Vg== +json5@^0.5.1: + version "0.5.1" + resolved "https://registry.yarnpkg.com/json5/-/json5-0.5.1.tgz#1eade7acc012034ad84e2396767ead9fa5495821" + integrity sha1-Hq3nrMASA0rYTiOWdn6tn6VJWCE= + json5@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" @@ -1449,7 +1696,7 @@ loader-utils@1.2.3: emojis-list "^2.0.0" json5 "^1.0.1" -loader-utils@^1.2.3: +loader-utils@^1.0.2, loader-utils@^1.2.3: version "1.4.0" resolved "https://registry.yarnpkg.com/loader-utils/-/loader-utils-1.4.0.tgz#c579b5e34cb34b1a74edc6c1fb36bfa371d5a613" integrity sha512-qH0WSMBtn/oHuwjy/NucEgbx5dbxxnxup9s4PVXJUDHZBQY+s0NWA9rJf53RBnQZxfch7euUui7hpoAPvALZdA== @@ -1458,6 +1705,14 @@ loader-utils@^1.2.3: emojis-list "^3.0.0" json5 "^1.0.1" +locate-path@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" + integrity sha1-K1aLJl7slExtnA3pw9u7ygNUzY4= + dependencies: + p-locate "^2.0.0" + path-exists "^3.0.0" + locate-path@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-3.0.0.tgz#dbec3b3ab759758071b58fe59fc41871af21400e" @@ -1466,6 +1721,18 @@ locate-path@^3.0.0: p-locate "^3.0.0" path-exists "^3.0.0" +lodash@^4.17.4: + version "4.17.15" + resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" + integrity sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A== + +loose-envify@^1.0.0: + version "1.4.0" + resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" + integrity sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q== + dependencies: + js-tokens "^3.0.0 || ^4.0.0" + lru-cache@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-5.1.1.tgz#1da27e6710271947695daf6848e847f01d84b920" @@ -1473,6 +1740,13 @@ lru-cache@^5.1.1: dependencies: yallist "^3.0.2" +make-dir@^1.0.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" + integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ== + dependencies: + pify "^3.0.0" + make-dir@^2.0.0: version "2.1.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-2.1.0.tgz#5f0310e18b8be898cc07009295a30ae41e91e6f5" @@ -1756,6 +2030,11 @@ os-browserify@^0.3.0: resolved "https://registry.yarnpkg.com/os-browserify/-/os-browserify-0.3.0.tgz#854373c7f5c2315914fc9bfc6bd8238fdda1ec27" integrity sha1-hUNzx/XCMVkU/Jv8a9gjj92h7Cc= +os-homedir@^1.0.0: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-homedir/-/os-homedir-1.0.2.tgz#ffbc4988336e0e833de0c168c7ef152121aa7fb3" + integrity sha1-/7xJiDNuDoM94MFox+8VISGqf7M= + os-locale@^3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/os-locale/-/os-locale-3.1.0.tgz#a802a6ee17f24c10483ab9935719cef4ed16bf1a" @@ -1765,6 +2044,11 @@ os-locale@^3.1.0: lcid "^2.0.0" mem "^4.0.0" +os-tmpdir@^1.0.1: + version "1.0.2" + resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274" + integrity sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ= + p-defer@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" @@ -1780,6 +2064,13 @@ p-is-promise@^2.0.0: resolved "https://registry.yarnpkg.com/p-is-promise/-/p-is-promise-2.1.0.tgz#918cebaea248a62cf7ffab8e3bca8c5f882fc42e" integrity sha512-Y3W0wlRPK8ZMRbNq97l4M5otioeA5lm1z7bkNkxCka8HSPjR0xRWmpCmc9utiaLP9Jb1eD8BgeIxTW4AIF45Pg== +p-limit@^1.1.0: + version "1.3.0" + resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-1.3.0.tgz#b86bd5f0c25690911c7590fcbfc2010d54b3ccb8" + integrity sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q== + dependencies: + p-try "^1.0.0" + p-limit@^2.0.0: version "2.3.0" resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-2.3.0.tgz#3dd33c647a214fdfffd835933eb086da0dc21db1" @@ -1787,6 +2078,13 @@ p-limit@^2.0.0: dependencies: p-try "^2.0.0" +p-locate@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-2.0.0.tgz#20a0103b222a70c8fd39cc2e580680f3dde5ec43" + integrity sha1-IKAQOyIqcMj9OcwuWAaA893l7EM= + dependencies: + p-limit "^1.1.0" + p-locate@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-3.0.0.tgz#322d69a05c0264b25997d9f40cd8a891ab0064a4" @@ -1794,6 +2092,11 @@ p-locate@^3.0.0: dependencies: p-limit "^2.0.0" +p-try@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" + integrity sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M= + p-try@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-2.2.0.tgz#cb2868540e313d61de58fafbe35ce9004d5540e6" @@ -1850,7 +2153,7 @@ path-exists@^3.0.0: resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-3.0.0.tgz#ce0ebeaa5f78cb18925ea7d810d7b59b010fd515" integrity sha1-zg6+ql94yxiSXqfYENe1mwEP1RU= -path-is-absolute@^1.0.0: +path-is-absolute@^1.0.0, path-is-absolute@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f" integrity sha1-F0uSaHNVNP+8es5r9TpanhtcX18= @@ -1871,11 +2174,23 @@ pbkdf2@^3.0.3: safe-buffer "^5.0.1" sha.js "^2.4.8" +pify@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pify/-/pify-3.0.0.tgz#e5a4acd2c101fdf3d9a4d07f0dbc4db49dd28176" + integrity sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY= + pify@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/pify/-/pify-4.0.1.tgz#4b2cd25c50d598735c50292224fd8c6df41e3231" integrity sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g== +pkg-dir@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" + integrity sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s= + dependencies: + find-up "^2.1.0" + pkg-dir@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-3.0.0.tgz#2749020f239ed990881b1f71210d51eb6523bea3" @@ -1888,6 +2203,11 @@ posix-character-classes@^0.1.0: resolved "https://registry.yarnpkg.com/posix-character-classes/-/posix-character-classes-0.1.1.tgz#01eac0fe3b5af71a2a6c02feabb8c1fef7e00eab" integrity sha1-AerA/jta9xoqbAL+q7jB/vfgDqs= +private@^0.1.8: + version "0.1.8" + resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" + integrity sha512-VvivMrbvd2nKkiG38qjULzlc+4Vx4wm/whI9pQD35YrARNnhxeiRktSOhSukRLFNlzg6Br/cJPet5J/u19r/mg== + process-nextick-args@~2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" @@ -2016,6 +2336,11 @@ readdirp@^2.2.1: micromatch "^3.1.10" readable-stream "^2.0.2" +regenerator-runtime@^0.11.0: + version "0.11.1" + resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.11.1.tgz#be05ad7f9bf7d22e056f9726cee5017fbf19e2e9" + integrity sha512-MguG95oij0fC3QV3URf4V2SDYGJhJnJGqvIIgdECeODCT98wSWDAJ94SSuVpYQUoTcGUIL6L4yNB7j1DFFHSBg== + regex-not@^1.0.0, regex-not@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/regex-not/-/regex-not-1.0.2.tgz#1f4ece27e00b0b65e0247a6810e6a85d83a5752c" @@ -2039,6 +2364,13 @@ repeat-string@^1.6.1: resolved "https://registry.yarnpkg.com/repeat-string/-/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" integrity sha1-jcrkcOHIirwtYA//Sndihtp15jc= +repeating@^2.0.0: + version "2.0.1" + resolved "https://registry.yarnpkg.com/repeating/-/repeating-2.0.1.tgz#5214c53a926d3552707527fbab415dbc08d06dda" + integrity sha1-UhTFOpJtNVJwdSf7q0FdvAjQbdo= + dependencies: + is-finite "^1.0.0" + require-directory@^2.1.1: version "2.1.1" resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42" @@ -2182,6 +2514,11 @@ signal-exit@^3.0.0: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.3.tgz#a1410c2edd8f077b08b4e253c8eacfcaf057461c" integrity sha512-VUJ49FC8U1OxwZLxIbTTrDvLnf/6TDgxZcK8wxR8zs13xpx7xbG60ndBlhNrFi2EMuFRoeDoJO7wthSLq42EjA== +slash@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" + integrity sha1-xB8vbDn8FtHNF61LXYlhFK5HDVU= + snapdragon-node@^2.0.1: version "2.1.1" resolved "https://registry.yarnpkg.com/snapdragon-node/-/snapdragon-node-2.1.1.tgz#6c175f86ff14bdb0724563e8f3c1b021a286853b" @@ -2228,6 +2565,13 @@ source-map-resolve@^0.5.0: source-map-url "^0.4.0" urix "^0.1.0" +source-map-support@^0.4.15: + version "0.4.18" + resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.4.18.tgz#0286a6de8be42641338594e97ccea75f0a2c585f" + integrity sha512-try0/JqxPLF9nOjvSta7tVondkP5dwgyLDjVoyMDlmjugT2lRZ1OfsrYTkCd2hkDnJTKRbO/Rl3orm8vlsUzbA== + dependencies: + source-map "^0.5.6" + source-map-support@~0.5.12: version "0.5.19" resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.19.tgz#a98b62f86dcaf4f67399648c085291ab9e8fed61" @@ -2241,7 +2585,7 @@ source-map-url@^0.4.0: resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= -source-map@^0.5.6: +source-map@^0.5.6, source-map@^0.5.7: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= @@ -2328,6 +2672,13 @@ string_decoder@~1.1.1: dependencies: safe-buffer "~5.1.0" +strip-ansi@^3.0.0: + version "3.0.1" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" + integrity sha1-ajhfuIU9lS1f8F0Oiq+UJ43GPc8= + dependencies: + ansi-regex "^2.0.0" + strip-ansi@^5.0.0, strip-ansi@^5.1.0, strip-ansi@^5.2.0: version "5.2.0" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" @@ -2347,6 +2698,11 @@ supports-color@6.1.0: dependencies: has-flag "^3.0.0" +supports-color@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" + integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= + supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -2403,6 +2759,11 @@ to-arraybuffer@^1.0.0: resolved "https://registry.yarnpkg.com/to-arraybuffer/-/to-arraybuffer-1.0.1.tgz#7d229b1fcc637e466ca081180836a7aabff83f43" integrity sha1-fSKbH8xjfkZsoIEYCDanqr/4P0M= +to-fast-properties@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/to-fast-properties/-/to-fast-properties-1.0.3.tgz#b83571fa4d8c25b82e231b06e3a3055de4ca1a47" + integrity sha1-uDVx+k2MJbguIxsG46MFXeTKGkc= + to-object-path@^0.3.0: version "0.3.0" resolved "https://registry.yarnpkg.com/to-object-path/-/to-object-path-0.3.0.tgz#297588b7b0e7e0ac08e04e672f85c1f4999e17af" @@ -2428,6 +2789,11 @@ to-regex@^3.0.1, to-regex@^3.0.2: regex-not "^1.0.2" safe-regex "^1.1.0" +trim-right@^1.0.1: + version "1.0.1" + resolved "https://registry.yarnpkg.com/trim-right/-/trim-right-1.0.1.tgz#cb2e1203067e0c8de1f614094b9fe45704ea6003" + integrity sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM= + tslib@^1.9.0: version "1.11.2" resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.11.2.tgz#9c79d83272c9a7aaf166f73915c9667ecdde3cc9" From c6bcc081945fa22fc4b5ebf2ec465cb98484f74c Mon Sep 17 00:00:00 2001 From: Derik Ramirez Date: Thu, 21 May 2020 14:00:22 -0600 Subject: [PATCH 3/4] Updates code for JavaScript on specific files to export elements Configured Webpack to export a library with exports on the `window` object so the scripts' exported functions and variables are accessible on the global scope. By doing this we avoid changing the inline scripts on the HTML templates. TODO: Add production configuration to Webpack. --- .../www/javascript/edit_scripts.js | 2947 +---------------- .../www/javascript/resource_admin.js | 96 +- .../www/javascript/select_loaders.js | 97 +- .../www/javascript/src/edit_scripts.js | 2850 ++++++++++++++++ .../www/javascript/src/resource_admin.js | 18 +- .../www/javascript/src/select_loaders.js | 22 +- webpack.config.js | 7 +- 7 files changed, 3159 insertions(+), 2878 deletions(-) create mode 100644 src/virtualhosts/www/javascript/src/edit_scripts.js diff --git a/src/virtualhosts/www/javascript/edit_scripts.js b/src/virtualhosts/www/javascript/edit_scripts.js index 3ffac90f1..4bbd73061 100644 --- a/src/virtualhosts/www/javascript/edit_scripts.js +++ b/src/virtualhosts/www/javascript/edit_scripts.js @@ -1,2850 +1,97 @@ -/** - * Edit Scripts - * - * Scripts used in the edit page - * - * @author Robbie Hott - * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause - * @copyright 2015 the Rector and Visitors of the University of Virginia, and - * the Regents of the University of California - */ - -var biogHistEditor = null; - -// Has anything been edited on this page? -var somethingHasBeenEdited = false; - -function setEditedFlag(val) { - if (val == true) { - $("#save_and_continue").addClass("save-active"); - } else { - $("#save_and_continue").removeClass("save-active"); - } - somethingHasBeenEdited = val; -} - - -// Global Undo Set -var undoSet = new Array(); - -var defaults = { - language: { - id: 130, - term: "eng" - }, - script: { - id: 586, - term: "Latn" - } -}; - - - -/** - * Display Error message - * - * Displays the error message box to the user with the given error message - * - * @param string|object err The error message (string) or error object containing a message and type string - */ -function displayErrorMessage(err, data) { - var errorMsg = ""; - if (typeof err === 'undefined') - errorMsg = "an unknown problem occurred"; - else if ((typeof err) == "string") - errorMsg = err; - else if (err.message) - errorMsg = err.message; - else if (err.type) - errorMsg = err.type; - else - errorMsg = "an unknown problem occurred"; - - $('#error-message').html("

Oops

"+errorMsg+"

" - +"

" - +" " - +""+ - "Go to Dashboard" - +"" - +"

"); - setTimeout(function(){ - $('#error-message').slideDown(); - }, 500); - - // For reference, put the server response in the console - console.log(data); -} - -/** - * Add sub-Date GUI object - * - * Adds a Date GUI object to the Date modal for the given "short" type of data indexed by i - * - * @param string short The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index of the object to add a date object to. - * @returns boolean false to keep the browser from redrawing the page - */ -function addDateEntry(short, i){ - //next_date_{{short}}_{{i}}_j - var j = parseInt($('#next_date_'+short+'_'+i+'_j').text()); - var id = j + "_" + i; - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#sub_date_template').clone(); - var html = text.html().replace(/ZZ/g, i).replace(/XX/g, j).replace(/SHORT/g, short); - $('#add_date_'+short+'_'+i+'_div').after(html); - $('#next_date_'+short+'_'+i+'_j').text(j + 1); - turnOnButtons(short+"_date"+j, i); - turnOnTooltips(short+"_date_"+j, i); - makeEditable(short + "_date_"+j, i); - return false; -} - -/** - * Add sub-Date GUI object - * - * Adds a Date GUI object to the Date modal for the given "short" type of data indexed by i - * - * @param string short The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index of the object to add a date object to. - * @returns boolean false to keep the browser from redrawing the page - */ -function addDateRangeEntry(short, i){ - //next_date_{{short}}_{{i}}_j - var j = parseInt($('#next_date_'+short+'_'+i+'_j').text()); - var id = j + "_" + i; - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#sub_dateRange_template').clone(); - var html = text.html().replace(/ZZ/g, i).replace(/XX/g, j).replace(/SHORT/g, short); - $('#add_date_'+short+'_'+i+'_div').after(html); - $('#next_date_'+short+'_'+i+'_j').text(j + 1); - turnOnButtons(short+"_date"+j, i); - turnOnTooltips(short+"_date_"+j, i); - makeEditable(short + "_date_"+j, i); - return false; -} - -/** - * Add SCM GUI object - * - * Adds a GUI SCM object to the SCM modal for the given "short" type of data indexed by i - * - * @param string short The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index of the object to add an SCM object to. - * @returns boolean false to keep the browser from redrawing the page - */ -function addSCMEntry(short, i){ - //next_scm_{{short}}_{{i}}_j - var j = parseInt($('#next_scm_'+short+'_'+i+'_j').text()); - var id = j + "_" + i; - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#scm_template').clone(); - var html = text.html().replace(/ZZ/g, i).replace(/YY/g, j).replace(/SHORT/g, short); - $('#add_scm_'+short+'_'+i+'_div').after(html); - $('#next_scm_'+short+'_'+i+'_j').text(j + 1); - turnOnSCMButtons(short, i, j); - turnOnTooltips("scm_"+short, id); - makeSCMEditable(short, i, j); - return false; -} - -/** - * Undo Edit - * - * Returns the html for the (short, i) panel back to its original state, i.e. removes - * the edit. Before doing this, to clean up the page, it first makes the edited version - * uneditable. - * - * @param string short The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - */ -function undoEdit(short, i) { - makeUneditable(short, i); - - // restore the old content - $("#" + short + "_datapart_" + i).replaceWith(undoSet[short+"-"+i]); - turnOnTooltips(short,i); - $("#" + short + "_datapart_" + i + " input[type='checkbox']").each(function() { - var obj = $(this); - obj.bootstrapToggle(); - }); -} - -/** - * Undo SCM Edit - * - * Takes an SCM GUI object (j) for a data object (short, i) and returns it back to its - * original state (removing the edit). Before doing this, to clean up the page and JS, it first - * makes the edited version uneditable, then replaces the HTML. - * - * @param string short The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - * @param string|int j The index within the data object SCM list on the edit page of the SCM object. - */ -function undoSCMEdit(short, i, j) { - var id = j + "_" + i; - makeSCMUneditable(short, i, j); - - // restore the old content - $("#scm_" + short + "_datapart_" + id).replaceWith(undoSet["scm_"+short+"-"+id]); - turnOnTooltips("scm_"+short, id); -} - -/** - * Change vocabulary input divs to selects - * - * Changes all div's with id "select_" for a given data object (shortName, idStr) from a list of - * inputs defining the parameters to a select (view mode) to a select box (edit mode). It then - * calls the select2 function to replace the select with an AJAX-compatible select. - * - * This function handles VOCABULARY select boxes ONLY. - * - * Note: idStr must not have the "_" pre-appended - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int idStr The index within the edit page of the object. - */ -function textToSelect(shortName, idStr) { - $("#"+shortName+"_datapart_" + idStr + " div[id^='select_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace("select_", "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - var id = $("#"+shortName+"_"+name+"_id_"+idStr).val(); - var term = $("#"+shortName+"_"+name+"_term_"+idStr).val(); - var vocabtype = $("#"+shortName+"_"+name+"_vocabtype_"+idStr).val(); - var minlength = $("#"+shortName+"_"+name+"_minlength_"+idStr).val(); - var placeholder = "Select"; - if ($("#"+shortName+"_"+name+"_placeholder_"+idStr).exists()) { - placeholder = $("#"+shortName+"_"+name+"_placeholder_"+idStr).val(); - } - var options = ""; - if ($("#"+shortName+"_"+name+"_defaultOptions_"+idStr).exists()) { - options = $("#"+shortName+"_"+name+"_defaultOptions_"+idStr).val(); - } - - cont.html(""+ - "" + - ""); - - if (name == "citation") - scm_source_select_replace($("#"+shortName+"_"+name+"_id_"+idStr), "_"+idStr); - else - vocab_select_replace($("#"+shortName+"_"+name+"_id_"+idStr), "_"+idStr, vocabtype, minlength); - - } - }); -} - -function textToCheckbox(shortName, idStr) { - $("#"+shortName+"_datapart_" + idStr + " div[id^='checkbox_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace(/^checkbox_/, "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - var value = $("#"+shortName+"_"+name+"_"+idStr).val(); - var placeholderOn = ""; - if ($("#"+shortName+"_"+name+"_placeholderOn_"+idStr).exists()) { - placeholderOn = $("#"+shortName+"_"+name+"_placeholderOn_"+idStr).val(); - } - var placeholderOff = ""; - if ($("#"+shortName+"_"+name+"_placeholderOff_"+idStr).exists()) { - placeholderOff = $("#"+shortName+"_"+name+"_placeholderOff_"+idStr).val(); - } - - var html = ""; - } - if (placeholderOff != "") { - html += ""; - } - - cont.html(html); - $("#"+shortName+"_"+name+"_"+idStr).bootstrapToggle(); - } - }); - - -} - - -function checkboxToText(shortName, idStr) { - $("#"+shortName+"_datapart_" + idStr + " div[id^='checkbox_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace(/^checkbox_/, "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - var value = $("#"+shortName+"_"+name+"_"+idStr).val(); - var checked = $("#"+shortName+"_"+name+"_"+idStr).prop('checked'); - var placeholderOn = ""; - if ($("#"+shortName+"_"+name+"_placeholderOn_"+idStr).exists()) { - placeholderOn = $("#"+shortName+"_"+name+"_placeholderOn_"+idStr).val(); - } - var placeholderOff = ""; - if ($("#"+shortName+"_"+name+"_placeholderOff_"+idStr).exists()) { - placeholderOff = $("#"+shortName+"_"+name+"_placeholderOff_"+idStr).val(); - } - - - var html = ""; - - html += "

"; - if (checked) { - if (placeholderOn != "") - html += placeholderOn; - else - html += value; - } else { - if (placeholderOff != "") - html += placeholderOff; - } - html += "

"; - if (placeholderOn != "") { - html += ""; - } - if (placeholderOff != "") { - html += ""; - } - - $("#"+shortName+"_"+name+"_"+idStr).bootstrapToggle("destroy"); - cont.html(html); - } - }); - - -} - -function textToInput(shortName, idStr) { - $("#"+shortName+"_datapart_" + idStr + " div[id^='text_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace(/^text_/, "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - var value = $("#"+shortName+"_"+name+"_"+idStr).val(); - var size = 0; - var sizeStr = ""; - if ($("#"+shortName+"_"+name+"_size_"+idStr).exists()) { - size = parseInt($("#"+shortName+"_"+name+"_size_"+idStr).val()); - sizeStr = " size='" + size +"' "; - } - var placeholder = ""; - if ($("#"+shortName+"_"+name+"_placeholder_"+idStr).exists()) { - placeholder = $("#"+shortName+"_"+name+"_placeholder_"+idStr).val(); - } - - var onKeyUp = ""; - if ($("#"+shortName+"_"+name+"_onKeyUp_"+idStr).exists()) { - onKeyUp = $("#"+shortName+"_"+name+"_onKeyUp_"+idStr).val(); - } - var onKeyUpStr = ""; - if (onKeyUp != "") { - onKeyUpStr = " onKeyUp='"+onKeyUp+"' "; - } - - var html = ""; - if (size != 0) { - html += ""; - } - if (placeholder != "") { - html += ""; - } - if (onKeyUp != "") { - html += ""; - } - - cont.html(html); - } - }); - - -} - - -function inputToText(shortName, idStr) { - $("#"+shortName+"_datapart_" + idStr + " div[id^='text_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace(/^text_/, "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - var value = $("#"+shortName+"_"+name+"_"+idStr).val(); - var size = 0; - if ($("#"+shortName+"_"+name+"_size_"+idStr).exists()) { - size = parseInt($("#"+shortName+"_"+name+"_size_"+idStr).val()); - } - var placeholder = ""; - if ($("#"+shortName+"_"+name+"_placeholder_"+idStr).exists()) { - placeholder = $("#"+shortName+"_"+name+"_placeholder_"+idStr).val(); - } - var onKeyUp = ""; - if ($("#"+shortName+"_"+name+"_onKeyUp_"+idStr).exists()) { - onKeyUp = $("#"+shortName+"_"+name+"_onKeyUp_"+idStr).val(); - } - - var html = ""; - html += "

" + value + "

"; - if (size != 0) { - html += ""; - } - if (placeholder != "") { - html += ""; - } - if (onKeyUp != "") { - html += ""; - } - - cont.html(html); - } - }); - - -} - - - -function textToTextArea(shortName, idStr) { - $("#"+shortName+"_datapart_" + idStr + " div[id^='textarea_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace(/^textarea_/, "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - var value = $("#"+shortName+"_"+name+"_"+idStr).val(); - - var html = ""; - - cont.html(html); - } - }); -} - - -function textAreaToText(shortName, idStr) { - $("#"+shortName+"_datapart_" + idStr + " div[id^='textarea_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace(/^textarea_/, "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - var value = $("#"+shortName+"_"+name+"_"+idStr).val(); - - //var html = ""; - var html = ""; - html += "
" + value + "
"; - - cont.html(html); - } - }); -} - -/** - * Change vocabulary selects to divs of inputs - * - * Changes all div's with id "select_" for a given data object (shortName, idStr) from a select - * box (edit mode) to a list of inputs defining the parameters to a select (view mode). - * - * This function handles VOCABULARY select boxes ONLY. - * - * Note: idStr must not have the "_" pre-appended - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int idStr The index within the edit page of the object. - */ -function selectToText(shortName, idStr) { - $("div[id^='select_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace("select_", "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - var id = $("#"+shortName+"_"+name+"_id_"+idStr).val(); - var term = $("#"+shortName+"_"+name+"_id_"+idStr+ " option:selected").text(); - var vocabtype = $("#"+shortName+"_"+name+"_vocabtype_"+idStr).val(); - var minlength = $("#"+shortName+"_"+name+"_minlength_"+idStr).val(); - - var additionalStyle = ""; - var postText = ""; - if (vocabtype == "name_component") { - additionalStyle = "name-component-type"; - postText = " :"; - } - - cont.html("" + - "" + - "" + - "" + - "

"+term+postText+"

"); - - } - }); -} - - -var geoPlaceLoadResults = null; - -function textToGeoPlaceSelect(shortName, idStr) { - $("#"+shortName+"_datapart_" + idStr + " div[id^='selectGeo_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace("selectGeo_", "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - var id = $("#"+shortName+"_"+name+"_id_"+idStr).val(); - var term = $("#"+shortName+"_"+name+"_term_"+idStr).val(); - var placeholder = "Select Geo Place Term"; - - var confirmed = $("#"+shortName+"_confirmed_" + idStr).val() == "true" ? true : false; - var firstOptionSelect = ""; - var secondOptionSelect = " selected"; - if (!confirmed) { - firstOptionSelect = " selected"; - secondOptionSelect = ""; - } - - cont.html(""); - - geovocab_select_replace($("#"+shortName+"_"+name+"_id_"+idStr), "_"+idStr); - - } - }); -} - -function geoPlaceSelectToText(shortName, idStr) { - $("div[id^='selectGeo_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace("selectGeo_", "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - var id = $("#"+shortName+"_"+name+"_id_"+idStr).val(); - var term = $("#"+shortName+"_"+name+"_id_"+idStr+ " option:selected").text(); - - cont.html("" + - ""); - - } - }); -} - -/** - * Make a data object editable - * - * Make the GUI pane for a given constellation object (short, i) editable. Sets up the edit and delete - * buttons for first-order data objects. - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - * @return boolean False to play nice with the browser - */ -function makeEditable(short, i) { - // No editing if it's already in edit mode - if ($("#" + short + "_operation_" + i).val() == "update") - return false; - // If it's deleted, then you better undelete it first - if ($("#" + short + "_operation_" + i).val() == "delete") - setDeleted(short, i); - - $("#" + short + "_editbutton_" + i).removeClass("list-group-item-info").addClass("list-group-item-warning"); - $("#" + short + "_editbutton_" + i).html("
Undo"); - $("#" + short + "_editbutton_" + i).off('click').on("click", function() { - undoEdit(short, i); - }); - $("#" + short + "_deletebutton_" + i).removeClass("list-group-item-danger").addClass("disabled"); - $("#" + short + "_deletebutton_" + i).off('click').on("click", function() { - return false; - }); - - $("#" + short + "_panel_" + i).removeClass("panel-default").addClass("alert-info").addClass("edited-component"); - - return subMakeEditable(short, i); -} - -/** - * Make a data object editable - * - * Make the GUI pane for a given constellation object (short, i) editable. Handles removing the read-only - * statuses and changing divs into selects. - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - * @return boolean False to play nice with the browser - */ -function subMakeEditable(short, i) { - // No editing if it's already in edit mode - if ($("#" + short + "_operation_" + i).val() == "update") - return false; - - // Add to the undo set - undoSet[short + "-" + i] = $("#"+short+"_datapart_" + i).clone(); - - - textToInput(short, i); - textToTextArea(short, i); - textToCheckbox(short, i); - - var idstr = "_" + i; - - // Enable buttons - $("#"+short+"_datapart_" + i + " button[id^='"+short+"_']").each(function() { - var obj = $(this); - if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { - obj.removeAttr("disabled").removeClass("snac-hidden"); - } - }); - // Enable buttons - $("#"+short+"_datapart_" + i + " a.label").each(function() { - $(this).removeClass("snac-hidden"); - }); - - // Enable checkboxes - $("#"+short+"_datapart_" + i + " input[type='checkbox']").each(function() { - var obj = $(this); - if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { - obj.bootstrapToggle('enable'); - } - }); - - // Turn on CodeMirror Editors - $("#"+short+"_datapart_" + i + " textarea[id^='"+short+"_']").each(function() { - var obj = $(this); - if(obj.attr('id').endsWith(idstr) - && !obj.attr('id').endsWith("ZZ")) { - // remove the short name from the string we're parsing - var idStr = obj.attr('id').replace(short, ""); - if (idStr.indexOf('_text_') != -1 || idStr.indexOf('_source_') != -1) { - obj.get(0).CodeMirror = CodeMirror.fromTextArea(obj.get(0), { - lineNumbers: true, - lineWrapping: true, - viewportMargin: Infinity, - mode: {name: "xml"} - }); - } - } - }); - var sawSelect = false; - $("#"+short+"_datapart_" + i + " select[id^='"+short+"_']").each(function() { - var obj = $(this); - if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { - sawSelect = true; - } - }); - - if (!sawSelect) { - textToSelect(short, i); - textToGeoPlaceSelect(short, i); - textToDate(short, i); - } - - // Make things re-orderable if something exists - // $( "#nameEntry_component_ui_0" ).sortable({ // id of the container containing sortable things - // items : '.name_component' // class of the things that are sortable. They MUST have ids - // }); - $("#"+short+"_datapart_" + i + " span.move-handle").each(function() { - $(this).removeClass("snac-hidden"); - }); - $( "#"+short+"_reorderable_"+i ).sortable({ - items : '.reorderable', - opacity : 0.5, - update : function( event, ui ) { - var neworder = $( "#"+short+"_reorderable_"+i ).sortable("toArray"); - console.log(neworder); - neworder.forEach(function(orderedID, index) { - $("#"+orderedID + " input.order-index").val(index); - }); - if (short == "nameEntry") - updateNameEntryHeading(i); - } - }); - - // Make the relation pictures update appropriately - if (short == 'constellationRelation') { - // make the role dropdown affect the picture - $('#'+short+'_type_id_'+i).change(function() { - updatePictureArrow(short, i, - $('#'+short+'_type_id_'+i+' option:selected').text()); - }); - - } - if (short == 'resourceRelation') { - // make the role dropdown affect the picture - $('#'+short+'_role_id_'+i).change(function() { - updatePictureArrow(short, i, - $('#'+short+'_role_id_'+i+' option:selected').text()); - }); - } - // Places should update the place heading - if (short == 'place') { - // If there is a value pre-set, then automatically confirm and update - if ($('#'+short+'_geoplace_id_'+i).val() != null && $('#'+short+'_geoplace_id_'+i).val() != "") { - updatePlaceHeading(short, i, $('#'+short+'_geoplace_id_'+i).val()); - } - // make the role dropdown affect the picture - $('#'+short+'_geoplace_id_'+i).change(function() { - updatePlaceHeading(short, i, - $('#'+short+'_geoplace_id_'+i).val()); - }); - } - - // add parser btn if nameEntry is a computed name, entity is person, and if no btn or extra name components already exist - if (short === 'nameEntry' && ($("#entityType").val() === "700") && - ($("#nameEntry_component_0_panel_" + i).find('select:first').text() === "Name") && - (!$("#nameEntry_panel_" + i).find('.name-parser').length && - $("#nameEntry_component_1_panel_" + i).length === 0)) { - $('#nameEntry_component_add_' + i).after(''); - } - - // Set this data's operation value appropriately - if ($("#" + short + "_id_" + i).val() != "") - $("#" + short + "_operation_" + i).val("update"); - else - $("#" + short + "_operation_" + i).val("insert"); - - // Asked to edit something, so make it globally known - setEditedFlag(true); - //somethingHasBeenEdited = true; - - return false; -} - -/** - * Make a data object uneditable - * - * Make each object in the GUI page for the given piece uneditable by turning them back to text. Also - * takes the color away from the pane and removes the operation flag. - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - * @return boolean False to play nice with the browser - */ -function subMakeUneditable(shortName, i) { - - // Make inputs read-only - var idstr = "_" + i; - - - // Turn off the reordering js - $("#"+shortName+"_datapart_" + i + " span.move-handle").each(function() { - $(this).addClass("snac-hidden"); - }); - if ($( "#"+shortName+"_reorderable_"+i ).hasClass("ui-sortable")) - $( "#"+shortName+"_reorderable_"+i ).sortable("destroy"); - - // Remove CodeMirror editors - $("#"+shortName+"_datapart_" + i + " textarea[id^='"+shortName+"_']").each(function() { - var obj = $(this); - if(obj.attr('id').endsWith(idstr) - && !obj.attr('id').endsWith("ZZ") - && (obj.attr('id').indexOf('_text_') != -1 || obj.attr('id').indexOf('_source_') != -1)) { - - if (obj.get(0).CodeMirror) { - obj.get(0).CodeMirror.toTextArea(); - } - //(document.getElementById(obj.attr('id'))).CodeMirror.toTextArea(); - //obj.get(0).CodeMirror.toTextArea(); - } - }); - // Disable buttons - $("#"+shortName+"_datapart_" + i + " button[id^='"+shortName+"_']").each(function() { - var obj = $(this); - if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { - obj.attr("disabled", "true").addClass("snac-hidden"); - } - }); - - // Disable buttons - $("#"+shortName+"_datapart_" + i + " a.label").each(function() { - $(this).addClass("snac-hidden"); - }); - - // Disable checkboxes - $("#"+shortName+"_datapart_" + i + " input[type='checkbox']").each(function() { - var obj = $(this); - if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { - obj.bootstrapToggle("disable"); - } - }); - - inputToText(shortName, i); - textAreaToText(shortName, i); - checkboxToText(shortName, i); - // Check for a select box - var sawSelect = false; - $("#"+shortName+"_datapart_" + i + " select[id^='"+shortName+"_']").each(function() { - var obj = $(this); - if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { - sawSelect = true; - } - }); - // If a select box was seen, undo it - if (sawSelect) { - selectToText(shortName, i); - geoPlaceSelectToText(shortName, i); - dateToText(shortName,i); - } - - - // Clear the operation flags - //$("#" + shortName + "_operation_" + i).val(""); - $("#"+shortName+"_datapart_" + i + " input[id^='"+shortName+"_']").each(function() { - var obj = $(this); - if(obj.attr('id').endsWith("_operation" + idstr) && !obj.attr('id').endsWith("ZZ")) { - obj.val(""); - } - }); - - $("#" + shortName + "_panel_" + i).addClass("panel-default").removeClass("alert-info").removeClass("edited-component"); - - - -} - -/** - * Make a data object uneditable - * - * Make the GUI pane for a given constellation object (short, i) un-editable. Sets up the edit and delete - * buttons for first-order data objects, and calls the function to turn the elements back to text. - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - * @return boolean False to play nice with the browser - */ -function makeUneditable(shortName, i) { - // Make inputs read-only - var idstr = "_" + i; - - subMakeUneditable(shortName, i); - - // restore the edit button - $("#" + shortName + "_editbutton_" + i).addClass("list-group-item-info").removeClass("list-group-item-warning"); - $("#" + shortName + "_editbutton_" + i).html("
Edit"); - $("#" + shortName + "_editbutton_" + i).off('click').on("click", function() { - makeEditable(shortName, i); - }); - - // restore the delete button - $("#" + shortName + "_deletebutton_" + i).addClass("list-group-item-danger").removeClass("disabled"); - $("#" + shortName + "_deletebutton_" + i).off('click').on("click", function() { - setDeleted(shortName, i); - }); - - return false; -} - -/** - * Make an SCM data object editable - * - * Make the GUI pane for an SCM (j) of a given constellation object (short, i) editable. Sets up the edit and delete - * buttons for first-order data objects. - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - * @param string|int j The index within the data object SCM list on the edit page of the SCM object. - * @return boolean False to play nice with the browser - */ -function makeSCMEditable(shortName, i, j) { - var id = j + "_" + i; - var scmShortName = "scm_" + shortName; - - // No editing if it's already in edit mode - if ($("#" + scmShortName + "_operation_" + id).val() == "update") - return false; - // If it's deleted, then you better undelete it first - if ($("#" + scmShortName + "_operation_" + id).val() == "delete") - setSCMDeleted(shortName, i, j); - - $("#" + scmShortName + "_editbutton_" + id).removeClass("list-group-item-info").addClass("list-group-item-warning"); - $("#" + scmShortName + "_editbutton_" + id).html(""); - $("#" + scmShortName + "_editbutton_" + id).off('click').on("click", function() { - undoSCMEdit(shortName, i, j); - }); - $("#" + scmShortName + "_deletebutton_" + id).removeClass("list-group-item-danger").addClass("disabled"); - $("#" + scmShortName + "_deletebutton_" + id).off('click').on("click", function() { - return false; - }); - - $("#" + scmShortName + "_panel_" + id).removeClass("panel-default").addClass("alert-info").addClass("edited-component"); - - return subMakeEditable(scmShortName, id); -} - -/** - * Make an SCM data object un-editable - * - * Make the GUI pane for an SCM object (j) for a given constellation object (short, i) un-editable. Sets up the edit and delete - * buttons for SCM data objects. - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - * @param string|int j The index within the data object SCM list on the edit page of the SCM object. - * @return boolean False to play nice with the browser - */ -function makeSCMUneditable(shortName, i, j) { - - // Make inputs read-only - var idstr = j + "_" + i; - - subMakeUneditable('scm_'+shortName, idstr); - - // restore the edit button - $("#scm_" + shortName + "_editbutton_" + idstr).addClass("list-group-item-info").removeClass("list-group-item-warning"); - $("#scm_" + shortName + "_editbutton_" + idstr).html(""); - $("#scm_" + shortName + "_editbutton_" + idstr).off('click').on("click", function() { - makeSCMEditable(shortName, i, j); - }); - - // restore the delete button - $("#scm_" + shortName + "_deletebutton_" + idstr).addClass("list-group-item-danger").removeClass("disabled"); - $("#scm_" + shortName + "_deletebutton_" + idstr).off('click').on("click", function() { - setSCMDeleted(shortName, i, j); - }); - - return false; -} - -/** - * Set a Contributor Object as deleted - * - * Sets the contributor object (shortName, i) as deleted or undeleted and makes the appropriate changes. - * - * @param string shortName The short name of the contributor object. - * @param string|int i The index within the edit page of the object. - */ -function setRepeatedDataDeleted(shortName, i) { - if ($("#" + shortName + "_operation_" + i).val() != "delete") { - $("#" + shortName + "_remove_" + i).removeClass("btn-danger").addClass("btn-warning"); - $("#" + shortName + "_remove_" + i).html(""); - } else { - $("#" + shortName + "_remove_" + i).removeClass("btn-warning").addClass("btn-danger"); - $("#" + shortName + "_remove_" + i).html(""); - } - - return subSetDeleted(shortName, i); -} - -/** - * Set a first-order data object as deleted - * - * Sets a first-order data object (short, i) as deleted or undeleted and makes the appropriate changes throughout the page. - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - */ -function setDeleted(short, i) { - if ($("#" + short + "_operation_" + i).val() != "delete") { - // set deleted - $("#" + short + "_deletebutton_" + i).removeClass("list-group-item-danger").addClass("list-group-item-warning"); - $("#" + short + "_deletebutton_" + i).html("
Undo"); - - // disable edit button - $("#" + short + "_editbutton_" + i).removeClass("list-group-item-info").addClass("disabled"); - $("#" + short + "_editbutton_" + i).off('click').on("click", function() { - return false; - }); - - // disable the Date button - $("#" + short + "_datebutton_" + i).removeClass("list-group-item-success").addClass("disabled").prop('disabled', true); - - // disable the SCM button - $("#" + short + "_scmbutton_" + i).removeClass("list-group-item-success").addClass("disabled").prop('disabled', true); - - } else { - // set undelete - $("#" + short + "_deletebutton_" + i).removeClass("list-group-item-warning").addClass("list-group-item-danger"); - $("#" + short + "_deletebutton_" + i).html("
Trash"); - - // restore edit button - $("#" + short + "_editbutton_" + i).addClass("list-group-item-info").removeClass("disabled"); - $("#" + short + "_editbutton_" + i).off('click').on("click", function() { - makeEditable(short, i); - }); - - // restore the Date button - $("#" + short + "_datebutton_" + i).addClass("list-group-item-success").removeClass("disabled").prop('disabled', false); - - // restore the SCM button - $("#" + short + "_scmbutton_" + i).addClass("list-group-item-success").removeClass("disabled").prop('disabled', false); - - } - - return subSetDeleted(short, i); -} - -/** - * Make the delete/undelete happen - * - * Actually performs the changes to the object, affecting the operation and panel color. - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - * @return boolean False to play nice with the browser - */ -function subSetDeleted(short, i) { - if ($("#" + short + "_operation_" + i).val() != "delete") { - // set deleted - $("#" + short + "_panel_" + i).removeClass("panel-default").addClass("alert-danger").addClass("deleted-component"); - - $("#" + short + "_operation_" + i).val("delete"); - } else { - // set undelete - $("#" + short + "_panel_" + i).removeClass("alert-danger").addClass("panel-default").removeClass("deleted-component"); - - // If this thing was deleted but is supposed to be an update, then return it back to update status - var sawSelect = false; - $("select[id^='"+short+"_']").each(function() { - var obj = $(this); - if(obj.attr('id').endsWith("_" + i) && !obj.attr('id').endsWith("ZZ")) { - sawSelect = true; - } - }); - if (sawSelect) { - if ($("#" + short + "_id_" + i).val() != "") - $("#" + short + "_operation_" + i).val("update"); - else - $("#" + short + "_operation_" + i).val("insert"); - } else { - $("#" + short + "_operation_" + i).val(""); - } - - } - - // Asked to delete something, so make it globally known - setEditedFlag(true); - //somethingHasBeenEdited = true; - - return false; -} - -/** - * Set an SCM data object as deleted - * - * Sets an SCM object (j) for a constellation object (short, i) as deleted or undeleted and makes the appropriate changes throughout the page. - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - * @param string|int j The index within the data object SCM list on the edit page of the SCM object. - */ -function setSCMDeleted(short, i, j) { - var id = j + '_' + i; - if ($("#scm_" + short + "_operation_" + id).val() != "delete") { - // set deleted - $("#scm_" + short + "_deletebutton_" + id).removeClass("list-group-item-danger").addClass("list-group-item-warning"); - $("#scm_" + short + "_deletebutton_" + id).html(""); - - // disable edit button - $("#scm_" + short + "_editbutton_" + id).removeClass("list-group-item-info").addClass("disabled"); - $("#scm_" + short + "_editbutton_" + id).off('click').on("click", function() { - return false; - }); - - } else { - // set undelete - $("#scm_" + short + "_deletebutton_" + id).removeClass("list-group-item-warning").addClass("list-group-item-danger"); - $("#scm_" + short + "_deletebutton_" + id).html(""); - - // restore edit button - $("#scm_" + short + "_editbutton_" + id).addClass("list-group-item-info").removeClass("disabled"); - $("#scm_" + short + "_editbutton_" + id).off('click').on("click", function() { - makeSCMEditable(short, i, j); - }); - - } - - return subSetDeleted("scm_"+short, id); -} - -/** - * Turn on the Edit/Delete buttons for an object - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - */ -function turnOnButtons(shortName, i) { - - // Turn on the edit button - $("#"+shortName+"_editbutton_"+i).on("click", function() { - makeEditable(shortName, i); - }); - - // Turn on the delete buttons - $("#"+shortName+"_deletebutton_"+i).on("click", function() { - setDeleted(shortName, i); - }); -} - -function turnOnTooltips(shortName, i) { - // Load tooltips - $(function () { - $('#'+shortName+'_panel_'+ i +' [data-toggle="tooltip"]').tooltip() - }) - - // Load popovers - $(function () { - $('#'+shortName+'_panel_'+ i +' [data-toggle="popover"]').popover({ - trigger: 'hover', - container: 'body' - }) - }) - - -} - -/** - * Turn on the Edit/Delete buttons for an SCM object - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int i The index within the edit page of the object. - * @param string|int j The index within the data object SCM list on the edit page of the SCM object. - */ -function turnOnSCMButtons(shortName, i, j) { - - // Turn on the edit button - $("#scm_"+shortName+"_editbutton_"+j+"_"+i).on("click", function() { - makeSCMEditable(shortName, i, j); - }); - - // Turn on the delete buttons - $("#scm_"+shortName+"_deletebutton_"+j+"_"+i).on("click", function() { - setSCMDeleted(shortName, i, j); - }); -} - -/** - * Create a new Address Line object on page - * - * Puts a new Place Address Line object DIV on the page and attaches it correctly to the DOM and javascript. - * - * @param int i The index on the page of the place to add this component to - * @return boolean false to play nice with the browser. - */ -function newAddressLine(i) { - var nextid = 1; - if ($('#place_address_next_j_'+i).exists()) { - nextid = parseInt($('#place_address_next_j_'+i).text()); - } - console.log("Creating new address line for place " + i + " with id: " + nextid); - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#addressline_template').clone(); - var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid); - $('#place_address_add_div_'+i).before(html); - - $('#place_address_' + nextid + '_operation_' + 1).val("insert"); - subMakeEditable("place_address_" + nextid, i); - - vocab_select_replace($("#place_address_"+nextid+"_type_id_"+i), "_"+i, 'address_part', 0); - - // Put the updated version number back in the DOM - $('#place_address_next_j_'+i).text(++nextid); - - return false; -} - -/** - * Create a new Resource Relation Origination Name object on page - * - * Puts a new Resource Relation Origination Name object DIV on the page and attaches it correctly to the DOM and javascript. - * - * @param int i The index on the page of the Resource Relation to add this Origination Name to - * @return boolean false to play nice with the browser. - */ -function newOriginationName(i) { - var nextid = 1; - if ($('#resource_originationName_next_j_'+i).exists()) { - nextid = parseInt($('#resource_originationName_next_j_'+i).text()); - } - console.log("Creating new origination name for resource " + i + " with id: " + nextid); - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#originationName_template').clone(); - var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid); - $('#resource_originationName_add_div_'+i).before(html); - - $('#resource_originationName_' + nextid + '_operation_' + 1).val("insert"); - subMakeEditable("resource_originationName_" + nextid, i); - - // Put the updated version number back in the DOM - $('#resource_originationName_next_j_'+i).text(++nextid); - - return false; -} - - -/** - * Create a new Name Entry Component object on page - * - * Puts a new Name Entry component object DIV on the page and attaches it correctly to the DOM and javascript. - * - * @param int i The index on the page of the nameEntry to add this component to - * @return boolean false to play nice with the browser. - */ -function newNameEntryComponent(i) { - removeParserButton(i); - var nextid = 1; - if ($('#nameEntry_component_next_j_'+i).exists()) { - nextid = parseInt($('#nameEntry_component_next_j_'+i).text()); - } - console.log("Creating new name entry component for nameEntry " + i + " with id: " + nextid); - - // add parser btn if entity is person, and if no btn or other name components already exist - if (($("#entityType").val() === "700") && (nextid == 0) && - (!$("#nameEntry_panel_" + i).find('.name-parser').length && - $("#nameEntry_component_1_panel_" + i).length === 0)) { - $('#nameEntry_component_add_' + i).after(''); - } - - setEditedFlag(true); - //somethingHasBeenEdited = true; - - var text = $('#component_template').clone(); - var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid); - $('#nameEntry_component_add_div_'+i).before(html); - - $('#nameEntry_component_' + nextid + '_operation_' + 1).val("insert"); - subMakeEditable("nameEntry_component_" + nextid, i); - - vocab_select_replace($("#nameEntry_component_"+nextid+"_type_id_"+i), "_"+i, 'name_component', 0); - - // Put the updated version number back in the DOM - $('#nameEntry_component_next_j_'+i).text(++nextid); - - return false; -} - -function updateNameEntryHeading(i) { - var text = ""; - var components = []; - - $("#nameEntry_panel_"+i+" div[id^='nameEntry_component_']").each(function() { - var obj = $(this); - if (!obj.hasClass("deleted-component") && obj.attr('id').endsWith("_panel_" + i) - && !obj.attr('id').endsWith("ZZ")) { - var j = obj.attr('id').replace("nameEntry_component_", "").replace("_panel_"+i, ""); - var type = $("#nameEntry_component_"+j+"_type_id_"+i+" option:selected").text(); - var partText = $("#nameEntry_component_"+j+"_text_"+i).val(); - - components.push([type, partText]); - } - }); - - var entityType = $("#entityType option:selected").text(); - text = combineNameHeading(components, entityType); - - - $("#nameEntry_heading_"+i).text(text.trim()); - $("#nameEntry_original_"+i).val(text.trim()); -} - - -/** - * Create a new Name Entry Rules object on page - * - * Puts a new Name Entry rule object DIV on the page and attaches it correctly to the DOM and javascript. - * - * @param int i The index on the page of the nameEntry to add this rule to - * @return boolean false to play nice with the browser. - */ -function newNameEntryRule(i) { - var nextid = 1; - if ($('#nameEntry_rule_next_j_'+i).exists()) { - nextid = parseInt($('#nameEntry_rule_next_j_'+i).text()); - } - console.log("Creating new name entry rule for nameEntry " + i + " with id: " + nextid); - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#rule_template').clone(); - var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid); - $('#nameEntry_rule_add_div_'+i).before(html); - - $('#nameEntry_rule_' + nextid + '_operation_' + 1).val("insert"); - turnOnTooltips("nameEntry_rule_" + nextid, i); - subMakeEditable("nameEntry_rule_" + nextid, i); - - // Put the updated version number back in the DOM - $('#nameEntry_rule_next_j_'+i).text(++nextid); - - return false; -} - -/** - * Parse a date string into parts - */ -function parseDate(dateString) { - var pieces = dateString.split("-"); - if (pieces.length == 3) - return { - year : parseInt(pieces[0]), - month : parseInt(pieces[1]), - day : parseInt(pieces[2]) - }; - else if (pieces.length == 2) - return { - year : parseInt(pieces[0]), - month : parseInt(pieces[1]), - day : '' - }; - else if (pieces.length == 1 && pieces[0] != '') - return { - year : parseInt(pieces[0]), - month : '', - day : '' - }; - else return { - year : '', month : '', day : '' - } -} - -/** - * Change date input divs to select and boxes - * - * Changes all div's with id "date_" for a given data object (shortName, idStr) from a list of - * inputs defining the parameters (view mode) to a inputs and a select (edit mode). It then - * calls the select2 function to replace the select with one matching the rest of the page. - * - * Note: idStr must not have the "_" pre-appended - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int idStr The index within the edit page of the object. - */ -function textToDate(shortName, idStr) { - $("div[id^='date_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace("date_", "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - var dateStr = $("#"+shortName+"_"+name+"_"+idStr).val(); - - var dateParts = parseDate(dateStr); - - var html = ""; - html += " - "; - html += " "; - html += " - "; - html += " "; - html += ""; - cont.html(html); - - $("#"+shortName+"_"+name+"_month_"+idStr).select2({ - width: '57%', - allowClear: true, - theme: 'bootstrap', - placeholder: 'Month' - }); - - } - }); -} - -/** - * Pad an integer - * - * This is a helper function to pad an integer with 0s for display. This is useful to pad - * a month or day with a leading 0. - * - * @param int|string num The number to pad - * @param int size The total width of the desired output - * @return string A string containing a size-wide integer representation, 0-padded - */ -function pad(num, size) { - var s = num+""; - while (s.length < size) s = "0" + s; - return s; -} - -/** - * Updates the standard date input field - * - * If the date for the data object (shortName, idStr) has been turned into a 3-field edit - * area, then this function will update the hidden standard date (YYYY-MM-DD) field with the - * newest values from the human-enterable field. - * - * Note: idStr must not have the "_" pre-appended - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int idStr The index within the edit page of the object. - */ -function updateDate(shortName, idStr) { - $("div[id^='date_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace("date_", "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - - if ($("#"+shortName+"_"+name+"_year_"+idStr).exists()) { - var year = $("#"+shortName+"_"+name+"_year_"+idStr).val(); - var day = $("#"+shortName+"_"+name+"_day_"+idStr).val(); - var month = $("#"+shortName+"_"+name+"_month_"+idStr+ " option:selected").val(); - - var dateStr = ""; - if (year != "") { - dateStr += pad(year, 4); - if (month != "") { - dateStr += "-" + pad(month,2); - if (day != "") { - dateStr += "-" + pad(day,2); - } - } - } - - $("#"+shortName+"_"+name+"_"+idStr).val(dateStr); - } - - } - }); -} - -/** - * Return editable date area back to text - * - * If the date for the data object (shortName, idStr) has been turned into a 3-field edit - * area, then this function will return the editable area back to the view mode text, replacing - * the edit boxes with a paragraph containing the computed standard date string (YYYY-MM-DD). - * - * Note: idStr must not have the "_" pre-appended - * - * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" - * @param string|int idStr The index within the edit page of the object. - */ -function dateToText(shortName, idStr) { - $("div[id^='date_"+shortName+"']").each(function() { - var cont = $(this); - if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { - // remove the short name and "select_" from the string we're parsing - var divStr = cont.attr('id').replace("date_", "").replace(shortName + "_", ""); - // remove the idstr to receive the name of this element - var regex = new RegExp("\_"+idStr+"$", "g"); - var name = divStr.replace(regex, ""); - - updateDate(shortName, idStr); - - - var dateStr = $("#"+shortName+"_"+name+"_"+idStr).val(); - - var html = "

"+dateStr+"

"; - html += ""; - cont.html(html); - - } - }); -} - - -// TODO: If we want to show a DIV of edited and deleted components, we should use the following two functions -// to get copies of the edited/deleted components from the page. We can then insert those copies onto a modal -// dialog box with a "Save" or "Continue" button at the top and bottom. -// -// All the pieces shown in the dialog should be disabled. One way to do this would be using the following -// method to place a semi-transparent div on top of the editable pieces, making them appear to be grayed out -// and with the not permitted cursor. -// -// .append('
'); -// -// Note: this modal should NOT be inside the constellation form so that we don't submit the values twice. - -/** - * Get all the edited components - */ -function getEdited() { - var html = ""; - - $("#constellation_form div.edited-component").each(function() { - var cont = $(this); - console.log(cont.attr('id')); - var pieces = cont.attr('id').split("_panel_"); - if (pieces.length == 2) { - html += "
" + $("#"+pieces[0] + "_datapart_" + pieces[1]).html() + "
"; - } - }); - - return html; -} - -/** - * Get all the deleted components - */ -function getDeleted() { - var html = ""; - - $("#constellation_form div.deleted-component").each(function() { - var cont = $(this); - console.log(cont.attr('id')); - var pieces = cont.attr('id').split("_panel_"); - if (pieces.length == 2) { - html += "
" + $("#"+pieces[0] + "_datapart_" + pieces[1]).html() + "
"; - } - }); - - return html; -} - -function turnOnEditDeleteButtons(part='') { - var divID = ''; - if (part != '') - divID = "#" + part + " "; - // Turn on the edit buttons - $(divID + "a[id*='editbutton']").each(function() { - var obj = $(this); - var pieces = obj.attr('id').split("_"); - - if (pieces.length == 3) { - var short = pieces[0]; - var i = pieces[2]; - obj.on("click", function() { - makeEditable(short, i); - }); - } else if (pieces.length == 5 && pieces[0] == "scm") { - var short = pieces[1]; - var i = pieces[4]; - var j = pieces[3]; - obj.on("click", function() { - makeSCMEditable(short, i, j); - }); - } else if (pieces.length == 5) { - var short = pieces[0] + "_" + pieces[1] + "_" + pieces[2]; - var i = pieces[4]; - obj.on("click", function() { - makeEditable(short, i); - }); - } - }); - - // Turn on the delete buttons - $(divID + "a[id*='deletebutton']").each(function() { - var obj = $(this); - var pieces = obj.attr('id').split("_"); - - if (pieces.length == 3) { - var short = pieces[0]; - var i = pieces[2]; - obj.on("click", function() { - setDeleted(short, i); - }); - } else if (pieces.length == 5 && pieces[0] == "scm") { - var short = pieces[1]; - var i = pieces[4]; - var j = pieces[3]; - obj.on("click", function() { - setSCMDeleted(short, i, j); - }); - } else if (pieces.length == 5) { - var short = pieces[0] + "_" + pieces[1] + "_" + pieces[2]; - var i = pieces[4]; - obj.on("click", function() { - setDeleted(short, i); - }); - } - }); -} - -function turnOnTooltipsForTab(part='') { - var divID = ''; - if (part != '') - divID = "#" + part + " "; - // Load tooltips - $(function () { - $(divID + '[data-toggle="tooltip"]').tooltip() - }) - - // Load popovers - $(function () { - $(divID + '[data-toggle="popover"]').popover({ - trigger: 'hover', - container: 'body' - }) - }) - -} - -function updatePictureArrow(shortName, i, newValue) { - $('#'+shortName+'_relationPictureArrow_'+i).text(newValue); -} - -function updatePictureTitle(shortName, i, newValue) { - $('#'+shortName+'_relationPictureTitle_'+i).text(newValue); -} - -function updatePictureIcon(shortName, i, entityType) { - var html = ""; - if (entityType == 'person') - html = '
'; - else if (entityType == 'corporateBody') - html = '
'; - else if (entityType == 'family') - html = '
'; - $('#'+shortName+'_relationPictureIcon_'+i).html(html); -} - - -var geoPlaceLoadResults = null; - -function loadGeoPlaceResultCache() { - $("input[id^='place_geoplace_id_']").each(function() { - var obj = $(this); - // Query for term by ajax - if (obj.val() != null && obj.val() != "") { - $.get(snacUrl+"/vocabulary/read?type=geoPlace&id="+obj.val(), null, function (data) { - // Check the return value from the ajax. If success, then go to dashboard - if (data.term) { - if (!geoPlaceLoadResults) - geoPlaceLoadResults = new Array(); - geoPlaceLoadResults.push(data.term); - } - }); - } - }); -} - -function chooseSuggestedGeoPlace(selectID, idStr, value) { - // idStr == id number on the page - var obj = $("#"+selectID); - obj.select2('destroy'); - obj.val(value); - geovocab_select_replace(obj, "_"+idStr); - updatePlaceHeading("place", idStr, value); -} - -function updatePlaceHeading(shortName, i, newValue) { - var place = null; - if (!geoPlaceSearchResults && !geoPlaceLoadResults) { - $('#'+shortName+'_confirmed_'+i).val("false"); - $('#'+shortName+'_geoterm_text_'+i).html("Unconfirmed"); - $('#'+shortName+"_geoterm_maplink_"+i).addClass("disabled"); - $('#'+shortName+"_geoterm_maplink_"+i).prop('onclick',null).off("click"); - if ($('#'+shortName+'_original_'+i).val() != "") - $('#'+shortName+'_geoterm_caption_'+i).text("Recorded as: " + $('#'+shortName+'_original_'+i).val()); - else - $('#'+shortName+'_geoterm_caption_'+i).text(); - return; - } - - if (geoPlaceSearchResults) { - geoPlaceSearchResults.forEach(function(result) { - if (result.id == newValue) - place = result; - }); - } - - if (!place && geoPlaceLoadResults) { - geoPlaceLoadResults.forEach(function(result) { - if (result.id == newValue) - place = result; - }); - } - - if (!place) { - $('#'+shortName+'_confirmed_'+i).val("false"); - $('#'+shortName+"_geoterm_maplink_"+i).addClass("disabled"); - $('#'+shortName+"_geoterm_maplink_"+i).off("click"); - if ($('#'+shortName+'_original_'+i).val() != "") { - $('#'+shortName+'_geoterm_text_'+i).html("Unconfirmed"); - $('#'+shortName+'_geoterm_caption_'+i).text("Recorded as: " + $('#'+shortName+'_original_'+i).val()); - } else { - $('#'+shortName+'_geoterm_text_'+i).text("--"); - $('#'+shortName+'_geoterm_caption_'+i).text("GeoPlace term not specified"); - } - return; - } - $('#'+shortName+'_confirmed_'+i).val("true"); - $('#'+shortName+'_geoterm_text_'+i).text(place.name); - $('#'+shortName+'_geoterm_caption_'+i).text(place.administrationCode + ", " + place.countryCode); - if (place.latitude && place.longitude) { - $('#'+shortName+"_geoterm_maplink_"+i).prop('onclick',null).off("click"); - $('#'+shortName+"_geoterm_maplink_"+i).on("click", function() {openGeoPlaceViewer(place.id); return false;}); - $('#'+shortName+"_geoterm_maplink_"+i).removeClass("disabled"); - } else { - $('#'+shortName+"_geoterm_maplink_"+i).addClass("disabled"); - $('#'+shortName+"_geoterm_maplink_"+i).prop('onclick',null).off("click"); - } - - -} - -function magicDefaultFill(selectID, vocabType) { - if (typeof(defaults[vocabType]) !== undefined) { - - var data = { - id: defaults[vocabType].id, - text: defaults[vocabType].term - }; - - // If the selected item exists, then select it. Else, add a new option - // and select it. - if ($('#'+selectID).find("option[value='" + data.id + "']").length) { - $('#'+selectID).val(data.id).trigger('change'); - } else { - var newOption = new Option(data.text, data.id, false, true); - $('#'+selectID).append(newOption).trigger('change'); - } - } - -} - -function capitalize(word) { - return word[0].toUpperCase() + word.slice(1); -} - -function parseName(e) { - $('#name-parser-options').text(''); - var $nameComponents = $(e.target).closest('.name-components'); - - var $partType = $nameComponents.find("select:last"); - var $textbox = $nameComponents.find('input[type="text"]:last'); - - var name = $textbox.val(); - - var entityType = $('#entityType').text().trim(); - $('#name-parser-type').text(capitalize(entityType)); - $('#name-parser-original').text(name); - - var parser = new NameParser(); - guesses = parser.guessPerson(name); - - var parsedOption = ''; - - var counter = 0; - guesses.forEach(function(guess) { - // attach name data object to radio - for (var key in guess) { - if (guess[key] && guess[key].length != 0) { - parsedOption += "
  • " + key + ": " + guess[key] + "
  • "; - } - } - - $('#name-parser-options').append("
    " + - "
    "); - - - $('#name-parser-options').find("input[type='radio']:last").data("parsed-name", guess); - - parsedOption = ''; - counter++; - }) - - $('#name-parser-options').find("input[type='radio']:first").prop('checked', true) - - - $('#parser-accept-btn').unbind('click') - $('#parser-accept-btn').on('click', function() { - var selectedName = $('#name-parser input[type="radio"]:checked').data('parsed-name') - $.get( snacUrl + "/vocabulary/?type=name_component&entity_type=700") - .done(function(data) { - acceptParsedName(selectedName, $nameComponents, name, data.results) - }) - }) -} - -function acceptParsedName(selectedName, $nameComponents, name, nameComponentIDs) { - var i = $nameComponents.attr('id').split('_')[2]; - var $nameComponent = $nameComponents.find('.reorderable'); /// - $nameComponent.replaceWith('
    Name: ' + name + '
    '); - - var nameComponentMap = {}; - - for (var k = 0; k < nameComponentIDs.length; k++) { - nameComponentMap[nameComponentIDs[k].text] = nameComponentIDs[k].id - } - // var nameComponentMap = { - // 'Surname': 400223, - // 'Forename': 400224, - // 'NameAddition': 400236, - // 'Date': 400237, - // 'NameExpansion': 400226, - // 'Numeration': 400225 - // }; - - for (var key in selectedName) { - if (key == 'NameAdditions') { - key = 'NameAddition'; - for (var j = 0; j < selectedName['NameAdditions'].length; j++) { - newNameEntryComponent(i); - var option = new Option(key, nameComponentMap[key], false, true); - $partType = $nameComponents.find("select:last"); - $partType.append(option).trigger('change'); - $textbox = $nameComponents.find("input[type='text']:last"); - $textbox.val(selectedName["NameAdditions"][j]); - - $partType.append(option).trigger('change'); - } - } else if (selectedName[key] && nameComponentMap[key]) { - newNameEntryComponent(i); - var option = new Option(key, nameComponentMap[key], false, true); - $partType = $nameComponents.find("select:last"); - $partType.append(option).trigger('change'); - $textbox = $nameComponents.find("input[type='text']:last"); - $textbox.val(selectedName[key]); - - $partType.append(option).trigger('change'); - } - } - - $("#nameEntry_datapart_" + i).find(".name-parser").remove(); - updateNameEntryHeading(i); -} - -function removeParserButton(i) { - $('#nameEntry_datapart_' + i).find('.name-parser').remove(); -} - -/** - * Things to do when the page finishes loading - */ -$(document).ready(function() { - // Load the place cache, if needed - loadGeoPlaceResultCache(); - - // listen for name-parsing - $('#nameEntries').on('click', '.name-parser', function(event) { - event.preventDefault(); - parseName(event); - $("#name-parser").modal('toggle'); - }); - - $('#name-parser').on('shown.bs.modal', function () { - $('#parser-accept-btn').focus(); - }) - - // If the constellation is in "insert" mode, then we should automatically set "somethingHasBeenEdited" - // to be true... - if ($('#operation').val() == 'insert') - setEditedFlag(true); - //somethingHasBeenEdited = true; - - turnOnEditDeleteButtons(); - - // Attach functions to the entityType select - if ($('#entityType').exists()) { - $('#entityType').change(function() { - setEditedFlag(true); - //somethingHasBeenEdited = true; - // If there is an ID, then we need to set this to update - // Else, the main-level operation should be and remain insert - if ($('#constellationid').val() != null && - $('#constellationid').val() != "") { - $('#operation').val("update"); - } - }); - } - - // Name Entry doesn't get any AJAX, since it is pre-loaded - var nameEntryid = 1; - if ($('#next_nameEntry_i').exists()) { - nameEntryid = parseInt($('#next_nameEntry_i').text()); - } - console.log("Next NameEntry ID: " + nameEntryid); - if ($('#btn_add_nameEntry').exists()){ - $('#btn_add_nameEntry').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#nameEntry_template').clone(); - var html = text.html().replace(/ZZ/g, nameEntryid); - $('#add_nameEntry_div').after(html); - turnOnButtons("nameEntry", nameEntryid); - turnOnTooltips("nameEntry", nameEntryid); - makeEditable("nameEntry", nameEntryid); - nameEntryid = nameEntryid + 1; - return false; - }); - } - - - // Attach functions to each of the "+ Add New _______" buttons - - // Code to handle adding new genders to the page - var genderid = 1; - var genderOpen = false; - if ($('#genderstab').exists()){ - $('#genderstab').click(function(){ - // Don't open a second time - if (genderOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=genders", null, function (data) { - genderOpen = true; - $('#genders').html(data); - - turnOnEditDeleteButtons("genders"); - - if ($('#next_gender_i').exists()) { - genderid = parseInt($('#next_gender_i').text()); - } - console.log("Next Gender ID: " + genderid); - if ($('#btn_add_gender').exists()){ - $('#btn_add_gender').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#gender_template').clone(); - var html = text.html().replace(/ZZ/g, genderid); - $('#add_gender_div').after(html); - turnOnButtons("gender", genderid); - turnOnTooltips("gender", genderid); - makeEditable("gender", genderid); - genderid = genderid + 1; - return false; - }); - } - - turnOnTooltipsForTab("genders"); - }); - }); - } - - // Code to handle adding new genders to the page - var existid = 1; - var existOpen = false; - if ($('#existstab').exists()){ - $('#existstab').click(function(){ - // Don't open a second time - if (existOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=dates", null, function (data) { - existOpen = true; - $('#dates').html(data); - - turnOnEditDeleteButtons("dates"); - - if ($('#next_exist_i').exists()) { - existid = parseInt($('#next_exist_i').text()); - } - console.log("Next Exist Date ID: " + existid); - if ($('#btn_add_exist_date').exists()){ - $('#btn_add_exist_date').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#exist_date_template').clone(); - var html = text.html().replace(/ZZ/g, existid); - $('#add_exist_div').after(html); - turnOnButtons("exist", existid); - turnOnTooltips("exist", existid); - makeEditable("exist", existid); - existid = existid + 1; - return false; - }); - } - if ($('#btn_add_exist_dateRange').exists()){ - $('#btn_add_exist_dateRange').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#exist_dateRange_template').clone(); - var html = text.html().replace(/ZZ/g, existid); - $('#add_exist_div').after(html); - turnOnButtons("exist", existid); - turnOnTooltips("exist", existid); - makeEditable("exist", existid); - existid = existid + 1; - return false; - }); - } - - turnOnTooltipsForTab("dates"); - }); - }); - } - - var sameAsid = 1; - var sameAsOpen = false; - if ($('#sameAstab').exists()){ - $('#sameAstab').click(function(){ - // Don't open a second time - if (sameAsOpen) - return; - //set sameAs vocab type id - $.get(snacUrl+"/vocabulary?type=record_type&q=SameAs", null, function(data) { - sameAsTermId = data.results[0].id; - $("#sameAs_type_id_ZZ").val(sameAsTermId); - }); - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=sameAs", null, function (data) { - sameAsOpen = true; - $('#sameAs').html(data); - - turnOnEditDeleteButtons("sameAs"); - - if ($('#next_sameAs_i').exists()) { - sameAsid = parseInt($('#next_sameAs_i').text()); - } - console.log("Next sameAs ID: " + sameAsid); - if ($('#btn_add_sameAs').exists()){ - $('#btn_add_sameAs').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#sameAs_template').clone(); - var html = text.html().replace(/ZZ/g, sameAsid); - $('#add_sameAs_div').after(html); - turnOnButtons("sameAs", sameAsid); - turnOnTooltips("sameAs", sameAsid); - makeEditable("sameAs", sameAsid); - sameAsid = sameAsid + 1; - return false; - }); - } - - turnOnTooltipsForTab("sameAs"); - }); - }); - } - - - var entityIDid = 1; - var entityIDOpen = false; - if ($('#entityIDtab').exists()){ - $('#entityIDtab').click(function(){ - // Don't open a second time - if (entityIDOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=entityID", null, function (data) { - entityIDOpen = true; - $('#entityID').html(data); - - turnOnEditDeleteButtons("entityID"); - - if ($('#next_entityID_i').exists()) { - entityIDid = parseInt($('#next_entityID_i').text()); - } - console.log("Next entityID ID: " + entityIDid); - if ($('#btn_add_entityID').exists()){ - $('#btn_add_entityID').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#entityID_template').clone(); - var html = text.html().replace(/ZZ/g, entityIDid); - $('#add_entityID_div').after(html); - turnOnButtons("entityID", entityIDid); - turnOnTooltips("entityID", entityIDid); - makeEditable("entityID", entityIDid); - entityIDid = entityIDid + 1; - return false; - }); - } - - turnOnTooltipsForTab("entityID"); - }); - }); - } - - var sourceid = 1; - var sourceOpen = false; - if ($('#sourcestab').exists()){ - $('#sourcestab').click(function(){ - // Don't open a second time - if (sourceOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=sources", null, function (data) { - sourceOpen = true; - $('#sources').html(data); - - turnOnEditDeleteButtons("sources"); - - if ($('#next_source_i').exists()) { - sourceid = parseInt($('#next_source_i').text()); - } - console.log("Next source ID: " + sourceid); - if ($('#btn_add_source').exists()){ - $('#btn_add_source').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#source_template').clone(); - var html = text.html().replace(/ZZ/g, sourceid); - $('#add_source_div').after(html); - turnOnButtons("source", sourceid); - turnOnTooltips("source", sourceid); - makeEditable("source", sourceid); - sourceid = sourceid + 1; - return false; - }); - } - - turnOnTooltipsForTab("sources"); - }); - }); - } - - var resourceRelationid = 1; - var resourceRelationOpen = false; - if ($('#resourceRelationstab').exists()){ - $('#resourceRelationstab').click(function(){ - // Don't open a second time - if (resourceRelationOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=resourceRelations", null, function (data) { - resourceRelationOpen = true; - $('#resourceRelations').html(data); - - turnOnEditDeleteButtons("resourceRelations"); - - if ($('#next_resourceRelation_i').exists()) { - resourceRelationid = parseInt($('#next_resourceRelation_i').text()); - } - console.log("Next resourceRelation ID: " + resourceRelationid); - if ($('#btn_create_resourceRelation').exists()){ - $('#btn_create_resourceRelation').click(function(){ - var rid = $('input[name=resourceChoice]:checked', '#resource_search_form').val(); - if (rid != null && resourceResults != null && rid != 'new') { - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#resourceRelation_template').clone(); - var html = text.html().replace(/ZZ/g, resourceRelationid); - $('#add_resourceRelation_div').after(html); - - if (typeof resourceResults[rid].id !== 'undefined') - $('#resourceRelation_resourceid_'+resourceRelationid).val(resourceResults[rid].id); - if (typeof resourceResults[rid].version !== 'undefined') - $('#resourceRelation_resourceversion_'+resourceRelationid).val(resourceResults[rid].version); - - if (typeof resourceResults[rid].link !== 'undefined') - $('#resourceRelation_linkText_'+resourceRelationid).html(""+resourceResults[rid].link+"" + - " View"); - if (typeof resourceResults[rid].displayEntry !== 'undefined') - $('#resourceRelation_displayEntryText_'+resourceRelationid).text(resourceResults[rid].displayEntry); - if (typeof resourceResults[rid].title !== 'undefined') { - $('#resourceRelation_titleText_'+resourceRelationid).text(resourceResults[rid].title); - updatePictureTitle('resourceRelation', resourceRelationid, resourceResults[rid].title); - } - if (typeof resourceResults[rid].abstract !== 'undefined') - $('#resourceRelation_abstractText_'+resourceRelationid).text(resourceResults[rid].abstract); - if (typeof resourceResults[rid].extent !== 'undefined') - $('#resourceRelation_extentText_'+resourceRelationid).text(resourceResults[rid].extent); - // if (typeof resourceResults[rid].date !== 'undefined') - // $('#resourceRelation_dateText_'+resourceRelationid).text(resourceResults[rid].date); - if (typeof resourceResults[rid].documentType !== 'undefined' && typeof resourceResults[rid].documentType.term !== 'undefined') - $('#resourceRelation_documentTypeText_'+resourceRelationid).text(resourceResults[rid].documentType.term); - - $('#resourceRelation_linkText_'+resourceRelationid).after("View in SNAC"); - turnOnButtons("resourceRelation", resourceRelationid); - turnOnTooltips("resourceRelation", resourceRelationid); - makeEditable("resourceRelation", resourceRelationid); - resourceRelationid = resourceRelationid + 1; - $("#resource-results-box").html(""); - return true; - } - return false; - }); - } - - if ($('#btn_open_create_resource').exists()){ - $('#btn_open_create_resource').click(function(){ - // Close this modal and open the new modal - $("#resourceSearchPane").modal("hide"); - - // Set a 500ms timeout to give the hidden search pane time to fully close - setTimeout(function() {$("#resourceCreatePane").modal("show");}, 500); - - // Grab the empty template and replace - var text = $('#resource_template').clone(); - var html = text.html().replace(/ZZ/g, 0); - $('#resource-create-box').html(html); - var $resourceForm = $("#resource_create_form"); - // Copy the search contents to title or href - if ($("#resource-searchbox").val().indexOf("http") == -1) - $resourceForm.find("#resource-title").val($("#resource-searchbox").val()); - else - $resourceForm.find("#resource-url").val($("#resource-searchbox").val()); - - $resourceForm.find('[data-toggle="popover"]').popover({ - trigger: 'hover', - container: 'body' - }); - loadVocabSelectOptions($resourceForm.find("#resource-type-select"), "document_type", "Resource Type"); - vocab_select_replace($resourceForm.find("#resource-repo"), "", "holding", 3); - $resourceForm.find("#new-resource-language-btn").on("click", newResourceLanguage); - $resourceForm.find("#magic-resource-language-btn").on("click", magicNewResourceLanguage); - - $('#search-results-box').on("click", "a.list-group-item", selectHoldingRepository); - var timeoutID = null; - $resourceForm.find('#searchbox').keyup(function() { - clearTimeout(timeoutID); - timeoutID = setTimeout(function() { setSearchPosition(0); searchAndUpdate(); }, 500); - }); - - // Remove the search results from the other modal - $("#resource-results-box").html(""); - return false; - }); - } - - if ($('#btn_create_resource').exists()){ - $('#resource_create_form').on("submit", function(){ - // Remove leading and trailing whitespace - if ($("#resource_create_form #resource-url").val() == "") { - if (!confirm('Are you sure you want to save without an HREF?')) { - return; - } - } - $("#resource_create_form input, textarea").each(function() { - $(this).val($.trim($(this).val())); - }); - setDeletedResourceLanguageOperations($("#resource_create_form")); - - $.post(snacUrl+"/save_resource", $("#resource_create_form").serialize(), function (data) { - if (typeof data.result !== 'undefined' && data.result !== 'false') { - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#resourceRelation_template').clone(); - var html = text.html().replace(/ZZ/g, resourceRelationid); // clones DOM, replaces zz with next ids - $('#add_resourceRelation_div').after(html); - - if (typeof data.resource.id !== 'undefined') - $('#resourceRelation_resourceid_'+resourceRelationid).val(data.resource.id); - if (typeof data.resource.version !== 'undefined') - $('#resourceRelation_resourceversion_'+resourceRelationid).val(data.resource.version); - - if (typeof data.resource.link !== 'undefined') - $('#resourceRelation_linkText_'+resourceRelationid).html(""+data.resource.link+"" + - " View"); - if (typeof data.resource.displayEntry !== 'undefined') - $('#resourceRelation_displayEntryText_'+resourceRelationid).text(data.resource.displayEntry); - if (typeof data.resource.title !== 'undefined') { - $('#resourceRelation_titleText_'+resourceRelationid).text(data.resource.title); - updatePictureTitle('resourceRelation', resourceRelationid, data.resource.title); - } - if (typeof data.resource.abstract !== 'undefined') - $('#resourceRelation_abstractText_'+resourceRelationid).text(data.resource.abstract); - if (typeof data.resource.extent !== 'undefined') - $('#resourceRelation_extentText_'+resourceRelationid).text(data.resource.extent); - if (typeof data.resource.documentType !== 'undefined' && typeof data.resource.documentType.term !== 'undefined') - $('#resourceRelation_documentTypeText_'+resourceRelationid).text(data.resource.documentType.term); - - $('#resourceRelation_linkText_'+resourceRelationid).after("View in SNAC"); - turnOnButtons("resourceRelation", resourceRelationid); - turnOnTooltips("resourceRelation", resourceRelationid); - makeEditable("resourceRelation", resourceRelationid); - resourceRelationid = resourceRelationid + 1; - $("#resourceCreatePane").modal("hide"); - $('#resource-create-box').html(""); - return true; - } else { - console.log(data); - return false; - } - }); - return false; - }); - } - - turnOnTooltipsForTab("resourceRelations"); - }); - }); - } - - - var constellationRelationid = 1; - var constellationRelationOpen = false; - if ($('#constellationRelationstab').exists()){ - $('#constellationRelationstab').click(function(){ - // Don't open a second time - if (constellationRelationOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=constellationRelations", null, function (data) { - constellationRelationOpen = true; - $('#constellationRelations').html(data); - - turnOnEditDeleteButtons("constellationRelations"); - - if ($('#next_constellationRelation_i').exists()) { - constellationRelationid = parseInt($('#next_constellationRelation_i').text()); - } - console.log("Next constellationRelation ID: " + constellationRelationid); - if ($('#btn_create_constellationRelation').exists()){ - $('#btn_create_constellationRelation').click(function(){ - var cid = $('input[name=relationChoice]:checked', '#relation_search_form').val() - if (cid != null) { - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#constellationRelation_template').clone(); - var html = text.html().replace(/ZZ/g, constellationRelationid); - $('#add_constellationRelation_div').after(html); - $('#constellationRelation_targetID_'+constellationRelationid).val(cid); - $('#constellationRelation_content_'+constellationRelationid).val($('#relationChoice_nameEntry_'+cid).val()); - $('#constellationRelation_targetArkID_'+constellationRelationid).val($('#relationChoice_arkID_'+cid).val()); - $('#constellationRelation_targetEntityType_'+constellationRelationid).val($('#relationChoice_entityType_'+cid).val()); - - updatePictureIcon('constellationRelation', constellationRelationid, $('#relationChoice_entityTypeText_'+cid).val()); - updatePictureTitle('constellationRelation', constellationRelationid, $('#relationChoice_nameEntry_'+cid).val()); - - $('#constellationRelation_contentText_'+constellationRelationid).text($('#relationChoice_nameEntry_'+cid).val()); - $('#constellationRelation_targetArkIDText_'+constellationRelationid).text($('#relationChoice_arkID_'+cid).val()); - - turnOnButtons("constellationRelation", constellationRelationid); - turnOnTooltips("constellationRelation", constellationRelationid); - makeEditable("constellationRelation", constellationRelationid); - - constellationRelationid = constellationRelationid + 1; - - return true; - - } - - - return false; - }); - } - - turnOnTooltipsForTab("constellationRelations"); - }); - }); - } - - var languageid = 1; - var languageOpen = false; - if ($('#languagesUsedtab').exists()){ - $('#languagesUsedtab').click(function(){ - // Don't open a second time - if (languageOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=languagesUsed", null, function (data) { - languageOpen = true; - $('#languagesUsed').html(data); - - turnOnEditDeleteButtons("languagesUsed"); - - if ($('#next_language_i').exists()) { - languageid = parseInt($('#next_language_i').text()); - } - console.log("Next language ID: " + languageid); - if ($('#btn_add_language').exists()){ - $('#btn_add_language').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#language_template').clone(); - var html = text.html().replace(/ZZ/g, languageid); - $('#add_language_div').after(html); - turnOnButtons("language", languageid); - turnOnTooltips("language", languageid); - makeEditable("language", languageid); - languageid = languageid + 1; - return false; - }); - } - - turnOnTooltipsForTab("languagesUsed"); - }); - }); - } - - var subjectid = 1; - var subjectOpen = false; - if ($('#subjectstab').exists()){ - $('#subjectstab').click(function(){ - // Don't open a second time - if (subjectOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=subjects", null, function (data) { - subjectOpen = true; - $('#subjects').html(data); - - turnOnEditDeleteButtons("subjects"); - - if ($('#next_subject_i').exists()) { - subjectid = parseInt($('#next_subject_i').text()); - } - console.log("Next subject ID: " + subjectid); - if ($('#btn_add_subject').exists()){ - $('#btn_add_subject').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#subject_template').clone(); - var html = text.html().replace(/ZZ/g, subjectid); - $('#add_subject_div').after(html); - turnOnButtons("subject", subjectid); - turnOnTooltips("subject", subjectid); - makeEditable("subject", subjectid); - subjectid = subjectid + 1; - return false; - }); - } - - turnOnTooltipsForTab("subjects"); - }); - }); - } - - var nationalityid = 1; - var nationalityOpen = false; - if ($('#nationalitiestab').exists()){ - $('#nationalitiestab').click(function(){ - // Don't open a second time - if (nationalityOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=nationalities", null, function (data) { - nationalityOpen = true; - $('#nationalities').html(data); - - turnOnEditDeleteButtons("nationalities"); - - if ($('#next_nationality_i').exists()) { - nationalityid = parseInt($('#next_nationality_i').text()); - } - console.log("Next nationality ID: " + nationalityid); - if ($('#btn_add_nationality').exists()){ - $('#btn_add_nationality').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#nationality_template').clone(); - var html = text.html().replace(/ZZ/g, nationalityid); - $('#add_nationality_div').after(html); - turnOnButtons("nationality", nationalityid); - turnOnTooltips("nationality", nationalityid); - makeEditable("nationality", nationalityid); - nationalityid = nationalityid + 1; - return false; - }); - } - - turnOnTooltipsForTab("nationalities"); - }); - }); - } - - var functionid = 1; - var functionOpen = false; - if ($('#functionstab').exists()){ - $('#functionstab').click(function(){ - // Don't open a second time - if (functionOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=functions", null, function (data) { - functionOpen = true; - $('#functions').html(data); - - turnOnEditDeleteButtons("functions"); - - if ($('#next_function_i').exists()) { - functionid = parseInt($('#next_function_i').text()); - } - console.log("Next function ID: " + functionid); - if ($('#btn_add_function').exists()){ - $('#btn_add_function').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#function_template').clone(); - var html = text.html().replace(/ZZ/g, functionid); - $('#add_function_div').after(html); - turnOnButtons("function", functionid); - turnOnTooltips("function", functionid); - makeEditable("function", functionid); - functionid = functionid + 1; - return false; - }); - } - - turnOnTooltipsForTab("functions"); - }); - }); - } - - var occupationid = 1; - var occupationOpen = false; - if ($('#occupationstab').exists()){ - $('#occupationstab').click(function(){ - // Don't open a second time - if (occupationOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=occupations", null, function (data) { - occupationOpen = true; - $('#occupations').html(data); - - turnOnEditDeleteButtons("occupations"); - - if ($('#next_occupation_i').exists()) { - occupationid = parseInt($('#next_occupation_i').text()); - } - console.log("Next occupation ID: " + occupationid); - if ($('#btn_add_occupation').exists()){ - $('#btn_add_occupation').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#occupation_template').clone(); - var html = text.html().replace(/ZZ/g, occupationid); - $('#add_occupation_div').after(html); - turnOnButtons("occupation", occupationid); - turnOnTooltips("occupation", occupationid); - makeEditable("occupation", occupationid); - occupationid = occupationid + 1; - return false; - }); - } - - turnOnTooltipsForTab("occupations"); - }); - }); - } - - var legalStatusid = 1; - var legalStatusOpen = false; - if ($('#legalStatusestab').exists()){ - $('#legalStatusestab').click(function(){ - // Don't open a second time - if (legalStatusOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=legalStatuses", null, function (data) { - legalStatusOpen = true; - $('#legalStatuses').html(data); - - turnOnEditDeleteButtons("legalStatuses"); - - if ($('#next_legalStatus_i').exists()) { - legalStatusid = parseInt($('#next_legalStatus_i').text()); - } - console.log("Next legalStatus ID: " + legalStatusid); - if ($('#btn_add_legalStatus').exists()){ - $('#btn_add_legalStatus').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#legalStatus_template').clone(); - var html = text.html().replace(/ZZ/g, legalStatusid); - $('#add_legalStatus_div').after(html); - turnOnButtons("legalStatus", legalStatusid); - turnOnTooltips("legalStatus", legalStatusid); - makeEditable("legalStatus", legalStatusid); - legalStatusid = legalStatusid + 1; - return false; - }); - } - - turnOnTooltipsForTab("legalStatuses"); - }); - }); - } - - var placeid = 1; - var placeOpen = false; - if ($('#placestab').exists()){ - $('#placestab').click(function(){ - // Don't open a second time - if (placeOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=places", null, function (data) { - placeOpen = true; - $('#places').html(data); - - // Load the place cache, if needed - loadGeoPlaceResultCache(); - - turnOnEditDeleteButtons("places"); - - if ($('#next_place_i').exists()) { - placeid = parseInt($('#next_place_i').text()); - } - console.log("Next place ID: " + placeid); - if ($('#btn_add_place').exists()){ - $('#btn_add_place').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#place_template').clone(); - var html = text.html().replace(/ZZ/g, placeid); - $('#add_place_div').after(html); - turnOnButtons("place", placeid); - turnOnTooltips("place", placeid); - makeEditable("place", placeid); - placeid = placeid + 1; - return false; - }); - } - - turnOnTooltipsForTab("places"); - }); - }); - } - - var conventionDeclarationid = 1; - var conventionDeclarationOpen = false; - if ($('#conventionDeclarationstab').exists()){ - $('#conventionDeclarationstab').click(function(){ - // Don't open a second time - if (conventionDeclarationOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=conventionDeclarations", null, function (data) { - conventionDeclarationOpen = true; - $('#conventionDeclarations').html(data); - - turnOnEditDeleteButtons("conventionDeclarations"); - - if ($('#next_conventionDeclaration_i').exists()) { - conventionDeclarationid = parseInt($('#next_conventionDeclaration_i').text()); - } - console.log("Next conventionDeclaration ID: " + conventionDeclarationid); - if ($('#btn_add_conventionDeclaration').exists()){ - $('#btn_add_conventionDeclaration').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#conventionDeclaration_template').clone(); - var html = text.html().replace(/ZZ/g, conventionDeclarationid); - $('#add_conventionDeclaration_div').after(html); - turnOnButtons("conventionDeclaration", conventionDeclarationid); - turnOnTooltips("conventionDeclaration", conventionDeclarationid); - makeEditable("conventionDeclaration", conventionDeclarationid); - conventionDeclarationid = conventionDeclarationid + 1; - return false; - }); - } - - turnOnTooltipsForTab("conventionDeclarations"); - }); - }); - } - - var generalContextid = 1; - var generalContextOpen = false; - if ($('#generalContextstab').exists()){ - $('#generalContextstab').click(function(){ - // Don't open a second time - if (generalContextOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=generalContexts", null, function (data) { - generalContextOpen = true; - $('#generalContexts').html(data); - - turnOnEditDeleteButtons("generalContexts"); - - if ($('#next_generalContext_i').exists()) { - generalContextid = parseInt($('#next_generalContext_i').text()); - } - console.log("Next generalContext ID: " + generalContextid); - if ($('#btn_add_generalContext').exists()){ - $('#btn_add_generalContext').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#generalContext_template').clone(); - var html = text.html().replace(/ZZ/g, generalContextid); - $('#add_generalContext_div').after(html); - turnOnButtons("generalContext", generalContextid); - turnOnTooltips("generalContext", generalContextid); - makeEditable("generalContext", generalContextid); - generalContextid = generalContextid + 1; - return false; - }); - } - - turnOnTooltipsForTab("generalContexts"); - }); - }); - } - - var structureOrGenealogyid = 1; - var structureOrGenealogyOpen = false; - if ($('#structureOrGenealogiestab').exists()){ - $('#structureOrGenealogiestab').click(function(){ - // Don't open a second time - if (structureOrGenealogyOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=structureOrGenealogies", null, function (data) { - structureOrGenealogyOpen = true; - $('#structureOrGenealogies').html(data); - - turnOnEditDeleteButtons("structureOrGenealogies"); - - if ($('#next_structureOrGenealogy_i').exists()) { - structureOrGenealogyid = parseInt($('#next_structureOrGenealogy_i').text()); - } - console.log("Next structureOrGenealogy ID: " + structureOrGenealogyid); - if ($('#btn_add_structureOrGenealogy').exists()){ - $('#btn_add_structureOrGenealogy').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#structureOrGenealogy_template').clone(); - var html = text.html().replace(/ZZ/g, structureOrGenealogyid); - $('#add_structureOrGenealogy_div').after(html); - turnOnButtons("structureOrGenealogy", structureOrGenealogyid); - turnOnTooltips("structureOrGenealogy", structureOrGenealogyid); - makeEditable("structureOrGenealogy", structureOrGenealogyid); - structureOrGenealogyid = structureOrGenealogyid + 1; - return false; - }); - } - - turnOnTooltipsForTab("structureOrGenealogies"); - }); - }); - } - - var mandateid = 1; - var mandateOpen = false; - if ($('#mandatestab').exists()){ - $('#mandatestab').click(function(){ - // Don't open a second time - if (mandateOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=mandates", null, function (data) { - mandateOpen = true; - $('#mandates').html(data); - - turnOnEditDeleteButtons("mandates"); - - if ($('#next_mandate_i').exists()) { - mandateid = parseInt($('#next_mandate_i').text()); - } - console.log("Next mandate ID: " + mandateid); - if ($('#btn_add_mandate').exists()){ - $('#btn_add_mandate').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#mandate_template').clone(); - var html = text.html().replace(/ZZ/g, mandateid); - $('#add_mandate_div').after(html); - turnOnButtons("mandate", mandateid); - turnOnTooltips("mandate", mandateid); - makeEditable("mandate", mandateid); - mandateid = mandateid + 1; - return false; - }); - } - - turnOnTooltipsForTab("mandates"); - }); - }); - } - - var biogHistid = 1; - var biogHistOpen = false; - if ($('#biogHiststab').exists()){ - $('#biogHiststab').click(function(){ - // Don't open a second time - if (biogHistOpen) - return; - - $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=biogHists", null, function (data) { - biogHistOpen = true; - $('#biogHists').html(data); - - turnOnEditDeleteButtons("biogHists"); - - if ($('#next_biogHist_i').exists()) { - biogHistid = parseInt($('#next_biogHist_i').text()); - } - console.log("Next biogHist ID: " + biogHistid); - if ($('#btn_add_biogHist').exists()){ - $('#btn_add_biogHist').click(function(){ - setEditedFlag(true); - //somethingHasBeenEdited = true; - var text = $('#biogHist_template').clone(); - var html = text.html().replace(/ZZ/g, biogHistid); - $('#add_biogHist_div').after(html); - turnOnButtons("biogHist", biogHistid); - turnOnTooltips("biogHist", biogHistid); - makeEditable("biogHist", biogHistid); - biogHistid = biogHistid + 1; - return false; - }); - } - - turnOnTooltipsForTab("biogHists"); - }); - }); - } - - turnOnTooltipsForTab(); - - - $("#info-dropdown").click(function(e) { - $(this).parent().toggleClass("open"); - e.stopPropagation(); - }); - -}); +(function(e, a) { for(var i in a) e[i] = a[i]; }(window, /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 3); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ 3: +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"somethingHasBeenEdited\", function() { return somethingHasBeenEdited; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"setEditedFlag\", function() { return setEditedFlag; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"undoSet\", function() { return undoSet; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"defaults\", function() { return defaults; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"displayErrorMessage\", function() { return displayErrorMessage; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"addDateEntry\", function() { return addDateEntry; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"addDateRangeEntry\", function() { return addDateRangeEntry; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"addSCMEntry\", function() { return addSCMEntry; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"makeEditable\", function() { return makeEditable; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"makeUneditable\", function() { return makeUneditable; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"makeSCMUneditable\", function() { return makeSCMUneditable; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"setRepeatedDataDeleted\", function() { return setRepeatedDataDeleted; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"newAddressLine\", function() { return newAddressLine; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"newNameEntryComponent\", function() { return newNameEntryComponent; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"updateNameEntryHeading\", function() { return updateNameEntryHeading; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"newNameEntryRule\", function() { return newNameEntryRule; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"updateDate\", function() { return updateDate; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"chooseSuggestedGeoPlace\", function() { return chooseSuggestedGeoPlace; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"magicDefaultFill\", function() { return magicDefaultFill; });\n/**\n * Edit Scripts\n *\n * Scripts used in the edit page\n *\n * @author Robbie Hott\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\nvar biogHistEditor = null;\n\n// Has anything been edited on this page?\nvar somethingHasBeenEdited = false;\n\nfunction setEditedFlag(val) {\n if (val == true) {\n $(\"#save_and_continue\").addClass(\"save-active\");\n } else {\n $(\"#save_and_continue\").removeClass(\"save-active\");\n }\n somethingHasBeenEdited = val;\n}\n\n// Global Undo Set\nvar undoSet = new Array();\n\nvar defaults = {\n language: {\n id: 130,\n term: \"eng\"\n },\n script: {\n id: 586,\n term: \"Latn\"\n }\n};\n\n/**\n * Display Error message\n *\n * Displays the error message box to the user with the given error message\n *\n * @param string|object err The error message (string) or error object containing a message and type string\n */\nfunction displayErrorMessage(err, data) {\n var errorMsg = \"\";\n if (typeof err === 'undefined') errorMsg = \"an unknown problem occurred\";else if (typeof err == \"string\") errorMsg = err;else if (err.message) errorMsg = err.message;else if (err.type) errorMsg = err.type;else errorMsg = \"an unknown problem occurred\";\n\n $('#error-message').html(\"

    Oops

    \" + errorMsg + \"

    \" + \"

    \" + \" \" + \"\" + \"Go to Dashboard\" + \"\" + \"

    \");\n setTimeout(function () {\n $('#error-message').slideDown();\n }, 500);\n\n // For reference, put the server response in the console\n console.log(data);\n}\n\n/**\n * Add sub-Date GUI object\n *\n * Adds a Date GUI object to the Date modal for the given \"short\" type of data indexed by i\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index of the object to add a date object to.\n * @returns boolean false to keep the browser from redrawing the page\n */\nfunction addDateEntry(short, i) {\n //next_date_{{short}}_{{i}}_j\n var j = parseInt($('#next_date_' + short + '_' + i + '_j').text());\n var id = j + \"_\" + i;\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#sub_date_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/XX/g, j).replace(/SHORT/g, short);\n $('#add_date_' + short + '_' + i + '_div').after(html);\n $('#next_date_' + short + '_' + i + '_j').text(j + 1);\n turnOnButtons(short + \"_date\" + j, i);\n turnOnTooltips(short + \"_date_\" + j, i);\n makeEditable(short + \"_date_\" + j, i);\n return false;\n}\n\n/**\n * Add sub-Date GUI object\n *\n * Adds a Date GUI object to the Date modal for the given \"short\" type of data indexed by i\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index of the object to add a date object to.\n * @returns boolean false to keep the browser from redrawing the page\n */\nfunction addDateRangeEntry(short, i) {\n //next_date_{{short}}_{{i}}_j\n var j = parseInt($('#next_date_' + short + '_' + i + '_j').text());\n var id = j + \"_\" + i;\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#sub_dateRange_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/XX/g, j).replace(/SHORT/g, short);\n $('#add_date_' + short + '_' + i + '_div').after(html);\n $('#next_date_' + short + '_' + i + '_j').text(j + 1);\n turnOnButtons(short + \"_date\" + j, i);\n turnOnTooltips(short + \"_date_\" + j, i);\n makeEditable(short + \"_date_\" + j, i);\n return false;\n}\n\n/**\n * Add SCM GUI object\n *\n * Adds a GUI SCM object to the SCM modal for the given \"short\" type of data indexed by i\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index of the object to add an SCM object to.\n * @returns boolean false to keep the browser from redrawing the page\n */\nfunction addSCMEntry(short, i) {\n //next_scm_{{short}}_{{i}}_j\n var j = parseInt($('#next_scm_' + short + '_' + i + '_j').text());\n var id = j + \"_\" + i;\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#scm_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, j).replace(/SHORT/g, short);\n $('#add_scm_' + short + '_' + i + '_div').after(html);\n $('#next_scm_' + short + '_' + i + '_j').text(j + 1);\n turnOnSCMButtons(short, i, j);\n turnOnTooltips(\"scm_\" + short, id);\n makeSCMEditable(short, i, j);\n return false;\n}\n\n/**\n * Undo Edit\n *\n * Returns the html for the (short, i) panel back to its original state, i.e. removes\n * the edit. Before doing this, to clean up the page, it first makes the edited version\n * uneditable.\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n */\nfunction undoEdit(short, i) {\n makeUneditable(short, i);\n\n // restore the old content\n $(\"#\" + short + \"_datapart_\" + i).replaceWith(undoSet[short + \"-\" + i]);\n turnOnTooltips(short, i);\n $(\"#\" + short + \"_datapart_\" + i + \" input[type='checkbox']\").each(function () {\n var obj = $(this);\n obj.bootstrapToggle();\n });\n}\n\n/**\n * Undo SCM Edit\n *\n * Takes an SCM GUI object (j) for a data object (short, i) and returns it back to its\n * original state (removing the edit). Before doing this, to clean up the page and JS, it first\n * makes the edited version uneditable, then replaces the HTML.\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n */\nfunction undoSCMEdit(short, i, j) {\n var id = j + \"_\" + i;\n makeSCMUneditable(short, i, j);\n\n // restore the old content\n $(\"#scm_\" + short + \"_datapart_\" + id).replaceWith(undoSet[\"scm_\" + short + \"-\" + id]);\n turnOnTooltips(\"scm_\" + short, id);\n}\n\n/**\n * Change vocabulary input divs to selects\n *\n * Changes all div's with id \"select_\" for a given data object (shortName, idStr) from a list of\n * inputs defining the parameters to a select (view mode) to a select box (edit mode). It then\n * calls the select2 function to replace the select with an AJAX-compatible select.\n *\n * This function handles VOCABULARY select boxes ONLY.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction textToSelect(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='select_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"select_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr).val();\n var term = $(\"#\" + shortName + \"_\" + name + \"_term_\" + idStr).val();\n var vocabtype = $(\"#\" + shortName + \"_\" + name + \"_vocabtype_\" + idStr).val();\n var minlength = $(\"#\" + shortName + \"_\" + name + \"_minlength_\" + idStr).val();\n var placeholder = \"Select\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).exists()) {\n placeholder = $(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).val();\n }\n var options = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_defaultOptions_\" + idStr).exists()) {\n options = $(\"#\" + shortName + \"_\" + name + \"_defaultOptions_\" + idStr).val();\n }\n\n cont.html(\"\" + \"\" + \"\");\n\n if (name == \"citation\") scm_source_select_replace($(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr), \"_\" + idStr);else vocab_select_replace($(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr), \"_\" + idStr, vocabtype, minlength);\n }\n });\n}\n\nfunction textToCheckbox(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='checkbox_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^checkbox_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n var placeholderOn = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholderOn_\" + idStr).exists()) {\n placeholderOn = $(\"#\" + shortName + \"_\" + name + \"_placeholderOn_\" + idStr).val();\n }\n var placeholderOff = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholderOff_\" + idStr).exists()) {\n placeholderOff = $(\"#\" + shortName + \"_\" + name + \"_placeholderOff_\" + idStr).val();\n }\n\n var html = \"\";\n if (placeholderOn != \"\") {\n html += \"\";\n }\n if (placeholderOff != \"\") {\n html += \"\";\n }\n\n cont.html(html);\n $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).bootstrapToggle();\n }\n });\n}\n\nfunction checkboxToText(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='checkbox_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^checkbox_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n var checked = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).prop('checked');\n var placeholderOn = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholderOn_\" + idStr).exists()) {\n placeholderOn = $(\"#\" + shortName + \"_\" + name + \"_placeholderOn_\" + idStr).val();\n }\n var placeholderOff = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholderOff_\" + idStr).exists()) {\n placeholderOff = $(\"#\" + shortName + \"_\" + name + \"_placeholderOff_\" + idStr).val();\n }\n\n var html = \"\";\n\n html += \"

    \";\n if (checked) {\n if (placeholderOn != \"\") html += placeholderOn;else html += value;\n } else {\n if (placeholderOff != \"\") html += placeholderOff;\n }\n html += \"

    \";\n if (placeholderOn != \"\") {\n html += \"\";\n }\n if (placeholderOff != \"\") {\n html += \"\";\n }\n\n $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).bootstrapToggle(\"destroy\");\n cont.html(html);\n }\n });\n}\n\nfunction textToInput(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='text_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^text_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n var size = 0;\n var sizeStr = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_size_\" + idStr).exists()) {\n size = parseInt($(\"#\" + shortName + \"_\" + name + \"_size_\" + idStr).val());\n sizeStr = \" size='\" + size + \"' \";\n }\n var placeholder = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).exists()) {\n placeholder = $(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).val();\n }\n\n var onKeyUp = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_onKeyUp_\" + idStr).exists()) {\n onKeyUp = $(\"#\" + shortName + \"_\" + name + \"_onKeyUp_\" + idStr).val();\n }\n var onKeyUpStr = \"\";\n if (onKeyUp != \"\") {\n onKeyUpStr = \" onKeyUp='\" + onKeyUp + \"' \";\n }\n\n var html = \"\";\n if (size != 0) {\n html += \"\";\n }\n if (placeholder != \"\") {\n html += \"\";\n }\n if (onKeyUp != \"\") {\n html += \"\";\n }\n\n cont.html(html);\n }\n });\n}\n\nfunction inputToText(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='text_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^text_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n var size = 0;\n if ($(\"#\" + shortName + \"_\" + name + \"_size_\" + idStr).exists()) {\n size = parseInt($(\"#\" + shortName + \"_\" + name + \"_size_\" + idStr).val());\n }\n var placeholder = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).exists()) {\n placeholder = $(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).val();\n }\n var onKeyUp = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_onKeyUp_\" + idStr).exists()) {\n onKeyUp = $(\"#\" + shortName + \"_\" + name + \"_onKeyUp_\" + idStr).val();\n }\n\n var html = \"\";\n html += \"

    \" + value + \"

    \";\n if (size != 0) {\n html += \"\";\n }\n if (placeholder != \"\") {\n html += \"\";\n }\n if (onKeyUp != \"\") {\n html += \"\";\n }\n\n cont.html(html);\n }\n });\n}\n\nfunction textToTextArea(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='textarea_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^textarea_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n\n var html = \"\";\n\n cont.html(html);\n }\n });\n}\n\nfunction textAreaToText(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='textarea_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^textarea_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n\n //var html = \"\";\n var html = \"\";\n html += \"
    \" + value + \"
    \";\n\n cont.html(html);\n }\n });\n}\n\n/**\n * Change vocabulary selects to divs of inputs\n *\n * Changes all div's with id \"select_\" for a given data object (shortName, idStr) from a select\n * box (edit mode) to a list of inputs defining the parameters to a select (view mode).\n *\n * This function handles VOCABULARY select boxes ONLY.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction selectToText(shortName, idStr) {\n $(\"div[id^='select_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"select_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr).val();\n var term = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr + \" option:selected\").text();\n var vocabtype = $(\"#\" + shortName + \"_\" + name + \"_vocabtype_\" + idStr).val();\n var minlength = $(\"#\" + shortName + \"_\" + name + \"_minlength_\" + idStr).val();\n\n var additionalStyle = \"\";\n var postText = \"\";\n if (vocabtype == \"name_component\") {\n additionalStyle = \"name-component-type\";\n postText = \" :\";\n }\n\n cont.html(\"\" + \"\" + \"\" + \"\" + \"

    \" + term + postText + \"

    \");\n }\n });\n}\n\nvar geoPlaceLoadResults = null;\n\nfunction textToGeoPlaceSelect(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='selectGeo_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"selectGeo_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr).val();\n var term = $(\"#\" + shortName + \"_\" + name + \"_term_\" + idStr).val();\n var placeholder = \"Select Geo Place Term\";\n\n var confirmed = $(\"#\" + shortName + \"_confirmed_\" + idStr).val() == \"true\" ? true : false;\n var firstOptionSelect = \"\";\n var secondOptionSelect = \" selected\";\n if (!confirmed) {\n firstOptionSelect = \" selected\";\n secondOptionSelect = \"\";\n }\n\n cont.html(\"\");\n\n geovocab_select_replace($(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr), \"_\" + idStr);\n }\n });\n}\n\nfunction geoPlaceSelectToText(shortName, idStr) {\n $(\"div[id^='selectGeo_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"selectGeo_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr).val();\n var term = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr + \" option:selected\").text();\n\n cont.html(\"\" + \"\");\n }\n });\n}\n\n/**\n * Make a data object editable\n *\n * Make the GUI pane for a given constellation object (short, i) editable. Sets up the edit and delete\n * buttons for first-order data objects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction makeEditable(short, i) {\n // No editing if it's already in edit mode\n if ($(\"#\" + short + \"_operation_\" + i).val() == \"update\") return false;\n // If it's deleted, then you better undelete it first\n if ($(\"#\" + short + \"_operation_\" + i).val() == \"delete\") setDeleted(short, i);\n\n $(\"#\" + short + \"_editbutton_\" + i).removeClass(\"list-group-item-info\").addClass(\"list-group-item-warning\");\n $(\"#\" + short + \"_editbutton_\" + i).html(\"
    Undo\");\n $(\"#\" + short + \"_editbutton_\" + i).off('click').on(\"click\", function () {\n undoEdit(short, i);\n });\n $(\"#\" + short + \"_deletebutton_\" + i).removeClass(\"list-group-item-danger\").addClass(\"disabled\");\n $(\"#\" + short + \"_deletebutton_\" + i).off('click').on(\"click\", function () {\n return false;\n });\n\n $(\"#\" + short + \"_panel_\" + i).removeClass(\"panel-default\").addClass(\"alert-info\").addClass(\"edited-component\");\n\n return subMakeEditable(short, i);\n}\n\n/**\n * Make a data object editable\n *\n * Make the GUI pane for a given constellation object (short, i) editable. Handles removing the read-only\n * statuses and changing divs into selects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction subMakeEditable(short, i) {\n // No editing if it's already in edit mode\n if ($(\"#\" + short + \"_operation_\" + i).val() == \"update\") return false;\n\n // Add to the undo set\n undoSet[short + \"-\" + i] = $(\"#\" + short + \"_datapart_\" + i).clone();\n\n textToInput(short, i);\n textToTextArea(short, i);\n textToCheckbox(short, i);\n\n var idstr = \"_\" + i;\n\n // Enable buttons\n $(\"#\" + short + \"_datapart_\" + i + \" button[id^='\" + short + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.removeAttr(\"disabled\").removeClass(\"snac-hidden\");\n }\n });\n // Enable buttons\n $(\"#\" + short + \"_datapart_\" + i + \" a.label\").each(function () {\n $(this).removeClass(\"snac-hidden\");\n });\n\n // Enable checkboxes\n $(\"#\" + short + \"_datapart_\" + i + \" input[type='checkbox']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.bootstrapToggle('enable');\n }\n });\n\n // Turn on CodeMirror Editors\n $(\"#\" + short + \"_datapart_\" + i + \" textarea[id^='\" + short + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n // remove the short name from the string we're parsing\n var idStr = obj.attr('id').replace(short, \"\");\n if (idStr.indexOf('_text_') != -1 || idStr.indexOf('_source_') != -1) {\n obj.get(0).CodeMirror = CodeMirror.fromTextArea(obj.get(0), {\n lineNumbers: true,\n lineWrapping: true,\n viewportMargin: Infinity,\n mode: { name: \"xml\" }\n });\n }\n }\n });\n var sawSelect = false;\n $(\"#\" + short + \"_datapart_\" + i + \" select[id^='\" + short + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n sawSelect = true;\n }\n });\n\n if (!sawSelect) {\n textToSelect(short, i);\n textToGeoPlaceSelect(short, i);\n textToDate(short, i);\n }\n\n // Make things re-orderable if something exists\n // $( \"#nameEntry_component_ui_0\" ).sortable({ // id of the container containing sortable things\n // items : '.name_component' // class of the things that are sortable. They MUST have ids\n // });\n $(\"#\" + short + \"_datapart_\" + i + \" span.move-handle\").each(function () {\n $(this).removeClass(\"snac-hidden\");\n });\n $(\"#\" + short + \"_reorderable_\" + i).sortable({\n items: '.reorderable',\n opacity: 0.5,\n update: function (event, ui) {\n var neworder = $(\"#\" + short + \"_reorderable_\" + i).sortable(\"toArray\");\n console.log(neworder);\n neworder.forEach(function (orderedID, index) {\n $(\"#\" + orderedID + \" input.order-index\").val(index);\n });\n if (short == \"nameEntry\") updateNameEntryHeading(i);\n }\n });\n\n // Make the relation pictures update appropriately\n if (short == 'constellationRelation') {\n // make the role dropdown affect the picture\n $('#' + short + '_type_id_' + i).change(function () {\n updatePictureArrow(short, i, $('#' + short + '_type_id_' + i + ' option:selected').text());\n });\n }\n if (short == 'resourceRelation') {\n // make the role dropdown affect the picture\n $('#' + short + '_role_id_' + i).change(function () {\n updatePictureArrow(short, i, $('#' + short + '_role_id_' + i + ' option:selected').text());\n });\n }\n // Places should update the place heading\n if (short == 'place') {\n // If there is a value pre-set, then automatically confirm and update\n if ($('#' + short + '_geoplace_id_' + i).val() != null && $('#' + short + '_geoplace_id_' + i).val() != \"\") {\n updatePlaceHeading(short, i, $('#' + short + '_geoplace_id_' + i).val());\n }\n // make the role dropdown affect the picture\n $('#' + short + '_geoplace_id_' + i).change(function () {\n updatePlaceHeading(short, i, $('#' + short + '_geoplace_id_' + i).val());\n });\n }\n\n // add parser btn if nameEntry is a computed name, entity is person, and if no btn or extra name components already exist\n if (short === 'nameEntry' && $(\"#entityType\").val() === \"700\" && $(\"#nameEntry_component_0_panel_\" + i).find('select:first').text() === \"Name\" && !$(\"#nameEntry_panel_\" + i).find('.name-parser').length && $(\"#nameEntry_component_1_panel_\" + i).length === 0) {\n $('#nameEntry_component_add_' + i).after('');\n }\n\n // Set this data's operation value appropriately\n if ($(\"#\" + short + \"_id_\" + i).val() != \"\") $(\"#\" + short + \"_operation_\" + i).val(\"update\");else $(\"#\" + short + \"_operation_\" + i).val(\"insert\");\n\n // Asked to edit something, so make it globally known\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n return false;\n}\n\n/**\n * Make a data object uneditable\n *\n * Make each object in the GUI page for the given piece uneditable by turning them back to text. Also\n * takes the color away from the pane and removes the operation flag.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction subMakeUneditable(shortName, i) {\n\n // Make inputs read-only\n var idstr = \"_\" + i;\n\n // Turn off the reordering js\n $(\"#\" + shortName + \"_datapart_\" + i + \" span.move-handle\").each(function () {\n $(this).addClass(\"snac-hidden\");\n });\n if ($(\"#\" + shortName + \"_reorderable_\" + i).hasClass(\"ui-sortable\")) $(\"#\" + shortName + \"_reorderable_\" + i).sortable(\"destroy\");\n\n // Remove CodeMirror editors\n $(\"#\" + shortName + \"_datapart_\" + i + \" textarea[id^='\" + shortName + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\") && (obj.attr('id').indexOf('_text_') != -1 || obj.attr('id').indexOf('_source_') != -1)) {\n\n if (obj.get(0).CodeMirror) {\n obj.get(0).CodeMirror.toTextArea();\n }\n //(document.getElementById(obj.attr('id'))).CodeMirror.toTextArea();\n //obj.get(0).CodeMirror.toTextArea();\n }\n });\n // Disable buttons\n $(\"#\" + shortName + \"_datapart_\" + i + \" button[id^='\" + shortName + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.attr(\"disabled\", \"true\").addClass(\"snac-hidden\");\n }\n });\n\n // Disable buttons\n $(\"#\" + shortName + \"_datapart_\" + i + \" a.label\").each(function () {\n $(this).addClass(\"snac-hidden\");\n });\n\n // Disable checkboxes\n $(\"#\" + shortName + \"_datapart_\" + i + \" input[type='checkbox']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.bootstrapToggle(\"disable\");\n }\n });\n\n inputToText(shortName, i);\n textAreaToText(shortName, i);\n checkboxToText(shortName, i);\n // Check for a select box\n var sawSelect = false;\n $(\"#\" + shortName + \"_datapart_\" + i + \" select[id^='\" + shortName + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n sawSelect = true;\n }\n });\n // If a select box was seen, undo it\n if (sawSelect) {\n selectToText(shortName, i);\n geoPlaceSelectToText(shortName, i);\n dateToText(shortName, i);\n }\n\n // Clear the operation flags\n //$(\"#\" + shortName + \"_operation_\" + i).val(\"\");\n $(\"#\" + shortName + \"_datapart_\" + i + \" input[id^='\" + shortName + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(\"_operation\" + idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.val(\"\");\n }\n });\n\n $(\"#\" + shortName + \"_panel_\" + i).addClass(\"panel-default\").removeClass(\"alert-info\").removeClass(\"edited-component\");\n}\n\n/**\n * Make a data object uneditable\n *\n * Make the GUI pane for a given constellation object (short, i) un-editable. Sets up the edit and delete\n * buttons for first-order data objects, and calls the function to turn the elements back to text.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction makeUneditable(shortName, i) {\n // Make inputs read-only\n var idstr = \"_\" + i;\n\n subMakeUneditable(shortName, i);\n\n // restore the edit button\n $(\"#\" + shortName + \"_editbutton_\" + i).addClass(\"list-group-item-info\").removeClass(\"list-group-item-warning\");\n $(\"#\" + shortName + \"_editbutton_\" + i).html(\"
    Edit\");\n $(\"#\" + shortName + \"_editbutton_\" + i).off('click').on(\"click\", function () {\n makeEditable(shortName, i);\n });\n\n // restore the delete button\n $(\"#\" + shortName + \"_deletebutton_\" + i).addClass(\"list-group-item-danger\").removeClass(\"disabled\");\n $(\"#\" + shortName + \"_deletebutton_\" + i).off('click').on(\"click\", function () {\n setDeleted(shortName, i);\n });\n\n return false;\n}\n\n/**\n * Make an SCM data object editable\n *\n * Make the GUI pane for an SCM (j) of a given constellation object (short, i) editable. Sets up the edit and delete\n * buttons for first-order data objects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n * @return boolean False to play nice with the browser\n */\nfunction makeSCMEditable(shortName, i, j) {\n var id = j + \"_\" + i;\n var scmShortName = \"scm_\" + shortName;\n\n // No editing if it's already in edit mode\n if ($(\"#\" + scmShortName + \"_operation_\" + id).val() == \"update\") return false;\n // If it's deleted, then you better undelete it first\n if ($(\"#\" + scmShortName + \"_operation_\" + id).val() == \"delete\") setSCMDeleted(shortName, i, j);\n\n $(\"#\" + scmShortName + \"_editbutton_\" + id).removeClass(\"list-group-item-info\").addClass(\"list-group-item-warning\");\n $(\"#\" + scmShortName + \"_editbutton_\" + id).html(\"\");\n $(\"#\" + scmShortName + \"_editbutton_\" + id).off('click').on(\"click\", function () {\n undoSCMEdit(shortName, i, j);\n });\n $(\"#\" + scmShortName + \"_deletebutton_\" + id).removeClass(\"list-group-item-danger\").addClass(\"disabled\");\n $(\"#\" + scmShortName + \"_deletebutton_\" + id).off('click').on(\"click\", function () {\n return false;\n });\n\n $(\"#\" + scmShortName + \"_panel_\" + id).removeClass(\"panel-default\").addClass(\"alert-info\").addClass(\"edited-component\");\n\n return subMakeEditable(scmShortName, id);\n}\n\n/**\n * Make an SCM data object un-editable\n *\n * Make the GUI pane for an SCM object (j) for a given constellation object (short, i) un-editable. Sets up the edit and delete\n * buttons for SCM data objects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n * @return boolean False to play nice with the browser\n */\nfunction makeSCMUneditable(shortName, i, j) {\n\n // Make inputs read-only\n var idstr = j + \"_\" + i;\n\n subMakeUneditable('scm_' + shortName, idstr);\n\n // restore the edit button\n $(\"#scm_\" + shortName + \"_editbutton_\" + idstr).addClass(\"list-group-item-info\").removeClass(\"list-group-item-warning\");\n $(\"#scm_\" + shortName + \"_editbutton_\" + idstr).html(\"\");\n $(\"#scm_\" + shortName + \"_editbutton_\" + idstr).off('click').on(\"click\", function () {\n makeSCMEditable(shortName, i, j);\n });\n\n // restore the delete button\n $(\"#scm_\" + shortName + \"_deletebutton_\" + idstr).addClass(\"list-group-item-danger\").removeClass(\"disabled\");\n $(\"#scm_\" + shortName + \"_deletebutton_\" + idstr).off('click').on(\"click\", function () {\n setSCMDeleted(shortName, i, j);\n });\n\n return false;\n}\n\n/**\n * Set a Contributor Object as deleted\n *\n * Sets the contributor object (shortName, i) as deleted or undeleted and makes the appropriate changes.\n *\n * @param string shortName The short name of the contributor object.\n * @param string|int i The index within the edit page of the object.\n */\nfunction setRepeatedDataDeleted(shortName, i) {\n if ($(\"#\" + shortName + \"_operation_\" + i).val() != \"delete\") {\n $(\"#\" + shortName + \"_remove_\" + i).removeClass(\"btn-danger\").addClass(\"btn-warning\");\n $(\"#\" + shortName + \"_remove_\" + i).html(\"\");\n } else {\n $(\"#\" + shortName + \"_remove_\" + i).removeClass(\"btn-warning\").addClass(\"btn-danger\");\n $(\"#\" + shortName + \"_remove_\" + i).html(\"\");\n }\n\n return subSetDeleted(shortName, i);\n}\n\n/**\n * Set a first-order data object as deleted\n *\n * Sets a first-order data object (short, i) as deleted or undeleted and makes the appropriate changes throughout the page.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n */\nfunction setDeleted(short, i) {\n if ($(\"#\" + short + \"_operation_\" + i).val() != \"delete\") {\n // set deleted\n $(\"#\" + short + \"_deletebutton_\" + i).removeClass(\"list-group-item-danger\").addClass(\"list-group-item-warning\");\n $(\"#\" + short + \"_deletebutton_\" + i).html(\"
    Undo\");\n\n // disable edit button\n $(\"#\" + short + \"_editbutton_\" + i).removeClass(\"list-group-item-info\").addClass(\"disabled\");\n $(\"#\" + short + \"_editbutton_\" + i).off('click').on(\"click\", function () {\n return false;\n });\n\n // disable the Date button\n $(\"#\" + short + \"_datebutton_\" + i).removeClass(\"list-group-item-success\").addClass(\"disabled\").prop('disabled', true);\n\n // disable the SCM button\n $(\"#\" + short + \"_scmbutton_\" + i).removeClass(\"list-group-item-success\").addClass(\"disabled\").prop('disabled', true);\n } else {\n // set undelete\n $(\"#\" + short + \"_deletebutton_\" + i).removeClass(\"list-group-item-warning\").addClass(\"list-group-item-danger\");\n $(\"#\" + short + \"_deletebutton_\" + i).html(\"
    Trash\");\n\n // restore edit button\n $(\"#\" + short + \"_editbutton_\" + i).addClass(\"list-group-item-info\").removeClass(\"disabled\");\n $(\"#\" + short + \"_editbutton_\" + i).off('click').on(\"click\", function () {\n makeEditable(short, i);\n });\n\n // restore the Date button\n $(\"#\" + short + \"_datebutton_\" + i).addClass(\"list-group-item-success\").removeClass(\"disabled\").prop('disabled', false);\n\n // restore the SCM button\n $(\"#\" + short + \"_scmbutton_\" + i).addClass(\"list-group-item-success\").removeClass(\"disabled\").prop('disabled', false);\n }\n\n return subSetDeleted(short, i);\n}\n\n/**\n * Make the delete/undelete happen\n *\n * Actually performs the changes to the object, affecting the operation and panel color.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction subSetDeleted(short, i) {\n if ($(\"#\" + short + \"_operation_\" + i).val() != \"delete\") {\n // set deleted\n $(\"#\" + short + \"_panel_\" + i).removeClass(\"panel-default\").addClass(\"alert-danger\").addClass(\"deleted-component\");\n\n $(\"#\" + short + \"_operation_\" + i).val(\"delete\");\n } else {\n // set undelete\n $(\"#\" + short + \"_panel_\" + i).removeClass(\"alert-danger\").addClass(\"panel-default\").removeClass(\"deleted-component\");\n\n // If this thing was deleted but is supposed to be an update, then return it back to update status\n var sawSelect = false;\n $(\"select[id^='\" + short + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(\"_\" + i) && !obj.attr('id').endsWith(\"ZZ\")) {\n sawSelect = true;\n }\n });\n if (sawSelect) {\n if ($(\"#\" + short + \"_id_\" + i).val() != \"\") $(\"#\" + short + \"_operation_\" + i).val(\"update\");else $(\"#\" + short + \"_operation_\" + i).val(\"insert\");\n } else {\n $(\"#\" + short + \"_operation_\" + i).val(\"\");\n }\n }\n\n // Asked to delete something, so make it globally known\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n return false;\n}\n\n/**\n * Set an SCM data object as deleted\n *\n * Sets an SCM object (j) for a constellation object (short, i) as deleted or undeleted and makes the appropriate changes throughout the page.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n */\nfunction setSCMDeleted(short, i, j) {\n var id = j + '_' + i;\n if ($(\"#scm_\" + short + \"_operation_\" + id).val() != \"delete\") {\n // set deleted\n $(\"#scm_\" + short + \"_deletebutton_\" + id).removeClass(\"list-group-item-danger\").addClass(\"list-group-item-warning\");\n $(\"#scm_\" + short + \"_deletebutton_\" + id).html(\"\");\n\n // disable edit button\n $(\"#scm_\" + short + \"_editbutton_\" + id).removeClass(\"list-group-item-info\").addClass(\"disabled\");\n $(\"#scm_\" + short + \"_editbutton_\" + id).off('click').on(\"click\", function () {\n return false;\n });\n } else {\n // set undelete\n $(\"#scm_\" + short + \"_deletebutton_\" + id).removeClass(\"list-group-item-warning\").addClass(\"list-group-item-danger\");\n $(\"#scm_\" + short + \"_deletebutton_\" + id).html(\"\");\n\n // restore edit button\n $(\"#scm_\" + short + \"_editbutton_\" + id).addClass(\"list-group-item-info\").removeClass(\"disabled\");\n $(\"#scm_\" + short + \"_editbutton_\" + id).off('click').on(\"click\", function () {\n makeSCMEditable(short, i, j);\n });\n }\n\n return subSetDeleted(\"scm_\" + short, id);\n}\n\n/**\n * Turn on the Edit/Delete buttons for an object\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n */\nfunction turnOnButtons(shortName, i) {\n\n // Turn on the edit button\n $(\"#\" + shortName + \"_editbutton_\" + i).on(\"click\", function () {\n makeEditable(shortName, i);\n });\n\n // Turn on the delete buttons\n $(\"#\" + shortName + \"_deletebutton_\" + i).on(\"click\", function () {\n setDeleted(shortName, i);\n });\n}\n\nfunction turnOnTooltips(shortName, i) {\n // Load tooltips\n $(function () {\n $('#' + shortName + '_panel_' + i + ' [data-toggle=\"tooltip\"]').tooltip();\n });\n\n // Load popovers\n $(function () {\n $('#' + shortName + '_panel_' + i + ' [data-toggle=\"popover\"]').popover({\n trigger: 'hover',\n container: 'body'\n });\n });\n}\n\n/**\n * Turn on the Edit/Delete buttons for an SCM object\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n */\nfunction turnOnSCMButtons(shortName, i, j) {\n\n // Turn on the edit button\n $(\"#scm_\" + shortName + \"_editbutton_\" + j + \"_\" + i).on(\"click\", function () {\n makeSCMEditable(shortName, i, j);\n });\n\n // Turn on the delete buttons\n $(\"#scm_\" + shortName + \"_deletebutton_\" + j + \"_\" + i).on(\"click\", function () {\n setSCMDeleted(shortName, i, j);\n });\n}\n\n/**\n * Create a new Address Line object on page\n *\n * Puts a new Place Address Line object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the place to add this component to\n * @return boolean false to play nice with the browser.\n */\nfunction newAddressLine(i) {\n var nextid = 1;\n if ($('#place_address_next_j_' + i).exists()) {\n nextid = parseInt($('#place_address_next_j_' + i).text());\n }\n console.log(\"Creating new address line for place \" + i + \" with id: \" + nextid);\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#addressline_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#place_address_add_div_' + i).before(html);\n\n $('#place_address_' + nextid + '_operation_' + 1).val(\"insert\");\n subMakeEditable(\"place_address_\" + nextid, i);\n\n vocab_select_replace($(\"#place_address_\" + nextid + \"_type_id_\" + i), \"_\" + i, 'address_part', 0);\n\n // Put the updated version number back in the DOM\n $('#place_address_next_j_' + i).text(++nextid);\n\n return false;\n}\n\n/**\n * Create a new Resource Relation Origination Name object on page\n *\n * Puts a new Resource Relation Origination Name object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the Resource Relation to add this Origination Name to\n * @return boolean false to play nice with the browser.\n */\nfunction newOriginationName(i) {\n var nextid = 1;\n if ($('#resource_originationName_next_j_' + i).exists()) {\n nextid = parseInt($('#resource_originationName_next_j_' + i).text());\n }\n console.log(\"Creating new origination name for resource \" + i + \" with id: \" + nextid);\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#originationName_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#resource_originationName_add_div_' + i).before(html);\n\n $('#resource_originationName_' + nextid + '_operation_' + 1).val(\"insert\");\n subMakeEditable(\"resource_originationName_\" + nextid, i);\n\n // Put the updated version number back in the DOM\n $('#resource_originationName_next_j_' + i).text(++nextid);\n\n return false;\n}\n\n/**\n * Create a new Name Entry Component object on page\n *\n * Puts a new Name Entry component object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the nameEntry to add this component to\n * @return boolean false to play nice with the browser.\n */\nfunction newNameEntryComponent(i) {\n removeParserButton(i);\n var nextid = 1;\n if ($('#nameEntry_component_next_j_' + i).exists()) {\n nextid = parseInt($('#nameEntry_component_next_j_' + i).text());\n }\n console.log(\"Creating new name entry component for nameEntry \" + i + \" with id: \" + nextid);\n\n // add parser btn if entity is person, and if no btn or other name components already exist\n if ($(\"#entityType\").val() === \"700\" && nextid == 0 && !$(\"#nameEntry_panel_\" + i).find('.name-parser').length && $(\"#nameEntry_component_1_panel_\" + i).length === 0) {\n $('#nameEntry_component_add_' + i).after('');\n }\n\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n var text = $('#component_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#nameEntry_component_add_div_' + i).before(html);\n\n $('#nameEntry_component_' + nextid + '_operation_' + 1).val(\"insert\");\n subMakeEditable(\"nameEntry_component_\" + nextid, i);\n\n vocab_select_replace($(\"#nameEntry_component_\" + nextid + \"_type_id_\" + i), \"_\" + i, 'name_component', 0);\n\n // Put the updated version number back in the DOM\n $('#nameEntry_component_next_j_' + i).text(++nextid);\n\n return false;\n}\n\nfunction updateNameEntryHeading(i) {\n var text = \"\";\n var components = [];\n\n $(\"#nameEntry_panel_\" + i + \" div[id^='nameEntry_component_']\").each(function () {\n var obj = $(this);\n if (!obj.hasClass(\"deleted-component\") && obj.attr('id').endsWith(\"_panel_\" + i) && !obj.attr('id').endsWith(\"ZZ\")) {\n var j = obj.attr('id').replace(\"nameEntry_component_\", \"\").replace(\"_panel_\" + i, \"\");\n var type = $(\"#nameEntry_component_\" + j + \"_type_id_\" + i + \" option:selected\").text();\n var partText = $(\"#nameEntry_component_\" + j + \"_text_\" + i).val();\n\n components.push([type, partText]);\n }\n });\n\n var entityType = $(\"#entityType option:selected\").text();\n text = combineNameHeading(components, entityType);\n\n $(\"#nameEntry_heading_\" + i).text(text.trim());\n $(\"#nameEntry_original_\" + i).val(text.trim());\n}\n\n/**\n * Create a new Name Entry Rules object on page\n *\n * Puts a new Name Entry rule object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the nameEntry to add this rule to\n * @return boolean false to play nice with the browser.\n */\nfunction newNameEntryRule(i) {\n var nextid = 1;\n if ($('#nameEntry_rule_next_j_' + i).exists()) {\n nextid = parseInt($('#nameEntry_rule_next_j_' + i).text());\n }\n console.log(\"Creating new name entry rule for nameEntry \" + i + \" with id: \" + nextid);\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#rule_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#nameEntry_rule_add_div_' + i).before(html);\n\n $('#nameEntry_rule_' + nextid + '_operation_' + 1).val(\"insert\");\n turnOnTooltips(\"nameEntry_rule_\" + nextid, i);\n subMakeEditable(\"nameEntry_rule_\" + nextid, i);\n\n // Put the updated version number back in the DOM\n $('#nameEntry_rule_next_j_' + i).text(++nextid);\n\n return false;\n}\n\n/**\n * Parse a date string into parts\n */\nfunction parseDate(dateString) {\n var pieces = dateString.split(\"-\");\n if (pieces.length == 3) return {\n year: parseInt(pieces[0]),\n month: parseInt(pieces[1]),\n day: parseInt(pieces[2])\n };else if (pieces.length == 2) return {\n year: parseInt(pieces[0]),\n month: parseInt(pieces[1]),\n day: ''\n };else if (pieces.length == 1 && pieces[0] != '') return {\n year: parseInt(pieces[0]),\n month: '',\n day: ''\n };else return {\n year: '', month: '', day: ''\n };\n}\n\n/**\n * Change date input divs to select and boxes\n *\n * Changes all div's with id \"date_\" for a given data object (shortName, idStr) from a list of\n * inputs defining the parameters (view mode) to a inputs and a select (edit mode). It then\n * calls the select2 function to replace the select with one matching the rest of the page.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction textToDate(shortName, idStr) {\n $(\"div[id^='date_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"date_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var dateStr = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n\n var dateParts = parseDate(dateStr);\n\n var html = \"\";\n html += \" - \";\n html += \" \";\n html += \" - \";\n html += \" \";\n html += \"\";\n cont.html(html);\n\n $(\"#\" + shortName + \"_\" + name + \"_month_\" + idStr).select2({\n width: '57%',\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Month'\n });\n }\n });\n}\n\n/**\n * Pad an integer\n *\n * This is a helper function to pad an integer with 0s for display. This is useful to pad\n * a month or day with a leading 0.\n *\n * @param int|string num The number to pad\n * @param int size The total width of the desired output\n * @return string A string containing a size-wide integer representation, 0-padded\n */\nfunction pad(num, size) {\n var s = num + \"\";\n while (s.length < size) s = \"0\" + s;\n return s;\n}\n\n/**\n * Updates the standard date input field\n *\n * If the date for the data object (shortName, idStr) has been turned into a 3-field edit\n * area, then this function will update the hidden standard date (YYYY-MM-DD) field with the\n * newest values from the human-enterable field.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction updateDate(shortName, idStr) {\n $(\"div[id^='date_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"date_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n\n if ($(\"#\" + shortName + \"_\" + name + \"_year_\" + idStr).exists()) {\n var year = $(\"#\" + shortName + \"_\" + name + \"_year_\" + idStr).val();\n var day = $(\"#\" + shortName + \"_\" + name + \"_day_\" + idStr).val();\n var month = $(\"#\" + shortName + \"_\" + name + \"_month_\" + idStr + \" option:selected\").val();\n\n var dateStr = \"\";\n if (year != \"\") {\n dateStr += pad(year, 4);\n if (month != \"\") {\n dateStr += \"-\" + pad(month, 2);\n if (day != \"\") {\n dateStr += \"-\" + pad(day, 2);\n }\n }\n }\n\n $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val(dateStr);\n }\n }\n });\n}\n\n/**\n * Return editable date area back to text\n *\n * If the date for the data object (shortName, idStr) has been turned into a 3-field edit\n * area, then this function will return the editable area back to the view mode text, replacing\n * the edit boxes with a paragraph containing the computed standard date string (YYYY-MM-DD).\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction dateToText(shortName, idStr) {\n $(\"div[id^='date_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"date_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n\n updateDate(shortName, idStr);\n\n var dateStr = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n\n var html = \"

    \" + dateStr + \"

    \";\n html += \"\";\n cont.html(html);\n }\n });\n}\n\n// TODO: If we want to show a DIV of edited and deleted components, we should use the following two functions\n// to get copies of the edited/deleted components from the page. We can then insert those copies onto a modal\n// dialog box with a \"Save\" or \"Continue\" button at the top and bottom.\n//\n// All the pieces shown in the dialog should be disabled. One way to do this would be using the following\n// method to place a semi-transparent div on top of the editable pieces, making them appear to be grayed out\n// and with the not permitted cursor.\n//\n// .append('
    ');\n//\n// Note: this modal should NOT be inside the constellation form so that we don't submit the values twice.\n\n/**\n * Get all the edited components\n */\nfunction getEdited() {\n var html = \"\";\n\n $(\"#constellation_form div.edited-component\").each(function () {\n var cont = $(this);\n console.log(cont.attr('id'));\n var pieces = cont.attr('id').split(\"_panel_\");\n if (pieces.length == 2) {\n html += \"
    \" + $(\"#\" + pieces[0] + \"_datapart_\" + pieces[1]).html() + \"
    \";\n }\n });\n\n return html;\n}\n\n/**\n * Get all the deleted components\n */\nfunction getDeleted() {\n var html = \"\";\n\n $(\"#constellation_form div.deleted-component\").each(function () {\n var cont = $(this);\n console.log(cont.attr('id'));\n var pieces = cont.attr('id').split(\"_panel_\");\n if (pieces.length == 2) {\n html += \"
    \" + $(\"#\" + pieces[0] + \"_datapart_\" + pieces[1]).html() + \"
    \";\n }\n });\n\n return html;\n}\n\nfunction turnOnEditDeleteButtons(part = '') {\n var divID = '';\n if (part != '') divID = \"#\" + part + \" \";\n // Turn on the edit buttons\n $(divID + \"a[id*='editbutton']\").each(function () {\n var obj = $(this);\n var pieces = obj.attr('id').split(\"_\");\n\n if (pieces.length == 3) {\n var short = pieces[0];\n var i = pieces[2];\n obj.on(\"click\", function () {\n makeEditable(short, i);\n });\n } else if (pieces.length == 5 && pieces[0] == \"scm\") {\n var short = pieces[1];\n var i = pieces[4];\n var j = pieces[3];\n obj.on(\"click\", function () {\n makeSCMEditable(short, i, j);\n });\n } else if (pieces.length == 5) {\n var short = pieces[0] + \"_\" + pieces[1] + \"_\" + pieces[2];\n var i = pieces[4];\n obj.on(\"click\", function () {\n makeEditable(short, i);\n });\n }\n });\n\n // Turn on the delete buttons\n $(divID + \"a[id*='deletebutton']\").each(function () {\n var obj = $(this);\n var pieces = obj.attr('id').split(\"_\");\n\n if (pieces.length == 3) {\n var short = pieces[0];\n var i = pieces[2];\n obj.on(\"click\", function () {\n setDeleted(short, i);\n });\n } else if (pieces.length == 5 && pieces[0] == \"scm\") {\n var short = pieces[1];\n var i = pieces[4];\n var j = pieces[3];\n obj.on(\"click\", function () {\n setSCMDeleted(short, i, j);\n });\n } else if (pieces.length == 5) {\n var short = pieces[0] + \"_\" + pieces[1] + \"_\" + pieces[2];\n var i = pieces[4];\n obj.on(\"click\", function () {\n setDeleted(short, i);\n });\n }\n });\n}\n\nfunction turnOnTooltipsForTab(part = '') {\n var divID = '';\n if (part != '') divID = \"#\" + part + \" \";\n // Load tooltips\n $(function () {\n $(divID + '[data-toggle=\"tooltip\"]').tooltip();\n });\n\n // Load popovers\n $(function () {\n $(divID + '[data-toggle=\"popover\"]').popover({\n trigger: 'hover',\n container: 'body'\n });\n });\n}\n\nfunction updatePictureArrow(shortName, i, newValue) {\n $('#' + shortName + '_relationPictureArrow_' + i).text(newValue);\n}\n\nfunction updatePictureTitle(shortName, i, newValue) {\n $('#' + shortName + '_relationPictureTitle_' + i).text(newValue);\n}\n\nfunction updatePictureIcon(shortName, i, entityType) {\n var html = \"\";\n if (entityType == 'person') html = '
    ';else if (entityType == 'corporateBody') html = '
    ';else if (entityType == 'family') html = '
    ';\n $('#' + shortName + '_relationPictureIcon_' + i).html(html);\n}\n\nvar geoPlaceLoadResults = null;\n\nfunction loadGeoPlaceResultCache() {\n $(\"input[id^='place_geoplace_id_']\").each(function () {\n var obj = $(this);\n // Query for term by ajax\n if (obj.val() != null && obj.val() != \"\") {\n $.get(snacUrl + \"/vocabulary/read?type=geoPlace&id=\" + obj.val(), null, function (data) {\n // Check the return value from the ajax. If success, then go to dashboard\n if (data.term) {\n if (!geoPlaceLoadResults) geoPlaceLoadResults = new Array();\n geoPlaceLoadResults.push(data.term);\n }\n });\n }\n });\n}\n\nfunction chooseSuggestedGeoPlace(selectID, idStr, value) {\n // idStr == id number on the page\n var obj = $(\"#\" + selectID);\n obj.select2('destroy');\n obj.val(value);\n geovocab_select_replace(obj, \"_\" + idStr);\n updatePlaceHeading(\"place\", idStr, value);\n}\n\nfunction updatePlaceHeading(shortName, i, newValue) {\n var place = null;\n if (!geoPlaceSearchResults && !geoPlaceLoadResults) {\n $('#' + shortName + '_confirmed_' + i).val(\"false\");\n $('#' + shortName + '_geoterm_text_' + i).html(\"Unconfirmed\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).addClass(\"disabled\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).prop('onclick', null).off(\"click\");\n if ($('#' + shortName + '_original_' + i).val() != \"\") $('#' + shortName + '_geoterm_caption_' + i).text(\"Recorded as: \" + $('#' + shortName + '_original_' + i).val());else $('#' + shortName + '_geoterm_caption_' + i).text();\n return;\n }\n\n if (geoPlaceSearchResults) {\n geoPlaceSearchResults.forEach(function (result) {\n if (result.id == newValue) place = result;\n });\n }\n\n if (!place && geoPlaceLoadResults) {\n geoPlaceLoadResults.forEach(function (result) {\n if (result.id == newValue) place = result;\n });\n }\n\n if (!place) {\n $('#' + shortName + '_confirmed_' + i).val(\"false\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).addClass(\"disabled\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).off(\"click\");\n if ($('#' + shortName + '_original_' + i).val() != \"\") {\n $('#' + shortName + '_geoterm_text_' + i).html(\"Unconfirmed\");\n $('#' + shortName + '_geoterm_caption_' + i).text(\"Recorded as: \" + $('#' + shortName + '_original_' + i).val());\n } else {\n $('#' + shortName + '_geoterm_text_' + i).text(\"--\");\n $('#' + shortName + '_geoterm_caption_' + i).text(\"GeoPlace term not specified\");\n }\n return;\n }\n $('#' + shortName + '_confirmed_' + i).val(\"true\");\n $('#' + shortName + '_geoterm_text_' + i).text(place.name);\n $('#' + shortName + '_geoterm_caption_' + i).text(place.administrationCode + \", \" + place.countryCode);\n if (place.latitude && place.longitude) {\n $('#' + shortName + \"_geoterm_maplink_\" + i).prop('onclick', null).off(\"click\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).on(\"click\", function () {\n openGeoPlaceViewer(place.id);return false;\n });\n $('#' + shortName + \"_geoterm_maplink_\" + i).removeClass(\"disabled\");\n } else {\n $('#' + shortName + \"_geoterm_maplink_\" + i).addClass(\"disabled\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).prop('onclick', null).off(\"click\");\n }\n}\n\nfunction magicDefaultFill(selectID, vocabType) {\n if (typeof defaults[vocabType] !== undefined) {\n\n var data = {\n id: defaults[vocabType].id,\n text: defaults[vocabType].term\n };\n\n // If the selected item exists, then select it. Else, add a new option\n // and select it.\n if ($('#' + selectID).find(\"option[value='\" + data.id + \"']\").length) {\n $('#' + selectID).val(data.id).trigger('change');\n } else {\n var newOption = new Option(data.text, data.id, false, true);\n $('#' + selectID).append(newOption).trigger('change');\n }\n }\n}\n\nfunction capitalize(word) {\n return word[0].toUpperCase() + word.slice(1);\n}\n\nfunction parseName(e) {\n $('#name-parser-options').text('');\n var $nameComponents = $(e.target).closest('.name-components');\n\n var $partType = $nameComponents.find(\"select:last\");\n var $textbox = $nameComponents.find('input[type=\"text\"]:last');\n\n var name = $textbox.val();\n\n var entityType = $('#entityType').text().trim();\n $('#name-parser-type').text(capitalize(entityType));\n $('#name-parser-original').text(name);\n\n var parser = new NameParser();\n var guesses = parser.guessPerson(name);\n\n var parsedOption = '';\n\n var counter = 0;\n guesses.forEach(function (guess) {\n // attach name data object to radio\n for (var key in guess) {\n if (guess[key] && guess[key].length != 0) {\n parsedOption += \"
  • \" + key + \": \" + guess[key] + \"
  • \";\n }\n }\n\n $('#name-parser-options').append(\"
    \" + \"
    \");\n\n $('#name-parser-options').find(\"input[type='radio']:last\").data(\"parsed-name\", guess);\n\n parsedOption = '';\n counter++;\n });\n\n $('#name-parser-options').find(\"input[type='radio']:first\").prop('checked', true);\n\n $('#parser-accept-btn').unbind('click');\n $('#parser-accept-btn').on('click', function () {\n var selectedName = $('#name-parser input[type=\"radio\"]:checked').data('parsed-name');\n $.get(snacUrl + \"/vocabulary/?type=name_component&entity_type=700\").done(function (data) {\n acceptParsedName(selectedName, $nameComponents, name, data.results);\n });\n });\n}\n\nfunction acceptParsedName(selectedName, $nameComponents, name, nameComponentIDs) {\n var i = $nameComponents.attr('id').split('_')[2];\n var $nameComponent = $nameComponents.find('.reorderable'); ///\n $nameComponent.replaceWith('
    Name: ' + name + '
    ');\n\n var nameComponentMap = {};\n\n for (var k = 0; k < nameComponentIDs.length; k++) {\n nameComponentMap[nameComponentIDs[k].text] = nameComponentIDs[k].id;\n }\n // var nameComponentMap = {\n // 'Surname': 400223,\n // 'Forename': 400224,\n // 'NameAddition': 400236,\n // 'Date': 400237,\n // 'NameExpansion': 400226,\n // 'Numeration': 400225\n // };\n\n for (var key in selectedName) {\n if (key == 'NameAdditions') {\n key = 'NameAddition';\n for (var j = 0; j < selectedName['NameAdditions'].length; j++) {\n newNameEntryComponent(i);\n var option = new Option(key, nameComponentMap[key], false, true);\n $partType = $nameComponents.find(\"select:last\");\n $partType.append(option).trigger('change');\n $textbox = $nameComponents.find(\"input[type='text']:last\");\n $textbox.val(selectedName[\"NameAdditions\"][j]);\n\n $partType.append(option).trigger('change');\n }\n } else if (selectedName[key] && nameComponentMap[key]) {\n newNameEntryComponent(i);\n var option = new Option(key, nameComponentMap[key], false, true);\n $partType = $nameComponents.find(\"select:last\");\n $partType.append(option).trigger('change');\n $textbox = $nameComponents.find(\"input[type='text']:last\");\n $textbox.val(selectedName[key]);\n\n $partType.append(option).trigger('change');\n }\n }\n\n $(\"#nameEntry_datapart_\" + i).find(\".name-parser\").remove();\n updateNameEntryHeading(i);\n}\n\nfunction removeParserButton(i) {\n $('#nameEntry_datapart_' + i).find('.name-parser').remove();\n}\n\n/**\n * Things to do when the page finishes loading\n */\n$(document).ready(function () {\n // Load the place cache, if needed\n loadGeoPlaceResultCache();\n\n // listen for name-parsing\n $('#nameEntries').on('click', '.name-parser', function (event) {\n event.preventDefault();\n parseName(event);\n $(\"#name-parser\").modal('toggle');\n });\n\n $('#name-parser').on('shown.bs.modal', function () {\n $('#parser-accept-btn').focus();\n });\n\n // If the constellation is in \"insert\" mode, then we should automatically set \"somethingHasBeenEdited\"\n // to be true...\n if ($('#operation').val() == 'insert') setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n turnOnEditDeleteButtons();\n\n // Attach functions to the entityType select\n if ($('#entityType').exists()) {\n $('#entityType').change(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n // If there is an ID, then we need to set this to update\n // Else, the main-level operation should be and remain insert\n if ($('#constellationid').val() != null && $('#constellationid').val() != \"\") {\n $('#operation').val(\"update\");\n }\n });\n }\n\n // Name Entry doesn't get any AJAX, since it is pre-loaded\n var nameEntryid = 1;\n if ($('#next_nameEntry_i').exists()) {\n nameEntryid = parseInt($('#next_nameEntry_i').text());\n }\n console.log(\"Next NameEntry ID: \" + nameEntryid);\n if ($('#btn_add_nameEntry').exists()) {\n $('#btn_add_nameEntry').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#nameEntry_template').clone();\n var html = text.html().replace(/ZZ/g, nameEntryid);\n $('#add_nameEntry_div').after(html);\n turnOnButtons(\"nameEntry\", nameEntryid);\n turnOnTooltips(\"nameEntry\", nameEntryid);\n makeEditable(\"nameEntry\", nameEntryid);\n nameEntryid = nameEntryid + 1;\n return false;\n });\n }\n\n // Attach functions to each of the \"+ Add New _______\" buttons\n\n // Code to handle adding new genders to the page\n var genderid = 1;\n var genderOpen = false;\n if ($('#genderstab').exists()) {\n $('#genderstab').click(function () {\n // Don't open a second time\n if (genderOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=genders\", null, function (data) {\n genderOpen = true;\n $('#genders').html(data);\n\n turnOnEditDeleteButtons(\"genders\");\n\n if ($('#next_gender_i').exists()) {\n genderid = parseInt($('#next_gender_i').text());\n }\n console.log(\"Next Gender ID: \" + genderid);\n if ($('#btn_add_gender').exists()) {\n $('#btn_add_gender').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#gender_template').clone();\n var html = text.html().replace(/ZZ/g, genderid);\n $('#add_gender_div').after(html);\n turnOnButtons(\"gender\", genderid);\n turnOnTooltips(\"gender\", genderid);\n makeEditable(\"gender\", genderid);\n genderid = genderid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"genders\");\n });\n });\n }\n\n // Code to handle adding new genders to the page\n var existid = 1;\n var existOpen = false;\n if ($('#existstab').exists()) {\n $('#existstab').click(function () {\n // Don't open a second time\n if (existOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=dates\", null, function (data) {\n existOpen = true;\n $('#dates').html(data);\n\n turnOnEditDeleteButtons(\"dates\");\n\n if ($('#next_exist_i').exists()) {\n existid = parseInt($('#next_exist_i').text());\n }\n console.log(\"Next Exist Date ID: \" + existid);\n if ($('#btn_add_exist_date').exists()) {\n $('#btn_add_exist_date').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#exist_date_template').clone();\n var html = text.html().replace(/ZZ/g, existid);\n $('#add_exist_div').after(html);\n turnOnButtons(\"exist\", existid);\n turnOnTooltips(\"exist\", existid);\n makeEditable(\"exist\", existid);\n existid = existid + 1;\n return false;\n });\n }\n if ($('#btn_add_exist_dateRange').exists()) {\n $('#btn_add_exist_dateRange').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#exist_dateRange_template').clone();\n var html = text.html().replace(/ZZ/g, existid);\n $('#add_exist_div').after(html);\n turnOnButtons(\"exist\", existid);\n turnOnTooltips(\"exist\", existid);\n makeEditable(\"exist\", existid);\n existid = existid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"dates\");\n });\n });\n }\n\n var sameAsid = 1;\n var sameAsOpen = false;\n if ($('#sameAstab').exists()) {\n $('#sameAstab').click(function () {\n // Don't open a second time\n if (sameAsOpen) return;\n //set sameAs vocab type id\n $.get(snacUrl + \"/vocabulary?type=record_type&q=SameAs\", null, function (data) {\n sameAsTermId = data.results[0].id;\n $(\"#sameAs_type_id_ZZ\").val(sameAsTermId);\n });\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=sameAs\", null, function (data) {\n sameAsOpen = true;\n $('#sameAs').html(data);\n\n turnOnEditDeleteButtons(\"sameAs\");\n\n if ($('#next_sameAs_i').exists()) {\n sameAsid = parseInt($('#next_sameAs_i').text());\n }\n console.log(\"Next sameAs ID: \" + sameAsid);\n if ($('#btn_add_sameAs').exists()) {\n $('#btn_add_sameAs').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#sameAs_template').clone();\n var html = text.html().replace(/ZZ/g, sameAsid);\n $('#add_sameAs_div').after(html);\n turnOnButtons(\"sameAs\", sameAsid);\n turnOnTooltips(\"sameAs\", sameAsid);\n makeEditable(\"sameAs\", sameAsid);\n sameAsid = sameAsid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"sameAs\");\n });\n });\n }\n\n var entityIDid = 1;\n var entityIDOpen = false;\n if ($('#entityIDtab').exists()) {\n $('#entityIDtab').click(function () {\n // Don't open a second time\n if (entityIDOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=entityID\", null, function (data) {\n entityIDOpen = true;\n $('#entityID').html(data);\n\n turnOnEditDeleteButtons(\"entityID\");\n\n if ($('#next_entityID_i').exists()) {\n entityIDid = parseInt($('#next_entityID_i').text());\n }\n console.log(\"Next entityID ID: \" + entityIDid);\n if ($('#btn_add_entityID').exists()) {\n $('#btn_add_entityID').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#entityID_template').clone();\n var html = text.html().replace(/ZZ/g, entityIDid);\n $('#add_entityID_div').after(html);\n turnOnButtons(\"entityID\", entityIDid);\n turnOnTooltips(\"entityID\", entityIDid);\n makeEditable(\"entityID\", entityIDid);\n entityIDid = entityIDid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"entityID\");\n });\n });\n }\n\n var sourceid = 1;\n var sourceOpen = false;\n if ($('#sourcestab').exists()) {\n $('#sourcestab').click(function () {\n // Don't open a second time\n if (sourceOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=sources\", null, function (data) {\n sourceOpen = true;\n $('#sources').html(data);\n\n turnOnEditDeleteButtons(\"sources\");\n\n if ($('#next_source_i').exists()) {\n sourceid = parseInt($('#next_source_i').text());\n }\n console.log(\"Next source ID: \" + sourceid);\n if ($('#btn_add_source').exists()) {\n $('#btn_add_source').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#source_template').clone();\n var html = text.html().replace(/ZZ/g, sourceid);\n $('#add_source_div').after(html);\n turnOnButtons(\"source\", sourceid);\n turnOnTooltips(\"source\", sourceid);\n makeEditable(\"source\", sourceid);\n sourceid = sourceid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"sources\");\n });\n });\n }\n\n var resourceRelationid = 1;\n var resourceRelationOpen = false;\n if ($('#resourceRelationstab').exists()) {\n $('#resourceRelationstab').click(function () {\n // Don't open a second time\n if (resourceRelationOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=resourceRelations\", null, function (data) {\n resourceRelationOpen = true;\n $('#resourceRelations').html(data);\n\n turnOnEditDeleteButtons(\"resourceRelations\");\n\n if ($('#next_resourceRelation_i').exists()) {\n resourceRelationid = parseInt($('#next_resourceRelation_i').text());\n }\n console.log(\"Next resourceRelation ID: \" + resourceRelationid);\n if ($('#btn_create_resourceRelation').exists()) {\n $('#btn_create_resourceRelation').click(function () {\n var rid = $('input[name=resourceChoice]:checked', '#resource_search_form').val();\n if (rid != null && resourceResults != null && rid != 'new') {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#resourceRelation_template').clone();\n var html = text.html().replace(/ZZ/g, resourceRelationid);\n $('#add_resourceRelation_div').after(html);\n\n if (typeof resourceResults[rid].id !== 'undefined') $('#resourceRelation_resourceid_' + resourceRelationid).val(resourceResults[rid].id);\n if (typeof resourceResults[rid].version !== 'undefined') $('#resourceRelation_resourceversion_' + resourceRelationid).val(resourceResults[rid].version);\n\n if (typeof resourceResults[rid].link !== 'undefined') $('#resourceRelation_linkText_' + resourceRelationid).html(\"\" + resourceResults[rid].link + \"\" + \" View\");\n if (typeof resourceResults[rid].displayEntry !== 'undefined') $('#resourceRelation_displayEntryText_' + resourceRelationid).text(resourceResults[rid].displayEntry);\n if (typeof resourceResults[rid].title !== 'undefined') {\n $('#resourceRelation_titleText_' + resourceRelationid).text(resourceResults[rid].title);\n updatePictureTitle('resourceRelation', resourceRelationid, resourceResults[rid].title);\n }\n if (typeof resourceResults[rid].abstract !== 'undefined') $('#resourceRelation_abstractText_' + resourceRelationid).text(resourceResults[rid].abstract);\n if (typeof resourceResults[rid].extent !== 'undefined') $('#resourceRelation_extentText_' + resourceRelationid).text(resourceResults[rid].extent);\n // if (typeof resourceResults[rid].date !== 'undefined')\n // $('#resourceRelation_dateText_'+resourceRelationid).text(resourceResults[rid].date);\n if (typeof resourceResults[rid].documentType !== 'undefined' && typeof resourceResults[rid].documentType.term !== 'undefined') $('#resourceRelation_documentTypeText_' + resourceRelationid).text(resourceResults[rid].documentType.term);\n\n $('#resourceRelation_linkText_' + resourceRelationid).after(\"View in SNAC\");\n turnOnButtons(\"resourceRelation\", resourceRelationid);\n turnOnTooltips(\"resourceRelation\", resourceRelationid);\n makeEditable(\"resourceRelation\", resourceRelationid);\n resourceRelationid = resourceRelationid + 1;\n $(\"#resource-results-box\").html(\"\");\n return true;\n }\n return false;\n });\n }\n\n if ($('#btn_open_create_resource').exists()) {\n $('#btn_open_create_resource').click(function () {\n // Close this modal and open the new modal\n $(\"#resourceSearchPane\").modal(\"hide\");\n\n // Set a 500ms timeout to give the hidden search pane time to fully close\n setTimeout(function () {\n $(\"#resourceCreatePane\").modal(\"show\");\n }, 500);\n\n // Grab the empty template and replace\n var text = $('#resource_template').clone();\n var html = text.html().replace(/ZZ/g, 0);\n $('#resource-create-box').html(html);\n var $resourceForm = $(\"#resource_create_form\");\n // Copy the search contents to title or href\n if ($(\"#resource-searchbox\").val().indexOf(\"http\") == -1) $resourceForm.find(\"#resource-title\").val($(\"#resource-searchbox\").val());else $resourceForm.find(\"#resource-url\").val($(\"#resource-searchbox\").val());\n\n $resourceForm.find('[data-toggle=\"popover\"]').popover({\n trigger: 'hover',\n container: 'body'\n });\n loadVocabSelectOptions($resourceForm.find(\"#resource-type-select\"), \"document_type\", \"Resource Type\");\n vocab_select_replace($resourceForm.find(\"#resource-repo\"), \"\", \"holding\", 3);\n $resourceForm.find(\"#new-resource-language-btn\").on(\"click\", newResourceLanguage);\n $resourceForm.find(\"#magic-resource-language-btn\").on(\"click\", magicNewResourceLanguage);\n\n $('#search-results-box').on(\"click\", \"a.list-group-item\", selectHoldingRepository);\n var timeoutID = null;\n $resourceForm.find('#searchbox').keyup(function () {\n clearTimeout(timeoutID);\n timeoutID = setTimeout(function () {\n setSearchPosition(0);searchAndUpdate();\n }, 500);\n });\n\n // Remove the search results from the other modal\n $(\"#resource-results-box\").html(\"\");\n return false;\n });\n }\n\n if ($('#btn_create_resource').exists()) {\n $('#resource_create_form').on(\"submit\", function () {\n // Remove leading and trailing whitespace\n if ($(\"#resource_create_form #resource-url\").val() == \"\") {\n if (!confirm('Are you sure you want to save without an HREF?')) {\n return;\n }\n }\n $(\"#resource_create_form input, textarea\").each(function () {\n $(this).val($.trim($(this).val()));\n });\n setDeletedResourceLanguageOperations($(\"#resource_create_form\"));\n\n $.post(snacUrl + \"/save_resource\", $(\"#resource_create_form\").serialize(), function (data) {\n if (typeof data.result !== 'undefined' && data.result !== 'false') {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#resourceRelation_template').clone();\n var html = text.html().replace(/ZZ/g, resourceRelationid); // clones DOM, replaces zz with next ids\n $('#add_resourceRelation_div').after(html);\n\n if (typeof data.resource.id !== 'undefined') $('#resourceRelation_resourceid_' + resourceRelationid).val(data.resource.id);\n if (typeof data.resource.version !== 'undefined') $('#resourceRelation_resourceversion_' + resourceRelationid).val(data.resource.version);\n\n if (typeof data.resource.link !== 'undefined') $('#resourceRelation_linkText_' + resourceRelationid).html(\"\" + data.resource.link + \"\" + \" View\");\n if (typeof data.resource.displayEntry !== 'undefined') $('#resourceRelation_displayEntryText_' + resourceRelationid).text(data.resource.displayEntry);\n if (typeof data.resource.title !== 'undefined') {\n $('#resourceRelation_titleText_' + resourceRelationid).text(data.resource.title);\n updatePictureTitle('resourceRelation', resourceRelationid, data.resource.title);\n }\n if (typeof data.resource.abstract !== 'undefined') $('#resourceRelation_abstractText_' + resourceRelationid).text(data.resource.abstract);\n if (typeof data.resource.extent !== 'undefined') $('#resourceRelation_extentText_' + resourceRelationid).text(data.resource.extent);\n if (typeof data.resource.documentType !== 'undefined' && typeof data.resource.documentType.term !== 'undefined') $('#resourceRelation_documentTypeText_' + resourceRelationid).text(data.resource.documentType.term);\n\n $('#resourceRelation_linkText_' + resourceRelationid).after(\"View in SNAC\");\n turnOnButtons(\"resourceRelation\", resourceRelationid);\n turnOnTooltips(\"resourceRelation\", resourceRelationid);\n makeEditable(\"resourceRelation\", resourceRelationid);\n resourceRelationid = resourceRelationid + 1;\n $(\"#resourceCreatePane\").modal(\"hide\");\n $('#resource-create-box').html(\"\");\n return true;\n } else {\n console.log(data);\n return false;\n }\n });\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"resourceRelations\");\n });\n });\n }\n\n var constellationRelationid = 1;\n var constellationRelationOpen = false;\n if ($('#constellationRelationstab').exists()) {\n $('#constellationRelationstab').click(function () {\n // Don't open a second time\n if (constellationRelationOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=constellationRelations\", null, function (data) {\n constellationRelationOpen = true;\n $('#constellationRelations').html(data);\n\n turnOnEditDeleteButtons(\"constellationRelations\");\n\n if ($('#next_constellationRelation_i').exists()) {\n constellationRelationid = parseInt($('#next_constellationRelation_i').text());\n }\n console.log(\"Next constellationRelation ID: \" + constellationRelationid);\n if ($('#btn_create_constellationRelation').exists()) {\n $('#btn_create_constellationRelation').click(function () {\n var cid = $('input[name=relationChoice]:checked', '#relation_search_form').val();\n if (cid != null) {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#constellationRelation_template').clone();\n var html = text.html().replace(/ZZ/g, constellationRelationid);\n $('#add_constellationRelation_div').after(html);\n $('#constellationRelation_targetID_' + constellationRelationid).val(cid);\n $('#constellationRelation_content_' + constellationRelationid).val($('#relationChoice_nameEntry_' + cid).val());\n $('#constellationRelation_targetArkID_' + constellationRelationid).val($('#relationChoice_arkID_' + cid).val());\n $('#constellationRelation_targetEntityType_' + constellationRelationid).val($('#relationChoice_entityType_' + cid).val());\n\n updatePictureIcon('constellationRelation', constellationRelationid, $('#relationChoice_entityTypeText_' + cid).val());\n updatePictureTitle('constellationRelation', constellationRelationid, $('#relationChoice_nameEntry_' + cid).val());\n\n $('#constellationRelation_contentText_' + constellationRelationid).text($('#relationChoice_nameEntry_' + cid).val());\n $('#constellationRelation_targetArkIDText_' + constellationRelationid).text($('#relationChoice_arkID_' + cid).val());\n\n turnOnButtons(\"constellationRelation\", constellationRelationid);\n turnOnTooltips(\"constellationRelation\", constellationRelationid);\n makeEditable(\"constellationRelation\", constellationRelationid);\n\n constellationRelationid = constellationRelationid + 1;\n\n return true;\n }\n\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"constellationRelations\");\n });\n });\n }\n\n var languageid = 1;\n var languageOpen = false;\n if ($('#languagesUsedtab').exists()) {\n $('#languagesUsedtab').click(function () {\n // Don't open a second time\n if (languageOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=languagesUsed\", null, function (data) {\n languageOpen = true;\n $('#languagesUsed').html(data);\n\n turnOnEditDeleteButtons(\"languagesUsed\");\n\n if ($('#next_language_i').exists()) {\n languageid = parseInt($('#next_language_i').text());\n }\n console.log(\"Next language ID: \" + languageid);\n if ($('#btn_add_language').exists()) {\n $('#btn_add_language').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#language_template').clone();\n var html = text.html().replace(/ZZ/g, languageid);\n $('#add_language_div').after(html);\n turnOnButtons(\"language\", languageid);\n turnOnTooltips(\"language\", languageid);\n makeEditable(\"language\", languageid);\n languageid = languageid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"languagesUsed\");\n });\n });\n }\n\n var subjectid = 1;\n var subjectOpen = false;\n if ($('#subjectstab').exists()) {\n $('#subjectstab').click(function () {\n // Don't open a second time\n if (subjectOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=subjects\", null, function (data) {\n subjectOpen = true;\n $('#subjects').html(data);\n\n turnOnEditDeleteButtons(\"subjects\");\n\n if ($('#next_subject_i').exists()) {\n subjectid = parseInt($('#next_subject_i').text());\n }\n console.log(\"Next subject ID: \" + subjectid);\n if ($('#btn_add_subject').exists()) {\n $('#btn_add_subject').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#subject_template').clone();\n var html = text.html().replace(/ZZ/g, subjectid);\n $('#add_subject_div').after(html);\n turnOnButtons(\"subject\", subjectid);\n turnOnTooltips(\"subject\", subjectid);\n makeEditable(\"subject\", subjectid);\n subjectid = subjectid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"subjects\");\n });\n });\n }\n\n var nationalityid = 1;\n var nationalityOpen = false;\n if ($('#nationalitiestab').exists()) {\n $('#nationalitiestab').click(function () {\n // Don't open a second time\n if (nationalityOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=nationalities\", null, function (data) {\n nationalityOpen = true;\n $('#nationalities').html(data);\n\n turnOnEditDeleteButtons(\"nationalities\");\n\n if ($('#next_nationality_i').exists()) {\n nationalityid = parseInt($('#next_nationality_i').text());\n }\n console.log(\"Next nationality ID: \" + nationalityid);\n if ($('#btn_add_nationality').exists()) {\n $('#btn_add_nationality').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#nationality_template').clone();\n var html = text.html().replace(/ZZ/g, nationalityid);\n $('#add_nationality_div').after(html);\n turnOnButtons(\"nationality\", nationalityid);\n turnOnTooltips(\"nationality\", nationalityid);\n makeEditable(\"nationality\", nationalityid);\n nationalityid = nationalityid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"nationalities\");\n });\n });\n }\n\n var functionid = 1;\n var functionOpen = false;\n if ($('#functionstab').exists()) {\n $('#functionstab').click(function () {\n // Don't open a second time\n if (functionOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=functions\", null, function (data) {\n functionOpen = true;\n $('#functions').html(data);\n\n turnOnEditDeleteButtons(\"functions\");\n\n if ($('#next_function_i').exists()) {\n functionid = parseInt($('#next_function_i').text());\n }\n console.log(\"Next function ID: \" + functionid);\n if ($('#btn_add_function').exists()) {\n $('#btn_add_function').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#function_template').clone();\n var html = text.html().replace(/ZZ/g, functionid);\n $('#add_function_div').after(html);\n turnOnButtons(\"function\", functionid);\n turnOnTooltips(\"function\", functionid);\n makeEditable(\"function\", functionid);\n functionid = functionid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"functions\");\n });\n });\n }\n\n var occupationid = 1;\n var occupationOpen = false;\n if ($('#occupationstab').exists()) {\n $('#occupationstab').click(function () {\n // Don't open a second time\n if (occupationOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=occupations\", null, function (data) {\n occupationOpen = true;\n $('#occupations').html(data);\n\n turnOnEditDeleteButtons(\"occupations\");\n\n if ($('#next_occupation_i').exists()) {\n occupationid = parseInt($('#next_occupation_i').text());\n }\n console.log(\"Next occupation ID: \" + occupationid);\n if ($('#btn_add_occupation').exists()) {\n $('#btn_add_occupation').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#occupation_template').clone();\n var html = text.html().replace(/ZZ/g, occupationid);\n $('#add_occupation_div').after(html);\n turnOnButtons(\"occupation\", occupationid);\n turnOnTooltips(\"occupation\", occupationid);\n makeEditable(\"occupation\", occupationid);\n occupationid = occupationid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"occupations\");\n });\n });\n }\n\n var legalStatusid = 1;\n var legalStatusOpen = false;\n if ($('#legalStatusestab').exists()) {\n $('#legalStatusestab').click(function () {\n // Don't open a second time\n if (legalStatusOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=legalStatuses\", null, function (data) {\n legalStatusOpen = true;\n $('#legalStatuses').html(data);\n\n turnOnEditDeleteButtons(\"legalStatuses\");\n\n if ($('#next_legalStatus_i').exists()) {\n legalStatusid = parseInt($('#next_legalStatus_i').text());\n }\n console.log(\"Next legalStatus ID: \" + legalStatusid);\n if ($('#btn_add_legalStatus').exists()) {\n $('#btn_add_legalStatus').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#legalStatus_template').clone();\n var html = text.html().replace(/ZZ/g, legalStatusid);\n $('#add_legalStatus_div').after(html);\n turnOnButtons(\"legalStatus\", legalStatusid);\n turnOnTooltips(\"legalStatus\", legalStatusid);\n makeEditable(\"legalStatus\", legalStatusid);\n legalStatusid = legalStatusid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"legalStatuses\");\n });\n });\n }\n\n var placeid = 1;\n var placeOpen = false;\n if ($('#placestab').exists()) {\n $('#placestab').click(function () {\n // Don't open a second time\n if (placeOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=places\", null, function (data) {\n placeOpen = true;\n $('#places').html(data);\n\n // Load the place cache, if needed\n loadGeoPlaceResultCache();\n\n turnOnEditDeleteButtons(\"places\");\n\n if ($('#next_place_i').exists()) {\n placeid = parseInt($('#next_place_i').text());\n }\n console.log(\"Next place ID: \" + placeid);\n if ($('#btn_add_place').exists()) {\n $('#btn_add_place').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#place_template').clone();\n var html = text.html().replace(/ZZ/g, placeid);\n $('#add_place_div').after(html);\n turnOnButtons(\"place\", placeid);\n turnOnTooltips(\"place\", placeid);\n makeEditable(\"place\", placeid);\n placeid = placeid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"places\");\n });\n });\n }\n\n var conventionDeclarationid = 1;\n var conventionDeclarationOpen = false;\n if ($('#conventionDeclarationstab').exists()) {\n $('#conventionDeclarationstab').click(function () {\n // Don't open a second time\n if (conventionDeclarationOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=conventionDeclarations\", null, function (data) {\n conventionDeclarationOpen = true;\n $('#conventionDeclarations').html(data);\n\n turnOnEditDeleteButtons(\"conventionDeclarations\");\n\n if ($('#next_conventionDeclaration_i').exists()) {\n conventionDeclarationid = parseInt($('#next_conventionDeclaration_i').text());\n }\n console.log(\"Next conventionDeclaration ID: \" + conventionDeclarationid);\n if ($('#btn_add_conventionDeclaration').exists()) {\n $('#btn_add_conventionDeclaration').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#conventionDeclaration_template').clone();\n var html = text.html().replace(/ZZ/g, conventionDeclarationid);\n $('#add_conventionDeclaration_div').after(html);\n turnOnButtons(\"conventionDeclaration\", conventionDeclarationid);\n turnOnTooltips(\"conventionDeclaration\", conventionDeclarationid);\n makeEditable(\"conventionDeclaration\", conventionDeclarationid);\n conventionDeclarationid = conventionDeclarationid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"conventionDeclarations\");\n });\n });\n }\n\n var generalContextid = 1;\n var generalContextOpen = false;\n if ($('#generalContextstab').exists()) {\n $('#generalContextstab').click(function () {\n // Don't open a second time\n if (generalContextOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=generalContexts\", null, function (data) {\n generalContextOpen = true;\n $('#generalContexts').html(data);\n\n turnOnEditDeleteButtons(\"generalContexts\");\n\n if ($('#next_generalContext_i').exists()) {\n generalContextid = parseInt($('#next_generalContext_i').text());\n }\n console.log(\"Next generalContext ID: \" + generalContextid);\n if ($('#btn_add_generalContext').exists()) {\n $('#btn_add_generalContext').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#generalContext_template').clone();\n var html = text.html().replace(/ZZ/g, generalContextid);\n $('#add_generalContext_div').after(html);\n turnOnButtons(\"generalContext\", generalContextid);\n turnOnTooltips(\"generalContext\", generalContextid);\n makeEditable(\"generalContext\", generalContextid);\n generalContextid = generalContextid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"generalContexts\");\n });\n });\n }\n\n var structureOrGenealogyid = 1;\n var structureOrGenealogyOpen = false;\n if ($('#structureOrGenealogiestab').exists()) {\n $('#structureOrGenealogiestab').click(function () {\n // Don't open a second time\n if (structureOrGenealogyOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=structureOrGenealogies\", null, function (data) {\n structureOrGenealogyOpen = true;\n $('#structureOrGenealogies').html(data);\n\n turnOnEditDeleteButtons(\"structureOrGenealogies\");\n\n if ($('#next_structureOrGenealogy_i').exists()) {\n structureOrGenealogyid = parseInt($('#next_structureOrGenealogy_i').text());\n }\n console.log(\"Next structureOrGenealogy ID: \" + structureOrGenealogyid);\n if ($('#btn_add_structureOrGenealogy').exists()) {\n $('#btn_add_structureOrGenealogy').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#structureOrGenealogy_template').clone();\n var html = text.html().replace(/ZZ/g, structureOrGenealogyid);\n $('#add_structureOrGenealogy_div').after(html);\n turnOnButtons(\"structureOrGenealogy\", structureOrGenealogyid);\n turnOnTooltips(\"structureOrGenealogy\", structureOrGenealogyid);\n makeEditable(\"structureOrGenealogy\", structureOrGenealogyid);\n structureOrGenealogyid = structureOrGenealogyid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"structureOrGenealogies\");\n });\n });\n }\n\n var mandateid = 1;\n var mandateOpen = false;\n if ($('#mandatestab').exists()) {\n $('#mandatestab').click(function () {\n // Don't open a second time\n if (mandateOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=mandates\", null, function (data) {\n mandateOpen = true;\n $('#mandates').html(data);\n\n turnOnEditDeleteButtons(\"mandates\");\n\n if ($('#next_mandate_i').exists()) {\n mandateid = parseInt($('#next_mandate_i').text());\n }\n console.log(\"Next mandate ID: \" + mandateid);\n if ($('#btn_add_mandate').exists()) {\n $('#btn_add_mandate').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#mandate_template').clone();\n var html = text.html().replace(/ZZ/g, mandateid);\n $('#add_mandate_div').after(html);\n turnOnButtons(\"mandate\", mandateid);\n turnOnTooltips(\"mandate\", mandateid);\n makeEditable(\"mandate\", mandateid);\n mandateid = mandateid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"mandates\");\n });\n });\n }\n\n var biogHistid = 1;\n var biogHistOpen = false;\n if ($('#biogHiststab').exists()) {\n $('#biogHiststab').click(function () {\n // Don't open a second time\n if (biogHistOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=biogHists\", null, function (data) {\n biogHistOpen = true;\n $('#biogHists').html(data);\n\n turnOnEditDeleteButtons(\"biogHists\");\n\n if ($('#next_biogHist_i').exists()) {\n biogHistid = parseInt($('#next_biogHist_i').text());\n }\n console.log(\"Next biogHist ID: \" + biogHistid);\n if ($('#btn_add_biogHist').exists()) {\n $('#btn_add_biogHist').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#biogHist_template').clone();\n var html = text.html().replace(/ZZ/g, biogHistid);\n $('#add_biogHist_div').after(html);\n turnOnButtons(\"biogHist\", biogHistid);\n turnOnTooltips(\"biogHist\", biogHistid);\n makeEditable(\"biogHist\", biogHistid);\n biogHistid = biogHistid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"biogHists\");\n });\n });\n }\n\n turnOnTooltipsForTab();\n\n $(\"#info-dropdown\").click(function (e) {\n $(this).parent().toggleClass(\"open\");\n e.stopPropagation();\n });\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMy5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zcmMvdmlydHVhbGhvc3RzL3d3dy9qYXZhc2NyaXB0L3NyYy9lZGl0X3NjcmlwdHMuanM/N2I1OCJdLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEVkaXQgU2NyaXB0c1xuICpcbiAqIFNjcmlwdHMgdXNlZCBpbiB0aGUgZWRpdCBwYWdlXG4gKlxuICogQGF1dGhvciBSb2JiaWUgSG90dFxuICogQGxpY2Vuc2UgaHR0cHM6Ly9vcGVuc291cmNlLm9yZy9saWNlbnNlcy9CU0QtMy1DbGF1c2UgQlNEIDMtQ2xhdXNlXG4gKiBAY29weXJpZ2h0IDIwMTUgdGhlIFJlY3RvciBhbmQgVmlzaXRvcnMgb2YgdGhlIFVuaXZlcnNpdHkgb2YgVmlyZ2luaWEsIGFuZFxuICogICAgICAgICAgICB0aGUgUmVnZW50cyBvZiB0aGUgVW5pdmVyc2l0eSBvZiBDYWxpZm9ybmlhXG4gKi9cblxudmFy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l9cIitpZFN0cikuZXhpc3RzKCkpIHtcbiAgICAgICAgICAgICAgICBwbGFjZWhvbGRlck9mZiA9ICQoXCIjXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfcGxhY2Vob2xkZXJPZmZfXCIraWRTdHIpLnZhbCgpO1xuICAgICAgICAgICAgfVxuXG5cbiAgICAgICAgICAgIHZhciBodG1sID0gXCI8aW5wdXQgaWQ9J1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX1wiK2lkU3RyK1wiJyBuYW1lPSdcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStcIl9cIitcbiAgICAgICAgICAgICAgICAgICAgaWRTdHIrXCInIHR5cGU9J2hpZGRlbicgdmFsdWU9XFxcIlwiO1xuICAgICAgICAgICAgaWYgKGNoZWNrZWQpXG4gICAgICAgICAgICAgICAgaHRtbCArPSBcImNoZWNrZWRcIjtcbiAgICAgICAgICAgIGh0bWwgKz1cIlxcXCIvPlwiO1xuXG4gICAgICAgICAgICBodG1sICs9IFwiPHAgY2xhc3M9J2Zvcm0tY29udHJvbC1zdGF0aWMnPlwiO1xuICAgICAgICAgICAgaWYgKGNoZWNrZWQpIHtcbiAgICAgICAgICAgICAgICBpZiAocGxhY2Vob2xkZXJPbiAhPSBcIlwiKVxuICAgICAgICAgICAgICAgICAgIGh0bWwgKz0gcGxhY2Vob2xkZXJPbjtcbiAgICAgICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgICAgaHRtbCArPSB2YWx1ZTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHBsYWNlaG9sZGVyT2ZmICE9IFwiXCIpXG4gICAgICAgICAgICAgICAgICAgaHRtbCArPSBwbGFjZWhvbGRlck9mZjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGh0bWwgKz0gXCI8L3A+XCI7XG4gICAgICAgICAgICBpZiAocGxhY2Vob2xkZXJPbiAhPSBcIlwiKSB7XG4gICAgICAgICAgIC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2Vob2xkZXJfXCIraWRTdHIpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgcGxhY2Vob2xkZXIgPSAkKFwiI1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX3BsYWNlaG9sZGVyX1wiK2lkU3RyKS52YWwoKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdmFyIG9uS2V5VXAgPSBcIlwiO1xuICAgICAgICAgICAgaWYgKCQoXCIjXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfb25LZXlVcF9cIitpZFN0cikuZXhpc3RzKCkpIHtcbiAgICAgICAgICAgICAgICBvbktleVVwID0gJChcIiNcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStcIl9vbktleVVwX1wiK2lkU3RyKS52YWwoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBvbktleVVwU3RyID0gXCJcIjtcbiAgICAgICAgICAgIGlmIChvbktleVVwICE9IFwiXCIpIHtcbiAgICAgICAgICAgICAgICBvbktleVVwU3RyID0gXCIgb25LZXlVcD0nXCIrb25LZXlVcCtcIicgXCI7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHZhciBodG1sID0gXCI8aW5wdXQgaWQ9J1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX1wiK2lkU3RyK1wiJyBuYW1lPSdcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStcIl9cIitcbiAgICAgICAgICAgICAgICAgICAgaWRTdHIrXCInIGNsYXNzPSdmb3JtLWNvbnRyb2wnIHR5cGU9J3RleHQnIHZhbHVlPVxcXCJcIisgdmFsdWUgK1wiXFxcIlwiK3NpemVTdHIgKyBvbktleVVwU3RyICtcbiAgICAgICAgICAgICAgICAgICAgXCJwbGFjZWhvbGRlcj1cXFwiXCIrcGxhY2Vob2xkZXIrXCJcXFwiLz5cIjtcbiAgICAgICAgICAgIGlmIChzaXplICE9IDApIHtcbiAgICAgICAgICAgICAgICAgICAgaHRtbCArPSBcIjxpbnB1dCB0eXBlPVxcXCJoaWRkZW5cXFwiIGlkPVxcXCJcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStcIl9zaXplX1wiK2lkU3RyK1wiXFxcIiBcIiArXG4gICAgICAgICAgICAgICAgICAgICAgICBcInZhbHVlPVxcXCJcIitzaXplK1wiXFxcIi8+XCI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAocGxhY2Vob2xkZXIgIT0gXCJcIikge1xuICAgICAgICAgICAgICAgIGh0bWwgKz0gXCI8aW5wdXQgdHlwZT1cXFwiaGlkZGVuXFxcIiBpZD1cXFwiXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfcGxhY2Vob2xkZXJfXCIraWRTdHIrXCJcXFwiIFwiICtcbiAgICAgICAgICAgICAgICBcInZhbHVlPVxcXCJcIitwbGFjZWhvbGRlcitcIlxcXCIvPlwiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKG9uS2V5VXAgIT0gXCJcIikge1xuICAgICAgICAgICAgICAgIGh0bWwgKz0gXCI8aW5wdXQgdHlwZT1cXFwiaGlkZGVuXFxcIiBpZD1cXFwiXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfb25LZXlVcF9cIitpZFN0citcIlxcXCIgXCIgK1xuICAgICAgICAgICAgICAgIFwidmFsdWU9XFxcIlwiK29uS2V5VXArXCJcXFwiLz5cIjtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY29udC5odG1sKGh0bWwpO1xuICAgICAgICB9XG4gICAgfSk7XG5cblxufVxuXG5cbmZ1bmN0aW9uIGlucHV0VG9UZXh0KHNob3J0TmFtZSwgaWRTdHIpIHtcbiAgICAkKFwiI1wiK3Nob3J0TmFtZStcIl9kYXRhcGFydF9cIiArIGlkU3RyICsgXCIgZGl2W2lkXj0ndGV4dF9cIitzaG9ydE5hbWUrXCInXVwiKS5lYWNoKGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgY29udCA9ICQodG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JfcGxhY2Vob2xkZXJfXCIraWRTdHIpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgcGxhY2Vob2xkZXIgPSAkKFwiI1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX3BsYWNlaG9sZGVyX1wiK2lkU3RyKS52YWwoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBvbktleVVwID0gXCJcIjtcbiAgICAgICAgICAgIGlmICgkKFwiI1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX29uS2V5VXBfXCIraWRTdHIpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgb25LZXlVcCA9ICQoXCIjXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfb25LZXlVcF9cIitpZFN0cikudmFsKCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHZhciBodG1sID0gXCI8aW5wdXQgaWQ9J1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX1wiK2lkU3RyK1wiJyBuYW1lPSdcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStcIl9cIitcbiAgICAgICAgICAgICAgICAgICAgaWRTdHIrXCInIHR5cGU9J2hpZGRlbicgdmFsdWU9XFxcIlwiKyB2YWx1ZSArXCJcXFwiLz5cIjtcbiAgICAgICAgICAgIGh0bWwgKz0gXCI8cCBjbGFzcz0nZm9ybS1jb250cm9sLXN0YXRpYyc+XCIgKyB2YWx1ZSArIFwiPC9wPlwiO1xuICAgICAgICAgICAgaWYgKHNpemUgIT0gMCkge1xuICAgICAgICAgICAgICAgICAgICBodG1sICs9IFwiPGlucHV0IHR5cGU9XFxcImhpZGRlblxcXCIgaWQ9XFxcIlwiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX3NpemVfXCIraWRTdHIrXCJcXFwiIFwiICtcbiAgICAgICAgICAgICAgICAgICAgICAgIFwidmFsdWU9XFxcIlwiK3NpemUrXCJcXFwiLz5cIjtcbiAgICAgICAgICAgIH1cbiAg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uICAgICAgICAgICAgICAgICAgICBcIjxvcHRpb24+PC9vcHRpb24+XCI7XG4gICAgICAgICAgICB2YXIgbW9udGhzID0gW1wiSmFudWFyeVwiLCBcIkZlYnJ1YXJ5XCIsIFwiTWFyY2hcIiwgXCJBcHJpbFwiLCBcIk1heVwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwiSnVuZVwiLCBcIkp1bHlcIiwgXCJBdWd1c3RcIiwgXCJTZXB0ZW1iZXJcIiwgXCJPY3RvYmVyXCIsIFwiTm92ZW1iZXJcIiwgXCJEZWNlbWJlclwiXTtcblxuICAgICAgICAgICAgbW9udGhzLmZvckVhY2goZnVuY3Rpb24odmFsdWUsIGtleSkge1xuICAgICAgICAgICAgICAgIHZhciBtSW50ID0ga2V5ICsgMTtcblxuICAgICAgICAgICAgICAgIGlmIChtSW50ID09IGRhdGVQYXJ0cy5tb250aClcbiAgICAgICAgICAgICAgICAgICAgaHRtbCArPSBcIjxvcHRpb24gdmFsdWU9XFxcIlwiK21JbnQrXCJcXFwiIHNlbGVjdGVkPlwiK3ZhbHVlK1wiPC9vcHRpb24+XCI7XG4gICAgICAgICAgICAgICAgZWxzZVxuICAgICAgICAgICAgICAgICAgICBodG1sICs9IFwiPG9wdGlvbiB2YWx1ZT1cXFwiXCIrbUludCtcIlxcXCI+XCIrdmFsdWUrXCI8L29wdGlvbj5cIjtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgaHRtbCArPSBcIjxzZWxlY3Q+IFwiO1xuICAgICAgICAgICAgaHRtbCArPSBcIjxzcGFuIGNsYXNzPSdmb3JtLWNvbnRyb2wtc3RhdGljJz4gLSA8L3NwYW4+XCI7XG4gICAgICAgICAgICBodG1sICs9IFwiPGlucHV0IHR5cGU9J3RleHQnIHN0eWxlPSd3aWR0aDoxNCU7ZGlzcGxheTppbmxpbmU7JyBzaXplPScyJyBwbGFjZWhvbGRlcj0nREQnIGlkPSdcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStc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XCIpLnZhbCgpO1xuXG4gICAgICAgICAgICAgICAgdmFyIGRhdGVTdHIgPSBcIlwiO1xuICAgICAgICAgICAgICAgIGlmICh5ZWFyICE9IFwiXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgZGF0ZVN0ciArPSBwYWQoeWVhciwgNCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChtb250aCAhPSBcIlwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRlU3RyICs9IFwiLVwiICsgcGFkKG1vbnRoLDIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRheSAhPSBcIlwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0ZVN0ciArPSBcIi1cIiArIHBhZChkYXksMik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAkKFwiI1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX1wiK2lkU3RyKS52YWwoZGF0ZVN0cik7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgfVxuICAgIH0pO1xufVxuXG4vKipcbiAqIFJldHVybiBlZGl0YWJsZSBkYXRlIGFyZWEgYmFjayB0byB0ZXh0XG4gKlxuICogSWYgdGhlIGRhdGUgZm9yIHRoZSBkYXRhIG9iamVjdCAoc2hvcnROYW1lLCBpZFN0cikgaGFzIGJlZW4gdHVybmVkIGludG8gYSAzLWZpZWxkIGVkaXRcbiAqIGFyZWEsIHRoZW4gdGhpcyBmdW5jdGlvbiB3aWxsIHJldHVybiB0aGUgZWRpdGFibGUgYXJlYSBiYWNrIHRvIHRoZSB2aWV3IG1vZGUgdGV4dCwgcmVwbGFjaW5nXG4gKiB0aGUgZWRpdCBib3hlcyB3aXRoIGEgcGFyYWdyYXBoIGNvbnRhaW5pbmcgdGhlIGNvbXB1dGVkIHN0YW5kYXJkIGRhdGUgc3RyaW5nIChZWVlZLU1N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IFwiI1wiICsgcGFydCArIFwiIFwiO1xuICAgIC8vIFR1cm4gb24gdGhlIGVkaXQgYnV0dG9uc1xuICAgICQoZGl2SUQgKyBcImFbaWQqPSdlZGl0YnV0dG9uJ11cIikuZWFjaChmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIG9iaiA9ICQodGhpcyk7XG4gICAgICAgIHZhciBwaWVjZXMgPSBvYmouYXR0cignaWQnKS5zcGxpdChcIl9cIik7XG5cbiAgICAgICAgaWYgKHBpZWNlcy5sZW5ndGggPT0gMykge1xuICAgICAgICAgICAgdmFyIHNob3J0ID0gcGllY2VzWzBdO1xuICAgICAgICAgICAgdmFyIGkgPSBwaWVjZXNbMl07XG4gICAgICAgICAgICBvYmoub24oXCJjbGlja1wiLCBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoc2hvcnQsIGkpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSBpZiAocGllY2VzLmxlbmd0aCA9PSA1ICYmIHBpZWNlc1swXSA9PSBcInNjbVwiKSB7XG4gICAgICAgICAgICB2YXIgc2hvcnQgPSBwaWVjZXNbMV07XG4gICAgICAgICAgICB2YXIgaSA9IHBpZWNlc1s0XTtcbiAgICAgICAgICAgIHZhciBqID0gcGllY2VzWzNdO1xuICAgICAgICAgICAgb2JqLm9uKFwiY2xpY2tcIiwgZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgbWFrZVNDTUVkaXRhYmxlKHNob3J0LCBpLCBqKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2UgaWYgKHBpZWNlcy5sZW5ndGggPT0gNSkge1xuICAgICAgICAgICAgdmFyIHNob3J0ID0gcGllY2VzWzBdICsgXCJfXCIgKyBwaWVjZXNbMV0gKyBcIl9cIiArIHBpZWNlc1syXTtcbiAgICAgICAgICAgIHZhciBpID0gcGllY2VzWzRdO1xuICAgICAgICAgICAgb2JqLm9uKFwiY2xpY2tcIiwgZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgbWFrZUVkaXRhYmxlKHNob3J0LCBpKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfSk7XG5cbiAgICAvLyBUdXJuIG9uIHRoZSBkZWxldGUgYnV0dG9uc1xuICAgICQoZGl2SUQgKyBcImFbaWQqPSdkZWxldGVidXR0b24nXVwiKS5lYWNoKGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgb2JqID0gJCh0aGlzKTtcbiAgICAgICAgdmFyIHBpZWNlcyA9IG9iai5hdHRyKCdpZCcpLnNwbGl0KFwiX1wiKTtcblxuICAgICAgICBpZiAocGllY2VzLmxlbmd0aCA9PSAzKSB7XG4gICAgICAgICAgICB2YXIgc2hvcnQgPSBwaWVjZXNbMF07XG4gICAgICAgICAgICB2YXIgaSA9IHBpZWNlc1syXTtcbiAgICAgICAgICAgIG9iai5vbihcImNsaWNrXCIsIGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIHNldERlbGV0ZWQoc2hvcnQsIGkpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSBpZiAocGllY2VzLmxlbmd0aCA9PSA1ICYmIHBpZWNlc1swXSA9PSBcInNjbVwiKSB7XG4gICAgICAgICAgICB2YXIgc2hvcnQgPSBwaWVjZXNbMV07XG4gICAgICAgICAgICB2YXIgaSA9IHBpZWNlc1s0XTtcbiAgICAgICAgICAgIHZhciBqID0gcGllY2VzWzNdO1xuICAgICAgICAgICAgb2JqLm9uKFwiY2xpY2tcIiwgZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgc2V0U0NNRGVsZXRlZChzaG9ydCwgaSwgaik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIGlmIChwaWVjZXMubGVuZ3RoID09IDUpIHtcbiAgICAgICAgICAgIHZhciBzaG9ydCA9IHBpZWNlc1swXSArIFwiX1wiICsgcGllY2VzWzFdICsgXCJfXCIg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c3VsdHMuZm9yRWFjaChmdW5jdGlvbihyZXN1bHQpIHtcbiAgICAgICAgICAgIGlmIChyZXN1bHQuaWQgPT0gbmV3VmFsdWUpXG4gICAgICAgICAgICAgICAgcGxhY2UgPSByZXN1bHQ7XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIGlmICghcGxhY2UpIHtcbiAgICAgICAgJCgnIycrc2hvcnROYW1lKydfY29uZmlybWVkXycraSkudmFsKFwiZmFsc2VcIik7XG4gICAgICAgICQoJyMnK3Nob3J0TmFtZStcIl9nZW90ZXJtX21hcGxpbmtfXCIraSkuYWRkQ2xhc3MoXCJkaXNhYmxlZFwiKTtcbiAgICAgICAgJCgnIycrc2hvcnROYW1lK1wiX2dlb3Rlcm1fbWFwbGlua19cIitpKS5vZmYoXCJjbGlja1wiKTtcbiAgICAgICAgaWYgKCQoJyMnK3Nob3J0TmFtZSsnX29yaWdpbmFsXycraSkudmFsKCkgIT0gXCJcIikge1xuICAgICAgICAgICAgJCgnIycrc2hvcnROYW1lKydfZ2VvdGVybV90ZXh0XycraSkuaHRtbChcIjxlbT5VbmNvbmZpcm1lZDwvZW0+XCIpO1xuICAgICAgICAgICAgJCgnIycrc2hvcnROYW1lKydfZ2VvdGVybV9jYXB0aW9uXycraSkudGV4dChcIlJlY29yZGVkIGFzOiBcIiArICQoJyMnK3Nob3J0TmFtZSsnX29yaWdpbmFsXycraSkudmFsKCkpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgJCgnIycrc2hvcnROYW1lKydfZ2VvdGVybV90ZXh0XycraSkudGV4dChcIi0tXCIpO1xuICAgICAgICAgICAgJCgnIycrc2hvcnROYW1lKydfZ2VvdGVybV9jYXB0aW9uXycraSkudGV4dChcIkdlb1BsYWNlIHRlcm0gbm90IHNwZWNpZmllZFwiKTtcbiAgICAgICAgfVxuICAgICAgICByZXR1cm47XG4gICAgfVxuICAgICQoJyMnK3Nob3J0TmFtZSsnX2NvbmZpcm1lZF8nK2kpLnZhbCh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jYsXG4gICAgLy8gICAgICdOdW1lcmF0aW9uJzogNDAwMjI1XG4gICAgLy8gfTtcblxuICAgIGZvciAodmFyIGtleSBpbiBzZWxlY3RlZE5hbWUpIHtcbiAgICAgICAgaWYgKGtleSA9PSAnTmFtZUFkZGl0aW9ucycpIHtcbiAgICAgICAgICAgIGtleSA9ICdOYW1lQWRkaXRpb24nO1xuICAgICAgICAgICAgZm9yICh2YXIgaiA9IDA7IGogPCBzZWxlY3RlZE5hbWVbJ05hbWVBZGRpdGlvbnMnXS5sZW5ndGg7IGorKykge1xuICAgICAgICAgICAgICAgIG5ld05hbWVFbnRyeUNvbXBvbmVudChpKTtcbiAgICAgICAgICAgICAgICB2YXIgb3B0aW9uID0gbmV3IE9wdGlvbihrZXksIG5hbWVDb21wb25lbnRNYXBba2V5XSwgZmFsc2UsIHRydWUpO1xuICAgICAgICAgICAgICAgICRwYXJ0VHlwZSA9ICRuYW1lQ29tcG9uZW50cy5maW5kKFwic2VsZWN0Omxhc3RcIik7XG4gICAgICAgICAgICAgICAgJHBhcnRUeXBlLmFwcGVuZChvcHRpb24pLnRyaWdnZXIoJ2NoYW5nZScpO1xuICAgICAgICAgICAgICAgICR0ZXh0Ym94ID0gJG5hbWVDb21wb25lbnRzLmZpbmQoXCJpbnB1dFt0eXBlPSd0ZXh0J106bGFzdFwiKTtcbiAgICAgICAgICAgICAgICAkdGV4dGJveC52YWwoc2VsZWN0ZWROYW1lW1wiTmFtZUFkZGl0aW9uc1wiXVtqXSk7XG5cbiAgICAgICAgICAgICAgICAkcGFydFR5cGUuYXBwZW5kKG9wdGlvbikudHJpZ2dlcignY2hhbmdlJyk7XG4gICAgICAgICAgICB9XG4gICAgICAgIH0gZWxzZSBpZiAoc2VsZWN0ZWROYW1lW2tleV0gJiYgbmFtZUNvbXBvbmVudE1hcFtrZXldKSB7XG4gICAgICAgICAgICBuZXdOYW1lRW50cnlDb21wb25lbnQoaSk7XG4gICAgICAgICAgICB2YXIgb3B0aW9uID0gbm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ykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwiZ2VuZGVyc1wiKTtcblxuICAgICAgICAgICAgICAgIGlmICgkKCcjbmV4dF9nZW5kZXJfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIGdlbmRlcmlkID0gcGFyc2VJbnQoJCgnI25leHRfZ2VuZGVyX2knKS50ZXh0KCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIk5leHQgR2VuZGVyIElEOiBcIiArIGdlbmRlcmlkKTtcbiAgICAgICAgICAgICAgICBpZiAoJCgnI2J0bl9hZGRfZ2VuZGVyJykuZXhpc3RzKCkpe1xuICAgICAgICAgICAgICAgICAgICAkKCcjYnRuX2FkZF9nZW5kZXInKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNnZW5kZXJfdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSB0ZXh0Lmh0bWwoKS5yZXBsYWNlKC9aWi9nLCBnZW5kZXJpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX2dlbmRlcl9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJnZW5kZXJcIiwgZ2VuZGVyaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJnZW5kZXJcIiwgZ2VuZGVyaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUVkaXRhYmxlK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gICAgICAgICAgICAgICAgICBleGlzdGlkID0gcGFyc2VJbnQoJCgnI25leHRfZXhpc3RfaScpLnRleHQoKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiTmV4dCBFeGlzdCBEYXRlIElEOiBcIiArIGV4aXN0aWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9leGlzdF9kYXRlJykuZXhpc3RzKCkpe1xuICAgICAgICAgICAgICAgICAgICAkKCcjYnRuX2FkZF9leGlzdF9kYXRlJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjZXhpc3RfZGF0ZV90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGV4aXN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9leGlzdF9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJleGlzdFwiLCBleGlzdGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwiZXhpc3RcIiwgZXhpc3RpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJleGlzdFwiLCBleGlzdGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4aXN0aWQgPSBleGlzdGlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9leGlzdF9kYXRlUmFuZ2UnKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fYWRkX2V4aXN0X2RhdGVSYW5nZScpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRFZGl0ZWRGbGFnKHRydWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy9zb21ldGhpbmdIYXNCZWVuRWRpdGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0ZXh0ID0gJCgnI2V4aXN0X2RhdGVSYW5nZV90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGV4aXN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9leGlzdF9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJleGlzdFwiLCBleGlzdGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwiZXhpc3RcIiwgZXhpc3RpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJleGlzdFwiLCBleGlzdGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4aXN0aWQgPSBleGlzdGlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJkYXRlc1wiKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cblx0dmFyIHNhbW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KCQoJyNuZXh0X3NhbWVBc19pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IHNhbWVBcyBJRDogXCIgKyBzYW1lQXNpZCk7XG4gICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fYWRkX3NhbWVBcycpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfc2FtZUFzJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjc2FtZUFzX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgc2FtZUFzaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9zYW1lQXNfZGl2JykuYWZ0ZXIoaHRtbCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwic2FtZUFzXCIsIHNhbWVBc2lkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwic2FtZUFzXCIsIHNhbWVBc2lkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcInNhbWVBc1wiLCBzYW1lQXNpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBzYW1lQXNpZCA9IHNhbWVBc2lkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJzYW1lQXNcIik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG5cblx0dmFyIGVudGl0eUlEaWQgPSAxO1xuICAgIHZhciBlbnRpdHlJRE9wZW4gPSBmYWxzZTtcblx0aWYgKCQoJyNlbnRpdHlJRHRhYicpLmV4aXN0cygpKXtcblx0XHQkKCcjZW50aXR5SUR0YWInKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgLy8gRG9uJ3Qgb3BlbiBhIHNlY29uZCB0aW1lXG4gICAgICAgICAgICBpZiAoZW50aXR5SURPcGVuKVxuICAgICAgICAgICAgICAgIHJldHVybjtcblxuICAgICAgICAgICAgJC5nZXQoc25hY1VybCtcIi9lZGl0X3BhcnQvXCIrJCgnI2NvbnN0ZWxsYXRpb25pZCcpLnZhbCgpK1wiL1wiKyQoJyN2ZXJzaW9uJykudmFsKCkrXCI/cGFydD1lbnRpdHlJRFwiLCBudWxsLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgIGVudGl0eUlET3BlbiA9IHRydWU7XG4gICAgICAgICAgICAgICAgJCgnI2VudGl0eUlEJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwiZW50aXR5SURcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfZW50aXR5SURfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIGVudGl0eUlEaWQgPSBwYXJzZUludCgkKCcjbmV4dF9lbnRpdHlJRF9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IGVudGl0eUlEIElEOiBcIiArIGVudGl0eUlEaWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9lbnRpdHlJRCcpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfZW50aXR5SUQnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNlbnRpdHlJRF90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGVudGl0eUlEaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9lbnRpdHlJRF9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJlbnRpdHlJRFwiLCBlbnRpdHlJRGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwiZW50aXR5SURcIiwgZW50aXR5SURpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJlbnRpdHlJRFwiLCBlbnRpdHlJRGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVudGl0eUlEaWQgPSBlbnRpdHlJRGlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJlbnRpdHlJRFwiKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cblx0dmFyIHNvdXJjZWlkID0gMTtcbiAgICB2YXIgc291cmNlT3BlbiA9IGZhbHNlO1xuXHRpZiAoJCgnI3NvdXJjZXN0YWInKS5leGlzdHMoKSl7XG5cdFx0JCgnI3NvdXJjZXN0YWInKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgLy8gRG9uJ3Qgb3BlbiBhIHNlY29uZCB0aW1lXG4gICAgICAgICAgICBpZiAoc291cmNlT3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9c291cmNlc1wiLCBudWxsLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgIHNvdXJjZU9wZW4gPSB0cnVlO1xuICAgICAgICAgICAgICAgICQoJyNzb3VyY2VzJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwic291cmNlc1wiKTtcblxuICAgICAgICAgICAgICAgIGlmICgkKCcjbmV4dF9zb3VyY2VfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIHNvdXJjZWlkID0gcGFyc2VJbnQoJCgnI25leHRfc291cmNlX2knKS50ZXh0KCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIk5leHQgc291cmNlIElEOiBcIiArIHNvdXJjZWlkKTtcbiAgICAgICAgICAgICAgICBpZiAoJCgnI2J0bl9hZGRfc291cmNlJykuZXhpc3RzKCkpe1xuICAgICAgICAgICAgICAgICAgICAkKCcjYnRuX2FkZF9zb3VyY2UnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNzb3VyY2VfdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSB0ZXh0Lmh0bWwoKS5yZXBsYWNlKC9aWi9nLCBzb3VyY2VpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX3NvdXJjZV9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJzb3VyY2VcIiwgc291cmNlaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJzb3VyY2VcIiwgc291cmNlaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUVkaXRhYmxlKFwic291cmNlXCIsIHNvdXJjZWlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZWlkID0gc291cmNlaWQgKyAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwc0ZvclRhYihcInNvdXJjZXNcIik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG5cdHZhciByZXNvdXJjZVJlbGF0aW9uaWQgPSAxO1xuICAgIHZhciByZXNvdXJjZVJlbGF0aW9uT3BlbiA9IGZhbHNlO1xuXHRpZiAoJCgnI3Jlc291cmNlUmVsYXRpb25zdGFiJykuZXhpc3RzKCkpe1xuXHRcdCQoJyNyZXNvdXJjZVJlbGF0aW9uc3RhYicpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAvLyBEb24ndCBvcGVuIGEgc2Vjb25kIHRpbWVcbiAgICAgICAgICAgIGlmIChyZXNvdXJjZVJlbGF0aW9uT3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9cmVzb3VyY2VSZWxhdGlvbnNcIiwgbnVsbCwgZnVuY3Rpb24gKGRhdGEpIHtcbiAgICAgICAgICAgICAgICByZXNvdXJjZVJlbGF0aW9uT3BlbiA9IHRydWU7XG4gICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25zJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwicmVzb3VyY2VSZWxhdGlvbnNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfcmVzb3VyY2VSZWxhdGlvbl9pJykuZXhpc3RzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzb3VyY2VSZWxhdGlvbmlkID0gcGFyc2VJbnQoJCgnI25leHRfcmVzb3VyY2VSZWxhdGlvbl9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IHJlc291cmNlUmVsYXRpb24gSUQ6IFwiICsgcmVzb3VyY2VSZWxhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fY3JlYXRlX3Jlc291cmNlUmVsYXRpb24nKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fY3JlYXRlX3Jlc291cmNlUmVsYXRpb24nKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJpZCA9ICQoJ2lucHV0W25hbWU9cmVzb3VyY2VDaG9pY2VdOmNoZWNrZWQnLCAnI3Jlc291cmNlX3NlYXJjaF9mb3JtJykudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocmlkICE9IG51bGwgJiYgcmVzb3VyY2VSZXN1bHRzICE9IG51bGwgJiYgcmlkICE9ICduZXcnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0ZXh0ID0gJCgnI3Jlc291cmNlUmVsYXRpb25fdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgcmVzb3VyY2VSZWxhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX3Jlc291cmNlUmVsYXRpb25fZGl2JykuYWZ0ZXIoaHRtbCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc291cmNlUmVzdWx0c1tyaWRdLmlkICE9PSAndW5kZWZpbmVkJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fcmVzb3VyY2VpZF8nK3Jlc291cmNlUmVsYXRpb25pZCkudmFsKHJlc291cmNlUmVzdWx0c1tyaWRdLmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc291cmNlUmVzdWx0c1tyaWRdLnZlcnNpb24gIT09ICd1bmRlZmluZWQnKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl9yZXNvdXJjZXZlcnNpb25fJytyZXNvdXJjZVJlbGF0aW9uaWQpLnZhbChyZXNvdXJjZVJlc3VsdHNbcmlkXS52ZXJzaW9uKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzb3VyY2VSZXN1bHRzW3JpZF0ubGluayAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNyZXNvdXJjZVJlbGF0aW9uX2xpbmtUZXh0XycrcmVzb3VyY2VSZWxhdGlvbmlkKS5odG1sKFwiPGEgdGFyZ2V0PSdfYmxhbmsnIGhyZWY9J1wiK3Jlc291cmNlUmVzdWx0c1tyaWRdLmxpbmsrXCInPlwiK3Jlc291cmNlUmVzdWx0c1tyaWRdLmxpbmsrXCI8L2E+XCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXCIgPGEgY2xhc3M9J2xhYmVsIGxhYmVsLWluZm8nIHRhcmdldD0nX2JsYW5rJyBocmVmPSdcIityZXNvdXJjZVJlc3VsdHNbcmlkXS5saW5rK1wiJz5WaWV3PC9hPlwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc291cmNlUmVzdWx0c1tyaWRdLmRpc3BsYXlFbnRyeSAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNyZXNvdXJjZVJlbGF0aW9uX2Rpc3BsYXlFbnRyeVRleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnRleHQocmVzb3VyY2VSZXN1bHRzW3JpZF0uZGlzcGxheUVudHJ5KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc291cmNlUmVzdWx0c1tyaWRdLnRpdGxlICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl90aXRsZVRleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnRleHQocmVzb3VyY2VSZXN1bHRzW3JpZF0udGl0bGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cGRhdGVQaWN0dXJlVGl0bGUoJ3Jlc291cmNlUmVsYXRpb24nLCByZXNvdXJjZVJlbGF0aW9uaWQsIHJlc291cmNlUmVzdWx0c1tyaWRdLnRpdGxlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXNvdXJjZVJlc3VsdHNbcmlkXS5hYnN0cmFjdCAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNyZXNvdXJjZVJlbGF0aW9uX2Fic3RyYWN0VGV4dF8nK3Jlc291cmNlUmVsYXRpb25pZCkudGV4dChyZXNvdXJjZVJlc3VsdHNbcmlkXS5hYnN0cmFjdCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXNvdXJjZVJlc3VsdHNbcmlkXS5leHRlbnQgIT09ICd1bmRlZmluZWQnKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl9leHRlbnRUZXh0XycrcmVzb3VyY2VSZWxhdGlvbmlkKS50ZXh0KHJlc291cmNlUmVzdWx0c1tyaWRdLmV4dGVudCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaWYgKHR5cGVvZiByZXNvdXJjZVJlc3VsdHNbcmlkXS5kYXRlICE9PSAndW5kZWZpbmVkJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fZGF0ZVRleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnRleHQocmVzb3VyY2VSZXN1bHRzW3JpZF0uZGF0ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXNvdXJjZVJlc3VsdHNbcmlkXS5kb2N1bWVudFR5cGUgIT09ICd1bmRlZmluZWQnICYmIHR5cGVvZiByZXNvdXJjZVJlc3VsdHNbcmlkXS5kb2N1bWVudFR5cGUudGVybSAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNyZXNvdXJjZVJlbGF0aW9uX2RvY3VtZW50VHlwZVRleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnRleHQocmVzb3VyY2VSZXN1bHRzW3JpZF0uZG9jdW1lbnRUeXBlLnRlcm0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fbGlua1RleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLmFmdGVyKFwiPGEgY2xhc3M9J2NvbnRyb2wtbGFiZWwtc3VidGV4dCcgdGFyZ2V0PSdfYmxhbmsnIGhyZWY9J1wiICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc25hY1VybCtcIi92b2NhYl9hZG1pbmlzdHJhdG9yL3Jlc291cmNlcy9cIityZXNvdXJjZVJlc3VsdHNbcmlkXS5pZCtcIic+VmlldyBpbiBTTkFDPC9hPlwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwicmVzb3VyY2VSZWxhdGlvblwiLCByZXNvdXJjZVJlbGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwicmVzb3VyY2VSZWxhdGlvblwiLCByZXNvdXJjZVJlbGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcInJlc291cmNlUmVsYXRpb25cIiwgcmVzb3VyY2VSZWxhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvdXJjZVJlbGF0aW9uaWQgPSByZXNvdXJjZVJlbGF0aW9uaWQgKyAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjcmVzb3VyY2UtcmVzdWx0cy1ib3hcIikuaHRtbChcIlwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fb3Blbl9jcmVhdGVfcmVzb3VyY2UnKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fb3Blbl9jcmVhdGVfcmVzb3VyY2UnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ2xvc2UgdGhpcyBtb2RhbCBhbmQgb3BlbiB0aGUgbmV3IG1vZGFsXG4gICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3Jlc291cmNlU2VhcmNoUGFuZVwiKS5tb2RhbChcImhpZGVcIik7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFNldCBhIDUwMG1zIHRpbWVvdXQgdG8gZ2l2ZSB0aGUgaGlkZGVuIHNlYXJjaCBwYW5lIHRpbWUgdG8gZnVsbHkgY2xvc2VcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7JChcIiNyZXNvdXJjZUNyZWF0ZVBhbmVcIikubW9kYWwoXCJzaG93XCIpO30sIDUwMCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEdyYWIgdGhlIGVtcHR5IHRlbXBsYXRlIGFuZCByZXBsYWNlXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNyZXNvdXJjZV90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIDApO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlLWNyZWF0ZS1ib3gnKS5odG1sKGh0bWwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyICRyZXNvdXJjZUZvcm0gPSAkKFwiI3Jlc291cmNlX2NyZWF0ZV9mb3JtXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ29weSB0aGUgc2VhcmNoIGNvbnRlbnRzIHRvIHRpdGxlIG9yIGhyZWZcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgkKFwiI3Jlc291cmNlLXNlYXJjaGJveFwiKS52YWwoKS5pbmRleE9mKFwiaHR0cFwiKSA9PSAtMSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkcmVzb3VyY2VGb3JtLmZpbmQoXCIjcmVzb3VyY2UtdGl0bGVcIikudmFsKCQoXCIjcmVzb3VyY2Utc2VhcmNoYm94XCIpLnZhbCgpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkcmVzb3VyY2VGb3JtLmZpbmQoXCIjcmVzb3VyY2UtdXJsXCIpLnZhbCgkKFwiI3Jlc291cmNlLXNlYXJjaGJveFwiKS52YWwoKSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICRyZXNvdXJjZUZvcm0uZmluZCgnW2RhdGEtdG9nZ2xlPVwicG9wb3ZlclwiXScpLnBvcG92ZXIoe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlcjogJ2hvdmVyJyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lcjogJ2JvZHknXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRWb2NhYlNlbGVjdE9wdGlvbnMoJHJlc291cmNlRm9ybS5maW5kKFwiI3Jlc291cmNlLXR5cGUtc2VsZWN0XCIpLCBcImRvY3VtZW50X3R5cGVcIiwgXCJSZXNvdXJjZSBUeXBlXCIp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IG90aGVyIG1vZGFsXG4gICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3Jlc291cmNlLXJlc3VsdHMtYm94XCIpLmh0bWwoXCJcIik7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2NyZWF0ZV9yZXNvdXJjZScpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlX2NyZWF0ZV9mb3JtJykub24oXCJzdWJtaXRcIiwgZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBSZW1vdmUgbGVhZGluZyBhbmQgdHJhaWxpbmcgd2hpdGVzcGFjZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgkKFwiI3Jlc291cmNlX2NyZWF0ZV9mb3JtICNyZXNvdXJjZS11cmxcIikudmFsKCkgPT0gXCJcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbmZpcm0oJ0FyZSB5b3Ugc3VyZSB5b3Ugd2FudCB0byBzYXZlIHdpdGhvdXQgYW4gSFJFRj8nKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjcmVzb3VyY2VfY3JlYXRlX2Zvcm0gaW5wdXQsIHRleHRhcmVhXCIpLmVhY2goZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQodGhpcykudmFsKCQudHJpbSgkKHRoaXMpLnZhbCgpKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0RGVsZXRlZFJlc291cmNlTGFuZ3VhZ2VPcGVyYXRpb25zKCQoXCIjcmVzb3VyY2VfY3JlYXRlX2Zvcm1cIikpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJC5wb3N0KHNuYWNVcmwrXCIvc2F2ZV9yZXNvdXJjZVwiLCAkKFwiI3Jlc291cmNlX2NyZWF0ZV9mb3JtXCIpLnNlcmlhbGl6ZSgpLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEucmVzdWx0ICE9PSAndW5kZWZpbmVkJyAmJiBkYXRhLnJlc3VsdCAhPT0gJ2ZhbHNlJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNyZXNvdXJjZVJlbGF0aW9uX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgcmVzb3VyY2VSZWxhdGlvbmlkKTsgLy8gY2xvbmVzIERPTSwgcmVwbGFjZXMgenogd2l0aCBuZXh0IGlkc1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9yZXNvdXJjZVJlbGF0aW9uX2RpdicpLmFmdGVyKGh0bWwpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEucmVzb3VyY2UuaWQgIT09ICd1bmRlZmluZWQnKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNyZXNvdXJjZVJlbGF0aW9uX3Jlc291cmNlaWRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnZhbChkYXRhLnJlc291cmNlLmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGF0YS5yZXNvdXJjZS52ZXJzaW9uICE9PSAndW5kZWZpbmVkJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl9yZXNvdXJjZXZlcnNpb25fJytyZXNvdXJjZVJlbGF0aW9uaWQpLnZhbChkYXRhLnJlc291cmNlLnZlcnNpb24pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEucmVzb3VyY2UubGluayAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fbGlua1RleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLmh0bWwoXCI8YSB0YXJnZXQ9J19ibGFuaycgaHJlZj0nXCIrZGF0YS5yZXNvdXJjZS5saW5rK1wiJz5cIitkYXRhLnJlc291cmNlLmxpbmsrXCI8L2E+XCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIiA8YSBjbGFzcz0nbGFiZWwgbGFiZWwtaW5mbycgdGFyZ2V0PSdfYmxhbmsnIGhyZWY9J1wiK2RhdGEucmVzb3VyY2UubGluaytcIic+VmlldzwvYT5cIik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEucmVzb3VyY2UuZGlzcGxheUVudHJ5ICE9PSAndW5kZWZpbmVkJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl9kaXNwbGF5RW50cnlUZXh0XycrcmVzb3VyY2VSZWxhdGlvbmlkKS50ZXh0KGRhdGEucmVzb3VyY2UuZGlzcGxheUVudHJ5KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGF0YS5yZXNvdXJjZS50aXRsZSAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl90aXRsZVRleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnRleHQoZGF0YS5yZXNvdXJjZS50aXRsZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGljdHVyZVRpdGxlKCdyZXNvdXJjZVJlbGF0aW9uJywgcmVzb3VyY2VSZWxhdGlvbmlkLCBkYXRhLnJlc291cmNlLnRpdGxlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGF0YS5yZXNvdXJjZS5hYnN0cmFjdCAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fYWJzdHJhY3RUZXh0XycrcmVzb3VyY2VSZWxhdGlvbmlkKS50ZXh0KGRhdGEucmVzb3VyY2UuYWJzdHJhY3QpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBkYXRhLnJlc291cmNlLmV4dGVudCAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fZXh0ZW50VGV4dF8nK3Jlc291cmNlUmVsYXRpb25pZCkudGV4dChkYXRhLnJlc291cmNlLmV4dGVudCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEucmVzb3VyY2UuZG9jdW1lbnRUeXBlICE9PSAndW5kZWZpbmVkJyAmJiB0eXBlb2YgZGF0YS5yZXNvdXJjZS5kb2N1bWVudFR5cGUudGVybSAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fZG9jdW1lbnRUeXBlVGV4dF8nK3Jlc291cmNlUmVsYXRpb25pZCkudGV4dChkYXRhLnJlc291cmNlLmRvY3VtZW50VHlwZS50ZXJtKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fbGlua1RleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLmFmdGVyKFwiPGEgY2xhc3M9J2NvbnRyb2wtbGFiZWwtc3VidGV4dCcgdGFyZ2V0PSdfYmxhbmsnIGhyZWY9J1wiICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzbmFjVXJsK1wiL3ZvY2FiX2FkbWluaXN0cmF0b3IvcmVzb3VyY2VzL1wiK2RhdGEucmVzb3VyY2UuaWQrXCInPlZpZXcgaW4gU05BQzwvYT5cIik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwicmVzb3VyY2VSZWxhdGlvblwiLCByZXNvdXJjZVJlbGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJyZXNvdXJjZVJlbGF0aW9uXCIsIHJlc291cmNlUmVsYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJyZXNvdXJjZVJlbGF0aW9uXCIsIHJlc291cmNlUmVsYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvdXJjZVJlbGF0aW9uaWQgPSByZXNvdXJjZVJlbGF0aW9uaWQgKyAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJChcIiNyZXNvdXJjZUNyZWF0ZVBhbmVcIikubW9kYWwoXCJoaWRlXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlLWNyZWF0ZS1ib3gnKS5odG1sKFwiXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhkYXRhKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwc0ZvclRhYihcInJlc291cmNlUmVsYXRpb25zXCIpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH1cblxuXG5cdHZhciBjb25zdGVsbGF0aW9uUmVsYXRpb25pZCA9IDE7XG4gICAgdmFyIGNvbnN0ZWxsYXRpb25SZWxhdGlvbk9wZW4gPSBmYWxzZTtcblx0aWYgKCQoJyNjb25zdGVsbGF0aW9uUmVsYXRpb25zdGFiJykuZXhpc3RzKCkpe1xuXHRcdCQoJyNjb25zdGVsbGF0aW9uUmVsYXRpb25zdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gY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rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBjaWQgPSAkKCdpbnB1dFtuYW1lPXJlbGF0aW9uQ2hvaWNlXTpjaGVja2VkJywgJyNyZWxhdGlvbl9zZWFyY2hfZm9ybScpLnZhbCgpXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2lkICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRFZGl0ZWRGbGFnKHRydWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjY29uc3RlbGxhdGlvblJlbGF0aW9uX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGNvbnN0ZWxsYXRpb25SZWxhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX2NvbnN0ZWxsYXRpb25SZWxhdGlvbl9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjY29uc3RlbGxhdGlvblJlbGF0aW9uX3RhcmdldElEXycrY29uc3RlbGxhdGlvblJlbGF0aW9uaWQpLnZhbChjaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNjb25zdGVsbGF0aW9uUmVsYXRpb25fY29udGVudF8nK2NvbnN0ZWxsYXRpb25SZWxhdGlvbmlkKS52YWwoJCgnI3JlbGF0aW9uQ2hvaWNlX25hbWVFbnRyeV8nK2NpZCkudmFsKCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNjb25zdGVsbGF0aW9uUmVsYXRpb25fdGFyZ2V0QXJrSURfJytjb25zdGVsbGF0aW9uUmVsYXRpb25pZCkudmFsK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blwiLCBjb25zdGVsbGF0aW9uUmVsYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJjb25zdGVsbGF0aW9uUmVsYXRpb25cIiwgY29uc3RlbGxhdGlvblJlbGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcImNvbnN0ZWxsYXRpb25SZWxhdGlvblwiLCBjb25zdGVsbGF0aW9uUmVsYXRpb25pZCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdGVsbGF0aW9uUmVsYXRpb25pZCA9IGNvbnN0ZWxsYXRpb25SZWxhdGlvbmlkICsgMTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG5cblxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwc0ZvclRhYihcImNvbnN0ZWxsYXRpb25SZWxhdGlvbnNcIik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG5cdHZhciBsYW5ndWFnZWlkID0gMTtcbiAgICB2YXIgbGFuZ3VhZ2VPcGVuID0gZmFsc2U7XG5cdGlmICgkKCcjbGFuZ3VhZ2VzVXNlZHRhYicpLmV4aXN0cygpKXtcblx0XHQkKCcjbGFuZ3VhZ2VzVXNlZHRhYicpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAvLyBEb24ndCBvcGVuIGEgc2Vjb25kIHRpbWVcbiAgICAgICAgICAgIGlmIChsYW5ndWFnZU9wZW4pXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuXG4gICAgICAgICAgICAkLmdldChzbmFjVXJsK1wiL2VkaXRfcGFydC9cIisk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gICAgICAgICAgICAgICAgICAkKCcjYWRkX2xhbmd1YWdlX2RpdicpLmFmdGVyKGh0bWwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uQnV0dG9ucyhcImxhbmd1YWdlXCIsIGxhbmd1YWdlaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJsYW5ndWFnZVwiLCBsYW5ndWFnZWlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcImxhbmd1YWdlXCIsIGxhbmd1YWdlaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbGFuZ3VhZ2VpZCA9IGxhbmd1YWdlaWQgKyAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwc0ZvclRhYihcImxhbmd1YWdlc1VzZWRcIik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG5cdHZhciBzdWJqZWN0aWQgPSAxO1xuICAgIHZhciBzdWJqZWN0T3BlbiA9IGZhbHNlO1xuXHRpZiAoJCgnI3N1YmplY3RzdGFiJykuZXhpc3RzKCkpe1xuXHRcdCQoJyNzdWJqZWN0c3RhYicpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAvLyBEb24ndCBvcGVuIGEgc2Vjb25kIHRpbWVcbiAgICAgICAgICAgIGlmIChzdWJqZWN0T3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9c3ViamVjdHNcIiwgbnVsbCwgZnVuY3Rpb24gKGRhdGEpIHtcbiAgICAgICAgICAgICAgICBzdWJqZWN0T3BlbiA9IHRydWU7XG4gICAgICAgICAgICAgICAgJCgnI3N1YmplY3RzJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwic3ViamVjdHNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfc3ViamVjdF9pJykuZXhpc3RzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgc3ViamVjdGlkID0gcGFyc2VJbnQoJCgnI25leHRfc3ViamVjdF9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IHN1YmplY3QgSUQ6IFwiICsgc3ViamVjdGlkKTtcbiAgICAgICAgICAgICAgICBpZiAoJCgnI2J0bl9hZGRfc3ViamVjdCcpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfc3ViamVjdCcpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRFZGl0ZWRGbGFnKHRydWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy9zb21ldGhpbmdIYXNCZWVuRWRpdGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0ZXh0ID0gJCgnI3N1YmplY3RfdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSB0ZXh0Lmh0bWwoKS5yZXBsYWNlKC9aWi9nLCBzdWJqZWN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9zdWJqZWN0X2RpdicpLmFmdGVyKGh0bWwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uQnV0dG9ucyhcInN1YmplY3RcIiwgc3ViamVjdGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwic3ViamVjdFwiLCBzdWJqZWN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUVkaXRhYmxlKFwic3ViamVjdFwiLCBzdWJqZWN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdGlkID0gc3ViamVjdGlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJzdWJqZWN0c1wiKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cblx0dmFyIG5hdGlvbmFsaXR5aWQgPSAxO1xuICAgIHZhciBuYXRpb25hbGl0eU9wZW4gPSBmYWxzZTtcblx0aWYgKCQoJyNuYXRpb25hbGl0aWVzdGFiJykuZXhpc3RzKCkpe1xuXHRcdCQoJyNuYXRpb25hbGl0aWVzdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gYSBzZWNvbmQgdGltZVxuICAgICAgICAgICAgaWYgKG5hdGlvbmFsaXR5T3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9bmF0aW9uYWxpdGllc1wiLCBudWxsLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgIG5hdGlvbmFsaXR5T3BlbiA9IHRydWU7XG4gICAgICAgICAgICAgICAgJCgnI25hdGlvbmFsaXRpZXMnKS5odG1sKGRhdGEpO1xuXG4gICAgICAgICAgICAgICAgdHVybk9uRWRpdERlbGV0ZUJ1dHRvbnMoXCJuYXRpb25hbGl0aWVzXCIpO1xuXG4gICAgICAgICAgICAgICAgaWYgKCQoJyNuZXh0X25hdGlvbmFsaXR5X2knKS5leGlzdHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBuYXRpb25hbGl0eWlkID0gcGFyc2VJbnQoJCgnI25leHRfbmF0aW9uYWxpdHlfaScpLnRleHQoKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiTmV4dCBuYXRpb25hbGl0eSBJRDogXCIgKyBuYXRpb25hbGl0eWlkKTtcbiAgICAgICAgICAgICAgICBpZiAoJCgnI2J0bl9hZGRfbmF0aW9uYWxpdHknKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fYWRkX25hdGlvbmFsaXR5JykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjbmF0aW9uYWxpdHlfdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSB0ZXh0Lmh0bWwoKS5yZXBsYWNlKC9aWi9nLCBuYXRpb25hbGl0eWlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICQoJyNhZGRfbmF0aW9uYWxpdHlfZGl2JykuYWZ0ZXIoaHRtbCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwibmF0aW9uYWxpdHlcIiwgbmF0aW9uYWxpdHlpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwcyhcIm5hdGlvbmFsaXR5XCIsIG5hdGlvbmFsaXR5aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUVkaXRhYmxlKFwibmF0aW9uYWxpdHlcIiwgbmF0aW9uYWxpdHlpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBuYXRpb25hbGl0eWlkID0gbmF0aW9uYWxpdHlpZCArIDE7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzRm9yVGFiKFwibmF0aW9uYWxpdGllc1wiKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cblx0dmFyIGZ1bmN0aW9uaWQgPSAxO1xuICAgIHZhciBmdW5jdGlvbk9wZW4gPSBmYWxzZTtcblx0aWYgKCQoJyNmdW5jdGlvbnN0YWInKS5leGlzdHMoKSl7XG5cdFx0JCgnI2Z1bmN0aW9uc3RhYicpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAvLyBEb24ndCBvcGVuIGEgc2Vjb25kIHRpbWVcbiAgICAgICAgICAgIGlmIChmdW5jdGlvbk9wZW4pXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuXG4gICAgICAgICAgICAkLmdldChzbmFjVXJsK1wiL2VkaXRfcGFydC9cIiskKCcjY29uc3RlbGxhdGlvbmlkJykudmFsKCkrXCIvXCIrJCgnI3ZlcnNpb24nKS52YWwoKStcIj9wYXJ0PWZ1bmN0aW9uc1wiLCBudWxsLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgIGZ1bmN0aW9uT3BlbiA9IHRydWU7XG4gICAgICAgICAgICAgICAgJCgnI2Z1bmN0aW9ucycpLmh0bWwoZGF0YSk7XG5cbiAgICAgICAgICAgICAgICB0dXJuT25FZGl0RGVsZXRlQnV0dG9ucyhcImZ1bmN0aW9uc1wiKTtcblxuICAgICAgICAgICAgICAgIGlmICgkKCcjbmV4dF9mdW5jdGlvbl9pJykuZXhpc3RzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb25pZCA9IHBhcnNlSW50KCQoJyNuZXh0X2Z1bmN0aW9uX2knKS50ZXh0KCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIk5leHQgZnVuY3Rpb24gSUQ6IFwiICsgZnVuY3Rpb25pZCk7XG4gICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fYWRkX2Z1bmN0aW9uJykuZXhpc3RzKCkpe1xuICAgICAgICAgICAgICAgICAgICAkKCcjYnRuX2FkZF9mdW5jdGlvbicpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRFZGl0ZWRGbGFnKHRydWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy9zb21ldGhpbmdIYXNCZWVuRWRpdGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0ZXh0ID0gJCgnI2Z1bmN0aW9uX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgZnVuY3Rpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX2Z1bmN0aW9uX2RpdicpLmFmdGVyKGh0bWwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uQnV0dG9ucyhcImZ1bmN0aW9uXCIsIGZ1bmN0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJmdW5jdGlvblwiLCBmdW5jdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcImZ1bmN0aW9uXCIsIGZ1bmN0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb25pZCA9IGZ1bmN0aW9uaWQgKyAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwc0ZvclRhYihcImZ1bmN0aW9uc1wiKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cblx0dmFyIG9jY3VwYXRpb25pZCA9IDE7XG4gICAgdmFyIG9jY3VwYXRpb25PcGVuID0gZmFsc2U7XG5cdGlmICgkKCcjb2NjdXBhdGlvbnN0YWInKS5leGlzdHMoKSl7XG5cdFx0JCgnI29jY3VwYXRpb25zdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gYSBzZWNvbmQgdGltZVxuICAgICAgICAgICAgaWYgKG9jY3VwYXRpb25PcGVuKVxuICAgICAgICAgICAgICAgIHJldHVybjtcblxuICAgICAgICAgICAgJC5nZXQoc25hY1VybCtcIi9lZGl0X3BhcnQvXCIrJCgnI2NvbnN0ZWxsYXRpb25pZCcpLnZhbCgpK1wiL1wiKyQoJyN2ZXJzaW9uJykudmFsKCkrXCI/cGFydD1vY2N1cGF0aW9uc1wiLCBudWxsLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgIG9jY3VwYXRpb25PcGVuID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAkKCcjb2NjdXBhdGlvbnMnKS5odG1sKGRhdGEpO1xuXG4gICAgICAgICAgICAgICAgdHVybk9uRWRpdERlbGV0ZUJ1dHRvbnMoXCJvY2N1cGF0aW9uc1wiKTtcblxuICAgICAgICAgICAgICAgIGlmICgkKCcjbmV4dF9vY2N1cGF0aW9uX2knKS5leGlzdHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBvY2N1cGF0aW9uaWQgPSBwYXJzZUludCgkKCcjbmV4dF9vY2N1cGF0aW9uX2knKS50ZXh0KCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIk5leHQgb2NjdXBhdGlvbiBJRDogXCIgKyBvY2N1cGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9vY2N1cGF0aW9uJykuZXhpc3RzKCkpe1xuICAgICAgICAgICAgICAgICAgICAkKCcjYnRuX2FkZF9vY2N1cGF0aW9uJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjb2NjdXBhdGlvbl90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIG9jY3VwYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX29jY3VwYXRpb25fZGl2JykuYWZ0ZXIoaHRtbCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwib2NjdXBhdGlvblwiLCBvY2N1cGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJvY2N1cGF0aW9uXCIsIG9jY3VwYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJvY2N1cGF0aW9uXCIsIG9jY3VwYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBvY2N1cGF0aW9uaWQgPSBvY2N1cGF0aW9uaWQgKyAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAg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gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IGxlZ2FsU3RhdHVzIElEOiBcIiArIGxlZ2FsU3RhdHVzaWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9sZWdhbFN0YXR1cycpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfbGVnYWxTdGF0dXMnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNsZWdhbFN0YXR1c190ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGxlZ2FsU3RhdHVzaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9sZWdhbFN0YXR1c19kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJsZWdhbFN0YXR1c1wiLCBsZWdhbFN0YXR1c2lkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwibGVnYWxTdGF0dXNcIiwgbGVnYWxTdGF0dXNpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJsZWdhbFN0YXR1c1wiLCBsZWdhbFN0YXR1c2lkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxlZ2FsU3RhdHVzaWQgPSBsZWdhbFN0YXR1c2lkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJsZWdhbFN0YXR1c2VzXCIpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH1cblxuXHR2YXIgcGxhY2VpZCA9IDE7XG4gICAgdmFyIHBsYWNlT3BlbiA9IGZhbHNlO1xuXHRpZiAoJCgnI3BsYWNlc3RhYicpLmV4aXN0cygpKXtcblx0XHQkKCcjcGxhY2VzdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gYSBzZWNvbmQgdGltZVxuICAgICAgICAgICAgaWYgKHBsYWNlT3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9cGxhY2VzXCIsIG51bGwsIGZ1bmN0aW9uIChkYXRhKSB7XG4gICAgICAgICAgICAgICAgcGxhY2VPcGVuID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAkKCcjcGxhY2VzJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIC8vIExvYWQgdGhlIHBsYWNlIGNhY2hlLCBpZiBuZWVkZWRcbiAgICAgICAgICAgICAgICBsb2FkR2VvUGxhY2VSZXN1bHRDYWNoZSgpO1xuXG4gICAgICAgICAgICAgICAgdHVybk9uRWRpdERlbGV0ZUJ1dHRvbnMoXCJwbGFjZXNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfcGxhY2VfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIHBsYWNlaWQgPSBwYXJzZUludCgkKCcjbmV4dF9wbGFjZV9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IHBsYWNlIElEOiBcIiArIHBsYWNlaWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9wbGFjZScpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfcGxhY2UnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNwbGFjZV90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIHBsYWNlaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9wbGFjZV9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJwbGFjZVwiLCBwbGFjZWlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwicGxhY2VcIiwgcGxhY2VpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJwbGFjZVwiLCBwbGFjZWlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHBsYWNlaWQgPSBwbGFjZWlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJwbGFjZXNcIik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG5cdHZhciBjb252ZW50aW9uRGVjbGFyYXRpb25pZCA9IDE7XG4gICAgdmFyIGNvbnZlbnRpb25EZWNsYXJhdGlvbk9wZW4gPSBmYWxzZTtcblx0aWYgKCQoJyNjb252ZW50aW9uRGVjbGFyYXRpb25zdGFiJykuZXhpc3RzKCkpe1xuXHRcdCQoJyNjb252ZW50aW9uRGVjbGFyYXRpb25zdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gYSBzZWNvbmQgdGltZVxuICAgICAgICAgICAgaWYgKGNvbnZlbnRpb25EZWNsYXJhdGlvbk9wZW4pXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuXG4gICAgICAgICAgICAkLmdldChzbmFjVXJsK1wiL2VkaXRfcGFydC9cIiskKCcjY29uc3RlbGxhdGlvbmlkJykudmFsKCkrXCIvXCIrJCgnI3ZlcnNpb24nKS52YWwoKStcIj9wYXJ0PWNvbnZlbnRpb25EZWNsYXJhdGlvbnNcIiwgbnVsbCwgZnVuY3Rpb24gKGRhdGEpIHtcbiAgICAgICAgICAgICAgICBjb252ZW50aW9uRGVjbGFyYXRpb25PcGVuID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAkKCcjY29udmVudGlvbkRlY2xhcmF0aW9ucycpLmh0bWwoZGF0YSk7XG5cbiAgICAgICAgICAgICAgICB0dXJuT25FZGl0RGVsZXRlQnV0dG9ucyhcImNvbnZlbnRpb25EZWNsYXJhdGlvbnNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfY29udmVudGlvbkRlY2xhcmF0aW9uX2knKS5leGlzdHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBjb252ZW50aW9uRGVjbGFyYXRpb25pZCA9IHBhcnNlSW50KCQoJyNuZXh0X2NvbnZlbnRpb25EZWNsYXJhdGlvbl9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IGNvbnZlbnRpb25EZWNsYXJhdGlvbiBJRDogXCIgKyBjb252ZW50aW9uRGVjbGFyYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fYWRkX2NvbnZlbnRpb25EZWNsYXJhdGlvbicpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfY29udmVudGlvbkRlY2xhcmF0aW9uJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjY29udmVudGlvbkRlY2xhcmF0aW9uX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgY29udmVudGlvbkRlY2xhcmF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9jb252ZW50aW9uRGVjbGFyYXRpb25fZGl2JykuYWZ0ZXIoaHRtbCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwiY29udmVudGlvbkRlY2xhcmF0aW9uXCIsIGNvbnZlbnRpb25EZWNsYXJhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwiY29udmVudGlvbkRlY2xhcmF0aW9uXCIsIGNvbnZlbnRpb25EZWNsYXJhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcImNvbnZlbnRpb25EZWNsYXJhdGlvblwiLCBjb252ZW50aW9uRGVjbGFyYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb252ZW50aW9uRGVjbGFyYXRpb25pZCA9IGNvbnZlbnRpb25EZWNsYXJhdGlvbmlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJjb252ZW50aW9uRGVjbGFyYXRpb25zXCIpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH1cblxuXHR2YXIgZ2VuZXJhbENvbnRleHRpZCA9IDE7XG4gICAgdmFyIGdlbmVyYWxDb250ZXh0T3BlbiA9IGZhbHNlO1xuXHRpZiAoJCgnI2dlbmVyYWxDb250ZXh0c3RhYicpLmV4aXN0cygpKXtcblx0XHQkKCcjZ2VuZXJhbENvbnRleHRzdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gYSBzZWNvbmQgdGltZVxuICAgICAgICAgICAgaWYgKGdlbmVyYWxDb250ZXh0T3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9Z2VuZXJhbENvbnRleHRzXCIsIG51bGwsIGZ1bmN0aW9uIChkYXRhKSB7XG4gICAgICAgICAgICAgICAgZ2VuZXJhbENvbnRleHRPcGVuID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAkKCcjZ2VuZXJhbENvbnRleHRzJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwiZ2VuZXJhbENvbnRleHRzXCIpO1xuXG4gICAgICAgICAgICAgICAgaWYgKCQoJyNuZXh0X2dlbmVyYWxDb250ZXh0X2knKS5leGlzdHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBnZW5lcmFsQ29udGV4dGlkID0gcGFyc2VJbnQoJCgnI25leHRfZ2VuZXJhbENvbnRleHRfaScpLnRleHQoKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiTmV4dCBnZW5lcmFsQ29udGV4dCBJRDogXCIgKyBnZW5lcmFsQ29udGV4dGlkKTtcbiAgICAgICAgICAgICAgICBpZiAoJCgnI2J0bl9hZGRfZ2VuZXJhbENvbnRleHQnKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fYWRkX2dlbmVyYWxDb250ZXh0JykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjZ2VuZXJhbENvbnRleHRfdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSB0ZXh0Lmh0bWwoKS5yZXBsYWNlKC9aWi9nLCBnZW5lcmFsQ29udGV4dGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICQoJyNhZGRfZ2VuZXJhbENvbnRleHRfZGl2JykuYWZ0ZXIoaHRtbCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwiZ2VuZXJhbENvbnRleHRcIiwgZ2VuZXJhbENvbnRleHRpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwcyhcImdlbmVyYWxDb250ZXh0XCIsIGdlbmVyYWxDb250ZXh0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUVkaXRhYm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h0bWwoZGF0YSk7XG5cbiAgICAgICAgICAgICAgICB0dXJuT25FZGl0RGVsZXRlQnV0dG9ucyhcInN0cnVjdHVyZU9yR2VuZWFsb2dpZXNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfc3RydWN0dXJlT3JHZW5lYWxvZ3lfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0cnVjdHVyZU9yR2VuZWFsb2d5aWQgPSBwYXJzZUludCgkKCcjbmV4dF9zdHJ1Y3R1cmVPckdlbmVhbG9neV9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IHN0cnVjdHVyZU9yR2VuZWFsb2d5IElEOiBcIiArIHN0cnVjdHVyZU9yR2VuZWFsb2d5aWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9zdHJ1Y3R1cmVPckdlbmVhbG9neScpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfc3RydWN0dXJlT3JHZW5lYWxvZ3knKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNzdHJ1Y3R1cmVPckdlbmVhbG9neV90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIHN0cnVjdHVyZU9yR2VuZWFsb2d5aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9zdHJ1Y3R1cmVPckdlbmVhbG9neV9kaXYnKS5hZnRlcihodG1sKTtcb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CIrJCgnI3ZlcnNpb24nKS52YWwoKStcIj9wYXJ0PW1hbmRhdGVzXCIsIG51bGwsIGZ1bmN0aW9uIChkYXRhKSB7XG4gICAgICAgICAgICAgICAgbWFuZGF0ZU9wZW4gPSB0cnVlO1xuICAgICAgICAgICAgICAgICQoJyNtYW5kYXRlcycpLmh0bWwoZGF0YSk7XG5cbiAgICAgICAgICAgICAgICB0dXJuT25FZGl0RGVsZXRlQnV0dG9ucyhcIm1hbmRhdGVzXCIpO1xuXG4gICAgICAgICAgICAgICAgaWYgKCQoJyNuZXh0X21hbmRhdGVfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIG1hbmRhdGVpZCA9IHBhcnNlSW50KCQoJyNuZXh0X21hbmRhdGVfaScpLnRleHQoKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiTmV4dCBtYW5kYXRlIElEOiBcIiArIG1hbmRhdGVpZCk7XG4gICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fYWRkX21hbmRhdGUnKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fYWRkX21hbmRhdGUnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNtYW5kYXRlX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgbWFuZGF0ZWlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICQoJyNhZGRfbWFuZGF0ZV9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgIC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KS5odG1sKGRhdGEpO1xuXG4gICAgICAgICAgICAgICAgdHVybk9uRWRpdERlbGV0ZUJ1dHRvbnMoXCJiaW9nSGlzdHNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfYmlvZ0hpc3RfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIGJpb2dIaXN0aWQgPSBwYXJzZUludCgkKCcjbmV4dF9iaW9nSGlzdF9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IGJpb2dIaXN0IElEOiBcIiArIGJpb2dIaXN0aWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9iaW9nSGlzdCcpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfYmlvZ0hpc3QnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNiaW9nSGlzdF90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGJpb2dIaXN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9iaW9nSGlzdF9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJiaW9nSGlzdFwiLCBiaW9nSGlzdGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwiYmlvZ0hpc3RcIiwgYmlvZ0hpc3RpZCk7XG4gICA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TtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUVBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///3\n"); + +/***/ }) + +/******/ }))); \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/resource_admin.js b/src/virtualhosts/www/javascript/resource_admin.js index 4bc8cf0a9..4aaae7c4c 100644 --- a/src/virtualhosts/www/javascript/resource_admin.js +++ b/src/virtualhosts/www/javascript/resource_admin.js @@ -1 +1,95 @@ -!function(n){var e={};function g(l){if(e[l])return e[l].exports;var t=e[l]={i:l,l:!1,exports:{}};return n[l].call(t.exports,t,t.exports,g),t.l=!0,t.exports}g.m=n,g.c=e,g.d=function(n,e,l){g.o(n,e)||Object.defineProperty(n,e,{enumerable:!0,get:l})},g.r=function(n){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(n,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(n,"__esModule",{value:!0})},g.t=function(n,e){if(1&e&&(n=g(n)),8&e)return n;if(4&e&&"object"==typeof n&&n&&n.__esModule)return n;var l=Object.create(null);if(g.r(l),Object.defineProperty(l,"default",{enumerable:!0,value:n}),2&e&&"string"!=typeof n)for(var t in n)g.d(l,t,function(e){return n[e]}.bind(null,t));return l},g.n=function(n){var e=n&&n.__esModule?function(){return n.default}:function(){return n};return g.d(e,"a",e),e},g.o=function(n,e){return Object.prototype.hasOwnProperty.call(n,e)},g.p="",g(g.s=0)}([function(module,exports){eval("/**\n * Resource Admin Actions\n *\n * Contains code that handles Resource creation and editing\n *\n * @author Joseph Glass\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\nfunction saveResource(event) {\n event.preventDefault();\n var $form = $(event.target);\n\n if ($form.find(\"#resource-url\").val() == \"\") {\n if (!confirm('Are you sure you want to save without an HREF?')) {\n return;\n }\n }\n $('#notification-message').slideDown().html(\"

    Saving Resource... Please wait.

    \");\n\n // Remove leading and trailing whitespace\n $form.find(\"input, textarea\").each(function () {\n $(this).val($.trim($(this).val()));\n });\n\n setDeletedResourceLanguageOperations($form);\n\n $.post(snacUrl + \"/save_resource\", $form.serialize()).done(function (data) {\n createdResource = data;\n if (typeof data.resource === 'undefined') {\n $('#error-message').slideDown();\n return false;\n }\n $('#notification-message').slideUp();\n $('#success-message').slideDown();\n setTimeout(function () {\n window.location = snacUrl + \"/vocab_administrator/resources/\" + data.resource.id;\n }, 1000);\n }).fail(function () {\n $('#error-message').slideDown();\n });\n return false;\n}\n\nfunction setDeletedResourceLanguageOperations($form) {\n // Set deleted new languages to null, set deleted existing languages to delete\n var $deletedLanguages = $form.find(\"#resource-languages .component-deleted\").has('input[id]');\n var $ignoredLanguages = $form.find(\"#resource-languages .component-deleted.new-language\");\n setOperations($deletedLanguages, \"delete\");\n setOperations($ignoredLanguages, \"\");\n}\n\nfunction cancelResource() {\n if (!confirm('Are you sure you want to cancel?')) {\n return;\n }\n\n $('#notification-message').html(\"

    Cancelling...

    \");\n $('#notification-message').slideDown();\n setTimeout(function () {\n window.location.href = snacUrl + \"/vocab_administrator\";\n }, 1000);\n return false;\n}\n\n/**\n * New Resource Language\n * Copies the resource template DIV on the page and attaches it correctly to the DOM.\n * Tracks language index using $('#language-template').data('languageCount')\n *\n */\nfunction newResourceLanguage(event) {\n event.preventDefault();\n var $newLanguage = $('#resource-language-template').find(\".language\").clone();\n var data = $('#resource-language-template').data();\n var newLanguageID = 'language_' + data.languageCount;\n $newLanguage.attr('id', newLanguageID);\n $newLanguage.find('.operation').val('insert');\n $newLanguage.addClass('new-language');\n\n //update input names with new data.languageCount\n $newLanguage.find('input, select').attr('name', function (i, name) {\n return name.replace('YY', data.languageCount);\n });\n\n console.log('Adding new resource language with id: ', newLanguageID);\n $newLanguage.toggle();\n // selects last to avoid conflict on multiple clones\n $('.add-resource-language:last').before($newLanguage);\n enableLanguageSelect($newLanguage);\n\n data.languageCount++;\n return $newLanguage;\n}\n\n/**\n * Delete or Undo Language\n *\n * Toggles component-deleted class, and btn classes for delete and undo.\n * Does not change operations.\n *\n */\nfunction deleteOrUndoLanguage(event) {\n event.preventDefault();\n var $btn = $(event.currentTarget);\n $btn.toggleClass('btn-danger btn-warning');\n $btn.find(':only-child').toggleClass('fa-minus-circle fa-undo');\n var $language = $btn.closest('.language');\n $language.toggleClass('alert-danger component-deleted');\n}\n\nfunction setOperations($elements, operation) {\n $elements.find('.operation').each(function () {\n $(this).val(operation);\n });\n}\n\n/**\n * Mark Edited Resource Fields\n *\n * Adds edited-field class to altered inputs. Sets altered resource language to update.\n * @param jqueryObject $resourceForm jQuery object to modify\n *\n */\nfunction markEditedResourceFields($resourceForm) {\n $resourceForm.find(\"input, select, textarea\").on(\"change\", function (e) {\n $(e.target).addClass('edited-field');\n\n if ($(e.target).closest('.language').length) {\n setOperations($(e.target).closest('.language'), \"update\");\n }\n });\n}\n\nfunction enableVocabularySelect(selectItem, type) {\n selectItem.select2({\n ajax: {\n url: snacUrl + \"/vocabulary?type=\" + type,\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return {\n results: data.results\n };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 0,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n}\n\nfunction enableLanguageSelect($language) {\n enableVocabularySelect($language.find(\"select:first\"), 'language_code');\n enableVocabularySelect($language.find(\"select:last\"), 'script_code');\n}\n\nfunction magicNewResourceLanguage(event) {\n var $newLanguage = newResourceLanguage(event);\n var defaultLanguage = new Option(defaults.language.term, defaults.language.id, false, true);\n var defaultScript = new Option(defaults.script.term, defaults.script.id, false, true);\n $newLanguage.find(\"select:first\").append(defaultLanguage).trigger('change');\n $newLanguage.find(\"select:last\").append(defaultScript).trigger('change');\n}\n\nfunction selectHoldingRepository(event) {\n event.preventDefault();\n var name = event.target.innerHTML;\n var id = event.target.href.split('/').pop();\n var selectedRepo = new Option(name, id, false, true);\n $(\".resource-repo:last\").append(selectedRepo).trigger('change');\n $(\"#search_form\").slideToggle();\n $(\"#search-results-box\").html(\"\");\n $(\"#searchbox\").val(\"\");\n}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zcmMvdmlydHVhbGhvc3RzL3d3dy9qYXZhc2NyaXB0L3NyYy9yZXNvdXJjZV9hZG1pbi5qcz81OTE5Il0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogUmVzb3VyY2UgQWRtaW4gQWN0aW9uc1xuICpcbiAqIENvbnRhaW5zIGNvZGUgdGhhdCBoYW5kbGVzIFJlc291cmNlIGNyZWF0aW9uIGFuZCBlZGl0aW5nXG4gKlxuICogQGF1dGhvciBKb3NlcGggR2xhc3NcbiAqIEBsaWNlbnNlIGh0dHBzOi8vb3BlbnNvdXJjZS5vcmcvbGljZW5zZXMvQlNELTMtQ2xhdXNlIEJTRCAzLUNsYXVzZVxuICogQGNvcHlyaWdodCAyMDE1IHRoZSBSZWN0b3IgYW5kIFZpc2l0b3JzIG9mIHRoZSBVbml2ZXJzaXR5IG9mIFZpcmdpbmlhLCBhbmRcbiAqICAgICAgICAgICAgdGhlIFJlZ2VudHMgb2YgdGhlIFVuaXZlcnNpdHkgb2YgQ2FsaWZvcm5pYVxuICovXG5cbmZ1bmN0aW9uIHNhdmVSZXNvdXJjZShldmVudCk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2VsZWN0LCB0ZXh0YXJlYVwiKS5vbihcImNoYW5nZVwiLCBmdW5jdGlvbihlKSB7XG4gICAgICAgICQoZS50YXJnZXQpLmFkZENsYXNzKCdlZGl0ZWQtZmllbGQnKTtcblxuICAgICAgICBpZiAoJChlLnRhcmdldCkuY2xvc2VzdCgnLmxhbmd1YWdlJykubGVuZ3RoKSB7XG4gICAgICAgICAgICBzZXRPcGVyYXRpb25zKCQoZS50YXJnZXQpLmNsb3Nlc3QoJy5sYW5ndWFnZScpLCBcInVwZGF0ZVwiKTtcbiAgICAgICAgfVxuICAgIH0pO1xufVxuXG5mdW5jdGlvbiBlbmFibGVWb2NhYnVsYXJ5U2VsZWN0KHNlbGVjdEl0ZW0sIHR5cGUpIHtcbiAgICBzZWxlY3RJdGVtLnNlbGVjdDIoe1xuICAgICAgICBhamF4OiB7XG4gICAgICAgICAgICB1cmw6IHNuYWNVcmwgKyBcIi92b2NhYnVsYXJ5P3R5cGU9XCIgKyB0eXBlLFxuICAgICAgICAgICAgZGF0YVR5cGU6ICdqc29uJyxcbiAgICAgICAgICAgIGRlbGF5OiAyNTAsXG4gICAgICAgICAgICBkYXRhOiBmdW5jdGlvbihwYXJhbXMpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICBxOiBwYXJhbXMudGVybSxcbiAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2VcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHByb2Nlc3NSZXN1bHRzOiBmdW5jdGlvbihkYXRhLCBwYWdlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0czogZGF0YS5yZXN1bHRzXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjYWNoZTogdHJ1ZVxuICAgICAgICB9LFxuICAgICAgICB3aWR0aDogJzE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Q0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7Ozs7Ozs7QUFPQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7Ozs7OztBQU9BO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFGQTtBQUlBO0FBQ0E7QUFDQTtBQUNBO0FBREE7QUFHQTtBQUNBO0FBZkE7QUFpQkE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQXRCQTtBQXdCQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///0\n")}]); \ No newline at end of file +(function(e, a) { for(var i in a) e[i] = a[i]; }(window, /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"saveResource\", function() { return saveResource; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"setDeletedResourceLanguageOperations\", function() { return setDeletedResourceLanguageOperations; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"cancelResource\", function() { return cancelResource; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"newResourceLanguage\", function() { return newResourceLanguage; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"deleteOrUndoLanguage\", function() { return deleteOrUndoLanguage; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"markEditedResourceFields\", function() { return markEditedResourceFields; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"enableLanguageSelect\", function() { return enableLanguageSelect; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"magicNewResourceLanguage\", function() { return magicNewResourceLanguage; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"selectHoldingRepository\", function() { return selectHoldingRepository; });\n/**\n * Resource Admin Actions\n *\n * Contains code that handles Resource creation and editing\n *\n * @author Joseph Glass\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\nfunction saveResource(event) {\n event.preventDefault();\n var $form = $(event.target);\n\n if ($form.find(\"#resource-url\").val() == \"\") {\n if (!confirm('Are you sure you want to save without an HREF?')) {\n return;\n }\n }\n $('#notification-message').slideDown().html(\"

    Saving Resource... Please wait.

    \");\n\n // Remove leading and trailing whitespace\n $form.find(\"input, textarea\").each(function () {\n $(this).val($.trim($(this).val()));\n });\n\n setDeletedResourceLanguageOperations($form);\n\n $.post(snacUrl + \"/save_resource\", $form.serialize()).done(function (data) {\n createdResource = data;\n if (typeof data.resource === 'undefined') {\n $('#error-message').slideDown();\n return false;\n }\n $('#notification-message').slideUp();\n $('#success-message').slideDown();\n setTimeout(function () {\n window.location = snacUrl + \"/vocab_administrator/resources/\" + data.resource.id;\n }, 1000);\n }).fail(function () {\n $('#error-message').slideDown();\n });\n return false;\n}\n\nfunction setDeletedResourceLanguageOperations($form) {\n // Set deleted new languages to null, set deleted existing languages to delete\n var $deletedLanguages = $form.find(\"#resource-languages .component-deleted\").has('input[id]');\n var $ignoredLanguages = $form.find(\"#resource-languages .component-deleted.new-language\");\n setOperations($deletedLanguages, \"delete\");\n setOperations($ignoredLanguages, \"\");\n}\n\nfunction cancelResource() {\n if (!confirm('Are you sure you want to cancel?')) {\n return;\n }\n\n $('#notification-message').html(\"

    Cancelling...

    \");\n $('#notification-message').slideDown();\n setTimeout(function () {\n window.location.href = snacUrl + \"/vocab_administrator\";\n }, 1000);\n return false;\n}\n\n/**\n * New Resource Language\n * Copies the resource template DIV on the page and attaches it correctly to the DOM.\n * Tracks language index using $('#language-template').data('languageCount')\n *\n */\nfunction newResourceLanguage(event) {\n event.preventDefault();\n var $newLanguage = $('#resource-language-template').find(\".language\").clone();\n var data = $('#resource-language-template').data();\n var newLanguageID = 'language_' + data.languageCount;\n $newLanguage.attr('id', newLanguageID);\n $newLanguage.find('.operation').val('insert');\n $newLanguage.addClass('new-language');\n\n //update input names with new data.languageCount\n $newLanguage.find('input, select').attr('name', function (i, name) {\n return name.replace('YY', data.languageCount);\n });\n\n console.log('Adding new resource language with id: ', newLanguageID);\n $newLanguage.toggle();\n // selects last to avoid conflict on multiple clones\n $('.add-resource-language:last').before($newLanguage);\n enableLanguageSelect($newLanguage);\n\n data.languageCount++;\n return $newLanguage;\n}\n\n/**\n * Delete or Undo Language\n *\n * Toggles component-deleted class, and btn classes for delete and undo.\n * Does not change operations.\n *\n */\nfunction deleteOrUndoLanguage(event) {\n event.preventDefault();\n var $btn = $(event.currentTarget);\n $btn.toggleClass('btn-danger btn-warning');\n $btn.find(':only-child').toggleClass('fa-minus-circle fa-undo');\n var $language = $btn.closest('.language');\n $language.toggleClass('alert-danger component-deleted');\n}\n\nfunction setOperations($elements, operation) {\n $elements.find('.operation').each(function () {\n $(this).val(operation);\n });\n}\n\n/**\n * Mark Edited Resource Fields\n *\n * Adds edited-field class to altered inputs. Sets altered resource language to update.\n * @param jqueryObject $resourceForm jQuery object to modify\n *\n */\nfunction markEditedResourceFields($resourceForm) {\n $resourceForm.find(\"input, select, textarea\").on(\"change\", function (e) {\n $(e.target).addClass('edited-field');\n\n if ($(e.target).closest('.language').length) {\n setOperations($(e.target).closest('.language'), \"update\");\n }\n });\n}\n\nfunction enableVocabularySelect(selectItem, type) {\n selectItem.select2({\n ajax: {\n url: snacUrl + \"/vocabulary?type=\" + type,\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return {\n results: data.results\n };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 0,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n}\n\nfunction enableLanguageSelect($language) {\n enableVocabularySelect($language.find(\"select:first\"), 'language_code');\n enableVocabularySelect($language.find(\"select:last\"), 'script_code');\n}\n\nfunction magicNewResourceLanguage(event) {\n var $newLanguage = newResourceLanguage(event);\n var defaultLanguage = new Option(defaults.language.term, defaults.language.id, false, true);\n var defaultScript = new Option(defaults.script.term, defaults.script.id, false, true);\n $newLanguage.find(\"select:first\").append(defaultLanguage).trigger('change');\n $newLanguage.find(\"select:last\").append(defaultScript).trigger('change');\n}\n\nfunction selectHoldingRepository(event) {\n event.preventDefault();\n var name = event.target.innerHTML;\n var id = event.target.href.split('/').pop();\n var selectedRepo = new Option(name, id, false, true);\n $(\".resource-repo:last\").append(selectedRepo).trigger('change');\n $(\"#search_form\").slideToggle();\n $(\"#search-results-box\").html(\"\");\n $(\"#searchbox\").val(\"\");\n}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zcmMvdmlydHVhbGhvc3RzL3d3dy9qYXZhc2NyaXB0L3NyYy9yZXNvdXJjZV9hZG1pbi5qcz81OTE5Il0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogUmVzb3VyY2UgQWRtaW4gQWN0aW9uc1xuICpcbiAqIENvbnRhaW5zIGNvZGUgdGhhdCBoYW5kbGVzIFJlc291cmNlIGNyZWF0aW9uIGFuZCBlZGl0aW5nXG4gKlxuICogQGF1dGhvciBKb3NlcGggR2xhc3NcbiAqIEBsaWNlbnNlIGh0dHBzOi8vb3BlbnNvdXJjZS5vcmcvbGljZW5zZXMvQlNELTMtQ2xhdXNlIEJTRCAzLUNsYXVzZVxuICogQGNvcHlyaWdodCAyMDE1IHRoZSBSZWN0b3IgYW5kIFZpc2l0b3JzIG9mIHRoZSBVbml2ZXJzaXR5IG9mIFZpcmdpbmlhLCBhbmRcbiAqICAgICAgICAgICAgdGhlIFJlZ2VudHMgb2YgdGhlIFVuaXZlcnNpdHkgb2YgQ2FsaWZvcm5pYVxuICovXG5cbmV4cG9ydCBmdW5jdGlvbiBzYXZlUmVzb3VyY2UoZXZlbnQpIHtcbiAgICBldmVudC5wcmV2ZW50RGVmYXVsdCgpO1xuICAgIHZhciAkZm9ybSA9ICQoZXZlbnQudGFyZ2V0KTtcblxuICAgIGlmICgkZm9ybS5maW5kKFwiI3Jlc291cmNlLXVybFwiKS52YWwoKSA9PSBcIlwiKSB7XG4gICAgICAgIGlmICghY29uZmlybSgnQXJlIHlvdSBzdXJlIHlvdSB3YW50IHRvIHNhdmUgd2l0aG91dCBhbiBIUkVGPycpKSB7XG4gICAgICAgICAgICBy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AgICAgICAgICBzZXRPcGVyYXRpb25zKCQoZS50YXJnZXQpLmNsb3Nlc3QoJy5sYW5ndWFnZScpLCBcInVwZGF0ZVwiKTtcbiAgICAgICAgfVxuICAgIH0pO1xufVxuXG5mdW5jdGlvbiBlbmFibGVWb2NhYnVsYXJ5U2VsZWN0KHNlbGVjdEl0ZW0sIHR5cGUpIHtcbiAgICBzZWxlY3RJdGVtLnNlbGVjdDIoe1xuICAgICAgICBhamF4OiB7XG4gICAgICAgICAgICB1cmw6IHNuYWNVcmwgKyBcIi92b2NhYnVsYXJ5P3R5cGU9XCIgKyB0eXBlLFxuICAgICAgICAgICAgZGF0YVR5cGU6ICdqc29uJyxcbiAgICAgICAgICAgIGRlbGF5OiAyNTAsXG4gICAgICAgICAgICBkYXRhOiBmdW5jdGlvbihwYXJhbXMpIHtcbiAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICBxOiBwYXJhbXMudGVybSxcbiAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2VcbiAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgfSxcbiAgICAgICAgICAgIHByb2Nlc3NSZXN1bHRzOiBmdW5jdGlvbihkYXRhLCBwYWdlKSB7XG4gICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzdWx0czogZGF0YS5yZXN1bHRzXG4gICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgIH0sXG4gICAgICAgICAgICBjYWNoZTogdHJ1ZVxuICAgICAgICB9LFxuICAgICAgICB3aWR0aDogJzEwMCUnLFxuICAgICAgICBtaW5pbXVtSW5wdXRMZW5ndGg6IDAsXG4gICAgICAgIGFsbG93Q2xlYXI6IHRydWUsXG4gICAgICAgIHRoZW1lOiAnYm9vdHN0cmFwJyxcbiAgICAgICAgcGxhY2Vob2xkZXI6ICdTZWxlY3QnXG4gICAgfSk7XG59XG5cbmV4cG9ydCBmdW5jdGlvb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O0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTs7Ozs7OztBQU9BO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOzs7Ozs7O0FBT0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUZBO0FBSUE7QUFDQTtBQUNBO0FBQ0E7QUFEQTtBQUdBO0FBQ0E7QUFmQTtBQWlCQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBdEJBO0FBd0JBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///0\n"); + +/***/ }) +/******/ ]))); \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/select_loaders.js b/src/virtualhosts/www/javascript/select_loaders.js index 7e73e8400..550d091e0 100644 --- a/src/virtualhosts/www/javascript/select_loaders.js +++ b/src/virtualhosts/www/javascript/select_loaders.js @@ -1 +1,96 @@ -!function(I){var g={};function C(A){if(g[A])return g[A].exports;var e=g[A]={i:A,l:!1,exports:{}};return I[A].call(e.exports,e,e.exports,C),e.l=!0,e.exports}C.m=I,C.c=g,C.d=function(I,g,A){C.o(I,g)||Object.defineProperty(I,g,{enumerable:!0,get:A})},C.r=function(I){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(I,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(I,"__esModule",{value:!0})},C.t=function(I,g){if(1&g&&(I=C(I)),8&g)return I;if(4&g&&"object"==typeof I&&I&&I.__esModule)return I;var A=Object.create(null);if(C.r(A),Object.defineProperty(A,"default",{enumerable:!0,value:I}),2&g&&"string"!=typeof I)for(var e in I)C.d(A,e,function(g){return I[g]}.bind(null,e));return A},C.n=function(I){var g=I&&I.__esModule?function(){return I.default}:function(){return I};return C.d(g,"a",g),g},C.o=function(I,g){return Object.prototype.hasOwnProperty.call(I,g)},C.p="",C(C.s=1)}([,function(module,exports){eval('/**\n * Select Box Loaders\n *\n * Functions that can be used to replace select boxes on the edit page with\n * pretty-formatted versions using JQuery and Select2\n *\n * @author Robbie Hott\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\n/**\n * Replace a select that is linked to a Vocabulary search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n * @param string type The type of the vocabulary term\n * @param int minLength The minimum required length of the autocomplete search\n */\nfunction vocab_select_replace(selectItem, idMatch, type, minLength) {\n if (minLength === undefined) {\n minLength = 2;\n }\n\n if (selectItem.attr(\'id\').endsWith(idMatch) && !selectItem.attr(\'id\').endsWith("ZZ")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + "/vocabulary?type=" + type + "&id=";\n query += $("#constellationid").val() + "&version=" + $("#version").val();\n query += "&entity_type=" + $("#entityType").val();\n return query;\n },\n dataType: \'json\',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: \'100%\',\n minimumInputLength: minLength,\n allowClear: true,\n theme: \'bootstrap\',\n placeholder: \'Select\'\n });\n }\n}\n\nvar geoPlaceSearchResults = null;\n\nfunction geovocab_select_replace(selectItem, idMatch) {\n var minLength = 2;\n\n if (selectItem.attr(\'id\').endsWith(idMatch) && !selectItem.attr(\'id\').endsWith("ZZ")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + "/vocabulary?type=geo_place&format=term";\n query += "&entity_type=" + $("#entityType").val();\n return query;\n },\n dataType: \'json\',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n if (data.results) {\n geoPlaceSearchResults = data.results;\n var selectResults = new Array();\n data.results.forEach(function (result) {\n selectResults.push({\n id: result.id,\n text: result.name + " (" + result.administrationCode + ", " + result.countryCode + ")"\n });\n });\n return { results: selectResults };\n }\n return { results: null };\n },\n cache: true\n },\n width: \'100%\',\n minimumInputLength: minLength,\n allowClear: true,\n theme: \'bootstrap\',\n placeholder: \'Select\'\n });\n }\n}\n\nvar lastSourceSearchResults = null;\n\n/**\n * Add
    helper script\n *\n * Adds
    to strings so that they can be shown to the user in HTML\n * after being input into a text-only field.\n */\nfunction addbr(str) {\n if (typeof str !== \'undefined\' && str !== null) {\n return (str + \'\').replace(/(\\r\\n|\\n\\r|\\r|\\n)/g, \'
    \' + \'$1\');\n }\n return \'\';\n}\n\n/**\n * Replace a select that is linked to a Constellation Source search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n */\nfunction scm_source_select_replace(selectItem, idMatch) {\n if (selectItem.attr(\'id\').endsWith(idMatch) && !selectItem.attr(\'id\').endsWith("ZZ")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + "/vocabulary?type=ic_sources&id=";\n query += $("#constellationid").val() + "&version=" + $("#version").val();\n query += "&entity_type=" + $("#entityType").val();\n return query;\n },\n dataType: \'json\',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n // Modify the results to be in the format we want\n lastSourceSearchResults = data.results;\n // need id, text\n var results = new Array();\n data.results.forEach(function (res) {\n results.push({ id: res.id, text: res.displayName });\n });\n return { results: results };\n },\n cache: true\n },\n width: \'100%\',\n minimumInputLength: 0,\n allowClear: true,\n theme: \'bootstrap\',\n placeholder: \'Select\'\n });\n\n selectItem.on(\'change\', function (evt) {\n // TODO: Get the current selected value and update the well in the page to reflect it!\n // Note: all the selections are available in the global lastSourceSearchResults variable.\n var sourceID = $(this).val();\n var inPageID = $(this).attr("id");\n var idArray = inPageID.split("_");\n if (idArray.length >= 6) {\n var i = idArray[5];\n var j = idArray[4];\n var shortName = idArray[1];\n lastSourceSearchResults.forEach(function (source) {\n if (source.id == sourceID) {\n // Update the text of the source\n if (typeof source.text !== \'undefined\') {\n $("#scm_" + shortName + "_source_text_" + j + "_" + i).html(addbr(source.text)).removeClass(\'hidden\');\n $("#scm_" + shortName + "_source_text_" + j + "_" + i).closest(".panel-body").removeClass(\'hidden\');\n } else {\n $("#scm_" + shortName + "_source_text_" + j + "_" + i).text("").addClass(\'hidden\');\n $("#scm_" + shortName + "_source_text_" + j + "_" + i).closest(".panel-body").addClass(\'hidden\');\n }\n // Update the URI of the source\n if (typeof source.uri !== \'undefined\') $("#scm_" + shortName + "_source_uri_" + j + "_" + i).html(\'\' + source.uri + \'\');else $("#scm_" + shortName + "_source_uri_" + j + "_" + i).html(\'\');\n // Update the URI of the source\n if (typeof source.citation !== \'undefined\') $("#scm_" + shortName + "_source_citation_" + j + "_" + i).html(source.citation).removeClass(\'hidden\');else $("#scm_" + shortName + "_source_citation_" + j + "_" + i).html(\'\').addClass(\'hidden\');\n }\n });\n }\n });\n }\n}\n\n/**\n * Replace a select that is linked to an affiliation search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n */\nfunction affiliation_select_replace(selectItem) {\n $.get(snacUrl + "/vocabulary?type=affiliation").done(function (data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: true,\n theme: "bootstrap",\n placeholder: "Select Affiliation"\n });\n });\n}\n\nfunction reviewer_select_replace(selectItem) {\n if (selectItem != null) {\n selectItem.select2({\n placeholder: "Reviewer Name or Email...",\n ajax: {\n url: function () {\n var query = snacUrl + "/user_search?role=Reviewer";\n return query;\n },\n dataType: \'json\',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: \'100%\',\n minimumInputLength: 1,\n allowClear: false,\n theme: \'bootstrap\'\n });\n }\n}\n\nfunction select_replace(selectItem, idMatch) {\n if (selectItem.attr(\'id\').endsWith(idMatch) && !selectItem.attr(\'id\').endsWith("ZZ")) {\n selectItem.select2({\n allowClear: true,\n theme: \'bootstrap\'\n });\n }\n}\n\nfunction select_replace_simple(selectItem) {\n selectItem.select2({\n width: \'100%\',\n allowClear: true,\n theme: \'bootstrap\'\n });\n}\n\nfunction sayHi(user) {\n return `Hello, ${user}!`;\n}\n\nfunction sayBye(user) {\n return `Bye bye, ${user}!`;\n}\n\n/**\n * Load Vocab Select Options\n *\n * Replaces the select with a select2 object preloaded with an array of options\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string type The type of the vocabulary term\n * @param string type Text placeholder for select\n */\nfunction loadVocabSelectOptions(selectItem, type, placeholder) {\n return $.get(snacUrl + "/vocabulary?type=" + type).done(function (data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: false,\n theme: \'bootstrap\',\n placeholder: placeholder\n });\n });\n}\n\n/**\n * Replace all the selects that exist on the page when the page has finished loading\n */\n$(document).ready(function () {\n\n // Use select2 to display the select dropdowns\n // rather than the HTML default\n $("select").each(function () {\n if (typeof $(this).attr(\'id\') !== typeof undefined && $(this).attr(\'id\') !== false) {\n // Replace the subject selects\n vocab_select_replace($(this), "language_language_", "language_code", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), "language_script_", "script_code", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), "subject_", "subject", 4);\n\n // Replace the function selects\n vocab_select_replace($(this), "function_", "function", 4);\n\n // Replace the occupation selects\n vocab_select_replace($(this), "occupation_", "occupation", 4);\n\n // Replace the entityType select\n vocab_select_replace($(this), "entityType", "entity_type", 0);\n }\n });\n\n // Replace the Affiliation dropdowns, if one exists\n if ($("#affiliationid").exists()) affiliation_select_replace($("#affiliationid"));\n\n // Replace the User search dropdown, if one exists\n if ($("#reviewersearchbox").exists()) reviewer_select_replace($("#reviewersearchbox"));\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zcmMvdmlydHVhbGhvc3RzL3d3dy9qYXZhc2NyaXB0L3NyYy9zZWxlY3RfbG9hZGVycy5qcz8zOGJlIl0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogU2VsZWN0IEJveCBMb2FkZXJzXG4gKlxuICogRnVuY3Rpb25zIHRoYXQgY2FuIGJlIHVzZWQgdG8gcmVwbGFjZSBzZWxlY3QgYm94ZXMgb24gdGhlIGVkaXQgcGFnZSB3aXRoXG4gKiBwcmV0dHktZm9ybWF0dGVkIHZlcnNpb25zIHVzaW5nIEpRdWVyeSBhbmQgU2VsZWN0MlxuICpcbiAqIEBhdXRob3IgUm9iYmllIEhvdHRcbiAqIEBsaWNlbnNlIGh0dHBzOi8vb3BlbnNvdXJjZS5vcmcvbGljZW5zZXMvQlNELTMtQ2xhdXNlIEJTRCAzLUNsYXVzZVxuICogQGNvcHlyaWdodCAyMDE1IHRoZSBSZWN0b3IgYW5kIFZpc2l0b3JzIG9mIHRoZSBVbml2ZXJzaXR5IG9mIFZpcmdpbmlhLCBhbmRcbiAqICAgICAgICAgICAgdGhlIFJlZ2VudHMgb2YgdGhlIFVuaXZlcnNpdHkgb2YgQ2FsaWZvcm5pYVxuICovXG5cbi8qKlxuICogUmVwbGFjZSBhIHNlbGVjdCB0aGF0IGlzIGxpbmtlZCB0byBhIFZvY2FidWxhcnkgc2VhcmNoXG4gKlxuICogUmVw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AgICAgICAgICAgIHF1ZXJ5ICs9ICQoXCIjY29uc3RlbGxhdGlvbmlkXCIpLnZhbCgpK1wiJnZlcnNpb249XCIrJChcIiN2ZXJzaW9uXCIpLnZhbCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeSArPSBcIiZlbnRpdHlfdHlwZT1cIiskKFwiI2VudGl0eVR5cGVcIikudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBxdWVyeTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb24nLFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVsYXk6IDI1MCxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IGZ1bmN0aW9uIChwYXJhbXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxOiBwYXJhbXMudGVybSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb2Nlc3NSZXN1bHRzOiBmdW5jdGlvbiAoZGF0YSwgcGFnZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7IHJlc3VsdHM6IGRhdGEucmVzdWx0cyB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIHdpZHRoOiAnMTAwJScsXG4gICAgICAgICAgICAgICAgICAgIG1pbmltdW1JbnB1dExlbmd0aDogbWluTGVuZ3RoLFxuICAgICAgICAgICAgICAgICAgICBhbGxvd0NsZWFyOiB0cnVlLFxuICAgICAgICAgICAgICAgICAgICB0aGVtZTogJ2Jvb3RzdHJhcCcsXG4gICAgICAgICAgICAgICAgICAgIHBsYWNlaG9sZGVyOiAnU2VsZWN0J1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxufVxuXG52YXIgZ2VvUGxhY2VTZWFyY2hSZXN1bHRzID0gbnVsbDtcblxuZnVuY3Rpb24gZ2Vvdm9jYWJfc2VsZWN0X3JlcGxhY2Uoc2VsZWN0SXRlbSwgaWRNYXRjaCkge1xuICAgIHZhciBtaW5MZW5ndGggPSAyO1xuXG4gICAgaWYoc2VsZWN0SXRlbS5hdHRyKCdpZCcpLmVuZHNXaXRoKGlkTWF0Y2gpXG4gICAgICAgICYmICFzZWxlY3RJdGVtLmF0dHIoJ2lkJykuZW5kc1dpdGgoXCJaWlwiKSkge1xuICAgICAgICAgICAgc2VsZWN0SXRlbS5zZWxlY3QyKHtcbiAgICAgICAgICAgICAgICBhamF4OiB7XG4gICAgICAgICAgICAgICAgICAgIHVybDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcXVlcnkgPSBzbmFjVXJsK1wiL3ZvY2FidWxhcnk/dHlwZT1nZW9fcGxhY2UmZm9ybWF0PXRlcm1cIjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeSArPSBcIiZlbnRpdHlfdHlwZT1cIiskKFwiI2VudGl0eVR5cGVcIikudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHF1ZXJ5O1xuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb24nLFxuICAgICAgICAgICAgICAgICAgICBkZWxheTogMjUwLFxuICAgICAgICAgICAgICAgICAgICBkYXRhOiBmdW5jdGlvbiAocGFyYW1zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHE6IHBhcmFtcy50ZXJtLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhcmFtcy5wYWdlXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBwcm9jZXNzUmVzdWx0czogZnVuY3Rpb24gKGRhdGEsIHBhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnJlc3VsdHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZW9QbGFjZVNlYXJjaFJlc3VsdHMgPSBkYXRhLnJlc3VsdHM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNlbGVjdFJlc3VsdHMgPSBuZXcgQXJyYXkoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnJlc3VsdHMuZm9yRWFjaChmdW5jdGlvbihyZXN1bHQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0UmVzdWx0cy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiByZXN1bHQuaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0OiByZXN1bHQubmFtZSArIFwiIChcIiArIHJlc3VsdC5hZG1pbmlzdHJhdGlvbkNvZGUgKyBcIiwgXCIgKyByZXN1bHQuY291bnRyeUNvZGUrIFwiKVwiXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtyZXN1bHRzOiBzZWxlY3RSZXN1bHRzfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7IHJlc3VsdHM6IG51bGwg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BxdWVyaWVzXG4gKlxuICogQHBhcmFtICBKUXVlcnkgc2VsZWN0SXRlbSBUaGUgSlF1ZXJ5IGl0ZW0gdG8gcmVwbGFjZVxuICogQHBhcmFtICBzdHJpbmcgaWRNYXRjaCAgICBJRCBzdHJpbmcgZm9yIHRoZSBvYmplY3Qgb24gdGhlIHBhZ2VcbiAqL1xuZnVuY3Rpb24gc2NtX3NvdXJjZV9zZWxlY3RfcmVwbGFjZShzZWxlY3RJdGVtLCBpZE1hdGNoKSB7XG4gICAgICAgIGlmKHNlbGVjdEl0ZW0uYXR0cignaWQnKS5lbmRzV2l0aChpZE1hdGNoKVxuICAgICAgICAgICAgJiYgIXNlbGVjdEl0ZW0uYXR0cignaWQnKS5lbmRzV2l0aChcIlpaXCIpKSB7XG4gICAgICAgICAgICAgICAgc2VsZWN0SXRlbS5zZWxlY3QyKHtcbiAgICAgICAgICAgICAgICAgICAgYWpheDoge1xuICAgICAgICAgICAgICAgICAgICAgICAgdXJsOiBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcXVlcnkgPSBzbmFjVXJsK1wiL3ZvY2FidWxhcnk/dHlwZT1pY19zb3VyY2VzJmlkPVwiO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeSArPSAkKFwiI2NvbnN0ZWxsYXRpb25pZFwiKS52YWwoKStcIiZ2ZXJzaW9uPVwiKyQoXCIjdmVyc2lvblwiKS52YWwoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVlcnkgKz0gXCImZW50aXR5X3R5cGU9XCIrJChcIiNlbnRpdHlUeXBlXCIpLnZhbCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcXVlcnk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVR5cGU6ICdqc29uJyxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGF5OiAyNTAsXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhOiBmdW5jdGlvbiAocGFyYW1zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcTogcGFyYW1zLnRlcm0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhcmFtcy5wYWdlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzUmVzdWx0czogZnVuY3Rpb24gKGRhdGEsIHBhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBNb2RpZnkgdGhlIHJlc3VsdHMgdG8gYmUgaW4gdGhlIGZvcm1hdCB3ZSB3YW50XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgbGFzdFNvdXJjZVNlYXJjaFJlc3VsdHMgPSBkYXRhLnJlc3VsdHM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gbmVlZCBpZCwgdGV4dFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciByZXN1bHRzID0gbmV3IEFycmF5KCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0YS5yZXN1bHRzLmZvckVhY2goZnVuY3Rpb24ocmVzKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJlc3VsdHMucHVzaCh7aWQ6IHJlcy5pZCwgdGV4dDogcmVzLmRpc3BsYXlOYW1lfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHsgcmVzdWx0czogcmVzdWx0cyB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIHdpZHRoOiAnMTAwJScsXG4gICAgICAgICAgICAgICAgICAgIG1pbmltdW1JbnB1dExlbmd0aDogMCxcbiAgICAgICAgICAgICAgICAgICAgYWxsb3dDbGVhcjogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgdGhlbWU6ICdib290c3RyYXAnLFxuICAgICAgICAgICAgICAgICAgICBwbGFjZWhvbGRlcjogJ1NlbGVjdCdcbiAgICAgICAgICAgICAgICB9KTtcblxuICAgICAgICAgICAgc2VsZWN0SXRlbS5vbignY2hhbmdlJywgZnVuY3Rpb24gKGV2dCkge1xuICAgICAgICAgICAgICAgIC8vIFRPRE86IEdldCB0aGUgY3VycmVudCBzZWxlY3RlZCB2YWx1ZSBhbmQgdXBkYXRlIHRoZSB3ZWxsIGluIHRoZSBwYWdlIHRvIHJlZmxlY3QgaXQhXG4gICAgICAgICAgICAgICAgLy8gTm90ZTogYWxsIHRoZSBzZWxlY3Rpb25zIGFyZSBhdmFpbGFibGUgaW4gdGhlIGdsb2JhbCBsYXN0U291cmNlU2VhcmNoUmVzdWx0cyB2YXJpYWJsZS5cbiAgICAgICAgICAgICAgICB2YXIgc291cmNlSUQgPSAkKHRoaXMpLnZhbCgpO1xuICAgICAgICAgICAgICAgIHZhciBpblBhZ2VJRCA9ICQodGhpcykuYXR0cihcImlkXCIpO1xuICAgICAgICAgICAgICAgIHZhciBpZEFycmF5ID0gaW5QYWdlSUQuc3BsaXQoXCJfXCIpO1xuICAgICAgICAgICAgICAgIGlmIChpZEFycmF5Lmxlbmd0aCA+PSA2KSB7XG4gICAgICAgICAgICAgICAgICAgIHZhciBpID0gaWRBcnJheVs1XTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIGogPSBpZEFycmF5WzRdO1xuICAgICAgICAgICAgICAgICAgICB2YXIgc2hvcnROYW1lID0gaWRBcnJheVsxXTtcbiAgICAgICAgICAgICAgICAgICAgbGFzdFNvdXJjZVNlYXJjaFJlc3VsdHMuZm9yRWFjaChmdW5jdGlvbihzb3VyY2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChzb3VyY2UuaWQgPT0gc291cmNlSUQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBVcGRhdGUgdGhlIHRleHQgb2YgdGhlIHNvdXJjZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2Ygc291cmNlLnRleHQgIT09ICd1bmRlZmluZWQnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjc2NtX1wiICsgc2hvcnROYW1lICsgXCJfc291cmNlX3RleHRfXCIgKyBqICsgXCJfXCIgKyBpKS5odG1sKGFkZGJyKHNvdXJjZS50ZXh0KSkucmVtb3ZlQ2xhc3MoJ2hpZGRlbicpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV90ZXh0X1wiICsgaiArIFwiX1wiICsgaSkuY2xvc2VzdChcIi5wYW5lbC1ib2R5XCIpLnJlbW92ZUNsYXNzKCdoaWRkZW4nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV90ZXh0X1wiICsgaiArIFwiX1wiICsgaSkudGV4dChcIlwiKS5hZGRDbGFzcygnaGlkZGVuJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjc2NtX1wiICsgc2hvcnROYW1lICsgXCJfc291cmNlX3RleHRfXCIgKyBqICsgXCJfXCIgKyBpKS5jbG9zZXN0KFwiLnBhbmVsLWJvZHlcIikuYWRkQ2xhc3MoJ2hpZGRlbicpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFVwZGF0ZSB0aGUgVVJJIG9mIHRoZSBzb3VyY2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZS51cmkgIT09ICd1bmRlZmluZWQnKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV91cmlfXCIgKyBqICsgXCJfXCIgKyBpKS5odG1sKCc8YSBocmVmPVwiJytzb3VyY2UudXJpKydcIiB0YXJnZXQ9XCJfYmxhbmtcIj4nK3NvdXJjZS51cmkrJzwvYT4nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjc2NtX1wiICsgc2hvcnROYW1lICsgXCJfc291cmNlX3VyaV9cIiArIGogKyBcIl9cIiArIGkpLmh0bWwoJycpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIFVwZGF0ZSB0aGUgVVJJIG9mIHRoZSBzb3VyY2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZS5jaXRhdGlvbiAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjc2NtX1wiICsgc2hvcnROYW1lICsgXCJfc291cmNlX2NpdGF0aW9uX1wiICsgaiArIFwiX1wiICsgaSkuaHRtbChzb3VyY2UuY2l0YXRpb24pLnJlbW92ZUNsYXNzKCdoaWRkZW4nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjc2NtX1wiICsgc2hvcnROYW1lICsgXCJfc291cmNlX2NpdGF0aW9uX1wiICsgaiArIFwiX1wiICsgaSkuaHRtbCgnJykuYWRkQ2xhc3MoJ2hpZGRlbicpO1xuICAgICAgICAgICAgICAgICAgICAgICAgfVxuICA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EVtYWlsLi4uXCIsXG4gICAgICAgICAgICAgICAgICAgIGFqYXg6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHF1ZXJ5ID0gc25hY1VybCtcIi91c2VyX3NlYXJjaD9yb2xlPVJldmlld2VyXCI7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBxdWVyeTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb24nLFxuICAgICAgICAgICAgICAgICAgICAgICAgZGVsYXk6IDI1MCxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGE6IGZ1bmN0aW9uIChwYXJhbXMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxOiBwYXJhbXMudGVybSxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcGFnZTogcGFyYW1zLnBhZ2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIHByb2Nlc3NSZXN1bHRzOiBmdW5jdGlvbiAoZGF0YSwgcGFnZSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7IHJlc3VsdHM6IGRhdGEucmVzdWx0cyB9O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGNhY2hlOiB0cnVlXG4gICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgIHdpZHRoOiAnMTAwJScsXG4gICAgICAgICAgICAgICAgICAgIG1pbmltdW1JbnB1dExlbmd0aDogMSxcbiAgICAgICAgICAgICAgICAgICAgYWxsb3dDbGVhcjogZmFsc2UsX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QUFDQTtBQUNBO0FBRkE7QUFJQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBSEE7QUFLQTtBQUNBO0FBR0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBOzs7Ozs7Ozs7QUFTQTtBQUNBO0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBSkE7QUFNQTtBQUNBO0FBQ0E7QUFDQTs7O0FBR0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFFQSIsInNvdXJjZVJvb3QiOiIifQ==\n//# sourceURL=webpack-internal:///1\n')}]); \ No newline at end of file +(function(e, a) { for(var i in a) e[i] = a[i]; }(window, /******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = 1); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */, +/* 1 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"vocab_select_replace\", function() { return vocab_select_replace; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"geoPlaceSearchResults\", function() { return geoPlaceSearchResults; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"geovocab_select_replace\", function() { return geovocab_select_replace; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"scm_source_select_replace\", function() { return scm_source_select_replace; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"select_replace_simple\", function() { return select_replace_simple; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"sayHi\", function() { return sayHi; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"sayBye\", function() { return sayBye; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"loadVocabSelectOptions\", function() { return loadVocabSelectOptions; });\n/**\n * Select Box Loaders\n *\n * Functions that can be used to replace select boxes on the edit page with\n * pretty-formatted versions using JQuery and Select2\n *\n * @author Robbie Hott\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\n/**\n * Replace a select that is linked to a Vocabulary search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n * @param string type The type of the vocabulary term\n * @param int minLength The minimum required length of the autocomplete search\n */\nfunction vocab_select_replace(selectItem, idMatch, type, minLength) {\n if (minLength === undefined) {\n minLength = 2;\n }\n\n if (selectItem.attr('id').endsWith(idMatch) && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + \"/vocabulary?type=\" + type + \"&id=\";\n query += $(\"#constellationid\").val() + \"&version=\" + $(\"#version\").val();\n query += \"&entity_type=\" + $(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: minLength,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n }\n}\n\nvar geoPlaceSearchResults = null;\n\nfunction geovocab_select_replace(selectItem, idMatch) {\n var minLength = 2;\n\n if (selectItem.attr('id').endsWith(idMatch) && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + \"/vocabulary?type=geo_place&format=term\";\n query += \"&entity_type=\" + $(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n if (data.results) {\n geoPlaceSearchResults = data.results;\n var selectResults = new Array();\n data.results.forEach(function (result) {\n selectResults.push({\n id: result.id,\n text: result.name + \" (\" + result.administrationCode + \", \" + result.countryCode + \")\"\n });\n });\n return { results: selectResults };\n }\n return { results: null };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: minLength,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n }\n}\n\nvar lastSourceSearchResults = null;\n\n/**\n * Add
    helper script\n *\n * Adds
    to strings so that they can be shown to the user in HTML\n * after being input into a text-only field.\n */\nfunction addbr(str) {\n if (typeof str !== 'undefined' && str !== null) {\n return (str + '').replace(/(\\r\\n|\\n\\r|\\r|\\n)/g, '
    ' + '$1');\n }\n return '';\n}\n\n/**\n * Replace a select that is linked to a Constellation Source search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n */\nfunction scm_source_select_replace(selectItem, idMatch) {\n if (selectItem.attr('id').endsWith(idMatch) && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + \"/vocabulary?type=ic_sources&id=\";\n query += $(\"#constellationid\").val() + \"&version=\" + $(\"#version\").val();\n query += \"&entity_type=\" + $(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n // Modify the results to be in the format we want\n lastSourceSearchResults = data.results;\n // need id, text\n var results = new Array();\n data.results.forEach(function (res) {\n results.push({ id: res.id, text: res.displayName });\n });\n return { results: results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 0,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n\n selectItem.on('change', function (evt) {\n // TODO: Get the current selected value and update the well in the page to reflect it!\n // Note: all the selections are available in the global lastSourceSearchResults variable.\n var sourceID = $(this).val();\n var inPageID = $(this).attr(\"id\");\n var idArray = inPageID.split(\"_\");\n if (idArray.length >= 6) {\n var i = idArray[5];\n var j = idArray[4];\n var shortName = idArray[1];\n lastSourceSearchResults.forEach(function (source) {\n if (source.id == sourceID) {\n // Update the text of the source\n if (typeof source.text !== 'undefined') {\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).html(addbr(source.text)).removeClass('hidden');\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).closest(\".panel-body\").removeClass('hidden');\n } else {\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).text(\"\").addClass('hidden');\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).closest(\".panel-body\").addClass('hidden');\n }\n // Update the URI of the source\n if (typeof source.uri !== 'undefined') $(\"#scm_\" + shortName + \"_source_uri_\" + j + \"_\" + i).html('' + source.uri + '');else $(\"#scm_\" + shortName + \"_source_uri_\" + j + \"_\" + i).html('');\n // Update the URI of the source\n if (typeof source.citation !== 'undefined') $(\"#scm_\" + shortName + \"_source_citation_\" + j + \"_\" + i).html(source.citation).removeClass('hidden');else $(\"#scm_\" + shortName + \"_source_citation_\" + j + \"_\" + i).html('').addClass('hidden');\n }\n });\n }\n });\n }\n}\n\n/**\n * Replace a select that is linked to an affiliation search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n */\nfunction affiliation_select_replace(selectItem) {\n $.get(snacUrl + \"/vocabulary?type=affiliation\").done(function (data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: true,\n theme: \"bootstrap\",\n placeholder: \"Select Affiliation\"\n });\n });\n}\n\nfunction reviewer_select_replace(selectItem) {\n if (selectItem != null) {\n selectItem.select2({\n placeholder: \"Reviewer Name or Email...\",\n ajax: {\n url: function () {\n var query = snacUrl + \"/user_search?role=Reviewer\";\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 1,\n allowClear: false,\n theme: 'bootstrap'\n });\n }\n}\n\nfunction select_replace(selectItem, idMatch) {\n if (selectItem.attr('id').endsWith(idMatch) && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n allowClear: true,\n theme: 'bootstrap'\n });\n }\n}\n\nfunction select_replace_simple(selectItem) {\n selectItem.select2({\n width: '100%',\n allowClear: true,\n theme: 'bootstrap'\n });\n}\n\nfunction sayHi(user) {\n return `Hello, ${user}!`;\n}\n\nfunction sayBye(user) {\n return `Bye bye, ${user}!`;\n}\n\n/**\n * Load Vocab Select Options\n *\n * Replaces the select with a select2 object preloaded with an array of options\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string type The type of the vocabulary term\n * @param string type Text placeholder for select\n */\nfunction loadVocabSelectOptions(selectItem, type, placeholder) {\n return $.get(snacUrl + \"/vocabulary?type=\" + type).done(function (data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: false,\n theme: 'bootstrap',\n placeholder: placeholder\n });\n });\n}\n\n/**\n * Replace all the selects that exist on the page when the page has finished loading\n */\n$(document).ready(function () {\n\n // Use select2 to display the select dropdowns\n // rather than the HTML default\n $(\"select\").each(function () {\n if (typeof $(this).attr('id') !== typeof undefined && $(this).attr('id') !== false) {\n // Replace the subject selects\n vocab_select_replace($(this), \"language_language_\", \"language_code\", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), \"language_script_\", \"script_code\", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), \"subject_\", \"subject\", 4);\n\n // Replace the function selects\n vocab_select_replace($(this), \"function_\", \"function\", 4);\n\n // Replace the occupation selects\n vocab_select_replace($(this), \"occupation_\", \"occupation\", 4);\n\n // Replace the entityType select\n vocab_select_replace($(this), \"entityType\", \"entity_type\", 0);\n }\n });\n\n // Replace the Affiliation dropdowns, if one exists\n if ($(\"#affiliationid\").exists()) affiliation_select_replace($(\"#affiliationid\"));\n\n // Replace the User search dropdown, if one exists\n if ($(\"#reviewersearchbox\").exists()) reviewer_select_replace($(\"#reviewersearchbox\"));\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zcmMvdmlydHVhbGhvc3RzL3d3dy9qYXZhc2NyaXB0L3NyYy9zZWxlY3RfbG9hZGVycy5qcz8zOGJlIl0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogU2VsZWN0IEJveCBMb2FkZXJzXG4gKlxuICogRnVuY3Rpb25zIHRoYXQgY2FuIGJlIHVzZWQgdG8gcmVwbGFjZSBzZWxlY3QgYm94ZXMgb24gdGhlIGVkaXQgcGFnZSB3aXRoXG4gKiBwcmV0dHktZm9ybWF0dGVkIHZlcnNpb25zIHVzaW5nIEpRdWVyeSBhbmQgU2VsZWN0MlxuICpcbiAqIEBhdXRob3IgUm9iYmllIEhvdHRcbiAqIEBsaWNlbnNlIGh0dHBzOi8vb3BlbnNvdXJjZS5vcmcvbGljZW5zZXMvQlNELTMtQ2xhdXNlIEJTRCAzLUNsYXVzZVxuICogQGNvcHlyaWd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XCJaWlwiKSkge1xuICAgICAgICAgICAgICAgIHNlbGVjdEl0ZW0uc2VsZWN0Mih7XG4gICAgICAgICAgICAgICAgICAgIGFqYXg6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHF1ZXJ5ID0gc25hY1VybCArIFwiL3ZvY2FidWxhcnk/dHlwZT1cIit0eXBlK1wiJmlkPVwiO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeSArPSAkKFwiI2NvbnN0ZWxsYXRpb25pZFwiKS52YWwoKStcIiZ2ZXJzaW9uPVwiKyQoXCIjdmVyc2lvblwiKS52YWwoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVlcnkgKz0gXCImZW50aXR5X3R5cGU9XCIrJChcIiNlbnRpdHlUeXBlXCIpLnZhbCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcXVlcnk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVR5cGU6ICdqc29uJyxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGF5OiAyNTAsXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhOiBmdW5jdGlvbiAocGFyYW1zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcTogcGFyYW1zLnRlcm0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhcmFtcy5wYWdlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzUmVzdWx0czogZnVuY3Rpb24gKGRhdGEsIHBhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyByZXN1bHRzOiBkYXRhLnJlc3VsdHMgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBjYWNoZTogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB3aWR0aDogJzEwMCUnLFxuICAgICAgICAgICAgICAgICAgICBtaW5pbXVtSW5wdXRMZW5ndGg6IG1pbkxlbmd0aCxcbiAgICAgICAgICAgICAgICAgICAgYWxsb3dDbGVhcjogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgdGhlbWU6ICdib290c3RyYXAnLFxuICAgICAgICAgICAgICAgICAgICBwbGFjZWhvbGRlcjogJ1NlbGVjdCdcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbn1cblxuZXhwb3J0IHZhciBnZW9QbGFjZVNlYXJjaFJlc3VsdHMgPSBudWxsO1xuXG5leHBvcnQgZnVuY3Rpb24gZ2Vvdm9jYWJfc2VsZWN0X3JlcGxhY2Uoc2VsZWN0SXRlbSwgaWRNYXRjaCkge1xuICAgIHZhciBtaW5MZW5ndGggPSAyO1xuXG4gICAgaWYoc2VsZWN0SXRlbS5hdHRyKCdpZCcpLmVuZHNXaXRoKGlkTWF0Y2gpXG4gICAgICAgICYmICFzZWxlY3RJdGVtLmF0dHIoJ2lkJykuZW5kc1dpdGgoXCJaWlwiKSkge1xuICAgICAgICAgICAgc2VsZWN0SXRlbS5zZWxlY3QyKHtcbiAgICAgICAgICAgICAgICBhamF4OiB7XG4gICAgICAgICAgICAgICAgICAgIHVybDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcXVlcnkgPSBzbmFjVXJsK1wiL3ZvY2FidWxhcnk/dHlwZT1nZW9fcGxhY2UmZm9ybWF0PXRlcm1cIjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeSArPSBcIiZlbnRpdHlfdHlwZT1cIiskKFwiI2VudGl0eVR5cGVcIikudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHF1ZXJ5O1xuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb24nLFxuICAgICAgICAgICAgICAgICAgICBkZWxheTogMjUwLFxuICAgICAgICAgICAgICAgICAgICBkYXRhOiBmdW5jdGlvbiAocGFyYW1zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHE6IHBhcmFtcy50ZXJtLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhcmFtcy5wYWdlXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBwcm9jZXNzUmVzdWx0czogZnVuY3Rpb24gKGRhdGEsIHBhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnJlc3VsdHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZW9QbGFjZVNlYXJjaFJlc3VsdHMgPSBkYXRhLnJlc3VsdHM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNlbGVjdFJlc3VsdHMgPSBuZXcgQXJyYXkoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnJlc3VsdHMuZm9yRWFjaChmdW5jdGlvbihyZXN1bHQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0UmVzdWx0cy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiByZXN1bHQuaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0OiByZXN1bHQubmFtZSArIFwiIChcIiArIHJlc3VsdC5hZG1pbmlzdHJhdGlvbkNvZGUgKyBcIiwgXCIgKyByZXN1bHQuY291bnRyeUNvZGUrIFwiKVwiXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtyZXN1bHRzOiBzZWxlY3RSZXN1bHRzfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7IHJlc3VsdHM6IG51bGwgfTtcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgY2FjaGU6IHRydWVcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHdpZHRoOiAnMTAwJScsXG4gICAgICAgICAgICAgICAgbWluaW11bUlucHV0TGVuZ3RoOiBtaW5MZW5ndGgsXG4gICAgICAgICAgICAgICAgYWxsb3dDbGVhcjogdHJ1ZSxcbiAgICAgICAgICAgICAgICB0aGVtZTogJ2Jvb3RzdHJhcCcsXG4gICAgICAgICAgICAgICAgcGxhY2Vob2xkZXI6ICdTZWxlY3QnXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxufVxuXG52YXIgbGFzdFNvdXJjZVNlYXJjaFJlc3VsdHMgPSBudWxsO1xuXG4vKipcbiAqIEFkZCA8YnI+IGhlbHBlciBzY3JpcHRcbiAqXG4gKiBBZGRzIDxicj4gdG8gc3RyaW5ncyBzbyB0aGF0IHRoZXkgY2FuIGJlIHNob3duIHRvIHRoZSB1c2VyIGluIEhUTUxcbiAqIGFmdGVyIGJlaW5nIGlucHV0IGludG8gYSB0ZXh0LW9ubHkgZmllbGQuXG4gKi9cbmZ1bmN0aW9uIGFkZGJyKHN0cikge1xuICAgIGlmICh0eXBlb2Ygc3RyICE9PSAndW5kZWZpbmVkJyAmJiBzdHIgIT09IG51bGwpIHtcbiAgICAgICAgcmV0dXJuIChzdHIgKyAnJyk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vbj1cIiskKFwiI3ZlcnNpb25cIikudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJ5ICs9IFwiJmVudGl0eV90eXBlPVwiKyQoXCIjZW50aXR5VHlwZVwiKS52YWwoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHF1ZXJ5O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFUeXBlOiAnanNvbicsXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWxheTogMjUwLFxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogZnVuY3Rpb24gKHBhcmFtcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHE6IHBhcmFtcy50ZXJtLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlOiBwYXJhbXMucGFnZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc1Jlc3VsdHM6IGZ1bmN0aW9uIChkYXRhLCBwYWdlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gTW9kaWZ5IHRoZSByZXN1bHRzIHRvIGJlIGluIHRoZSBmb3JtYXQgd2Ugd2FudFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3RTb3VyY2VTZWFyY2hSZXN1bHRzID0gZGF0YS5yZXN1bHRzO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG5lZWQgaWQsIHRleHRcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0cyA9IG5ldyBBcnJheSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEucmVzdWx0cy5mb3JFYWNoKGZ1bmN0aW9uKHJlcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzLnB1c2goe2lkOiByZXMuaWQsIHRleHQ6IHJlcy5kaXNwbGF5TmFtZX0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7IHJlc3VsdHM6IHJlc3VsdHMgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBjYWNoZTogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB3aWR0aDogJzEwMCUnLFxuICAgICAgICAgICAgICAgICAgICBtaW5pbXVtSW5wdXRMZW5ndGg6IDAsXG4gICAgICAgICAgICAgICAgICAgIGFsbG93Q2xlYXI6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHRoZW1lOiAnYm9vdHN0cmFwJyxcbiAgICAgICAgICAgICAgICAgICAgcGxhY2Vob2xkZXI6ICdTZWxlY3QnXG4gICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIHNlbGVjdEl0ZW0ub24oJ2NoYW5nZScsIGZ1bmN0aW9uIChldnQpIHtcbiAgICAgICAgICAgICAgICAvLyBUT0RPOiBHZXQgdGhlIGN1cnJlbnQgc2VsZWN0ZWQgdmFsdWUgYW5kIHVwZGF0ZSB0aGUgd2VsbCBpbiB0aGUgcGFnZSB0byByZWZsZWN0IGl0IVxuICAgICAgICAgICAgICAgIC8vIE5vdGU6IGFsbCB0aGUgc2VsZWN0aW9ucyBhcmUgYXZhaWxhYmxlIGluIHRoZSBnbG9iYWwgbGFzdFNvdXJjZVNlYXJjaFJlc3VsdHMgdmFyaWFibGUuXG4gICAgICAgICAgICAgICAgdmFyIHNvdXJjZUlEID0gJCh0aGlzKS52YWwoKTtcbiAgICAgICAgICAgICAgICB2YXIgaW5QYWdlSUQgPSAkKHRoaXMpLmF0dHIoXCJpZFwiKTtcbiAgICAgICAgICAgICAgICB2YXIgaWRBcnJheSA9IGluUGFnZUlELnNwbGl0KFwiX1wiKTtcbiAgICAgICAgICAgICAgICBpZiAoaWRBcnJheS5sZW5ndGggPj0gNikge1xuICAgICAgICAgICAgICAgICAgICB2YXIgaSA9IGlkQXJyYXlbNV07XG4gICAgICAgICAgICAgICAgICAgIHZhciBqID0gaWRBcnJheVs0XTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHNob3J0TmFtZSA9IGlkQXJyYXlbMV07XG4gICAgICAgICAgICAgICAgICAgIGxhc3RTb3VyY2VTZWFyY2hSZXN1bHRzLmZvckVhY2goZnVuY3Rpb24oc291cmNlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlLmlkID09IHNvdXJjZUlEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gVXBkYXRlIHRoZSB0ZXh0IG9mIHRoZSBzb3VyY2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZS50ZXh0ICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV90ZXh0X1wiICsgaiArIFwiX1wiICsgaSkuaHRtbChhZGRicihzb3VyY2UudGV4dCkpLnJlbW92ZUNsYXNzKCdoaWRkZW4nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJChcIiNzY21fXCIgKyBzaG9ydE5hbWUgKyBcIl9zb3VyY2VfdGV4dF9cIiArIGogKyBcIl9cIiArIGkpLmNsb3Nlc3QoXCIucGFuZWwtYm9keVwiKS5yZW1vdmVDbGFzcygnaGlkZGVuJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJChcIiNzY21fXCIgKyBzaG9ydE5hbWUgKyBcIl9zb3VyY2VfdGV4dF9cIiArIGogKyBcIl9cIiArIGkpLnRleHQoXCJcIikuYWRkQ2xhc3MoJ2hpZGRlbicpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV90ZXh0X1wiICsgaiArIFwiX1wiICsgaSkuY2xvc2VzdChcIi5wYW5lbC1ib2R5XCIpLmFkZENsYXNzKCdoaWRkZW4nKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBVcGRhdGUgdGhlIFVSSSBvZiB0aGUgc291cmNlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzb3VyY2UudXJpICE9PSAndW5kZWZpbmVkJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJChcIiNzY21fXCIgKyBzaG9ydE5hbWUgKyBcIl9zb3VyY2VfdXJpX1wiICsgaiArIFwiX1wiICsgaSkuaHRtbCgnPGEgaHJlZj1cIicrc291cmNlLnVyaSsnXCIgdGFyZ2V0PVwiX2JsYW5rXCI+Jytzb3VyY2UudXJpKyc8L2E+Jyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV91cmlfXCIgKyBqICsgXCJfXCIgKyBpKS5odG1sKCcnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBVcGRhdGUgdGhlIFVSSSBvZiB0aGUgc291cmNlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzb3VyY2UuY2l0YXRpb24gIT09ICd1bmRlZmluZWQnKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV9jaXR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JhcFwiLFxuICAgICAgICAgICAgcGxhY2Vob2xkZXI6IFwiU2VsZWN0IEFmZmlsaWF0aW9uXCJcbiAgICAgICAgfSk7XG4gICAgfSk7XG59XG5cbmZ1bmN0aW9uIHJldmlld2VyX3NlbGVjdF9yZXBsYWNlKHNlbGVjdEl0ZW0pIHtcbiAgICAgICAgaWYoc2VsZWN0SXRlbSAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgc2VsZWN0SXRlbS5zZWxlY3QyKHtcbiAgICAgICAgICAgICAgICAgICAgcGxhY2Vob2xkZXI6IFwiUmV2aWV3ZXIgTmFtZSBvciBFbWFpbC4uLlwiLFxuICAgICAgICAgICAgICAgICAgICBhamF4OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBxdWVyeSA9IHNuYWNVcmwrXCIvdXNlcl9zZWFyY2g/cm9sZT1SZXZpZXdlclwiO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcXVlcnk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVR5cGU6ICdqc29uJyxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGF5OiAyNTAsXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhOiBmdW5jdGlvbiAocGFyYW1zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcTogcGFyYW1zLnRlcm0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhcmFtcy5wYWdlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzUmVzdWx0czogZnVuY3Rpb24gKGRhdGEsIHBhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyByZXN1bHRzOiBkYXRhLnJlc3VsdHMgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBjYWNoZTogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB3aWR0aDogJzEwMCUnLFxuICAgICAgICAgICAgICAgICAgICBtaW5pbXVtSW5wdXRMZW5ndGg6IDEsXG4gICAgICAgICAgICAgICAgICAgIGFsbG93Q2xlYXI6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICB0aGVtZTogJ2Jvb3RzdHJhcCdcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbn1cblxuZnVuY3Rpb24gc2VsZWN0X3JlcGxhY2Uoc2VsZWN0SXRlbSwgaWRNYXRjaCkge1xuICAgICAgICBpZihzZWxlY3RJdGVtLmF0dHIoJ2lkJykuZW5kc1dpdGgoaWRNYXRjaClcbiAgICAgICAgICAgICYmICFzZWxlY3RJdGVtLmF0dHIoJ2lkJykuZW5kc1dpdGgoXCJaWlwiKSkge1xuICAgICAgICAgICAgICAgIHNlbGVjdEl0ZW0uc2VsZWN0Mih7XG4gICAgICAgICAgICAgICAgICAgIGFsbG93Q2xlYXI6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHRoZW1lOiAnYm9vdHN0cmFwJ1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gc2VsZWN0X3JlcGxhY2Vfc2ltcGxlKHNlbGVjdEl0ZW0pIHtcbiAgICBzZWxlY3RJdGVtLnNlbGVjdDIoe1xuICAgICAgICB3aWR0aDogJzEwMCUnLFxuICAgICAgICBhbGxvd0NsZWFyOiB0cnVlLFxuICAgICAgICB0aGVtZTogJ2Jvb3RzdHJhcCdcbiAgICB9KTtcbn1cblxuXG5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7QUFJQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFDQTtBQUNBOzs7Ozs7O0FBT0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUpBO0FBTUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBRkE7QUFJQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBaEJBO0FBa0JBO0FBQ0E7QUFDQTtBQUNBO0FBdkJBO0FBeUJBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFGQTtBQUlBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFIQTtBQUtBO0FBQ0E7QUFHQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7Ozs7Ozs7OztBQVNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFKQTtBQU1BO0FBQ0E7QUFDQTtBQUNBOzs7QUFHQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUVBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///1\n"); + +/***/ }) +/******/ ]))); \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/src/edit_scripts.js b/src/virtualhosts/www/javascript/src/edit_scripts.js new file mode 100644 index 000000000..70d59acf0 --- /dev/null +++ b/src/virtualhosts/www/javascript/src/edit_scripts.js @@ -0,0 +1,2850 @@ +/** + * Edit Scripts + * + * Scripts used in the edit page + * + * @author Robbie Hott + * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause + * @copyright 2015 the Rector and Visitors of the University of Virginia, and + * the Regents of the University of California + */ + +var biogHistEditor = null; + +// Has anything been edited on this page? +export var somethingHasBeenEdited = false; + +export function setEditedFlag(val) { + if (val == true) { + $("#save_and_continue").addClass("save-active"); + } else { + $("#save_and_continue").removeClass("save-active"); + } + somethingHasBeenEdited = val; +} + + +// Global Undo Set +export var undoSet = new Array(); + +export var defaults = { + language: { + id: 130, + term: "eng" + }, + script: { + id: 586, + term: "Latn" + } +}; + + + +/** + * Display Error message + * + * Displays the error message box to the user with the given error message + * + * @param string|object err The error message (string) or error object containing a message and type string + */ +export function displayErrorMessage(err, data) { + var errorMsg = ""; + if (typeof err === 'undefined') + errorMsg = "an unknown problem occurred"; + else if ((typeof err) == "string") + errorMsg = err; + else if (err.message) + errorMsg = err.message; + else if (err.type) + errorMsg = err.type; + else + errorMsg = "an unknown problem occurred"; + + $('#error-message').html("

    Oops

    "+errorMsg+"

    " + +"

    " + +" " + +""+ + "Go to Dashboard" + +"" + +"

    "); + setTimeout(function(){ + $('#error-message').slideDown(); + }, 500); + + // For reference, put the server response in the console + console.log(data); +} + +/** + * Add sub-Date GUI object + * + * Adds a Date GUI object to the Date modal for the given "short" type of data indexed by i + * + * @param string short The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index of the object to add a date object to. + * @returns boolean false to keep the browser from redrawing the page + */ +export function addDateEntry(short, i){ + //next_date_{{short}}_{{i}}_j + var j = parseInt($('#next_date_'+short+'_'+i+'_j').text()); + var id = j + "_" + i; + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#sub_date_template').clone(); + var html = text.html().replace(/ZZ/g, i).replace(/XX/g, j).replace(/SHORT/g, short); + $('#add_date_'+short+'_'+i+'_div').after(html); + $('#next_date_'+short+'_'+i+'_j').text(j + 1); + turnOnButtons(short+"_date"+j, i); + turnOnTooltips(short+"_date_"+j, i); + makeEditable(short + "_date_"+j, i); + return false; +} + +/** + * Add sub-Date GUI object + * + * Adds a Date GUI object to the Date modal for the given "short" type of data indexed by i + * + * @param string short The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index of the object to add a date object to. + * @returns boolean false to keep the browser from redrawing the page + */ +export function addDateRangeEntry(short, i){ + //next_date_{{short}}_{{i}}_j + var j = parseInt($('#next_date_'+short+'_'+i+'_j').text()); + var id = j + "_" + i; + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#sub_dateRange_template').clone(); + var html = text.html().replace(/ZZ/g, i).replace(/XX/g, j).replace(/SHORT/g, short); + $('#add_date_'+short+'_'+i+'_div').after(html); + $('#next_date_'+short+'_'+i+'_j').text(j + 1); + turnOnButtons(short+"_date"+j, i); + turnOnTooltips(short+"_date_"+j, i); + makeEditable(short + "_date_"+j, i); + return false; +} + +/** + * Add SCM GUI object + * + * Adds a GUI SCM object to the SCM modal for the given "short" type of data indexed by i + * + * @param string short The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index of the object to add an SCM object to. + * @returns boolean false to keep the browser from redrawing the page + */ +export function addSCMEntry(short, i){ + //next_scm_{{short}}_{{i}}_j + var j = parseInt($('#next_scm_'+short+'_'+i+'_j').text()); + var id = j + "_" + i; + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#scm_template').clone(); + var html = text.html().replace(/ZZ/g, i).replace(/YY/g, j).replace(/SHORT/g, short); + $('#add_scm_'+short+'_'+i+'_div').after(html); + $('#next_scm_'+short+'_'+i+'_j').text(j + 1); + turnOnSCMButtons(short, i, j); + turnOnTooltips("scm_"+short, id); + makeSCMEditable(short, i, j); + return false; +} + +/** + * Undo Edit + * + * Returns the html for the (short, i) panel back to its original state, i.e. removes + * the edit. Before doing this, to clean up the page, it first makes the edited version + * uneditable. + * + * @param string short The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + */ +function undoEdit(short, i) { + makeUneditable(short, i); + + // restore the old content + $("#" + short + "_datapart_" + i).replaceWith(undoSet[short+"-"+i]); + turnOnTooltips(short,i); + $("#" + short + "_datapart_" + i + " input[type='checkbox']").each(function() { + var obj = $(this); + obj.bootstrapToggle(); + }); +} + +/** + * Undo SCM Edit + * + * Takes an SCM GUI object (j) for a data object (short, i) and returns it back to its + * original state (removing the edit). Before doing this, to clean up the page and JS, it first + * makes the edited version uneditable, then replaces the HTML. + * + * @param string short The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + * @param string|int j The index within the data object SCM list on the edit page of the SCM object. + */ +function undoSCMEdit(short, i, j) { + var id = j + "_" + i; + makeSCMUneditable(short, i, j); + + // restore the old content + $("#scm_" + short + "_datapart_" + id).replaceWith(undoSet["scm_"+short+"-"+id]); + turnOnTooltips("scm_"+short, id); +} + +/** + * Change vocabulary input divs to selects + * + * Changes all div's with id "select_" for a given data object (shortName, idStr) from a list of + * inputs defining the parameters to a select (view mode) to a select box (edit mode). It then + * calls the select2 function to replace the select with an AJAX-compatible select. + * + * This function handles VOCABULARY select boxes ONLY. + * + * Note: idStr must not have the "_" pre-appended + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int idStr The index within the edit page of the object. + */ +function textToSelect(shortName, idStr) { + $("#"+shortName+"_datapart_" + idStr + " div[id^='select_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace("select_", "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + var id = $("#"+shortName+"_"+name+"_id_"+idStr).val(); + var term = $("#"+shortName+"_"+name+"_term_"+idStr).val(); + var vocabtype = $("#"+shortName+"_"+name+"_vocabtype_"+idStr).val(); + var minlength = $("#"+shortName+"_"+name+"_minlength_"+idStr).val(); + var placeholder = "Select"; + if ($("#"+shortName+"_"+name+"_placeholder_"+idStr).exists()) { + placeholder = $("#"+shortName+"_"+name+"_placeholder_"+idStr).val(); + } + var options = ""; + if ($("#"+shortName+"_"+name+"_defaultOptions_"+idStr).exists()) { + options = $("#"+shortName+"_"+name+"_defaultOptions_"+idStr).val(); + } + + cont.html(""+ + "" + + ""); + + if (name == "citation") + scm_source_select_replace($("#"+shortName+"_"+name+"_id_"+idStr), "_"+idStr); + else + vocab_select_replace($("#"+shortName+"_"+name+"_id_"+idStr), "_"+idStr, vocabtype, minlength); + + } + }); +} + +function textToCheckbox(shortName, idStr) { + $("#"+shortName+"_datapart_" + idStr + " div[id^='checkbox_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace(/^checkbox_/, "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + var value = $("#"+shortName+"_"+name+"_"+idStr).val(); + var placeholderOn = ""; + if ($("#"+shortName+"_"+name+"_placeholderOn_"+idStr).exists()) { + placeholderOn = $("#"+shortName+"_"+name+"_placeholderOn_"+idStr).val(); + } + var placeholderOff = ""; + if ($("#"+shortName+"_"+name+"_placeholderOff_"+idStr).exists()) { + placeholderOff = $("#"+shortName+"_"+name+"_placeholderOff_"+idStr).val(); + } + + var html = ""; + } + if (placeholderOff != "") { + html += ""; + } + + cont.html(html); + $("#"+shortName+"_"+name+"_"+idStr).bootstrapToggle(); + } + }); + + +} + + +function checkboxToText(shortName, idStr) { + $("#"+shortName+"_datapart_" + idStr + " div[id^='checkbox_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace(/^checkbox_/, "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + var value = $("#"+shortName+"_"+name+"_"+idStr).val(); + var checked = $("#"+shortName+"_"+name+"_"+idStr).prop('checked'); + var placeholderOn = ""; + if ($("#"+shortName+"_"+name+"_placeholderOn_"+idStr).exists()) { + placeholderOn = $("#"+shortName+"_"+name+"_placeholderOn_"+idStr).val(); + } + var placeholderOff = ""; + if ($("#"+shortName+"_"+name+"_placeholderOff_"+idStr).exists()) { + placeholderOff = $("#"+shortName+"_"+name+"_placeholderOff_"+idStr).val(); + } + + + var html = ""; + + html += "

    "; + if (checked) { + if (placeholderOn != "") + html += placeholderOn; + else + html += value; + } else { + if (placeholderOff != "") + html += placeholderOff; + } + html += "

    "; + if (placeholderOn != "") { + html += ""; + } + if (placeholderOff != "") { + html += ""; + } + + $("#"+shortName+"_"+name+"_"+idStr).bootstrapToggle("destroy"); + cont.html(html); + } + }); + + +} + +function textToInput(shortName, idStr) { + $("#"+shortName+"_datapart_" + idStr + " div[id^='text_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace(/^text_/, "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + var value = $("#"+shortName+"_"+name+"_"+idStr).val(); + var size = 0; + var sizeStr = ""; + if ($("#"+shortName+"_"+name+"_size_"+idStr).exists()) { + size = parseInt($("#"+shortName+"_"+name+"_size_"+idStr).val()); + sizeStr = " size='" + size +"' "; + } + var placeholder = ""; + if ($("#"+shortName+"_"+name+"_placeholder_"+idStr).exists()) { + placeholder = $("#"+shortName+"_"+name+"_placeholder_"+idStr).val(); + } + + var onKeyUp = ""; + if ($("#"+shortName+"_"+name+"_onKeyUp_"+idStr).exists()) { + onKeyUp = $("#"+shortName+"_"+name+"_onKeyUp_"+idStr).val(); + } + var onKeyUpStr = ""; + if (onKeyUp != "") { + onKeyUpStr = " onKeyUp='"+onKeyUp+"' "; + } + + var html = ""; + if (size != 0) { + html += ""; + } + if (placeholder != "") { + html += ""; + } + if (onKeyUp != "") { + html += ""; + } + + cont.html(html); + } + }); + + +} + + +function inputToText(shortName, idStr) { + $("#"+shortName+"_datapart_" + idStr + " div[id^='text_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace(/^text_/, "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + var value = $("#"+shortName+"_"+name+"_"+idStr).val(); + var size = 0; + if ($("#"+shortName+"_"+name+"_size_"+idStr).exists()) { + size = parseInt($("#"+shortName+"_"+name+"_size_"+idStr).val()); + } + var placeholder = ""; + if ($("#"+shortName+"_"+name+"_placeholder_"+idStr).exists()) { + placeholder = $("#"+shortName+"_"+name+"_placeholder_"+idStr).val(); + } + var onKeyUp = ""; + if ($("#"+shortName+"_"+name+"_onKeyUp_"+idStr).exists()) { + onKeyUp = $("#"+shortName+"_"+name+"_onKeyUp_"+idStr).val(); + } + + var html = ""; + html += "

    " + value + "

    "; + if (size != 0) { + html += ""; + } + if (placeholder != "") { + html += ""; + } + if (onKeyUp != "") { + html += ""; + } + + cont.html(html); + } + }); + + +} + + + +function textToTextArea(shortName, idStr) { + $("#"+shortName+"_datapart_" + idStr + " div[id^='textarea_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace(/^textarea_/, "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + var value = $("#"+shortName+"_"+name+"_"+idStr).val(); + + var html = ""; + + cont.html(html); + } + }); +} + + +function textAreaToText(shortName, idStr) { + $("#"+shortName+"_datapart_" + idStr + " div[id^='textarea_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace(/^textarea_/, "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + var value = $("#"+shortName+"_"+name+"_"+idStr).val(); + + //var html = ""; + var html = ""; + html += "
    " + value + "
    "; + + cont.html(html); + } + }); +} + +/** + * Change vocabulary selects to divs of inputs + * + * Changes all div's with id "select_" for a given data object (shortName, idStr) from a select + * box (edit mode) to a list of inputs defining the parameters to a select (view mode). + * + * This function handles VOCABULARY select boxes ONLY. + * + * Note: idStr must not have the "_" pre-appended + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int idStr The index within the edit page of the object. + */ +function selectToText(shortName, idStr) { + $("div[id^='select_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace("select_", "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + var id = $("#"+shortName+"_"+name+"_id_"+idStr).val(); + var term = $("#"+shortName+"_"+name+"_id_"+idStr+ " option:selected").text(); + var vocabtype = $("#"+shortName+"_"+name+"_vocabtype_"+idStr).val(); + var minlength = $("#"+shortName+"_"+name+"_minlength_"+idStr).val(); + + var additionalStyle = ""; + var postText = ""; + if (vocabtype == "name_component") { + additionalStyle = "name-component-type"; + postText = " :"; + } + + cont.html("" + + "" + + "" + + "" + + "

    "+term+postText+"

    "); + + } + }); +} + + +var geoPlaceLoadResults = null; + +function textToGeoPlaceSelect(shortName, idStr) { + $("#"+shortName+"_datapart_" + idStr + " div[id^='selectGeo_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace("selectGeo_", "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + var id = $("#"+shortName+"_"+name+"_id_"+idStr).val(); + var term = $("#"+shortName+"_"+name+"_term_"+idStr).val(); + var placeholder = "Select Geo Place Term"; + + var confirmed = $("#"+shortName+"_confirmed_" + idStr).val() == "true" ? true : false; + var firstOptionSelect = ""; + var secondOptionSelect = " selected"; + if (!confirmed) { + firstOptionSelect = " selected"; + secondOptionSelect = ""; + } + + cont.html(""); + + geovocab_select_replace($("#"+shortName+"_"+name+"_id_"+idStr), "_"+idStr); + + } + }); +} + +function geoPlaceSelectToText(shortName, idStr) { + $("div[id^='selectGeo_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace("selectGeo_", "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + var id = $("#"+shortName+"_"+name+"_id_"+idStr).val(); + var term = $("#"+shortName+"_"+name+"_id_"+idStr+ " option:selected").text(); + + cont.html("" + + ""); + + } + }); +} + +/** + * Make a data object editable + * + * Make the GUI pane for a given constellation object (short, i) editable. Sets up the edit and delete + * buttons for first-order data objects. + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + * @return boolean False to play nice with the browser + */ +export function makeEditable(short, i) { + // No editing if it's already in edit mode + if ($("#" + short + "_operation_" + i).val() == "update") + return false; + // If it's deleted, then you better undelete it first + if ($("#" + short + "_operation_" + i).val() == "delete") + setDeleted(short, i); + + $("#" + short + "_editbutton_" + i).removeClass("list-group-item-info").addClass("list-group-item-warning"); + $("#" + short + "_editbutton_" + i).html("
    Undo"); + $("#" + short + "_editbutton_" + i).off('click').on("click", function() { + undoEdit(short, i); + }); + $("#" + short + "_deletebutton_" + i).removeClass("list-group-item-danger").addClass("disabled"); + $("#" + short + "_deletebutton_" + i).off('click').on("click", function() { + return false; + }); + + $("#" + short + "_panel_" + i).removeClass("panel-default").addClass("alert-info").addClass("edited-component"); + + return subMakeEditable(short, i); +} + +/** + * Make a data object editable + * + * Make the GUI pane for a given constellation object (short, i) editable. Handles removing the read-only + * statuses and changing divs into selects. + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + * @return boolean False to play nice with the browser + */ +function subMakeEditable(short, i) { + // No editing if it's already in edit mode + if ($("#" + short + "_operation_" + i).val() == "update") + return false; + + // Add to the undo set + undoSet[short + "-" + i] = $("#"+short+"_datapart_" + i).clone(); + + + textToInput(short, i); + textToTextArea(short, i); + textToCheckbox(short, i); + + var idstr = "_" + i; + + // Enable buttons + $("#"+short+"_datapart_" + i + " button[id^='"+short+"_']").each(function() { + var obj = $(this); + if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { + obj.removeAttr("disabled").removeClass("snac-hidden"); + } + }); + // Enable buttons + $("#"+short+"_datapart_" + i + " a.label").each(function() { + $(this).removeClass("snac-hidden"); + }); + + // Enable checkboxes + $("#"+short+"_datapart_" + i + " input[type='checkbox']").each(function() { + var obj = $(this); + if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { + obj.bootstrapToggle('enable'); + } + }); + + // Turn on CodeMirror Editors + $("#"+short+"_datapart_" + i + " textarea[id^='"+short+"_']").each(function() { + var obj = $(this); + if(obj.attr('id').endsWith(idstr) + && !obj.attr('id').endsWith("ZZ")) { + // remove the short name from the string we're parsing + var idStr = obj.attr('id').replace(short, ""); + if (idStr.indexOf('_text_') != -1 || idStr.indexOf('_source_') != -1) { + obj.get(0).CodeMirror = CodeMirror.fromTextArea(obj.get(0), { + lineNumbers: true, + lineWrapping: true, + viewportMargin: Infinity, + mode: {name: "xml"} + }); + } + } + }); + var sawSelect = false; + $("#"+short+"_datapart_" + i + " select[id^='"+short+"_']").each(function() { + var obj = $(this); + if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { + sawSelect = true; + } + }); + + if (!sawSelect) { + textToSelect(short, i); + textToGeoPlaceSelect(short, i); + textToDate(short, i); + } + + // Make things re-orderable if something exists + // $( "#nameEntry_component_ui_0" ).sortable({ // id of the container containing sortable things + // items : '.name_component' // class of the things that are sortable. They MUST have ids + // }); + $("#"+short+"_datapart_" + i + " span.move-handle").each(function() { + $(this).removeClass("snac-hidden"); + }); + $( "#"+short+"_reorderable_"+i ).sortable({ + items : '.reorderable', + opacity : 0.5, + update : function( event, ui ) { + var neworder = $( "#"+short+"_reorderable_"+i ).sortable("toArray"); + console.log(neworder); + neworder.forEach(function(orderedID, index) { + $("#"+orderedID + " input.order-index").val(index); + }); + if (short == "nameEntry") + updateNameEntryHeading(i); + } + }); + + // Make the relation pictures update appropriately + if (short == 'constellationRelation') { + // make the role dropdown affect the picture + $('#'+short+'_type_id_'+i).change(function() { + updatePictureArrow(short, i, + $('#'+short+'_type_id_'+i+' option:selected').text()); + }); + + } + if (short == 'resourceRelation') { + // make the role dropdown affect the picture + $('#'+short+'_role_id_'+i).change(function() { + updatePictureArrow(short, i, + $('#'+short+'_role_id_'+i+' option:selected').text()); + }); + } + // Places should update the place heading + if (short == 'place') { + // If there is a value pre-set, then automatically confirm and update + if ($('#'+short+'_geoplace_id_'+i).val() != null && $('#'+short+'_geoplace_id_'+i).val() != "") { + updatePlaceHeading(short, i, $('#'+short+'_geoplace_id_'+i).val()); + } + // make the role dropdown affect the picture + $('#'+short+'_geoplace_id_'+i).change(function() { + updatePlaceHeading(short, i, + $('#'+short+'_geoplace_id_'+i).val()); + }); + } + + // add parser btn if nameEntry is a computed name, entity is person, and if no btn or extra name components already exist + if (short === 'nameEntry' && ($("#entityType").val() === "700") && + ($("#nameEntry_component_0_panel_" + i).find('select:first').text() === "Name") && + (!$("#nameEntry_panel_" + i).find('.name-parser').length && + $("#nameEntry_component_1_panel_" + i).length === 0)) { + $('#nameEntry_component_add_' + i).after(''); + } + + // Set this data's operation value appropriately + if ($("#" + short + "_id_" + i).val() != "") + $("#" + short + "_operation_" + i).val("update"); + else + $("#" + short + "_operation_" + i).val("insert"); + + // Asked to edit something, so make it globally known + setEditedFlag(true); + //somethingHasBeenEdited = true; + + return false; +} + +/** + * Make a data object uneditable + * + * Make each object in the GUI page for the given piece uneditable by turning them back to text. Also + * takes the color away from the pane and removes the operation flag. + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + * @return boolean False to play nice with the browser + */ +function subMakeUneditable(shortName, i) { + + // Make inputs read-only + var idstr = "_" + i; + + + // Turn off the reordering js + $("#"+shortName+"_datapart_" + i + " span.move-handle").each(function() { + $(this).addClass("snac-hidden"); + }); + if ($( "#"+shortName+"_reorderable_"+i ).hasClass("ui-sortable")) + $( "#"+shortName+"_reorderable_"+i ).sortable("destroy"); + + // Remove CodeMirror editors + $("#"+shortName+"_datapart_" + i + " textarea[id^='"+shortName+"_']").each(function() { + var obj = $(this); + if(obj.attr('id').endsWith(idstr) + && !obj.attr('id').endsWith("ZZ") + && (obj.attr('id').indexOf('_text_') != -1 || obj.attr('id').indexOf('_source_') != -1)) { + + if (obj.get(0).CodeMirror) { + obj.get(0).CodeMirror.toTextArea(); + } + //(document.getElementById(obj.attr('id'))).CodeMirror.toTextArea(); + //obj.get(0).CodeMirror.toTextArea(); + } + }); + // Disable buttons + $("#"+shortName+"_datapart_" + i + " button[id^='"+shortName+"_']").each(function() { + var obj = $(this); + if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { + obj.attr("disabled", "true").addClass("snac-hidden"); + } + }); + + // Disable buttons + $("#"+shortName+"_datapart_" + i + " a.label").each(function() { + $(this).addClass("snac-hidden"); + }); + + // Disable checkboxes + $("#"+shortName+"_datapart_" + i + " input[type='checkbox']").each(function() { + var obj = $(this); + if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { + obj.bootstrapToggle("disable"); + } + }); + + inputToText(shortName, i); + textAreaToText(shortName, i); + checkboxToText(shortName, i); + // Check for a select box + var sawSelect = false; + $("#"+shortName+"_datapart_" + i + " select[id^='"+shortName+"_']").each(function() { + var obj = $(this); + if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith("ZZ")) { + sawSelect = true; + } + }); + // If a select box was seen, undo it + if (sawSelect) { + selectToText(shortName, i); + geoPlaceSelectToText(shortName, i); + dateToText(shortName,i); + } + + + // Clear the operation flags + //$("#" + shortName + "_operation_" + i).val(""); + $("#"+shortName+"_datapart_" + i + " input[id^='"+shortName+"_']").each(function() { + var obj = $(this); + if(obj.attr('id').endsWith("_operation" + idstr) && !obj.attr('id').endsWith("ZZ")) { + obj.val(""); + } + }); + + $("#" + shortName + "_panel_" + i).addClass("panel-default").removeClass("alert-info").removeClass("edited-component"); + + + +} + +/** + * Make a data object uneditable + * + * Make the GUI pane for a given constellation object (short, i) un-editable. Sets up the edit and delete + * buttons for first-order data objects, and calls the function to turn the elements back to text. + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + * @return boolean False to play nice with the browser + */ +export function makeUneditable(shortName, i) { + // Make inputs read-only + var idstr = "_" + i; + + subMakeUneditable(shortName, i); + + // restore the edit button + $("#" + shortName + "_editbutton_" + i).addClass("list-group-item-info").removeClass("list-group-item-warning"); + $("#" + shortName + "_editbutton_" + i).html("
    Edit"); + $("#" + shortName + "_editbutton_" + i).off('click').on("click", function() { + makeEditable(shortName, i); + }); + + // restore the delete button + $("#" + shortName + "_deletebutton_" + i).addClass("list-group-item-danger").removeClass("disabled"); + $("#" + shortName + "_deletebutton_" + i).off('click').on("click", function() { + setDeleted(shortName, i); + }); + + return false; +} + +/** + * Make an SCM data object editable + * + * Make the GUI pane for an SCM (j) of a given constellation object (short, i) editable. Sets up the edit and delete + * buttons for first-order data objects. + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + * @param string|int j The index within the data object SCM list on the edit page of the SCM object. + * @return boolean False to play nice with the browser + */ +function makeSCMEditable(shortName, i, j) { + var id = j + "_" + i; + var scmShortName = "scm_" + shortName; + + // No editing if it's already in edit mode + if ($("#" + scmShortName + "_operation_" + id).val() == "update") + return false; + // If it's deleted, then you better undelete it first + if ($("#" + scmShortName + "_operation_" + id).val() == "delete") + setSCMDeleted(shortName, i, j); + + $("#" + scmShortName + "_editbutton_" + id).removeClass("list-group-item-info").addClass("list-group-item-warning"); + $("#" + scmShortName + "_editbutton_" + id).html(""); + $("#" + scmShortName + "_editbutton_" + id).off('click').on("click", function() { + undoSCMEdit(shortName, i, j); + }); + $("#" + scmShortName + "_deletebutton_" + id).removeClass("list-group-item-danger").addClass("disabled"); + $("#" + scmShortName + "_deletebutton_" + id).off('click').on("click", function() { + return false; + }); + + $("#" + scmShortName + "_panel_" + id).removeClass("panel-default").addClass("alert-info").addClass("edited-component"); + + return subMakeEditable(scmShortName, id); +} + +/** + * Make an SCM data object un-editable + * + * Make the GUI pane for an SCM object (j) for a given constellation object (short, i) un-editable. Sets up the edit and delete + * buttons for SCM data objects. + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + * @param string|int j The index within the data object SCM list on the edit page of the SCM object. + * @return boolean False to play nice with the browser + */ +export function makeSCMUneditable(shortName, i, j) { + + // Make inputs read-only + var idstr = j + "_" + i; + + subMakeUneditable('scm_'+shortName, idstr); + + // restore the edit button + $("#scm_" + shortName + "_editbutton_" + idstr).addClass("list-group-item-info").removeClass("list-group-item-warning"); + $("#scm_" + shortName + "_editbutton_" + idstr).html(""); + $("#scm_" + shortName + "_editbutton_" + idstr).off('click').on("click", function() { + makeSCMEditable(shortName, i, j); + }); + + // restore the delete button + $("#scm_" + shortName + "_deletebutton_" + idstr).addClass("list-group-item-danger").removeClass("disabled"); + $("#scm_" + shortName + "_deletebutton_" + idstr).off('click').on("click", function() { + setSCMDeleted(shortName, i, j); + }); + + return false; +} + +/** + * Set a Contributor Object as deleted + * + * Sets the contributor object (shortName, i) as deleted or undeleted and makes the appropriate changes. + * + * @param string shortName The short name of the contributor object. + * @param string|int i The index within the edit page of the object. + */ +export function setRepeatedDataDeleted(shortName, i) { + if ($("#" + shortName + "_operation_" + i).val() != "delete") { + $("#" + shortName + "_remove_" + i).removeClass("btn-danger").addClass("btn-warning"); + $("#" + shortName + "_remove_" + i).html(""); + } else { + $("#" + shortName + "_remove_" + i).removeClass("btn-warning").addClass("btn-danger"); + $("#" + shortName + "_remove_" + i).html(""); + } + + return subSetDeleted(shortName, i); +} + +/** + * Set a first-order data object as deleted + * + * Sets a first-order data object (short, i) as deleted or undeleted and makes the appropriate changes throughout the page. + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + */ +function setDeleted(short, i) { + if ($("#" + short + "_operation_" + i).val() != "delete") { + // set deleted + $("#" + short + "_deletebutton_" + i).removeClass("list-group-item-danger").addClass("list-group-item-warning"); + $("#" + short + "_deletebutton_" + i).html("
    Undo"); + + // disable edit button + $("#" + short + "_editbutton_" + i).removeClass("list-group-item-info").addClass("disabled"); + $("#" + short + "_editbutton_" + i).off('click').on("click", function() { + return false; + }); + + // disable the Date button + $("#" + short + "_datebutton_" + i).removeClass("list-group-item-success").addClass("disabled").prop('disabled', true); + + // disable the SCM button + $("#" + short + "_scmbutton_" + i).removeClass("list-group-item-success").addClass("disabled").prop('disabled', true); + + } else { + // set undelete + $("#" + short + "_deletebutton_" + i).removeClass("list-group-item-warning").addClass("list-group-item-danger"); + $("#" + short + "_deletebutton_" + i).html("
    Trash"); + + // restore edit button + $("#" + short + "_editbutton_" + i).addClass("list-group-item-info").removeClass("disabled"); + $("#" + short + "_editbutton_" + i).off('click').on("click", function() { + makeEditable(short, i); + }); + + // restore the Date button + $("#" + short + "_datebutton_" + i).addClass("list-group-item-success").removeClass("disabled").prop('disabled', false); + + // restore the SCM button + $("#" + short + "_scmbutton_" + i).addClass("list-group-item-success").removeClass("disabled").prop('disabled', false); + + } + + return subSetDeleted(short, i); +} + +/** + * Make the delete/undelete happen + * + * Actually performs the changes to the object, affecting the operation and panel color. + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + * @return boolean False to play nice with the browser + */ +function subSetDeleted(short, i) { + if ($("#" + short + "_operation_" + i).val() != "delete") { + // set deleted + $("#" + short + "_panel_" + i).removeClass("panel-default").addClass("alert-danger").addClass("deleted-component"); + + $("#" + short + "_operation_" + i).val("delete"); + } else { + // set undelete + $("#" + short + "_panel_" + i).removeClass("alert-danger").addClass("panel-default").removeClass("deleted-component"); + + // If this thing was deleted but is supposed to be an update, then return it back to update status + var sawSelect = false; + $("select[id^='"+short+"_']").each(function() { + var obj = $(this); + if(obj.attr('id').endsWith("_" + i) && !obj.attr('id').endsWith("ZZ")) { + sawSelect = true; + } + }); + if (sawSelect) { + if ($("#" + short + "_id_" + i).val() != "") + $("#" + short + "_operation_" + i).val("update"); + else + $("#" + short + "_operation_" + i).val("insert"); + } else { + $("#" + short + "_operation_" + i).val(""); + } + + } + + // Asked to delete something, so make it globally known + setEditedFlag(true); + //somethingHasBeenEdited = true; + + return false; +} + +/** + * Set an SCM data object as deleted + * + * Sets an SCM object (j) for a constellation object (short, i) as deleted or undeleted and makes the appropriate changes throughout the page. + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + * @param string|int j The index within the data object SCM list on the edit page of the SCM object. + */ +function setSCMDeleted(short, i, j) { + var id = j + '_' + i; + if ($("#scm_" + short + "_operation_" + id).val() != "delete") { + // set deleted + $("#scm_" + short + "_deletebutton_" + id).removeClass("list-group-item-danger").addClass("list-group-item-warning"); + $("#scm_" + short + "_deletebutton_" + id).html(""); + + // disable edit button + $("#scm_" + short + "_editbutton_" + id).removeClass("list-group-item-info").addClass("disabled"); + $("#scm_" + short + "_editbutton_" + id).off('click').on("click", function() { + return false; + }); + + } else { + // set undelete + $("#scm_" + short + "_deletebutton_" + id).removeClass("list-group-item-warning").addClass("list-group-item-danger"); + $("#scm_" + short + "_deletebutton_" + id).html(""); + + // restore edit button + $("#scm_" + short + "_editbutton_" + id).addClass("list-group-item-info").removeClass("disabled"); + $("#scm_" + short + "_editbutton_" + id).off('click').on("click", function() { + makeSCMEditable(short, i, j); + }); + + } + + return subSetDeleted("scm_"+short, id); +} + +/** + * Turn on the Edit/Delete buttons for an object + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + */ +function turnOnButtons(shortName, i) { + + // Turn on the edit button + $("#"+shortName+"_editbutton_"+i).on("click", function() { + makeEditable(shortName, i); + }); + + // Turn on the delete buttons + $("#"+shortName+"_deletebutton_"+i).on("click", function() { + setDeleted(shortName, i); + }); +} + +function turnOnTooltips(shortName, i) { + // Load tooltips + $(function () { + $('#'+shortName+'_panel_'+ i +' [data-toggle="tooltip"]').tooltip() + }) + + // Load popovers + $(function () { + $('#'+shortName+'_panel_'+ i +' [data-toggle="popover"]').popover({ + trigger: 'hover', + container: 'body' + }) + }) + + +} + +/** + * Turn on the Edit/Delete buttons for an SCM object + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int i The index within the edit page of the object. + * @param string|int j The index within the data object SCM list on the edit page of the SCM object. + */ +function turnOnSCMButtons(shortName, i, j) { + + // Turn on the edit button + $("#scm_"+shortName+"_editbutton_"+j+"_"+i).on("click", function() { + makeSCMEditable(shortName, i, j); + }); + + // Turn on the delete buttons + $("#scm_"+shortName+"_deletebutton_"+j+"_"+i).on("click", function() { + setSCMDeleted(shortName, i, j); + }); +} + +/** + * Create a new Address Line object on page + * + * Puts a new Place Address Line object DIV on the page and attaches it correctly to the DOM and javascript. + * + * @param int i The index on the page of the place to add this component to + * @return boolean false to play nice with the browser. + */ +export function newAddressLine(i) { + var nextid = 1; + if ($('#place_address_next_j_'+i).exists()) { + nextid = parseInt($('#place_address_next_j_'+i).text()); + } + console.log("Creating new address line for place " + i + " with id: " + nextid); + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#addressline_template').clone(); + var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid); + $('#place_address_add_div_'+i).before(html); + + $('#place_address_' + nextid + '_operation_' + 1).val("insert"); + subMakeEditable("place_address_" + nextid, i); + + vocab_select_replace($("#place_address_"+nextid+"_type_id_"+i), "_"+i, 'address_part', 0); + + // Put the updated version number back in the DOM + $('#place_address_next_j_'+i).text(++nextid); + + return false; +} + +/** + * Create a new Resource Relation Origination Name object on page + * + * Puts a new Resource Relation Origination Name object DIV on the page and attaches it correctly to the DOM and javascript. + * + * @param int i The index on the page of the Resource Relation to add this Origination Name to + * @return boolean false to play nice with the browser. + */ +function newOriginationName(i) { + var nextid = 1; + if ($('#resource_originationName_next_j_'+i).exists()) { + nextid = parseInt($('#resource_originationName_next_j_'+i).text()); + } + console.log("Creating new origination name for resource " + i + " with id: " + nextid); + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#originationName_template').clone(); + var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid); + $('#resource_originationName_add_div_'+i).before(html); + + $('#resource_originationName_' + nextid + '_operation_' + 1).val("insert"); + subMakeEditable("resource_originationName_" + nextid, i); + + // Put the updated version number back in the DOM + $('#resource_originationName_next_j_'+i).text(++nextid); + + return false; +} + + +/** + * Create a new Name Entry Component object on page + * + * Puts a new Name Entry component object DIV on the page and attaches it correctly to the DOM and javascript. + * + * @param int i The index on the page of the nameEntry to add this component to + * @return boolean false to play nice with the browser. + */ +export function newNameEntryComponent(i) { + removeParserButton(i); + var nextid = 1; + if ($('#nameEntry_component_next_j_'+i).exists()) { + nextid = parseInt($('#nameEntry_component_next_j_'+i).text()); + } + console.log("Creating new name entry component for nameEntry " + i + " with id: " + nextid); + + // add parser btn if entity is person, and if no btn or other name components already exist + if (($("#entityType").val() === "700") && (nextid == 0) && + (!$("#nameEntry_panel_" + i).find('.name-parser').length && + $("#nameEntry_component_1_panel_" + i).length === 0)) { + $('#nameEntry_component_add_' + i).after(''); + } + + setEditedFlag(true); + //somethingHasBeenEdited = true; + + var text = $('#component_template').clone(); + var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid); + $('#nameEntry_component_add_div_'+i).before(html); + + $('#nameEntry_component_' + nextid + '_operation_' + 1).val("insert"); + subMakeEditable("nameEntry_component_" + nextid, i); + + vocab_select_replace($("#nameEntry_component_"+nextid+"_type_id_"+i), "_"+i, 'name_component', 0); + + // Put the updated version number back in the DOM + $('#nameEntry_component_next_j_'+i).text(++nextid); + + return false; +} + +export function updateNameEntryHeading(i) { + var text = ""; + var components = []; + + $("#nameEntry_panel_"+i+" div[id^='nameEntry_component_']").each(function() { + var obj = $(this); + if (!obj.hasClass("deleted-component") && obj.attr('id').endsWith("_panel_" + i) + && !obj.attr('id').endsWith("ZZ")) { + var j = obj.attr('id').replace("nameEntry_component_", "").replace("_panel_"+i, ""); + var type = $("#nameEntry_component_"+j+"_type_id_"+i+" option:selected").text(); + var partText = $("#nameEntry_component_"+j+"_text_"+i).val(); + + components.push([type, partText]); + } + }); + + var entityType = $("#entityType option:selected").text(); + text = combineNameHeading(components, entityType); + + + $("#nameEntry_heading_"+i).text(text.trim()); + $("#nameEntry_original_"+i).val(text.trim()); +} + + +/** + * Create a new Name Entry Rules object on page + * + * Puts a new Name Entry rule object DIV on the page and attaches it correctly to the DOM and javascript. + * + * @param int i The index on the page of the nameEntry to add this rule to + * @return boolean false to play nice with the browser. + */ +export function newNameEntryRule(i) { + var nextid = 1; + if ($('#nameEntry_rule_next_j_'+i).exists()) { + nextid = parseInt($('#nameEntry_rule_next_j_'+i).text()); + } + console.log("Creating new name entry rule for nameEntry " + i + " with id: " + nextid); + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#rule_template').clone(); + var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid); + $('#nameEntry_rule_add_div_'+i).before(html); + + $('#nameEntry_rule_' + nextid + '_operation_' + 1).val("insert"); + turnOnTooltips("nameEntry_rule_" + nextid, i); + subMakeEditable("nameEntry_rule_" + nextid, i); + + // Put the updated version number back in the DOM + $('#nameEntry_rule_next_j_'+i).text(++nextid); + + return false; +} + +/** + * Parse a date string into parts + */ +function parseDate(dateString) { + var pieces = dateString.split("-"); + if (pieces.length == 3) + return { + year : parseInt(pieces[0]), + month : parseInt(pieces[1]), + day : parseInt(pieces[2]) + }; + else if (pieces.length == 2) + return { + year : parseInt(pieces[0]), + month : parseInt(pieces[1]), + day : '' + }; + else if (pieces.length == 1 && pieces[0] != '') + return { + year : parseInt(pieces[0]), + month : '', + day : '' + }; + else return { + year : '', month : '', day : '' + } +} + +/** + * Change date input divs to select and boxes + * + * Changes all div's with id "date_" for a given data object (shortName, idStr) from a list of + * inputs defining the parameters (view mode) to a inputs and a select (edit mode). It then + * calls the select2 function to replace the select with one matching the rest of the page. + * + * Note: idStr must not have the "_" pre-appended + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int idStr The index within the edit page of the object. + */ +function textToDate(shortName, idStr) { + $("div[id^='date_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace("date_", "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + var dateStr = $("#"+shortName+"_"+name+"_"+idStr).val(); + + var dateParts = parseDate(dateStr); + + var html = ""; + html += " - "; + html += " "; + html += " - "; + html += " "; + html += ""; + cont.html(html); + + $("#"+shortName+"_"+name+"_month_"+idStr).select2({ + width: '57%', + allowClear: true, + theme: 'bootstrap', + placeholder: 'Month' + }); + + } + }); +} + +/** + * Pad an integer + * + * This is a helper function to pad an integer with 0s for display. This is useful to pad + * a month or day with a leading 0. + * + * @param int|string num The number to pad + * @param int size The total width of the desired output + * @return string A string containing a size-wide integer representation, 0-padded + */ +function pad(num, size) { + var s = num+""; + while (s.length < size) s = "0" + s; + return s; +} + +/** + * Updates the standard date input field + * + * If the date for the data object (shortName, idStr) has been turned into a 3-field edit + * area, then this function will update the hidden standard date (YYYY-MM-DD) field with the + * newest values from the human-enterable field. + * + * Note: idStr must not have the "_" pre-appended + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int idStr The index within the edit page of the object. + */ +export function updateDate(shortName, idStr) { + $("div[id^='date_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace("date_", "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + + if ($("#"+shortName+"_"+name+"_year_"+idStr).exists()) { + var year = $("#"+shortName+"_"+name+"_year_"+idStr).val(); + var day = $("#"+shortName+"_"+name+"_day_"+idStr).val(); + var month = $("#"+shortName+"_"+name+"_month_"+idStr+ " option:selected").val(); + + var dateStr = ""; + if (year != "") { + dateStr += pad(year, 4); + if (month != "") { + dateStr += "-" + pad(month,2); + if (day != "") { + dateStr += "-" + pad(day,2); + } + } + } + + $("#"+shortName+"_"+name+"_"+idStr).val(dateStr); + } + + } + }); +} + +/** + * Return editable date area back to text + * + * If the date for the data object (shortName, idStr) has been turned into a 3-field edit + * area, then this function will return the editable area back to the view mode text, replacing + * the edit boxes with a paragraph containing the computed standard date string (YYYY-MM-DD). + * + * Note: idStr must not have the "_" pre-appended + * + * @param string shortName The short name of the data object, such as "nameEntry" or "occupation" + * @param string|int idStr The index within the edit page of the object. + */ +function dateToText(shortName, idStr) { + $("div[id^='date_"+shortName+"']").each(function() { + var cont = $(this); + if(cont.attr('id').endsWith("_"+idStr) && !cont.attr('id').endsWith("ZZ")) { + // remove the short name and "select_" from the string we're parsing + var divStr = cont.attr('id').replace("date_", "").replace(shortName + "_", ""); + // remove the idstr to receive the name of this element + var regex = new RegExp("\_"+idStr+"$", "g"); + var name = divStr.replace(regex, ""); + + updateDate(shortName, idStr); + + + var dateStr = $("#"+shortName+"_"+name+"_"+idStr).val(); + + var html = "

    "+dateStr+"

    "; + html += ""; + cont.html(html); + + } + }); +} + + +// TODO: If we want to show a DIV of edited and deleted components, we should use the following two functions +// to get copies of the edited/deleted components from the page. We can then insert those copies onto a modal +// dialog box with a "Save" or "Continue" button at the top and bottom. +// +// All the pieces shown in the dialog should be disabled. One way to do this would be using the following +// method to place a semi-transparent div on top of the editable pieces, making them appear to be grayed out +// and with the not permitted cursor. +// +// .append('
    '); +// +// Note: this modal should NOT be inside the constellation form so that we don't submit the values twice. + +/** + * Get all the edited components + */ +function getEdited() { + var html = ""; + + $("#constellation_form div.edited-component").each(function() { + var cont = $(this); + console.log(cont.attr('id')); + var pieces = cont.attr('id').split("_panel_"); + if (pieces.length == 2) { + html += "
    " + $("#"+pieces[0] + "_datapart_" + pieces[1]).html() + "
    "; + } + }); + + return html; +} + +/** + * Get all the deleted components + */ +function getDeleted() { + var html = ""; + + $("#constellation_form div.deleted-component").each(function() { + var cont = $(this); + console.log(cont.attr('id')); + var pieces = cont.attr('id').split("_panel_"); + if (pieces.length == 2) { + html += "
    " + $("#"+pieces[0] + "_datapart_" + pieces[1]).html() + "
    "; + } + }); + + return html; +} + +function turnOnEditDeleteButtons(part='') { + var divID = ''; + if (part != '') + divID = "#" + part + " "; + // Turn on the edit buttons + $(divID + "a[id*='editbutton']").each(function() { + var obj = $(this); + var pieces = obj.attr('id').split("_"); + + if (pieces.length == 3) { + var short = pieces[0]; + var i = pieces[2]; + obj.on("click", function() { + makeEditable(short, i); + }); + } else if (pieces.length == 5 && pieces[0] == "scm") { + var short = pieces[1]; + var i = pieces[4]; + var j = pieces[3]; + obj.on("click", function() { + makeSCMEditable(short, i, j); + }); + } else if (pieces.length == 5) { + var short = pieces[0] + "_" + pieces[1] + "_" + pieces[2]; + var i = pieces[4]; + obj.on("click", function() { + makeEditable(short, i); + }); + } + }); + + // Turn on the delete buttons + $(divID + "a[id*='deletebutton']").each(function() { + var obj = $(this); + var pieces = obj.attr('id').split("_"); + + if (pieces.length == 3) { + var short = pieces[0]; + var i = pieces[2]; + obj.on("click", function() { + setDeleted(short, i); + }); + } else if (pieces.length == 5 && pieces[0] == "scm") { + var short = pieces[1]; + var i = pieces[4]; + var j = pieces[3]; + obj.on("click", function() { + setSCMDeleted(short, i, j); + }); + } else if (pieces.length == 5) { + var short = pieces[0] + "_" + pieces[1] + "_" + pieces[2]; + var i = pieces[4]; + obj.on("click", function() { + setDeleted(short, i); + }); + } + }); +} + +function turnOnTooltipsForTab(part='') { + var divID = ''; + if (part != '') + divID = "#" + part + " "; + // Load tooltips + $(function () { + $(divID + '[data-toggle="tooltip"]').tooltip() + }) + + // Load popovers + $(function () { + $(divID + '[data-toggle="popover"]').popover({ + trigger: 'hover', + container: 'body' + }) + }) + +} + +function updatePictureArrow(shortName, i, newValue) { + $('#'+shortName+'_relationPictureArrow_'+i).text(newValue); +} + +function updatePictureTitle(shortName, i, newValue) { + $('#'+shortName+'_relationPictureTitle_'+i).text(newValue); +} + +function updatePictureIcon(shortName, i, entityType) { + var html = ""; + if (entityType == 'person') + html = '
    '; + else if (entityType == 'corporateBody') + html = '
    '; + else if (entityType == 'family') + html = '
    '; + $('#'+shortName+'_relationPictureIcon_'+i).html(html); +} + + +var geoPlaceLoadResults = null; + +function loadGeoPlaceResultCache() { + $("input[id^='place_geoplace_id_']").each(function() { + var obj = $(this); + // Query for term by ajax + if (obj.val() != null && obj.val() != "") { + $.get(snacUrl+"/vocabulary/read?type=geoPlace&id="+obj.val(), null, function (data) { + // Check the return value from the ajax. If success, then go to dashboard + if (data.term) { + if (!geoPlaceLoadResults) + geoPlaceLoadResults = new Array(); + geoPlaceLoadResults.push(data.term); + } + }); + } + }); +} + +export function chooseSuggestedGeoPlace(selectID, idStr, value) { + // idStr == id number on the page + var obj = $("#"+selectID); + obj.select2('destroy'); + obj.val(value); + geovocab_select_replace(obj, "_"+idStr); + updatePlaceHeading("place", idStr, value); +} + +function updatePlaceHeading(shortName, i, newValue) { + var place = null; + if (!geoPlaceSearchResults && !geoPlaceLoadResults) { + $('#'+shortName+'_confirmed_'+i).val("false"); + $('#'+shortName+'_geoterm_text_'+i).html("Unconfirmed"); + $('#'+shortName+"_geoterm_maplink_"+i).addClass("disabled"); + $('#'+shortName+"_geoterm_maplink_"+i).prop('onclick',null).off("click"); + if ($('#'+shortName+'_original_'+i).val() != "") + $('#'+shortName+'_geoterm_caption_'+i).text("Recorded as: " + $('#'+shortName+'_original_'+i).val()); + else + $('#'+shortName+'_geoterm_caption_'+i).text(); + return; + } + + if (geoPlaceSearchResults) { + geoPlaceSearchResults.forEach(function(result) { + if (result.id == newValue) + place = result; + }); + } + + if (!place && geoPlaceLoadResults) { + geoPlaceLoadResults.forEach(function(result) { + if (result.id == newValue) + place = result; + }); + } + + if (!place) { + $('#'+shortName+'_confirmed_'+i).val("false"); + $('#'+shortName+"_geoterm_maplink_"+i).addClass("disabled"); + $('#'+shortName+"_geoterm_maplink_"+i).off("click"); + if ($('#'+shortName+'_original_'+i).val() != "") { + $('#'+shortName+'_geoterm_text_'+i).html("Unconfirmed"); + $('#'+shortName+'_geoterm_caption_'+i).text("Recorded as: " + $('#'+shortName+'_original_'+i).val()); + } else { + $('#'+shortName+'_geoterm_text_'+i).text("--"); + $('#'+shortName+'_geoterm_caption_'+i).text("GeoPlace term not specified"); + } + return; + } + $('#'+shortName+'_confirmed_'+i).val("true"); + $('#'+shortName+'_geoterm_text_'+i).text(place.name); + $('#'+shortName+'_geoterm_caption_'+i).text(place.administrationCode + ", " + place.countryCode); + if (place.latitude && place.longitude) { + $('#'+shortName+"_geoterm_maplink_"+i).prop('onclick',null).off("click"); + $('#'+shortName+"_geoterm_maplink_"+i).on("click", function() {openGeoPlaceViewer(place.id); return false;}); + $('#'+shortName+"_geoterm_maplink_"+i).removeClass("disabled"); + } else { + $('#'+shortName+"_geoterm_maplink_"+i).addClass("disabled"); + $('#'+shortName+"_geoterm_maplink_"+i).prop('onclick',null).off("click"); + } + + +} + +export function magicDefaultFill(selectID, vocabType) { + if (typeof(defaults[vocabType]) !== undefined) { + + var data = { + id: defaults[vocabType].id, + text: defaults[vocabType].term + }; + + // If the selected item exists, then select it. Else, add a new option + // and select it. + if ($('#'+selectID).find("option[value='" + data.id + "']").length) { + $('#'+selectID).val(data.id).trigger('change'); + } else { + var newOption = new Option(data.text, data.id, false, true); + $('#'+selectID).append(newOption).trigger('change'); + } + } + +} + +function capitalize(word) { + return word[0].toUpperCase() + word.slice(1); +} + +function parseName(e) { + $('#name-parser-options').text(''); + var $nameComponents = $(e.target).closest('.name-components'); + + var $partType = $nameComponents.find("select:last"); + var $textbox = $nameComponents.find('input[type="text"]:last'); + + var name = $textbox.val(); + + var entityType = $('#entityType').text().trim(); + $('#name-parser-type').text(capitalize(entityType)); + $('#name-parser-original').text(name); + + var parser = new NameParser(); + var guesses = parser.guessPerson(name); + + var parsedOption = ''; + + var counter = 0; + guesses.forEach(function(guess) { + // attach name data object to radio + for (var key in guess) { + if (guess[key] && guess[key].length != 0) { + parsedOption += "
  • " + key + ": " + guess[key] + "
  • "; + } + } + + $('#name-parser-options').append("
    " + + "
    "); + + + $('#name-parser-options').find("input[type='radio']:last").data("parsed-name", guess); + + parsedOption = ''; + counter++; + }) + + $('#name-parser-options').find("input[type='radio']:first").prop('checked', true) + + + $('#parser-accept-btn').unbind('click') + $('#parser-accept-btn').on('click', function() { + var selectedName = $('#name-parser input[type="radio"]:checked').data('parsed-name') + $.get( snacUrl + "/vocabulary/?type=name_component&entity_type=700") + .done(function(data) { + acceptParsedName(selectedName, $nameComponents, name, data.results) + }) + }) +} + +function acceptParsedName(selectedName, $nameComponents, name, nameComponentIDs) { + var i = $nameComponents.attr('id').split('_')[2]; + var $nameComponent = $nameComponents.find('.reorderable'); /// + $nameComponent.replaceWith('
    Name: ' + name + '
    '); + + var nameComponentMap = {}; + + for (var k = 0; k < nameComponentIDs.length; k++) { + nameComponentMap[nameComponentIDs[k].text] = nameComponentIDs[k].id + } + // var nameComponentMap = { + // 'Surname': 400223, + // 'Forename': 400224, + // 'NameAddition': 400236, + // 'Date': 400237, + // 'NameExpansion': 400226, + // 'Numeration': 400225 + // }; + + for (var key in selectedName) { + if (key == 'NameAdditions') { + key = 'NameAddition'; + for (var j = 0; j < selectedName['NameAdditions'].length; j++) { + newNameEntryComponent(i); + var option = new Option(key, nameComponentMap[key], false, true); + $partType = $nameComponents.find("select:last"); + $partType.append(option).trigger('change'); + $textbox = $nameComponents.find("input[type='text']:last"); + $textbox.val(selectedName["NameAdditions"][j]); + + $partType.append(option).trigger('change'); + } + } else if (selectedName[key] && nameComponentMap[key]) { + newNameEntryComponent(i); + var option = new Option(key, nameComponentMap[key], false, true); + $partType = $nameComponents.find("select:last"); + $partType.append(option).trigger('change'); + $textbox = $nameComponents.find("input[type='text']:last"); + $textbox.val(selectedName[key]); + + $partType.append(option).trigger('change'); + } + } + + $("#nameEntry_datapart_" + i).find(".name-parser").remove(); + updateNameEntryHeading(i); +} + +function removeParserButton(i) { + $('#nameEntry_datapart_' + i).find('.name-parser').remove(); +} + +/** + * Things to do when the page finishes loading + */ +$(document).ready(function() { + // Load the place cache, if needed + loadGeoPlaceResultCache(); + + // listen for name-parsing + $('#nameEntries').on('click', '.name-parser', function(event) { + event.preventDefault(); + parseName(event); + $("#name-parser").modal('toggle'); + }); + + $('#name-parser').on('shown.bs.modal', function () { + $('#parser-accept-btn').focus(); + }) + + // If the constellation is in "insert" mode, then we should automatically set "somethingHasBeenEdited" + // to be true... + if ($('#operation').val() == 'insert') + setEditedFlag(true); + //somethingHasBeenEdited = true; + + turnOnEditDeleteButtons(); + + // Attach functions to the entityType select + if ($('#entityType').exists()) { + $('#entityType').change(function() { + setEditedFlag(true); + //somethingHasBeenEdited = true; + // If there is an ID, then we need to set this to update + // Else, the main-level operation should be and remain insert + if ($('#constellationid').val() != null && + $('#constellationid').val() != "") { + $('#operation').val("update"); + } + }); + } + + // Name Entry doesn't get any AJAX, since it is pre-loaded + var nameEntryid = 1; + if ($('#next_nameEntry_i').exists()) { + nameEntryid = parseInt($('#next_nameEntry_i').text()); + } + console.log("Next NameEntry ID: " + nameEntryid); + if ($('#btn_add_nameEntry').exists()){ + $('#btn_add_nameEntry').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#nameEntry_template').clone(); + var html = text.html().replace(/ZZ/g, nameEntryid); + $('#add_nameEntry_div').after(html); + turnOnButtons("nameEntry", nameEntryid); + turnOnTooltips("nameEntry", nameEntryid); + makeEditable("nameEntry", nameEntryid); + nameEntryid = nameEntryid + 1; + return false; + }); + } + + + // Attach functions to each of the "+ Add New _______" buttons + + // Code to handle adding new genders to the page + var genderid = 1; + var genderOpen = false; + if ($('#genderstab').exists()){ + $('#genderstab').click(function(){ + // Don't open a second time + if (genderOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=genders", null, function (data) { + genderOpen = true; + $('#genders').html(data); + + turnOnEditDeleteButtons("genders"); + + if ($('#next_gender_i').exists()) { + genderid = parseInt($('#next_gender_i').text()); + } + console.log("Next Gender ID: " + genderid); + if ($('#btn_add_gender').exists()){ + $('#btn_add_gender').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#gender_template').clone(); + var html = text.html().replace(/ZZ/g, genderid); + $('#add_gender_div').after(html); + turnOnButtons("gender", genderid); + turnOnTooltips("gender", genderid); + makeEditable("gender", genderid); + genderid = genderid + 1; + return false; + }); + } + + turnOnTooltipsForTab("genders"); + }); + }); + } + + // Code to handle adding new genders to the page + var existid = 1; + var existOpen = false; + if ($('#existstab').exists()){ + $('#existstab').click(function(){ + // Don't open a second time + if (existOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=dates", null, function (data) { + existOpen = true; + $('#dates').html(data); + + turnOnEditDeleteButtons("dates"); + + if ($('#next_exist_i').exists()) { + existid = parseInt($('#next_exist_i').text()); + } + console.log("Next Exist Date ID: " + existid); + if ($('#btn_add_exist_date').exists()){ + $('#btn_add_exist_date').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#exist_date_template').clone(); + var html = text.html().replace(/ZZ/g, existid); + $('#add_exist_div').after(html); + turnOnButtons("exist", existid); + turnOnTooltips("exist", existid); + makeEditable("exist", existid); + existid = existid + 1; + return false; + }); + } + if ($('#btn_add_exist_dateRange').exists()){ + $('#btn_add_exist_dateRange').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#exist_dateRange_template').clone(); + var html = text.html().replace(/ZZ/g, existid); + $('#add_exist_div').after(html); + turnOnButtons("exist", existid); + turnOnTooltips("exist", existid); + makeEditable("exist", existid); + existid = existid + 1; + return false; + }); + } + + turnOnTooltipsForTab("dates"); + }); + }); + } + + var sameAsid = 1; + var sameAsOpen = false; + if ($('#sameAstab').exists()){ + $('#sameAstab').click(function(){ + // Don't open a second time + if (sameAsOpen) + return; + //set sameAs vocab type id + $.get(snacUrl+"/vocabulary?type=record_type&q=SameAs", null, function(data) { + sameAsTermId = data.results[0].id; + $("#sameAs_type_id_ZZ").val(sameAsTermId); + }); + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=sameAs", null, function (data) { + sameAsOpen = true; + $('#sameAs').html(data); + + turnOnEditDeleteButtons("sameAs"); + + if ($('#next_sameAs_i').exists()) { + sameAsid = parseInt($('#next_sameAs_i').text()); + } + console.log("Next sameAs ID: " + sameAsid); + if ($('#btn_add_sameAs').exists()){ + $('#btn_add_sameAs').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#sameAs_template').clone(); + var html = text.html().replace(/ZZ/g, sameAsid); + $('#add_sameAs_div').after(html); + turnOnButtons("sameAs", sameAsid); + turnOnTooltips("sameAs", sameAsid); + makeEditable("sameAs", sameAsid); + sameAsid = sameAsid + 1; + return false; + }); + } + + turnOnTooltipsForTab("sameAs"); + }); + }); + } + + + var entityIDid = 1; + var entityIDOpen = false; + if ($('#entityIDtab').exists()){ + $('#entityIDtab').click(function(){ + // Don't open a second time + if (entityIDOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=entityID", null, function (data) { + entityIDOpen = true; + $('#entityID').html(data); + + turnOnEditDeleteButtons("entityID"); + + if ($('#next_entityID_i').exists()) { + entityIDid = parseInt($('#next_entityID_i').text()); + } + console.log("Next entityID ID: " + entityIDid); + if ($('#btn_add_entityID').exists()){ + $('#btn_add_entityID').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#entityID_template').clone(); + var html = text.html().replace(/ZZ/g, entityIDid); + $('#add_entityID_div').after(html); + turnOnButtons("entityID", entityIDid); + turnOnTooltips("entityID", entityIDid); + makeEditable("entityID", entityIDid); + entityIDid = entityIDid + 1; + return false; + }); + } + + turnOnTooltipsForTab("entityID"); + }); + }); + } + + var sourceid = 1; + var sourceOpen = false; + if ($('#sourcestab').exists()){ + $('#sourcestab').click(function(){ + // Don't open a second time + if (sourceOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=sources", null, function (data) { + sourceOpen = true; + $('#sources').html(data); + + turnOnEditDeleteButtons("sources"); + + if ($('#next_source_i').exists()) { + sourceid = parseInt($('#next_source_i').text()); + } + console.log("Next source ID: " + sourceid); + if ($('#btn_add_source').exists()){ + $('#btn_add_source').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#source_template').clone(); + var html = text.html().replace(/ZZ/g, sourceid); + $('#add_source_div').after(html); + turnOnButtons("source", sourceid); + turnOnTooltips("source", sourceid); + makeEditable("source", sourceid); + sourceid = sourceid + 1; + return false; + }); + } + + turnOnTooltipsForTab("sources"); + }); + }); + } + + var resourceRelationid = 1; + var resourceRelationOpen = false; + if ($('#resourceRelationstab').exists()){ + $('#resourceRelationstab').click(function(){ + // Don't open a second time + if (resourceRelationOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=resourceRelations", null, function (data) { + resourceRelationOpen = true; + $('#resourceRelations').html(data); + + turnOnEditDeleteButtons("resourceRelations"); + + if ($('#next_resourceRelation_i').exists()) { + resourceRelationid = parseInt($('#next_resourceRelation_i').text()); + } + console.log("Next resourceRelation ID: " + resourceRelationid); + if ($('#btn_create_resourceRelation').exists()){ + $('#btn_create_resourceRelation').click(function(){ + var rid = $('input[name=resourceChoice]:checked', '#resource_search_form').val(); + if (rid != null && resourceResults != null && rid != 'new') { + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#resourceRelation_template').clone(); + var html = text.html().replace(/ZZ/g, resourceRelationid); + $('#add_resourceRelation_div').after(html); + + if (typeof resourceResults[rid].id !== 'undefined') + $('#resourceRelation_resourceid_'+resourceRelationid).val(resourceResults[rid].id); + if (typeof resourceResults[rid].version !== 'undefined') + $('#resourceRelation_resourceversion_'+resourceRelationid).val(resourceResults[rid].version); + + if (typeof resourceResults[rid].link !== 'undefined') + $('#resourceRelation_linkText_'+resourceRelationid).html(""+resourceResults[rid].link+"" + + " View"); + if (typeof resourceResults[rid].displayEntry !== 'undefined') + $('#resourceRelation_displayEntryText_'+resourceRelationid).text(resourceResults[rid].displayEntry); + if (typeof resourceResults[rid].title !== 'undefined') { + $('#resourceRelation_titleText_'+resourceRelationid).text(resourceResults[rid].title); + updatePictureTitle('resourceRelation', resourceRelationid, resourceResults[rid].title); + } + if (typeof resourceResults[rid].abstract !== 'undefined') + $('#resourceRelation_abstractText_'+resourceRelationid).text(resourceResults[rid].abstract); + if (typeof resourceResults[rid].extent !== 'undefined') + $('#resourceRelation_extentText_'+resourceRelationid).text(resourceResults[rid].extent); + // if (typeof resourceResults[rid].date !== 'undefined') + // $('#resourceRelation_dateText_'+resourceRelationid).text(resourceResults[rid].date); + if (typeof resourceResults[rid].documentType !== 'undefined' && typeof resourceResults[rid].documentType.term !== 'undefined') + $('#resourceRelation_documentTypeText_'+resourceRelationid).text(resourceResults[rid].documentType.term); + + $('#resourceRelation_linkText_'+resourceRelationid).after("View in SNAC"); + turnOnButtons("resourceRelation", resourceRelationid); + turnOnTooltips("resourceRelation", resourceRelationid); + makeEditable("resourceRelation", resourceRelationid); + resourceRelationid = resourceRelationid + 1; + $("#resource-results-box").html(""); + return true; + } + return false; + }); + } + + if ($('#btn_open_create_resource').exists()){ + $('#btn_open_create_resource').click(function(){ + // Close this modal and open the new modal + $("#resourceSearchPane").modal("hide"); + + // Set a 500ms timeout to give the hidden search pane time to fully close + setTimeout(function() {$("#resourceCreatePane").modal("show");}, 500); + + // Grab the empty template and replace + var text = $('#resource_template').clone(); + var html = text.html().replace(/ZZ/g, 0); + $('#resource-create-box').html(html); + var $resourceForm = $("#resource_create_form"); + // Copy the search contents to title or href + if ($("#resource-searchbox").val().indexOf("http") == -1) + $resourceForm.find("#resource-title").val($("#resource-searchbox").val()); + else + $resourceForm.find("#resource-url").val($("#resource-searchbox").val()); + + $resourceForm.find('[data-toggle="popover"]').popover({ + trigger: 'hover', + container: 'body' + }); + loadVocabSelectOptions($resourceForm.find("#resource-type-select"), "document_type", "Resource Type"); + vocab_select_replace($resourceForm.find("#resource-repo"), "", "holding", 3); + $resourceForm.find("#new-resource-language-btn").on("click", newResourceLanguage); + $resourceForm.find("#magic-resource-language-btn").on("click", magicNewResourceLanguage); + + $('#search-results-box').on("click", "a.list-group-item", selectHoldingRepository); + var timeoutID = null; + $resourceForm.find('#searchbox').keyup(function() { + clearTimeout(timeoutID); + timeoutID = setTimeout(function() { setSearchPosition(0); searchAndUpdate(); }, 500); + }); + + // Remove the search results from the other modal + $("#resource-results-box").html(""); + return false; + }); + } + + if ($('#btn_create_resource').exists()){ + $('#resource_create_form').on("submit", function(){ + // Remove leading and trailing whitespace + if ($("#resource_create_form #resource-url").val() == "") { + if (!confirm('Are you sure you want to save without an HREF?')) { + return; + } + } + $("#resource_create_form input, textarea").each(function() { + $(this).val($.trim($(this).val())); + }); + setDeletedResourceLanguageOperations($("#resource_create_form")); + + $.post(snacUrl+"/save_resource", $("#resource_create_form").serialize(), function (data) { + if (typeof data.result !== 'undefined' && data.result !== 'false') { + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#resourceRelation_template').clone(); + var html = text.html().replace(/ZZ/g, resourceRelationid); // clones DOM, replaces zz with next ids + $('#add_resourceRelation_div').after(html); + + if (typeof data.resource.id !== 'undefined') + $('#resourceRelation_resourceid_'+resourceRelationid).val(data.resource.id); + if (typeof data.resource.version !== 'undefined') + $('#resourceRelation_resourceversion_'+resourceRelationid).val(data.resource.version); + + if (typeof data.resource.link !== 'undefined') + $('#resourceRelation_linkText_'+resourceRelationid).html(""+data.resource.link+"" + + " View"); + if (typeof data.resource.displayEntry !== 'undefined') + $('#resourceRelation_displayEntryText_'+resourceRelationid).text(data.resource.displayEntry); + if (typeof data.resource.title !== 'undefined') { + $('#resourceRelation_titleText_'+resourceRelationid).text(data.resource.title); + updatePictureTitle('resourceRelation', resourceRelationid, data.resource.title); + } + if (typeof data.resource.abstract !== 'undefined') + $('#resourceRelation_abstractText_'+resourceRelationid).text(data.resource.abstract); + if (typeof data.resource.extent !== 'undefined') + $('#resourceRelation_extentText_'+resourceRelationid).text(data.resource.extent); + if (typeof data.resource.documentType !== 'undefined' && typeof data.resource.documentType.term !== 'undefined') + $('#resourceRelation_documentTypeText_'+resourceRelationid).text(data.resource.documentType.term); + + $('#resourceRelation_linkText_'+resourceRelationid).after("View in SNAC"); + turnOnButtons("resourceRelation", resourceRelationid); + turnOnTooltips("resourceRelation", resourceRelationid); + makeEditable("resourceRelation", resourceRelationid); + resourceRelationid = resourceRelationid + 1; + $("#resourceCreatePane").modal("hide"); + $('#resource-create-box').html(""); + return true; + } else { + console.log(data); + return false; + } + }); + return false; + }); + } + + turnOnTooltipsForTab("resourceRelations"); + }); + }); + } + + + var constellationRelationid = 1; + var constellationRelationOpen = false; + if ($('#constellationRelationstab').exists()){ + $('#constellationRelationstab').click(function(){ + // Don't open a second time + if (constellationRelationOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=constellationRelations", null, function (data) { + constellationRelationOpen = true; + $('#constellationRelations').html(data); + + turnOnEditDeleteButtons("constellationRelations"); + + if ($('#next_constellationRelation_i').exists()) { + constellationRelationid = parseInt($('#next_constellationRelation_i').text()); + } + console.log("Next constellationRelation ID: " + constellationRelationid); + if ($('#btn_create_constellationRelation').exists()){ + $('#btn_create_constellationRelation').click(function(){ + var cid = $('input[name=relationChoice]:checked', '#relation_search_form').val() + if (cid != null) { + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#constellationRelation_template').clone(); + var html = text.html().replace(/ZZ/g, constellationRelationid); + $('#add_constellationRelation_div').after(html); + $('#constellationRelation_targetID_'+constellationRelationid).val(cid); + $('#constellationRelation_content_'+constellationRelationid).val($('#relationChoice_nameEntry_'+cid).val()); + $('#constellationRelation_targetArkID_'+constellationRelationid).val($('#relationChoice_arkID_'+cid).val()); + $('#constellationRelation_targetEntityType_'+constellationRelationid).val($('#relationChoice_entityType_'+cid).val()); + + updatePictureIcon('constellationRelation', constellationRelationid, $('#relationChoice_entityTypeText_'+cid).val()); + updatePictureTitle('constellationRelation', constellationRelationid, $('#relationChoice_nameEntry_'+cid).val()); + + $('#constellationRelation_contentText_'+constellationRelationid).text($('#relationChoice_nameEntry_'+cid).val()); + $('#constellationRelation_targetArkIDText_'+constellationRelationid).text($('#relationChoice_arkID_'+cid).val()); + + turnOnButtons("constellationRelation", constellationRelationid); + turnOnTooltips("constellationRelation", constellationRelationid); + makeEditable("constellationRelation", constellationRelationid); + + constellationRelationid = constellationRelationid + 1; + + return true; + + } + + + return false; + }); + } + + turnOnTooltipsForTab("constellationRelations"); + }); + }); + } + + var languageid = 1; + var languageOpen = false; + if ($('#languagesUsedtab').exists()){ + $('#languagesUsedtab').click(function(){ + // Don't open a second time + if (languageOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=languagesUsed", null, function (data) { + languageOpen = true; + $('#languagesUsed').html(data); + + turnOnEditDeleteButtons("languagesUsed"); + + if ($('#next_language_i').exists()) { + languageid = parseInt($('#next_language_i').text()); + } + console.log("Next language ID: " + languageid); + if ($('#btn_add_language').exists()){ + $('#btn_add_language').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#language_template').clone(); + var html = text.html().replace(/ZZ/g, languageid); + $('#add_language_div').after(html); + turnOnButtons("language", languageid); + turnOnTooltips("language", languageid); + makeEditable("language", languageid); + languageid = languageid + 1; + return false; + }); + } + + turnOnTooltipsForTab("languagesUsed"); + }); + }); + } + + var subjectid = 1; + var subjectOpen = false; + if ($('#subjectstab').exists()){ + $('#subjectstab').click(function(){ + // Don't open a second time + if (subjectOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=subjects", null, function (data) { + subjectOpen = true; + $('#subjects').html(data); + + turnOnEditDeleteButtons("subjects"); + + if ($('#next_subject_i').exists()) { + subjectid = parseInt($('#next_subject_i').text()); + } + console.log("Next subject ID: " + subjectid); + if ($('#btn_add_subject').exists()){ + $('#btn_add_subject').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#subject_template').clone(); + var html = text.html().replace(/ZZ/g, subjectid); + $('#add_subject_div').after(html); + turnOnButtons("subject", subjectid); + turnOnTooltips("subject", subjectid); + makeEditable("subject", subjectid); + subjectid = subjectid + 1; + return false; + }); + } + + turnOnTooltipsForTab("subjects"); + }); + }); + } + + var nationalityid = 1; + var nationalityOpen = false; + if ($('#nationalitiestab').exists()){ + $('#nationalitiestab').click(function(){ + // Don't open a second time + if (nationalityOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=nationalities", null, function (data) { + nationalityOpen = true; + $('#nationalities').html(data); + + turnOnEditDeleteButtons("nationalities"); + + if ($('#next_nationality_i').exists()) { + nationalityid = parseInt($('#next_nationality_i').text()); + } + console.log("Next nationality ID: " + nationalityid); + if ($('#btn_add_nationality').exists()){ + $('#btn_add_nationality').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#nationality_template').clone(); + var html = text.html().replace(/ZZ/g, nationalityid); + $('#add_nationality_div').after(html); + turnOnButtons("nationality", nationalityid); + turnOnTooltips("nationality", nationalityid); + makeEditable("nationality", nationalityid); + nationalityid = nationalityid + 1; + return false; + }); + } + + turnOnTooltipsForTab("nationalities"); + }); + }); + } + + var functionid = 1; + var functionOpen = false; + if ($('#functionstab').exists()){ + $('#functionstab').click(function(){ + // Don't open a second time + if (functionOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=functions", null, function (data) { + functionOpen = true; + $('#functions').html(data); + + turnOnEditDeleteButtons("functions"); + + if ($('#next_function_i').exists()) { + functionid = parseInt($('#next_function_i').text()); + } + console.log("Next function ID: " + functionid); + if ($('#btn_add_function').exists()){ + $('#btn_add_function').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#function_template').clone(); + var html = text.html().replace(/ZZ/g, functionid); + $('#add_function_div').after(html); + turnOnButtons("function", functionid); + turnOnTooltips("function", functionid); + makeEditable("function", functionid); + functionid = functionid + 1; + return false; + }); + } + + turnOnTooltipsForTab("functions"); + }); + }); + } + + var occupationid = 1; + var occupationOpen = false; + if ($('#occupationstab').exists()){ + $('#occupationstab').click(function(){ + // Don't open a second time + if (occupationOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=occupations", null, function (data) { + occupationOpen = true; + $('#occupations').html(data); + + turnOnEditDeleteButtons("occupations"); + + if ($('#next_occupation_i').exists()) { + occupationid = parseInt($('#next_occupation_i').text()); + } + console.log("Next occupation ID: " + occupationid); + if ($('#btn_add_occupation').exists()){ + $('#btn_add_occupation').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#occupation_template').clone(); + var html = text.html().replace(/ZZ/g, occupationid); + $('#add_occupation_div').after(html); + turnOnButtons("occupation", occupationid); + turnOnTooltips("occupation", occupationid); + makeEditable("occupation", occupationid); + occupationid = occupationid + 1; + return false; + }); + } + + turnOnTooltipsForTab("occupations"); + }); + }); + } + + var legalStatusid = 1; + var legalStatusOpen = false; + if ($('#legalStatusestab').exists()){ + $('#legalStatusestab').click(function(){ + // Don't open a second time + if (legalStatusOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=legalStatuses", null, function (data) { + legalStatusOpen = true; + $('#legalStatuses').html(data); + + turnOnEditDeleteButtons("legalStatuses"); + + if ($('#next_legalStatus_i').exists()) { + legalStatusid = parseInt($('#next_legalStatus_i').text()); + } + console.log("Next legalStatus ID: " + legalStatusid); + if ($('#btn_add_legalStatus').exists()){ + $('#btn_add_legalStatus').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#legalStatus_template').clone(); + var html = text.html().replace(/ZZ/g, legalStatusid); + $('#add_legalStatus_div').after(html); + turnOnButtons("legalStatus", legalStatusid); + turnOnTooltips("legalStatus", legalStatusid); + makeEditable("legalStatus", legalStatusid); + legalStatusid = legalStatusid + 1; + return false; + }); + } + + turnOnTooltipsForTab("legalStatuses"); + }); + }); + } + + var placeid = 1; + var placeOpen = false; + if ($('#placestab').exists()){ + $('#placestab').click(function(){ + // Don't open a second time + if (placeOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=places", null, function (data) { + placeOpen = true; + $('#places').html(data); + + // Load the place cache, if needed + loadGeoPlaceResultCache(); + + turnOnEditDeleteButtons("places"); + + if ($('#next_place_i').exists()) { + placeid = parseInt($('#next_place_i').text()); + } + console.log("Next place ID: " + placeid); + if ($('#btn_add_place').exists()){ + $('#btn_add_place').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#place_template').clone(); + var html = text.html().replace(/ZZ/g, placeid); + $('#add_place_div').after(html); + turnOnButtons("place", placeid); + turnOnTooltips("place", placeid); + makeEditable("place", placeid); + placeid = placeid + 1; + return false; + }); + } + + turnOnTooltipsForTab("places"); + }); + }); + } + + var conventionDeclarationid = 1; + var conventionDeclarationOpen = false; + if ($('#conventionDeclarationstab').exists()){ + $('#conventionDeclarationstab').click(function(){ + // Don't open a second time + if (conventionDeclarationOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=conventionDeclarations", null, function (data) { + conventionDeclarationOpen = true; + $('#conventionDeclarations').html(data); + + turnOnEditDeleteButtons("conventionDeclarations"); + + if ($('#next_conventionDeclaration_i').exists()) { + conventionDeclarationid = parseInt($('#next_conventionDeclaration_i').text()); + } + console.log("Next conventionDeclaration ID: " + conventionDeclarationid); + if ($('#btn_add_conventionDeclaration').exists()){ + $('#btn_add_conventionDeclaration').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#conventionDeclaration_template').clone(); + var html = text.html().replace(/ZZ/g, conventionDeclarationid); + $('#add_conventionDeclaration_div').after(html); + turnOnButtons("conventionDeclaration", conventionDeclarationid); + turnOnTooltips("conventionDeclaration", conventionDeclarationid); + makeEditable("conventionDeclaration", conventionDeclarationid); + conventionDeclarationid = conventionDeclarationid + 1; + return false; + }); + } + + turnOnTooltipsForTab("conventionDeclarations"); + }); + }); + } + + var generalContextid = 1; + var generalContextOpen = false; + if ($('#generalContextstab').exists()){ + $('#generalContextstab').click(function(){ + // Don't open a second time + if (generalContextOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=generalContexts", null, function (data) { + generalContextOpen = true; + $('#generalContexts').html(data); + + turnOnEditDeleteButtons("generalContexts"); + + if ($('#next_generalContext_i').exists()) { + generalContextid = parseInt($('#next_generalContext_i').text()); + } + console.log("Next generalContext ID: " + generalContextid); + if ($('#btn_add_generalContext').exists()){ + $('#btn_add_generalContext').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#generalContext_template').clone(); + var html = text.html().replace(/ZZ/g, generalContextid); + $('#add_generalContext_div').after(html); + turnOnButtons("generalContext", generalContextid); + turnOnTooltips("generalContext", generalContextid); + makeEditable("generalContext", generalContextid); + generalContextid = generalContextid + 1; + return false; + }); + } + + turnOnTooltipsForTab("generalContexts"); + }); + }); + } + + var structureOrGenealogyid = 1; + var structureOrGenealogyOpen = false; + if ($('#structureOrGenealogiestab').exists()){ + $('#structureOrGenealogiestab').click(function(){ + // Don't open a second time + if (structureOrGenealogyOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=structureOrGenealogies", null, function (data) { + structureOrGenealogyOpen = true; + $('#structureOrGenealogies').html(data); + + turnOnEditDeleteButtons("structureOrGenealogies"); + + if ($('#next_structureOrGenealogy_i').exists()) { + structureOrGenealogyid = parseInt($('#next_structureOrGenealogy_i').text()); + } + console.log("Next structureOrGenealogy ID: " + structureOrGenealogyid); + if ($('#btn_add_structureOrGenealogy').exists()){ + $('#btn_add_structureOrGenealogy').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#structureOrGenealogy_template').clone(); + var html = text.html().replace(/ZZ/g, structureOrGenealogyid); + $('#add_structureOrGenealogy_div').after(html); + turnOnButtons("structureOrGenealogy", structureOrGenealogyid); + turnOnTooltips("structureOrGenealogy", structureOrGenealogyid); + makeEditable("structureOrGenealogy", structureOrGenealogyid); + structureOrGenealogyid = structureOrGenealogyid + 1; + return false; + }); + } + + turnOnTooltipsForTab("structureOrGenealogies"); + }); + }); + } + + var mandateid = 1; + var mandateOpen = false; + if ($('#mandatestab').exists()){ + $('#mandatestab').click(function(){ + // Don't open a second time + if (mandateOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=mandates", null, function (data) { + mandateOpen = true; + $('#mandates').html(data); + + turnOnEditDeleteButtons("mandates"); + + if ($('#next_mandate_i').exists()) { + mandateid = parseInt($('#next_mandate_i').text()); + } + console.log("Next mandate ID: " + mandateid); + if ($('#btn_add_mandate').exists()){ + $('#btn_add_mandate').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#mandate_template').clone(); + var html = text.html().replace(/ZZ/g, mandateid); + $('#add_mandate_div').after(html); + turnOnButtons("mandate", mandateid); + turnOnTooltips("mandate", mandateid); + makeEditable("mandate", mandateid); + mandateid = mandateid + 1; + return false; + }); + } + + turnOnTooltipsForTab("mandates"); + }); + }); + } + + var biogHistid = 1; + var biogHistOpen = false; + if ($('#biogHiststab').exists()){ + $('#biogHiststab').click(function(){ + // Don't open a second time + if (biogHistOpen) + return; + + $.get(snacUrl+"/edit_part/"+$('#constellationid').val()+"/"+$('#version').val()+"?part=biogHists", null, function (data) { + biogHistOpen = true; + $('#biogHists').html(data); + + turnOnEditDeleteButtons("biogHists"); + + if ($('#next_biogHist_i').exists()) { + biogHistid = parseInt($('#next_biogHist_i').text()); + } + console.log("Next biogHist ID: " + biogHistid); + if ($('#btn_add_biogHist').exists()){ + $('#btn_add_biogHist').click(function(){ + setEditedFlag(true); + //somethingHasBeenEdited = true; + var text = $('#biogHist_template').clone(); + var html = text.html().replace(/ZZ/g, biogHistid); + $('#add_biogHist_div').after(html); + turnOnButtons("biogHist", biogHistid); + turnOnTooltips("biogHist", biogHistid); + makeEditable("biogHist", biogHistid); + biogHistid = biogHistid + 1; + return false; + }); + } + + turnOnTooltipsForTab("biogHists"); + }); + }); + } + + turnOnTooltipsForTab(); + + + $("#info-dropdown").click(function(e) { + $(this).parent().toggleClass("open"); + e.stopPropagation(); + }); + +}); diff --git a/src/virtualhosts/www/javascript/src/resource_admin.js b/src/virtualhosts/www/javascript/src/resource_admin.js index 27a28e900..7537722d4 100644 --- a/src/virtualhosts/www/javascript/src/resource_admin.js +++ b/src/virtualhosts/www/javascript/src/resource_admin.js @@ -9,7 +9,7 @@ * the Regents of the University of California */ -function saveResource(event) { +export function saveResource(event) { event.preventDefault(); var $form = $(event.target); @@ -47,7 +47,7 @@ function saveResource(event) { } -function setDeletedResourceLanguageOperations($form) { +export function setDeletedResourceLanguageOperations($form) { // Set deleted new languages to null, set deleted existing languages to delete var $deletedLanguages = $form.find("#resource-languages .component-deleted").has('input[id]'); var $ignoredLanguages = $form.find("#resource-languages .component-deleted.new-language"); @@ -55,7 +55,7 @@ function setDeletedResourceLanguageOperations($form) { setOperations($ignoredLanguages, ""); } -function cancelResource() { +export function cancelResource() { if (!confirm('Are you sure you want to cancel?')) { return; } @@ -74,7 +74,7 @@ function cancelResource() { * Tracks language index using $('#language-template').data('languageCount') * */ -function newResourceLanguage(event) { +export function newResourceLanguage(event) { event.preventDefault(); var $newLanguage = $('#resource-language-template').find(".language").clone(); var data = $('#resource-language-template').data(); @@ -105,7 +105,7 @@ function newResourceLanguage(event) { * Does not change operations. * */ -function deleteOrUndoLanguage(event) { +export function deleteOrUndoLanguage(event) { event.preventDefault(); var $btn = $(event.currentTarget); $btn.toggleClass('btn-danger btn-warning'); @@ -128,7 +128,7 @@ function setOperations($elements, operation) { * @param jqueryObject $resourceForm jQuery object to modify * */ -function markEditedResourceFields($resourceForm) { +export function markEditedResourceFields($resourceForm) { $resourceForm.find("input, select, textarea").on("change", function(e) { $(e.target).addClass('edited-field'); @@ -165,13 +165,13 @@ function enableVocabularySelect(selectItem, type) { }); } -function enableLanguageSelect($language) { +export function enableLanguageSelect($language) { enableVocabularySelect($language.find("select:first"), 'language_code'); enableVocabularySelect($language.find("select:last"), 'script_code'); } -function magicNewResourceLanguage(event) { +export function magicNewResourceLanguage(event) { var $newLanguage = newResourceLanguage(event); var defaultLanguage = new Option(defaults.language.term, defaults.language.id, false, true); var defaultScript = new Option(defaults.script.term, defaults.script.id, false, true); @@ -179,7 +179,7 @@ function magicNewResourceLanguage(event) { $newLanguage.find("select:last").append(defaultScript).trigger('change'); } -function selectHoldingRepository(event) { +export function selectHoldingRepository(event) { event.preventDefault(); var name = event.target.innerHTML; var id = event.target.href.split('/').pop(); diff --git a/src/virtualhosts/www/javascript/src/select_loaders.js b/src/virtualhosts/www/javascript/src/select_loaders.js index f3b45d189..b54204df3 100644 --- a/src/virtualhosts/www/javascript/src/select_loaders.js +++ b/src/virtualhosts/www/javascript/src/select_loaders.js @@ -20,7 +20,7 @@ * @param string type The type of the vocabulary term * @param int minLength The minimum required length of the autocomplete search */ -function vocab_select_replace(selectItem, idMatch, type, minLength) { +export function vocab_select_replace(selectItem, idMatch, type, minLength) { if (minLength === undefined) { minLength = 2; } @@ -57,9 +57,9 @@ function vocab_select_replace(selectItem, idMatch, type, minLength) { } } -var geoPlaceSearchResults = null; +export var geoPlaceSearchResults = null; -function geovocab_select_replace(selectItem, idMatch) { +export function geovocab_select_replace(selectItem, idMatch) { var minLength = 2; if(selectItem.attr('id').endsWith(idMatch) @@ -127,7 +127,7 @@ function addbr(str) { * @param JQuery selectItem The JQuery item to replace * @param string idMatch ID string for the object on the page */ -function scm_source_select_replace(selectItem, idMatch) { +export function scm_source_select_replace(selectItem, idMatch) { if(selectItem.attr('id').endsWith(idMatch) && !selectItem.attr('id').endsWith("ZZ")) { selectItem.select2({ @@ -263,7 +263,7 @@ function select_replace(selectItem, idMatch) { } } -function select_replace_simple(selectItem) { +export function select_replace_simple(selectItem) { selectItem.select2({ width: '100%', allowClear: true, @@ -271,16 +271,6 @@ function select_replace_simple(selectItem) { }); } - - -function sayHi(user) { - return `Hello, ${user}!`; -} - -function sayBye(user) { - return `Bye bye, ${user}!`; -} - /** * Load Vocab Select Options * @@ -290,7 +280,7 @@ function sayBye(user) { * @param string type The type of the vocabulary term * @param string type Text placeholder for select */ -function loadVocabSelectOptions(selectItem, type, placeholder) { +export function loadVocabSelectOptions(selectItem, type, placeholder) { return $.get(snacUrl + "/vocabulary?type=" + type) .done(function(data) { var options = data.results; diff --git a/webpack.config.js b/webpack.config.js index bd347e879..ddc715bc6 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -5,11 +5,13 @@ module.exports = { entry: { bundle: path.join(js_path, "src", "main.js"), resource_admin: path.join(js_path, "src", "resource_admin.js"), + edit_scripts: path.join(js_path, "src", "edit_scripts.js"), select_loaders: path.join(js_path, "src", "select_loaders.js"), }, output: { path: js_path, - filename: "[name].js" + filename: "[name].js", + libraryTarget: "window" }, devtool: "cheap-module-eval-source-map", module: { @@ -19,4 +21,7 @@ module.exports = { exclude: /node_modules/ }] }, + optimization: { + minimize: false + }, }; From 484bbabf5e7ed6c1037544943d8048d98370e585 Mon Sep 17 00:00:00 2001 From: Derik Ramirez Date: Fri, 22 May 2020 13:18:24 -0600 Subject: [PATCH 4/4] Improves webpack configuration for production and development We are now able to generate a minified version for production and development for our JavaScript files. The development script leaves keeps a watch on the files, if anything changes Webpack updates the files so we don't have to regenerate them manualy while developing. --- package.json | 3 +- src/virtualhosts/www/javascript/bundle.js.map | 1 + .../www/javascript/edit_scripts.js | 110 +++--------------- .../www/javascript/edit_scripts.js.map | 1 + .../www/javascript/resource_admin.js | 108 +++-------------- .../www/javascript/resource_admin.js.map | 1 + .../www/javascript/select_loaders.js | 110 +++--------------- .../www/javascript/select_loaders.js.map | 1 + .../www/javascript/src/select_loaders.js | 1 - webpack.config.js | 48 ++++---- 10 files changed, 71 insertions(+), 313 deletions(-) create mode 100644 src/virtualhosts/www/javascript/bundle.js.map create mode 100644 src/virtualhosts/www/javascript/edit_scripts.js.map create mode 100644 src/virtualhosts/www/javascript/resource_admin.js.map create mode 100644 src/virtualhosts/www/javascript/select_loaders.js.map diff --git a/package.json b/package.json index 8a807713b..5fa315f20 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,8 @@ "webpack": "^4.43.0" }, "scripts": { - "build": "webpack" + "build-dev": "webpack", + "build-prod": "webpack -p --env production" }, "devDependencies": { "webpack-cli": "^3.3.11" diff --git a/src/virtualhosts/www/javascript/bundle.js.map b/src/virtualhosts/www/javascript/bundle.js.map new file mode 100644 index 000000000..e762ac23a --- /dev/null +++ b/src/virtualhosts/www/javascript/bundle.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/virtualhosts/www/javascript/src/resource_admin.js","webpack:///./src/virtualhosts/www/javascript/src/select_loaders.js","webpack:///./src/virtualhosts/www/javascript/src/main.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","saveResource","event","preventDefault","$form","$","target","find","val","confirm","slideDown","html","each","this","trim","setDeletedResourceLanguageOperations","post","snacUrl","serialize","done","data","createdResource","resource","slideUp","setTimeout","window","location","id","fail","$deletedLanguages","has","$ignoredLanguages","setOperations","cancelResource","href","newResourceLanguage","$newLanguage","clone","newLanguageID","languageCount","attr","addClass","replace","console","log","toggle","before","enableLanguageSelect","deleteOrUndoLanguage","$btn","currentTarget","toggleClass","closest","$elements","operation","markEditedResourceFields","$resourceForm","on","e","length","enableVocabularySelect","selectItem","type","select2","ajax","url","dataType","delay","params","q","term","page","processResults","results","cache","width","minimumInputLength","allowClear","theme","placeholder","$language","magicNewResourceLanguage","defaultLanguage","Option","defaults","language","defaultScript","script","append","trigger","selectHoldingRepository","innerHTML","split","pop","selectedRepo","slideToggle","vocab_select_replace","idMatch","minLength","undefined","endsWith","query","geoPlaceSearchResults","geovocab_select_replace","selectResults","Array","forEach","result","push","text","administrationCode","countryCode","lastSourceSearchResults","scm_source_select_replace","res","displayName","evt","sourceID","idArray","j","shortName","source","str","removeClass","uri","citation","select_replace_simple","loadVocabSelectOptions","options","document","ready","exists","reviewer_select_replace"],"mappings":"4DACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EAAPE,GAA4B,iBAATF,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cAAe,OAK/DR,EAAE,kBAAkB8H,WA/GQtE,EAgHDxD,EAAE,kBA/GjCA,EAAEvB,IAAImC,QAAU,gCAAgCE,MAAK,SAASC,GAC1D,IAAI4G,EAAU5G,EAAKqD,QACnBZ,EAAWE,QAAQ,CACf3C,KAAM4G,EACNnD,YAAY,EACZC,MAAO,YACPC,YAAa,2BA4GjB1E,EAAE,sBAAsB8H,UAvGhC,SAAiCtE,GACR,MAAdA,GACKA,EAAWE,QAAQ,CACfgB,YAAa,4BACbf,KAAM,CACFC,IAAK,WAEG,OADQhD,QAAQ,8BAGxBiD,SAAU,OACVC,MAAO,IACP/C,KAAM,SAAUgD,GACZ,MAAO,CACHC,EAAGD,EAAOE,KACVC,KAAMH,EAAOG,OAGrBC,eAAgB,SAAUpD,EAAMmD,GAC5B,MAAO,CAAEE,QAASrD,EAAKqD,UAE3BC,OAAO,GAEXC,MAAO,OACPC,mBAAoB,EACpBC,YAAY,EACZC,MAAO,cA+EnBsD,CAAwB/H,EAAE,2B,6BCzUlC,yBAGAoB,OAAOsG,uBAAyBA,yBAChCtG,OAAOuE,qBAAuBA,uBAC9BvE,OAAOsB,qBAAuBA,uBAC9BtB,OAAO8B,yBAA2BA,2BAClC9B,OAAOU,oBAAsBA,sBAC7BV,OAAOQ,eAAiBA,iBACxBR,OAAOxB,aAAeA,eACtBwB,OAAOiE,wBAA0BA,0BACjCjE,OAAOwD,yBAA2BA","file":"bundle.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 2);\n","/**\n * Resource Admin Actions\n *\n * Contains code that handles Resource creation and editing\n *\n * @author Joseph Glass\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\nexport function saveResource(event) {\n event.preventDefault();\n var $form = $(event.target);\n\n if ($form.find(\"#resource-url\").val() == \"\") {\n if (!confirm('Are you sure you want to save without an HREF?')) {\n return;\n }\n }\n $('#notification-message').slideDown().html(\"

    Saving Resource... Please wait.

    \");\n\n // Remove leading and trailing whitespace\n $form.find(\"input, textarea\").each(function() {\n $(this).val($.trim($(this).val()));\n });\n\n setDeletedResourceLanguageOperations($form);\n\n $.post(snacUrl + \"/save_resource\", $form.serialize())\n .done(function(data) {\n createdResource = data;\n if (typeof(data.resource) === 'undefined') {\n $('#error-message').slideDown();\n return false;\n }\n $('#notification-message').slideUp();\n $('#success-message').slideDown();\n setTimeout(function() {\n window.location = (snacUrl + \"/vocab_administrator/resources/\" + data.resource.id);\n }, 1000);\n })\n .fail(function() {\n $('#error-message').slideDown();\n });\n return false;\n}\n\n\nexport function setDeletedResourceLanguageOperations($form) {\n // Set deleted new languages to null, set deleted existing languages to delete\n var $deletedLanguages = $form.find(\"#resource-languages .component-deleted\").has('input[id]');\n var $ignoredLanguages = $form.find(\"#resource-languages .component-deleted.new-language\");\n setOperations($deletedLanguages, \"delete\");\n setOperations($ignoredLanguages, \"\");\n}\n\nexport function cancelResource() {\n if (!confirm('Are you sure you want to cancel?')) {\n return;\n }\n\n $('#notification-message').html(\"

    Cancelling...

    \");\n $('#notification-message').slideDown();\n setTimeout(function() {\n window.location.href = snacUrl + \"/vocab_administrator\";\n }, 1000);\n return false;\n}\n\n/**\n * New Resource Language\n * Copies the resource template DIV on the page and attaches it correctly to the DOM.\n * Tracks language index using $('#language-template').data('languageCount')\n *\n */\nexport function newResourceLanguage(event) {\n event.preventDefault();\n var $newLanguage = $('#resource-language-template').find(\".language\").clone();\n var data = $('#resource-language-template').data();\n var newLanguageID = 'language_' + data.languageCount;\n $newLanguage.attr('id', newLanguageID);\n $newLanguage.find('.operation').val('insert');\n $newLanguage.addClass('new-language');\n\n //update input names with new data.languageCount\n $newLanguage.find('input, select').attr('name', function(i, name) {\n return name.replace('YY', data.languageCount);\n });\n\n console.log('Adding new resource language with id: ', newLanguageID);\n $newLanguage.toggle();\n // selects last to avoid conflict on multiple clones\n $('.add-resource-language:last').before($newLanguage);\n enableLanguageSelect($newLanguage);\n\n data.languageCount++;\n return $newLanguage;\n}\n\n/**\n * Delete or Undo Language\n *\n * Toggles component-deleted class, and btn classes for delete and undo.\n * Does not change operations.\n *\n */\nexport function deleteOrUndoLanguage(event) {\n event.preventDefault();\n var $btn = $(event.currentTarget);\n $btn.toggleClass('btn-danger btn-warning');\n $btn.find(':only-child').toggleClass('fa-minus-circle fa-undo');\n var $language = $btn.closest('.language');\n $language.toggleClass('alert-danger component-deleted');\n}\n\n\nfunction setOperations($elements, operation) {\n $elements.find('.operation').each(function() {\n $(this).val(operation);\n });\n}\n\n/**\n * Mark Edited Resource Fields\n *\n * Adds edited-field class to altered inputs. Sets altered resource language to update.\n * @param jqueryObject $resourceForm jQuery object to modify\n *\n */\nexport function markEditedResourceFields($resourceForm) {\n $resourceForm.find(\"input, select, textarea\").on(\"change\", function(e) {\n $(e.target).addClass('edited-field');\n\n if ($(e.target).closest('.language').length) {\n setOperations($(e.target).closest('.language'), \"update\");\n }\n });\n}\n\nfunction enableVocabularySelect(selectItem, type) {\n selectItem.select2({\n ajax: {\n url: snacUrl + \"/vocabulary?type=\" + type,\n dataType: 'json',\n delay: 250,\n data: function(params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function(data, page) {\n return {\n results: data.results\n };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 0,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n}\n\nexport function enableLanguageSelect($language) {\n enableVocabularySelect($language.find(\"select:first\"), 'language_code');\n enableVocabularySelect($language.find(\"select:last\"), 'script_code');\n}\n\n\nexport function magicNewResourceLanguage(event) {\n var $newLanguage = newResourceLanguage(event);\n var defaultLanguage = new Option(defaults.language.term, defaults.language.id, false, true);\n var defaultScript = new Option(defaults.script.term, defaults.script.id, false, true);\n $newLanguage.find(\"select:first\").append(defaultLanguage).trigger('change');\n $newLanguage.find(\"select:last\").append(defaultScript).trigger('change');\n}\n\nexport function selectHoldingRepository(event) {\n event.preventDefault();\n var name = event.target.innerHTML;\n var id = event.target.href.split('/').pop();\n var selectedRepo = new Option(name, id, false, true);\n $(\".resource-repo:last\").append(selectedRepo).trigger('change');\n $(\"#search_form\").slideToggle();\n $(\"#search-results-box\").html(\"\");\n $(\"#searchbox\").val(\"\");\n}\n","/**\n * Select Box Loaders\n *\n * Functions that can be used to replace select boxes on the edit page with\n * pretty-formatted versions using JQuery and Select2\n *\n * @author Robbie Hott\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\n/**\n * Replace a select that is linked to a Vocabulary search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n * @param string type The type of the vocabulary term\n * @param int minLength The minimum required length of the autocomplete search\n */\nexport function vocab_select_replace(selectItem, idMatch, type, minLength) {\n if (minLength === undefined) {\n minLength = 2;\n }\n\n if(selectItem.attr('id').endsWith(idMatch)\n && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function() {\n var query = snacUrl + \"/vocabulary?type=\"+type+\"&id=\";\n query += $(\"#constellationid\").val()+\"&version=\"+$(\"#version\").val();\n query += \"&entity_type=\"+$(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: minLength,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n }\n}\n\nexport var geoPlaceSearchResults = null;\n\nexport function geovocab_select_replace(selectItem, idMatch) {\n var minLength = 2;\n\n if(selectItem.attr('id').endsWith(idMatch)\n && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function() {\n var query = snacUrl+\"/vocabulary?type=geo_place&format=term\";\n query += \"&entity_type=\"+$(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n if (data.results) {\n geoPlaceSearchResults = data.results;\n var selectResults = new Array();\n data.results.forEach(function(result) {\n selectResults.push({\n id: result.id,\n text: result.name + \" (\" + result.administrationCode + \", \" + result.countryCode+ \")\"\n })\n });\n return {results: selectResults};\n }\n return { results: null };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: minLength,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n }\n}\n\nvar lastSourceSearchResults = null;\n\n/**\n * Add
    helper script\n *\n * Adds
    to strings so that they can be shown to the user in HTML\n * after being input into a text-only field.\n */\nfunction addbr(str) {\n if (typeof str !== 'undefined' && str !== null) {\n return (str + '').replace(/(\\r\\n|\\n\\r|\\r|\\n)/g, '
    ' + '$1');\n }\n return '';\n}\n\n/**\n * Replace a select that is linked to a Constellation Source search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n */\nexport function scm_source_select_replace(selectItem, idMatch) {\n if(selectItem.attr('id').endsWith(idMatch)\n && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function() {\n var query = snacUrl+\"/vocabulary?type=ic_sources&id=\";\n query += $(\"#constellationid\").val()+\"&version=\"+$(\"#version\").val();\n query += \"&entity_type=\"+$(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n // Modify the results to be in the format we want\n lastSourceSearchResults = data.results;\n // need id, text\n var results = new Array();\n data.results.forEach(function(res) {\n results.push({id: res.id, text: res.displayName});\n });\n return { results: results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 0,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n\n selectItem.on('change', function (evt) {\n // TODO: Get the current selected value and update the well in the page to reflect it!\n // Note: all the selections are available in the global lastSourceSearchResults variable.\n var sourceID = $(this).val();\n var inPageID = $(this).attr(\"id\");\n var idArray = inPageID.split(\"_\");\n if (idArray.length >= 6) {\n var i = idArray[5];\n var j = idArray[4];\n var shortName = idArray[1];\n lastSourceSearchResults.forEach(function(source) {\n if (source.id == sourceID) {\n // Update the text of the source\n if (typeof source.text !== 'undefined') {\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).html(addbr(source.text)).removeClass('hidden');\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).closest(\".panel-body\").removeClass('hidden');\n } else {\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).text(\"\").addClass('hidden');\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).closest(\".panel-body\").addClass('hidden');\n\n }\n // Update the URI of the source\n if (typeof source.uri !== 'undefined')\n $(\"#scm_\" + shortName + \"_source_uri_\" + j + \"_\" + i).html(''+source.uri+'');\n else\n $(\"#scm_\" + shortName + \"_source_uri_\" + j + \"_\" + i).html('');\n // Update the URI of the source\n if (typeof source.citation !== 'undefined')\n $(\"#scm_\" + shortName + \"_source_citation_\" + j + \"_\" + i).html(source.citation).removeClass('hidden');\n else\n $(\"#scm_\" + shortName + \"_source_citation_\" + j + \"_\" + i).html('').addClass('hidden');\n }\n });\n }\n });\n\n }\n}\n\n/**\n * Replace a select that is linked to an affiliation search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n */\nfunction affiliation_select_replace(selectItem) {\n $.get(snacUrl + \"/vocabulary?type=affiliation\").done(function(data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: true,\n theme: \"bootstrap\",\n placeholder: \"Select Affiliation\"\n });\n });\n}\n\nfunction reviewer_select_replace(selectItem) {\n if(selectItem != null) {\n selectItem.select2({\n placeholder: \"Reviewer Name or Email...\",\n ajax: {\n url: function() {\n var query = snacUrl+\"/user_search?role=Reviewer\";\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 1,\n allowClear: false,\n theme: 'bootstrap'\n });\n }\n}\n\nfunction select_replace(selectItem, idMatch) {\n if(selectItem.attr('id').endsWith(idMatch)\n && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n allowClear: true,\n theme: 'bootstrap'\n });\n }\n}\n\nexport function select_replace_simple(selectItem) {\n selectItem.select2({\n width: '100%',\n allowClear: true,\n theme: 'bootstrap'\n });\n}\n\n/**\n * Load Vocab Select Options\n *\n * Replaces the select with a select2 object preloaded with an array of options\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string type The type of the vocabulary term\n * @param string type Text placeholder for select\n */\nexport function loadVocabSelectOptions(selectItem, type, placeholder) {\n return $.get(snacUrl + \"/vocabulary?type=\" + type)\n .done(function(data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: false,\n theme: 'bootstrap',\n placeholder: placeholder\n });\n });\n}\n\n/**\n * Replace all the selects that exist on the page when the page has finished loading\n */\n$(document).ready(function() {\n // Use select2 to display the select dropdowns\n // rather than the HTML default\n $(\"select\").each(function() {\n if (typeof $(this).attr('id') !== typeof undefined && $(this).attr('id') !== false) {\n // Replace the subject selects\n vocab_select_replace($(this), \"language_language_\", \"language_code\", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), \"language_script_\", \"script_code\", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), \"subject_\", \"subject\", 4);\n\n // Replace the function selects\n vocab_select_replace($(this), \"function_\", \"function\", 4);\n\n // Replace the occupation selects\n vocab_select_replace($(this), \"occupation_\", \"occupation\", 4);\n\n // Replace the entityType select\n vocab_select_replace($(this), \"entityType\", \"entity_type\", 0);\n }\n });\n\n // Replace the Affiliation dropdowns, if one exists\n if ($(\"#affiliationid\").exists())\n affiliation_select_replace($(\"#affiliationid\"));\n\n // Replace the User search dropdown, if one exists\n if ($(\"#reviewersearchbox\").exists())\n reviewer_select_replace($(\"#reviewersearchbox\"));\n});\n","import { loadVocabSelectOptions, vocab_select_replace } from \"./select_loaders.js\";\nimport { enableLanguageSelect, markEditedResourceFields, newResourceLanguage, cancelResource, saveResource, selectHoldingRepository, magicNewResourceLanguage } from \"./resource_admin.js\";\n\nwindow.loadVocabSelectOptions = loadVocabSelectOptions;\nwindow.vocab_select_replace = vocab_select_replace;\nwindow.enableLanguageSelect = enableLanguageSelect;\nwindow.markEditedResourceFields = markEditedResourceFields;\nwindow.newResourceLanguage = newResourceLanguage;\nwindow.cancelResource = cancelResource;\nwindow.saveResource = saveResource;\nwindow.selectHoldingRepository = selectHoldingRepository;\nwindow.magicNewResourceLanguage = magicNewResourceLanguage;\n"],"sourceRoot":""} \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/edit_scripts.js b/src/virtualhosts/www/javascript/edit_scripts.js index 4bbd73061..5dafa5c7a 100644 --- a/src/virtualhosts/www/javascript/edit_scripts.js +++ b/src/virtualhosts/www/javascript/edit_scripts.js @@ -1,97 +1,13 @@ -(function(e, a) { for(var i in a) e[i] = a[i]; }(window, /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 3); -/******/ }) -/************************************************************************/ -/******/ ({ - -/***/ 3: -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"somethingHasBeenEdited\", function() { return somethingHasBeenEdited; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"setEditedFlag\", function() { return setEditedFlag; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"undoSet\", function() { return undoSet; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"defaults\", function() { return defaults; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"displayErrorMessage\", function() { return displayErrorMessage; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"addDateEntry\", function() { return addDateEntry; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"addDateRangeEntry\", function() { return addDateRangeEntry; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"addSCMEntry\", function() { return addSCMEntry; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"makeEditable\", function() { return makeEditable; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"makeUneditable\", function() { return makeUneditable; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"makeSCMUneditable\", function() { return makeSCMUneditable; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"setRepeatedDataDeleted\", function() { return setRepeatedDataDeleted; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"newAddressLine\", function() { return newAddressLine; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"newNameEntryComponent\", function() { return newNameEntryComponent; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"updateNameEntryHeading\", function() { return updateNameEntryHeading; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"newNameEntryRule\", function() { return newNameEntryRule; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"updateDate\", function() { return updateDate; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"chooseSuggestedGeoPlace\", function() { return chooseSuggestedGeoPlace; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"magicDefaultFill\", function() { return magicDefaultFill; });\n/**\n * Edit Scripts\n *\n * Scripts used in the edit page\n *\n * @author Robbie Hott\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\nvar biogHistEditor = null;\n\n// Has anything been edited on this page?\nvar somethingHasBeenEdited = false;\n\nfunction setEditedFlag(val) {\n if (val == true) {\n $(\"#save_and_continue\").addClass(\"save-active\");\n } else {\n $(\"#save_and_continue\").removeClass(\"save-active\");\n }\n somethingHasBeenEdited = val;\n}\n\n// Global Undo Set\nvar undoSet = new Array();\n\nvar defaults = {\n language: {\n id: 130,\n term: \"eng\"\n },\n script: {\n id: 586,\n term: \"Latn\"\n }\n};\n\n/**\n * Display Error message\n *\n * Displays the error message box to the user with the given error message\n *\n * @param string|object err The error message (string) or error object containing a message and type string\n */\nfunction displayErrorMessage(err, data) {\n var errorMsg = \"\";\n if (typeof err === 'undefined') errorMsg = \"an unknown problem occurred\";else if (typeof err == \"string\") errorMsg = err;else if (err.message) errorMsg = err.message;else if (err.type) errorMsg = err.type;else errorMsg = \"an unknown problem occurred\";\n\n $('#error-message').html(\"

    Oops

    \" + errorMsg + \"

    \" + \"

    \" + \" \" + \"\" + \"Go to Dashboard\" + \"\" + \"

    \");\n setTimeout(function () {\n $('#error-message').slideDown();\n }, 500);\n\n // For reference, put the server response in the console\n console.log(data);\n}\n\n/**\n * Add sub-Date GUI object\n *\n * Adds a Date GUI object to the Date modal for the given \"short\" type of data indexed by i\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index of the object to add a date object to.\n * @returns boolean false to keep the browser from redrawing the page\n */\nfunction addDateEntry(short, i) {\n //next_date_{{short}}_{{i}}_j\n var j = parseInt($('#next_date_' + short + '_' + i + '_j').text());\n var id = j + \"_\" + i;\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#sub_date_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/XX/g, j).replace(/SHORT/g, short);\n $('#add_date_' + short + '_' + i + '_div').after(html);\n $('#next_date_' + short + '_' + i + '_j').text(j + 1);\n turnOnButtons(short + \"_date\" + j, i);\n turnOnTooltips(short + \"_date_\" + j, i);\n makeEditable(short + \"_date_\" + j, i);\n return false;\n}\n\n/**\n * Add sub-Date GUI object\n *\n * Adds a Date GUI object to the Date modal for the given \"short\" type of data indexed by i\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index of the object to add a date object to.\n * @returns boolean false to keep the browser from redrawing the page\n */\nfunction addDateRangeEntry(short, i) {\n //next_date_{{short}}_{{i}}_j\n var j = parseInt($('#next_date_' + short + '_' + i + '_j').text());\n var id = j + \"_\" + i;\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#sub_dateRange_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/XX/g, j).replace(/SHORT/g, short);\n $('#add_date_' + short + '_' + i + '_div').after(html);\n $('#next_date_' + short + '_' + i + '_j').text(j + 1);\n turnOnButtons(short + \"_date\" + j, i);\n turnOnTooltips(short + \"_date_\" + j, i);\n makeEditable(short + \"_date_\" + j, i);\n return false;\n}\n\n/**\n * Add SCM GUI object\n *\n * Adds a GUI SCM object to the SCM modal for the given \"short\" type of data indexed by i\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index of the object to add an SCM object to.\n * @returns boolean false to keep the browser from redrawing the page\n */\nfunction addSCMEntry(short, i) {\n //next_scm_{{short}}_{{i}}_j\n var j = parseInt($('#next_scm_' + short + '_' + i + '_j').text());\n var id = j + \"_\" + i;\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#scm_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, j).replace(/SHORT/g, short);\n $('#add_scm_' + short + '_' + i + '_div').after(html);\n $('#next_scm_' + short + '_' + i + '_j').text(j + 1);\n turnOnSCMButtons(short, i, j);\n turnOnTooltips(\"scm_\" + short, id);\n makeSCMEditable(short, i, j);\n return false;\n}\n\n/**\n * Undo Edit\n *\n * Returns the html for the (short, i) panel back to its original state, i.e. removes\n * the edit. Before doing this, to clean up the page, it first makes the edited version\n * uneditable.\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n */\nfunction undoEdit(short, i) {\n makeUneditable(short, i);\n\n // restore the old content\n $(\"#\" + short + \"_datapart_\" + i).replaceWith(undoSet[short + \"-\" + i]);\n turnOnTooltips(short, i);\n $(\"#\" + short + \"_datapart_\" + i + \" input[type='checkbox']\").each(function () {\n var obj = $(this);\n obj.bootstrapToggle();\n });\n}\n\n/**\n * Undo SCM Edit\n *\n * Takes an SCM GUI object (j) for a data object (short, i) and returns it back to its\n * original state (removing the edit). Before doing this, to clean up the page and JS, it first\n * makes the edited version uneditable, then replaces the HTML.\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n */\nfunction undoSCMEdit(short, i, j) {\n var id = j + \"_\" + i;\n makeSCMUneditable(short, i, j);\n\n // restore the old content\n $(\"#scm_\" + short + \"_datapart_\" + id).replaceWith(undoSet[\"scm_\" + short + \"-\" + id]);\n turnOnTooltips(\"scm_\" + short, id);\n}\n\n/**\n * Change vocabulary input divs to selects\n *\n * Changes all div's with id \"select_\" for a given data object (shortName, idStr) from a list of\n * inputs defining the parameters to a select (view mode) to a select box (edit mode). It then\n * calls the select2 function to replace the select with an AJAX-compatible select.\n *\n * This function handles VOCABULARY select boxes ONLY.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction textToSelect(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='select_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"select_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr).val();\n var term = $(\"#\" + shortName + \"_\" + name + \"_term_\" + idStr).val();\n var vocabtype = $(\"#\" + shortName + \"_\" + name + \"_vocabtype_\" + idStr).val();\n var minlength = $(\"#\" + shortName + \"_\" + name + \"_minlength_\" + idStr).val();\n var placeholder = \"Select\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).exists()) {\n placeholder = $(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).val();\n }\n var options = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_defaultOptions_\" + idStr).exists()) {\n options = $(\"#\" + shortName + \"_\" + name + \"_defaultOptions_\" + idStr).val();\n }\n\n cont.html(\"\" + \"\" + \"\");\n\n if (name == \"citation\") scm_source_select_replace($(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr), \"_\" + idStr);else vocab_select_replace($(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr), \"_\" + idStr, vocabtype, minlength);\n }\n });\n}\n\nfunction textToCheckbox(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='checkbox_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^checkbox_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n var placeholderOn = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholderOn_\" + idStr).exists()) {\n placeholderOn = $(\"#\" + shortName + \"_\" + name + \"_placeholderOn_\" + idStr).val();\n }\n var placeholderOff = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholderOff_\" + idStr).exists()) {\n placeholderOff = $(\"#\" + shortName + \"_\" + name + \"_placeholderOff_\" + idStr).val();\n }\n\n var html = \"\";\n if (placeholderOn != \"\") {\n html += \"\";\n }\n if (placeholderOff != \"\") {\n html += \"\";\n }\n\n cont.html(html);\n $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).bootstrapToggle();\n }\n });\n}\n\nfunction checkboxToText(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='checkbox_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^checkbox_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n var checked = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).prop('checked');\n var placeholderOn = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholderOn_\" + idStr).exists()) {\n placeholderOn = $(\"#\" + shortName + \"_\" + name + \"_placeholderOn_\" + idStr).val();\n }\n var placeholderOff = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholderOff_\" + idStr).exists()) {\n placeholderOff = $(\"#\" + shortName + \"_\" + name + \"_placeholderOff_\" + idStr).val();\n }\n\n var html = \"\";\n\n html += \"

    \";\n if (checked) {\n if (placeholderOn != \"\") html += placeholderOn;else html += value;\n } else {\n if (placeholderOff != \"\") html += placeholderOff;\n }\n html += \"

    \";\n if (placeholderOn != \"\") {\n html += \"\";\n }\n if (placeholderOff != \"\") {\n html += \"\";\n }\n\n $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).bootstrapToggle(\"destroy\");\n cont.html(html);\n }\n });\n}\n\nfunction textToInput(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='text_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^text_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n var size = 0;\n var sizeStr = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_size_\" + idStr).exists()) {\n size = parseInt($(\"#\" + shortName + \"_\" + name + \"_size_\" + idStr).val());\n sizeStr = \" size='\" + size + \"' \";\n }\n var placeholder = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).exists()) {\n placeholder = $(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).val();\n }\n\n var onKeyUp = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_onKeyUp_\" + idStr).exists()) {\n onKeyUp = $(\"#\" + shortName + \"_\" + name + \"_onKeyUp_\" + idStr).val();\n }\n var onKeyUpStr = \"\";\n if (onKeyUp != \"\") {\n onKeyUpStr = \" onKeyUp='\" + onKeyUp + \"' \";\n }\n\n var html = \"\";\n if (size != 0) {\n html += \"\";\n }\n if (placeholder != \"\") {\n html += \"\";\n }\n if (onKeyUp != \"\") {\n html += \"\";\n }\n\n cont.html(html);\n }\n });\n}\n\nfunction inputToText(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='text_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^text_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n var size = 0;\n if ($(\"#\" + shortName + \"_\" + name + \"_size_\" + idStr).exists()) {\n size = parseInt($(\"#\" + shortName + \"_\" + name + \"_size_\" + idStr).val());\n }\n var placeholder = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).exists()) {\n placeholder = $(\"#\" + shortName + \"_\" + name + \"_placeholder_\" + idStr).val();\n }\n var onKeyUp = \"\";\n if ($(\"#\" + shortName + \"_\" + name + \"_onKeyUp_\" + idStr).exists()) {\n onKeyUp = $(\"#\" + shortName + \"_\" + name + \"_onKeyUp_\" + idStr).val();\n }\n\n var html = \"\";\n html += \"

    \" + value + \"

    \";\n if (size != 0) {\n html += \"\";\n }\n if (placeholder != \"\") {\n html += \"\";\n }\n if (onKeyUp != \"\") {\n html += \"\";\n }\n\n cont.html(html);\n }\n });\n}\n\nfunction textToTextArea(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='textarea_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^textarea_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n\n var html = \"\";\n\n cont.html(html);\n }\n });\n}\n\nfunction textAreaToText(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='textarea_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^textarea_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n\n //var html = \"\";\n var html = \"\";\n html += \"
    \" + value + \"
    \";\n\n cont.html(html);\n }\n });\n}\n\n/**\n * Change vocabulary selects to divs of inputs\n *\n * Changes all div's with id \"select_\" for a given data object (shortName, idStr) from a select\n * box (edit mode) to a list of inputs defining the parameters to a select (view mode).\n *\n * This function handles VOCABULARY select boxes ONLY.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction selectToText(shortName, idStr) {\n $(\"div[id^='select_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"select_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr).val();\n var term = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr + \" option:selected\").text();\n var vocabtype = $(\"#\" + shortName + \"_\" + name + \"_vocabtype_\" + idStr).val();\n var minlength = $(\"#\" + shortName + \"_\" + name + \"_minlength_\" + idStr).val();\n\n var additionalStyle = \"\";\n var postText = \"\";\n if (vocabtype == \"name_component\") {\n additionalStyle = \"name-component-type\";\n postText = \" :\";\n }\n\n cont.html(\"\" + \"\" + \"\" + \"\" + \"

    \" + term + postText + \"

    \");\n }\n });\n}\n\nvar geoPlaceLoadResults = null;\n\nfunction textToGeoPlaceSelect(shortName, idStr) {\n $(\"#\" + shortName + \"_datapart_\" + idStr + \" div[id^='selectGeo_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"selectGeo_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr).val();\n var term = $(\"#\" + shortName + \"_\" + name + \"_term_\" + idStr).val();\n var placeholder = \"Select Geo Place Term\";\n\n var confirmed = $(\"#\" + shortName + \"_confirmed_\" + idStr).val() == \"true\" ? true : false;\n var firstOptionSelect = \"\";\n var secondOptionSelect = \" selected\";\n if (!confirmed) {\n firstOptionSelect = \" selected\";\n secondOptionSelect = \"\";\n }\n\n cont.html(\"\");\n\n geovocab_select_replace($(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr), \"_\" + idStr);\n }\n });\n}\n\nfunction geoPlaceSelectToText(shortName, idStr) {\n $(\"div[id^='selectGeo_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"selectGeo_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr).val();\n var term = $(\"#\" + shortName + \"_\" + name + \"_id_\" + idStr + \" option:selected\").text();\n\n cont.html(\"\" + \"\");\n }\n });\n}\n\n/**\n * Make a data object editable\n *\n * Make the GUI pane for a given constellation object (short, i) editable. Sets up the edit and delete\n * buttons for first-order data objects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction makeEditable(short, i) {\n // No editing if it's already in edit mode\n if ($(\"#\" + short + \"_operation_\" + i).val() == \"update\") return false;\n // If it's deleted, then you better undelete it first\n if ($(\"#\" + short + \"_operation_\" + i).val() == \"delete\") setDeleted(short, i);\n\n $(\"#\" + short + \"_editbutton_\" + i).removeClass(\"list-group-item-info\").addClass(\"list-group-item-warning\");\n $(\"#\" + short + \"_editbutton_\" + i).html(\"
    Undo\");\n $(\"#\" + short + \"_editbutton_\" + i).off('click').on(\"click\", function () {\n undoEdit(short, i);\n });\n $(\"#\" + short + \"_deletebutton_\" + i).removeClass(\"list-group-item-danger\").addClass(\"disabled\");\n $(\"#\" + short + \"_deletebutton_\" + i).off('click').on(\"click\", function () {\n return false;\n });\n\n $(\"#\" + short + \"_panel_\" + i).removeClass(\"panel-default\").addClass(\"alert-info\").addClass(\"edited-component\");\n\n return subMakeEditable(short, i);\n}\n\n/**\n * Make a data object editable\n *\n * Make the GUI pane for a given constellation object (short, i) editable. Handles removing the read-only\n * statuses and changing divs into selects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction subMakeEditable(short, i) {\n // No editing if it's already in edit mode\n if ($(\"#\" + short + \"_operation_\" + i).val() == \"update\") return false;\n\n // Add to the undo set\n undoSet[short + \"-\" + i] = $(\"#\" + short + \"_datapart_\" + i).clone();\n\n textToInput(short, i);\n textToTextArea(short, i);\n textToCheckbox(short, i);\n\n var idstr = \"_\" + i;\n\n // Enable buttons\n $(\"#\" + short + \"_datapart_\" + i + \" button[id^='\" + short + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.removeAttr(\"disabled\").removeClass(\"snac-hidden\");\n }\n });\n // Enable buttons\n $(\"#\" + short + \"_datapart_\" + i + \" a.label\").each(function () {\n $(this).removeClass(\"snac-hidden\");\n });\n\n // Enable checkboxes\n $(\"#\" + short + \"_datapart_\" + i + \" input[type='checkbox']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.bootstrapToggle('enable');\n }\n });\n\n // Turn on CodeMirror Editors\n $(\"#\" + short + \"_datapart_\" + i + \" textarea[id^='\" + short + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n // remove the short name from the string we're parsing\n var idStr = obj.attr('id').replace(short, \"\");\n if (idStr.indexOf('_text_') != -1 || idStr.indexOf('_source_') != -1) {\n obj.get(0).CodeMirror = CodeMirror.fromTextArea(obj.get(0), {\n lineNumbers: true,\n lineWrapping: true,\n viewportMargin: Infinity,\n mode: { name: \"xml\" }\n });\n }\n }\n });\n var sawSelect = false;\n $(\"#\" + short + \"_datapart_\" + i + \" select[id^='\" + short + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n sawSelect = true;\n }\n });\n\n if (!sawSelect) {\n textToSelect(short, i);\n textToGeoPlaceSelect(short, i);\n textToDate(short, i);\n }\n\n // Make things re-orderable if something exists\n // $( \"#nameEntry_component_ui_0\" ).sortable({ // id of the container containing sortable things\n // items : '.name_component' // class of the things that are sortable. They MUST have ids\n // });\n $(\"#\" + short + \"_datapart_\" + i + \" span.move-handle\").each(function () {\n $(this).removeClass(\"snac-hidden\");\n });\n $(\"#\" + short + \"_reorderable_\" + i).sortable({\n items: '.reorderable',\n opacity: 0.5,\n update: function (event, ui) {\n var neworder = $(\"#\" + short + \"_reorderable_\" + i).sortable(\"toArray\");\n console.log(neworder);\n neworder.forEach(function (orderedID, index) {\n $(\"#\" + orderedID + \" input.order-index\").val(index);\n });\n if (short == \"nameEntry\") updateNameEntryHeading(i);\n }\n });\n\n // Make the relation pictures update appropriately\n if (short == 'constellationRelation') {\n // make the role dropdown affect the picture\n $('#' + short + '_type_id_' + i).change(function () {\n updatePictureArrow(short, i, $('#' + short + '_type_id_' + i + ' option:selected').text());\n });\n }\n if (short == 'resourceRelation') {\n // make the role dropdown affect the picture\n $('#' + short + '_role_id_' + i).change(function () {\n updatePictureArrow(short, i, $('#' + short + '_role_id_' + i + ' option:selected').text());\n });\n }\n // Places should update the place heading\n if (short == 'place') {\n // If there is a value pre-set, then automatically confirm and update\n if ($('#' + short + '_geoplace_id_' + i).val() != null && $('#' + short + '_geoplace_id_' + i).val() != \"\") {\n updatePlaceHeading(short, i, $('#' + short + '_geoplace_id_' + i).val());\n }\n // make the role dropdown affect the picture\n $('#' + short + '_geoplace_id_' + i).change(function () {\n updatePlaceHeading(short, i, $('#' + short + '_geoplace_id_' + i).val());\n });\n }\n\n // add parser btn if nameEntry is a computed name, entity is person, and if no btn or extra name components already exist\n if (short === 'nameEntry' && $(\"#entityType\").val() === \"700\" && $(\"#nameEntry_component_0_panel_\" + i).find('select:first').text() === \"Name\" && !$(\"#nameEntry_panel_\" + i).find('.name-parser').length && $(\"#nameEntry_component_1_panel_\" + i).length === 0) {\n $('#nameEntry_component_add_' + i).after('');\n }\n\n // Set this data's operation value appropriately\n if ($(\"#\" + short + \"_id_\" + i).val() != \"\") $(\"#\" + short + \"_operation_\" + i).val(\"update\");else $(\"#\" + short + \"_operation_\" + i).val(\"insert\");\n\n // Asked to edit something, so make it globally known\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n return false;\n}\n\n/**\n * Make a data object uneditable\n *\n * Make each object in the GUI page for the given piece uneditable by turning them back to text. Also\n * takes the color away from the pane and removes the operation flag.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction subMakeUneditable(shortName, i) {\n\n // Make inputs read-only\n var idstr = \"_\" + i;\n\n // Turn off the reordering js\n $(\"#\" + shortName + \"_datapart_\" + i + \" span.move-handle\").each(function () {\n $(this).addClass(\"snac-hidden\");\n });\n if ($(\"#\" + shortName + \"_reorderable_\" + i).hasClass(\"ui-sortable\")) $(\"#\" + shortName + \"_reorderable_\" + i).sortable(\"destroy\");\n\n // Remove CodeMirror editors\n $(\"#\" + shortName + \"_datapart_\" + i + \" textarea[id^='\" + shortName + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\") && (obj.attr('id').indexOf('_text_') != -1 || obj.attr('id').indexOf('_source_') != -1)) {\n\n if (obj.get(0).CodeMirror) {\n obj.get(0).CodeMirror.toTextArea();\n }\n //(document.getElementById(obj.attr('id'))).CodeMirror.toTextArea();\n //obj.get(0).CodeMirror.toTextArea();\n }\n });\n // Disable buttons\n $(\"#\" + shortName + \"_datapart_\" + i + \" button[id^='\" + shortName + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.attr(\"disabled\", \"true\").addClass(\"snac-hidden\");\n }\n });\n\n // Disable buttons\n $(\"#\" + shortName + \"_datapart_\" + i + \" a.label\").each(function () {\n $(this).addClass(\"snac-hidden\");\n });\n\n // Disable checkboxes\n $(\"#\" + shortName + \"_datapart_\" + i + \" input[type='checkbox']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.bootstrapToggle(\"disable\");\n }\n });\n\n inputToText(shortName, i);\n textAreaToText(shortName, i);\n checkboxToText(shortName, i);\n // Check for a select box\n var sawSelect = false;\n $(\"#\" + shortName + \"_datapart_\" + i + \" select[id^='\" + shortName + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n sawSelect = true;\n }\n });\n // If a select box was seen, undo it\n if (sawSelect) {\n selectToText(shortName, i);\n geoPlaceSelectToText(shortName, i);\n dateToText(shortName, i);\n }\n\n // Clear the operation flags\n //$(\"#\" + shortName + \"_operation_\" + i).val(\"\");\n $(\"#\" + shortName + \"_datapart_\" + i + \" input[id^='\" + shortName + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(\"_operation\" + idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.val(\"\");\n }\n });\n\n $(\"#\" + shortName + \"_panel_\" + i).addClass(\"panel-default\").removeClass(\"alert-info\").removeClass(\"edited-component\");\n}\n\n/**\n * Make a data object uneditable\n *\n * Make the GUI pane for a given constellation object (short, i) un-editable. Sets up the edit and delete\n * buttons for first-order data objects, and calls the function to turn the elements back to text.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction makeUneditable(shortName, i) {\n // Make inputs read-only\n var idstr = \"_\" + i;\n\n subMakeUneditable(shortName, i);\n\n // restore the edit button\n $(\"#\" + shortName + \"_editbutton_\" + i).addClass(\"list-group-item-info\").removeClass(\"list-group-item-warning\");\n $(\"#\" + shortName + \"_editbutton_\" + i).html(\"
    Edit\");\n $(\"#\" + shortName + \"_editbutton_\" + i).off('click').on(\"click\", function () {\n makeEditable(shortName, i);\n });\n\n // restore the delete button\n $(\"#\" + shortName + \"_deletebutton_\" + i).addClass(\"list-group-item-danger\").removeClass(\"disabled\");\n $(\"#\" + shortName + \"_deletebutton_\" + i).off('click').on(\"click\", function () {\n setDeleted(shortName, i);\n });\n\n return false;\n}\n\n/**\n * Make an SCM data object editable\n *\n * Make the GUI pane for an SCM (j) of a given constellation object (short, i) editable. Sets up the edit and delete\n * buttons for first-order data objects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n * @return boolean False to play nice with the browser\n */\nfunction makeSCMEditable(shortName, i, j) {\n var id = j + \"_\" + i;\n var scmShortName = \"scm_\" + shortName;\n\n // No editing if it's already in edit mode\n if ($(\"#\" + scmShortName + \"_operation_\" + id).val() == \"update\") return false;\n // If it's deleted, then you better undelete it first\n if ($(\"#\" + scmShortName + \"_operation_\" + id).val() == \"delete\") setSCMDeleted(shortName, i, j);\n\n $(\"#\" + scmShortName + \"_editbutton_\" + id).removeClass(\"list-group-item-info\").addClass(\"list-group-item-warning\");\n $(\"#\" + scmShortName + \"_editbutton_\" + id).html(\"\");\n $(\"#\" + scmShortName + \"_editbutton_\" + id).off('click').on(\"click\", function () {\n undoSCMEdit(shortName, i, j);\n });\n $(\"#\" + scmShortName + \"_deletebutton_\" + id).removeClass(\"list-group-item-danger\").addClass(\"disabled\");\n $(\"#\" + scmShortName + \"_deletebutton_\" + id).off('click').on(\"click\", function () {\n return false;\n });\n\n $(\"#\" + scmShortName + \"_panel_\" + id).removeClass(\"panel-default\").addClass(\"alert-info\").addClass(\"edited-component\");\n\n return subMakeEditable(scmShortName, id);\n}\n\n/**\n * Make an SCM data object un-editable\n *\n * Make the GUI pane for an SCM object (j) for a given constellation object (short, i) un-editable. Sets up the edit and delete\n * buttons for SCM data objects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n * @return boolean False to play nice with the browser\n */\nfunction makeSCMUneditable(shortName, i, j) {\n\n // Make inputs read-only\n var idstr = j + \"_\" + i;\n\n subMakeUneditable('scm_' + shortName, idstr);\n\n // restore the edit button\n $(\"#scm_\" + shortName + \"_editbutton_\" + idstr).addClass(\"list-group-item-info\").removeClass(\"list-group-item-warning\");\n $(\"#scm_\" + shortName + \"_editbutton_\" + idstr).html(\"\");\n $(\"#scm_\" + shortName + \"_editbutton_\" + idstr).off('click').on(\"click\", function () {\n makeSCMEditable(shortName, i, j);\n });\n\n // restore the delete button\n $(\"#scm_\" + shortName + \"_deletebutton_\" + idstr).addClass(\"list-group-item-danger\").removeClass(\"disabled\");\n $(\"#scm_\" + shortName + \"_deletebutton_\" + idstr).off('click').on(\"click\", function () {\n setSCMDeleted(shortName, i, j);\n });\n\n return false;\n}\n\n/**\n * Set a Contributor Object as deleted\n *\n * Sets the contributor object (shortName, i) as deleted or undeleted and makes the appropriate changes.\n *\n * @param string shortName The short name of the contributor object.\n * @param string|int i The index within the edit page of the object.\n */\nfunction setRepeatedDataDeleted(shortName, i) {\n if ($(\"#\" + shortName + \"_operation_\" + i).val() != \"delete\") {\n $(\"#\" + shortName + \"_remove_\" + i).removeClass(\"btn-danger\").addClass(\"btn-warning\");\n $(\"#\" + shortName + \"_remove_\" + i).html(\"\");\n } else {\n $(\"#\" + shortName + \"_remove_\" + i).removeClass(\"btn-warning\").addClass(\"btn-danger\");\n $(\"#\" + shortName + \"_remove_\" + i).html(\"\");\n }\n\n return subSetDeleted(shortName, i);\n}\n\n/**\n * Set a first-order data object as deleted\n *\n * Sets a first-order data object (short, i) as deleted or undeleted and makes the appropriate changes throughout the page.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n */\nfunction setDeleted(short, i) {\n if ($(\"#\" + short + \"_operation_\" + i).val() != \"delete\") {\n // set deleted\n $(\"#\" + short + \"_deletebutton_\" + i).removeClass(\"list-group-item-danger\").addClass(\"list-group-item-warning\");\n $(\"#\" + short + \"_deletebutton_\" + i).html(\"
    Undo\");\n\n // disable edit button\n $(\"#\" + short + \"_editbutton_\" + i).removeClass(\"list-group-item-info\").addClass(\"disabled\");\n $(\"#\" + short + \"_editbutton_\" + i).off('click').on(\"click\", function () {\n return false;\n });\n\n // disable the Date button\n $(\"#\" + short + \"_datebutton_\" + i).removeClass(\"list-group-item-success\").addClass(\"disabled\").prop('disabled', true);\n\n // disable the SCM button\n $(\"#\" + short + \"_scmbutton_\" + i).removeClass(\"list-group-item-success\").addClass(\"disabled\").prop('disabled', true);\n } else {\n // set undelete\n $(\"#\" + short + \"_deletebutton_\" + i).removeClass(\"list-group-item-warning\").addClass(\"list-group-item-danger\");\n $(\"#\" + short + \"_deletebutton_\" + i).html(\"
    Trash\");\n\n // restore edit button\n $(\"#\" + short + \"_editbutton_\" + i).addClass(\"list-group-item-info\").removeClass(\"disabled\");\n $(\"#\" + short + \"_editbutton_\" + i).off('click').on(\"click\", function () {\n makeEditable(short, i);\n });\n\n // restore the Date button\n $(\"#\" + short + \"_datebutton_\" + i).addClass(\"list-group-item-success\").removeClass(\"disabled\").prop('disabled', false);\n\n // restore the SCM button\n $(\"#\" + short + \"_scmbutton_\" + i).addClass(\"list-group-item-success\").removeClass(\"disabled\").prop('disabled', false);\n }\n\n return subSetDeleted(short, i);\n}\n\n/**\n * Make the delete/undelete happen\n *\n * Actually performs the changes to the object, affecting the operation and panel color.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction subSetDeleted(short, i) {\n if ($(\"#\" + short + \"_operation_\" + i).val() != \"delete\") {\n // set deleted\n $(\"#\" + short + \"_panel_\" + i).removeClass(\"panel-default\").addClass(\"alert-danger\").addClass(\"deleted-component\");\n\n $(\"#\" + short + \"_operation_\" + i).val(\"delete\");\n } else {\n // set undelete\n $(\"#\" + short + \"_panel_\" + i).removeClass(\"alert-danger\").addClass(\"panel-default\").removeClass(\"deleted-component\");\n\n // If this thing was deleted but is supposed to be an update, then return it back to update status\n var sawSelect = false;\n $(\"select[id^='\" + short + \"_']\").each(function () {\n var obj = $(this);\n if (obj.attr('id').endsWith(\"_\" + i) && !obj.attr('id').endsWith(\"ZZ\")) {\n sawSelect = true;\n }\n });\n if (sawSelect) {\n if ($(\"#\" + short + \"_id_\" + i).val() != \"\") $(\"#\" + short + \"_operation_\" + i).val(\"update\");else $(\"#\" + short + \"_operation_\" + i).val(\"insert\");\n } else {\n $(\"#\" + short + \"_operation_\" + i).val(\"\");\n }\n }\n\n // Asked to delete something, so make it globally known\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n return false;\n}\n\n/**\n * Set an SCM data object as deleted\n *\n * Sets an SCM object (j) for a constellation object (short, i) as deleted or undeleted and makes the appropriate changes throughout the page.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n */\nfunction setSCMDeleted(short, i, j) {\n var id = j + '_' + i;\n if ($(\"#scm_\" + short + \"_operation_\" + id).val() != \"delete\") {\n // set deleted\n $(\"#scm_\" + short + \"_deletebutton_\" + id).removeClass(\"list-group-item-danger\").addClass(\"list-group-item-warning\");\n $(\"#scm_\" + short + \"_deletebutton_\" + id).html(\"\");\n\n // disable edit button\n $(\"#scm_\" + short + \"_editbutton_\" + id).removeClass(\"list-group-item-info\").addClass(\"disabled\");\n $(\"#scm_\" + short + \"_editbutton_\" + id).off('click').on(\"click\", function () {\n return false;\n });\n } else {\n // set undelete\n $(\"#scm_\" + short + \"_deletebutton_\" + id).removeClass(\"list-group-item-warning\").addClass(\"list-group-item-danger\");\n $(\"#scm_\" + short + \"_deletebutton_\" + id).html(\"\");\n\n // restore edit button\n $(\"#scm_\" + short + \"_editbutton_\" + id).addClass(\"list-group-item-info\").removeClass(\"disabled\");\n $(\"#scm_\" + short + \"_editbutton_\" + id).off('click').on(\"click\", function () {\n makeSCMEditable(short, i, j);\n });\n }\n\n return subSetDeleted(\"scm_\" + short, id);\n}\n\n/**\n * Turn on the Edit/Delete buttons for an object\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n */\nfunction turnOnButtons(shortName, i) {\n\n // Turn on the edit button\n $(\"#\" + shortName + \"_editbutton_\" + i).on(\"click\", function () {\n makeEditable(shortName, i);\n });\n\n // Turn on the delete buttons\n $(\"#\" + shortName + \"_deletebutton_\" + i).on(\"click\", function () {\n setDeleted(shortName, i);\n });\n}\n\nfunction turnOnTooltips(shortName, i) {\n // Load tooltips\n $(function () {\n $('#' + shortName + '_panel_' + i + ' [data-toggle=\"tooltip\"]').tooltip();\n });\n\n // Load popovers\n $(function () {\n $('#' + shortName + '_panel_' + i + ' [data-toggle=\"popover\"]').popover({\n trigger: 'hover',\n container: 'body'\n });\n });\n}\n\n/**\n * Turn on the Edit/Delete buttons for an SCM object\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n */\nfunction turnOnSCMButtons(shortName, i, j) {\n\n // Turn on the edit button\n $(\"#scm_\" + shortName + \"_editbutton_\" + j + \"_\" + i).on(\"click\", function () {\n makeSCMEditable(shortName, i, j);\n });\n\n // Turn on the delete buttons\n $(\"#scm_\" + shortName + \"_deletebutton_\" + j + \"_\" + i).on(\"click\", function () {\n setSCMDeleted(shortName, i, j);\n });\n}\n\n/**\n * Create a new Address Line object on page\n *\n * Puts a new Place Address Line object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the place to add this component to\n * @return boolean false to play nice with the browser.\n */\nfunction newAddressLine(i) {\n var nextid = 1;\n if ($('#place_address_next_j_' + i).exists()) {\n nextid = parseInt($('#place_address_next_j_' + i).text());\n }\n console.log(\"Creating new address line for place \" + i + \" with id: \" + nextid);\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#addressline_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#place_address_add_div_' + i).before(html);\n\n $('#place_address_' + nextid + '_operation_' + 1).val(\"insert\");\n subMakeEditable(\"place_address_\" + nextid, i);\n\n vocab_select_replace($(\"#place_address_\" + nextid + \"_type_id_\" + i), \"_\" + i, 'address_part', 0);\n\n // Put the updated version number back in the DOM\n $('#place_address_next_j_' + i).text(++nextid);\n\n return false;\n}\n\n/**\n * Create a new Resource Relation Origination Name object on page\n *\n * Puts a new Resource Relation Origination Name object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the Resource Relation to add this Origination Name to\n * @return boolean false to play nice with the browser.\n */\nfunction newOriginationName(i) {\n var nextid = 1;\n if ($('#resource_originationName_next_j_' + i).exists()) {\n nextid = parseInt($('#resource_originationName_next_j_' + i).text());\n }\n console.log(\"Creating new origination name for resource \" + i + \" with id: \" + nextid);\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#originationName_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#resource_originationName_add_div_' + i).before(html);\n\n $('#resource_originationName_' + nextid + '_operation_' + 1).val(\"insert\");\n subMakeEditable(\"resource_originationName_\" + nextid, i);\n\n // Put the updated version number back in the DOM\n $('#resource_originationName_next_j_' + i).text(++nextid);\n\n return false;\n}\n\n/**\n * Create a new Name Entry Component object on page\n *\n * Puts a new Name Entry component object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the nameEntry to add this component to\n * @return boolean false to play nice with the browser.\n */\nfunction newNameEntryComponent(i) {\n removeParserButton(i);\n var nextid = 1;\n if ($('#nameEntry_component_next_j_' + i).exists()) {\n nextid = parseInt($('#nameEntry_component_next_j_' + i).text());\n }\n console.log(\"Creating new name entry component for nameEntry \" + i + \" with id: \" + nextid);\n\n // add parser btn if entity is person, and if no btn or other name components already exist\n if ($(\"#entityType\").val() === \"700\" && nextid == 0 && !$(\"#nameEntry_panel_\" + i).find('.name-parser').length && $(\"#nameEntry_component_1_panel_\" + i).length === 0) {\n $('#nameEntry_component_add_' + i).after('');\n }\n\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n var text = $('#component_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#nameEntry_component_add_div_' + i).before(html);\n\n $('#nameEntry_component_' + nextid + '_operation_' + 1).val(\"insert\");\n subMakeEditable(\"nameEntry_component_\" + nextid, i);\n\n vocab_select_replace($(\"#nameEntry_component_\" + nextid + \"_type_id_\" + i), \"_\" + i, 'name_component', 0);\n\n // Put the updated version number back in the DOM\n $('#nameEntry_component_next_j_' + i).text(++nextid);\n\n return false;\n}\n\nfunction updateNameEntryHeading(i) {\n var text = \"\";\n var components = [];\n\n $(\"#nameEntry_panel_\" + i + \" div[id^='nameEntry_component_']\").each(function () {\n var obj = $(this);\n if (!obj.hasClass(\"deleted-component\") && obj.attr('id').endsWith(\"_panel_\" + i) && !obj.attr('id').endsWith(\"ZZ\")) {\n var j = obj.attr('id').replace(\"nameEntry_component_\", \"\").replace(\"_panel_\" + i, \"\");\n var type = $(\"#nameEntry_component_\" + j + \"_type_id_\" + i + \" option:selected\").text();\n var partText = $(\"#nameEntry_component_\" + j + \"_text_\" + i).val();\n\n components.push([type, partText]);\n }\n });\n\n var entityType = $(\"#entityType option:selected\").text();\n text = combineNameHeading(components, entityType);\n\n $(\"#nameEntry_heading_\" + i).text(text.trim());\n $(\"#nameEntry_original_\" + i).val(text.trim());\n}\n\n/**\n * Create a new Name Entry Rules object on page\n *\n * Puts a new Name Entry rule object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the nameEntry to add this rule to\n * @return boolean false to play nice with the browser.\n */\nfunction newNameEntryRule(i) {\n var nextid = 1;\n if ($('#nameEntry_rule_next_j_' + i).exists()) {\n nextid = parseInt($('#nameEntry_rule_next_j_' + i).text());\n }\n console.log(\"Creating new name entry rule for nameEntry \" + i + \" with id: \" + nextid);\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#rule_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#nameEntry_rule_add_div_' + i).before(html);\n\n $('#nameEntry_rule_' + nextid + '_operation_' + 1).val(\"insert\");\n turnOnTooltips(\"nameEntry_rule_\" + nextid, i);\n subMakeEditable(\"nameEntry_rule_\" + nextid, i);\n\n // Put the updated version number back in the DOM\n $('#nameEntry_rule_next_j_' + i).text(++nextid);\n\n return false;\n}\n\n/**\n * Parse a date string into parts\n */\nfunction parseDate(dateString) {\n var pieces = dateString.split(\"-\");\n if (pieces.length == 3) return {\n year: parseInt(pieces[0]),\n month: parseInt(pieces[1]),\n day: parseInt(pieces[2])\n };else if (pieces.length == 2) return {\n year: parseInt(pieces[0]),\n month: parseInt(pieces[1]),\n day: ''\n };else if (pieces.length == 1 && pieces[0] != '') return {\n year: parseInt(pieces[0]),\n month: '',\n day: ''\n };else return {\n year: '', month: '', day: ''\n };\n}\n\n/**\n * Change date input divs to select and boxes\n *\n * Changes all div's with id \"date_\" for a given data object (shortName, idStr) from a list of\n * inputs defining the parameters (view mode) to a inputs and a select (edit mode). It then\n * calls the select2 function to replace the select with one matching the rest of the page.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction textToDate(shortName, idStr) {\n $(\"div[id^='date_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"date_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var dateStr = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n\n var dateParts = parseDate(dateStr);\n\n var html = \"\";\n html += \" - \";\n html += \" \";\n html += \" - \";\n html += \" \";\n html += \"\";\n cont.html(html);\n\n $(\"#\" + shortName + \"_\" + name + \"_month_\" + idStr).select2({\n width: '57%',\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Month'\n });\n }\n });\n}\n\n/**\n * Pad an integer\n *\n * This is a helper function to pad an integer with 0s for display. This is useful to pad\n * a month or day with a leading 0.\n *\n * @param int|string num The number to pad\n * @param int size The total width of the desired output\n * @return string A string containing a size-wide integer representation, 0-padded\n */\nfunction pad(num, size) {\n var s = num + \"\";\n while (s.length < size) s = \"0\" + s;\n return s;\n}\n\n/**\n * Updates the standard date input field\n *\n * If the date for the data object (shortName, idStr) has been turned into a 3-field edit\n * area, then this function will update the hidden standard date (YYYY-MM-DD) field with the\n * newest values from the human-enterable field.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction updateDate(shortName, idStr) {\n $(\"div[id^='date_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"date_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n\n if ($(\"#\" + shortName + \"_\" + name + \"_year_\" + idStr).exists()) {\n var year = $(\"#\" + shortName + \"_\" + name + \"_year_\" + idStr).val();\n var day = $(\"#\" + shortName + \"_\" + name + \"_day_\" + idStr).val();\n var month = $(\"#\" + shortName + \"_\" + name + \"_month_\" + idStr + \" option:selected\").val();\n\n var dateStr = \"\";\n if (year != \"\") {\n dateStr += pad(year, 4);\n if (month != \"\") {\n dateStr += \"-\" + pad(month, 2);\n if (day != \"\") {\n dateStr += \"-\" + pad(day, 2);\n }\n }\n }\n\n $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val(dateStr);\n }\n }\n });\n}\n\n/**\n * Return editable date area back to text\n *\n * If the date for the data object (shortName, idStr) has been turned into a 3-field edit\n * area, then this function will return the editable area back to the view mode text, replacing\n * the edit boxes with a paragraph containing the computed standard date string (YYYY-MM-DD).\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction dateToText(shortName, idStr) {\n $(\"div[id^='date_\" + shortName + \"']\").each(function () {\n var cont = $(this);\n if (cont.attr('id').endsWith(\"_\" + idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"date_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\" + idStr + \"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n\n updateDate(shortName, idStr);\n\n var dateStr = $(\"#\" + shortName + \"_\" + name + \"_\" + idStr).val();\n\n var html = \"

    \" + dateStr + \"

    \";\n html += \"\";\n cont.html(html);\n }\n });\n}\n\n// TODO: If we want to show a DIV of edited and deleted components, we should use the following two functions\n// to get copies of the edited/deleted components from the page. We can then insert those copies onto a modal\n// dialog box with a \"Save\" or \"Continue\" button at the top and bottom.\n//\n// All the pieces shown in the dialog should be disabled. One way to do this would be using the following\n// method to place a semi-transparent div on top of the editable pieces, making them appear to be grayed out\n// and with the not permitted cursor.\n//\n// .append('
    ');\n//\n// Note: this modal should NOT be inside the constellation form so that we don't submit the values twice.\n\n/**\n * Get all the edited components\n */\nfunction getEdited() {\n var html = \"\";\n\n $(\"#constellation_form div.edited-component\").each(function () {\n var cont = $(this);\n console.log(cont.attr('id'));\n var pieces = cont.attr('id').split(\"_panel_\");\n if (pieces.length == 2) {\n html += \"
    \" + $(\"#\" + pieces[0] + \"_datapart_\" + pieces[1]).html() + \"
    \";\n }\n });\n\n return html;\n}\n\n/**\n * Get all the deleted components\n */\nfunction getDeleted() {\n var html = \"\";\n\n $(\"#constellation_form div.deleted-component\").each(function () {\n var cont = $(this);\n console.log(cont.attr('id'));\n var pieces = cont.attr('id').split(\"_panel_\");\n if (pieces.length == 2) {\n html += \"
    \" + $(\"#\" + pieces[0] + \"_datapart_\" + pieces[1]).html() + \"
    \";\n }\n });\n\n return html;\n}\n\nfunction turnOnEditDeleteButtons(part = '') {\n var divID = '';\n if (part != '') divID = \"#\" + part + \" \";\n // Turn on the edit buttons\n $(divID + \"a[id*='editbutton']\").each(function () {\n var obj = $(this);\n var pieces = obj.attr('id').split(\"_\");\n\n if (pieces.length == 3) {\n var short = pieces[0];\n var i = pieces[2];\n obj.on(\"click\", function () {\n makeEditable(short, i);\n });\n } else if (pieces.length == 5 && pieces[0] == \"scm\") {\n var short = pieces[1];\n var i = pieces[4];\n var j = pieces[3];\n obj.on(\"click\", function () {\n makeSCMEditable(short, i, j);\n });\n } else if (pieces.length == 5) {\n var short = pieces[0] + \"_\" + pieces[1] + \"_\" + pieces[2];\n var i = pieces[4];\n obj.on(\"click\", function () {\n makeEditable(short, i);\n });\n }\n });\n\n // Turn on the delete buttons\n $(divID + \"a[id*='deletebutton']\").each(function () {\n var obj = $(this);\n var pieces = obj.attr('id').split(\"_\");\n\n if (pieces.length == 3) {\n var short = pieces[0];\n var i = pieces[2];\n obj.on(\"click\", function () {\n setDeleted(short, i);\n });\n } else if (pieces.length == 5 && pieces[0] == \"scm\") {\n var short = pieces[1];\n var i = pieces[4];\n var j = pieces[3];\n obj.on(\"click\", function () {\n setSCMDeleted(short, i, j);\n });\n } else if (pieces.length == 5) {\n var short = pieces[0] + \"_\" + pieces[1] + \"_\" + pieces[2];\n var i = pieces[4];\n obj.on(\"click\", function () {\n setDeleted(short, i);\n });\n }\n });\n}\n\nfunction turnOnTooltipsForTab(part = '') {\n var divID = '';\n if (part != '') divID = \"#\" + part + \" \";\n // Load tooltips\n $(function () {\n $(divID + '[data-toggle=\"tooltip\"]').tooltip();\n });\n\n // Load popovers\n $(function () {\n $(divID + '[data-toggle=\"popover\"]').popover({\n trigger: 'hover',\n container: 'body'\n });\n });\n}\n\nfunction updatePictureArrow(shortName, i, newValue) {\n $('#' + shortName + '_relationPictureArrow_' + i).text(newValue);\n}\n\nfunction updatePictureTitle(shortName, i, newValue) {\n $('#' + shortName + '_relationPictureTitle_' + i).text(newValue);\n}\n\nfunction updatePictureIcon(shortName, i, entityType) {\n var html = \"\";\n if (entityType == 'person') html = '
    ';else if (entityType == 'corporateBody') html = '
    ';else if (entityType == 'family') html = '
    ';\n $('#' + shortName + '_relationPictureIcon_' + i).html(html);\n}\n\nvar geoPlaceLoadResults = null;\n\nfunction loadGeoPlaceResultCache() {\n $(\"input[id^='place_geoplace_id_']\").each(function () {\n var obj = $(this);\n // Query for term by ajax\n if (obj.val() != null && obj.val() != \"\") {\n $.get(snacUrl + \"/vocabulary/read?type=geoPlace&id=\" + obj.val(), null, function (data) {\n // Check the return value from the ajax. If success, then go to dashboard\n if (data.term) {\n if (!geoPlaceLoadResults) geoPlaceLoadResults = new Array();\n geoPlaceLoadResults.push(data.term);\n }\n });\n }\n });\n}\n\nfunction chooseSuggestedGeoPlace(selectID, idStr, value) {\n // idStr == id number on the page\n var obj = $(\"#\" + selectID);\n obj.select2('destroy');\n obj.val(value);\n geovocab_select_replace(obj, \"_\" + idStr);\n updatePlaceHeading(\"place\", idStr, value);\n}\n\nfunction updatePlaceHeading(shortName, i, newValue) {\n var place = null;\n if (!geoPlaceSearchResults && !geoPlaceLoadResults) {\n $('#' + shortName + '_confirmed_' + i).val(\"false\");\n $('#' + shortName + '_geoterm_text_' + i).html(\"Unconfirmed\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).addClass(\"disabled\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).prop('onclick', null).off(\"click\");\n if ($('#' + shortName + '_original_' + i).val() != \"\") $('#' + shortName + '_geoterm_caption_' + i).text(\"Recorded as: \" + $('#' + shortName + '_original_' + i).val());else $('#' + shortName + '_geoterm_caption_' + i).text();\n return;\n }\n\n if (geoPlaceSearchResults) {\n geoPlaceSearchResults.forEach(function (result) {\n if (result.id == newValue) place = result;\n });\n }\n\n if (!place && geoPlaceLoadResults) {\n geoPlaceLoadResults.forEach(function (result) {\n if (result.id == newValue) place = result;\n });\n }\n\n if (!place) {\n $('#' + shortName + '_confirmed_' + i).val(\"false\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).addClass(\"disabled\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).off(\"click\");\n if ($('#' + shortName + '_original_' + i).val() != \"\") {\n $('#' + shortName + '_geoterm_text_' + i).html(\"Unconfirmed\");\n $('#' + shortName + '_geoterm_caption_' + i).text(\"Recorded as: \" + $('#' + shortName + '_original_' + i).val());\n } else {\n $('#' + shortName + '_geoterm_text_' + i).text(\"--\");\n $('#' + shortName + '_geoterm_caption_' + i).text(\"GeoPlace term not specified\");\n }\n return;\n }\n $('#' + shortName + '_confirmed_' + i).val(\"true\");\n $('#' + shortName + '_geoterm_text_' + i).text(place.name);\n $('#' + shortName + '_geoterm_caption_' + i).text(place.administrationCode + \", \" + place.countryCode);\n if (place.latitude && place.longitude) {\n $('#' + shortName + \"_geoterm_maplink_\" + i).prop('onclick', null).off(\"click\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).on(\"click\", function () {\n openGeoPlaceViewer(place.id);return false;\n });\n $('#' + shortName + \"_geoterm_maplink_\" + i).removeClass(\"disabled\");\n } else {\n $('#' + shortName + \"_geoterm_maplink_\" + i).addClass(\"disabled\");\n $('#' + shortName + \"_geoterm_maplink_\" + i).prop('onclick', null).off(\"click\");\n }\n}\n\nfunction magicDefaultFill(selectID, vocabType) {\n if (typeof defaults[vocabType] !== undefined) {\n\n var data = {\n id: defaults[vocabType].id,\n text: defaults[vocabType].term\n };\n\n // If the selected item exists, then select it. Else, add a new option\n // and select it.\n if ($('#' + selectID).find(\"option[value='\" + data.id + \"']\").length) {\n $('#' + selectID).val(data.id).trigger('change');\n } else {\n var newOption = new Option(data.text, data.id, false, true);\n $('#' + selectID).append(newOption).trigger('change');\n }\n }\n}\n\nfunction capitalize(word) {\n return word[0].toUpperCase() + word.slice(1);\n}\n\nfunction parseName(e) {\n $('#name-parser-options').text('');\n var $nameComponents = $(e.target).closest('.name-components');\n\n var $partType = $nameComponents.find(\"select:last\");\n var $textbox = $nameComponents.find('input[type=\"text\"]:last');\n\n var name = $textbox.val();\n\n var entityType = $('#entityType').text().trim();\n $('#name-parser-type').text(capitalize(entityType));\n $('#name-parser-original').text(name);\n\n var parser = new NameParser();\n var guesses = parser.guessPerson(name);\n\n var parsedOption = '';\n\n var counter = 0;\n guesses.forEach(function (guess) {\n // attach name data object to radio\n for (var key in guess) {\n if (guess[key] && guess[key].length != 0) {\n parsedOption += \"
  • \" + key + \": \" + guess[key] + \"
  • \";\n }\n }\n\n $('#name-parser-options').append(\"
    \" + \"
    \");\n\n $('#name-parser-options').find(\"input[type='radio']:last\").data(\"parsed-name\", guess);\n\n parsedOption = '';\n counter++;\n });\n\n $('#name-parser-options').find(\"input[type='radio']:first\").prop('checked', true);\n\n $('#parser-accept-btn').unbind('click');\n $('#parser-accept-btn').on('click', function () {\n var selectedName = $('#name-parser input[type=\"radio\"]:checked').data('parsed-name');\n $.get(snacUrl + \"/vocabulary/?type=name_component&entity_type=700\").done(function (data) {\n acceptParsedName(selectedName, $nameComponents, name, data.results);\n });\n });\n}\n\nfunction acceptParsedName(selectedName, $nameComponents, name, nameComponentIDs) {\n var i = $nameComponents.attr('id').split('_')[2];\n var $nameComponent = $nameComponents.find('.reorderable'); ///\n $nameComponent.replaceWith('
    Name: ' + name + '
    ');\n\n var nameComponentMap = {};\n\n for (var k = 0; k < nameComponentIDs.length; k++) {\n nameComponentMap[nameComponentIDs[k].text] = nameComponentIDs[k].id;\n }\n // var nameComponentMap = {\n // 'Surname': 400223,\n // 'Forename': 400224,\n // 'NameAddition': 400236,\n // 'Date': 400237,\n // 'NameExpansion': 400226,\n // 'Numeration': 400225\n // };\n\n for (var key in selectedName) {\n if (key == 'NameAdditions') {\n key = 'NameAddition';\n for (var j = 0; j < selectedName['NameAdditions'].length; j++) {\n newNameEntryComponent(i);\n var option = new Option(key, nameComponentMap[key], false, true);\n $partType = $nameComponents.find(\"select:last\");\n $partType.append(option).trigger('change');\n $textbox = $nameComponents.find(\"input[type='text']:last\");\n $textbox.val(selectedName[\"NameAdditions\"][j]);\n\n $partType.append(option).trigger('change');\n }\n } else if (selectedName[key] && nameComponentMap[key]) {\n newNameEntryComponent(i);\n var option = new Option(key, nameComponentMap[key], false, true);\n $partType = $nameComponents.find(\"select:last\");\n $partType.append(option).trigger('change');\n $textbox = $nameComponents.find(\"input[type='text']:last\");\n $textbox.val(selectedName[key]);\n\n $partType.append(option).trigger('change');\n }\n }\n\n $(\"#nameEntry_datapart_\" + i).find(\".name-parser\").remove();\n updateNameEntryHeading(i);\n}\n\nfunction removeParserButton(i) {\n $('#nameEntry_datapart_' + i).find('.name-parser').remove();\n}\n\n/**\n * Things to do when the page finishes loading\n */\n$(document).ready(function () {\n // Load the place cache, if needed\n loadGeoPlaceResultCache();\n\n // listen for name-parsing\n $('#nameEntries').on('click', '.name-parser', function (event) {\n event.preventDefault();\n parseName(event);\n $(\"#name-parser\").modal('toggle');\n });\n\n $('#name-parser').on('shown.bs.modal', function () {\n $('#parser-accept-btn').focus();\n });\n\n // If the constellation is in \"insert\" mode, then we should automatically set \"somethingHasBeenEdited\"\n // to be true...\n if ($('#operation').val() == 'insert') setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n turnOnEditDeleteButtons();\n\n // Attach functions to the entityType select\n if ($('#entityType').exists()) {\n $('#entityType').change(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n // If there is an ID, then we need to set this to update\n // Else, the main-level operation should be and remain insert\n if ($('#constellationid').val() != null && $('#constellationid').val() != \"\") {\n $('#operation').val(\"update\");\n }\n });\n }\n\n // Name Entry doesn't get any AJAX, since it is pre-loaded\n var nameEntryid = 1;\n if ($('#next_nameEntry_i').exists()) {\n nameEntryid = parseInt($('#next_nameEntry_i').text());\n }\n console.log(\"Next NameEntry ID: \" + nameEntryid);\n if ($('#btn_add_nameEntry').exists()) {\n $('#btn_add_nameEntry').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#nameEntry_template').clone();\n var html = text.html().replace(/ZZ/g, nameEntryid);\n $('#add_nameEntry_div').after(html);\n turnOnButtons(\"nameEntry\", nameEntryid);\n turnOnTooltips(\"nameEntry\", nameEntryid);\n makeEditable(\"nameEntry\", nameEntryid);\n nameEntryid = nameEntryid + 1;\n return false;\n });\n }\n\n // Attach functions to each of the \"+ Add New _______\" buttons\n\n // Code to handle adding new genders to the page\n var genderid = 1;\n var genderOpen = false;\n if ($('#genderstab').exists()) {\n $('#genderstab').click(function () {\n // Don't open a second time\n if (genderOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=genders\", null, function (data) {\n genderOpen = true;\n $('#genders').html(data);\n\n turnOnEditDeleteButtons(\"genders\");\n\n if ($('#next_gender_i').exists()) {\n genderid = parseInt($('#next_gender_i').text());\n }\n console.log(\"Next Gender ID: \" + genderid);\n if ($('#btn_add_gender').exists()) {\n $('#btn_add_gender').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#gender_template').clone();\n var html = text.html().replace(/ZZ/g, genderid);\n $('#add_gender_div').after(html);\n turnOnButtons(\"gender\", genderid);\n turnOnTooltips(\"gender\", genderid);\n makeEditable(\"gender\", genderid);\n genderid = genderid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"genders\");\n });\n });\n }\n\n // Code to handle adding new genders to the page\n var existid = 1;\n var existOpen = false;\n if ($('#existstab').exists()) {\n $('#existstab').click(function () {\n // Don't open a second time\n if (existOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=dates\", null, function (data) {\n existOpen = true;\n $('#dates').html(data);\n\n turnOnEditDeleteButtons(\"dates\");\n\n if ($('#next_exist_i').exists()) {\n existid = parseInt($('#next_exist_i').text());\n }\n console.log(\"Next Exist Date ID: \" + existid);\n if ($('#btn_add_exist_date').exists()) {\n $('#btn_add_exist_date').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#exist_date_template').clone();\n var html = text.html().replace(/ZZ/g, existid);\n $('#add_exist_div').after(html);\n turnOnButtons(\"exist\", existid);\n turnOnTooltips(\"exist\", existid);\n makeEditable(\"exist\", existid);\n existid = existid + 1;\n return false;\n });\n }\n if ($('#btn_add_exist_dateRange').exists()) {\n $('#btn_add_exist_dateRange').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#exist_dateRange_template').clone();\n var html = text.html().replace(/ZZ/g, existid);\n $('#add_exist_div').after(html);\n turnOnButtons(\"exist\", existid);\n turnOnTooltips(\"exist\", existid);\n makeEditable(\"exist\", existid);\n existid = existid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"dates\");\n });\n });\n }\n\n var sameAsid = 1;\n var sameAsOpen = false;\n if ($('#sameAstab').exists()) {\n $('#sameAstab').click(function () {\n // Don't open a second time\n if (sameAsOpen) return;\n //set sameAs vocab type id\n $.get(snacUrl + \"/vocabulary?type=record_type&q=SameAs\", null, function (data) {\n sameAsTermId = data.results[0].id;\n $(\"#sameAs_type_id_ZZ\").val(sameAsTermId);\n });\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=sameAs\", null, function (data) {\n sameAsOpen = true;\n $('#sameAs').html(data);\n\n turnOnEditDeleteButtons(\"sameAs\");\n\n if ($('#next_sameAs_i').exists()) {\n sameAsid = parseInt($('#next_sameAs_i').text());\n }\n console.log(\"Next sameAs ID: \" + sameAsid);\n if ($('#btn_add_sameAs').exists()) {\n $('#btn_add_sameAs').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#sameAs_template').clone();\n var html = text.html().replace(/ZZ/g, sameAsid);\n $('#add_sameAs_div').after(html);\n turnOnButtons(\"sameAs\", sameAsid);\n turnOnTooltips(\"sameAs\", sameAsid);\n makeEditable(\"sameAs\", sameAsid);\n sameAsid = sameAsid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"sameAs\");\n });\n });\n }\n\n var entityIDid = 1;\n var entityIDOpen = false;\n if ($('#entityIDtab').exists()) {\n $('#entityIDtab').click(function () {\n // Don't open a second time\n if (entityIDOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=entityID\", null, function (data) {\n entityIDOpen = true;\n $('#entityID').html(data);\n\n turnOnEditDeleteButtons(\"entityID\");\n\n if ($('#next_entityID_i').exists()) {\n entityIDid = parseInt($('#next_entityID_i').text());\n }\n console.log(\"Next entityID ID: \" + entityIDid);\n if ($('#btn_add_entityID').exists()) {\n $('#btn_add_entityID').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#entityID_template').clone();\n var html = text.html().replace(/ZZ/g, entityIDid);\n $('#add_entityID_div').after(html);\n turnOnButtons(\"entityID\", entityIDid);\n turnOnTooltips(\"entityID\", entityIDid);\n makeEditable(\"entityID\", entityIDid);\n entityIDid = entityIDid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"entityID\");\n });\n });\n }\n\n var sourceid = 1;\n var sourceOpen = false;\n if ($('#sourcestab').exists()) {\n $('#sourcestab').click(function () {\n // Don't open a second time\n if (sourceOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=sources\", null, function (data) {\n sourceOpen = true;\n $('#sources').html(data);\n\n turnOnEditDeleteButtons(\"sources\");\n\n if ($('#next_source_i').exists()) {\n sourceid = parseInt($('#next_source_i').text());\n }\n console.log(\"Next source ID: \" + sourceid);\n if ($('#btn_add_source').exists()) {\n $('#btn_add_source').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#source_template').clone();\n var html = text.html().replace(/ZZ/g, sourceid);\n $('#add_source_div').after(html);\n turnOnButtons(\"source\", sourceid);\n turnOnTooltips(\"source\", sourceid);\n makeEditable(\"source\", sourceid);\n sourceid = sourceid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"sources\");\n });\n });\n }\n\n var resourceRelationid = 1;\n var resourceRelationOpen = false;\n if ($('#resourceRelationstab').exists()) {\n $('#resourceRelationstab').click(function () {\n // Don't open a second time\n if (resourceRelationOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=resourceRelations\", null, function (data) {\n resourceRelationOpen = true;\n $('#resourceRelations').html(data);\n\n turnOnEditDeleteButtons(\"resourceRelations\");\n\n if ($('#next_resourceRelation_i').exists()) {\n resourceRelationid = parseInt($('#next_resourceRelation_i').text());\n }\n console.log(\"Next resourceRelation ID: \" + resourceRelationid);\n if ($('#btn_create_resourceRelation').exists()) {\n $('#btn_create_resourceRelation').click(function () {\n var rid = $('input[name=resourceChoice]:checked', '#resource_search_form').val();\n if (rid != null && resourceResults != null && rid != 'new') {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#resourceRelation_template').clone();\n var html = text.html().replace(/ZZ/g, resourceRelationid);\n $('#add_resourceRelation_div').after(html);\n\n if (typeof resourceResults[rid].id !== 'undefined') $('#resourceRelation_resourceid_' + resourceRelationid).val(resourceResults[rid].id);\n if (typeof resourceResults[rid].version !== 'undefined') $('#resourceRelation_resourceversion_' + resourceRelationid).val(resourceResults[rid].version);\n\n if (typeof resourceResults[rid].link !== 'undefined') $('#resourceRelation_linkText_' + resourceRelationid).html(\"\" + resourceResults[rid].link + \"\" + \" View\");\n if (typeof resourceResults[rid].displayEntry !== 'undefined') $('#resourceRelation_displayEntryText_' + resourceRelationid).text(resourceResults[rid].displayEntry);\n if (typeof resourceResults[rid].title !== 'undefined') {\n $('#resourceRelation_titleText_' + resourceRelationid).text(resourceResults[rid].title);\n updatePictureTitle('resourceRelation', resourceRelationid, resourceResults[rid].title);\n }\n if (typeof resourceResults[rid].abstract !== 'undefined') $('#resourceRelation_abstractText_' + resourceRelationid).text(resourceResults[rid].abstract);\n if (typeof resourceResults[rid].extent !== 'undefined') $('#resourceRelation_extentText_' + resourceRelationid).text(resourceResults[rid].extent);\n // if (typeof resourceResults[rid].date !== 'undefined')\n // $('#resourceRelation_dateText_'+resourceRelationid).text(resourceResults[rid].date);\n if (typeof resourceResults[rid].documentType !== 'undefined' && typeof resourceResults[rid].documentType.term !== 'undefined') $('#resourceRelation_documentTypeText_' + resourceRelationid).text(resourceResults[rid].documentType.term);\n\n $('#resourceRelation_linkText_' + resourceRelationid).after(\"View in SNAC\");\n turnOnButtons(\"resourceRelation\", resourceRelationid);\n turnOnTooltips(\"resourceRelation\", resourceRelationid);\n makeEditable(\"resourceRelation\", resourceRelationid);\n resourceRelationid = resourceRelationid + 1;\n $(\"#resource-results-box\").html(\"\");\n return true;\n }\n return false;\n });\n }\n\n if ($('#btn_open_create_resource').exists()) {\n $('#btn_open_create_resource').click(function () {\n // Close this modal and open the new modal\n $(\"#resourceSearchPane\").modal(\"hide\");\n\n // Set a 500ms timeout to give the hidden search pane time to fully close\n setTimeout(function () {\n $(\"#resourceCreatePane\").modal(\"show\");\n }, 500);\n\n // Grab the empty template and replace\n var text = $('#resource_template').clone();\n var html = text.html().replace(/ZZ/g, 0);\n $('#resource-create-box').html(html);\n var $resourceForm = $(\"#resource_create_form\");\n // Copy the search contents to title or href\n if ($(\"#resource-searchbox\").val().indexOf(\"http\") == -1) $resourceForm.find(\"#resource-title\").val($(\"#resource-searchbox\").val());else $resourceForm.find(\"#resource-url\").val($(\"#resource-searchbox\").val());\n\n $resourceForm.find('[data-toggle=\"popover\"]').popover({\n trigger: 'hover',\n container: 'body'\n });\n loadVocabSelectOptions($resourceForm.find(\"#resource-type-select\"), \"document_type\", \"Resource Type\");\n vocab_select_replace($resourceForm.find(\"#resource-repo\"), \"\", \"holding\", 3);\n $resourceForm.find(\"#new-resource-language-btn\").on(\"click\", newResourceLanguage);\n $resourceForm.find(\"#magic-resource-language-btn\").on(\"click\", magicNewResourceLanguage);\n\n $('#search-results-box').on(\"click\", \"a.list-group-item\", selectHoldingRepository);\n var timeoutID = null;\n $resourceForm.find('#searchbox').keyup(function () {\n clearTimeout(timeoutID);\n timeoutID = setTimeout(function () {\n setSearchPosition(0);searchAndUpdate();\n }, 500);\n });\n\n // Remove the search results from the other modal\n $(\"#resource-results-box\").html(\"\");\n return false;\n });\n }\n\n if ($('#btn_create_resource').exists()) {\n $('#resource_create_form').on(\"submit\", function () {\n // Remove leading and trailing whitespace\n if ($(\"#resource_create_form #resource-url\").val() == \"\") {\n if (!confirm('Are you sure you want to save without an HREF?')) {\n return;\n }\n }\n $(\"#resource_create_form input, textarea\").each(function () {\n $(this).val($.trim($(this).val()));\n });\n setDeletedResourceLanguageOperations($(\"#resource_create_form\"));\n\n $.post(snacUrl + \"/save_resource\", $(\"#resource_create_form\").serialize(), function (data) {\n if (typeof data.result !== 'undefined' && data.result !== 'false') {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#resourceRelation_template').clone();\n var html = text.html().replace(/ZZ/g, resourceRelationid); // clones DOM, replaces zz with next ids\n $('#add_resourceRelation_div').after(html);\n\n if (typeof data.resource.id !== 'undefined') $('#resourceRelation_resourceid_' + resourceRelationid).val(data.resource.id);\n if (typeof data.resource.version !== 'undefined') $('#resourceRelation_resourceversion_' + resourceRelationid).val(data.resource.version);\n\n if (typeof data.resource.link !== 'undefined') $('#resourceRelation_linkText_' + resourceRelationid).html(\"\" + data.resource.link + \"\" + \" View\");\n if (typeof data.resource.displayEntry !== 'undefined') $('#resourceRelation_displayEntryText_' + resourceRelationid).text(data.resource.displayEntry);\n if (typeof data.resource.title !== 'undefined') {\n $('#resourceRelation_titleText_' + resourceRelationid).text(data.resource.title);\n updatePictureTitle('resourceRelation', resourceRelationid, data.resource.title);\n }\n if (typeof data.resource.abstract !== 'undefined') $('#resourceRelation_abstractText_' + resourceRelationid).text(data.resource.abstract);\n if (typeof data.resource.extent !== 'undefined') $('#resourceRelation_extentText_' + resourceRelationid).text(data.resource.extent);\n if (typeof data.resource.documentType !== 'undefined' && typeof data.resource.documentType.term !== 'undefined') $('#resourceRelation_documentTypeText_' + resourceRelationid).text(data.resource.documentType.term);\n\n $('#resourceRelation_linkText_' + resourceRelationid).after(\"View in SNAC\");\n turnOnButtons(\"resourceRelation\", resourceRelationid);\n turnOnTooltips(\"resourceRelation\", resourceRelationid);\n makeEditable(\"resourceRelation\", resourceRelationid);\n resourceRelationid = resourceRelationid + 1;\n $(\"#resourceCreatePane\").modal(\"hide\");\n $('#resource-create-box').html(\"\");\n return true;\n } else {\n console.log(data);\n return false;\n }\n });\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"resourceRelations\");\n });\n });\n }\n\n var constellationRelationid = 1;\n var constellationRelationOpen = false;\n if ($('#constellationRelationstab').exists()) {\n $('#constellationRelationstab').click(function () {\n // Don't open a second time\n if (constellationRelationOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=constellationRelations\", null, function (data) {\n constellationRelationOpen = true;\n $('#constellationRelations').html(data);\n\n turnOnEditDeleteButtons(\"constellationRelations\");\n\n if ($('#next_constellationRelation_i').exists()) {\n constellationRelationid = parseInt($('#next_constellationRelation_i').text());\n }\n console.log(\"Next constellationRelation ID: \" + constellationRelationid);\n if ($('#btn_create_constellationRelation').exists()) {\n $('#btn_create_constellationRelation').click(function () {\n var cid = $('input[name=relationChoice]:checked', '#relation_search_form').val();\n if (cid != null) {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#constellationRelation_template').clone();\n var html = text.html().replace(/ZZ/g, constellationRelationid);\n $('#add_constellationRelation_div').after(html);\n $('#constellationRelation_targetID_' + constellationRelationid).val(cid);\n $('#constellationRelation_content_' + constellationRelationid).val($('#relationChoice_nameEntry_' + cid).val());\n $('#constellationRelation_targetArkID_' + constellationRelationid).val($('#relationChoice_arkID_' + cid).val());\n $('#constellationRelation_targetEntityType_' + constellationRelationid).val($('#relationChoice_entityType_' + cid).val());\n\n updatePictureIcon('constellationRelation', constellationRelationid, $('#relationChoice_entityTypeText_' + cid).val());\n updatePictureTitle('constellationRelation', constellationRelationid, $('#relationChoice_nameEntry_' + cid).val());\n\n $('#constellationRelation_contentText_' + constellationRelationid).text($('#relationChoice_nameEntry_' + cid).val());\n $('#constellationRelation_targetArkIDText_' + constellationRelationid).text($('#relationChoice_arkID_' + cid).val());\n\n turnOnButtons(\"constellationRelation\", constellationRelationid);\n turnOnTooltips(\"constellationRelation\", constellationRelationid);\n makeEditable(\"constellationRelation\", constellationRelationid);\n\n constellationRelationid = constellationRelationid + 1;\n\n return true;\n }\n\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"constellationRelations\");\n });\n });\n }\n\n var languageid = 1;\n var languageOpen = false;\n if ($('#languagesUsedtab').exists()) {\n $('#languagesUsedtab').click(function () {\n // Don't open a second time\n if (languageOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=languagesUsed\", null, function (data) {\n languageOpen = true;\n $('#languagesUsed').html(data);\n\n turnOnEditDeleteButtons(\"languagesUsed\");\n\n if ($('#next_language_i').exists()) {\n languageid = parseInt($('#next_language_i').text());\n }\n console.log(\"Next language ID: \" + languageid);\n if ($('#btn_add_language').exists()) {\n $('#btn_add_language').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#language_template').clone();\n var html = text.html().replace(/ZZ/g, languageid);\n $('#add_language_div').after(html);\n turnOnButtons(\"language\", languageid);\n turnOnTooltips(\"language\", languageid);\n makeEditable(\"language\", languageid);\n languageid = languageid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"languagesUsed\");\n });\n });\n }\n\n var subjectid = 1;\n var subjectOpen = false;\n if ($('#subjectstab').exists()) {\n $('#subjectstab').click(function () {\n // Don't open a second time\n if (subjectOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=subjects\", null, function (data) {\n subjectOpen = true;\n $('#subjects').html(data);\n\n turnOnEditDeleteButtons(\"subjects\");\n\n if ($('#next_subject_i').exists()) {\n subjectid = parseInt($('#next_subject_i').text());\n }\n console.log(\"Next subject ID: \" + subjectid);\n if ($('#btn_add_subject').exists()) {\n $('#btn_add_subject').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#subject_template').clone();\n var html = text.html().replace(/ZZ/g, subjectid);\n $('#add_subject_div').after(html);\n turnOnButtons(\"subject\", subjectid);\n turnOnTooltips(\"subject\", subjectid);\n makeEditable(\"subject\", subjectid);\n subjectid = subjectid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"subjects\");\n });\n });\n }\n\n var nationalityid = 1;\n var nationalityOpen = false;\n if ($('#nationalitiestab').exists()) {\n $('#nationalitiestab').click(function () {\n // Don't open a second time\n if (nationalityOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=nationalities\", null, function (data) {\n nationalityOpen = true;\n $('#nationalities').html(data);\n\n turnOnEditDeleteButtons(\"nationalities\");\n\n if ($('#next_nationality_i').exists()) {\n nationalityid = parseInt($('#next_nationality_i').text());\n }\n console.log(\"Next nationality ID: \" + nationalityid);\n if ($('#btn_add_nationality').exists()) {\n $('#btn_add_nationality').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#nationality_template').clone();\n var html = text.html().replace(/ZZ/g, nationalityid);\n $('#add_nationality_div').after(html);\n turnOnButtons(\"nationality\", nationalityid);\n turnOnTooltips(\"nationality\", nationalityid);\n makeEditable(\"nationality\", nationalityid);\n nationalityid = nationalityid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"nationalities\");\n });\n });\n }\n\n var functionid = 1;\n var functionOpen = false;\n if ($('#functionstab').exists()) {\n $('#functionstab').click(function () {\n // Don't open a second time\n if (functionOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=functions\", null, function (data) {\n functionOpen = true;\n $('#functions').html(data);\n\n turnOnEditDeleteButtons(\"functions\");\n\n if ($('#next_function_i').exists()) {\n functionid = parseInt($('#next_function_i').text());\n }\n console.log(\"Next function ID: \" + functionid);\n if ($('#btn_add_function').exists()) {\n $('#btn_add_function').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#function_template').clone();\n var html = text.html().replace(/ZZ/g, functionid);\n $('#add_function_div').after(html);\n turnOnButtons(\"function\", functionid);\n turnOnTooltips(\"function\", functionid);\n makeEditable(\"function\", functionid);\n functionid = functionid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"functions\");\n });\n });\n }\n\n var occupationid = 1;\n var occupationOpen = false;\n if ($('#occupationstab').exists()) {\n $('#occupationstab').click(function () {\n // Don't open a second time\n if (occupationOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=occupations\", null, function (data) {\n occupationOpen = true;\n $('#occupations').html(data);\n\n turnOnEditDeleteButtons(\"occupations\");\n\n if ($('#next_occupation_i').exists()) {\n occupationid = parseInt($('#next_occupation_i').text());\n }\n console.log(\"Next occupation ID: \" + occupationid);\n if ($('#btn_add_occupation').exists()) {\n $('#btn_add_occupation').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#occupation_template').clone();\n var html = text.html().replace(/ZZ/g, occupationid);\n $('#add_occupation_div').after(html);\n turnOnButtons(\"occupation\", occupationid);\n turnOnTooltips(\"occupation\", occupationid);\n makeEditable(\"occupation\", occupationid);\n occupationid = occupationid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"occupations\");\n });\n });\n }\n\n var legalStatusid = 1;\n var legalStatusOpen = false;\n if ($('#legalStatusestab').exists()) {\n $('#legalStatusestab').click(function () {\n // Don't open a second time\n if (legalStatusOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=legalStatuses\", null, function (data) {\n legalStatusOpen = true;\n $('#legalStatuses').html(data);\n\n turnOnEditDeleteButtons(\"legalStatuses\");\n\n if ($('#next_legalStatus_i').exists()) {\n legalStatusid = parseInt($('#next_legalStatus_i').text());\n }\n console.log(\"Next legalStatus ID: \" + legalStatusid);\n if ($('#btn_add_legalStatus').exists()) {\n $('#btn_add_legalStatus').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#legalStatus_template').clone();\n var html = text.html().replace(/ZZ/g, legalStatusid);\n $('#add_legalStatus_div').after(html);\n turnOnButtons(\"legalStatus\", legalStatusid);\n turnOnTooltips(\"legalStatus\", legalStatusid);\n makeEditable(\"legalStatus\", legalStatusid);\n legalStatusid = legalStatusid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"legalStatuses\");\n });\n });\n }\n\n var placeid = 1;\n var placeOpen = false;\n if ($('#placestab').exists()) {\n $('#placestab').click(function () {\n // Don't open a second time\n if (placeOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=places\", null, function (data) {\n placeOpen = true;\n $('#places').html(data);\n\n // Load the place cache, if needed\n loadGeoPlaceResultCache();\n\n turnOnEditDeleteButtons(\"places\");\n\n if ($('#next_place_i').exists()) {\n placeid = parseInt($('#next_place_i').text());\n }\n console.log(\"Next place ID: \" + placeid);\n if ($('#btn_add_place').exists()) {\n $('#btn_add_place').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#place_template').clone();\n var html = text.html().replace(/ZZ/g, placeid);\n $('#add_place_div').after(html);\n turnOnButtons(\"place\", placeid);\n turnOnTooltips(\"place\", placeid);\n makeEditable(\"place\", placeid);\n placeid = placeid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"places\");\n });\n });\n }\n\n var conventionDeclarationid = 1;\n var conventionDeclarationOpen = false;\n if ($('#conventionDeclarationstab').exists()) {\n $('#conventionDeclarationstab').click(function () {\n // Don't open a second time\n if (conventionDeclarationOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=conventionDeclarations\", null, function (data) {\n conventionDeclarationOpen = true;\n $('#conventionDeclarations').html(data);\n\n turnOnEditDeleteButtons(\"conventionDeclarations\");\n\n if ($('#next_conventionDeclaration_i').exists()) {\n conventionDeclarationid = parseInt($('#next_conventionDeclaration_i').text());\n }\n console.log(\"Next conventionDeclaration ID: \" + conventionDeclarationid);\n if ($('#btn_add_conventionDeclaration').exists()) {\n $('#btn_add_conventionDeclaration').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#conventionDeclaration_template').clone();\n var html = text.html().replace(/ZZ/g, conventionDeclarationid);\n $('#add_conventionDeclaration_div').after(html);\n turnOnButtons(\"conventionDeclaration\", conventionDeclarationid);\n turnOnTooltips(\"conventionDeclaration\", conventionDeclarationid);\n makeEditable(\"conventionDeclaration\", conventionDeclarationid);\n conventionDeclarationid = conventionDeclarationid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"conventionDeclarations\");\n });\n });\n }\n\n var generalContextid = 1;\n var generalContextOpen = false;\n if ($('#generalContextstab').exists()) {\n $('#generalContextstab').click(function () {\n // Don't open a second time\n if (generalContextOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=generalContexts\", null, function (data) {\n generalContextOpen = true;\n $('#generalContexts').html(data);\n\n turnOnEditDeleteButtons(\"generalContexts\");\n\n if ($('#next_generalContext_i').exists()) {\n generalContextid = parseInt($('#next_generalContext_i').text());\n }\n console.log(\"Next generalContext ID: \" + generalContextid);\n if ($('#btn_add_generalContext').exists()) {\n $('#btn_add_generalContext').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#generalContext_template').clone();\n var html = text.html().replace(/ZZ/g, generalContextid);\n $('#add_generalContext_div').after(html);\n turnOnButtons(\"generalContext\", generalContextid);\n turnOnTooltips(\"generalContext\", generalContextid);\n makeEditable(\"generalContext\", generalContextid);\n generalContextid = generalContextid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"generalContexts\");\n });\n });\n }\n\n var structureOrGenealogyid = 1;\n var structureOrGenealogyOpen = false;\n if ($('#structureOrGenealogiestab').exists()) {\n $('#structureOrGenealogiestab').click(function () {\n // Don't open a second time\n if (structureOrGenealogyOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=structureOrGenealogies\", null, function (data) {\n structureOrGenealogyOpen = true;\n $('#structureOrGenealogies').html(data);\n\n turnOnEditDeleteButtons(\"structureOrGenealogies\");\n\n if ($('#next_structureOrGenealogy_i').exists()) {\n structureOrGenealogyid = parseInt($('#next_structureOrGenealogy_i').text());\n }\n console.log(\"Next structureOrGenealogy ID: \" + structureOrGenealogyid);\n if ($('#btn_add_structureOrGenealogy').exists()) {\n $('#btn_add_structureOrGenealogy').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#structureOrGenealogy_template').clone();\n var html = text.html().replace(/ZZ/g, structureOrGenealogyid);\n $('#add_structureOrGenealogy_div').after(html);\n turnOnButtons(\"structureOrGenealogy\", structureOrGenealogyid);\n turnOnTooltips(\"structureOrGenealogy\", structureOrGenealogyid);\n makeEditable(\"structureOrGenealogy\", structureOrGenealogyid);\n structureOrGenealogyid = structureOrGenealogyid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"structureOrGenealogies\");\n });\n });\n }\n\n var mandateid = 1;\n var mandateOpen = false;\n if ($('#mandatestab').exists()) {\n $('#mandatestab').click(function () {\n // Don't open a second time\n if (mandateOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=mandates\", null, function (data) {\n mandateOpen = true;\n $('#mandates').html(data);\n\n turnOnEditDeleteButtons(\"mandates\");\n\n if ($('#next_mandate_i').exists()) {\n mandateid = parseInt($('#next_mandate_i').text());\n }\n console.log(\"Next mandate ID: \" + mandateid);\n if ($('#btn_add_mandate').exists()) {\n $('#btn_add_mandate').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#mandate_template').clone();\n var html = text.html().replace(/ZZ/g, mandateid);\n $('#add_mandate_div').after(html);\n turnOnButtons(\"mandate\", mandateid);\n turnOnTooltips(\"mandate\", mandateid);\n makeEditable(\"mandate\", mandateid);\n mandateid = mandateid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"mandates\");\n });\n });\n }\n\n var biogHistid = 1;\n var biogHistOpen = false;\n if ($('#biogHiststab').exists()) {\n $('#biogHiststab').click(function () {\n // Don't open a second time\n if (biogHistOpen) return;\n\n $.get(snacUrl + \"/edit_part/\" + $('#constellationid').val() + \"/\" + $('#version').val() + \"?part=biogHists\", null, function (data) {\n biogHistOpen = true;\n $('#biogHists').html(data);\n\n turnOnEditDeleteButtons(\"biogHists\");\n\n if ($('#next_biogHist_i').exists()) {\n biogHistid = parseInt($('#next_biogHist_i').text());\n }\n console.log(\"Next biogHist ID: \" + biogHistid);\n if ($('#btn_add_biogHist').exists()) {\n $('#btn_add_biogHist').click(function () {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#biogHist_template').clone();\n var html = text.html().replace(/ZZ/g, biogHistid);\n $('#add_biogHist_div').after(html);\n turnOnButtons(\"biogHist\", biogHistid);\n turnOnTooltips(\"biogHist\", biogHistid);\n makeEditable(\"biogHist\", biogHistid);\n biogHistid = biogHistid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"biogHists\");\n });\n });\n }\n\n turnOnTooltipsForTab();\n\n $(\"#info-dropdown\").click(function (e) {\n $(this).parent().toggleClass(\"open\");\n e.stopPropagation();\n });\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMy5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zcmMvdmlydHVhbGhvc3RzL3d3dy9qYXZhc2NyaXB0L3NyYy9lZGl0X3NjcmlwdHMuanM/N2I1OCJdLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIEVkaXQgU2NyaXB0c1xuICpcbiAqIFNjcmlwdHMgdXNlZCBpbiB0aGUgZWRpdCBwYWdlXG4gKlxuICogQGF1dGhvciBSb2JiaWUgSG90dFxuICogQGxpY2Vuc2UgaHR0cHM6Ly9vcGVuc291cmNlLm9yZy9saWNlbnNlcy9CU0QtMy1DbGF1c2UgQlNEIDMtQ2xhdXNlXG4gKiBAY29weXJpZ2h0IDIwMTUgdGhlIFJlY3RvciBhbmQgVmlzaXRvcnMgb2YgdGhlIFVuaXZlcnNpdHkgb2YgVmlyZ2luaWEsIGFuZFxuICogICAgICAgICAgIC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gICAgICAgICBpZiAoJChcIiNcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStcIl9wbGFjZWhvbGRlck9mZl9cIitpZFN0cikuZXhpc3RzKCkpIHtcbiAgICAgICAgICAgICAgICBwbGFjZWhvbGRlck9mZiA9ICQoXCIjXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfcGxhY2Vob2xkZXJPZmZfXCIraWRTdHIpLnZhbCgpO1xuICAgICAgICAgICAgfVxuXG5cbiAgICAgICAgICAgIHZhciBodG1sID0gXCI8aW5wdXQgaWQ9J1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX1wiK2lkU3RyK1wiJyBuYW1lPSdcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStcIl9cIitcbiAgICAgICAgICAgICAgICAgICAgaWRTdHIrXCInIHR5cGU9J2hpZGRlbicgdmFsdWU9XFxcIlwiO1xuICAgICAgICAgICAgaWYgKGNoZWNrZWQpXG4gICAgICAgICAgICAgICAgaHRtbCArPSBcImNoZWNrZWRcIjtcbiAgICAgICAgICAgIGh0bWwgKz1cIlxcXCIvPlwiO1xuXG4gICAgICAgICAgICBodG1sICs9IFwiPHAgY2xhc3M9J2Zvcm0tY29udHJvbC1zdGF0aWMnPlwiO1xuICAgICAgICAgICAgaWYgKGNoZWNrZWQpIHtcbiAgICAgICAgICAgICAgICBpZiAocGxhY2Vob2xkZXJPbiAhPSBcIlwiKVxuICAgICAgICAgICAgICAgICAgIGh0bWwgKz0gcGxhY2Vob2xkZXJPbjtcbiAgICAgICAgICAgICAgICBlbHNlXG4gICAgICAgICAgICAgICAgICAgaHRtbCArPSB2YWx1ZTtcbiAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgaWYgKHBsYWNlaG9sZGVyT2ZmICE9IFwiXCIpXG4gICAgICAgICAgICAgICAgICAgaHRtbCArPSBwbGFjZWhvbGRlck9mZjtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIGh0bWwgKz0gXCI8L3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IlwiO1xuICAgICAgICAgICAgaWYgKCQoXCIjXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfcGxhY2Vob2xkZXJfXCIraWRTdHIpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgcGxhY2Vob2xkZXIgPSAkKFwiI1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX3BsYWNlaG9sZGVyX1wiK2lkU3RyKS52YWwoKTtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgdmFyIG9uS2V5VXAgPSBcIlwiO1xuICAgICAgICAgICAgaWYgKCQoXCIjXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfb25LZXlVcF9cIitpZFN0cikuZXhpc3RzKCkpIHtcbiAgICAgICAgICAgICAgICBvbktleVVwID0gJChcIiNcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStcIl9vbktleVVwX1wiK2lkU3RyKS52YWwoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBvbktleVVwU3RyID0gXCJcIjtcbiAgICAgICAgICAgIGlmIChvbktleVVwICE9IFwiXCIpIHtcbiAgICAgICAgICAgICAgICBvbktleVVwU3RyID0gXCIgb25LZXlVcD0nXCIrb25LZXlVcCtcIicgXCI7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHZhciBodG1sID0gXCI8aW5wdXQgaWQ9J1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX1wiK2lkU3RyK1wiJyBuYW1lPSdcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStcIl9cIitcbiAgICAgICAgICAgICAgICAgICAgaWRTdHIrXCInIGNsYXNzPSdmb3JtLWNvbnRyb2wnIHR5cGU9J3RleHQnIHZhbHVlPVxcXCJcIisgdmFsdWUgK1wiXFxcIlwiK3NpemVTdHIgKyBvbktleVVwU3RyICtcbiAgICAgICAgICAgICAgICAgICAgXCJwbGFjZWhvbGRlcj1cXFwiXCIrcGxhY2Vob2xkZXIrXCJcXFwiLz5cIjtcbiAgICAgICAgICAgIGlmIChzaXplICE9IDApIHtcbiAgICAgICAgICAgICAgICAgICAgaHRtbCArPSBcIjxpbnB1dCB0eXBlPVxcXCJoaWRkZW5cXFwiIGlkPVxcXCJcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStcIl9zaXplX1wiK2lkU3RyK1wiXFxcIiBcIiArXG4gICAgICAgICAgICAgICAgICAgICAgICBcInZhbHVlPVxcXCJcIitzaXplK1wiXFxcIi8+XCI7XG4gICAgICAgICAgICB9XG4gICAgICAgICAgICBpZiAocGxhY2Vob2xkZXIgIT0gXCJcIikge1xuICAgICAgICAgICAgICAgIGh0bWwgKz0gXCI8aW5wdXQgdHlwZT1cXFwiaGlkZGVuXFxcIiBpZD1cXFwiXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfcGxhY2Vob2xkZXJfXCIraWRTdHIrXCJcXFwiIFwiICtcbiAgICAgICAgICAgICAgICBcInZhbHVlPVxcXCJcIitwbGFjZWhvbGRlcitcIlxcXCIvPlwiO1xuICAgICAgICAgICAgfVxuICAgICAgICAgICAgaWYgKG9uS2V5VXAgIT0gXCJcIikge1xuICAgICAgICAgICAgICAgIGh0bWwgKz0gXCI8aW5wdXQgdHlwZT1cXFwiaGlkZGVuXFxcIiBpZD1cXFwiXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfb25LZXlVcF9cIitpZFN0citcIlxcXCIgXCIgK1xuICAgICAgICAgICAgICAgIFwidmFsdWU9XFxcIlwiK29uS2V5VXArXCJcXFwiLz5cIjtcbiAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgY29udC5odG1sKGh0bWwpO1xuICAgICAgICB9XG4gICAgfSk7XG5cblxufVxuXG5cbmZ1bmN0aW9uIGlucHV0VG9UZXh0KHNob3J0TmFtZSwgaWRTdHIpIHtcbiAgICAkKFwiI1wiK3Nob3J0TmFtZStcIl9kYXRhcGFydF9cIiArIGlkU3RyICsgXCIgZGl2W2lkXj0ndGV4dF9cIitz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XIgPSBcIlwiO1xuICAgICAgICAgICAgaWYgKCQoXCIjXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfcGxhY2Vob2xkZXJfXCIraWRTdHIpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgcGxhY2Vob2xkZXIgPSAkKFwiI1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX3BsYWNlaG9sZGVyX1wiK2lkU3RyKS52YWwoKTtcbiAgICAgICAgICAgIH1cbiAgICAgICAgICAgIHZhciBvbktleVVwID0gXCJcIjtcbiAgICAgICAgICAgIGlmICgkKFwiI1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX29uS2V5VXBfXCIraWRTdHIpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgb25LZXlVcCA9ICQoXCIjXCIrc2hvcnROYW1lK1wiX1wiK25hbWUrXCJfb25LZXlVcF9cIitpZFN0cikudmFsKCk7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgICAgIHZhciBodG1sID0gXCI8aW5wdXQgaWQ9J1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX1wiK2lkU3RyK1wiJyBuYW1lPSdcIitzaG9ydE5hbWUrXCJfXCIrbmFtZStcIl9cIitcbiAgICAgICAgICAgICAgICAgICAgaWRTdHIrXCInIHR5cGU9J2hpZGRlbicgdmFsdWU9XFxcIlwiKyB2YWx1ZSArXCJcXFwiLz5cIjtcbiAgICAgICAgICAgIGh0bWwgKz0gXCI8cCBjbGFzcz0nZm9ybS1jb250cm9sLXN0YXRpYyc+XCIgKyB2YWx1ZSArIFwiPC9wPlwiO1xuICAgICAgICAgICAgaWYgKHNpemUgIT0gMCkge1xuICAgICAgICAgICAgICAgICAgICBodG1sICs9IFwiPGlucHV0IHR5cGU9XFxcImhpZGRlblxcXCIgaWQ9XFxcIlwiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX3NpemVfXCIraWRTdHIrXCJcXFwiIFwiICtcbiAgICAgICAgICAgICAgIC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R0aDogNTclOyBtYXJnaW4tYm90dG9tOiA1cHg7IGRpc3BsYXk6IGlubGluZS1ibG9jazsnPlwiK1xuICAgICAgICAgICAgICAgICAgICBcIjxvcHRpb24+PC9vcHRpb24+XCI7XG4gICAgICAgICAgICB2YXIgbW9udGhzID0gW1wiSmFudWFyeVwiLCBcIkZlYnJ1YXJ5XCIsIFwiTWFyY2hcIiwgXCJBcHJpbFwiLCBcIk1heVwiLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIFwiSnVuZVwiLCBcIkp1bHlcIiwgXCJBdWd1c3RcIiwgXCJTZXB0ZW1iZXJcIiwgXCJPY3RvYmVyXCIsIFwiTm92ZW1iZXJcIiwgXCJEZWNlbWJlclwiXTtcblxuICAgICAgICAgICAgbW9udGhzLmZvckVhY2goZnVuY3Rpb24odmFsdWUsIGtleSkge1xuICAgICAgICAgICAgICAgIHZhciBtSW50ID0ga2V5ICsgMTtcblxuICAgICAgICAgICAgICAgIGlmIChtSW50ID09IGRhdGVQYXJ0cy5tb250aClcbiAgICAgICAgICAgICAgICAgICAgaHRtbCArPSBcIjxvcHRpb24gdmFsdWU9XFxcIlwiK21JbnQrXCJcXFwiIHNlbGVjdGVkPlwiK3ZhbHVlK1wiPC9vcHRpb24+XCI7XG4gICAgICAgICAgICAgICAgZWxzZVxuICAgICAgICAgICAgICAgICAgICBodG1sICs9IFwiPG9wdGlvbiB2YWx1ZT1cXFwiXCIrbUludCtcIlxcXCI+XCIrdmFsdWUrXCI8L29wdGlvbj5cIjtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgaHRtbCArPSBcIjxzZWxlY3Q+IFwiO1xuICAgICAgICAgICAgaHRtbCArPSBcIjxzcGFuIGNsYXNzPSdmb3JtLWNvbnRyb2wtc3RhdGljJz4gLSA8L3NwYW4+XCI7XG4gICAgICAgICAgICBodG1sICs9IFwiPGlucHV0IHR5cGU9J3RleHQnIHN0eWxlPSd3aWR0aDoxNCU7ZGlzcGxheTppbmxpbmU7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aG9ydE5hbWUrXCJfXCIrbmFtZStcIl9tb250aF9cIitpZFN0cisgXCIgb3B0aW9uOnNlbGVjdGVkXCIpLnZhbCgpO1xuXG4gICAgICAgICAgICAgICAgdmFyIGRhdGVTdHIgPSBcIlwiO1xuICAgICAgICAgICAgICAgIGlmICh5ZWFyICE9IFwiXCIpIHtcbiAgICAgICAgICAgICAgICAgICAgZGF0ZVN0ciArPSBwYWQoeWVhciwgNCk7XG4gICAgICAgICAgICAgICAgICAgIGlmIChtb250aCAhPSBcIlwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRlU3RyICs9IFwiLVwiICsgcGFkKG1vbnRoLDIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgaWYgKGRheSAhPSBcIlwiKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZGF0ZVN0ciArPSBcIi1cIiArIHBhZChkYXksMik7XG4gICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICAkKFwiI1wiK3Nob3J0TmFtZStcIl9cIituYW1lK1wiX1wiK2lkU3RyKS52YWwoZGF0ZVN0cik7XG4gICAgICAgICAgICB9XG5cbiAgICAgICAgfVxuICAgIH0pO1xufVxuXG4vKipcbiAqIFJldHVybiBlZGl0YWJsZSBkYXRlIGFyZWEgYmFjayB0byB0ZXh0XG4gKlxuICogSWYgdGhlIGRhdGUgZm9yIHRoZSBkYXRhIG9iamVjdCAoc2hvcnROYW1lLCBpZFN0cikgaGFzIGJlZW4gdHVybmVkIGludG8gYSAzLWZpZWxkIGVkaXRcbiAqIGFyZWEsIHRoZW4gdGhpcyBmdW5jdGlvbiB3aWxsIHJldHVybiB0aGUgZWRpdGFibGUgYXJlYSBiYWNrIHRvIHRoZSB2aWV3IG1vZGUgdGV4dCwgcmVwbGFjaW5nXG4gKiB0aGUgZWRpdCBib3hlcyB3aXRoIGEgcGFyYWdyYXBo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uICAgIHZhciBkaXZJRCA9ICcnO1xuICAgIGlmIChwYXJ0ICE9ICcnKVxuICAgICAgICBkaXZJRCA9IFwiI1wiICsgcGFydCArIFwiIFwiO1xuICAgIC8vIFR1cm4gb24gdGhlIGVkaXQgYnV0dG9uc1xuICAgICQoZGl2SUQgKyBcImFbaWQqPSdlZGl0YnV0dG9uJ11cIikuZWFjaChmdW5jdGlvbigpIHtcbiAgICAgICAgdmFyIG9iaiA9ICQodGhpcyk7XG4gICAgICAgIHZhciBwaWVjZXMgPSBvYmouYXR0cignaWQnKS5zcGxpdChcIl9cIik7XG5cbiAgICAgICAgaWYgKHBpZWNlcy5sZW5ndGggPT0gMykge1xuICAgICAgICAgICAgdmFyIHNob3J0ID0gcGllY2VzWzBdO1xuICAgICAgICAgICAgdmFyIGkgPSBwaWVjZXNbMl07XG4gICAgICAgICAgICBvYmoub24oXCJjbGlja1wiLCBmdW5jdGlvbigpIHtcbiAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoc2hvcnQsIGkpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSBpZiAocGllY2VzLmxlbmd0aCA9PSA1ICYmIHBpZWNlc1swXSA9PSBcInNjbVwiKSB7XG4gICAgICAgICAgICB2YXIgc2hvcnQgPSBwaWVjZXNbMV07XG4gICAgICAgICAgICB2YXIgaSA9IHBpZWNlc1s0XTtcbiAgICAgICAgICAgIHZhciBqID0gcGllY2VzWzNdO1xuICAgICAgICAgICAgb2JqLm9uKFwiY2xpY2tcIiwgZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgbWFrZVNDTUVkaXRhYmxlKHNob3J0LCBpLCBqKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9IGVsc2UgaWYgKHBpZWNlcy5sZW5ndGggPT0gNSkge1xuICAgICAgICAgICAgdmFyIHNob3J0ID0gcGllY2VzWzBdICsgXCJfXCIgKyBwaWVjZXNbMV0gKyBcIl9cIiArIHBpZWNlc1syXTtcbiAgICAgICAgICAgIHZhciBpID0gcGllY2VzWzRdO1xuICAgICAgICAgICAgb2JqLm9uKFwiY2xpY2tcIiwgZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgbWFrZUVkaXRhYmxlKHNob3J0LCBpKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9XG4gICAgfSk7XG5cbiAgICAvLyBUdXJuIG9uIHRoZSBkZWxldGUgYnV0dG9uc1xuICAgICQoZGl2SUQgKyBcImFbaWQqPSdkZWxldGVidXR0b24nXVwiKS5lYWNoKGZ1bmN0aW9uKCkge1xuICAgICAgICB2YXIgb2JqID0gJCh0aGlzKTtcbiAgICAgICAgdmFyIHBpZWNlcyA9IG9iai5hdHRyKCdpZCcpLnNwbGl0KFwiX1wiKTtcblxuICAgICAgICBpZiAocGllY2VzLmxlbmd0aCA9PSAzKSB7XG4gICAgICAgICAgICB2YXIgc2hvcnQgPSBwaWVjZXNbMF07XG4gICAgICAgICAgICB2YXIgaSA9IHBpZWNlc1syXTtcbiAgICAgICAgICAgIG9iai5vbihcImNsaWNrXCIsIGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgIHNldERlbGV0ZWQoc2hvcnQsIGkpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0gZWxzZSBpZiAocGllY2VzLmxlbmd0aCA9PSA1ICYmIHBpZWNlc1swXSA9PSBcInNjbVwiKSB7XG4gICAgICAgICAgICB2YXIgc2hvcnQgPSBwaWVjZXNbMV07XG4gICAgICAgICAgICB2YXIgaSA9IHBpZWNlc1s0XTtcbiAgICAgICAgICAgIHZhciBqID0gcGllY2VzWzNdO1xuICAgICAgICAgICAgb2JqLm9uKFwiY2xpY2tcIiwgZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgc2V0U0NNRGVsZXRlZChzaG9ydCwgaSwgaik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSBlbHNlIGlmIChwaWVjZXMubGVuZ3RoID09IDUpIHtcbiAg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wbGFjZSAmJiBnZW9QbGFjZUxvYWRSZXN1bHRzKSB7XG4gICAgICAgIGdlb1BsYWNlTG9hZFJlc3VsdHMuZm9yRWFjaChmdW5jdGlvbihyZXN1bHQpIHtcbiAgICAgICAgICAgIGlmIChyZXN1bHQuaWQgPT0gbmV3VmFsdWUpXG4gICAgICAgICAgICAgICAgcGxhY2UgPSByZXN1bHQ7XG4gICAgICAgIH0pO1xuICAgIH1cblxuICAgIGlmICghcGxhY2UpIHtcbiAgICAgICAgJCgnIycrc2hvcnROYW1lKydfY29uZmlybWVkXycraSkudmFsKFwiZmFsc2VcIik7XG4gICAgICAgICQoJyMnK3Nob3J0TmFtZStcIl9nZW90ZXJtX21hcGxpbmtfXCIraSkuYWRkQ2xhc3MoXCJkaXNhYmxlZFwiKTtcbiAgICAgICAgJCgnIycrc2hvcnROYW1lK1wiX2dlb3Rlcm1fbWFwbGlua19cIitpKS5vZmYoXCJjbGlja1wiKTtcbiAgICAgICAgaWYgKCQoJyMnK3Nob3J0TmFtZSsnX29yaWdpbmFsXycraSkudmFsKCkgIT0gXCJcIikge1xuICAgICAgICAgICAgJCgnIycrc2hvcnROYW1lKydfZ2VvdGVybV90ZXh0XycraSkuaHRtbChcIjxlbT5VbmNvbmZpcm1lZDwvZW0+XCIpO1xuICAgICAgICAgICAgJCgnIycrc2hvcnROYW1lKydfZ2VvdGVybV9jYXB0aW9uXycraSkudGV4dChcIlJlY29yZGVkIGFzOiBcIiArICQoJyMnK3Nob3J0TmFtZSsnX29yaWdpbmFsXycraSkudmFsKCkpO1xuICAgICAgICB9IGVsc2Uge1xuICAgICAgICAgICAgJCgnIycrc2hvcnROYW1lKydfZ2VvdGVybV90ZXh0XycraSkudGV4dChcIi0tXCIpO1xuICAgICAgICAgICAgJCgnIycrc2hvcnROYW1lKydfZ2VvdGVybV9jYXB0aW9uXycraSkudGV4dChcIkdlb1BsYWNlIHRlcm0gbm90IHNwZWNpZmllZFwiKTtcbiAgICAgICAgfVxuICAgICAgIC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gICAgICAgICAgICAgIGdlbmRlck9wZW4gPSB0cnVlO1xuICAgICAgICAgICAgICAgICQoJyNnZW5kZXJzJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwiZ2VuZGVyc1wiKTtcblxuICAgICAgICAgICAgICAgIGlmICgkKCcjbmV4dF9nZW5kZXJfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIGdlbmRlcmlkID0gcGFyc2VJbnQoJCgnI25leHRfZ2VuZGVyX2knKS50ZXh0KCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIk5leHQgR2VuZGVyIElEOiBcIiArIGdlbmRlcmlkKTtcbiAgICAgICAgICAgICAgICBpZiAoJCgnI2J0bl9hZGRfZ2VuZGVyJykuZXhpc3RzKCkpe1xuICAgICAgICAgICAgICAgICAgICAkKCcjYnRuX2FkZF9nZW5kZXInKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNnZW5kZXJfdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSB0ZXh0Lmh0bWwoKS5yZXBsYWNlKC9aWi9nLCBnZW5kZXJpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX2dlbmRlcl9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJnZW5kZXJcIiwgZ2VuZGVyaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJ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pO1xuXG4gICAgICAgICAgICAgICAgaWYgKCQoJyNuZXh0X2V4aXN0X2knKS5leGlzdHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBleGlzdGlkID0gcGFyc2VJbnQoJCgnI25leHRfZXhpc3RfaScpLnRleHQoKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiTmV4dCBFeGlzdCBEYXRlIElEOiBcIiArIGV4aXN0aWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9leGlzdF9kYXRlJykuZXhpc3RzKCkpe1xuICAgICAgICAgICAgICAgICAgICAkKCcjYnRuX2FkZF9leGlzdF9kYXRlJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjZXhpc3RfZGF0ZV90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGV4aXN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9leGlzdF9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJleGlzdFwiLCBleGlzdGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwiZXhpc3RcIiwgZXhpc3RpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJleGlzdFwiLCBleGlzdGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4aXN0aWQgPSBleGlzdGlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9leGlzdF9kYXRlUmFuZ2UnKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fYWRkX2V4aXN0X2RhdGVSYW5nZScpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRFZGl0ZWRGbGFnKHRydWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy9zb21ldGhpbmdIYXNCZWVuRWRpdGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0ZXh0ID0gJCgnI2V4aXN0X2RhdGVSYW5nZV90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGV4aXN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9leGlzdF9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJleGlzdFwiLCBleGlzdGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwiZXhpc3RcIiwgZXhpc3RpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJleGlzdFwiLCBleGlzdGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGV4aXN0aWQgPSBleGlzdGlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJ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FtZUFzX2knKS5leGlzdHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBzYW1lQXNpZCA9IHBhcnNlSW50KCQoJyNuZXh0X3NhbWVBc19pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IHNhbWVBcyBJRDogXCIgKyBzYW1lQXNpZCk7XG4gICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fYWRkX3NhbWVBcycpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfc2FtZUFzJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjc2FtZUFzX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgc2FtZUFzaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9zYW1lQXNfZGl2JykuYWZ0ZXIoaHRtbCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwic2FtZUFzXCIsIHNhbWVBc2lkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwic2FtZUFzXCIsIHNhbWVBc2lkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcInNhbWVBc1wiLCBzYW1lQXNpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBzYW1lQXNpZCA9IHNhbWVBc2lkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJzYW1lQXNcIik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG5cblx0dmFyIGVudGl0eUlEaWQgPSAxO1xuICAgIHZhciBlbnRpdHlJRE9wZW4gPSBmYWxzZTtcblx0aWYgKCQoJyNlbnRpdHlJRHRhYicpLmV4aXN0cygpKXtcblx0XHQkKCcjZW50aXR5SUR0YWInKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgLy8gRG9uJ3Qgb3BlbiBhIHNlY29uZCB0aW1lXG4gICAgICAgICAgICBpZiAoZW50aXR5SURPcGVuKVxuICAgICAgICAgICAgICAgIHJldHVybjtcblxuICAgICAgICAgICAgJC5nZXQoc25hY1VybCtcIi9lZGl0X3BhcnQvXCIrJCgnI2NvbnN0ZWxsYXRpb25pZCcpLnZhbCgpK1wiL1wiKyQoJyN2ZXJzaW9uJykudmFsKCkrXCI/cGFydD1lbnRpdHlJRFwiLCBudWxsLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgIGVudGl0eUlET3BlbiA9IHRydWU7XG4gICAgICAgICAgICAgICAgJCgnI2VudGl0eUlEJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwiZW50aXR5SURcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfZW50aXR5SURfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIGVudGl0eUlEaWQgPSBwYXJzZUludCgkKCcjbmV4dF9lbnRpdHlJRF9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IGVudGl0eUlEIElEOiBcIiArIGVudGl0eUlEaWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9lbnRpdHlJRCcpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfZW50aXR5SUQnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNlbnRpdHlJRF90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGVudGl0eUlEaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9lbnRpdHlJRF9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJlbnRpdHlJRFwiLCBlbnRpdHlJRGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwiZW50aXR5SURcIiwgZW50aXR5SURpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJlbnRpdHlJRFwiLCBlbnRpdHlJRGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVudGl0eUlEaWQgPSBlbnRpdHlJRGlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJlbnRpdHlJRFwiKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cblx0dmFyIHNvdXJjZWlkID0gMTtcbiAgICB2YXIgc291cmNlT3BlbiA9IGZhbHNlO1xuXHRpZiAoJCgnI3NvdXJjZXN0YWInKS5leGlzdHMoKSl7XG5cdFx0JCgnI3NvdXJjZXN0YWInKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgLy8gRG9uJ3Qgb3BlbiBhIHNlY29uZCB0aW1lXG4gICAgICAgICAgICBpZiAoc291cmNlT3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9c291cmNlc1wiLCBudWxsLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgIHNvdXJjZU9wZW4gPSB0cnVlO1xuICAgICAgICAgICAgICAgICQoJyNzb3VyY2VzJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwic291cmNlc1wiKTtcblxuICAgICAgICAgICAgICAgIGlmICgkKCcjbmV4dF9zb3VyY2VfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIHNvdXJjZWlkID0gcGFyc2VJbnQoJCgnI25leHRfc291cmNlX2knKS50ZXh0KCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIk5leHQgc291cmNlIElEOiBcIiArIHNvdXJjZWlkKTtcbiAgICAgICAgICAgICAgICBpZiAoJCgnI2J0bl9hZGRfc291cmNlJykuZXhpc3RzKCkpe1xuICAgICAgICAgICAgICAgICAgICAkKCcjYnRuX2FkZF9zb3VyY2UnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNzb3VyY2VfdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSB0ZXh0Lmh0bWwoKS5yZXBsYWNlKC9aWi9nLCBzb3VyY2VpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX3NvdXJjZV9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJzb3VyY2VcIiwgc291cmNlaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJzb3VyY2VcIiwgc291cmNlaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUVkaXRhYmxlKFwic291cmNlXCIsIHNvdXJjZWlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNvdXJjZWlkID0gc291cmNlaWQgKyAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwc0ZvclRhYihcInNvdXJjZXNcIik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG5cdHZhciByZXNvdXJjZVJlbGF0aW9uaWQgPSAxO1xuICAgIHZhciByZXNvdXJjZVJlbGF0aW9uT3BlbiA9IGZhbHNlO1xuXHRpZiAoJCgnI3Jlc291cmNlUmVsYXRpb25zdGFiJykuZXhpc3RzKCkpe1xuXHRcdCQoJyNyZXNvdXJjZVJlbGF0aW9uc3RhYicpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAvLyBEb24ndCBvcGVuIGEgc2Vjb25kIHRpbWVcbiAgICAgICAgICAgIGlmIChyZXNvdXJjZVJlbGF0aW9uT3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9cmVzb3VyY2VSZWxhdGlvbnNcIiwgbnVsbCwgZnVuY3Rpb24gKGRhdGEpIHtcbiAgICAgICAgICAgICAgICByZXNvdXJjZVJlbGF0aW9uT3BlbiA9IHRydWU7XG4gICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25zJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwicmVzb3VyY2VSZWxhdGlvbnNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfcmVzb3VyY2VSZWxhdGlvbl9pJykuZXhpc3RzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgcmVzb3VyY2VSZWxhdGlvbmlkID0gcGFyc2VJbnQoJCgnI25leHRfcmVzb3VyY2VSZWxhdGlvbl9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IHJlc291cmNlUmVsYXRpb24gSUQ6IFwiICsgcmVzb3VyY2VSZWxhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fY3JlYXRlX3Jlc291cmNlUmVsYXRpb24nKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fY3JlYXRlX3Jlc291cmNlUmVsYXRpb24nKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHJpZCA9ICQoJ2lucHV0W25hbWU9cmVzb3VyY2VDaG9pY2VdOmNoZWNrZWQnLCAnI3Jlc291cmNlX3NlYXJjaF9mb3JtJykudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAocmlkICE9IG51bGwgJiYgcmVzb3VyY2VSZXN1bHRzICE9IG51bGwgJiYgcmlkICE9ICduZXcnKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0ZXh0ID0gJCgnI3Jlc291cmNlUmVsYXRpb25fdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgcmVzb3VyY2VSZWxhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX3Jlc291cmNlUmVsYXRpb25fZGl2JykuYWZ0ZXIoaHRtbCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc291cmNlUmVzdWx0c1tyaWRdLmlkICE9PSAndW5kZWZpbmVkJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fcmVzb3VyY2VpZF8nK3Jlc291cmNlUmVsYXRpb25pZCkudmFsKHJlc291cmNlUmVzdWx0c1tyaWRdLmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc291cmNlUmVzdWx0c1tyaWRdLnZlcnNpb24gIT09ICd1bmRlZmluZWQnKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl9yZXNvdXJjZXZlcnNpb25fJytyZXNvdXJjZVJlbGF0aW9uaWQpLnZhbChyZXNvdXJjZVJlc3VsdHNbcmlkXS52ZXJzaW9uKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgcmVzb3VyY2VSZXN1bHRzW3JpZF0ubGluayAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNyZXNvdXJjZVJlbGF0aW9uX2xpbmtUZXh0XycrcmVzb3VyY2VSZWxhdGlvbmlkKS5odG1sKFwiPGEgdGFyZ2V0PSdfYmxhbmsnIGhyZWY9J1wiK3Jlc291cmNlUmVzdWx0c1tyaWRdLmxpbmsrXCInPlwiK3Jlc291cmNlUmVzdWx0c1tyaWRdLmxpbmsrXCI8L2E+XCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgXCIgPGEgY2xhc3M9J2xhYmVsIGxhYmVsLWluZm8nIHRhcmdldD0nX2JsYW5rJyBocmVmPSdcIityZXNvdXJjZVJlc3VsdHNbcmlkXS5saW5rK1wiJz5WaWV3PC9hPlwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc291cmNlUmVzdWx0c1tyaWRdLmRpc3BsYXlFbnRyeSAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNyZXNvdXJjZVJlbGF0aW9uX2Rpc3BsYXlFbnRyeVRleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnRleHQocmVzb3VyY2VSZXN1bHRzW3JpZF0uZGlzcGxheUVudHJ5KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHJlc291cmNlUmVzdWx0c1tyaWRdLnRpdGxlICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl90aXRsZVRleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnRleHQocmVzb3VyY2VSZXN1bHRzW3JpZF0udGl0bGUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB1cGRhdGVQaWN0dXJlVGl0bGUoJ3Jlc291cmNlUmVsYXRpb24nLCByZXNvdXJjZVJlbGF0aW9uaWQsIHJlc291cmNlUmVzdWx0c1tyaWRdLnRpdGxlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXNvdXJjZVJlc3VsdHNbcmlkXS5hYnN0cmFjdCAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNyZXNvdXJjZVJlbGF0aW9uX2Fic3RyYWN0VGV4dF8nK3Jlc291cmNlUmVsYXRpb25pZCkudGV4dChyZXNvdXJjZVJlc3VsdHNbcmlkXS5hYnN0cmFjdCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXNvdXJjZVJlc3VsdHNbcmlkXS5leHRlbnQgIT09ICd1bmRlZmluZWQnKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl9leHRlbnRUZXh0XycrcmVzb3VyY2VSZWxhdGlvbmlkKS50ZXh0KHJlc291cmNlUmVzdWx0c1tyaWRdLmV4dGVudCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gaWYgKHR5cGVvZiByZXNvdXJjZVJlc3VsdHNbcmlkXS5kYXRlICE9PSAndW5kZWZpbmVkJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fZGF0ZVRleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnRleHQocmVzb3VyY2VSZXN1bHRzW3JpZF0uZGF0ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiByZXNvdXJjZVJlc3VsdHNbcmlkXS5kb2N1bWVudFR5cGUgIT09ICd1bmRlZmluZWQnICYmIHR5cGVvZiByZXNvdXJjZVJlc3VsdHNbcmlkXS5kb2N1bWVudFR5cGUudGVybSAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNyZXNvdXJjZVJlbGF0aW9uX2RvY3VtZW50VHlwZVRleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnRleHQocmVzb3VyY2VSZXN1bHRzW3JpZF0uZG9jdW1lbnRUeXBlLnRlcm0pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fbGlua1RleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLmFmdGVyKFwiPGEgY2xhc3M9J2NvbnRyb2wtbGFiZWwtc3VidGV4dCcgdGFyZ2V0PSdfYmxhbmsnIGhyZWY9J1wiICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc25hY1VybCtcIi92b2NhYl9hZG1pbmlzdHJhdG9yL3Jlc291cmNlcy9cIityZXNvdXJjZVJlc3VsdHNbcmlkXS5pZCtcIic+VmlldyBpbiBTTkFDPC9hPlwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwicmVzb3VyY2VSZWxhdGlvblwiLCByZXNvdXJjZVJlbGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwicmVzb3VyY2VSZWxhdGlvblwiLCByZXNvdXJjZVJlbGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcInJlc291cmNlUmVsYXRpb25cIiwgcmVzb3VyY2VSZWxhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvdXJjZVJlbGF0aW9uaWQgPSByZXNvdXJjZVJlbGF0aW9uaWQgKyAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjcmVzb3VyY2UtcmVzdWx0cy1ib3hcIikuaHRtbChcIlwiKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fb3Blbl9jcmVhdGVfcmVzb3VyY2UnKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fb3Blbl9jcmVhdGVfcmVzb3VyY2UnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ2xvc2UgdGhpcyBtb2RhbCBhbmQgb3BlbiB0aGUgbmV3IG1vZGFsXG4gICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3Jlc291cmNlU2VhcmNoUGFuZVwiKS5tb2RhbChcImhpZGVcIik7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIFNldCBhIDUwMG1zIHRpbWVvdXQgdG8gZ2l2ZSB0aGUgaGlkZGVuIHNlYXJjaCBwYW5lIHRpbWUgdG8gZnVsbHkgY2xvc2VcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldFRpbWVvdXQoZnVuY3Rpb24oKSB7JChcIiNyZXNvdXJjZUNyZWF0ZVBhbmVcIikubW9kYWwoXCJzaG93XCIpO30sIDUwMCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgIC8vIEdyYWIgdGhlIGVtcHR5IHRlbXBsYXRlIGFuZCByZXBsYWNlXG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNyZXNvdXJjZV90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIDApO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlLWNyZWF0ZS1ib3gnKS5odG1sKGh0bWwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyICRyZXNvdXJjZUZvcm0gPSAkKFwiI3Jlc291cmNlX2NyZWF0ZV9mb3JtXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy8gQ29weSB0aGUgc2VhcmNoIGNvbnRlbnRzIHRvIHRpdGxlIG9yIGhyZWZcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmICgkKFwiI3Jlc291cmNlLXNlYXJjaGJveFwiKS52YWwoKS5pbmRleE9mKFwiaHR0cFwiKSA9PSAtMSlcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkcmVzb3VyY2VGb3JtLmZpbmQoXCIjcmVzb3VyY2UtdGl0bGVcIikudmFsKCQoXCIjcmVzb3VyY2Utc2VhcmNoYm94XCIpLnZhbCgpKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGVsc2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkcmVzb3VyY2VGb3JtLmZpbmQoXCIjcmVzb3VyY2UtdXJsXCIpLnZhbCgkKFwiI3Jlc291cmNlLXNlYXJjaGJveFwiKS52YWwoKSk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICRyZXNvdXJjZUZvcm0uZmluZCgnW2RhdGEtdG9nZ2xlPVwicG9wb3ZlclwiXScpLnBvcG92ZXIoe1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHJpZ2dlcjogJ2hvdmVyJyxcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGNvbnRhaW5lcjogJ2JvZHknXG4gICAgICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxvYWRWb2NhYlNlbGVjdE9wdGlvbnMoJHJlc291cmNlRm9ybS5maW5kKFwiI3Jlc291cmN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gICAgICAgICAgICAgICAgICAgICAgICAvLyBSZW1vdmUgdGhlIHNlYXJjaCByZXN1bHRzIGZyb20gdGhlIG90aGVyIG1vZGFsXG4gICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3Jlc291cmNlLXJlc3VsdHMtYm94XCIpLmh0bWwoXCJcIik7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2NyZWF0ZV9yZXNvdXJjZScpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlX2NyZWF0ZV9mb3JtJykub24oXCJzdWJtaXRcIiwgZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBSZW1vdmUgbGVhZGluZyBhbmQgdHJhaWxpbmcgd2hpdGVzcGFjZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICgkKFwiI3Jlc291cmNlX2NyZWF0ZV9mb3JtICNyZXNvdXJjZS11cmxcIikudmFsKCkgPT0gXCJcIikge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAoIWNvbmZpcm0oJ0FyZSB5b3Ugc3VyZSB5b3Ugd2FudCB0byBzYXZlIHdpdGhvdXQgYW4gSFJFRj8nKSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoXCIjcmVzb3VyY2VfY3JlYXRlX2Zvcm0gaW5wdXQsIHRleHRhcmVhXCIpLmVhY2goZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQodGhpcykudmFsKCQudHJpbSgkKHRoaXMpLnZhbCgpKSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0RGVsZXRlZFJlc291cmNlTGFuZ3VhZ2VPcGVyYXRpb25zKCQoXCIjcmVzb3VyY2VfY3JlYXRlX2Zvcm1cIikpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgJC5wb3N0KHNuYWNVcmwrXCIvc2F2ZV9yZXNvdXJjZVwiLCAkKFwiI3Jlc291cmNlX2NyZWF0ZV9mb3JtXCIpLnNlcmlhbGl6ZSgpLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEucmVzdWx0ICE9PSAndW5kZWZpbmVkJyAmJiBkYXRhLnJlc3VsdCAhPT0gJ2ZhbHNlJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNyZXNvdXJjZVJlbGF0aW9uX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgcmVzb3VyY2VSZWxhdGlvbmlkKTsgLy8gY2xvbmVzIERPTSwgcmVwbGFjZXMgenogd2l0aCBuZXh0IGlkc1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9yZXNvdXJjZVJlbGF0aW9uX2RpdicpLmFmdGVyKGh0bWwpO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEucmVzb3VyY2UuaWQgIT09ICd1bmRlZmluZWQnKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNyZXNvdXJjZVJlbGF0aW9uX3Jlc291cmNlaWRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnZhbChkYXRhLnJlc291cmNlLmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGF0YS5yZXNvdXJjZS52ZXJzaW9uICE9PSAndW5kZWZpbmVkJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl9yZXNvdXJjZXZlcnNpb25fJytyZXNvdXJjZVJlbGF0aW9uaWQpLnZhbChkYXRhLnJlc291cmNlLnZlcnNpb24pO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEucmVzb3VyY2UubGluayAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fbGlua1RleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLmh0bWwoXCI8YSB0YXJnZXQ9J19ibGFuaycgaHJlZj0nXCIrZGF0YS5yZXNvdXJjZS5saW5rK1wiJz5cIitkYXRhLnJlc291cmNlLmxpbmsrXCI8L2E+XCIgK1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBcIiA8YSBjbGFzcz0nbGFiZWwgbGFiZWwtaW5mbycgdGFyZ2V0PSdfYmxhbmsnIGhyZWY9J1wiK2RhdGEucmVzb3VyY2UubGluaytcIic+VmlldzwvYT5cIik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEucmVzb3VyY2UuZGlzcGxheUVudHJ5ICE9PSAndW5kZWZpbmVkJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl9kaXNwbGF5RW50cnlUZXh0XycrcmVzb3VyY2VSZWxhdGlvbmlkKS50ZXh0KGRhdGEucmVzb3VyY2UuZGlzcGxheUVudHJ5KTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGF0YS5yZXNvdXJjZS50aXRsZSAhPT0gJ3VuZGVmaW5lZCcpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjcmVzb3VyY2VSZWxhdGlvbl90aXRsZVRleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLnRleHQoZGF0YS5yZXNvdXJjZS50aXRsZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdXBkYXRlUGljdHVyZVRpdGxlKCdyZXNvdXJjZVJlbGF0aW9uJywgcmVzb3VyY2VSZWxhdGlvbmlkLCBkYXRhLnJlc291cmNlLnRpdGxlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlmICh0eXBlb2YgZGF0YS5yZXNvdXJjZS5hYnN0cmFjdCAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fYWJzdHJhY3RUZXh0XycrcmVzb3VyY2VSZWxhdGlvbmlkKS50ZXh0KGRhdGEucmVzb3VyY2UuYWJzdHJhY3QpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBkYXRhLnJlc291cmNlLmV4dGVudCAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fZXh0ZW50VGV4dF8nK3Jlc291cmNlUmVsYXRpb25pZCkudGV4dChkYXRhLnJlc291cmNlLmV4dGVudCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIGRhdGEucmVzb3VyY2UuZG9jdW1lbnRUeXBlICE9PSAndW5kZWZpbmVkJyAmJiB0eXBlb2YgZGF0YS5yZXNvdXJjZS5kb2N1bWVudFR5cGUudGVybSAhPT0gJ3VuZGVmaW5lZCcpXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fZG9jdW1lbnRUeXBlVGV4dF8nK3Jlc291cmNlUmVsYXRpb25pZCkudGV4dChkYXRhLnJlc291cmNlLmRvY3VtZW50VHlwZS50ZXJtKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlUmVsYXRpb25fbGlua1RleHRfJytyZXNvdXJjZVJlbGF0aW9uaWQpLmFmdGVyKFwiPGEgY2xhc3M9J2NvbnRyb2wtbGFiZWwtc3VidGV4dCcgdGFyZ2V0PSdfYmxhbmsnIGhyZWY9J1wiICtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBzbmFjVXJsK1wiL3ZvY2FiX2FkbWluaXN0cmF0b3IvcmVzb3VyY2VzL1wiK2RhdGEucmVzb3VyY2UuaWQrXCInPlZpZXcgaW4gU05BQzwvYT5cIik7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwicmVzb3VyY2VSZWxhdGlvblwiLCByZXNvdXJjZVJlbGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJyZXNvdXJjZVJlbGF0aW9uXCIsIHJlc291cmNlUmVsYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJyZXNvdXJjZVJlbGF0aW9uXCIsIHJlc291cmNlUmVsYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXNvdXJjZVJlbGF0aW9uaWQgPSByZXNvdXJjZVJlbGF0aW9uaWQgKyAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJChcIiNyZXNvdXJjZUNyZWF0ZVBhbmVcIikubW9kYWwoXCJoaWRlXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJCgnI3Jlc291cmNlLWNyZWF0ZS1ib3gnKS5odG1sKFwiXCIpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0gZWxzZSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhkYXRhKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwc0ZvclRhYihcInJlc291cmNlUmVsYXRpb25zXCIpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH1cblxuXG5cdHZhciBjb25zdGVsbGF0aW9uUmVsYXRpb25pZCA9IDE7XG4gICAgdmFyIGNvbnN0ZWxsYXRpb25SZWxhdGlvbk9wZW4gPSBmYWxzZTtcblx0aWYgKCQoJyNjb25zdGVsbGF0aW9uUmVsYXRpb25zdGFiJykuZXhpc3RzKCkpe1xuXHRcdCQoJyNjb25zdGVsbGF0aW9uUmVsYXRpb25zdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gYSBzZWNvbmQgdGltZVxuICAgICAgICAgICAgaWYgKGNvbnN0ZWxsYXRpb25SZWxhdGlvbk9wZW4pXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuXG4gICAgICAgICAgICAkLmdldChzbmFjVXJsK1wiL2VkaXRfcGFydC9cIiskKCcjY29uc3RlbGxhdGlvbmlkJykudmFsKCkrXCIvXCIrJCgnI3ZlcnNpb24nKS52YWwoKStcIj9wYXJ0PWNvbnN0ZWxsYXRpb25SZWxhdGlvbnNcIiwgbnVsbCwgZnVuY3Rpb24gKGRhdGEpIHtcbiAgICAgICAgICAgICAgICBjb25zdGVsbGF0aW9uUmVsYXRpb25PcGVuID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAkKCcjY29uc3RlbGxhdGlvblJlbGF0aW9ucycpLmh0bWwoZGF0YSk7XG5cbiAgICAgICAgICAgICAgICB0dXJuT25FZGl0RGVsZXRlQnV0dG9ucyhcImNvbnN0ZWxsYXRpb25SZWxhdGlvbnNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfY29uc3RlbGxhdGlvblJlbGF0aW9uX2knKS5leGlzdHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBjb25zdGVsbGF0aW9uUmVsYXRpb25pZCA9IHBhcnNlSW50KCQoJyNuZXh0X2NvbnN0ZWxsYXRpb25SZWxhdGlvbl9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IGNvbnN0ZWxsYXRpb25SZWxhdGlvbiBJRDogXCIgKyBjb25zdGVsbGF0aW9uUmVsYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fY3JlYXRlX2NvbnN0ZWxsYXRpb25SZWxhdGlvbicpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9jcmVhdGVfY29uc3RlbGxhdGlvblJlbGF0aW9uJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBjaWQgPSAkKCdpbnB1dFtuYW1lPXJlbGF0aW9uQ2hvaWNlXTpjaGVja2VkJywgJyNyZWxhdGlvbl9zZWFyY2hfZm9ybScpLnZhbCgpXG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoY2lkICE9IG51bGwpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBzZXRFZGl0ZWRGbGFnKHRydWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjY29uc3RlbGxhdGlvblJlbGF0aW9uX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGNvbnN0ZWxsYXRpb25SZWxhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX2NvbnN0ZWxsYXRpb25SZWxhdGlvbl9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKCcjY29uc3RlbGxhdGlvblJlbGF0aW9uX3RhcmdldElEXycrY29uc3RlbGxhdGlvblJlbGF0aW9uaWQpLnZhbChjaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNjb25zdGVsbGF0aW9uUmVsYXRpb25fY29udGVudF8nK2NvbnN0ZWxsYXRpb25SZWxhdGlvbmlkKS52YWwoJCgnI3JlbGF0aW9uQ2hvaWNlX25hbWVFbnRyeV8nK2NpZCkudmFsKCkpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICQoJyNjb25zdGVsb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gICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uQnV0dG9ucyhcImNvbnN0ZWxsYXRpb25SZWxhdGlvblwiLCBjb25zdGVsbGF0aW9uUmVsYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJjb25zdGVsbGF0aW9uUmVsYXRpb25cIiwgY29uc3RlbGxhdGlvblJlbGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcImNvbnN0ZWxsYXRpb25SZWxhdGlvblwiLCBjb25zdGVsbGF0aW9uUmVsYXRpb25pZCk7XG5cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBjb25zdGVsbGF0aW9uUmVsYXRpb25pZCA9IGNvbnN0ZWxsYXRpb25SZWxhdGlvbmlkICsgMTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB0cnVlO1xuXG4gICAgICAgICAgICAgICAgICAgICAgICB9XG5cblxuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwc0ZvclRhYihcImNvbnN0ZWxsYXRpb25SZWxhdGlvbnNcIik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG5cdHZhciBsYW5ndWFnZWlkID0gMTtcbiAgICB2YXIgbGFuZ3VhZ2VPcGVuID0gZmFsc2U7XG5cdGlmICgkKCcjbGFuZ3VhZ2VzVXNlZHRhYicpLmV4aXN0cygpKXtcblx0XHQkKCcjbGFuZ3VhZ2VzVXNlZHRhYicpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAvLyBEb24ndCBvcGVuIGEgc2Vjb25kIHRpbWVcbiAgICAgICAgICAgIGlmIChsYW5ndWFnZU9wZW4pXG4gICAgICAgICA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HZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgbGFuZ3VhZ2VpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX2xhbmd1YWdlX2RpdicpLmFmdGVyKGh0bWwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uQnV0dG9ucyhcImxhbmd1YWdlXCIsIGxhbmd1YWdlaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJsYW5ndWFnZVwiLCBsYW5ndWFnZWlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcImxhbmd1YWdlXCIsIGxhbmd1YWdlaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbGFuZ3VhZ2VpZCA9IGxhbmd1YWdlaWQgKyAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwc0ZvclRhYihcImxhbmd1YWdlc1VzZWRcIik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG5cdHZhciBzdWJqZWN0aWQgPSAxO1xuICAgIHZhciBzdWJqZWN0T3BlbiA9IGZhbHNlO1xuXHRpZiAoJCgnI3N1YmplY3RzdGFiJykuZXhpc3RzKCkpe1xuXHRcdCQoJyNzdWJqZWN0c3RhYicpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAvLyBEb24ndCBvcGVuIGEgc2Vjb25kIHRpbWVcbiAgICAgICAgICAgIGlmIChzdWJqZWN0T3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9c3ViamVjdHNcIiwgbnVsbCwgZnVuY3Rpb24gKGRhdGEpIHtcbiAgICAgICAgICAgICAgICBzdWJqZWN0T3BlbiA9IHRydWU7XG4gICAgICAgICAgICAgICAgJCgnI3N1YmplY3RzJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwic3ViamVjdHNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfc3ViamVjdF9pJykuZXhpc3RzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgc3ViamVjdGlkID0gcGFyc2VJbnQoJCgnI25leHRfc3ViamVjdF9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IHN1YmplY3QgSUQ6IFwiICsgc3ViamVjdGlkKTtcbiAgICAgICAgICAgICAgICBpZiAoJCgnI2J0bl9hZGRfc3ViamVjdCcpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfc3ViamVjdCcpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRFZGl0ZWRGbGFnKHRydWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy9zb21ldGhpbmdIYXNCZWVuRWRpdGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0ZXh0ID0gJCgnI3N1YmplY3RfdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSB0ZXh0Lmh0bWwoKS5yZXBsYWNlKC9aWi9nLCBzdWJqZWN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9zdWJqZWN0X2RpdicpLmFmdGVyKGh0bWwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uQnV0dG9ucyhcInN1YmplY3RcIiwgc3ViamVjdGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwic3ViamVjdFwiLCBzdWJqZWN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUVkaXRhYmxlKFwic3ViamVjdFwiLCBzdWJqZWN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgc3ViamVjdGlkID0gc3ViamVjdGlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJzdWJqZWN0c1wiKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cblx0dmFyIG5hdGlvbmFsaXR5aWQgPSAxO1xuICAgIHZhciBuYXRpb25hbGl0eU9wZW4gPSBmYWxzZTtcblx0aWYgKCQoJyNuYXRpb25hbGl0aWVzdGFiJykuZXhpc3RzKCkpe1xuXHRcdCQoJyNuYXRpb25hbGl0aWVzdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gYSBzZWNvbmQgdGltZVxuICAgICAgICAgICAgaWYgKG5hdGlvbmFsaXR5T3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9bmF0aW9uYWxpdGllc1wiLCBudWxsLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgIG5hdGlvbmFsaXR5T3BlbiA9IHRydWU7XG4gICAgICAgICAgICAgICAgJCgnI25hdGlvbmFsaXRpZXMnKS5odG1sKGRhdGEpO1xuXG4gICAgICAgICAgICAgICAgdHVybk9uRWRpdERlbGV0ZUJ1dHRvbnMoXCJuYXRpb25hbGl0aWVzXCIpO1xuXG4gICAgICAgICAgICAgICAgaWYgKCQoJyNuZXh0X25hdGlvbmFsaXR5X2knKS5leGlzdHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBuYXRpb25hbGl0eWlkID0gcGFyc2VJbnQoJCgnI25leHRfbmF0aW9uYWxpdHlfaScpLnRleHQoKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiTmV4dCBuYXRpb25hbGl0eSBJRDogXCIgKyBuYXRpb25hbGl0eWlkKTtcbiAgICAgICAgICAgICAgICBpZiAoJCgnI2J0bl9hZGRfbmF0aW9uYWxpdHknKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fYWRkX25hdGlvbmFsaXR5JykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjbmF0aW9uYWxpdHlfdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSB0ZXh0Lmh0bWwoKS5yZXBsYWNlKC9aWi9nLCBuYXRpb25hbGl0eWlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICQoJyNhZGRfbmF0aW9uYWxpdHlfZGl2JykuYWZ0ZXIoaHRtbCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwibmF0aW9uYWxpdHlcIiwgbmF0aW9uYWxpdHlpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwcyhcIm5hdGlvbmFsaXR5XCIsIG5hdGlvbmFsaXR5aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgbWFrZUVkaXRhYmxlKFwibmF0aW9uYWxpdHlcIiwgbmF0aW9uYWxpdHlpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBuYXRpb25hbGl0eWlkID0gbmF0aW9uYWxpdHlpZCArIDE7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gZmFsc2U7XG4gICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgIH1cblxuICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzRm9yVGFiKFwibmF0aW9uYWxpdGllc1wiKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cblx0dmFyIGZ1bmN0aW9uaWQgPSAxO1xuICAgIHZhciBmdW5jdGlvbk9wZW4gPSBmYWxzZTtcblx0aWYgKCQoJyNmdW5jdGlvbnN0YWInKS5leGlzdHMoKSl7XG5cdFx0JCgnI2Z1bmN0aW9uc3RhYicpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAvLyBEb24ndCBvcGVuIGEgc2Vjb25kIHRpbWVcbiAgICAgICAgICAgIGlmIChmdW5jdGlvbk9wZW4pXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuXG4gICAgICAgICAgICAkLmdldChzbmFjVXJsK1wiL2VkaXRfcGFydC9cIiskKCcjY29uc3RlbGxhdGlvbmlkJykudmFsKCkrXCIvXCIrJCgnI3ZlcnNpb24nKS52YWwoKStcIj9wYXJ0PWZ1bmN0aW9uc1wiLCBudWxsLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgIGZ1bmN0aW9uT3BlbiA9IHRydWU7XG4gICAgICAgICAgICAgICAgJCgnI2Z1bmN0aW9ucycpLmh0bWwoZGF0YSk7XG5cbiAgICAgICAgICAgICAgICB0dXJuT25FZGl0RGVsZXRlQnV0dG9ucyhcImZ1bmN0aW9uc1wiKTtcblxuICAgICAgICAgICAgICAgIGlmICgkKCcjbmV4dF9mdW5jdGlvbl9pJykuZXhpc3RzKCkpIHtcbiAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb25pZCA9IHBhcnNlSW50KCQoJyNuZXh0X2Z1bmN0aW9uX2knKS50ZXh0KCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIk5leHQgZnVuY3Rpb24gSUQ6IFwiICsgZnVuY3Rpb25pZCk7XG4gICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fYWRkX2Z1bmN0aW9uJykuZXhpc3RzKCkpe1xuICAgICAgICAgICAgICAgICAgICAkKCcjYnRuX2FkZF9mdW5jdGlvbicpLmNsaWNrKGZ1bmN0aW9uKCl7XG4gICAgICAgICAgICAgICAgICAgICAgICBzZXRFZGl0ZWRGbGFnKHRydWUpO1xuICAgICAgICAgICAgICAgICAgICAgICAgLy9zb21ldGhpbmdIYXNCZWVuRWRpdGVkID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciB0ZXh0ID0gJCgnI2Z1bmN0aW9uX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgZnVuY3Rpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX2Z1bmN0aW9uX2RpdicpLmFmdGVyKGh0bWwpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uQnV0dG9ucyhcImZ1bmN0aW9uXCIsIGZ1bmN0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJmdW5jdGlvblwiLCBmdW5jdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcImZ1bmN0aW9uXCIsIGZ1bmN0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgZnVuY3Rpb25pZCA9IGZ1bmN0aW9uaWQgKyAxO1xuICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIGZhbHNlO1xuICAgICAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgICAgICB9XG5cbiAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwc0ZvclRhYihcImZ1bmN0aW9uc1wiKTtcbiAgICAgICAgICAgIH0pO1xuICAgICAgICB9KTtcbiAgICB9XG5cblx0dmFyIG9jY3VwYXRpb25pZCA9IDE7XG4gICAgdmFyIG9jY3VwYXRpb25PcGVuID0gZmFsc2U7XG5cdGlmICgkKCcjb2NjdXBhdGlvbnN0YWInKS5leGlzdHMoKSl7XG5cdFx0JCgnI29jY3VwYXRpb25zdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gYSBzZWNvbmQgdGltZVxuICAgICAgICAgICAgaWYgKG9jY3VwYXRpb25PcGVuKVxuICAgICAgICAgICAgICAgIHJldHVybjtcblxuICAgICAgICAgICAgJC5nZXQoc25hY1VybCtcIi9lZGl0X3BhcnQvXCIrJCgnI2NvbnN0ZWxsYXRpb25pZCcpLnZhbCgpK1wiL1wiKyQoJyN2ZXJzaW9uJykudmFsKCkrXCI/cGFydD1vY2N1cGF0aW9uc1wiLCBudWxsLCBmdW5jdGlvbiAoZGF0YSkge1xuICAgICAgICAgICAgICAgIG9jY3VwYXRpb25PcGVuID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAkKCcjb2NjdXBhdGlvbnMnKS5odG1sKGRhdGEpO1xuXG4gICAgICAgICAgICAgICAgdHVybk9uRWRpdERlbGV0ZUJ1dHRvbnMoXCJvY2N1cGF0aW9uc1wiKTtcblxuICAgICAgICAgICAgICAgIGlmICgkKCcjbmV4dF9vY2N1cGF0aW9uX2knKS5leGlzdHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBvY2N1cGF0aW9uaWQgPSBwYXJzZUludCgkKCcjbmV4dF9vY2N1cGF0aW9uX2knKS50ZXh0KCkpO1xuICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhcIk5leHQgb2NjdXBhdGlvbiBJRDogXCIgKyBvY2N1cGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9vY2N1cGF0aW9uJykuZXhpc3RzKCkpe1xuICAgICAgICAgICAgICAgICAgICAkKCcjYnRuX2FkZF9vY2N1cGF0aW9uJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjb2NjdXBhdGlvbl90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIG9jY3VwYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAkKCcjYWRkX29jY3VwYXRpb25fZGl2JykuYWZ0ZXIoaHRtbCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwib2NjdXBhdGlvblwiLCBvY2N1cGF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHMoXCJvY2N1cGF0aW9uXCIsIG9jY3VwYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJvY2N1cGF0aW9uXCIsIG9jY3VwYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBvY2N1cGF0aW9uaWQgPSBvY2N1cG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JzZUludCgkKCcjbmV4dF9sZWdhbFN0YXR1c19pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IGxlZ2FsU3RhdHVzIElEOiBcIiArIGxlZ2FsU3RhdHVzaWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9sZWdhbFN0YXR1cycpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfbGVnYWxTdGF0dXMnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNsZWdhbFN0YXR1c190ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGxlZ2FsU3RhdHVzaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9sZWdhbFN0YXR1c19kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJsZWdhbFN0YXR1c1wiLCBsZWdhbFN0YXR1c2lkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwibGVnYWxTdGF0dXNcIiwgbGVnYWxTdGF0dXNpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJsZWdhbFN0YXR1c1wiLCBsZWdhbFN0YXR1c2lkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIGxlZ2FsU3RhdHVzaWQgPSBsZWdhbFN0YXR1c2lkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJsZWdhbFN0YXR1c2VzXCIpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH1cblxuXHR2YXIgcGxhY2VpZCA9IDE7XG4gICAgdmFyIHBsYWNlT3BlbiA9IGZhbHNlO1xuXHRpZiAoJCgnI3BsYWNlc3RhYicpLmV4aXN0cygpKXtcblx0XHQkKCcjcGxhY2VzdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gYSBzZWNvbmQgdGltZVxuICAgICAgICAgICAgaWYgKHBsYWNlT3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9cGxhY2VzXCIsIG51bGwsIGZ1bmN0aW9uIChkYXRhKSB7XG4gICAgICAgICAgICAgICAgcGxhY2VPcGVuID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAkKCcjcGxhY2VzJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIC8vIExvYWQgdGhlIHBsYWNlIGNhY2hlLCBpZiBuZWVkZWRcbiAgICAgICAgICAgICAgICBsb2FkR2VvUGxhY2VSZXN1bHRDYWNoZSgpO1xuXG4gICAgICAgICAgICAgICAgdHVybk9uRWRpdERlbGV0ZUJ1dHRvbnMoXCJwbGFjZXNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfcGxhY2VfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIHBsYWNlaWQgPSBwYXJzZUludCgkKCcjbmV4dF9wbGFjZV9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IHBsYWNlIElEOiBcIiArIHBsYWNlaWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9wbGFjZScpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfcGxhY2UnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNwbGFjZV90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIHBsYWNlaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9wbGFjZV9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJwbGFjZVwiLCBwbGFjZWlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwicGxhY2VcIiwgcGxhY2VpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBtYWtlRWRpdGFibGUoXCJwbGFjZVwiLCBwbGFjZWlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHBsYWNlaWQgPSBwbGFjZWlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJwbGFjZXNcIik7XG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfSk7XG4gICAgfVxuXG5cdHZhciBjb252ZW50aW9uRGVjbGFyYXRpb25pZCA9IDE7XG4gICAgdmFyIGNvbnZlbnRpb25EZWNsYXJhdGlvbk9wZW4gPSBmYWxzZTtcblx0aWYgKCQoJyNjb252ZW50aW9uRGVjbGFyYXRpb25zdGFiJykuZXhpc3RzKCkpe1xuXHRcdCQoJyNjb252ZW50aW9uRGVjbGFyYXRpb25zdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gYSBzZWNvbmQgdGltZVxuICAgICAgICAgICAgaWYgKGNvbnZlbnRpb25EZWNsYXJhdGlvbk9wZW4pXG4gICAgICAgICAgICAgICAgcmV0dXJuO1xuXG4gICAgICAgICAgICAkLmdldChzbmFjVXJsK1wiL2VkaXRfcGFydC9cIiskKCcjY29uc3RlbGxhdGlvbmlkJykudmFsKCkrXCIvXCIrJCgnI3ZlcnNpb24nKS52YWwoKStcIj9wYXJ0PWNvbnZlbnRpb25EZWNsYXJhdGlvbnNcIiwgbnVsbCwgZnVuY3Rpb24gKGRhdGEpIHtcbiAgICAgICAgICAgICAgICBjb252ZW50aW9uRGVjbGFyYXRpb25PcGVuID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAkKCcjY29udmVudGlvbkRlY2xhcmF0aW9ucycpLmh0bWwoZGF0YSk7XG5cbiAgICAgICAgICAgICAgICB0dXJuT25FZGl0RGVsZXRlQnV0dG9ucyhcImNvbnZlbnRpb25EZWNsYXJhdGlvbnNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfY29udmVudGlvbkRlY2xhcmF0aW9uX2knKS5leGlzdHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBjb252ZW50aW9uRGVjbGFyYXRpb25pZCA9IHBhcnNlSW50KCQoJyNuZXh0X2NvbnZlbnRpb25EZWNsYXJhdGlvbl9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IGNvbnZlbnRpb25EZWNsYXJhdGlvbiBJRDogXCIgKyBjb252ZW50aW9uRGVjbGFyYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fYWRkX2NvbnZlbnRpb25EZWNsYXJhdGlvbicpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfY29udmVudGlvbkRlY2xhcmF0aW9uJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjY29udmVudGlvbkRlY2xhcmF0aW9uX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgY29udmVudGlvbkRlY2xhcmF0aW9uaWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9jb252ZW50aW9uRGVjbGFyYXRpb25fZGl2JykuYWZ0ZXIoaHRtbCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwiY29udmVudGlvbkRlY2xhcmF0aW9uXCIsIGNvbnZlbnRpb25EZWNsYXJhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PblRvb2x0aXBzKFwiY29udmVudGlvbkRlY2xhcmF0aW9uXCIsIGNvbnZlbnRpb25EZWNsYXJhdGlvbmlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIG1ha2VFZGl0YWJsZShcImNvbnZlbnRpb25EZWNsYXJhdGlvblwiLCBjb252ZW50aW9uRGVjbGFyYXRpb25pZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICBjb252ZW50aW9uRGVjbGFyYXRpb25pZCA9IGNvbnZlbnRpb25EZWNsYXJhdGlvbmlkICsgMTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBmYWxzZTtcbiAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgfVxuXG4gICAgICAgICAgICAgICAgdHVybk9uVG9vbHRpcHNGb3JUYWIoXCJjb252ZW50aW9uRGVjbGFyYXRpb25zXCIpO1xuICAgICAgICAgICAgfSk7XG4gICAgICAgIH0pO1xuICAgIH1cblxuXHR2YXIgZ2VuZXJhbENvbnRleHRpZCA9IDE7XG4gICAgdmFyIGdlbmVyYWxDb250ZXh0T3BlbiA9IGZhbHNlO1xuXHRpZiAoJCgnI2dlbmVyYWxDb250ZXh0c3RhYicpLmV4aXN0cygpKXtcblx0XHQkKCcjZ2VuZXJhbENvbnRleHRzdGFiJykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgIC8vIERvbid0IG9wZW4gYSBzZWNvbmQgdGltZVxuICAgICAgICAgICAgaWYgKGdlbmVyYWxDb250ZXh0T3BlbilcbiAgICAgICAgICAgICAgICByZXR1cm47XG5cbiAgICAgICAgICAgICQuZ2V0KHNuYWNVcmwrXCIvZWRpdF9wYXJ0L1wiKyQoJyNjb25zdGVsbGF0aW9uaWQnKS52YWwoKStcIi9cIiskKCcjdmVyc2lvbicpLnZhbCgpK1wiP3BhcnQ9Z2VuZXJhbENvbnRleHRzXCIsIG51bGwsIGZ1bmN0aW9uIChkYXRhKSB7XG4gICAgICAgICAgICAgICAgZ2VuZXJhbENvbnRleHRPcGVuID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAkKCcjZ2VuZXJhbENvbnRleHRzJykuaHRtbChkYXRhKTtcblxuICAgICAgICAgICAgICAgIHR1cm5PbkVkaXREZWxldGVCdXR0b25zKFwiZ2VuZXJhbENvbnRleHRzXCIpO1xuXG4gICAgICAgICAgICAgICAgaWYgKCQoJyNuZXh0X2dlbmVyYWxDb250ZXh0X2knKS5leGlzdHMoKSkge1xuICAgICAgICAgICAgICAgICAgICBnZW5lcmFsQ29udGV4dGlkID0gcGFyc2VJbnQoJCgnI25leHRfZ2VuZXJhbENvbnRleHRfaScpLnRleHQoKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiTmV4dCBnZW5lcmFsQ29udGV4dCBJRDogXCIgKyBnZW5lcmFsQ29udGV4dGlkKTtcbiAgICAgICAgICAgICAgICBpZiAoJCgnI2J0bl9hZGRfZ2VuZXJhbENvbnRleHQnKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fYWRkX2dlbmVyYWxDb250ZXh0JykuY2xpY2soZnVuY3Rpb24oKXtcbiAgICAgICAgICAgICAgICAgICAgICAgIHNldEVkaXRlZEZsYWcodHJ1ZSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAvL3NvbWV0aGluZ0hhc0JlZW5FZGl0ZWQgPSB0cnVlO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHRleHQgPSAkKCcjZ2VuZXJhbENvbnRleHRfdGVtcGxhdGUnKS5jbG9uZSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgdmFyIGh0bWwgPSB0ZXh0Lmh0bWwoKS5yZXBsYWNlKC9aWi9nLCBnZW5lcmFsQ29udGV4dGlkKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICQoJyNhZGRfZ2VuZXJhbENvbnRleHRfZGl2JykuYWZ0ZXIoaHRtbCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25CdXR0b25zKFwiZ2VuZXJhbENvbnRleHRcIiwgZ2VuZXJhbENvbnRleHRpZCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB0dXJuT25Ub29sdGlwcyhcImdlbmVyYWxDb250ZX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GVuID0gdHJ1ZTtcbiAgICAgICAgICAgICAgICAkKCcjc3RydWN0dXJlT3JHZW5lYWxvZ2llcycpLmh0bWwoZGF0YSk7XG5cbiAgICAgICAgICAgICAgICB0dXJuT25FZGl0RGVsZXRlQnV0dG9ucyhcInN0cnVjdHVyZU9yR2VuZWFsb2dpZXNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfc3RydWN0dXJlT3JHZW5lYWxvZ3lfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIHN0cnVjdHVyZU9yR2VuZWFsb2d5aWQgPSBwYXJzZUludCgkKCcjbmV4dF9zdHJ1Y3R1cmVPckdlbmVhbG9neV9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IHN0cnVjdHVyZU9yR2VuZWFsb2d5IElEOiBcIiArIHN0cnVjdHVyZU9yR2VuZWFsb2d5aWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9zdHJ1Y3R1cmVPckdlbmVhbG9neScpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfc3RydWN0dXJlT3JHZW5lYWxvZ3knKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNzdHJ1Y3R1cmVPckdlbmVhbG9neV90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIHN0cnVjdHVyZU9yR2VuZWFsb2d5aWQpO1xuICAgICAgICAgICAgICAgIC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ldChzbmFjVXJsK1wiL2VkaXRfcGFydC9cIiskKCcjY29uc3RlbGxhdGlvbmlkJykudmFsKCkrXCIvXCIrJCgnI3ZlcnNpb24nKS52YWwoKStcIj9wYXJ0PW1hbmRhdGVzXCIsIG51bGwsIGZ1bmN0aW9uIChkYXRhKSB7XG4gICAgICAgICAgICAgICAgbWFuZGF0ZU9wZW4gPSB0cnVlO1xuICAgICAgICAgICAgICAgICQoJyNtYW5kYXRlcycpLmh0bWwoZGF0YSk7XG5cbiAgICAgICAgICAgICAgICB0dXJuT25FZGl0RGVsZXRlQnV0dG9ucyhcIm1hbmRhdGVzXCIpO1xuXG4gICAgICAgICAgICAgICAgaWYgKCQoJyNuZXh0X21hbmRhdGVfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIG1hbmRhdGVpZCA9IHBhcnNlSW50KCQoJyNuZXh0X21hbmRhdGVfaScpLnRleHQoKSk7XG4gICAgICAgICAgICAgICAgfVxuICAgICAgICAgICAgICAgIGNvbnNvbGUubG9nKFwiTmV4dCBtYW5kYXRlIElEOiBcIiArIG1hbmRhdGVpZCk7XG4gICAgICAgICAgICAgICAgaWYgKCQoJyNidG5fYWRkX21hbmRhdGUnKS5leGlzdHMoKSl7XG4gICAgICAgICAgICAgICAgICAgICQoJyNidG5fYWRkX21hbmRhdGUnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNtYW5kYXRlX3RlbXBsYXRlJykuY2xvbmUoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHZhciBodG1sID0gdGV4dC5odG1sKCkucmVwbGFjZSgvWlovZywgbWFuZGF0ZWlkKTtcbiAgICAgICAgICAgICAgICAgICAgIC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ICAgICAgICBiaW9nSGlzdE9wZW4gPSB0cnVlO1xuICAgICAgICAgICAgICAgICQoJyNiaW9nSGlzdHMnKS5odG1sKGRhdGEpO1xuXG4gICAgICAgICAgICAgICAgdHVybk9uRWRpdERlbGV0ZUJ1dHRvbnMoXCJiaW9nSGlzdHNcIik7XG5cbiAgICAgICAgICAgICAgICBpZiAoJCgnI25leHRfYmlvZ0hpc3RfaScpLmV4aXN0cygpKSB7XG4gICAgICAgICAgICAgICAgICAgIGJpb2dIaXN0aWQgPSBwYXJzZUludCgkKCcjbmV4dF9iaW9nSGlzdF9pJykudGV4dCgpKTtcbiAgICAgICAgICAgICAgICB9XG4gICAgICAgICAgICAgICAgY29uc29sZS5sb2coXCJOZXh0IGJpb2dIaXN0IElEOiBcIiArIGJpb2dIaXN0aWQpO1xuICAgICAgICAgICAgICAgIGlmICgkKCcjYnRuX2FkZF9iaW9nSGlzdCcpLmV4aXN0cygpKXtcbiAgICAgICAgICAgICAgICAgICAgJCgnI2J0bl9hZGRfYmlvZ0hpc3QnKS5jbGljayhmdW5jdGlvbigpe1xuICAgICAgICAgICAgICAgICAgICAgICAgc2V0RWRpdGVkRmxhZyh0cnVlKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIC8vc29tZXRoaW5nSGFzQmVlbkVkaXRlZCA9IHRydWU7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgdGV4dCA9ICQoJyNiaW9nSGlzdF90ZW1wbGF0ZScpLmNsb25lKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgaHRtbCA9IHRleHQuaHRtbCgpLnJlcGxhY2UoL1paL2csIGJpb2dIaXN0aWQpO1xuICAgICAgICAgICAgICAgICAgICAgICAgJCgnI2FkZF9iaW9nSGlzdF9kaXYnKS5hZnRlcihodG1sKTtcbiAgICAgICAgICAgICAgICAgICAgICAgIHR1cm5PbkJ1dHRvbnMoXCJiaW9nSGlzdFwiLCBiaW9nSGlzdGlkKTtcbiAgICAgICAgICAgICAgIC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0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUVBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFFQTtBQUNBO0FBQ0E7QUFDQTtBQUVBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///3\n"); - -/***/ }) - -/******/ }))); \ No newline at end of file +!function(e,t){for(var a in t)e[a]=t[a]}(window,function(e){var t={};function a(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,a),i.l=!0,i.exports}return a.m=e,a.c=t,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)a.d(n,i,function(t){return e[t]}.bind(null,i));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="",a(a.s=3)}({3:function(e,t,a){"use strict";a.r(t),a.d(t,"somethingHasBeenEdited",(function(){return n})),a.d(t,"setEditedFlag",(function(){return i})),a.d(t,"undoSet",(function(){return r})),a.d(t,"defaults",(function(){return o})),a.d(t,"displayErrorMessage",(function(){return l})),a.d(t,"addDateEntry",(function(){return s})),a.d(t,"addDateRangeEntry",(function(){return c})),a.d(t,"addSCMEntry",(function(){return _})),a.d(t,"makeEditable",(function(){return u})),a.d(t,"makeUneditable",(function(){return v})),a.d(t,"makeSCMUneditable",(function(){return g})),a.d(t,"setRepeatedDataDeleted",(function(){return h})),a.d(t,"newAddressLine",(function(){return C})),a.d(t,"newNameEntryComponent",(function(){return Z})),a.d(t,"updateNameEntryHeading",(function(){return E})),a.d(t,"newNameEntryRule",(function(){return I})),a.d(t,"updateDate",(function(){return w})),a.d(t,"chooseSuggestedGeoPlace",(function(){return A})),a.d(t,"magicDefaultFill",(function(){return N})); +/** + * Edit Scripts + * + * Scripts used in the edit page + * + * @author Robbie Hott + * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause + * @copyright 2015 the Rector and Visitors of the University of Virginia, and + * the Regents of the University of California + */ +var n=!1;function i(e){1==e?$("#save_and_continue").addClass("save-active"):$("#save_and_continue").removeClass("save-active"),n=e}var r=new Array,o={language:{id:130,term:"eng"},script:{id:586,term:"Latn"}};function l(e,t){var a="";a=void 0===e?"an unknown problem occurred":"string"==typeof e?e:e.message?e.message:e.type?e.type:"an unknown problem occurred",$("#error-message").html("

    Oops

    "+a+'

    Go to Dashboard

    '),setTimeout((function(){$("#error-message").slideDown()}),500),console.log(t)}function s(e,t){var a=parseInt($("#next_date_"+e+"_"+t+"_j").text());i(!0);var n=$("#sub_date_template").clone().html().replace(/ZZ/g,t).replace(/XX/g,a).replace(/SHORT/g,e);return $("#add_date_"+e+"_"+t+"_div").after(n),$("#next_date_"+e+"_"+t+"_j").text(a+1),k(e+"_date"+a,t),R(e+"_date_"+a,t),u(e+"_date_"+a,t),!1}function c(e,t){var a=parseInt($("#next_date_"+e+"_"+t+"_j").text());i(!0);var n=$("#sub_dateRange_template").clone().html().replace(/ZZ/g,t).replace(/XX/g,a).replace(/SHORT/g,e);return $("#add_date_"+e+"_"+t+"_div").after(n),$("#next_date_"+e+"_"+t+"_j").text(a+1),k(e+"_date"+a,t),R(e+"_date_"+a,t),u(e+"_date_"+a,t),!1}function _(e,t){var a=parseInt($("#next_scm_"+e+"_"+t+"_j").text()),n=a+"_"+t;i(!0);var r=$("#scm_template").clone().html().replace(/ZZ/g,t).replace(/YY/g,a).replace(/SHORT/g,e);return $("#add_scm_"+e+"_"+t+"_div").after(r),$("#next_scm_"+e+"_"+t+"_j").text(a+1),function(e,t,a){$("#scm_"+e+"_editbutton_"+a+"_"+t).on("click",(function(){f(e,t,a)})),$("#scm_"+e+"_deletebutton_"+a+"_"+t).on("click",(function(){y(e,t,a)}))}(e,t,a),R("scm_"+e,n),f(e,t,a),!1}var d=null;function u(e,t){return"update"!=$("#"+e+"_operation_"+t).val()&&("delete"==$("#"+e+"_operation_"+t).val()&&x(e,t),$("#"+e+"_editbutton_"+t).removeClass("list-group-item-info").addClass("list-group-item-warning"),$("#"+e+"_editbutton_"+t).html('
    Undo'),$("#"+e+"_editbutton_"+t).off("click").on("click",(function(){!function(e,t){v(e,t),$("#"+e+"_datapart_"+t).replaceWith(r[e+"-"+t]),R(e,t),$("#"+e+"_datapart_"+t+" input[type='checkbox']").each((function(){$(this).bootstrapToggle()}))}(e,t)})),$("#"+e+"_deletebutton_"+t).removeClass("list-group-item-danger").addClass("disabled"),$("#"+e+"_deletebutton_"+t).off("click").on("click",(function(){return!1})),$("#"+e+"_panel_"+t).removeClass("panel-default").addClass("alert-info").addClass("edited-component"),p(e,t))}function p(e,t){if("update"==$("#"+e+"_operation_"+t).val())return!1;var a,n;r[e+"-"+t]=$("#"+e+"_datapart_"+t).clone(),a=e,n=t,$("#"+a+"_datapart_"+n+" div[id^='text_"+a+"']").each((function(){var e=$(this);if(e.attr("id").endsWith("_"+n)&&!e.attr("id").endsWith("ZZ")){var t=e.attr("id").replace(/^text_/,"").replace(a+"_",""),i=new RegExp("_"+n+"$","g"),r=t.replace(i,""),o=$("#"+a+"_"+r+"_"+n).val(),l=0,s="";$("#"+a+"_"+r+"_size_"+n).exists()&&(s=" size='"+(l=parseInt($("#"+a+"_"+r+"_size_"+n).val()))+"' ");var c="";$("#"+a+"_"+r+"_placeholder_"+n).exists()&&(c=$("#"+a+"_"+r+"_placeholder_"+n).val());var _="";$("#"+a+"_"+r+"_onKeyUp_"+n).exists()&&(_=$("#"+a+"_"+r+"_onKeyUp_"+n).val());var d="";""!=_&&(d=" onKeyUp='"+_+"' ");var u="';0!=l&&(u+=''),""!=c&&(u+=''),""!=_&&(u+=''),e.html(u)}})),function(e,t){$("#"+e+"_datapart_"+t+" div[id^='textarea_"+e+"']").each((function(){var a=$(this);if(a.attr("id").endsWith("_"+t)&&!a.attr("id").endsWith("ZZ")){var n=a.attr("id").replace(/^textarea_/,"").replace(e+"_",""),i=new RegExp("_"+t+"$","g"),r=n.replace(i,""),o=$("#"+e+"_"+r+"_"+t).val(),l="";a.html(l)}}))}(e,t),function(e,t){$("#"+e+"_datapart_"+t+" div[id^='checkbox_"+e+"']").each((function(){var a=$(this);if(a.attr("id").endsWith("_"+t)&&!a.attr("id").endsWith("ZZ")){var n=a.attr("id").replace(/^checkbox_/,"").replace(e+"_",""),i=new RegExp("_"+t+"$","g"),r=n.replace(i,""),o=$("#"+e+"_"+r+"_"+t).val(),l="";$("#"+e+"_"+r+"_placeholderOn_"+t).exists()&&(l=$("#"+e+"_"+r+"_placeholderOn_"+t).val());var s="";$("#"+e+"_"+r+"_placeholderOff_"+t).exists()&&(s=$("#"+e+"_"+r+"_placeholderOff_"+t).val());var c="'),""!=s&&(c+=''),a.html(c),$("#"+e+"_"+r+"_"+t).bootstrapToggle()}}))}(e,t);var o="_"+t;$("#"+e+"_datapart_"+t+" button[id^='"+e+"_']").each((function(){var e=$(this);e.attr("id").endsWith(o)&&!e.attr("id").endsWith("ZZ")&&e.removeAttr("disabled").removeClass("snac-hidden")})),$("#"+e+"_datapart_"+t+" a.label").each((function(){$(this).removeClass("snac-hidden")})),$("#"+e+"_datapart_"+t+" input[type='checkbox']").each((function(){var e=$(this);e.attr("id").endsWith(o)&&!e.attr("id").endsWith("ZZ")&&e.bootstrapToggle("enable")})),$("#"+e+"_datapart_"+t+" textarea[id^='"+e+"_']").each((function(){var t=$(this);if(t.attr("id").endsWith(o)&&!t.attr("id").endsWith("ZZ")){var a=t.attr("id").replace(e,"");-1==a.indexOf("_text_")&&-1==a.indexOf("_source_")||(t.get(0).CodeMirror=CodeMirror.fromTextArea(t.get(0),{lineNumbers:!0,lineWrapping:!0,viewportMargin:1/0,mode:{name:"xml"}}))}}));var l=!1;return $("#"+e+"_datapart_"+t+" select[id^='"+e+"_']").each((function(){var e=$(this);e.attr("id").endsWith(o)&&!e.attr("id").endsWith("ZZ")&&(l=!0)})),l||(function(e,t){$("#"+e+"_datapart_"+t+" div[id^='select_"+e+"']").each((function(){var a=$(this);if(a.attr("id").endsWith("_"+t)&&!a.attr("id").endsWith("ZZ")){var n=a.attr("id").replace("select_","").replace(e+"_",""),i=new RegExp("_"+t+"$","g"),r=n.replace(i,""),o=$("#"+e+"_"+r+"_id_"+t).val(),l=$("#"+e+"_"+r+"_term_"+t).val(),s=$("#"+e+"_"+r+"_vocabtype_"+t).val(),c=$("#"+e+"_"+r+"_minlength_"+t).val(),_="Select";$("#"+e+"_"+r+"_placeholder_"+t).exists()&&(_=$("#"+e+"_"+r+"_placeholder_"+t).val());var d="";$("#"+e+"_"+r+"_defaultOptions_"+t).exists()&&(d=$("#"+e+"_"+r+"_defaultOptions_"+t).val()),a.html("'),"citation"==r?scm_source_select_replace($("#"+e+"_"+r+"_id_"+t),"_"+t):vocab_select_replace($("#"+e+"_"+r+"_id_"+t),"_"+t,s,c)}}))}(e,t),function(e,t){$("#"+e+"_datapart_"+t+" div[id^='selectGeo_"+e+"']").each((function(){var a=$(this);if(a.attr("id").endsWith("_"+t)&&!a.attr("id").endsWith("ZZ")){var n=a.attr("id").replace("selectGeo_","").replace(e+"_",""),i=new RegExp("_"+t+"$","g"),r=n.replace(i,""),o=$("#"+e+"_"+r+"_id_"+t).val(),l=$("#"+e+"_"+r+"_term_"+t).val(),s="",c=" selected";"true"==$("#"+e+"_confirmed_"+t).val()||(s=" selected",c=""),a.html(""),geovocab_select_replace($("#"+e+"_"+r+"_id_"+t),"_"+t)}}))}(e,t),function(e,t){$("div[id^='date_"+e+"']").each((function(){var a,n=$(this);if(n.attr("id").endsWith("_"+t)&&!n.attr("id").endsWith("ZZ")){var i=n.attr("id").replace("date_","").replace(e+"_",""),r=new RegExp("_"+t+"$","g"),o=i.replace(r,""),l=$("#"+e+"_"+o+"_"+t).val(),s=3==(a=l.split("-")).length?{year:parseInt(a[0]),month:parseInt(a[1]),day:parseInt(a[2])}:2==a.length?{year:parseInt(a[0]),month:parseInt(a[1]),day:""}:1==a.length&&""!=a[0]?{year:parseInt(a[0]),month:"",day:""}:{year:"",month:"",day:""},c="";c+=" - ",c+=" ",c+=" - ",c+=" ",c+="",n.html(c),$("#"+e+"_"+o+"_month_"+t).select2({width:"57%",allowClear:!0,theme:"bootstrap",placeholder:"Month"})}}))}(e,t)),$("#"+e+"_datapart_"+t+" span.move-handle").each((function(){$(this).removeClass("snac-hidden")})),$("#"+e+"_reorderable_"+t).sortable({items:".reorderable",opacity:.5,update:function(a,n){var i=$("#"+e+"_reorderable_"+t).sortable("toArray");console.log(i),i.forEach((function(e,t){$("#"+e+" input.order-index").val(t)})),"nameEntry"==e&&E(t)}}),"constellationRelation"==e&&$("#"+e+"_type_id_"+t).change((function(){W(e,t,$("#"+e+"_type_id_"+t+" option:selected").text())})),"resourceRelation"==e&&$("#"+e+"_role_id_"+t).change((function(){W(e,t,$("#"+e+"_role_id_"+t+" option:selected").text())})),"place"==e&&(null!=$("#"+e+"_geoplace_id_"+t).val()&&""!=$("#"+e+"_geoplace_id_"+t).val()&&j(e,t,$("#"+e+"_geoplace_id_"+t).val()),$("#"+e+"_geoplace_id_"+t).change((function(){j(e,t,$("#"+e+"_geoplace_id_"+t).val())}))),"nameEntry"!==e||"700"!==$("#entityType").val()||"Name"!==$("#nameEntry_component_0_panel_"+t).find("select:first").text()||$("#nameEntry_panel_"+t).find(".name-parser").length||0!==$("#nameEntry_component_1_panel_"+t).length||$("#nameEntry_component_add_"+t).after(''),""!=$("#"+e+"_id_"+t).val()?$("#"+e+"_operation_"+t).val("update"):$("#"+e+"_operation_"+t).val("insert"),i(!0),!1}function m(e,t){var a="_"+t;$("#"+e+"_datapart_"+t+" span.move-handle").each((function(){$(this).addClass("snac-hidden")})),$("#"+e+"_reorderable_"+t).hasClass("ui-sortable")&&$("#"+e+"_reorderable_"+t).sortable("destroy"),$("#"+e+"_datapart_"+t+" textarea[id^='"+e+"_']").each((function(){var e=$(this);!e.attr("id").endsWith(a)||e.attr("id").endsWith("ZZ")||-1==e.attr("id").indexOf("_text_")&&-1==e.attr("id").indexOf("_source_")||e.get(0).CodeMirror&&e.get(0).CodeMirror.toTextArea()})),$("#"+e+"_datapart_"+t+" button[id^='"+e+"_']").each((function(){var e=$(this);e.attr("id").endsWith(a)&&!e.attr("id").endsWith("ZZ")&&e.attr("disabled","true").addClass("snac-hidden")})),$("#"+e+"_datapart_"+t+" a.label").each((function(){$(this).addClass("snac-hidden")})),$("#"+e+"_datapart_"+t+" input[type='checkbox']").each((function(){var e=$(this);e.attr("id").endsWith(a)&&!e.attr("id").endsWith("ZZ")&&e.bootstrapToggle("disable")})),function(e,t){$("#"+e+"_datapart_"+t+" div[id^='text_"+e+"']").each((function(){var a=$(this);if(a.attr("id").endsWith("_"+t)&&!a.attr("id").endsWith("ZZ")){var n=a.attr("id").replace(/^text_/,"").replace(e+"_",""),i=new RegExp("_"+t+"$","g"),r=n.replace(i,""),o=$("#"+e+"_"+r+"_"+t).val(),l=0;$("#"+e+"_"+r+"_size_"+t).exists()&&(l=parseInt($("#"+e+"_"+r+"_size_"+t).val()));var s="";$("#"+e+"_"+r+"_placeholder_"+t).exists()&&(s=$("#"+e+"_"+r+"_placeholder_"+t).val());var c="";$("#"+e+"_"+r+"_onKeyUp_"+t).exists()&&(c=$("#"+e+"_"+r+"_onKeyUp_"+t).val());var _="';_+="

    "+o+"

    ",0!=l&&(_+=''),""!=s&&(_+=''),""!=c&&(_+=''),a.html(_)}}))}(e,t),function(e,t){$("#"+e+"_datapart_"+t+" div[id^='textarea_"+e+"']").each((function(){var a=$(this);if(a.attr("id").endsWith("_"+t)&&!a.attr("id").endsWith("ZZ")){var n=a.attr("id").replace(/^textarea_/,"").replace(e+"_",""),i=new RegExp("_"+t+"$","g"),r=n.replace(i,""),o=$("#"+e+"_"+r+"_"+t).val(),l="";l+="
    "+o+"
    ",a.html(l)}}))}(e,t),function(e,t){$("#"+e+"_datapart_"+t+" div[id^='checkbox_"+e+"']").each((function(){var a=$(this);if(a.attr("id").endsWith("_"+t)&&!a.attr("id").endsWith("ZZ")){var n=a.attr("id").replace(/^checkbox_/,"").replace(e+"_",""),i=new RegExp("_"+t+"$","g"),r=n.replace(i,""),o=$("#"+e+"_"+r+"_"+t).val(),l=$("#"+e+"_"+r+"_"+t).prop("checked"),s="";$("#"+e+"_"+r+"_placeholderOn_"+t).exists()&&(s=$("#"+e+"_"+r+"_placeholderOn_"+t).val());var c="";$("#"+e+"_"+r+"_placeholderOff_"+t).exists()&&(c=$("#"+e+"_"+r+"_placeholderOff_"+t).val());var _="',_+="

    ",l?_+=""!=s?s:o:""!=c&&(_+=c),_+="

    ",""!=s&&(_+=''),""!=c&&(_+=''),$("#"+e+"_"+r+"_"+t).bootstrapToggle("destroy"),a.html(_)}}))}(e,t);var n=!1;$("#"+e+"_datapart_"+t+" select[id^='"+e+"_']").each((function(){var e=$(this);e.attr("id").endsWith(a)&&!e.attr("id").endsWith("ZZ")&&(n=!0)})),n&&(function(e,t){$("div[id^='select_"+e+"']").each((function(){var a=$(this);if(a.attr("id").endsWith("_"+t)&&!a.attr("id").endsWith("ZZ")){var n=a.attr("id").replace("select_","").replace(e+"_",""),i=new RegExp("_"+t+"$","g"),r=n.replace(i,""),o=$("#"+e+"_"+r+"_id_"+t).val(),l=$("#"+e+"_"+r+"_id_"+t+" option:selected").text(),s=$("#"+e+"_"+r+"_vocabtype_"+t).val(),c=$("#"+e+"_"+r+"_minlength_"+t).val(),_="",d="";"name_component"==s&&(_="name-component-type",d=" :"),a.html('

    '+l+d+"

    ")}}))}(e,t),function(e,t){$("div[id^='selectGeo_"+e+"']").each((function(){var a=$(this);if(a.attr("id").endsWith("_"+t)&&!a.attr("id").endsWith("ZZ")){var n=a.attr("id").replace("selectGeo_","").replace(e+"_",""),i=new RegExp("_"+t+"$","g"),r=n.replace(i,""),o=$("#"+e+"_"+r+"_id_"+t).val(),l=$("#"+e+"_"+r+"_id_"+t+" option:selected").text();a.html('')}}))}(e,t),function(e,t){$("div[id^='date_"+e+"']").each((function(){var a=$(this);if(a.attr("id").endsWith("_"+t)&&!a.attr("id").endsWith("ZZ")){var n=a.attr("id").replace("date_","").replace(e+"_",""),i=new RegExp("_"+t+"$","g"),r=n.replace(i,"");w(e,t);var o=$("#"+e+"_"+r+"_"+t).val(),l="

    "+o+"

    ";l+="",a.html(l)}}))}(e,t)),$("#"+e+"_datapart_"+t+" input[id^='"+e+"_']").each((function(){var e=$(this);e.attr("id").endsWith("_operation"+a)&&!e.attr("id").endsWith("ZZ")&&e.val("")})),$("#"+e+"_panel_"+t).addClass("panel-default").removeClass("alert-info").removeClass("edited-component")}function v(e,t){return m(e,t),$("#"+e+"_editbutton_"+t).addClass("list-group-item-info").removeClass("list-group-item-warning"),$("#"+e+"_editbutton_"+t).html('
    Edit'),$("#"+e+"_editbutton_"+t).off("click").on("click",(function(){u(e,t)})),$("#"+e+"_deletebutton_"+t).addClass("list-group-item-danger").removeClass("disabled"),$("#"+e+"_deletebutton_"+t).off("click").on("click",(function(){x(e,t)})),!1}function f(e,t,a){var n=a+"_"+t,i="scm_"+e;return"update"!=$("#"+i+"_operation_"+n).val()&&("delete"==$("#"+i+"_operation_"+n).val()&&y(e,t,a),$("#"+i+"_editbutton_"+n).removeClass("list-group-item-info").addClass("list-group-item-warning"),$("#"+i+"_editbutton_"+n).html(''),$("#"+i+"_editbutton_"+n).off("click").on("click",(function(){!function(e,t,a){var n=a+"_"+t;g(e,t,a),$("#scm_"+e+"_datapart_"+n).replaceWith(r["scm_"+e+"-"+n]),R("scm_"+e,n)}(e,t,a)})),$("#"+i+"_deletebutton_"+n).removeClass("list-group-item-danger").addClass("disabled"),$("#"+i+"_deletebutton_"+n).off("click").on("click",(function(){return!1})),$("#"+i+"_panel_"+n).removeClass("panel-default").addClass("alert-info").addClass("edited-component"),p(i,n))}function g(e,t,a){var n=a+"_"+t;return m("scm_"+e,n),$("#scm_"+e+"_editbutton_"+n).addClass("list-group-item-info").removeClass("list-group-item-warning"),$("#scm_"+e+"_editbutton_"+n).html(''),$("#scm_"+e+"_editbutton_"+n).off("click").on("click",(function(){f(e,t,a)})),$("#scm_"+e+"_deletebutton_"+n).addClass("list-group-item-danger").removeClass("disabled"),$("#scm_"+e+"_deletebutton_"+n).off("click").on("click",(function(){y(e,t,a)})),!1}function h(e,t){return"delete"!=$("#"+e+"_operation_"+t).val()?($("#"+e+"_remove_"+t).removeClass("btn-danger").addClass("btn-warning"),$("#"+e+"_remove_"+t).html('')):($("#"+e+"_remove_"+t).removeClass("btn-warning").addClass("btn-danger"),$("#"+e+"_remove_"+t).html('')),b(e,t)}function x(e,t){return"delete"!=$("#"+e+"_operation_"+t).val()?($("#"+e+"_deletebutton_"+t).removeClass("list-group-item-danger").addClass("list-group-item-warning"),$("#"+e+"_deletebutton_"+t).html('
    Undo'),$("#"+e+"_editbutton_"+t).removeClass("list-group-item-info").addClass("disabled"),$("#"+e+"_editbutton_"+t).off("click").on("click",(function(){return!1})),$("#"+e+"_datebutton_"+t).removeClass("list-group-item-success").addClass("disabled").prop("disabled",!0),$("#"+e+"_scmbutton_"+t).removeClass("list-group-item-success").addClass("disabled").prop("disabled",!0)):($("#"+e+"_deletebutton_"+t).removeClass("list-group-item-warning").addClass("list-group-item-danger"),$("#"+e+"_deletebutton_"+t).html('
    Trash'),$("#"+e+"_editbutton_"+t).addClass("list-group-item-info").removeClass("disabled"),$("#"+e+"_editbutton_"+t).off("click").on("click",(function(){u(e,t)})),$("#"+e+"_datebutton_"+t).addClass("list-group-item-success").removeClass("disabled").prop("disabled",!1),$("#"+e+"_scmbutton_"+t).addClass("list-group-item-success").removeClass("disabled").prop("disabled",!1)),b(e,t)}function b(e,t){if("delete"!=$("#"+e+"_operation_"+t).val())$("#"+e+"_panel_"+t).removeClass("panel-default").addClass("alert-danger").addClass("deleted-component"),$("#"+e+"_operation_"+t).val("delete");else{$("#"+e+"_panel_"+t).removeClass("alert-danger").addClass("panel-default").removeClass("deleted-component");var a=!1;$("select[id^='"+e+"_']").each((function(){var e=$(this);e.attr("id").endsWith("_"+t)&&!e.attr("id").endsWith("ZZ")&&(a=!0)})),a?""!=$("#"+e+"_id_"+t).val()?$("#"+e+"_operation_"+t).val("update"):$("#"+e+"_operation_"+t).val("insert"):$("#"+e+"_operation_"+t).val("")}return i(!0),!1}function y(e,t,a){var n=a+"_"+t;return"delete"!=$("#scm_"+e+"_operation_"+n).val()?($("#scm_"+e+"_deletebutton_"+n).removeClass("list-group-item-danger").addClass("list-group-item-warning"),$("#scm_"+e+"_deletebutton_"+n).html(''),$("#scm_"+e+"_editbutton_"+n).removeClass("list-group-item-info").addClass("disabled"),$("#scm_"+e+"_editbutton_"+n).off("click").on("click",(function(){return!1}))):($("#scm_"+e+"_deletebutton_"+n).removeClass("list-group-item-warning").addClass("list-group-item-danger"),$("#scm_"+e+"_deletebutton_"+n).html(''),$("#scm_"+e+"_editbutton_"+n).addClass("list-group-item-info").removeClass("disabled"),$("#scm_"+e+"_editbutton_"+n).off("click").on("click",(function(){f(e,t,a)}))),b("scm_"+e,n)}function k(e,t){$("#"+e+"_editbutton_"+t).on("click",(function(){u(e,t)})),$("#"+e+"_deletebutton_"+t).on("click",(function(){x(e,t)}))}function R(e,t){$((function(){$("#"+e+"_panel_"+t+' [data-toggle="tooltip"]').tooltip()})),$((function(){$("#"+e+"_panel_"+t+' [data-toggle="popover"]').popover({trigger:"hover",container:"body"})}))}function C(e){var t=1;$("#place_address_next_j_"+e).exists()&&(t=parseInt($("#place_address_next_j_"+e).text())),console.log("Creating new address line for place "+e+" with id: "+t),i(!0);var a=$("#addressline_template").clone().html().replace(/ZZ/g,e).replace(/YY/g,t);return $("#place_address_add_div_"+e).before(a),$("#place_address_"+t+"_operation_1").val("insert"),p("place_address_"+t,e),vocab_select_replace($("#place_address_"+t+"_type_id_"+e),"_"+e,"address_part",0),$("#place_address_next_j_"+e).text(++t),!1}function Z(e){!function(e){$("#nameEntry_datapart_"+e).find(".name-parser").remove()}(e);var t=1;$("#nameEntry_component_next_j_"+e).exists()&&(t=parseInt($("#nameEntry_component_next_j_"+e).text())),console.log("Creating new name entry component for nameEntry "+e+" with id: "+t),"700"!==$("#entityType").val()||0!=t||$("#nameEntry_panel_"+e).find(".name-parser").length||0!==$("#nameEntry_component_1_panel_"+e).length||$("#nameEntry_component_add_"+e).after(''),i(!0);var a=$("#component_template").clone().html().replace(/ZZ/g,e).replace(/YY/g,t);return $("#nameEntry_component_add_div_"+e).before(a),$("#nameEntry_component_"+t+"_operation_1").val("insert"),p("nameEntry_component_"+t,e),vocab_select_replace($("#nameEntry_component_"+t+"_type_id_"+e),"_"+e,"name_component",0),$("#nameEntry_component_next_j_"+e).text(++t),!1}function E(e){var t="",a=[];$("#nameEntry_panel_"+e+" div[id^='nameEntry_component_']").each((function(){var t=$(this);if(!t.hasClass("deleted-component")&&t.attr("id").endsWith("_panel_"+e)&&!t.attr("id").endsWith("ZZ")){var n=t.attr("id").replace("nameEntry_component_","").replace("_panel_"+e,""),i=$("#nameEntry_component_"+n+"_type_id_"+e+" option:selected").text(),r=$("#nameEntry_component_"+n+"_text_"+e).val();a.push([i,r])}}));var n=$("#entityType option:selected").text();t=combineNameHeading(a,n),$("#nameEntry_heading_"+e).text(t.trim()),$("#nameEntry_original_"+e).val(t.trim())}function I(e){var t=1;$("#nameEntry_rule_next_j_"+e).exists()&&(t=parseInt($("#nameEntry_rule_next_j_"+e).text())),console.log("Creating new name entry rule for nameEntry "+e+" with id: "+t),i(!0);var a=$("#rule_template").clone().html().replace(/ZZ/g,e).replace(/YY/g,t);return $("#nameEntry_rule_add_div_"+e).before(a),$("#nameEntry_rule_"+t+"_operation_1").val("insert"),R("nameEntry_rule_"+t,e),p("nameEntry_rule_"+t,e),$("#nameEntry_rule_next_j_"+e).text(++t),!1}function D(e,t){for(var a=e+"";a.lengthUnconfirmed"),$("#"+e+"_geoterm_caption_"+t).text("Recorded as: "+$("#"+e+"_original_"+t).val())):($("#"+e+"_geoterm_text_"+t).text("--"),$("#"+e+"_geoterm_caption_"+t).text("GeoPlace term not specified"))))):($("#"+e+"_confirmed_"+t).val("false"),$("#"+e+"_geoterm_text_"+t).html("Unconfirmed"),$("#"+e+"_geoterm_maplink_"+t).addClass("disabled"),$("#"+e+"_geoterm_maplink_"+t).prop("onclick",null).off("click"),void(""!=$("#"+e+"_original_"+t).val()?$("#"+e+"_geoterm_caption_"+t).text("Recorded as: "+$("#"+e+"_original_"+t).val()):$("#"+e+"_geoterm_caption_"+t).text()))}function N(e,t){if(void 0!==typeof o[t]){var a={id:o[t].id,text:o[t].term};if($("#"+e).find("option[value='"+a.id+"']").length)$("#"+e).val(a.id).trigger("change");else{var n=new Option(a.text,a.id,!1,!0);$("#"+e).append(n).trigger("change")}}}function G(e,t,a,n){var i=t.attr("id").split("_")[2];t.find(".reorderable").replaceWith('
    Name: '+a+"
    ");for(var r={},o=0;o"+t+": "+e[t]+"");$("#name-parser-options").append("
    "),$("#name-parser-options").find("input[type='radio']:last").data("parsed-name",e),o="",l++})),$("#name-parser-options").find("input[type='radio']:first").prop("checked",!0),$("#parser-accept-btn").unbind("click"),$("#parser-accept-btn").on("click",(function(){var e=$('#name-parser input[type="radio"]:checked').data("parsed-name");$.get(snacUrl+"/vocabulary/?type=name_component&entity_type=700").done((function(t){G(e,a,n,t.results)}))}))}(e),$("#name-parser").modal("toggle")})),$("#name-parser").on("shown.bs.modal",(function(){$("#parser-accept-btn").focus()})),"insert"==$("#operation").val()&&i(!0),T(),$("#entityType").exists()&&$("#entityType").change((function(){i(!0),null!=$("#constellationid").val()&&""!=$("#constellationid").val()&&$("#operation").val("update")}));var e=1;$("#next_nameEntry_i").exists()&&(e=parseInt($("#next_nameEntry_i").text())),console.log("Next NameEntry ID: "+e),$("#btn_add_nameEntry").exists()&&$("#btn_add_nameEntry").click((function(){i(!0);var t=$("#nameEntry_template").clone().html().replace(/ZZ/g,e);return $("#add_nameEntry_div").after(t),k("nameEntry",e),R("nameEntry",e),u("nameEntry",e),e+=1,!1}));var t=1,a=!1;$("#genderstab").exists()&&$("#genderstab").click((function(){a||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=genders",null,(function(e){a=!0,$("#genders").html(e),T("genders"),$("#next_gender_i").exists()&&(t=parseInt($("#next_gender_i").text())),console.log("Next Gender ID: "+t),$("#btn_add_gender").exists()&&$("#btn_add_gender").click((function(){i(!0);var e=$("#gender_template").clone().html().replace(/ZZ/g,t);return $("#add_gender_div").after(e),k("gender",t),R("gender",t),u("gender",t),t+=1,!1})),O("genders")}))}));var n=1,r=!1;$("#existstab").exists()&&$("#existstab").click((function(){r||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=dates",null,(function(e){r=!0,$("#dates").html(e),T("dates"),$("#next_exist_i").exists()&&(n=parseInt($("#next_exist_i").text())),console.log("Next Exist Date ID: "+n),$("#btn_add_exist_date").exists()&&$("#btn_add_exist_date").click((function(){i(!0);var e=$("#exist_date_template").clone().html().replace(/ZZ/g,n);return $("#add_exist_div").after(e),k("exist",n),R("exist",n),u("exist",n),n+=1,!1})),$("#btn_add_exist_dateRange").exists()&&$("#btn_add_exist_dateRange").click((function(){i(!0);var e=$("#exist_dateRange_template").clone().html().replace(/ZZ/g,n);return $("#add_exist_div").after(e),k("exist",n),R("exist",n),u("exist",n),n+=1,!1})),O("dates")}))}));var o=1,l=!1;$("#sameAstab").exists()&&$("#sameAstab").click((function(){l||($.get(snacUrl+"/vocabulary?type=record_type&q=SameAs",null,(function(e){sameAsTermId=e.results[0].id,$("#sameAs_type_id_ZZ").val(sameAsTermId)})),$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=sameAs",null,(function(e){l=!0,$("#sameAs").html(e),T("sameAs"),$("#next_sameAs_i").exists()&&(o=parseInt($("#next_sameAs_i").text())),console.log("Next sameAs ID: "+o),$("#btn_add_sameAs").exists()&&$("#btn_add_sameAs").click((function(){i(!0);var e=$("#sameAs_template").clone().html().replace(/ZZ/g,o);return $("#add_sameAs_div").after(e),k("sameAs",o),R("sameAs",o),u("sameAs",o),o+=1,!1})),O("sameAs")})))}));var s=1,c=!1;$("#entityIDtab").exists()&&$("#entityIDtab").click((function(){c||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=entityID",null,(function(e){c=!0,$("#entityID").html(e),T("entityID"),$("#next_entityID_i").exists()&&(s=parseInt($("#next_entityID_i").text())),console.log("Next entityID ID: "+s),$("#btn_add_entityID").exists()&&$("#btn_add_entityID").click((function(){i(!0);var e=$("#entityID_template").clone().html().replace(/ZZ/g,s);return $("#add_entityID_div").after(e),k("entityID",s),R("entityID",s),u("entityID",s),s+=1,!1})),O("entityID")}))}));var _=1,d=!1;$("#sourcestab").exists()&&$("#sourcestab").click((function(){d||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=sources",null,(function(e){d=!0,$("#sources").html(e),T("sources"),$("#next_source_i").exists()&&(_=parseInt($("#next_source_i").text())),console.log("Next source ID: "+_),$("#btn_add_source").exists()&&$("#btn_add_source").click((function(){i(!0);var e=$("#source_template").clone().html().replace(/ZZ/g,_);return $("#add_source_div").after(e),k("source",_),R("source",_),u("source",_),_+=1,!1})),O("sources")}))}));var p=1,m=!1;$("#resourceRelationstab").exists()&&$("#resourceRelationstab").click((function(){m||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=resourceRelations",null,(function(e){m=!0,$("#resourceRelations").html(e),T("resourceRelations"),$("#next_resourceRelation_i").exists()&&(p=parseInt($("#next_resourceRelation_i").text())),console.log("Next resourceRelation ID: "+p),$("#btn_create_resourceRelation").exists()&&$("#btn_create_resourceRelation").click((function(){var e=$("input[name=resourceChoice]:checked","#resource_search_form").val();if(null!=e&&null!=resourceResults&&"new"!=e){i(!0);var t=$("#resourceRelation_template").clone().html().replace(/ZZ/g,p);return $("#add_resourceRelation_div").after(t),void 0!==resourceResults[e].id&&$("#resourceRelation_resourceid_"+p).val(resourceResults[e].id),void 0!==resourceResults[e].version&&$("#resourceRelation_resourceversion_"+p).val(resourceResults[e].version),void 0!==resourceResults[e].link&&$("#resourceRelation_linkText_"+p).html(""+resourceResults[e].link+" View"),void 0!==resourceResults[e].displayEntry&&$("#resourceRelation_displayEntryText_"+p).text(resourceResults[e].displayEntry),void 0!==resourceResults[e].title&&($("#resourceRelation_titleText_"+p).text(resourceResults[e].title),U("resourceRelation",p,resourceResults[e].title)),void 0!==resourceResults[e].abstract&&$("#resourceRelation_abstractText_"+p).text(resourceResults[e].abstract),void 0!==resourceResults[e].extent&&$("#resourceRelation_extentText_"+p).text(resourceResults[e].extent),void 0!==resourceResults[e].documentType&&void 0!==resourceResults[e].documentType.term&&$("#resourceRelation_documentTypeText_"+p).text(resourceResults[e].documentType.term),$("#resourceRelation_linkText_"+p).after("View in SNAC"),k("resourceRelation",p),R("resourceRelation",p),u("resourceRelation",p),p+=1,$("#resource-results-box").html(""),!0}return!1})),$("#btn_open_create_resource").exists()&&$("#btn_open_create_resource").click((function(){$("#resourceSearchPane").modal("hide"),setTimeout((function(){$("#resourceCreatePane").modal("show")}),500);var e=$("#resource_template").clone().html().replace(/ZZ/g,0);$("#resource-create-box").html(e);var t=$("#resource_create_form");-1==$("#resource-searchbox").val().indexOf("http")?t.find("#resource-title").val($("#resource-searchbox").val()):t.find("#resource-url").val($("#resource-searchbox").val()),t.find('[data-toggle="popover"]').popover({trigger:"hover",container:"body"}),loadVocabSelectOptions(t.find("#resource-type-select"),"document_type","Resource Type"),vocab_select_replace(t.find("#resource-repo"),"","holding",3),t.find("#new-resource-language-btn").on("click",newResourceLanguage),t.find("#magic-resource-language-btn").on("click",magicNewResourceLanguage),$("#search-results-box").on("click","a.list-group-item",selectHoldingRepository);var a=null;return t.find("#searchbox").keyup((function(){clearTimeout(a),a=setTimeout((function(){setSearchPosition(0),searchAndUpdate()}),500)})),$("#resource-results-box").html(""),!1})),$("#btn_create_resource").exists()&&$("#resource_create_form").on("submit",(function(){if(""!=$("#resource_create_form #resource-url").val()||confirm("Are you sure you want to save without an HREF?"))return $("#resource_create_form input, textarea").each((function(){$(this).val($.trim($(this).val()))})),setDeletedResourceLanguageOperations($("#resource_create_form")),$.post(snacUrl+"/save_resource",$("#resource_create_form").serialize(),(function(e){if(void 0!==e.result&&"false"!==e.result){i(!0);var t=$("#resourceRelation_template").clone().html().replace(/ZZ/g,p);return $("#add_resourceRelation_div").after(t),void 0!==e.resource.id&&$("#resourceRelation_resourceid_"+p).val(e.resource.id),void 0!==e.resource.version&&$("#resourceRelation_resourceversion_"+p).val(e.resource.version),void 0!==e.resource.link&&$("#resourceRelation_linkText_"+p).html(""+e.resource.link+" View"),void 0!==e.resource.displayEntry&&$("#resourceRelation_displayEntryText_"+p).text(e.resource.displayEntry),void 0!==e.resource.title&&($("#resourceRelation_titleText_"+p).text(e.resource.title),U("resourceRelation",p,e.resource.title)),void 0!==e.resource.abstract&&$("#resourceRelation_abstractText_"+p).text(e.resource.abstract),void 0!==e.resource.extent&&$("#resourceRelation_extentText_"+p).text(e.resource.extent),void 0!==e.resource.documentType&&void 0!==e.resource.documentType.term&&$("#resourceRelation_documentTypeText_"+p).text(e.resource.documentType.term),$("#resourceRelation_linkText_"+p).after("View in SNAC"),k("resourceRelation",p),R("resourceRelation",p),u("resourceRelation",p),p+=1,$("#resourceCreatePane").modal("hide"),$("#resource-create-box").html(""),!0}return console.log(e),!1})),!1})),O("resourceRelations")}))}));var v=1,f=!1;$("#constellationRelationstab").exists()&&$("#constellationRelationstab").click((function(){f||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=constellationRelations",null,(function(e){f=!0,$("#constellationRelations").html(e),T("constellationRelations"),$("#next_constellationRelation_i").exists()&&(v=parseInt($("#next_constellationRelation_i").text())),console.log("Next constellationRelation ID: "+v),$("#btn_create_constellationRelation").exists()&&$("#btn_create_constellationRelation").click((function(){var e=$("input[name=relationChoice]:checked","#relation_search_form").val();if(null!=e){i(!0);var t=$("#constellationRelation_template").clone().html().replace(/ZZ/g,v);return $("#add_constellationRelation_div").after(t),$("#constellationRelation_targetID_"+v).val(e),$("#constellationRelation_content_"+v).val($("#relationChoice_nameEntry_"+e).val()),$("#constellationRelation_targetArkID_"+v).val($("#relationChoice_arkID_"+e).val()),$("#constellationRelation_targetEntityType_"+v).val($("#relationChoice_entityType_"+e).val()),function(e,t,a){var n="";"person"==a?n='
    ':"corporateBody"==a?n='
    ':"family"==a&&(n='
    '),$("#"+e+"_relationPictureIcon_"+t).html(n)}("constellationRelation",v,$("#relationChoice_entityTypeText_"+e).val()),U("constellationRelation",v,$("#relationChoice_nameEntry_"+e).val()),$("#constellationRelation_contentText_"+v).text($("#relationChoice_nameEntry_"+e).val()),$("#constellationRelation_targetArkIDText_"+v).text($("#relationChoice_arkID_"+e).val()),k("constellationRelation",v),R("constellationRelation",v),u("constellationRelation",v),v+=1,!0}return!1})),O("constellationRelations")}))}));var g=1,h=!1;$("#languagesUsedtab").exists()&&$("#languagesUsedtab").click((function(){h||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=languagesUsed",null,(function(e){h=!0,$("#languagesUsed").html(e),T("languagesUsed"),$("#next_language_i").exists()&&(g=parseInt($("#next_language_i").text())),console.log("Next language ID: "+g),$("#btn_add_language").exists()&&$("#btn_add_language").click((function(){i(!0);var e=$("#language_template").clone().html().replace(/ZZ/g,g);return $("#add_language_div").after(e),k("language",g),R("language",g),u("language",g),g+=1,!1})),O("languagesUsed")}))}));var x=1,b=!1;$("#subjectstab").exists()&&$("#subjectstab").click((function(){b||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=subjects",null,(function(e){b=!0,$("#subjects").html(e),T("subjects"),$("#next_subject_i").exists()&&(x=parseInt($("#next_subject_i").text())),console.log("Next subject ID: "+x),$("#btn_add_subject").exists()&&$("#btn_add_subject").click((function(){i(!0);var e=$("#subject_template").clone().html().replace(/ZZ/g,x);return $("#add_subject_div").after(e),k("subject",x),R("subject",x),u("subject",x),x+=1,!1})),O("subjects")}))}));var y=1,C=!1;$("#nationalitiestab").exists()&&$("#nationalitiestab").click((function(){C||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=nationalities",null,(function(e){C=!0,$("#nationalities").html(e),T("nationalities"),$("#next_nationality_i").exists()&&(y=parseInt($("#next_nationality_i").text())),console.log("Next nationality ID: "+y),$("#btn_add_nationality").exists()&&$("#btn_add_nationality").click((function(){i(!0);var e=$("#nationality_template").clone().html().replace(/ZZ/g,y);return $("#add_nationality_div").after(e),k("nationality",y),R("nationality",y),u("nationality",y),y+=1,!1})),O("nationalities")}))}));var Z=1,E=!1;$("#functionstab").exists()&&$("#functionstab").click((function(){E||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=functions",null,(function(e){E=!0,$("#functions").html(e),T("functions"),$("#next_function_i").exists()&&(Z=parseInt($("#next_function_i").text())),console.log("Next function ID: "+Z),$("#btn_add_function").exists()&&$("#btn_add_function").click((function(){i(!0);var e=$("#function_template").clone().html().replace(/ZZ/g,Z);return $("#add_function_div").after(e),k("function",Z),R("function",Z),u("function",Z),Z+=1,!1})),O("functions")}))}));var I=1,D=!1;$("#occupationstab").exists()&&$("#occupationstab").click((function(){D||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=occupations",null,(function(e){D=!0,$("#occupations").html(e),T("occupations"),$("#next_occupation_i").exists()&&(I=parseInt($("#next_occupation_i").text())),console.log("Next occupation ID: "+I),$("#btn_add_occupation").exists()&&$("#btn_add_occupation").click((function(){i(!0);var e=$("#occupation_template").clone().html().replace(/ZZ/g,I);return $("#add_occupation_div").after(e),k("occupation",I),R("occupation",I),u("occupation",I),I+=1,!1})),O("occupations")}))}));var w=1,W=!1;$("#legalStatusestab").exists()&&$("#legalStatusestab").click((function(){W||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=legalStatuses",null,(function(e){W=!0,$("#legalStatuses").html(e),T("legalStatuses"),$("#next_legalStatus_i").exists()&&(w=parseInt($("#next_legalStatus_i").text())),console.log("Next legalStatus ID: "+w),$("#btn_add_legalStatus").exists()&&$("#btn_add_legalStatus").click((function(){i(!0);var e=$("#legalStatus_template").clone().html().replace(/ZZ/g,w);return $("#add_legalStatus_div").after(e),k("legalStatus",w),R("legalStatus",w),u("legalStatus",w),w+=1,!1})),O("legalStatuses")}))}));var A=1,j=!1;$("#placestab").exists()&&$("#placestab").click((function(){j||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=places",null,(function(e){j=!0,$("#places").html(e),S(),T("places"),$("#next_place_i").exists()&&(A=parseInt($("#next_place_i").text())),console.log("Next place ID: "+A),$("#btn_add_place").exists()&&$("#btn_add_place").click((function(){i(!0);var e=$("#place_template").clone().html().replace(/ZZ/g,A);return $("#add_place_div").after(e),k("place",A),R("place",A),u("place",A),A+=1,!1})),O("places")}))}));var N=1,H=!1;$("#conventionDeclarationstab").exists()&&$("#conventionDeclarationstab").click((function(){H||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=conventionDeclarations",null,(function(e){H=!0,$("#conventionDeclarations").html(e),T("conventionDeclarations"),$("#next_conventionDeclaration_i").exists()&&(N=parseInt($("#next_conventionDeclaration_i").text())),console.log("Next conventionDeclaration ID: "+N),$("#btn_add_conventionDeclaration").exists()&&$("#btn_add_conventionDeclaration").click((function(){i(!0);var e=$("#conventionDeclaration_template").clone().html().replace(/ZZ/g,N);return $("#add_conventionDeclaration_div").after(e),k("conventionDeclaration",N),R("conventionDeclaration",N),u("conventionDeclaration",N),N+=1,!1})),O("conventionDeclarations")}))}));var P=1,M=!1;$("#generalContextstab").exists()&&$("#generalContextstab").click((function(){M||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=generalContexts",null,(function(e){M=!0,$("#generalContexts").html(e),T("generalContexts"),$("#next_generalContext_i").exists()&&(P=parseInt($("#next_generalContext_i").text())),console.log("Next generalContext ID: "+P),$("#btn_add_generalContext").exists()&&$("#btn_add_generalContext").click((function(){i(!0);var e=$("#generalContext_template").clone().html().replace(/ZZ/g,P);return $("#add_generalContext_div").after(e),k("generalContext",P),R("generalContext",P),u("generalContext",P),P+=1,!1})),O("generalContexts")}))}));var Y=1,z=!1;$("#structureOrGenealogiestab").exists()&&$("#structureOrGenealogiestab").click((function(){z||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=structureOrGenealogies",null,(function(e){z=!0,$("#structureOrGenealogies").html(e),T("structureOrGenealogies"),$("#next_structureOrGenealogy_i").exists()&&(Y=parseInt($("#next_structureOrGenealogy_i").text())),console.log("Next structureOrGenealogy ID: "+Y),$("#btn_add_structureOrGenealogy").exists()&&$("#btn_add_structureOrGenealogy").click((function(){i(!0);var e=$("#structureOrGenealogy_template").clone().html().replace(/ZZ/g,Y);return $("#add_structureOrGenealogy_div").after(e),k("structureOrGenealogy",Y),R("structureOrGenealogy",Y),u("structureOrGenealogy",Y),Y+=1,!1})),O("structureOrGenealogies")}))}));var K=1,V=!1;$("#mandatestab").exists()&&$("#mandatestab").click((function(){V||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=mandates",null,(function(e){V=!0,$("#mandates").html(e),T("mandates"),$("#next_mandate_i").exists()&&(K=parseInt($("#next_mandate_i").text())),console.log("Next mandate ID: "+K),$("#btn_add_mandate").exists()&&$("#btn_add_mandate").click((function(){i(!0);var e=$("#mandate_template").clone().html().replace(/ZZ/g,K);return $("#add_mandate_div").after(e),k("mandate",K),R("mandate",K),u("mandate",K),K+=1,!1})),O("mandates")}))}));var L=1,F=!1;$("#biogHiststab").exists()&&$("#biogHiststab").click((function(){F||$.get(snacUrl+"/edit_part/"+$("#constellationid").val()+"/"+$("#version").val()+"?part=biogHists",null,(function(e){F=!0,$("#biogHists").html(e),T("biogHists"),$("#next_biogHist_i").exists()&&(L=parseInt($("#next_biogHist_i").text())),console.log("Next biogHist ID: "+L),$("#btn_add_biogHist").exists()&&$("#btn_add_biogHist").click((function(){i(!0);var e=$("#biogHist_template").clone().html().replace(/ZZ/g,L);return $("#add_biogHist_div").after(e),k("biogHist",L),R("biogHist",L),u("biogHist",L),L+=1,!1})),O("biogHists")}))})),O(),$("#info-dropdown").click((function(e){$(this).parent().toggleClass("open"),e.stopPropagation()}))}))}})); +//# sourceMappingURL=edit_scripts.js.map \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/edit_scripts.js.map b/src/virtualhosts/www/javascript/edit_scripts.js.map new file mode 100644 index 000000000..5b654aba8 --- /dev/null +++ b/src/virtualhosts/www/javascript/edit_scripts.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/virtualhosts/www/javascript/src/edit_scripts.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","somethingHasBeenEdited","setEditedFlag","val","$","addClass","removeClass","undoSet","Array","defaults","language","id","term","script","displayErrorMessage","err","data","errorMsg","message","type","html","snacUrl","setTimeout","slideDown","console","log","addDateEntry","short","j","parseInt","text","clone","replace","after","turnOnButtons","turnOnTooltips","makeEditable","addDateRangeEntry","addSCMEntry","shortName","on","makeSCMEditable","setSCMDeleted","turnOnSCMButtons","geoPlaceLoadResults","setDeleted","off","makeUneditable","replaceWith","each","this","bootstrapToggle","undoEdit","subMakeEditable","idStr","cont","attr","endsWith","divStr","regex","RegExp","size","sizeStr","exists","placeholder","onKeyUp","onKeyUpStr","textToTextArea","placeholderOn","placeholderOff","textToCheckbox","idstr","obj","removeAttr","indexOf","CodeMirror","fromTextArea","lineNumbers","lineWrapping","viewportMargin","Infinity","sawSelect","vocabtype","minlength","options","scm_source_select_replace","vocab_select_replace","textToSelect","firstOptionSelect","secondOptionSelect","geovocab_select_replace","textToGeoPlaceSelect","pieces","dateStr","dateParts","split","length","year","month","day","forEach","mInt","select2","width","allowClear","theme","textToDate","sortable","items","opacity","update","event","ui","neworder","orderedID","index","updateNameEntryHeading","change","updatePictureArrow","updatePlaceHeading","find","subMakeUneditable","hasClass","toTextArea","inputToText","textAreaToText","checked","prop","checkboxToText","additionalStyle","postText","selectToText","geoPlaceSelectToText","updateDate","dateToText","scmShortName","makeSCMUneditable","undoSCMEdit","setRepeatedDataDeleted","subSetDeleted","tooltip","popover","trigger","container","newAddressLine","nextid","before","newNameEntryComponent","remove","removeParserButton","components","partText","push","entityType","combineNameHeading","trim","newNameEntryRule","pad","num","turnOnEditDeleteButtons","part","divID","turnOnTooltipsForTab","newValue","updatePictureTitle","loadGeoPlaceResultCache","chooseSuggestedGeoPlace","selectID","place","geoPlaceSearchResults","result","administrationCode","countryCode","latitude","longitude","openGeoPlaceViewer","magicDefaultFill","vocabType","undefined","newOption","Option","append","acceptParsedName","selectedName","$nameComponents","nameComponentIDs","nameComponentMap","k","option","$partType","$textbox","document","ready","preventDefault","e","word","target","closest","toUpperCase","slice","guesses","NameParser","guessPerson","parsedOption","counter","guess","unbind","done","results","parseName","modal","focus","nameEntryid","click","genderid","genderOpen","existid","existOpen","sameAsid","sameAsOpen","sameAsTermId","entityIDid","entityIDOpen","sourceid","sourceOpen","resourceRelationid","resourceRelationOpen","rid","resourceResults","version","link","displayEntry","title","abstract","extent","documentType","$resourceForm","loadVocabSelectOptions","newResourceLanguage","magicNewResourceLanguage","selectHoldingRepository","timeoutID","keyup","clearTimeout","setSearchPosition","searchAndUpdate","confirm","setDeletedResourceLanguageOperations","post","serialize","resource","constellationRelationid","constellationRelationOpen","cid","updatePictureIcon","languageid","languageOpen","subjectid","subjectOpen","nationalityid","nationalityOpen","functionid","functionOpen","occupationid","occupationOpen","legalStatusid","legalStatusOpen","placeid","placeOpen","conventionDeclarationid","conventionDeclarationOpen","generalContextid","generalContextOpen","structureOrGenealogyid","structureOrGenealogyOpen","mandateid","mandateOpen","biogHistid","biogHistOpen","parent","toggleClass","stopPropagation"],"mappings":"4DACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAA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WAAYkP,GAC3BjP,EAAa,WAAYiP,GACzBA,GAA0B,GACnB,KAIfnH,EAAqB,mBAKjCA,IAGA9J,EAAE,kBAAkBiN,OAAM,SAASnB,GAC/B9L,EAAE8C,MAAMqO,SAASC,YAAY,QAC7BtF,EAAEuF","file":"edit_scripts.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 3);\n","/**\n * Edit Scripts\n *\n * Scripts used in the edit page\n *\n * @author Robbie Hott\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\nvar biogHistEditor = null;\n\n// Has anything been edited on this page?\nexport var somethingHasBeenEdited = false;\n\nexport function setEditedFlag(val) {\n if (val == true) {\n $(\"#save_and_continue\").addClass(\"save-active\");\n } else {\n $(\"#save_and_continue\").removeClass(\"save-active\");\n }\n somethingHasBeenEdited = val;\n}\n\n\n// Global Undo Set\nexport var undoSet = new Array();\n\nexport var defaults = {\n language: {\n id: 130,\n term: \"eng\"\n },\n script: {\n id: 586,\n term: \"Latn\"\n }\n};\n\n\n\n/**\n * Display Error message\n *\n * Displays the error message box to the user with the given error message\n *\n * @param string|object err The error message (string) or error object containing a message and type string\n */\nexport function displayErrorMessage(err, data) {\n var errorMsg = \"\";\n if (typeof err === 'undefined')\n errorMsg = \"an unknown problem occurred\";\n else if ((typeof err) == \"string\")\n errorMsg = err;\n else if (err.message)\n errorMsg = err.message;\n else if (err.type)\n errorMsg = err.type;\n else\n errorMsg = \"an unknown problem occurred\";\n\n $('#error-message').html(\"

    Oops

    \"+errorMsg+\"

    \"\n +\"

    \"\n +\" \"\n +\"\"+\n \"Go to Dashboard\"\n +\"\"\n +\"

    \");\n setTimeout(function(){\n $('#error-message').slideDown();\n }, 500);\n\n // For reference, put the server response in the console\n console.log(data);\n}\n\n/**\n * Add sub-Date GUI object\n *\n * Adds a Date GUI object to the Date modal for the given \"short\" type of data indexed by i\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index of the object to add a date object to.\n * @returns boolean false to keep the browser from redrawing the page\n */\nexport function addDateEntry(short, i){\n\t//next_date_{{short}}_{{i}}_j\n\tvar j = parseInt($('#next_date_'+short+'_'+i+'_j').text());\n\tvar id = j + \"_\" + i;\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\tvar text = $('#sub_date_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/XX/g, j).replace(/SHORT/g, short);\n $('#add_date_'+short+'_'+i+'_div').after(html);\n $('#next_date_'+short+'_'+i+'_j').text(j + 1);\n turnOnButtons(short+\"_date\"+j, i);\n turnOnTooltips(short+\"_date_\"+j, i);\n makeEditable(short + \"_date_\"+j, i);\n return false;\n}\n\n/**\n * Add sub-Date GUI object\n *\n * Adds a Date GUI object to the Date modal for the given \"short\" type of data indexed by i\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index of the object to add a date object to.\n * @returns boolean false to keep the browser from redrawing the page\n */\nexport function addDateRangeEntry(short, i){\n\t//next_date_{{short}}_{{i}}_j\n\tvar j = parseInt($('#next_date_'+short+'_'+i+'_j').text());\n\tvar id = j + \"_\" + i;\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\tvar text = $('#sub_dateRange_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/XX/g, j).replace(/SHORT/g, short);\n $('#add_date_'+short+'_'+i+'_div').after(html);\n $('#next_date_'+short+'_'+i+'_j').text(j + 1);\n turnOnButtons(short+\"_date\"+j, i);\n turnOnTooltips(short+\"_date_\"+j, i);\n makeEditable(short + \"_date_\"+j, i);\n return false;\n}\n\n/**\n * Add SCM GUI object\n *\n * Adds a GUI SCM object to the SCM modal for the given \"short\" type of data indexed by i\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index of the object to add an SCM object to.\n * @returns boolean false to keep the browser from redrawing the page\n */\nexport function addSCMEntry(short, i){\n\t//next_scm_{{short}}_{{i}}_j\n\tvar j = parseInt($('#next_scm_'+short+'_'+i+'_j').text());\n\tvar id = j + \"_\" + i;\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\tvar text = $('#scm_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, j).replace(/SHORT/g, short);\n $('#add_scm_'+short+'_'+i+'_div').after(html);\n $('#next_scm_'+short+'_'+i+'_j').text(j + 1);\n turnOnSCMButtons(short, i, j);\n turnOnTooltips(\"scm_\"+short, id);\n makeSCMEditable(short, i, j);\n return false;\n}\n\n/**\n * Undo Edit\n *\n * Returns the html for the (short, i) panel back to its original state, i.e. removes\n * the edit. Before doing this, to clean up the page, it first makes the edited version\n * uneditable.\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n */\nfunction undoEdit(short, i) {\n\tmakeUneditable(short, i);\n\n\t// restore the old content\n\t$(\"#\" + short + \"_datapart_\" + i).replaceWith(undoSet[short+\"-\"+i]);\n turnOnTooltips(short,i);\n $(\"#\" + short + \"_datapart_\" + i + \" input[type='checkbox']\").each(function() {\n var obj = $(this);\n obj.bootstrapToggle();\n });\n}\n\n/**\n * Undo SCM Edit\n *\n * Takes an SCM GUI object (j) for a data object (short, i) and returns it back to its\n * original state (removing the edit). Before doing this, to clean up the page and JS, it first\n * makes the edited version uneditable, then replaces the HTML.\n *\n * @param string short The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n */\nfunction undoSCMEdit(short, i, j) {\n\tvar id = j + \"_\" + i;\n\tmakeSCMUneditable(short, i, j);\n\n\t// restore the old content\n\t$(\"#scm_\" + short + \"_datapart_\" + id).replaceWith(undoSet[\"scm_\"+short+\"-\"+id]);\n turnOnTooltips(\"scm_\"+short, id);\n}\n\n/**\n * Change vocabulary input divs to selects\n *\n * Changes all div's with id \"select_\" for a given data object (shortName, idStr) from a list of\n * inputs defining the parameters to a select (view mode) to a select box (edit mode). It then\n * calls the select2 function to replace the select with an AJAX-compatible select.\n *\n * This function handles VOCABULARY select boxes ONLY.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction textToSelect(shortName, idStr) {\n $(\"#\"+shortName+\"_datapart_\" + idStr + \" div[id^='select_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"select_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\"+shortName+\"_\"+name+\"_id_\"+idStr).val();\n var term = $(\"#\"+shortName+\"_\"+name+\"_term_\"+idStr).val();\n var vocabtype = $(\"#\"+shortName+\"_\"+name+\"_vocabtype_\"+idStr).val();\n var minlength = $(\"#\"+shortName+\"_\"+name+\"_minlength_\"+idStr).val();\n var placeholder = \"Select\";\n if ($(\"#\"+shortName+\"_\"+name+\"_placeholder_\"+idStr).exists()) {\n placeholder = $(\"#\"+shortName+\"_\"+name+\"_placeholder_\"+idStr).val();\n }\n var options = \"\";\n if ($(\"#\"+shortName+\"_\"+name+\"_defaultOptions_\"+idStr).exists()) {\n options = $(\"#\"+shortName+\"_\"+name+\"_defaultOptions_\"+idStr).val();\n }\n\n cont.html(\"\"+\n \"\" +\n \"\");\n\n if (name == \"citation\")\n scm_source_select_replace($(\"#\"+shortName+\"_\"+name+\"_id_\"+idStr), \"_\"+idStr);\n else\n vocab_select_replace($(\"#\"+shortName+\"_\"+name+\"_id_\"+idStr), \"_\"+idStr, vocabtype, minlength);\n\n }\n });\n}\n\nfunction textToCheckbox(shortName, idStr) {\n $(\"#\"+shortName+\"_datapart_\" + idStr + \" div[id^='checkbox_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^checkbox_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).val();\n var placeholderOn = \"\";\n if ($(\"#\"+shortName+\"_\"+name+\"_placeholderOn_\"+idStr).exists()) {\n placeholderOn = $(\"#\"+shortName+\"_\"+name+\"_placeholderOn_\"+idStr).val();\n }\n var placeholderOff = \"\";\n if ($(\"#\"+shortName+\"_\"+name+\"_placeholderOff_\"+idStr).exists()) {\n placeholderOff = $(\"#\"+shortName+\"_\"+name+\"_placeholderOff_\"+idStr).val();\n }\n\n var html = \"\";\n if (placeholderOn != \"\") {\n html += \"\";\n }\n if (placeholderOff != \"\") {\n html += \"\";\n }\n\n cont.html(html);\n $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).bootstrapToggle();\n }\n });\n\n\n}\n\n\nfunction checkboxToText(shortName, idStr) {\n $(\"#\"+shortName+\"_datapart_\" + idStr + \" div[id^='checkbox_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^checkbox_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).val();\n var checked = $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).prop('checked');\n var placeholderOn = \"\";\n if ($(\"#\"+shortName+\"_\"+name+\"_placeholderOn_\"+idStr).exists()) {\n placeholderOn = $(\"#\"+shortName+\"_\"+name+\"_placeholderOn_\"+idStr).val();\n }\n var placeholderOff = \"\";\n if ($(\"#\"+shortName+\"_\"+name+\"_placeholderOff_\"+idStr).exists()) {\n placeholderOff = $(\"#\"+shortName+\"_\"+name+\"_placeholderOff_\"+idStr).val();\n }\n\n\n var html = \"\";\n\n html += \"

    \";\n if (checked) {\n if (placeholderOn != \"\")\n html += placeholderOn;\n else\n html += value;\n } else {\n if (placeholderOff != \"\")\n html += placeholderOff;\n }\n html += \"

    \";\n if (placeholderOn != \"\") {\n html += \"\";\n }\n if (placeholderOff != \"\") {\n html += \"\";\n }\n\n $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).bootstrapToggle(\"destroy\");\n cont.html(html);\n }\n });\n\n\n}\n\nfunction textToInput(shortName, idStr) {\n $(\"#\"+shortName+\"_datapart_\" + idStr + \" div[id^='text_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^text_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).val();\n var size = 0;\n var sizeStr = \"\";\n if ($(\"#\"+shortName+\"_\"+name+\"_size_\"+idStr).exists()) {\n size = parseInt($(\"#\"+shortName+\"_\"+name+\"_size_\"+idStr).val());\n sizeStr = \" size='\" + size +\"' \";\n }\n var placeholder = \"\";\n if ($(\"#\"+shortName+\"_\"+name+\"_placeholder_\"+idStr).exists()) {\n placeholder = $(\"#\"+shortName+\"_\"+name+\"_placeholder_\"+idStr).val();\n }\n\n var onKeyUp = \"\";\n if ($(\"#\"+shortName+\"_\"+name+\"_onKeyUp_\"+idStr).exists()) {\n onKeyUp = $(\"#\"+shortName+\"_\"+name+\"_onKeyUp_\"+idStr).val();\n }\n var onKeyUpStr = \"\";\n if (onKeyUp != \"\") {\n onKeyUpStr = \" onKeyUp='\"+onKeyUp+\"' \";\n }\n\n var html = \"\";\n if (size != 0) {\n html += \"\";\n }\n if (placeholder != \"\") {\n html += \"\";\n }\n if (onKeyUp != \"\") {\n html += \"\";\n }\n\n cont.html(html);\n }\n });\n\n\n}\n\n\nfunction inputToText(shortName, idStr) {\n $(\"#\"+shortName+\"_datapart_\" + idStr + \" div[id^='text_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^text_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).val();\n var size = 0;\n if ($(\"#\"+shortName+\"_\"+name+\"_size_\"+idStr).exists()) {\n size = parseInt($(\"#\"+shortName+\"_\"+name+\"_size_\"+idStr).val());\n }\n var placeholder = \"\";\n if ($(\"#\"+shortName+\"_\"+name+\"_placeholder_\"+idStr).exists()) {\n placeholder = $(\"#\"+shortName+\"_\"+name+\"_placeholder_\"+idStr).val();\n }\n var onKeyUp = \"\";\n if ($(\"#\"+shortName+\"_\"+name+\"_onKeyUp_\"+idStr).exists()) {\n onKeyUp = $(\"#\"+shortName+\"_\"+name+\"_onKeyUp_\"+idStr).val();\n }\n\n var html = \"\";\n html += \"

    \" + value + \"

    \";\n if (size != 0) {\n html += \"\";\n }\n if (placeholder != \"\") {\n html += \"\";\n }\n if (onKeyUp != \"\") {\n html += \"\";\n }\n\n cont.html(html);\n }\n });\n\n\n}\n\n\n\nfunction textToTextArea(shortName, idStr) {\n $(\"#\"+shortName+\"_datapart_\" + idStr + \" div[id^='textarea_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^textarea_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).val();\n\n var html = \"\";\n\n cont.html(html);\n }\n });\n}\n\n\nfunction textAreaToText(shortName, idStr) {\n $(\"#\"+shortName+\"_datapart_\" + idStr + \" div[id^='textarea_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(/^textarea_/, \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var value = $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).val();\n\n //var html = \"\";\n var html = \"\";\n html += \"
    \" + value + \"
    \";\n\n cont.html(html);\n }\n });\n}\n\n/**\n * Change vocabulary selects to divs of inputs\n *\n * Changes all div's with id \"select_\" for a given data object (shortName, idStr) from a select\n * box (edit mode) to a list of inputs defining the parameters to a select (view mode).\n *\n * This function handles VOCABULARY select boxes ONLY.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction selectToText(shortName, idStr) {\n $(\"div[id^='select_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"select_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\"+shortName+\"_\"+name+\"_id_\"+idStr).val();\n var term = $(\"#\"+shortName+\"_\"+name+\"_id_\"+idStr+ \" option:selected\").text();\n var vocabtype = $(\"#\"+shortName+\"_\"+name+\"_vocabtype_\"+idStr).val();\n var minlength = $(\"#\"+shortName+\"_\"+name+\"_minlength_\"+idStr).val();\n\n var additionalStyle = \"\";\n var postText = \"\";\n if (vocabtype == \"name_component\") {\n additionalStyle = \"name-component-type\";\n postText = \" :\";\n }\n\n cont.html(\"\" +\n \"\" +\n \"\" +\n \"\" +\n \"

    \"+term+postText+\"

    \");\n\n }\n });\n}\n\n\nvar geoPlaceLoadResults = null;\n\nfunction textToGeoPlaceSelect(shortName, idStr) {\n $(\"#\"+shortName+\"_datapart_\" + idStr + \" div[id^='selectGeo_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"selectGeo_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\"+shortName+\"_\"+name+\"_id_\"+idStr).val();\n var term = $(\"#\"+shortName+\"_\"+name+\"_term_\"+idStr).val();\n var placeholder = \"Select Geo Place Term\";\n\n var confirmed = $(\"#\"+shortName+\"_confirmed_\" + idStr).val() == \"true\" ? true : false;\n var firstOptionSelect = \"\";\n var secondOptionSelect = \" selected\";\n if (!confirmed) {\n firstOptionSelect = \" selected\";\n secondOptionSelect = \"\";\n }\n\n cont.html(\"\");\n\n geovocab_select_replace($(\"#\"+shortName+\"_\"+name+\"_id_\"+idStr), \"_\"+idStr);\n\n }\n });\n}\n\nfunction geoPlaceSelectToText(shortName, idStr) {\n $(\"div[id^='selectGeo_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"selectGeo_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var id = $(\"#\"+shortName+\"_\"+name+\"_id_\"+idStr).val();\n var term = $(\"#\"+shortName+\"_\"+name+\"_id_\"+idStr+ \" option:selected\").text();\n\n cont.html(\"\" +\n \"\");\n\n }\n });\n}\n\n/**\n * Make a data object editable\n *\n * Make the GUI pane for a given constellation object (short, i) editable. Sets up the edit and delete\n * buttons for first-order data objects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nexport function makeEditable(short, i) {\n // No editing if it's already in edit mode\n if ($(\"#\" + short + \"_operation_\" + i).val() == \"update\")\n return false;\n // If it's deleted, then you better undelete it first\n if ($(\"#\" + short + \"_operation_\" + i).val() == \"delete\")\n setDeleted(short, i);\n\n $(\"#\" + short + \"_editbutton_\" + i).removeClass(\"list-group-item-info\").addClass(\"list-group-item-warning\");\n $(\"#\" + short + \"_editbutton_\" + i).html(\"
    Undo\");\n $(\"#\" + short + \"_editbutton_\" + i).off('click').on(\"click\", function() {\n \tundoEdit(short, i);\n });\n $(\"#\" + short + \"_deletebutton_\" + i).removeClass(\"list-group-item-danger\").addClass(\"disabled\");\n $(\"#\" + short + \"_deletebutton_\" + i).off('click').on(\"click\", function() {\n return false;\n });\n\n $(\"#\" + short + \"_panel_\" + i).removeClass(\"panel-default\").addClass(\"alert-info\").addClass(\"edited-component\");\n\n return subMakeEditable(short, i);\n}\n\n/**\n * Make a data object editable\n *\n * Make the GUI pane for a given constellation object (short, i) editable. Handles removing the read-only\n * statuses and changing divs into selects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction subMakeEditable(short, i) {\n // No editing if it's already in edit mode\n if ($(\"#\" + short + \"_operation_\" + i).val() == \"update\")\n return false;\n\n // Add to the undo set\n undoSet[short + \"-\" + i] = $(\"#\"+short+\"_datapart_\" + i).clone();\n\n\n textToInput(short, i);\n textToTextArea(short, i);\n textToCheckbox(short, i);\n\n var idstr = \"_\" + i;\n\n // Enable buttons\n $(\"#\"+short+\"_datapart_\" + i + \" button[id^='\"+short+\"_']\").each(function() {\n var obj = $(this);\n if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.removeAttr(\"disabled\").removeClass(\"snac-hidden\");\n }\n });\n // Enable buttons\n $(\"#\"+short+\"_datapart_\" + i + \" a.label\").each(function() {\n $(this).removeClass(\"snac-hidden\");\n });\n\n // Enable checkboxes\n $(\"#\"+short+\"_datapart_\" + i + \" input[type='checkbox']\").each(function() {\n var obj = $(this);\n if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.bootstrapToggle('enable');\n }\n });\n\n // Turn on CodeMirror Editors\n $(\"#\"+short+\"_datapart_\" + i + \" textarea[id^='\"+short+\"_']\").each(function() {\n var obj = $(this);\n if(obj.attr('id').endsWith(idstr)\n && !obj.attr('id').endsWith(\"ZZ\")) {\n // remove the short name from the string we're parsing\n var idStr = obj.attr('id').replace(short, \"\");\n if (idStr.indexOf('_text_') != -1 || idStr.indexOf('_source_') != -1) {\n obj.get(0).CodeMirror = CodeMirror.fromTextArea(obj.get(0), {\n lineNumbers: true,\n lineWrapping: true,\n viewportMargin: Infinity,\n mode: {name: \"xml\"}\n });\n }\n }\n });\n var sawSelect = false;\n $(\"#\"+short+\"_datapart_\" + i + \" select[id^='\"+short+\"_']\").each(function() {\n var obj = $(this);\n if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n sawSelect = true;\n }\n });\n\n if (!sawSelect) {\n textToSelect(short, i);\n textToGeoPlaceSelect(short, i);\n textToDate(short, i);\n }\n\n // Make things re-orderable if something exists\n // $( \"#nameEntry_component_ui_0\" ).sortable({ // id of the container containing sortable things\n // items : '.name_component' // class of the things that are sortable. They MUST have ids\n // });\n $(\"#\"+short+\"_datapart_\" + i + \" span.move-handle\").each(function() {\n $(this).removeClass(\"snac-hidden\");\n });\n $( \"#\"+short+\"_reorderable_\"+i ).sortable({\n items : '.reorderable',\n opacity : 0.5,\n update : function( event, ui ) {\n var neworder = $( \"#\"+short+\"_reorderable_\"+i ).sortable(\"toArray\");\n console.log(neworder);\n neworder.forEach(function(orderedID, index) {\n $(\"#\"+orderedID + \" input.order-index\").val(index);\n });\n if (short == \"nameEntry\")\n updateNameEntryHeading(i);\n }\n });\n\n // Make the relation pictures update appropriately\n if (short == 'constellationRelation') {\n // make the role dropdown affect the picture\n $('#'+short+'_type_id_'+i).change(function() {\n updatePictureArrow(short, i,\n $('#'+short+'_type_id_'+i+' option:selected').text());\n });\n\n }\n if (short == 'resourceRelation') {\n // make the role dropdown affect the picture\n $('#'+short+'_role_id_'+i).change(function() {\n updatePictureArrow(short, i,\n $('#'+short+'_role_id_'+i+' option:selected').text());\n });\n }\n // Places should update the place heading\n if (short == 'place') {\n // If there is a value pre-set, then automatically confirm and update\n if ($('#'+short+'_geoplace_id_'+i).val() != null && $('#'+short+'_geoplace_id_'+i).val() != \"\") {\n updatePlaceHeading(short, i, $('#'+short+'_geoplace_id_'+i).val());\n }\n // make the role dropdown affect the picture\n $('#'+short+'_geoplace_id_'+i).change(function() {\n updatePlaceHeading(short, i,\n $('#'+short+'_geoplace_id_'+i).val());\n });\n }\n\n // add parser btn if nameEntry is a computed name, entity is person, and if no btn or extra name components already exist\n if (short === 'nameEntry' && ($(\"#entityType\").val() === \"700\") &&\n ($(\"#nameEntry_component_0_panel_\" + i).find('select:first').text() === \"Name\") &&\n (!$(\"#nameEntry_panel_\" + i).find('.name-parser').length &&\n $(\"#nameEntry_component_1_panel_\" + i).length === 0)) {\n $('#nameEntry_component_add_' + i).after('');\n }\n\n // Set this data's operation value appropriately\n if ($(\"#\" + short + \"_id_\" + i).val() != \"\")\n \t$(\"#\" + short + \"_operation_\" + i).val(\"update\");\n else\n \t$(\"#\" + short + \"_operation_\" + i).val(\"insert\");\n\n // Asked to edit something, so make it globally known\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n return false;\n}\n\n/**\n * Make a data object uneditable\n *\n * Make each object in the GUI page for the given piece uneditable by turning them back to text. Also\n * takes the color away from the pane and removes the operation flag.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction subMakeUneditable(shortName, i) {\n\n\t// Make inputs read-only\n var idstr = \"_\" + i;\n\n\n // Turn off the reordering js\n $(\"#\"+shortName+\"_datapart_\" + i + \" span.move-handle\").each(function() {\n $(this).addClass(\"snac-hidden\");\n });\n if ($( \"#\"+shortName+\"_reorderable_\"+i ).hasClass(\"ui-sortable\"))\n $( \"#\"+shortName+\"_reorderable_\"+i ).sortable(\"destroy\");\n\n // Remove CodeMirror editors\n $(\"#\"+shortName+\"_datapart_\" + i + \" textarea[id^='\"+shortName+\"_']\").each(function() {\n var obj = $(this);\n if(obj.attr('id').endsWith(idstr)\n && !obj.attr('id').endsWith(\"ZZ\")\n && (obj.attr('id').indexOf('_text_') != -1 || obj.attr('id').indexOf('_source_') != -1)) {\n\n if (obj.get(0).CodeMirror) {\n obj.get(0).CodeMirror.toTextArea();\n }\n //(document.getElementById(obj.attr('id'))).CodeMirror.toTextArea();\n //obj.get(0).CodeMirror.toTextArea();\n }\n });\n // Disable buttons\n $(\"#\"+shortName+\"_datapart_\" + i + \" button[id^='\"+shortName+\"_']\").each(function() {\n var obj = $(this);\n if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.attr(\"disabled\", \"true\").addClass(\"snac-hidden\");\n }\n });\n\n // Disable buttons\n $(\"#\"+shortName+\"_datapart_\" + i + \" a.label\").each(function() {\n $(this).addClass(\"snac-hidden\");\n });\n\n // Disable checkboxes\n $(\"#\"+shortName+\"_datapart_\" + i + \" input[type='checkbox']\").each(function() {\n var obj = $(this);\n if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.bootstrapToggle(\"disable\");\n }\n });\n\n inputToText(shortName, i);\n textAreaToText(shortName, i);\n checkboxToText(shortName, i);\n // Check for a select box\n var sawSelect = false;\n $(\"#\"+shortName+\"_datapart_\" + i + \" select[id^='\"+shortName+\"_']\").each(function() {\n var obj = $(this);\n if(obj.attr('id').endsWith(idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n sawSelect = true;\n }\n });\n // If a select box was seen, undo it\n if (sawSelect) {\n selectToText(shortName, i);\n geoPlaceSelectToText(shortName, i);\n dateToText(shortName,i);\n }\n\n\n // Clear the operation flags\n //$(\"#\" + shortName + \"_operation_\" + i).val(\"\");\n $(\"#\"+shortName+\"_datapart_\" + i + \" input[id^='\"+shortName+\"_']\").each(function() {\n var obj = $(this);\n if(obj.attr('id').endsWith(\"_operation\" + idstr) && !obj.attr('id').endsWith(\"ZZ\")) {\n obj.val(\"\");\n }\n });\n\n\t$(\"#\" + shortName + \"_panel_\" + i).addClass(\"panel-default\").removeClass(\"alert-info\").removeClass(\"edited-component\");\n\n\n\n}\n\n/**\n * Make a data object uneditable\n *\n * Make the GUI pane for a given constellation object (short, i) un-editable. Sets up the edit and delete\n * buttons for first-order data objects, and calls the function to turn the elements back to text.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nexport function makeUneditable(shortName, i) {\n\t// Make inputs read-only\n var idstr = \"_\" + i;\n\n subMakeUneditable(shortName, i);\n\n // restore the edit button\n $(\"#\" + shortName + \"_editbutton_\" + i).addClass(\"list-group-item-info\").removeClass(\"list-group-item-warning\");\n $(\"#\" + shortName + \"_editbutton_\" + i).html(\"
    Edit\");\n $(\"#\" + shortName + \"_editbutton_\" + i).off('click').on(\"click\", function() {\n \tmakeEditable(shortName, i);\n });\n\n // restore the delete button\n $(\"#\" + shortName + \"_deletebutton_\" + i).addClass(\"list-group-item-danger\").removeClass(\"disabled\");\n $(\"#\" + shortName + \"_deletebutton_\" + i).off('click').on(\"click\", function() {\n setDeleted(shortName, i);\n });\n\n return false;\n}\n\n/**\n * Make an SCM data object editable\n *\n * Make the GUI pane for an SCM (j) of a given constellation object (short, i) editable. Sets up the edit and delete\n * buttons for first-order data objects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n * @return boolean False to play nice with the browser\n */\nfunction makeSCMEditable(shortName, i, j) {\n\tvar id = j + \"_\" + i;\n var scmShortName = \"scm_\" + shortName;\n\n // No editing if it's already in edit mode\n if ($(\"#\" + scmShortName + \"_operation_\" + id).val() == \"update\")\n return false;\n // If it's deleted, then you better undelete it first\n if ($(\"#\" + scmShortName + \"_operation_\" + id).val() == \"delete\")\n setSCMDeleted(shortName, i, j);\n\n $(\"#\" + scmShortName + \"_editbutton_\" + id).removeClass(\"list-group-item-info\").addClass(\"list-group-item-warning\");\n $(\"#\" + scmShortName + \"_editbutton_\" + id).html(\"\");\n $(\"#\" + scmShortName + \"_editbutton_\" + id).off('click').on(\"click\", function() {\n \tundoSCMEdit(shortName, i, j);\n });\n $(\"#\" + scmShortName + \"_deletebutton_\" + id).removeClass(\"list-group-item-danger\").addClass(\"disabled\");\n $(\"#\" + scmShortName + \"_deletebutton_\" + id).off('click').on(\"click\", function() {\n return false;\n });\n\n $(\"#\" + scmShortName + \"_panel_\" + id).removeClass(\"panel-default\").addClass(\"alert-info\").addClass(\"edited-component\");\n\n return subMakeEditable(scmShortName, id);\n}\n\n/**\n * Make an SCM data object un-editable\n *\n * Make the GUI pane for an SCM object (j) for a given constellation object (short, i) un-editable. Sets up the edit and delete\n * buttons for SCM data objects.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n * @return boolean False to play nice with the browser\n */\nexport function makeSCMUneditable(shortName, i, j) {\n\n\t// Make inputs read-only\n var idstr = j + \"_\" + i;\n\n subMakeUneditable('scm_'+shortName, idstr);\n\n // restore the edit button\n $(\"#scm_\" + shortName + \"_editbutton_\" + idstr).addClass(\"list-group-item-info\").removeClass(\"list-group-item-warning\");\n $(\"#scm_\" + shortName + \"_editbutton_\" + idstr).html(\"\");\n $(\"#scm_\" + shortName + \"_editbutton_\" + idstr).off('click').on(\"click\", function() {\n \tmakeSCMEditable(shortName, i, j);\n });\n\n // restore the delete button\n $(\"#scm_\" + shortName + \"_deletebutton_\" + idstr).addClass(\"list-group-item-danger\").removeClass(\"disabled\");\n $(\"#scm_\" + shortName + \"_deletebutton_\" + idstr).off('click').on(\"click\", function() {\n setSCMDeleted(shortName, i, j);\n });\n\n return false;\n}\n\n/**\n * Set a Contributor Object as deleted\n *\n * Sets the contributor object (shortName, i) as deleted or undeleted and makes the appropriate changes.\n *\n * @param string shortName The short name of the contributor object.\n * @param string|int i The index within the edit page of the object.\n */\nexport function setRepeatedDataDeleted(shortName, i) {\n if ($(\"#\" + shortName + \"_operation_\" + i).val() != \"delete\") {\n $(\"#\" + shortName + \"_remove_\" + i).removeClass(\"btn-danger\").addClass(\"btn-warning\");\n $(\"#\" + shortName + \"_remove_\" + i).html(\"\");\n } else {\n $(\"#\" + shortName + \"_remove_\" + i).removeClass(\"btn-warning\").addClass(\"btn-danger\");\n $(\"#\" + shortName + \"_remove_\" + i).html(\"\");\n }\n\n return subSetDeleted(shortName, i);\n}\n\n/**\n * Set a first-order data object as deleted\n *\n * Sets a first-order data object (short, i) as deleted or undeleted and makes the appropriate changes throughout the page.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n */\nfunction setDeleted(short, i) {\n if ($(\"#\" + short + \"_operation_\" + i).val() != \"delete\") {\n \t// set deleted\n $(\"#\" + short + \"_deletebutton_\" + i).removeClass(\"list-group-item-danger\").addClass(\"list-group-item-warning\");\n $(\"#\" + short + \"_deletebutton_\" + i).html(\"
    Undo\");\n\n // disable edit button\n $(\"#\" + short + \"_editbutton_\" + i).removeClass(\"list-group-item-info\").addClass(\"disabled\");\n $(\"#\" + short + \"_editbutton_\" + i).off('click').on(\"click\", function() {\n return false;\n });\n\n // disable the Date button\n $(\"#\" + short + \"_datebutton_\" + i).removeClass(\"list-group-item-success\").addClass(\"disabled\").prop('disabled', true);\n\n // disable the SCM button\n $(\"#\" + short + \"_scmbutton_\" + i).removeClass(\"list-group-item-success\").addClass(\"disabled\").prop('disabled', true);\n\n } else {\n \t// set undelete\n $(\"#\" + short + \"_deletebutton_\" + i).removeClass(\"list-group-item-warning\").addClass(\"list-group-item-danger\");\n $(\"#\" + short + \"_deletebutton_\" + i).html(\"
    Trash\");\n\n // restore edit button\n $(\"#\" + short + \"_editbutton_\" + i).addClass(\"list-group-item-info\").removeClass(\"disabled\");\n $(\"#\" + short + \"_editbutton_\" + i).off('click').on(\"click\", function() {\n makeEditable(short, i);\n });\n\n // restore the Date button\n $(\"#\" + short + \"_datebutton_\" + i).addClass(\"list-group-item-success\").removeClass(\"disabled\").prop('disabled', false);\n\n // restore the SCM button\n $(\"#\" + short + \"_scmbutton_\" + i).addClass(\"list-group-item-success\").removeClass(\"disabled\").prop('disabled', false);\n\n }\n\n return subSetDeleted(short, i);\n}\n\n/**\n * Make the delete/undelete happen\n *\n * Actually performs the changes to the object, affecting the operation and panel color.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @return boolean False to play nice with the browser\n */\nfunction subSetDeleted(short, i) {\n if ($(\"#\" + short + \"_operation_\" + i).val() != \"delete\") {\n \t// set deleted\n \t$(\"#\" + short + \"_panel_\" + i).removeClass(\"panel-default\").addClass(\"alert-danger\").addClass(\"deleted-component\");\n\n $(\"#\" + short + \"_operation_\" + i).val(\"delete\");\n } else {\n \t// set undelete\n \t$(\"#\" + short + \"_panel_\" + i).removeClass(\"alert-danger\").addClass(\"panel-default\").removeClass(\"deleted-component\");\n\n // If this thing was deleted but is supposed to be an update, then return it back to update status\n var sawSelect = false;\n $(\"select[id^='\"+short+\"_']\").each(function() {\n var obj = $(this);\n if(obj.attr('id').endsWith(\"_\" + i) && !obj.attr('id').endsWith(\"ZZ\")) {\n sawSelect = true;\n }\n });\n if (sawSelect) {\n \t if ($(\"#\" + short + \"_id_\" + i).val() != \"\")\n \t \t$(\"#\" + short + \"_operation_\" + i).val(\"update\");\n \t else\n \t \t$(\"#\" + short + \"_operation_\" + i).val(\"insert\");\n } else {\n \t$(\"#\" + short + \"_operation_\" + i).val(\"\");\n }\n\n }\n\n // Asked to delete something, so make it globally known\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n return false;\n}\n\n/**\n * Set an SCM data object as deleted\n *\n * Sets an SCM object (j) for a constellation object (short, i) as deleted or undeleted and makes the appropriate changes throughout the page.\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n */\nfunction setSCMDeleted(short, i, j) {\n\tvar id = j + '_' + i;\n if ($(\"#scm_\" + short + \"_operation_\" + id).val() != \"delete\") {\n \t// set deleted\n $(\"#scm_\" + short + \"_deletebutton_\" + id).removeClass(\"list-group-item-danger\").addClass(\"list-group-item-warning\");\n $(\"#scm_\" + short + \"_deletebutton_\" + id).html(\"\");\n\n // disable edit button\n $(\"#scm_\" + short + \"_editbutton_\" + id).removeClass(\"list-group-item-info\").addClass(\"disabled\");\n $(\"#scm_\" + short + \"_editbutton_\" + id).off('click').on(\"click\", function() {\n return false;\n });\n\n } else {\n \t// set undelete\n $(\"#scm_\" + short + \"_deletebutton_\" + id).removeClass(\"list-group-item-warning\").addClass(\"list-group-item-danger\");\n $(\"#scm_\" + short + \"_deletebutton_\" + id).html(\"\");\n\n // restore edit button\n $(\"#scm_\" + short + \"_editbutton_\" + id).addClass(\"list-group-item-info\").removeClass(\"disabled\");\n $(\"#scm_\" + short + \"_editbutton_\" + id).off('click').on(\"click\", function() {\n makeSCMEditable(short, i, j);\n });\n\n }\n\n return subSetDeleted(\"scm_\"+short, id);\n}\n\n/**\n * Turn on the Edit/Delete buttons for an object\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n */\nfunction turnOnButtons(shortName, i) {\n\n // Turn on the edit button\n $(\"#\"+shortName+\"_editbutton_\"+i).on(\"click\", function() {\n makeEditable(shortName, i);\n });\n\n // Turn on the delete buttons\n $(\"#\"+shortName+\"_deletebutton_\"+i).on(\"click\", function() {\n setDeleted(shortName, i);\n });\n}\n\nfunction turnOnTooltips(shortName, i) {\n // Load tooltips\n $(function () {\n $('#'+shortName+'_panel_'+ i +' [data-toggle=\"tooltip\"]').tooltip()\n })\n\n // Load popovers\n $(function () {\n $('#'+shortName+'_panel_'+ i +' [data-toggle=\"popover\"]').popover({\n trigger: 'hover',\n container: 'body'\n })\n })\n\n\n}\n\n/**\n * Turn on the Edit/Delete buttons for an SCM object\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int i The index within the edit page of the object.\n * @param string|int j The index within the data object SCM list on the edit page of the SCM object.\n */\nfunction turnOnSCMButtons(shortName, i, j) {\n\n // Turn on the edit button\n $(\"#scm_\"+shortName+\"_editbutton_\"+j+\"_\"+i).on(\"click\", function() {\n makeSCMEditable(shortName, i, j);\n });\n\n // Turn on the delete buttons\n $(\"#scm_\"+shortName+\"_deletebutton_\"+j+\"_\"+i).on(\"click\", function() {\n setSCMDeleted(shortName, i, j);\n });\n}\n\n/**\n * Create a new Address Line object on page\n *\n * Puts a new Place Address Line object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the place to add this component to\n * @return boolean false to play nice with the browser.\n */\nexport function newAddressLine(i) {\n\tvar nextid = 1;\n\tif ($('#place_address_next_j_'+i).exists()) {\n\t nextid = parseInt($('#place_address_next_j_'+i).text());\n\t}\n\tconsole.log(\"Creating new address line for place \" + i + \" with id: \" + nextid);\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#addressline_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#place_address_add_div_'+i).before(html);\n\n $('#place_address_' + nextid + '_operation_' + 1).val(\"insert\");\n subMakeEditable(\"place_address_\" + nextid, i);\n\n vocab_select_replace($(\"#place_address_\"+nextid+\"_type_id_\"+i), \"_\"+i, 'address_part', 0);\n\n // Put the updated version number back in the DOM\n $('#place_address_next_j_'+i).text(++nextid);\n\n return false;\n}\n\n/**\n * Create a new Resource Relation Origination Name object on page\n *\n * Puts a new Resource Relation Origination Name object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the Resource Relation to add this Origination Name to\n * @return boolean false to play nice with the browser.\n */\nfunction newOriginationName(i) {\n\tvar nextid = 1;\n\tif ($('#resource_originationName_next_j_'+i).exists()) {\n\t nextid = parseInt($('#resource_originationName_next_j_'+i).text());\n\t}\n\tconsole.log(\"Creating new origination name for resource \" + i + \" with id: \" + nextid);\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#originationName_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#resource_originationName_add_div_'+i).before(html);\n\n $('#resource_originationName_' + nextid + '_operation_' + 1).val(\"insert\");\n subMakeEditable(\"resource_originationName_\" + nextid, i);\n\n // Put the updated version number back in the DOM\n $('#resource_originationName_next_j_'+i).text(++nextid);\n\n return false;\n}\n\n\n/**\n * Create a new Name Entry Component object on page\n *\n * Puts a new Name Entry component object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the nameEntry to add this component to\n * @return boolean false to play nice with the browser.\n */\nexport function newNameEntryComponent(i) {\n removeParserButton(i);\n\tvar nextid = 1;\n\tif ($('#nameEntry_component_next_j_'+i).exists()) {\n\t nextid = parseInt($('#nameEntry_component_next_j_'+i).text());\n\t}\n\tconsole.log(\"Creating new name entry component for nameEntry \" + i + \" with id: \" + nextid);\n\n // add parser btn if entity is person, and if no btn or other name components already exist\n if (($(\"#entityType\").val() === \"700\") && (nextid == 0) &&\n (!$(\"#nameEntry_panel_\" + i).find('.name-parser').length &&\n $(\"#nameEntry_component_1_panel_\" + i).length === 0)) {\n $('#nameEntry_component_add_' + i).after('');\n }\n\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n var text = $('#component_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#nameEntry_component_add_div_'+i).before(html);\n\n $('#nameEntry_component_' + nextid + '_operation_' + 1).val(\"insert\");\n subMakeEditable(\"nameEntry_component_\" + nextid, i);\n\n vocab_select_replace($(\"#nameEntry_component_\"+nextid+\"_type_id_\"+i), \"_\"+i, 'name_component', 0);\n\n // Put the updated version number back in the DOM\n $('#nameEntry_component_next_j_'+i).text(++nextid);\n\n return false;\n}\n\nexport function updateNameEntryHeading(i) {\n var text = \"\";\n var components = [];\n\n $(\"#nameEntry_panel_\"+i+\" div[id^='nameEntry_component_']\").each(function() {\n var obj = $(this);\n if (!obj.hasClass(\"deleted-component\") && obj.attr('id').endsWith(\"_panel_\" + i)\n && !obj.attr('id').endsWith(\"ZZ\")) {\n var j = obj.attr('id').replace(\"nameEntry_component_\", \"\").replace(\"_panel_\"+i, \"\");\n var type = $(\"#nameEntry_component_\"+j+\"_type_id_\"+i+\" option:selected\").text();\n var partText = $(\"#nameEntry_component_\"+j+\"_text_\"+i).val();\n\n components.push([type, partText]);\n }\n });\n\n var entityType = $(\"#entityType option:selected\").text();\n text = combineNameHeading(components, entityType);\n\n\n $(\"#nameEntry_heading_\"+i).text(text.trim());\n $(\"#nameEntry_original_\"+i).val(text.trim());\n}\n\n\n/**\n * Create a new Name Entry Rules object on page\n *\n * Puts a new Name Entry rule object DIV on the page and attaches it correctly to the DOM and javascript.\n *\n * @param int i The index on the page of the nameEntry to add this rule to\n * @return boolean false to play nice with the browser.\n */\nexport function newNameEntryRule(i) {\n\tvar nextid = 1;\n\tif ($('#nameEntry_rule_next_j_'+i).exists()) {\n\t nextid = parseInt($('#nameEntry_rule_next_j_'+i).text());\n\t}\n\tconsole.log(\"Creating new name entry rule for nameEntry \" + i + \" with id: \" + nextid);\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#rule_template').clone();\n var html = text.html().replace(/ZZ/g, i).replace(/YY/g, nextid);\n $('#nameEntry_rule_add_div_'+i).before(html);\n\n $('#nameEntry_rule_' + nextid + '_operation_' + 1).val(\"insert\");\n turnOnTooltips(\"nameEntry_rule_\" + nextid, i);\n subMakeEditable(\"nameEntry_rule_\" + nextid, i);\n\n // Put the updated version number back in the DOM\n $('#nameEntry_rule_next_j_'+i).text(++nextid);\n\n return false;\n}\n\n/**\n * Parse a date string into parts\n */\nfunction parseDate(dateString) {\n var pieces = dateString.split(\"-\");\n if (pieces.length == 3)\n return {\n year : parseInt(pieces[0]),\n month : parseInt(pieces[1]),\n day : parseInt(pieces[2])\n };\n else if (pieces.length == 2)\n return {\n year : parseInt(pieces[0]),\n month : parseInt(pieces[1]),\n day : ''\n };\n else if (pieces.length == 1 && pieces[0] != '')\n return {\n year : parseInt(pieces[0]),\n month : '',\n day : ''\n };\n else return {\n year : '', month : '', day : ''\n }\n}\n\n/**\n * Change date input divs to select and boxes\n *\n * Changes all div's with id \"date_\" for a given data object (shortName, idStr) from a list of\n * inputs defining the parameters (view mode) to a inputs and a select (edit mode). It then\n * calls the select2 function to replace the select with one matching the rest of the page.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction textToDate(shortName, idStr) {\n $(\"div[id^='date_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"date_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n var dateStr = $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).val();\n\n var dateParts = parseDate(dateStr);\n\n var html = \"\";\n html += \" - \";\n html += \" \";\n html += \" - \";\n html += \" \";\n html += \"\";\n cont.html(html);\n\n $(\"#\"+shortName+\"_\"+name+\"_month_\"+idStr).select2({\n width: '57%',\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Month'\n });\n\n }\n });\n}\n\n/**\n * Pad an integer\n *\n * This is a helper function to pad an integer with 0s for display. This is useful to pad\n * a month or day with a leading 0.\n *\n * @param int|string num The number to pad\n * @param int size The total width of the desired output\n * @return string A string containing a size-wide integer representation, 0-padded\n */\nfunction pad(num, size) {\n var s = num+\"\";\n while (s.length < size) s = \"0\" + s;\n return s;\n}\n\n/**\n * Updates the standard date input field\n *\n * If the date for the data object (shortName, idStr) has been turned into a 3-field edit\n * area, then this function will update the hidden standard date (YYYY-MM-DD) field with the\n * newest values from the human-enterable field.\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nexport function updateDate(shortName, idStr) {\n $(\"div[id^='date_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"date_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n\n if ($(\"#\"+shortName+\"_\"+name+\"_year_\"+idStr).exists()) {\n var year = $(\"#\"+shortName+\"_\"+name+\"_year_\"+idStr).val();\n var day = $(\"#\"+shortName+\"_\"+name+\"_day_\"+idStr).val();\n var month = $(\"#\"+shortName+\"_\"+name+\"_month_\"+idStr+ \" option:selected\").val();\n\n var dateStr = \"\";\n if (year != \"\") {\n dateStr += pad(year, 4);\n if (month != \"\") {\n dateStr += \"-\" + pad(month,2);\n if (day != \"\") {\n dateStr += \"-\" + pad(day,2);\n }\n }\n }\n\n $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).val(dateStr);\n }\n\n }\n });\n}\n\n/**\n * Return editable date area back to text\n *\n * If the date for the data object (shortName, idStr) has been turned into a 3-field edit\n * area, then this function will return the editable area back to the view mode text, replacing\n * the edit boxes with a paragraph containing the computed standard date string (YYYY-MM-DD).\n *\n * Note: idStr must not have the \"_\" pre-appended\n *\n * @param string shortName The short name of the data object, such as \"nameEntry\" or \"occupation\"\n * @param string|int idStr The index within the edit page of the object.\n */\nfunction dateToText(shortName, idStr) {\n $(\"div[id^='date_\"+shortName+\"']\").each(function() {\n var cont = $(this);\n if(cont.attr('id').endsWith(\"_\"+idStr) && !cont.attr('id').endsWith(\"ZZ\")) {\n // remove the short name and \"select_\" from the string we're parsing\n var divStr = cont.attr('id').replace(\"date_\", \"\").replace(shortName + \"_\", \"\");\n // remove the idstr to receive the name of this element\n var regex = new RegExp(\"\\_\"+idStr+\"$\", \"g\");\n var name = divStr.replace(regex, \"\");\n\n updateDate(shortName, idStr);\n\n\n var dateStr = $(\"#\"+shortName+\"_\"+name+\"_\"+idStr).val();\n\n var html = \"

    \"+dateStr+\"

    \";\n html += \"\";\n cont.html(html);\n\n }\n });\n}\n\n\n// TODO: If we want to show a DIV of edited and deleted components, we should use the following two functions\n// to get copies of the edited/deleted components from the page. We can then insert those copies onto a modal\n// dialog box with a \"Save\" or \"Continue\" button at the top and bottom.\n//\n// All the pieces shown in the dialog should be disabled. One way to do this would be using the following\n// method to place a semi-transparent div on top of the editable pieces, making them appear to be grayed out\n// and with the not permitted cursor.\n//\n// .append('
    ');\n//\n// Note: this modal should NOT be inside the constellation form so that we don't submit the values twice.\n\n/**\n * Get all the edited components\n */\nfunction getEdited() {\n var html = \"\";\n\n $(\"#constellation_form div.edited-component\").each(function() {\n var cont = $(this);\n console.log(cont.attr('id'));\n var pieces = cont.attr('id').split(\"_panel_\");\n if (pieces.length == 2) {\n html += \"
    \" + $(\"#\"+pieces[0] + \"_datapart_\" + pieces[1]).html() + \"
    \";\n }\n });\n\n return html;\n}\n\n/**\n * Get all the deleted components\n */\nfunction getDeleted() {\n var html = \"\";\n\n $(\"#constellation_form div.deleted-component\").each(function() {\n var cont = $(this);\n console.log(cont.attr('id'));\n var pieces = cont.attr('id').split(\"_panel_\");\n if (pieces.length == 2) {\n html += \"
    \" + $(\"#\"+pieces[0] + \"_datapart_\" + pieces[1]).html() + \"
    \";\n }\n });\n\n return html;\n}\n\nfunction turnOnEditDeleteButtons(part='') {\n var divID = '';\n if (part != '')\n divID = \"#\" + part + \" \";\n // Turn on the edit buttons\n $(divID + \"a[id*='editbutton']\").each(function() {\n var obj = $(this);\n var pieces = obj.attr('id').split(\"_\");\n\n if (pieces.length == 3) {\n var short = pieces[0];\n var i = pieces[2];\n obj.on(\"click\", function() {\n makeEditable(short, i);\n });\n } else if (pieces.length == 5 && pieces[0] == \"scm\") {\n var short = pieces[1];\n var i = pieces[4];\n var j = pieces[3];\n obj.on(\"click\", function() {\n makeSCMEditable(short, i, j);\n });\n } else if (pieces.length == 5) {\n var short = pieces[0] + \"_\" + pieces[1] + \"_\" + pieces[2];\n var i = pieces[4];\n obj.on(\"click\", function() {\n makeEditable(short, i);\n });\n }\n });\n\n // Turn on the delete buttons\n $(divID + \"a[id*='deletebutton']\").each(function() {\n var obj = $(this);\n var pieces = obj.attr('id').split(\"_\");\n\n if (pieces.length == 3) {\n var short = pieces[0];\n var i = pieces[2];\n obj.on(\"click\", function() {\n setDeleted(short, i);\n });\n } else if (pieces.length == 5 && pieces[0] == \"scm\") {\n var short = pieces[1];\n var i = pieces[4];\n var j = pieces[3];\n obj.on(\"click\", function() {\n setSCMDeleted(short, i, j);\n });\n } else if (pieces.length == 5) {\n var short = pieces[0] + \"_\" + pieces[1] + \"_\" + pieces[2];\n var i = pieces[4];\n obj.on(\"click\", function() {\n setDeleted(short, i);\n });\n }\n });\n}\n\nfunction turnOnTooltipsForTab(part='') {\n var divID = '';\n if (part != '')\n divID = \"#\" + part + \" \";\n // Load tooltips\n $(function () {\n $(divID + '[data-toggle=\"tooltip\"]').tooltip()\n })\n\n // Load popovers\n $(function () {\n $(divID + '[data-toggle=\"popover\"]').popover({\n trigger: 'hover',\n container: 'body'\n })\n })\n\n}\n\nfunction updatePictureArrow(shortName, i, newValue) {\n $('#'+shortName+'_relationPictureArrow_'+i).text(newValue);\n}\n\nfunction updatePictureTitle(shortName, i, newValue) {\n $('#'+shortName+'_relationPictureTitle_'+i).text(newValue);\n}\n\nfunction updatePictureIcon(shortName, i, entityType) {\n var html = \"\";\n if (entityType == 'person')\n html = '
    ';\n else if (entityType == 'corporateBody')\n html = '
    ';\n else if (entityType == 'family')\n html = '
    ';\n $('#'+shortName+'_relationPictureIcon_'+i).html(html);\n}\n\n\nvar geoPlaceLoadResults = null;\n\nfunction loadGeoPlaceResultCache() {\n $(\"input[id^='place_geoplace_id_']\").each(function() {\n var obj = $(this);\n // Query for term by ajax\n if (obj.val() != null && obj.val() != \"\") {\n $.get(snacUrl+\"/vocabulary/read?type=geoPlace&id=\"+obj.val(), null, function (data) {\n // Check the return value from the ajax. If success, then go to dashboard\n if (data.term) {\n if (!geoPlaceLoadResults)\n geoPlaceLoadResults = new Array();\n geoPlaceLoadResults.push(data.term);\n }\n });\n }\n });\n}\n\nexport function chooseSuggestedGeoPlace(selectID, idStr, value) {\n // idStr == id number on the page\n var obj = $(\"#\"+selectID);\n obj.select2('destroy');\n obj.val(value);\n geovocab_select_replace(obj, \"_\"+idStr);\n updatePlaceHeading(\"place\", idStr, value);\n}\n\nfunction updatePlaceHeading(shortName, i, newValue) {\n var place = null;\n if (!geoPlaceSearchResults && !geoPlaceLoadResults) {\n $('#'+shortName+'_confirmed_'+i).val(\"false\");\n $('#'+shortName+'_geoterm_text_'+i).html(\"Unconfirmed\");\n $('#'+shortName+\"_geoterm_maplink_\"+i).addClass(\"disabled\");\n $('#'+shortName+\"_geoterm_maplink_\"+i).prop('onclick',null).off(\"click\");\n if ($('#'+shortName+'_original_'+i).val() != \"\")\n $('#'+shortName+'_geoterm_caption_'+i).text(\"Recorded as: \" + $('#'+shortName+'_original_'+i).val());\n else\n $('#'+shortName+'_geoterm_caption_'+i).text();\n return;\n }\n\n if (geoPlaceSearchResults) {\n geoPlaceSearchResults.forEach(function(result) {\n if (result.id == newValue)\n place = result;\n });\n }\n\n if (!place && geoPlaceLoadResults) {\n geoPlaceLoadResults.forEach(function(result) {\n if (result.id == newValue)\n place = result;\n });\n }\n\n if (!place) {\n $('#'+shortName+'_confirmed_'+i).val(\"false\");\n $('#'+shortName+\"_geoterm_maplink_\"+i).addClass(\"disabled\");\n $('#'+shortName+\"_geoterm_maplink_\"+i).off(\"click\");\n if ($('#'+shortName+'_original_'+i).val() != \"\") {\n $('#'+shortName+'_geoterm_text_'+i).html(\"Unconfirmed\");\n $('#'+shortName+'_geoterm_caption_'+i).text(\"Recorded as: \" + $('#'+shortName+'_original_'+i).val());\n } else {\n $('#'+shortName+'_geoterm_text_'+i).text(\"--\");\n $('#'+shortName+'_geoterm_caption_'+i).text(\"GeoPlace term not specified\");\n }\n return;\n }\n $('#'+shortName+'_confirmed_'+i).val(\"true\");\n $('#'+shortName+'_geoterm_text_'+i).text(place.name);\n $('#'+shortName+'_geoterm_caption_'+i).text(place.administrationCode + \", \" + place.countryCode);\n if (place.latitude && place.longitude) {\n $('#'+shortName+\"_geoterm_maplink_\"+i).prop('onclick',null).off(\"click\");\n $('#'+shortName+\"_geoterm_maplink_\"+i).on(\"click\", function() {openGeoPlaceViewer(place.id); return false;});\n $('#'+shortName+\"_geoterm_maplink_\"+i).removeClass(\"disabled\");\n } else {\n $('#'+shortName+\"_geoterm_maplink_\"+i).addClass(\"disabled\");\n $('#'+shortName+\"_geoterm_maplink_\"+i).prop('onclick',null).off(\"click\");\n }\n\n\n}\n\nexport function magicDefaultFill(selectID, vocabType) {\n if (typeof(defaults[vocabType]) !== undefined) {\n\n var data = {\n id: defaults[vocabType].id,\n text: defaults[vocabType].term\n };\n\n // If the selected item exists, then select it. Else, add a new option\n // and select it.\n if ($('#'+selectID).find(\"option[value='\" + data.id + \"']\").length) {\n $('#'+selectID).val(data.id).trigger('change');\n } else {\n var newOption = new Option(data.text, data.id, false, true);\n $('#'+selectID).append(newOption).trigger('change');\n }\n }\n\n}\n\nfunction capitalize(word) {\n return word[0].toUpperCase() + word.slice(1);\n}\n\nfunction parseName(e) {\n $('#name-parser-options').text('');\n var $nameComponents = $(e.target).closest('.name-components');\n\n var $partType = $nameComponents.find(\"select:last\");\n var $textbox = $nameComponents.find('input[type=\"text\"]:last');\n\n var name = $textbox.val();\n\n var entityType = $('#entityType').text().trim();\n $('#name-parser-type').text(capitalize(entityType));\n $('#name-parser-original').text(name);\n\n var parser = new NameParser();\n var guesses = parser.guessPerson(name);\n\n var parsedOption = '';\n\n var counter = 0;\n guesses.forEach(function(guess) {\n // attach name data object to radio\n for (var key in guess) {\n if (guess[key] && guess[key].length != 0) {\n parsedOption += \"
  • \" + key + \": \" + guess[key] + \"
  • \";\n }\n }\n\n $('#name-parser-options').append(\"
    \" +\n \"
    \");\n\n\n $('#name-parser-options').find(\"input[type='radio']:last\").data(\"parsed-name\", guess);\n\n parsedOption = '';\n counter++;\n })\n\n $('#name-parser-options').find(\"input[type='radio']:first\").prop('checked', true)\n\n\n $('#parser-accept-btn').unbind('click')\n $('#parser-accept-btn').on('click', function() {\n var selectedName = $('#name-parser input[type=\"radio\"]:checked').data('parsed-name')\n $.get( snacUrl + \"/vocabulary/?type=name_component&entity_type=700\")\n .done(function(data) {\n acceptParsedName(selectedName, $nameComponents, name, data.results)\n })\n })\n}\n\nfunction acceptParsedName(selectedName, $nameComponents, name, nameComponentIDs) {\n var i = $nameComponents.attr('id').split('_')[2];\n var $nameComponent = $nameComponents.find('.reorderable'); ///\n $nameComponent.replaceWith('
    Name: ' + name + '
    ');\n\n var nameComponentMap = {};\n\n for (var k = 0; k < nameComponentIDs.length; k++) {\n nameComponentMap[nameComponentIDs[k].text] = nameComponentIDs[k].id\n }\n // var nameComponentMap = {\n // 'Surname': 400223,\n // 'Forename': 400224,\n // 'NameAddition': 400236,\n // 'Date': 400237,\n // 'NameExpansion': 400226,\n // 'Numeration': 400225\n // };\n\n for (var key in selectedName) {\n if (key == 'NameAdditions') {\n key = 'NameAddition';\n for (var j = 0; j < selectedName['NameAdditions'].length; j++) {\n newNameEntryComponent(i);\n var option = new Option(key, nameComponentMap[key], false, true);\n $partType = $nameComponents.find(\"select:last\");\n $partType.append(option).trigger('change');\n $textbox = $nameComponents.find(\"input[type='text']:last\");\n $textbox.val(selectedName[\"NameAdditions\"][j]);\n\n $partType.append(option).trigger('change');\n }\n } else if (selectedName[key] && nameComponentMap[key]) {\n newNameEntryComponent(i);\n var option = new Option(key, nameComponentMap[key], false, true);\n $partType = $nameComponents.find(\"select:last\");\n $partType.append(option).trigger('change');\n $textbox = $nameComponents.find(\"input[type='text']:last\");\n $textbox.val(selectedName[key]);\n\n $partType.append(option).trigger('change');\n }\n }\n\n $(\"#nameEntry_datapart_\" + i).find(\".name-parser\").remove();\n updateNameEntryHeading(i);\n}\n\nfunction removeParserButton(i) {\n $('#nameEntry_datapart_' + i).find('.name-parser').remove();\n}\n\n/**\n * Things to do when the page finishes loading\n */\n$(document).ready(function() {\n // Load the place cache, if needed\n loadGeoPlaceResultCache();\n\n // listen for name-parsing\n $('#nameEntries').on('click', '.name-parser', function(event) {\n event.preventDefault();\n parseName(event);\n $(\"#name-parser\").modal('toggle');\n });\n\n $('#name-parser').on('shown.bs.modal', function () {\n $('#parser-accept-btn').focus();\n })\n\n // If the constellation is in \"insert\" mode, then we should automatically set \"somethingHasBeenEdited\"\n // to be true...\n if ($('#operation').val() == 'insert')\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\n turnOnEditDeleteButtons();\n\n\t// Attach functions to the entityType select\n\tif ($('#entityType').exists()) {\n\t\t$('#entityType').change(function() {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n // If there is an ID, then we need to set this to update\n // Else, the main-level operation should be and remain insert\n\t\t\tif ($('#constellationid').val() != null &&\n\t\t\t\t\t$('#constellationid').val() != \"\") {\n\t\t\t\t$('#operation').val(\"update\");\n\t\t\t}\n\t\t});\n\t}\n\n // Name Entry doesn't get any AJAX, since it is pre-loaded\n\tvar nameEntryid = 1;\n\tif ($('#next_nameEntry_i').exists()) {\n\t nameEntryid = parseInt($('#next_nameEntry_i').text());\n\t}\n\tconsole.log(\"Next NameEntry ID: \" + nameEntryid);\n\tif ($('#btn_add_nameEntry').exists()){\n\t\t$('#btn_add_nameEntry').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n\t\t\tvar text = $('#nameEntry_template').clone();\n\t var html = text.html().replace(/ZZ/g, nameEntryid);\n\t $('#add_nameEntry_div').after(html);\n turnOnButtons(\"nameEntry\", nameEntryid);\n turnOnTooltips(\"nameEntry\", nameEntryid);\n makeEditable(\"nameEntry\", nameEntryid);\n\t nameEntryid = nameEntryid + 1;\n\t return false;\n\t\t});\n\t}\n\n\n\t// Attach functions to each of the \"+ Add New _______\" buttons\n\n\t// Code to handle adding new genders to the page\n\tvar genderid = 1;\n var genderOpen = false;\n\tif ($('#genderstab').exists()){\n\t\t$('#genderstab').click(function(){\n // Don't open a second time\n if (genderOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=genders\", null, function (data) {\n genderOpen = true;\n $('#genders').html(data);\n\n turnOnEditDeleteButtons(\"genders\");\n\n if ($('#next_gender_i').exists()) {\n genderid = parseInt($('#next_gender_i').text());\n }\n console.log(\"Next Gender ID: \" + genderid);\n if ($('#btn_add_gender').exists()){\n $('#btn_add_gender').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#gender_template').clone();\n var html = text.html().replace(/ZZ/g, genderid);\n $('#add_gender_div').after(html);\n turnOnButtons(\"gender\", genderid);\n turnOnTooltips(\"gender\", genderid);\n makeEditable(\"gender\", genderid);\n genderid = genderid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"genders\");\n });\n });\n }\n\n\t// Code to handle adding new genders to the page\n\tvar existid = 1;\n var existOpen = false;\n\tif ($('#existstab').exists()){\n\t\t$('#existstab').click(function(){\n // Don't open a second time\n if (existOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=dates\", null, function (data) {\n existOpen = true;\n $('#dates').html(data);\n\n turnOnEditDeleteButtons(\"dates\");\n\n if ($('#next_exist_i').exists()) {\n existid = parseInt($('#next_exist_i').text());\n }\n console.log(\"Next Exist Date ID: \" + existid);\n if ($('#btn_add_exist_date').exists()){\n $('#btn_add_exist_date').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#exist_date_template').clone();\n var html = text.html().replace(/ZZ/g, existid);\n $('#add_exist_div').after(html);\n turnOnButtons(\"exist\", existid);\n turnOnTooltips(\"exist\", existid);\n makeEditable(\"exist\", existid);\n existid = existid + 1;\n return false;\n });\n }\n if ($('#btn_add_exist_dateRange').exists()){\n $('#btn_add_exist_dateRange').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#exist_dateRange_template').clone();\n var html = text.html().replace(/ZZ/g, existid);\n $('#add_exist_div').after(html);\n turnOnButtons(\"exist\", existid);\n turnOnTooltips(\"exist\", existid);\n makeEditable(\"exist\", existid);\n existid = existid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"dates\");\n });\n });\n }\n\n\tvar sameAsid = 1;\n var sameAsOpen = false;\n\tif ($('#sameAstab').exists()){\n\t\t$('#sameAstab').click(function(){\n // Don't open a second time\n if (sameAsOpen)\n return;\n //set sameAs vocab type id\n $.get(snacUrl+\"/vocabulary?type=record_type&q=SameAs\", null, function(data) {\n sameAsTermId = data.results[0].id;\n $(\"#sameAs_type_id_ZZ\").val(sameAsTermId);\n });\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=sameAs\", null, function (data) {\n sameAsOpen = true;\n $('#sameAs').html(data);\n\n turnOnEditDeleteButtons(\"sameAs\");\n\n if ($('#next_sameAs_i').exists()) {\n sameAsid = parseInt($('#next_sameAs_i').text());\n }\n console.log(\"Next sameAs ID: \" + sameAsid);\n if ($('#btn_add_sameAs').exists()){\n $('#btn_add_sameAs').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#sameAs_template').clone();\n var html = text.html().replace(/ZZ/g, sameAsid);\n $('#add_sameAs_div').after(html);\n turnOnButtons(\"sameAs\", sameAsid);\n turnOnTooltips(\"sameAs\", sameAsid);\n makeEditable(\"sameAs\", sameAsid);\n sameAsid = sameAsid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"sameAs\");\n });\n });\n }\n\n\n\tvar entityIDid = 1;\n var entityIDOpen = false;\n\tif ($('#entityIDtab').exists()){\n\t\t$('#entityIDtab').click(function(){\n // Don't open a second time\n if (entityIDOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=entityID\", null, function (data) {\n entityIDOpen = true;\n $('#entityID').html(data);\n\n turnOnEditDeleteButtons(\"entityID\");\n\n if ($('#next_entityID_i').exists()) {\n entityIDid = parseInt($('#next_entityID_i').text());\n }\n console.log(\"Next entityID ID: \" + entityIDid);\n if ($('#btn_add_entityID').exists()){\n $('#btn_add_entityID').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#entityID_template').clone();\n var html = text.html().replace(/ZZ/g, entityIDid);\n $('#add_entityID_div').after(html);\n turnOnButtons(\"entityID\", entityIDid);\n turnOnTooltips(\"entityID\", entityIDid);\n makeEditable(\"entityID\", entityIDid);\n entityIDid = entityIDid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"entityID\");\n });\n });\n }\n\n\tvar sourceid = 1;\n var sourceOpen = false;\n\tif ($('#sourcestab').exists()){\n\t\t$('#sourcestab').click(function(){\n // Don't open a second time\n if (sourceOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=sources\", null, function (data) {\n sourceOpen = true;\n $('#sources').html(data);\n\n turnOnEditDeleteButtons(\"sources\");\n\n if ($('#next_source_i').exists()) {\n sourceid = parseInt($('#next_source_i').text());\n }\n console.log(\"Next source ID: \" + sourceid);\n if ($('#btn_add_source').exists()){\n $('#btn_add_source').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#source_template').clone();\n var html = text.html().replace(/ZZ/g, sourceid);\n $('#add_source_div').after(html);\n turnOnButtons(\"source\", sourceid);\n turnOnTooltips(\"source\", sourceid);\n makeEditable(\"source\", sourceid);\n sourceid = sourceid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"sources\");\n });\n });\n }\n\n\tvar resourceRelationid = 1;\n var resourceRelationOpen = false;\n\tif ($('#resourceRelationstab').exists()){\n\t\t$('#resourceRelationstab').click(function(){\n // Don't open a second time\n if (resourceRelationOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=resourceRelations\", null, function (data) {\n resourceRelationOpen = true;\n $('#resourceRelations').html(data);\n\n turnOnEditDeleteButtons(\"resourceRelations\");\n\n if ($('#next_resourceRelation_i').exists()) {\n resourceRelationid = parseInt($('#next_resourceRelation_i').text());\n }\n console.log(\"Next resourceRelation ID: \" + resourceRelationid);\n if ($('#btn_create_resourceRelation').exists()){\n $('#btn_create_resourceRelation').click(function(){\n var rid = $('input[name=resourceChoice]:checked', '#resource_search_form').val();\n if (rid != null && resourceResults != null && rid != 'new') {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#resourceRelation_template').clone();\n var html = text.html().replace(/ZZ/g, resourceRelationid);\n $('#add_resourceRelation_div').after(html);\n\n if (typeof resourceResults[rid].id !== 'undefined')\n $('#resourceRelation_resourceid_'+resourceRelationid).val(resourceResults[rid].id);\n if (typeof resourceResults[rid].version !== 'undefined')\n $('#resourceRelation_resourceversion_'+resourceRelationid).val(resourceResults[rid].version);\n\n if (typeof resourceResults[rid].link !== 'undefined')\n $('#resourceRelation_linkText_'+resourceRelationid).html(\"\"+resourceResults[rid].link+\"\" +\n \" View\");\n if (typeof resourceResults[rid].displayEntry !== 'undefined')\n $('#resourceRelation_displayEntryText_'+resourceRelationid).text(resourceResults[rid].displayEntry);\n if (typeof resourceResults[rid].title !== 'undefined') {\n $('#resourceRelation_titleText_'+resourceRelationid).text(resourceResults[rid].title);\n updatePictureTitle('resourceRelation', resourceRelationid, resourceResults[rid].title);\n }\n if (typeof resourceResults[rid].abstract !== 'undefined')\n $('#resourceRelation_abstractText_'+resourceRelationid).text(resourceResults[rid].abstract);\n if (typeof resourceResults[rid].extent !== 'undefined')\n $('#resourceRelation_extentText_'+resourceRelationid).text(resourceResults[rid].extent);\n // if (typeof resourceResults[rid].date !== 'undefined')\n // $('#resourceRelation_dateText_'+resourceRelationid).text(resourceResults[rid].date);\n if (typeof resourceResults[rid].documentType !== 'undefined' && typeof resourceResults[rid].documentType.term !== 'undefined')\n $('#resourceRelation_documentTypeText_'+resourceRelationid).text(resourceResults[rid].documentType.term);\n\n $('#resourceRelation_linkText_'+resourceRelationid).after(\"View in SNAC\");\n turnOnButtons(\"resourceRelation\", resourceRelationid);\n turnOnTooltips(\"resourceRelation\", resourceRelationid);\n makeEditable(\"resourceRelation\", resourceRelationid);\n resourceRelationid = resourceRelationid + 1;\n $(\"#resource-results-box\").html(\"\");\n return true;\n }\n return false;\n });\n }\n\n if ($('#btn_open_create_resource').exists()){\n $('#btn_open_create_resource').click(function(){\n // Close this modal and open the new modal\n $(\"#resourceSearchPane\").modal(\"hide\");\n\n // Set a 500ms timeout to give the hidden search pane time to fully close\n setTimeout(function() {$(\"#resourceCreatePane\").modal(\"show\");}, 500);\n\n // Grab the empty template and replace\n var text = $('#resource_template').clone();\n var html = text.html().replace(/ZZ/g, 0);\n $('#resource-create-box').html(html);\n var $resourceForm = $(\"#resource_create_form\");\n // Copy the search contents to title or href\n if ($(\"#resource-searchbox\").val().indexOf(\"http\") == -1)\n $resourceForm.find(\"#resource-title\").val($(\"#resource-searchbox\").val());\n else\n $resourceForm.find(\"#resource-url\").val($(\"#resource-searchbox\").val());\n\n $resourceForm.find('[data-toggle=\"popover\"]').popover({\n trigger: 'hover',\n container: 'body'\n });\n loadVocabSelectOptions($resourceForm.find(\"#resource-type-select\"), \"document_type\", \"Resource Type\");\n vocab_select_replace($resourceForm.find(\"#resource-repo\"), \"\", \"holding\", 3);\n $resourceForm.find(\"#new-resource-language-btn\").on(\"click\", newResourceLanguage);\n $resourceForm.find(\"#magic-resource-language-btn\").on(\"click\", magicNewResourceLanguage);\n\n $('#search-results-box').on(\"click\", \"a.list-group-item\", selectHoldingRepository);\n var timeoutID = null;\n $resourceForm.find('#searchbox').keyup(function() {\n clearTimeout(timeoutID);\n timeoutID = setTimeout(function() { setSearchPosition(0); searchAndUpdate(); }, 500);\n });\n\n // Remove the search results from the other modal\n $(\"#resource-results-box\").html(\"\");\n return false;\n });\n }\n\n if ($('#btn_create_resource').exists()){\n $('#resource_create_form').on(\"submit\", function(){\n // Remove leading and trailing whitespace\n if ($(\"#resource_create_form #resource-url\").val() == \"\") {\n if (!confirm('Are you sure you want to save without an HREF?')) {\n return;\n }\n }\n $(\"#resource_create_form input, textarea\").each(function() {\n $(this).val($.trim($(this).val()));\n });\n setDeletedResourceLanguageOperations($(\"#resource_create_form\"));\n\n $.post(snacUrl+\"/save_resource\", $(\"#resource_create_form\").serialize(), function (data) {\n if (typeof data.result !== 'undefined' && data.result !== 'false') {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#resourceRelation_template').clone();\n var html = text.html().replace(/ZZ/g, resourceRelationid); // clones DOM, replaces zz with next ids\n $('#add_resourceRelation_div').after(html);\n\n if (typeof data.resource.id !== 'undefined')\n $('#resourceRelation_resourceid_'+resourceRelationid).val(data.resource.id);\n if (typeof data.resource.version !== 'undefined')\n $('#resourceRelation_resourceversion_'+resourceRelationid).val(data.resource.version);\n\n if (typeof data.resource.link !== 'undefined')\n $('#resourceRelation_linkText_'+resourceRelationid).html(\"\"+data.resource.link+\"\" +\n \" View\");\n if (typeof data.resource.displayEntry !== 'undefined')\n $('#resourceRelation_displayEntryText_'+resourceRelationid).text(data.resource.displayEntry);\n if (typeof data.resource.title !== 'undefined') {\n $('#resourceRelation_titleText_'+resourceRelationid).text(data.resource.title);\n updatePictureTitle('resourceRelation', resourceRelationid, data.resource.title);\n }\n if (typeof data.resource.abstract !== 'undefined')\n $('#resourceRelation_abstractText_'+resourceRelationid).text(data.resource.abstract);\n if (typeof data.resource.extent !== 'undefined')\n $('#resourceRelation_extentText_'+resourceRelationid).text(data.resource.extent);\n if (typeof data.resource.documentType !== 'undefined' && typeof data.resource.documentType.term !== 'undefined')\n $('#resourceRelation_documentTypeText_'+resourceRelationid).text(data.resource.documentType.term);\n\n $('#resourceRelation_linkText_'+resourceRelationid).after(\"View in SNAC\");\n turnOnButtons(\"resourceRelation\", resourceRelationid);\n turnOnTooltips(\"resourceRelation\", resourceRelationid);\n makeEditable(\"resourceRelation\", resourceRelationid);\n resourceRelationid = resourceRelationid + 1;\n $(\"#resourceCreatePane\").modal(\"hide\");\n $('#resource-create-box').html(\"\");\n return true;\n } else {\n console.log(data);\n return false;\n }\n });\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"resourceRelations\");\n });\n });\n }\n\n\n\tvar constellationRelationid = 1;\n var constellationRelationOpen = false;\n\tif ($('#constellationRelationstab').exists()){\n\t\t$('#constellationRelationstab').click(function(){\n // Don't open a second time\n if (constellationRelationOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=constellationRelations\", null, function (data) {\n constellationRelationOpen = true;\n $('#constellationRelations').html(data);\n\n turnOnEditDeleteButtons(\"constellationRelations\");\n\n if ($('#next_constellationRelation_i').exists()) {\n constellationRelationid = parseInt($('#next_constellationRelation_i').text());\n }\n console.log(\"Next constellationRelation ID: \" + constellationRelationid);\n if ($('#btn_create_constellationRelation').exists()){\n $('#btn_create_constellationRelation').click(function(){\n var cid = $('input[name=relationChoice]:checked', '#relation_search_form').val()\n if (cid != null) {\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#constellationRelation_template').clone();\n var html = text.html().replace(/ZZ/g, constellationRelationid);\n $('#add_constellationRelation_div').after(html);\n $('#constellationRelation_targetID_'+constellationRelationid).val(cid);\n $('#constellationRelation_content_'+constellationRelationid).val($('#relationChoice_nameEntry_'+cid).val());\n $('#constellationRelation_targetArkID_'+constellationRelationid).val($('#relationChoice_arkID_'+cid).val());\n $('#constellationRelation_targetEntityType_'+constellationRelationid).val($('#relationChoice_entityType_'+cid).val());\n\n updatePictureIcon('constellationRelation', constellationRelationid, $('#relationChoice_entityTypeText_'+cid).val());\n updatePictureTitle('constellationRelation', constellationRelationid, $('#relationChoice_nameEntry_'+cid).val());\n\n $('#constellationRelation_contentText_'+constellationRelationid).text($('#relationChoice_nameEntry_'+cid).val());\n $('#constellationRelation_targetArkIDText_'+constellationRelationid).text($('#relationChoice_arkID_'+cid).val());\n\n turnOnButtons(\"constellationRelation\", constellationRelationid);\n turnOnTooltips(\"constellationRelation\", constellationRelationid);\n makeEditable(\"constellationRelation\", constellationRelationid);\n\n constellationRelationid = constellationRelationid + 1;\n\n return true;\n\n }\n\n\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"constellationRelations\");\n });\n });\n }\n\n\tvar languageid = 1;\n var languageOpen = false;\n\tif ($('#languagesUsedtab').exists()){\n\t\t$('#languagesUsedtab').click(function(){\n // Don't open a second time\n if (languageOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=languagesUsed\", null, function (data) {\n languageOpen = true;\n $('#languagesUsed').html(data);\n\n turnOnEditDeleteButtons(\"languagesUsed\");\n\n if ($('#next_language_i').exists()) {\n languageid = parseInt($('#next_language_i').text());\n }\n console.log(\"Next language ID: \" + languageid);\n if ($('#btn_add_language').exists()){\n $('#btn_add_language').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#language_template').clone();\n var html = text.html().replace(/ZZ/g, languageid);\n $('#add_language_div').after(html);\n turnOnButtons(\"language\", languageid);\n turnOnTooltips(\"language\", languageid);\n makeEditable(\"language\", languageid);\n languageid = languageid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"languagesUsed\");\n });\n });\n }\n\n\tvar subjectid = 1;\n var subjectOpen = false;\n\tif ($('#subjectstab').exists()){\n\t\t$('#subjectstab').click(function(){\n // Don't open a second time\n if (subjectOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=subjects\", null, function (data) {\n subjectOpen = true;\n $('#subjects').html(data);\n\n turnOnEditDeleteButtons(\"subjects\");\n\n if ($('#next_subject_i').exists()) {\n subjectid = parseInt($('#next_subject_i').text());\n }\n console.log(\"Next subject ID: \" + subjectid);\n if ($('#btn_add_subject').exists()){\n $('#btn_add_subject').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#subject_template').clone();\n var html = text.html().replace(/ZZ/g, subjectid);\n $('#add_subject_div').after(html);\n turnOnButtons(\"subject\", subjectid);\n turnOnTooltips(\"subject\", subjectid);\n makeEditable(\"subject\", subjectid);\n subjectid = subjectid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"subjects\");\n });\n });\n }\n\n\tvar nationalityid = 1;\n var nationalityOpen = false;\n\tif ($('#nationalitiestab').exists()){\n\t\t$('#nationalitiestab').click(function(){\n // Don't open a second time\n if (nationalityOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=nationalities\", null, function (data) {\n nationalityOpen = true;\n $('#nationalities').html(data);\n\n turnOnEditDeleteButtons(\"nationalities\");\n\n if ($('#next_nationality_i').exists()) {\n nationalityid = parseInt($('#next_nationality_i').text());\n }\n console.log(\"Next nationality ID: \" + nationalityid);\n if ($('#btn_add_nationality').exists()){\n $('#btn_add_nationality').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#nationality_template').clone();\n var html = text.html().replace(/ZZ/g, nationalityid);\n $('#add_nationality_div').after(html);\n turnOnButtons(\"nationality\", nationalityid);\n turnOnTooltips(\"nationality\", nationalityid);\n makeEditable(\"nationality\", nationalityid);\n nationalityid = nationalityid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"nationalities\");\n });\n });\n }\n\n\tvar functionid = 1;\n var functionOpen = false;\n\tif ($('#functionstab').exists()){\n\t\t$('#functionstab').click(function(){\n // Don't open a second time\n if (functionOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=functions\", null, function (data) {\n functionOpen = true;\n $('#functions').html(data);\n\n turnOnEditDeleteButtons(\"functions\");\n\n if ($('#next_function_i').exists()) {\n functionid = parseInt($('#next_function_i').text());\n }\n console.log(\"Next function ID: \" + functionid);\n if ($('#btn_add_function').exists()){\n $('#btn_add_function').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#function_template').clone();\n var html = text.html().replace(/ZZ/g, functionid);\n $('#add_function_div').after(html);\n turnOnButtons(\"function\", functionid);\n turnOnTooltips(\"function\", functionid);\n makeEditable(\"function\", functionid);\n functionid = functionid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"functions\");\n });\n });\n }\n\n\tvar occupationid = 1;\n var occupationOpen = false;\n\tif ($('#occupationstab').exists()){\n\t\t$('#occupationstab').click(function(){\n // Don't open a second time\n if (occupationOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=occupations\", null, function (data) {\n occupationOpen = true;\n $('#occupations').html(data);\n\n turnOnEditDeleteButtons(\"occupations\");\n\n if ($('#next_occupation_i').exists()) {\n occupationid = parseInt($('#next_occupation_i').text());\n }\n console.log(\"Next occupation ID: \" + occupationid);\n if ($('#btn_add_occupation').exists()){\n $('#btn_add_occupation').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#occupation_template').clone();\n var html = text.html().replace(/ZZ/g, occupationid);\n $('#add_occupation_div').after(html);\n turnOnButtons(\"occupation\", occupationid);\n turnOnTooltips(\"occupation\", occupationid);\n makeEditable(\"occupation\", occupationid);\n occupationid = occupationid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"occupations\");\n });\n });\n }\n\n\tvar legalStatusid = 1;\n var legalStatusOpen = false;\n\tif ($('#legalStatusestab').exists()){\n\t\t$('#legalStatusestab').click(function(){\n // Don't open a second time\n if (legalStatusOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=legalStatuses\", null, function (data) {\n legalStatusOpen = true;\n $('#legalStatuses').html(data);\n\n turnOnEditDeleteButtons(\"legalStatuses\");\n\n if ($('#next_legalStatus_i').exists()) {\n legalStatusid = parseInt($('#next_legalStatus_i').text());\n }\n console.log(\"Next legalStatus ID: \" + legalStatusid);\n if ($('#btn_add_legalStatus').exists()){\n $('#btn_add_legalStatus').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#legalStatus_template').clone();\n var html = text.html().replace(/ZZ/g, legalStatusid);\n $('#add_legalStatus_div').after(html);\n turnOnButtons(\"legalStatus\", legalStatusid);\n turnOnTooltips(\"legalStatus\", legalStatusid);\n makeEditable(\"legalStatus\", legalStatusid);\n legalStatusid = legalStatusid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"legalStatuses\");\n });\n });\n }\n\n\tvar placeid = 1;\n var placeOpen = false;\n\tif ($('#placestab').exists()){\n\t\t$('#placestab').click(function(){\n // Don't open a second time\n if (placeOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=places\", null, function (data) {\n placeOpen = true;\n $('#places').html(data);\n\n // Load the place cache, if needed\n loadGeoPlaceResultCache();\n\n turnOnEditDeleteButtons(\"places\");\n\n if ($('#next_place_i').exists()) {\n placeid = parseInt($('#next_place_i').text());\n }\n console.log(\"Next place ID: \" + placeid);\n if ($('#btn_add_place').exists()){\n $('#btn_add_place').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#place_template').clone();\n var html = text.html().replace(/ZZ/g, placeid);\n $('#add_place_div').after(html);\n turnOnButtons(\"place\", placeid);\n turnOnTooltips(\"place\", placeid);\n makeEditable(\"place\", placeid);\n placeid = placeid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"places\");\n });\n });\n }\n\n\tvar conventionDeclarationid = 1;\n var conventionDeclarationOpen = false;\n\tif ($('#conventionDeclarationstab').exists()){\n\t\t$('#conventionDeclarationstab').click(function(){\n // Don't open a second time\n if (conventionDeclarationOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=conventionDeclarations\", null, function (data) {\n conventionDeclarationOpen = true;\n $('#conventionDeclarations').html(data);\n\n turnOnEditDeleteButtons(\"conventionDeclarations\");\n\n if ($('#next_conventionDeclaration_i').exists()) {\n conventionDeclarationid = parseInt($('#next_conventionDeclaration_i').text());\n }\n console.log(\"Next conventionDeclaration ID: \" + conventionDeclarationid);\n if ($('#btn_add_conventionDeclaration').exists()){\n $('#btn_add_conventionDeclaration').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#conventionDeclaration_template').clone();\n var html = text.html().replace(/ZZ/g, conventionDeclarationid);\n $('#add_conventionDeclaration_div').after(html);\n turnOnButtons(\"conventionDeclaration\", conventionDeclarationid);\n turnOnTooltips(\"conventionDeclaration\", conventionDeclarationid);\n makeEditable(\"conventionDeclaration\", conventionDeclarationid);\n conventionDeclarationid = conventionDeclarationid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"conventionDeclarations\");\n });\n });\n }\n\n\tvar generalContextid = 1;\n var generalContextOpen = false;\n\tif ($('#generalContextstab').exists()){\n\t\t$('#generalContextstab').click(function(){\n // Don't open a second time\n if (generalContextOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=generalContexts\", null, function (data) {\n generalContextOpen = true;\n $('#generalContexts').html(data);\n\n turnOnEditDeleteButtons(\"generalContexts\");\n\n if ($('#next_generalContext_i').exists()) {\n generalContextid = parseInt($('#next_generalContext_i').text());\n }\n console.log(\"Next generalContext ID: \" + generalContextid);\n if ($('#btn_add_generalContext').exists()){\n $('#btn_add_generalContext').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#generalContext_template').clone();\n var html = text.html().replace(/ZZ/g, generalContextid);\n $('#add_generalContext_div').after(html);\n turnOnButtons(\"generalContext\", generalContextid);\n turnOnTooltips(\"generalContext\", generalContextid);\n makeEditable(\"generalContext\", generalContextid);\n generalContextid = generalContextid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"generalContexts\");\n });\n });\n }\n\n\tvar structureOrGenealogyid = 1;\n var structureOrGenealogyOpen = false;\n\tif ($('#structureOrGenealogiestab').exists()){\n\t\t$('#structureOrGenealogiestab').click(function(){\n // Don't open a second time\n if (structureOrGenealogyOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=structureOrGenealogies\", null, function (data) {\n structureOrGenealogyOpen = true;\n $('#structureOrGenealogies').html(data);\n\n turnOnEditDeleteButtons(\"structureOrGenealogies\");\n\n if ($('#next_structureOrGenealogy_i').exists()) {\n structureOrGenealogyid = parseInt($('#next_structureOrGenealogy_i').text());\n }\n console.log(\"Next structureOrGenealogy ID: \" + structureOrGenealogyid);\n if ($('#btn_add_structureOrGenealogy').exists()){\n $('#btn_add_structureOrGenealogy').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#structureOrGenealogy_template').clone();\n var html = text.html().replace(/ZZ/g, structureOrGenealogyid);\n $('#add_structureOrGenealogy_div').after(html);\n turnOnButtons(\"structureOrGenealogy\", structureOrGenealogyid);\n turnOnTooltips(\"structureOrGenealogy\", structureOrGenealogyid);\n makeEditable(\"structureOrGenealogy\", structureOrGenealogyid);\n structureOrGenealogyid = structureOrGenealogyid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"structureOrGenealogies\");\n });\n });\n }\n\n\tvar mandateid = 1;\n var mandateOpen = false;\n\tif ($('#mandatestab').exists()){\n\t\t$('#mandatestab').click(function(){\n // Don't open a second time\n if (mandateOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=mandates\", null, function (data) {\n mandateOpen = true;\n $('#mandates').html(data);\n\n turnOnEditDeleteButtons(\"mandates\");\n\n if ($('#next_mandate_i').exists()) {\n mandateid = parseInt($('#next_mandate_i').text());\n }\n console.log(\"Next mandate ID: \" + mandateid);\n if ($('#btn_add_mandate').exists()){\n $('#btn_add_mandate').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#mandate_template').clone();\n var html = text.html().replace(/ZZ/g, mandateid);\n $('#add_mandate_div').after(html);\n turnOnButtons(\"mandate\", mandateid);\n turnOnTooltips(\"mandate\", mandateid);\n makeEditable(\"mandate\", mandateid);\n mandateid = mandateid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"mandates\");\n });\n });\n }\n\n\tvar biogHistid = 1;\n var biogHistOpen = false;\n\tif ($('#biogHiststab').exists()){\n\t\t$('#biogHiststab').click(function(){\n // Don't open a second time\n if (biogHistOpen)\n return;\n\n $.get(snacUrl+\"/edit_part/\"+$('#constellationid').val()+\"/\"+$('#version').val()+\"?part=biogHists\", null, function (data) {\n biogHistOpen = true;\n $('#biogHists').html(data);\n\n turnOnEditDeleteButtons(\"biogHists\");\n\n if ($('#next_biogHist_i').exists()) {\n biogHistid = parseInt($('#next_biogHist_i').text());\n }\n console.log(\"Next biogHist ID: \" + biogHistid);\n if ($('#btn_add_biogHist').exists()){\n $('#btn_add_biogHist').click(function(){\n setEditedFlag(true);\n //somethingHasBeenEdited = true;\n var text = $('#biogHist_template').clone();\n var html = text.html().replace(/ZZ/g, biogHistid);\n $('#add_biogHist_div').after(html);\n turnOnButtons(\"biogHist\", biogHistid);\n turnOnTooltips(\"biogHist\", biogHistid);\n makeEditable(\"biogHist\", biogHistid);\n biogHistid = biogHistid + 1;\n return false;\n });\n }\n\n turnOnTooltipsForTab(\"biogHists\");\n });\n });\n }\n\n turnOnTooltipsForTab();\n\n\n $(\"#info-dropdown\").click(function(e) {\n $(this).parent().toggleClass(\"open\");\n e.stopPropagation();\n });\n\n});\n"],"sourceRoot":""} \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/resource_admin.js b/src/virtualhosts/www/javascript/resource_admin.js index 4aaae7c4c..956ca2c30 100644 --- a/src/virtualhosts/www/javascript/resource_admin.js +++ b/src/virtualhosts/www/javascript/resource_admin.js @@ -1,95 +1,13 @@ -(function(e, a) { for(var i in a) e[i] = a[i]; }(window, /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 0); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"saveResource\", function() { return saveResource; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"setDeletedResourceLanguageOperations\", function() { return setDeletedResourceLanguageOperations; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"cancelResource\", function() { return cancelResource; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"newResourceLanguage\", function() { return newResourceLanguage; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"deleteOrUndoLanguage\", function() { return deleteOrUndoLanguage; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"markEditedResourceFields\", function() { return markEditedResourceFields; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"enableLanguageSelect\", function() { return enableLanguageSelect; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"magicNewResourceLanguage\", function() { return magicNewResourceLanguage; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"selectHoldingRepository\", function() { return selectHoldingRepository; });\n/**\n * Resource Admin Actions\n *\n * Contains code that handles Resource creation and editing\n *\n * @author Joseph Glass\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\nfunction saveResource(event) {\n event.preventDefault();\n var $form = $(event.target);\n\n if ($form.find(\"#resource-url\").val() == \"\") {\n if (!confirm('Are you sure you want to save without an HREF?')) {\n return;\n }\n }\n $('#notification-message').slideDown().html(\"

    Saving Resource... Please wait.

    \");\n\n // Remove leading and trailing whitespace\n $form.find(\"input, textarea\").each(function () {\n $(this).val($.trim($(this).val()));\n });\n\n setDeletedResourceLanguageOperations($form);\n\n $.post(snacUrl + \"/save_resource\", $form.serialize()).done(function (data) {\n createdResource = data;\n if (typeof data.resource === 'undefined') {\n $('#error-message').slideDown();\n return false;\n }\n $('#notification-message').slideUp();\n $('#success-message').slideDown();\n setTimeout(function () {\n window.location = snacUrl + \"/vocab_administrator/resources/\" + data.resource.id;\n }, 1000);\n }).fail(function () {\n $('#error-message').slideDown();\n });\n return false;\n}\n\nfunction setDeletedResourceLanguageOperations($form) {\n // Set deleted new languages to null, set deleted existing languages to delete\n var $deletedLanguages = $form.find(\"#resource-languages .component-deleted\").has('input[id]');\n var $ignoredLanguages = $form.find(\"#resource-languages .component-deleted.new-language\");\n setOperations($deletedLanguages, \"delete\");\n setOperations($ignoredLanguages, \"\");\n}\n\nfunction cancelResource() {\n if (!confirm('Are you sure you want to cancel?')) {\n return;\n }\n\n $('#notification-message').html(\"

    Cancelling...

    \");\n $('#notification-message').slideDown();\n setTimeout(function () {\n window.location.href = snacUrl + \"/vocab_administrator\";\n }, 1000);\n return false;\n}\n\n/**\n * New Resource Language\n * Copies the resource template DIV on the page and attaches it correctly to the DOM.\n * Tracks language index using $('#language-template').data('languageCount')\n *\n */\nfunction newResourceLanguage(event) {\n event.preventDefault();\n var $newLanguage = $('#resource-language-template').find(\".language\").clone();\n var data = $('#resource-language-template').data();\n var newLanguageID = 'language_' + data.languageCount;\n $newLanguage.attr('id', newLanguageID);\n $newLanguage.find('.operation').val('insert');\n $newLanguage.addClass('new-language');\n\n //update input names with new data.languageCount\n $newLanguage.find('input, select').attr('name', function (i, name) {\n return name.replace('YY', data.languageCount);\n });\n\n console.log('Adding new resource language with id: ', newLanguageID);\n $newLanguage.toggle();\n // selects last to avoid conflict on multiple clones\n $('.add-resource-language:last').before($newLanguage);\n enableLanguageSelect($newLanguage);\n\n data.languageCount++;\n return $newLanguage;\n}\n\n/**\n * Delete or Undo Language\n *\n * Toggles component-deleted class, and btn classes for delete and undo.\n * Does not change operations.\n *\n */\nfunction deleteOrUndoLanguage(event) {\n event.preventDefault();\n var $btn = $(event.currentTarget);\n $btn.toggleClass('btn-danger btn-warning');\n $btn.find(':only-child').toggleClass('fa-minus-circle fa-undo');\n var $language = $btn.closest('.language');\n $language.toggleClass('alert-danger component-deleted');\n}\n\nfunction setOperations($elements, operation) {\n $elements.find('.operation').each(function () {\n $(this).val(operation);\n });\n}\n\n/**\n * Mark Edited Resource Fields\n *\n * Adds edited-field class to altered inputs. Sets altered resource language to update.\n * @param jqueryObject $resourceForm jQuery object to modify\n *\n */\nfunction markEditedResourceFields($resourceForm) {\n $resourceForm.find(\"input, select, textarea\").on(\"change\", function (e) {\n $(e.target).addClass('edited-field');\n\n if ($(e.target).closest('.language').length) {\n setOperations($(e.target).closest('.language'), \"update\");\n }\n });\n}\n\nfunction enableVocabularySelect(selectItem, type) {\n selectItem.select2({\n ajax: {\n url: snacUrl + \"/vocabulary?type=\" + type,\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return {\n results: data.results\n };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 0,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n}\n\nfunction enableLanguageSelect($language) {\n enableVocabularySelect($language.find(\"select:first\"), 'language_code');\n enableVocabularySelect($language.find(\"select:last\"), 'script_code');\n}\n\nfunction magicNewResourceLanguage(event) {\n var $newLanguage = newResourceLanguage(event);\n var defaultLanguage = new Option(defaults.language.term, defaults.language.id, false, true);\n var defaultScript = new Option(defaults.script.term, defaults.script.id, false, true);\n $newLanguage.find(\"select:first\").append(defaultLanguage).trigger('change');\n $newLanguage.find(\"select:last\").append(defaultScript).trigger('change');\n}\n\nfunction selectHoldingRepository(event) {\n event.preventDefault();\n var name = event.target.innerHTML;\n var id = event.target.href.split('/').pop();\n var selectedRepo = new Option(name, id, false, true);\n $(\".resource-repo:last\").append(selectedRepo).trigger('change');\n $(\"#search_form\").slideToggle();\n $(\"#search-results-box\").html(\"\");\n $(\"#searchbox\").val(\"\");\n}//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMC5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zcmMvdmlydHVhbGhvc3RzL3d3dy9qYXZhc2NyaXB0L3NyYy9yZXNvdXJjZV9hZG1pbi5qcz81OTE5Il0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogUmVzb3VyY2UgQWRtaW4gQWN0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UE7QUFDQTtBQUNBO0FBQ0E7QUFEQTtBQUdBO0FBQ0E7QUFmQTtBQWlCQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBdEJBO0FBd0JBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBRUE7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBO0FBQ0E7QUFDQTtBQUNBIiwic291cmNlUm9vdCI6IiJ9\n//# sourceURL=webpack-internal:///0\n"); - -/***/ }) -/******/ ]))); \ No newline at end of file +!function(e,n){for(var t in n)e[t]=n[t]}(window,function(e){var n={};function t(r){if(n[r])return n[r].exports;var a=n[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,t),a.l=!0,a.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var a in e)t.d(r,a,function(n){return e[n]}.bind(null,a));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){"use strict"; +/** + * Resource Admin Actions + * + * Contains code that handles Resource creation and editing + * + * @author Joseph Glass + * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause + * @copyright 2015 the Rector and Visitors of the University of Virginia, and + * the Regents of the University of California + */ +function r(e){e.preventDefault();var n=$(e.target);if(""!=n.find("#resource-url").val()||confirm("Are you sure you want to save without an HREF?"))return $("#notification-message").slideDown().html("

    Saving Resource... Please wait.

    "),n.find("input, textarea").each((function(){$(this).val($.trim($(this).val()))})),a(n),$.post(snacUrl+"/save_resource",n.serialize()).done((function(e){if(createdResource=e,void 0===e.resource)return $("#error-message").slideDown(),!1;$("#notification-message").slideUp(),$("#success-message").slideDown(),setTimeout((function(){window.location=snacUrl+"/vocab_administrator/resources/"+e.resource.id}),1e3)})).fail((function(){$("#error-message").slideDown()})),!1}function a(e){var n=e.find("#resource-languages .component-deleted").has("input[id]"),t=e.find("#resource-languages .component-deleted.new-language");l(n,"delete"),l(t,"")}function o(){if(confirm("Are you sure you want to cancel?"))return $("#notification-message").html("

    Cancelling...

    "),$("#notification-message").slideDown(),setTimeout((function(){window.location.href=snacUrl+"/vocab_administrator"}),1e3),!1}function u(e){e.preventDefault();var n=$("#resource-language-template").find(".language").clone(),t=$("#resource-language-template").data(),r="language_"+t.languageCount;return n.attr("id",r),n.find(".operation").val("insert"),n.addClass("new-language"),n.find("input, select").attr("name",(function(e,n){return n.replace("YY",t.languageCount)})),console.log("Adding new resource language with id: ",r),n.toggle(),$(".add-resource-language:last").before(n),d(n),t.languageCount++,n}function i(e){e.preventDefault();var n=$(e.currentTarget);n.toggleClass("btn-danger btn-warning"),n.find(":only-child").toggleClass("fa-minus-circle fa-undo"),n.closest(".language").toggleClass("alert-danger component-deleted")}function l(e,n){e.find(".operation").each((function(){$(this).val(n)}))}function s(e){e.find("input, select, textarea").on("change",(function(e){$(e.target).addClass("edited-field"),$(e.target).closest(".language").length&&l($(e.target).closest(".language"),"update")}))}function c(e,n){e.select2({ajax:{url:snacUrl+"/vocabulary?type="+n,dataType:"json",delay:250,data:function(e){return{q:e.term,page:e.page}},processResults:function(e,n){return{results:e.results}},cache:!0},width:"100%",minimumInputLength:0,allowClear:!0,theme:"bootstrap",placeholder:"Select"})}function d(e){c(e.find("select:first"),"language_code"),c(e.find("select:last"),"script_code")}function g(e){var n=u(e),t=new Option(defaults.language.term,defaults.language.id,!1,!0),r=new Option(defaults.script.term,defaults.script.id,!1,!0);n.find("select:first").append(t).trigger("change"),n.find("select:last").append(r).trigger("change")}function f(e){e.preventDefault();var n=e.target.innerHTML,t=e.target.href.split("/").pop(),r=new Option(n,t,!1,!0);$(".resource-repo:last").append(r).trigger("change"),$("#search_form").slideToggle(),$("#search-results-box").html(""),$("#searchbox").val("")}t.r(n),t.d(n,"saveResource",(function(){return r})),t.d(n,"setDeletedResourceLanguageOperations",(function(){return a})),t.d(n,"cancelResource",(function(){return o})),t.d(n,"newResourceLanguage",(function(){return u})),t.d(n,"deleteOrUndoLanguage",(function(){return i})),t.d(n,"markEditedResourceFields",(function(){return s})),t.d(n,"enableLanguageSelect",(function(){return d})),t.d(n,"magicNewResourceLanguage",(function(){return g})),t.d(n,"selectHoldingRepository",(function(){return f}))}])); +//# sourceMappingURL=resource_admin.js.map \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/resource_admin.js.map b/src/virtualhosts/www/javascript/resource_admin.js.map new file mode 100644 index 000000000..08bf80aa8 --- /dev/null +++ b/src/virtualhosts/www/javascript/resource_admin.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/virtualhosts/www/javascript/src/resource_admin.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","saveResource","event","preventDefault","$form","$","target","find","val","confirm","slideDown","html","each","this","trim","setDeletedResourceLanguageOperations","post","snacUrl","serialize","done","data","createdResource","resource","slideUp","setTimeout","window","location","id","fail","$deletedLanguages","has","$ignoredLanguages","setOperations","cancelResource","href","newResourceLanguage","$newLanguage","clone","newLanguageID","languageCount","attr","addClass","replace","console","log","toggle","before","enableLanguageSelect","deleteOrUndoLanguage","$btn","currentTarget","toggleClass","closest","$elements","operation","markEditedResourceFields","$resourceForm","on","e","length","enableVocabularySelect","selectItem","type","select2","ajax","url","dataType","delay","params","q","term","page","processResults","results","cache","width","minimumInputLength","allowClear","theme","placeholder","$language","magicNewResourceLanguage","defaultLanguage","Option","defaults","language","defaultScript","script","append","trigger","selectHoldingRepository","innerHTML","split","pop","selectedRepo","slideToggle"],"mappings":"4DACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YAAY,EAAMK,MAAOA,IACtD,EAAPE,GAA4B,iBAATF,EAAmB,IAAI,IAAIM,KAAON,EAAOr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VC,KAAMH,EAAOG,OAGrBC,eAAgB,SAASpD,EAAMmD,GAC3B,MAAO,CACHE,QAASrD,EAAKqD,UAGtBC,OAAO,GAEXC,MAAO,OACPC,mBAAoB,EACpBC,YAAY,EACZC,MAAO,YACPC,YAAa,WAId,SAAShC,EAAqBiC,GACjCpB,EAAuBoB,EAAUzE,KAAK,gBAAiB,iBACvDqD,EAAuBoB,EAAUzE,KAAK,eAAgB,eAInD,SAAS0E,EAAyB/E,GACrC,IAAIkC,EAAeD,EAAoBjC,GACnCgF,EAAkB,IAAIC,OAAOC,SAASC,SAASf,KAAMc,SAASC,SAAS1D,IAAI,GAAO,GAClF2D,EAAgB,IAAIH,OAAOC,SAASG,OAAOjB,KAAMc,SAASG,OAAO5D,IAAI,GAAO,GAChFS,EAAa7B,KAAK,gBAAgBiF,OAAON,GAAiBO,QAAQ,UAClErD,EAAa7B,KAAK,eAAeiF,OAAOF,GAAeG,QAAQ,UAG5D,SAASC,EAAwBxF,GACpCA,EAAMC,iBACN,IAAI3B,EAAO0B,EAAMI,OAAOqF,UACpBhE,EAAKzB,EAAMI,OAAO4B,KAAK0D,MAAM,KAAKC,MAClCC,EAAe,IAAIX,OAAO3G,EAAMmD,GAAI,GAAO,GAC/CtB,EAAE,uBAAuBmF,OAAOM,GAAcL,QAAQ,UACtDpF,EAAE,gBAAgB0F,cAClB1F,EAAE,uBAAuBM,KAAK,IAC9BN,EAAE,cAAcG,IAAI,IA7LxB","file":"resource_admin.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","/**\n * Resource Admin Actions\n *\n * Contains code that handles Resource creation and editing\n *\n * @author Joseph Glass\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\nexport function saveResource(event) {\n event.preventDefault();\n var $form = $(event.target);\n\n if ($form.find(\"#resource-url\").val() == \"\") {\n if (!confirm('Are you sure you want to save without an HREF?')) {\n return;\n }\n }\n $('#notification-message').slideDown().html(\"

    Saving Resource... Please wait.

    \");\n\n // Remove leading and trailing whitespace\n $form.find(\"input, textarea\").each(function() {\n $(this).val($.trim($(this).val()));\n });\n\n setDeletedResourceLanguageOperations($form);\n\n $.post(snacUrl + \"/save_resource\", $form.serialize())\n .done(function(data) {\n createdResource = data;\n if (typeof(data.resource) === 'undefined') {\n $('#error-message').slideDown();\n return false;\n }\n $('#notification-message').slideUp();\n $('#success-message').slideDown();\n setTimeout(function() {\n window.location = (snacUrl + \"/vocab_administrator/resources/\" + data.resource.id);\n }, 1000);\n })\n .fail(function() {\n $('#error-message').slideDown();\n });\n return false;\n}\n\n\nexport function setDeletedResourceLanguageOperations($form) {\n // Set deleted new languages to null, set deleted existing languages to delete\n var $deletedLanguages = $form.find(\"#resource-languages .component-deleted\").has('input[id]');\n var $ignoredLanguages = $form.find(\"#resource-languages .component-deleted.new-language\");\n setOperations($deletedLanguages, \"delete\");\n setOperations($ignoredLanguages, \"\");\n}\n\nexport function cancelResource() {\n if (!confirm('Are you sure you want to cancel?')) {\n return;\n }\n\n $('#notification-message').html(\"

    Cancelling...

    \");\n $('#notification-message').slideDown();\n setTimeout(function() {\n window.location.href = snacUrl + \"/vocab_administrator\";\n }, 1000);\n return false;\n}\n\n/**\n * New Resource Language\n * Copies the resource template DIV on the page and attaches it correctly to the DOM.\n * Tracks language index using $('#language-template').data('languageCount')\n *\n */\nexport function newResourceLanguage(event) {\n event.preventDefault();\n var $newLanguage = $('#resource-language-template').find(\".language\").clone();\n var data = $('#resource-language-template').data();\n var newLanguageID = 'language_' + data.languageCount;\n $newLanguage.attr('id', newLanguageID);\n $newLanguage.find('.operation').val('insert');\n $newLanguage.addClass('new-language');\n\n //update input names with new data.languageCount\n $newLanguage.find('input, select').attr('name', function(i, name) {\n return name.replace('YY', data.languageCount);\n });\n\n console.log('Adding new resource language with id: ', newLanguageID);\n $newLanguage.toggle();\n // selects last to avoid conflict on multiple clones\n $('.add-resource-language:last').before($newLanguage);\n enableLanguageSelect($newLanguage);\n\n data.languageCount++;\n return $newLanguage;\n}\n\n/**\n * Delete or Undo Language\n *\n * Toggles component-deleted class, and btn classes for delete and undo.\n * Does not change operations.\n *\n */\nexport function deleteOrUndoLanguage(event) {\n event.preventDefault();\n var $btn = $(event.currentTarget);\n $btn.toggleClass('btn-danger btn-warning');\n $btn.find(':only-child').toggleClass('fa-minus-circle fa-undo');\n var $language = $btn.closest('.language');\n $language.toggleClass('alert-danger component-deleted');\n}\n\n\nfunction setOperations($elements, operation) {\n $elements.find('.operation').each(function() {\n $(this).val(operation);\n });\n}\n\n/**\n * Mark Edited Resource Fields\n *\n * Adds edited-field class to altered inputs. Sets altered resource language to update.\n * @param jqueryObject $resourceForm jQuery object to modify\n *\n */\nexport function markEditedResourceFields($resourceForm) {\n $resourceForm.find(\"input, select, textarea\").on(\"change\", function(e) {\n $(e.target).addClass('edited-field');\n\n if ($(e.target).closest('.language').length) {\n setOperations($(e.target).closest('.language'), \"update\");\n }\n });\n}\n\nfunction enableVocabularySelect(selectItem, type) {\n selectItem.select2({\n ajax: {\n url: snacUrl + \"/vocabulary?type=\" + type,\n dataType: 'json',\n delay: 250,\n data: function(params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function(data, page) {\n return {\n results: data.results\n };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 0,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n}\n\nexport function enableLanguageSelect($language) {\n enableVocabularySelect($language.find(\"select:first\"), 'language_code');\n enableVocabularySelect($language.find(\"select:last\"), 'script_code');\n}\n\n\nexport function magicNewResourceLanguage(event) {\n var $newLanguage = newResourceLanguage(event);\n var defaultLanguage = new Option(defaults.language.term, defaults.language.id, false, true);\n var defaultScript = new Option(defaults.script.term, defaults.script.id, false, true);\n $newLanguage.find(\"select:first\").append(defaultLanguage).trigger('change');\n $newLanguage.find(\"select:last\").append(defaultScript).trigger('change');\n}\n\nexport function selectHoldingRepository(event) {\n event.preventDefault();\n var name = event.target.innerHTML;\n var id = event.target.href.split('/').pop();\n var selectedRepo = new Option(name, id, false, true);\n $(\".resource-repo:last\").append(selectedRepo).trigger('change');\n $(\"#search_form\").slideToggle();\n $(\"#search-results-box\").html(\"\");\n $(\"#searchbox\").val(\"\");\n}\n"],"sourceRoot":""} \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/select_loaders.js b/src/virtualhosts/www/javascript/select_loaders.js index 550d091e0..2ee3b9da2 100644 --- a/src/virtualhosts/www/javascript/select_loaders.js +++ b/src/virtualhosts/www/javascript/select_loaders.js @@ -1,96 +1,14 @@ -(function(e, a) { for(var i in a) e[i] = a[i]; }(window, /******/ (function(modules) { // webpackBootstrap -/******/ // The module cache -/******/ var installedModules = {}; -/******/ -/******/ // The require function -/******/ function __webpack_require__(moduleId) { -/******/ -/******/ // Check if module is in cache -/******/ if(installedModules[moduleId]) { -/******/ return installedModules[moduleId].exports; -/******/ } -/******/ // Create a new module (and put it into the cache) -/******/ var module = installedModules[moduleId] = { -/******/ i: moduleId, -/******/ l: false, -/******/ exports: {} -/******/ }; -/******/ -/******/ // Execute the module function -/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); -/******/ -/******/ // Flag the module as loaded -/******/ module.l = true; -/******/ -/******/ // Return the exports of the module -/******/ return module.exports; -/******/ } -/******/ -/******/ -/******/ // expose the modules object (__webpack_modules__) -/******/ __webpack_require__.m = modules; -/******/ -/******/ // expose the module cache -/******/ __webpack_require__.c = installedModules; -/******/ -/******/ // define getter function for harmony exports -/******/ __webpack_require__.d = function(exports, name, getter) { -/******/ if(!__webpack_require__.o(exports, name)) { -/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); -/******/ } -/******/ }; -/******/ -/******/ // define __esModule on exports -/******/ __webpack_require__.r = function(exports) { -/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { -/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); -/******/ } -/******/ Object.defineProperty(exports, '__esModule', { value: true }); -/******/ }; -/******/ -/******/ // create a fake namespace object -/******/ // mode & 1: value is a module id, require it -/******/ // mode & 2: merge all properties of value into the ns -/******/ // mode & 4: return value when already ns object -/******/ // mode & 8|1: behave like require -/******/ __webpack_require__.t = function(value, mode) { -/******/ if(mode & 1) value = __webpack_require__(value); -/******/ if(mode & 8) return value; -/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; -/******/ var ns = Object.create(null); -/******/ __webpack_require__.r(ns); -/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); -/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); -/******/ return ns; -/******/ }; -/******/ -/******/ // getDefaultExport function for compatibility with non-harmony modules -/******/ __webpack_require__.n = function(module) { -/******/ var getter = module && module.__esModule ? -/******/ function getDefault() { return module['default']; } : -/******/ function getModuleExports() { return module; }; -/******/ __webpack_require__.d(getter, 'a', getter); -/******/ return getter; -/******/ }; -/******/ -/******/ // Object.prototype.hasOwnProperty.call -/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; -/******/ -/******/ // __webpack_public_path__ -/******/ __webpack_require__.p = ""; -/******/ -/******/ -/******/ // Load entry module and return exports -/******/ return __webpack_require__(__webpack_require__.s = 1); -/******/ }) -/************************************************************************/ -/******/ ([ -/* 0 */, -/* 1 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"vocab_select_replace\", function() { return vocab_select_replace; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"geoPlaceSearchResults\", function() { return geoPlaceSearchResults; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"geovocab_select_replace\", function() { return geovocab_select_replace; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"scm_source_select_replace\", function() { return scm_source_select_replace; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"select_replace_simple\", function() { return select_replace_simple; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"sayHi\", function() { return sayHi; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"sayBye\", function() { return sayBye; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"loadVocabSelectOptions\", function() { return loadVocabSelectOptions; });\n/**\n * Select Box Loaders\n *\n * Functions that can be used to replace select boxes on the edit page with\n * pretty-formatted versions using JQuery and Select2\n *\n * @author Robbie Hott\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\n/**\n * Replace a select that is linked to a Vocabulary search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n * @param string type The type of the vocabulary term\n * @param int minLength The minimum required length of the autocomplete search\n */\nfunction vocab_select_replace(selectItem, idMatch, type, minLength) {\n if (minLength === undefined) {\n minLength = 2;\n }\n\n if (selectItem.attr('id').endsWith(idMatch) && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + \"/vocabulary?type=\" + type + \"&id=\";\n query += $(\"#constellationid\").val() + \"&version=\" + $(\"#version\").val();\n query += \"&entity_type=\" + $(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: minLength,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n }\n}\n\nvar geoPlaceSearchResults = null;\n\nfunction geovocab_select_replace(selectItem, idMatch) {\n var minLength = 2;\n\n if (selectItem.attr('id').endsWith(idMatch) && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + \"/vocabulary?type=geo_place&format=term\";\n query += \"&entity_type=\" + $(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n if (data.results) {\n geoPlaceSearchResults = data.results;\n var selectResults = new Array();\n data.results.forEach(function (result) {\n selectResults.push({\n id: result.id,\n text: result.name + \" (\" + result.administrationCode + \", \" + result.countryCode + \")\"\n });\n });\n return { results: selectResults };\n }\n return { results: null };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: minLength,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n }\n}\n\nvar lastSourceSearchResults = null;\n\n/**\n * Add
    helper script\n *\n * Adds
    to strings so that they can be shown to the user in HTML\n * after being input into a text-only field.\n */\nfunction addbr(str) {\n if (typeof str !== 'undefined' && str !== null) {\n return (str + '').replace(/(\\r\\n|\\n\\r|\\r|\\n)/g, '
    ' + '$1');\n }\n return '';\n}\n\n/**\n * Replace a select that is linked to a Constellation Source search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n */\nfunction scm_source_select_replace(selectItem, idMatch) {\n if (selectItem.attr('id').endsWith(idMatch) && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function () {\n var query = snacUrl + \"/vocabulary?type=ic_sources&id=\";\n query += $(\"#constellationid\").val() + \"&version=\" + $(\"#version\").val();\n query += \"&entity_type=\" + $(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n // Modify the results to be in the format we want\n lastSourceSearchResults = data.results;\n // need id, text\n var results = new Array();\n data.results.forEach(function (res) {\n results.push({ id: res.id, text: res.displayName });\n });\n return { results: results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 0,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n\n selectItem.on('change', function (evt) {\n // TODO: Get the current selected value and update the well in the page to reflect it!\n // Note: all the selections are available in the global lastSourceSearchResults variable.\n var sourceID = $(this).val();\n var inPageID = $(this).attr(\"id\");\n var idArray = inPageID.split(\"_\");\n if (idArray.length >= 6) {\n var i = idArray[5];\n var j = idArray[4];\n var shortName = idArray[1];\n lastSourceSearchResults.forEach(function (source) {\n if (source.id == sourceID) {\n // Update the text of the source\n if (typeof source.text !== 'undefined') {\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).html(addbr(source.text)).removeClass('hidden');\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).closest(\".panel-body\").removeClass('hidden');\n } else {\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).text(\"\").addClass('hidden');\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).closest(\".panel-body\").addClass('hidden');\n }\n // Update the URI of the source\n if (typeof source.uri !== 'undefined') $(\"#scm_\" + shortName + \"_source_uri_\" + j + \"_\" + i).html('' + source.uri + '');else $(\"#scm_\" + shortName + \"_source_uri_\" + j + \"_\" + i).html('');\n // Update the URI of the source\n if (typeof source.citation !== 'undefined') $(\"#scm_\" + shortName + \"_source_citation_\" + j + \"_\" + i).html(source.citation).removeClass('hidden');else $(\"#scm_\" + shortName + \"_source_citation_\" + j + \"_\" + i).html('').addClass('hidden');\n }\n });\n }\n });\n }\n}\n\n/**\n * Replace a select that is linked to an affiliation search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n */\nfunction affiliation_select_replace(selectItem) {\n $.get(snacUrl + \"/vocabulary?type=affiliation\").done(function (data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: true,\n theme: \"bootstrap\",\n placeholder: \"Select Affiliation\"\n });\n });\n}\n\nfunction reviewer_select_replace(selectItem) {\n if (selectItem != null) {\n selectItem.select2({\n placeholder: \"Reviewer Name or Email...\",\n ajax: {\n url: function () {\n var query = snacUrl + \"/user_search?role=Reviewer\";\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 1,\n allowClear: false,\n theme: 'bootstrap'\n });\n }\n}\n\nfunction select_replace(selectItem, idMatch) {\n if (selectItem.attr('id').endsWith(idMatch) && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n allowClear: true,\n theme: 'bootstrap'\n });\n }\n}\n\nfunction select_replace_simple(selectItem) {\n selectItem.select2({\n width: '100%',\n allowClear: true,\n theme: 'bootstrap'\n });\n}\n\nfunction sayHi(user) {\n return `Hello, ${user}!`;\n}\n\nfunction sayBye(user) {\n return `Bye bye, ${user}!`;\n}\n\n/**\n * Load Vocab Select Options\n *\n * Replaces the select with a select2 object preloaded with an array of options\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string type The type of the vocabulary term\n * @param string type Text placeholder for select\n */\nfunction loadVocabSelectOptions(selectItem, type, placeholder) {\n return $.get(snacUrl + \"/vocabulary?type=\" + type).done(function (data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: false,\n theme: 'bootstrap',\n placeholder: placeholder\n });\n });\n}\n\n/**\n * Replace all the selects that exist on the page when the page has finished loading\n */\n$(document).ready(function () {\n\n // Use select2 to display the select dropdowns\n // rather than the HTML default\n $(\"select\").each(function () {\n if (typeof $(this).attr('id') !== typeof undefined && $(this).attr('id') !== false) {\n // Replace the subject selects\n vocab_select_replace($(this), \"language_language_\", \"language_code\", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), \"language_script_\", \"script_code\", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), \"subject_\", \"subject\", 4);\n\n // Replace the function selects\n vocab_select_replace($(this), \"function_\", \"function\", 4);\n\n // Replace the occupation selects\n vocab_select_replace($(this), \"occupation_\", \"occupation\", 4);\n\n // Replace the entityType select\n vocab_select_replace($(this), \"entityType\", \"entity_type\", 0);\n }\n });\n\n // Replace the Affiliation dropdowns, if one exists\n if ($(\"#affiliationid\").exists()) affiliation_select_replace($(\"#affiliationid\"));\n\n // Replace the User search dropdown, if one exists\n if ($(\"#reviewersearchbox\").exists()) reviewer_select_replace($(\"#reviewersearchbox\"));\n});//# sourceURL=[module]\n//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMS5qcyIsInNvdXJjZXMiOlsid2VicGFjazovLy9zcmMvdmlydHVhbGhvc3RzL3d3dy9qYXZhc2NyaXB0L3NyYy9zZWxlY3RfbG9hZGVycy5qcz8zOGJlIl0sInNvdXJjZXNDb250ZW50IjpbIi8qKlxuICogU2VsZWN0IEJveCBMb2FkZXJzXG4gKlxuICogRnVuY3Rpb25zIHRoYXQgY2FuIGJlIHVzZWQgdG8gcmVwbGFjZSBzZWxlY3QgYm94ZXMgb24gdGhlIGVkaXQgcGFnZSB3aXRoXG4gKiBwcmV0dHktZm9ybWF0dGVkIHZlcnNpb25zIHVzaW5nIEpRdWVyeSBhbmQgU2VsZWN0MlxuICpcbiAqIEBhdXRob3IgUm9iYmllIEhvdHRcbiAqIEBsaWNlbnNlIGh0dHBzOi8vb3BlbnNvdXJjZS5vcmcvbGljZW5zZXM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gICAgICYmICFzZWxlY3RJdGVtLmF0dHIoJ2lkJykuZW5kc1dpdGgoXCJaWlwiKSkge1xuICAgICAgICAgICAgICAgIHNlbGVjdEl0ZW0uc2VsZWN0Mih7XG4gICAgICAgICAgICAgICAgICAgIGFqYXg6IHtcbiAgICAgICAgICAgICAgICAgICAgICAgIHVybDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHF1ZXJ5ID0gc25hY1VybCArIFwiL3ZvY2FidWxhcnk/dHlwZT1cIit0eXBlK1wiJmlkPVwiO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeSArPSAkKFwiI2NvbnN0ZWxsYXRpb25pZFwiKS52YWwoKStcIiZ2ZXJzaW9uPVwiKyQoXCIjdmVyc2lvblwiKS52YWwoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcXVlcnkgKz0gXCImZW50aXR5X3R5cGU9XCIrJChcIiNlbnRpdHlUeXBlXCIpLnZhbCgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcXVlcnk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVR5cGU6ICdqc29uJyxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGF5OiAyNTAsXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhOiBmdW5jdGlvbiAocGFyYW1zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcTogcGFyYW1zLnRlcm0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhcmFtcy5wYWdlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzUmVzdWx0czogZnVuY3Rpb24gKGRhdGEsIHBhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyByZXN1bHRzOiBkYXRhLnJlc3VsdHMgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBjYWNoZTogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB3aWR0aDogJzEwMCUnLFxuICAgICAgICAgICAgICAgICAgICBtaW5pbXVtSW5wdXRMZW5ndGg6IG1pbkxlbmd0aCxcbiAgICAgICAgICAgICAgICAgICAgYWxsb3dDbGVhcjogdHJ1ZSxcbiAgICAgICAgICAgICAgICAgICAgdGhlbWU6ICdib290c3RyYXAnLFxuICAgICAgICAgICAgICAgICAgICBwbGFjZWhvbGRlcjogJ1NlbGVjdCdcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbn1cblxuZXhwb3J0IHZhciBnZW9QbGFjZVNlYXJjaFJlc3VsdHMgPSBudWxsO1xuXG5leHBvcnQgZnVuY3Rpb24gZ2Vvdm9jYWJfc2VsZWN0X3JlcGxhY2Uoc2VsZWN0SXRlbSwgaWRNYXRjaCkge1xuICAgIHZhciBtaW5MZW5ndGggPSAyO1xuXG4gICAgaWYoc2VsZWN0SXRlbS5hdHRyKCdpZCcpLmVuZHNXaXRoKGlkTWF0Y2gpXG4gICAgICAgICYmICFzZWxlY3RJdGVtLmF0dHIoJ2lkJykuZW5kc1dpdGgoXCJaWlwiKSkge1xuICAgICAgICAgICAgc2VsZWN0SXRlbS5zZWxlY3QyKHtcbiAgICAgICAgICAgICAgICBhamF4OiB7XG4gICAgICAgICAgICAgICAgICAgIHVybDogZnVuY3Rpb24oKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICB2YXIgcXVlcnkgPSBzbmFjVXJsK1wiL3ZvY2FidWxhcnk/dHlwZT1nZW9fcGxhY2UmZm9ybWF0PXRlcm1cIjtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBxdWVyeSArPSBcIiZlbnRpdHlfdHlwZT1cIiskKFwiI2VudGl0eVR5cGVcIikudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHF1ZXJ5O1xuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBkYXRhVHlwZTogJ2pzb24nLFxuICAgICAgICAgICAgICAgICAgICBkZWxheTogMjUwLFxuICAgICAgICAgICAgICAgICAgICBkYXRhOiBmdW5jdGlvbiAocGFyYW1zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4ge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHE6IHBhcmFtcy50ZXJtLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhcmFtcy5wYWdlXG4gICAgICAgICAgICAgICAgICAgICAgICB9O1xuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICBwcm9jZXNzUmVzdWx0czogZnVuY3Rpb24gKGRhdGEsIHBhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgIGlmIChkYXRhLnJlc3VsdHMpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBnZW9QbGFjZVNlYXJjaFJlc3VsdHMgPSBkYXRhLnJlc3VsdHM7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgdmFyIHNlbGVjdFJlc3VsdHMgPSBuZXcgQXJyYXkoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBkYXRhLnJlc3VsdHMuZm9yRWFjaChmdW5jdGlvbihyZXN1bHQpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgc2VsZWN0UmVzdWx0cy5wdXNoKHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIGlkOiByZXN1bHQuaWQsXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICB0ZXh0OiByZXN1bHQubmFtZSArIFwiIChcIiArIHJlc3VsdC5hZG1pbmlzdHJhdGlvbkNvZGUgKyBcIiwgXCIgKyByZXN1bHQuY291bnRyeUNvZGUrIFwiKVwiXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtyZXN1bHRzOiBzZWxlY3RSZXN1bHRzfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7IHJlc3VsdHM6IG51bGwgfTtcbiAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgY2FjaGU6IHRydWVcbiAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgIHdpZHRoOiAnMTAwJScsXG4gICAgICAgICAgICAgICAgbWluaW11bUlucHV0TGVuZ3RoOiBtaW5MZW5ndGgsXG4gICAgICAgICAgICAgICAgYWxsb3dDbGVhcjogdHJ1ZSxcbiAgICAgICAgICAgICAgICB0aGVtZTogJ2Jvb3RzdHJhcCcsXG4gICAgICAgICAgICAgICAgcGxhY2Vob2xkZXI6ICdTZWxlY3QnXG4gICAgICAgICAgICB9KTtcbiAgICAgICAgfVxufVxuXG52YXIgbGFzdFNvdXJjZVNlYXJjaFJlc3VsdHMgPSBudWxsO1xuXG4vKipcbiAqIEFkZCA8YnI+IGhlbHBlciBzY3JpcHRcbiAqXG4gKiBBZGRzIDxicj4gdG8gc3RyaW5ncyBzbyB0aGF0IHRoZXkgY2FuIGJlIHNob3duIHRvIHRoZSB1c2VyIGluIEhUTUxcbiAqIGFmdGVyIGJlaW5nIGlucHV0IGludG8gYSB0ZXh0LW9ubHkgZmllbGQuXG4gKi9cbmZ1bmN0aW9uIGFkZGJyKHN0cikge1xuICAgIGlmICh0eXBlb2Ygc3RyICE9PSAndW5kZWZpbmVkJyAmJiB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Kz0gJChcIiNjb25zdGVsbGF0aW9uaWRcIikudmFsKCkrXCImdmVyc2lvbj1cIiskKFwiI3ZlcnNpb25cIikudmFsKCk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHF1ZXJ5ICs9IFwiJmVudGl0eV90eXBlPVwiKyQoXCIjZW50aXR5VHlwZVwiKS52YWwoKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHF1ZXJ5O1xuICAgICAgICAgICAgICAgICAgICAgICAgfSxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRhdGFUeXBlOiAnanNvbicsXG4gICAgICAgICAgICAgICAgICAgICAgICBkZWxheTogMjUwLFxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YTogZnVuY3Rpb24gKHBhcmFtcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHE6IHBhcmFtcy50ZXJtLFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICBwYWdlOiBwYXJhbXMucGFnZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH07XG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgcHJvY2Vzc1Jlc3VsdHM6IGZ1bmN0aW9uIChkYXRhLCBwYWdlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gTW9kaWZ5IHRoZSByZXN1bHRzIHRvIGJlIGluIHRoZSBmb3JtYXQgd2Ugd2FudFxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGxhc3RTb3VyY2VTZWFyY2hSZXN1bHRzID0gZGF0YS5yZXN1bHRzO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIC8vIG5lZWQgaWQsIHRleHRcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICB2YXIgcmVzdWx0cyA9IG5ldyBBcnJheSgpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIGRhdGEucmVzdWx0cy5mb3JFYWNoKGZ1bmN0aW9uKHJlcykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXN1bHRzLnB1c2goe2lkOiByZXMuaWQsIHRleHQ6IHJlcy5kaXNwbGF5TmFtZX0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiB7IHJlc3VsdHM6IHJlc3VsdHMgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBjYWNoZTogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB3aWR0aDogJzEwMCUnLFxuICAgICAgICAgICAgICAgICAgICBtaW5pbXVtSW5wdXRMZW5ndGg6IDAsXG4gICAgICAgICAgICAgICAgICAgIGFsbG93Q2xlYXI6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHRoZW1lOiAnYm9vdHN0cmFwJyxcbiAgICAgICAgICAgICAgICAgICAgcGxhY2Vob2xkZXI6ICdTZWxlY3QnXG4gICAgICAgICAgICAgICAgfSk7XG5cbiAgICAgICAgICAgIHNlbGVjdEl0ZW0ub24oJ2NoYW5nZScsIGZ1bmN0aW9uIChldnQpIHtcbiAgICAgICAgICAgICAgICAvLyBUT0RPOiBHZXQgdGhlIGN1cnJlbnQgc2VsZWN0ZWQgdmFsdWUgYW5kIHVwZGF0ZSB0aGUgd2VsbCBpbiB0aGUgcGFnZSB0byByZWZsZWN0IGl0IVxuICAgICAgICAgICAgICAgIC8vIE5vdGU6IGFsbCB0aGUgc2VsZWN0aW9ucyBhcmUgYXZhaWxhYmxlIGluIHRoZSBnbG9iYWwgbGFzdFNvdXJjZVNlYXJjaFJlc3VsdHMgdmFyaWFibGUuXG4gICAgICAgICAgICAgICAgdmFyIHNvdXJjZUlEID0gJCh0aGlzKS52YWwoKTtcbiAgICAgICAgICAgICAgICB2YXIgaW5QYWdlSUQgPSAkKHRoaXMpLmF0dHIoXCJpZFwiKTtcbiAgICAgICAgICAgICAgICB2YXIgaWRBcnJheSA9IGluUGFnZUlELnNwbGl0KFwiX1wiKTtcbiAgICAgICAgICAgICAgICBpZiAoaWRBcnJheS5sZW5ndGggPj0gNikge1xuICAgICAgICAgICAgICAgICAgICB2YXIgaSA9IGlkQXJyYXlbNV07XG4gICAgICAgICAgICAgICAgICAgIHZhciBqID0gaWRBcnJheVs0XTtcbiAgICAgICAgICAgICAgICAgICAgdmFyIHNob3J0TmFtZSA9IGlkQXJyYXlbMV07XG4gICAgICAgICAgICAgICAgICAgIGxhc3RTb3VyY2VTZWFyY2hSZXN1bHRzLmZvckVhY2goZnVuY3Rpb24oc291cmNlKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICBpZiAoc291cmNlLmlkID09IHNvdXJjZUlEKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgLy8gVXBkYXRlIHRoZSB0ZXh0IG9mIHRoZSBzb3VyY2VcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICBpZiAodHlwZW9mIHNvdXJjZS50ZXh0ICE9PSAndW5kZWZpbmVkJykge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV90ZXh0X1wiICsgaiArIFwiX1wiICsgaSkuaHRtbChhZGRicihzb3VyY2UudGV4dCkpLnJlbW92ZUNsYXNzKCdoaWRkZW4nKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJChcIiNzY21fXCIgKyBzaG9ydE5hbWUgKyBcIl9zb3VyY2VfdGV4dF9cIiArIGogKyBcIl9cIiArIGkpLmNsb3Nlc3QoXCIucGFuZWwtYm9keVwiKS5yZW1vdmVDbGFzcygnaGlkZGVuJyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfSBlbHNlIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJChcIiNzY21fXCIgKyBzaG9ydE5hbWUgKyBcIl9zb3VyY2VfdGV4dF9cIiArIGogKyBcIl9cIiArIGkpLnRleHQoXCJcIikuYWRkQ2xhc3MoJ2hpZGRlbicpO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV90ZXh0X1wiICsgaiArIFwiX1wiICsgaSkuY2xvc2VzdChcIi5wYW5lbC1ib2R5XCIpLmFkZENsYXNzKCdoaWRkZW4nKTtcblxuICAgICAgICAgICAgICAgICAgICAgICAgICAgIH1cbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBVcGRhdGUgdGhlIFVSSSBvZiB0aGUgc291cmNlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzb3VyY2UudXJpICE9PSAndW5kZWZpbmVkJylcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgJChcIiNzY21fXCIgKyBzaG9ydE5hbWUgKyBcIl9zb3VyY2VfdXJpX1wiICsgaiArIFwiX1wiICsgaSkuaHRtbCgnPGEgaHJlZj1cIicrc291cmNlLnVyaSsnXCIgdGFyZ2V0PVwiX2JsYW5rXCI+Jytzb3VyY2UudXJpKyc8L2E+Jyk7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgZWxzZVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAkKFwiI3NjbV9cIiArIHNob3J0TmFtZSArIFwiX3NvdXJjZV91cmlfXCIgKyBqICsgXCJfXCIgKyBpKS5odG1sKCcnKTtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAvLyBVcGRhdGUgdGhlIFVSSSBvZiB0aGUgc291cmNlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgaWYgKHR5cGVvZiBzb3VyY2UuY2l0YXRpb24gIT09ICd1bmRlZmluZWQnKVxuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIC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GVhcjogdHJ1ZSxcbiAgICAgICAgICAgIHRoZW1lOiBcImJvb3RzdHJhcFwiLFxuICAgICAgICAgICAgcGxhY2Vob2xkZXI6IFwiU2VsZWN0IEFmZmlsaWF0aW9uXCJcbiAgICAgICAgfSk7XG4gICAgfSk7XG59XG5cbmZ1bmN0aW9uIHJldmlld2VyX3NlbGVjdF9yZXBsYWNlKHNlbGVjdEl0ZW0pIHtcbiAgICAgICAgaWYoc2VsZWN0SXRlbSAhPSBudWxsKSB7XG4gICAgICAgICAgICAgICAgc2VsZWN0SXRlbS5zZWxlY3QyKHtcbiAgICAgICAgICAgICAgICAgICAgcGxhY2Vob2xkZXI6IFwiUmV2aWV3ZXIgTmFtZSBvciBFbWFpbC4uLlwiLFxuICAgICAgICAgICAgICAgICAgICBhamF4OiB7XG4gICAgICAgICAgICAgICAgICAgICAgICB1cmw6IGZ1bmN0aW9uKCkge1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgIHZhciBxdWVyeSA9IHNuYWNVcmwrXCIvdXNlcl9zZWFyY2g/cm9sZT1SZXZpZXdlclwiO1xuICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4gcXVlcnk7XG4gICAgICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICAgICAgZGF0YVR5cGU6ICdqc29uJyxcbiAgICAgICAgICAgICAgICAgICAgICAgIGRlbGF5OiAyNTAsXG4gICAgICAgICAgICAgICAgICAgICAgICBkYXRhOiBmdW5jdGlvbiAocGFyYW1zKSB7XG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgcTogcGFyYW1zLnRlcm0sXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIHBhZ2U6IHBhcmFtcy5wYWdlXG4gICAgICAgICAgICAgICAgICAgICAgICAgICAgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBwcm9jZXNzUmVzdWx0czogZnVuY3Rpb24gKGRhdGEsIHBhZ2UpIHtcbiAgICAgICAgICAgICAgICAgICAgICAgICAgICByZXR1cm4geyByZXN1bHRzOiBkYXRhLnJlc3VsdHMgfTtcbiAgICAgICAgICAgICAgICAgICAgICAgIH0sXG4gICAgICAgICAgICAgICAgICAgICAgICBjYWNoZTogdHJ1ZVxuICAgICAgICAgICAgICAgICAgICB9LFxuICAgICAgICAgICAgICAgICAgICB3aWR0aDogJzEwMCUnLFxuICAgICAgICAgICAgICAgICAgICBtaW5pbXVtSW5wdXRMZW5ndGg6IDEsXG4gICAgICAgICAgICAgICAgICAgIGFsbG93Q2xlYXI6IGZhbHNlLFxuICAgICAgICAgICAgICAgICAgICB0aGVtZTogJ2Jvb3RzdHJhcCdcbiAgICAgICAgICAgICAgICB9KTtcbiAgICAgICAgICAgIH1cbn1cblxuZnVuY3Rpb24gc2VsZWN0X3JlcGxhY2Uoc2VsZWN0SXRlbSwgaWRNYXRjaCkge1xuICAgICAgICBpZihzZWxlY3RJdGVtLmF0dHIoJ2lkJykuZW5kc1dpdGgoaWRNYXRjaClcbiAgICAgICAgICAgICYmICFzZWxlY3RJdGVtLmF0dHIoJ2lkJykuZW5kc1dpdGgoXCJaWlwiKSkge1xuICAgICAgICAgICAgICAgIHNlbGVjdEl0ZW0uc2VsZWN0Mih7XG4gICAgICAgICAgICAgICAgICAgIGFsbG93Q2xlYXI6IHRydWUsXG4gICAgICAgICAgICAgICAgICAgIHRoZW1lOiAnYm9vdHN0cmFwJ1xuICAgICAgICAgICAgICAgIH0pO1xuICAgICAgICAgICAgfVxufVxuXG5leHBvcnQgZnVuY3Rpb24gc2VsZWN0X3JlcGxhY2Vfc2ltcGxlKHNlbGVjdEl0ZW0pIHtcbiAgICBzZWxlY3RJdGVtLnNlbGVjdDIoe1xuICAgICAgICB3aWR0aDogJzEwMCUnLFxuICAgICAgICBhbGxvd0NsZWFyOiB0cnVlLFxuICAgICA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={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([,function(e,t,r){"use strict"; +/** + * Select Box Loaders + * + * Functions that can be used to replace select boxes on the edit page with + * pretty-formatted versions using JQuery and Select2 + * + * @author Robbie Hott + * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause + * @copyright 2015 the Rector and Visitors of the University of Virginia, and + * the Regents of the University of California + */ +function n(e,t,r,n){void 0===n&&(n=2),e.attr("id").endsWith(t)&&!e.attr("id").endsWith("ZZ")&&e.select2({ajax:{url:function(){var e=snacUrl+"/vocabulary?type="+r+"&id=";return e+=$("#constellationid").val()+"&version="+$("#version").val(),e+="&entity_type="+$("#entityType").val()},dataType:"json",delay:250,data:function(e){return{q:e.term,page:e.page}},processResults:function(e,t){return{results:e.results}},cache:!0},width:"100%",minimumInputLength:n,allowClear:!0,theme:"bootstrap",placeholder:"Select"})}r.r(t),r.d(t,"vocab_select_replace",(function(){return n})),r.d(t,"geoPlaceSearchResults",(function(){return a})),r.d(t,"geovocab_select_replace",(function(){return i})),r.d(t,"scm_source_select_replace",(function(){return l})),r.d(t,"select_replace_simple",(function(){return s})),r.d(t,"loadVocabSelectOptions",(function(){return c}));var a=null;function i(e,t){e.attr("id").endsWith(t)&&!e.attr("id").endsWith("ZZ")&&e.select2({ajax:{url:function(){var e=snacUrl+"/vocabulary?type=geo_place&format=term";return e+="&entity_type="+$("#entityType").val()},dataType:"json",delay:250,data:function(e){return{q:e.term,page:e.page}},processResults:function(e,t){if(e.results){a=e.results;var r=new Array;return e.results.forEach((function(e){r.push({id:e.id,text:e.name+" ("+e.administrationCode+", "+e.countryCode+")"})})),{results:r}}return{results:null}},cache:!0},width:"100%",minimumInputLength:2,allowClear:!0,theme:"bootstrap",placeholder:"Select"})}var o=null;function l(e,t){e.attr("id").endsWith(t)&&!e.attr("id").endsWith("ZZ")&&(e.select2({ajax:{url:function(){var e=snacUrl+"/vocabulary?type=ic_sources&id=";return e+=$("#constellationid").val()+"&version="+$("#version").val(),e+="&entity_type="+$("#entityType").val()},dataType:"json",delay:250,data:function(e){return{q:e.term,page:e.page}},processResults:function(e,t){o=e.results;var r=new Array;return e.results.forEach((function(e){r.push({id:e.id,text:e.displayName})})),{results:r}},cache:!0},width:"100%",minimumInputLength:0,allowClear:!0,theme:"bootstrap",placeholder:"Select"}),e.on("change",(function(e){var t=$(this).val(),r=$(this).attr("id").split("_");if(r.length>=6){var n=r[5],a=r[4],i=r[1];o.forEach((function(e){var r;e.id==t&&(void 0!==e.text?($("#scm_"+i+"_source_text_"+a+"_"+n).html((r=e.text,null!=r?(r+"").replace(/(\r\n|\n\r|\r|\n)/g,"
    $1"):"")).removeClass("hidden"),$("#scm_"+i+"_source_text_"+a+"_"+n).closest(".panel-body").removeClass("hidden")):($("#scm_"+i+"_source_text_"+a+"_"+n).text("").addClass("hidden"),$("#scm_"+i+"_source_text_"+a+"_"+n).closest(".panel-body").addClass("hidden")),void 0!==e.uri?$("#scm_"+i+"_source_uri_"+a+"_"+n).html(''+e.uri+""):$("#scm_"+i+"_source_uri_"+a+"_"+n).html(""),void 0!==e.citation?$("#scm_"+i+"_source_citation_"+a+"_"+n).html(e.citation).removeClass("hidden"):$("#scm_"+i+"_source_citation_"+a+"_"+n).html("").addClass("hidden"))}))}})))}function s(e){e.select2({width:"100%",allowClear:!0,theme:"bootstrap"})}function c(e,t,r){return $.get(snacUrl+"/vocabulary?type="+t).done((function(t){var n=t.results;e.select2({data:n,allowClear:!1,theme:"bootstrap",placeholder:r})}))}$(document).ready((function(){var e;$("select").each((function(){void 0!==$(this).attr("id")&&!1!==$(this).attr("id")&&(n($(this),"language_language_","language_code",1),n($(this),"language_script_","script_code",1),n($(this),"subject_","subject",4),n($(this),"function_","function",4),n($(this),"occupation_","occupation",4),n($(this),"entityType","entity_type",0))})),$("#affiliationid").exists()&&(e=$("#affiliationid"),$.get(snacUrl+"/vocabulary?type=affiliation").done((function(t){var r=t.results;e.select2({data:r,allowClear:!0,theme:"bootstrap",placeholder:"Select Affiliation"})}))),$("#reviewersearchbox").exists()&&function(e){null!=e&&e.select2({placeholder:"Reviewer Name or Email...",ajax:{url:function(){return snacUrl+"/user_search?role=Reviewer"},dataType:"json",delay:250,data:function(e){return{q:e.term,page:e.page}},processResults:function(e,t){return{results:e.results}},cache:!0},width:"100%",minimumInputLength:1,allowClear:!1,theme:"bootstrap"})}($("#reviewersearchbox"))}))}])); +//# sourceMappingURL=select_loaders.js.map \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/select_loaders.js.map b/src/virtualhosts/www/javascript/select_loaders.js.map new file mode 100644 index 000000000..8343a13d2 --- /dev/null +++ b/src/virtualhosts/www/javascript/select_loaders.js.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap","webpack:///./src/virtualhosts/www/javascript/src/select_loaders.js"],"names":["installedModules","__webpack_require__","moduleId","exports","module","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","vocab_select_replace","selectItem","idMatch","type","minLength","undefined","attr","endsWith","select2","ajax","url","query","snacUrl","$","val","dataType","delay","data","params","q","term","page","processResults","results","cache","width","minimumInputLength","allowClear","theme","placeholder","geoPlaceSearchResults","geovocab_select_replace","selectResults","Array","forEach","result","push","id","text","administrationCode","countryCode","lastSourceSearchResults","scm_source_select_replace","res","displayName","on","evt","sourceID","this","idArray","split","length","j","shortName","source","str","html","replace","removeClass","closest","addClass","uri","citation","select_replace_simple","loadVocabSelectOptions","done","options","document","ready","each","exists","reviewer_select_replace"],"mappings":"4DACE,IAAIA,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB,OAAOF,EAAiBE,GAAUC,QAGnC,IAAIC,EAASJ,EAAiBE,GAAY,CACzCG,EAAGH,EACHI,GAAG,EACHH,QAAS,IAUV,OANAI,EAAQL,GAAUM,KAAKJ,EAAOD,QAASC,EAAQA,EAAOD,QAASF,GAG/DG,EAAOE,GAAI,EAGJF,EAAOD,QA0Df,OArDAF,EAAoBQ,EAAIF,EAGxBN,EAAoBS,EAAIV,EAGxBC,EAAoBU,EAAI,SAASR,EAASS,EAAMC,GAC3CZ,EAAoBa,EAAEX,EAASS,IAClCG,OAAOC,eAAeb,EAASS,EAAM,CAAEK,YAAY,EAAMC,IAAKL,KAKhEZ,EAAoBkB,EAAI,SAAShB,GACX,oBAAXiB,QAA0BA,OAAOC,aAC1CN,OAAOC,eAAeb,EAASiB,OAAOC,YAAa,CAAEC,MAAO,WAE7DP,OAAOC,eAAeb,EAAS,aAAc,CAAEmB,OAAO,KAQvDrB,EAAoBsB,EAAI,SAASD,EAAOE,GAEvC,GADU,EAAPA,IAAUF,EAAQrB,EAAoBqB,IAC/B,EAAPE,EAAU,OAAOF,EACpB,GAAW,EAAPE,GAA8B,iBAAVF,GAAsBA,GAASA,EAAMG,WAAY,OAAOH,EAChF,IAAII,EAAKX,OAAOY,OAAO,MAGvB,GAFA1B,EAAoBkB,EAAEO,GACtBX,OAAOC,eAAeU,EAAI,UAAW,CAAET,YA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EACZC,MAAO,cA+EnB2C,CAAwB1D,EAAE","file":"select_loaders.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","/**\n * Select Box Loaders\n *\n * Functions that can be used to replace select boxes on the edit page with\n * pretty-formatted versions using JQuery and Select2\n *\n * @author Robbie Hott\n * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause\n * @copyright 2015 the Rector and Visitors of the University of Virginia, and\n * the Regents of the University of California\n */\n\n/**\n * Replace a select that is linked to a Vocabulary search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n * @param string type The type of the vocabulary term\n * @param int minLength The minimum required length of the autocomplete search\n */\nexport function vocab_select_replace(selectItem, idMatch, type, minLength) {\n if (minLength === undefined) {\n minLength = 2;\n }\n\n if(selectItem.attr('id').endsWith(idMatch)\n && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function() {\n var query = snacUrl + \"/vocabulary?type=\"+type+\"&id=\";\n query += $(\"#constellationid\").val()+\"&version=\"+$(\"#version\").val();\n query += \"&entity_type=\"+$(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: minLength,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n }\n}\n\nexport var geoPlaceSearchResults = null;\n\nexport function geovocab_select_replace(selectItem, idMatch) {\n var minLength = 2;\n\n if(selectItem.attr('id').endsWith(idMatch)\n && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function() {\n var query = snacUrl+\"/vocabulary?type=geo_place&format=term\";\n query += \"&entity_type=\"+$(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n if (data.results) {\n geoPlaceSearchResults = data.results;\n var selectResults = new Array();\n data.results.forEach(function(result) {\n selectResults.push({\n id: result.id,\n text: result.name + \" (\" + result.administrationCode + \", \" + result.countryCode+ \")\"\n })\n });\n return {results: selectResults};\n }\n return { results: null };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: minLength,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n }\n}\n\nvar lastSourceSearchResults = null;\n\n/**\n * Add
    helper script\n *\n * Adds
    to strings so that they can be shown to the user in HTML\n * after being input into a text-only field.\n */\nfunction addbr(str) {\n if (typeof str !== 'undefined' && str !== null) {\n return (str + '').replace(/(\\r\\n|\\n\\r|\\r|\\n)/g, '
    ' + '$1');\n }\n return '';\n}\n\n/**\n * Replace a select that is linked to a Constellation Source search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string idMatch ID string for the object on the page\n */\nexport function scm_source_select_replace(selectItem, idMatch) {\n if(selectItem.attr('id').endsWith(idMatch)\n && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n ajax: {\n url: function() {\n var query = snacUrl+\"/vocabulary?type=ic_sources&id=\";\n query += $(\"#constellationid\").val()+\"&version=\"+$(\"#version\").val();\n query += \"&entity_type=\"+$(\"#entityType\").val();\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n // Modify the results to be in the format we want\n lastSourceSearchResults = data.results;\n // need id, text\n var results = new Array();\n data.results.forEach(function(res) {\n results.push({id: res.id, text: res.displayName});\n });\n return { results: results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 0,\n allowClear: true,\n theme: 'bootstrap',\n placeholder: 'Select'\n });\n\n selectItem.on('change', function (evt) {\n // TODO: Get the current selected value and update the well in the page to reflect it!\n // Note: all the selections are available in the global lastSourceSearchResults variable.\n var sourceID = $(this).val();\n var inPageID = $(this).attr(\"id\");\n var idArray = inPageID.split(\"_\");\n if (idArray.length >= 6) {\n var i = idArray[5];\n var j = idArray[4];\n var shortName = idArray[1];\n lastSourceSearchResults.forEach(function(source) {\n if (source.id == sourceID) {\n // Update the text of the source\n if (typeof source.text !== 'undefined') {\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).html(addbr(source.text)).removeClass('hidden');\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).closest(\".panel-body\").removeClass('hidden');\n } else {\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).text(\"\").addClass('hidden');\n $(\"#scm_\" + shortName + \"_source_text_\" + j + \"_\" + i).closest(\".panel-body\").addClass('hidden');\n\n }\n // Update the URI of the source\n if (typeof source.uri !== 'undefined')\n $(\"#scm_\" + shortName + \"_source_uri_\" + j + \"_\" + i).html(''+source.uri+'');\n else\n $(\"#scm_\" + shortName + \"_source_uri_\" + j + \"_\" + i).html('');\n // Update the URI of the source\n if (typeof source.citation !== 'undefined')\n $(\"#scm_\" + shortName + \"_source_citation_\" + j + \"_\" + i).html(source.citation).removeClass('hidden');\n else\n $(\"#scm_\" + shortName + \"_source_citation_\" + j + \"_\" + i).html('').addClass('hidden');\n }\n });\n }\n });\n\n }\n}\n\n/**\n * Replace a select that is linked to an affiliation search\n *\n * Replaces the select with a select2 object capable of making AJAX queries\n *\n * @param JQuery selectItem The JQuery item to replace\n */\nfunction affiliation_select_replace(selectItem) {\n $.get(snacUrl + \"/vocabulary?type=affiliation\").done(function(data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: true,\n theme: \"bootstrap\",\n placeholder: \"Select Affiliation\"\n });\n });\n}\n\nfunction reviewer_select_replace(selectItem) {\n if(selectItem != null) {\n selectItem.select2({\n placeholder: \"Reviewer Name or Email...\",\n ajax: {\n url: function() {\n var query = snacUrl+\"/user_search?role=Reviewer\";\n return query;\n },\n dataType: 'json',\n delay: 250,\n data: function (params) {\n return {\n q: params.term,\n page: params.page\n };\n },\n processResults: function (data, page) {\n return { results: data.results };\n },\n cache: true\n },\n width: '100%',\n minimumInputLength: 1,\n allowClear: false,\n theme: 'bootstrap'\n });\n }\n}\n\nfunction select_replace(selectItem, idMatch) {\n if(selectItem.attr('id').endsWith(idMatch)\n && !selectItem.attr('id').endsWith(\"ZZ\")) {\n selectItem.select2({\n allowClear: true,\n theme: 'bootstrap'\n });\n }\n}\n\nexport function select_replace_simple(selectItem) {\n selectItem.select2({\n width: '100%',\n allowClear: true,\n theme: 'bootstrap'\n });\n}\n\n/**\n * Load Vocab Select Options\n *\n * Replaces the select with a select2 object preloaded with an array of options\n *\n * @param JQuery selectItem The JQuery item to replace\n * @param string type The type of the vocabulary term\n * @param string type Text placeholder for select\n */\nexport function loadVocabSelectOptions(selectItem, type, placeholder) {\n return $.get(snacUrl + \"/vocabulary?type=\" + type)\n .done(function(data) {\n var options = data.results;\n selectItem.select2({\n data: options,\n allowClear: false,\n theme: 'bootstrap',\n placeholder: placeholder\n });\n });\n}\n\n/**\n * Replace all the selects that exist on the page when the page has finished loading\n */\n$(document).ready(function() {\n // Use select2 to display the select dropdowns\n // rather than the HTML default\n $(\"select\").each(function() {\n if (typeof $(this).attr('id') !== typeof undefined && $(this).attr('id') !== false) {\n // Replace the subject selects\n vocab_select_replace($(this), \"language_language_\", \"language_code\", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), \"language_script_\", \"script_code\", 1);\n\n // Replace the subject selects\n vocab_select_replace($(this), \"subject_\", \"subject\", 4);\n\n // Replace the function selects\n vocab_select_replace($(this), \"function_\", \"function\", 4);\n\n // Replace the occupation selects\n vocab_select_replace($(this), \"occupation_\", \"occupation\", 4);\n\n // Replace the entityType select\n vocab_select_replace($(this), \"entityType\", \"entity_type\", 0);\n }\n });\n\n // Replace the Affiliation dropdowns, if one exists\n if ($(\"#affiliationid\").exists())\n affiliation_select_replace($(\"#affiliationid\"));\n\n // Replace the User search dropdown, if one exists\n if ($(\"#reviewersearchbox\").exists())\n reviewer_select_replace($(\"#reviewersearchbox\"));\n});\n"],"sourceRoot":""} \ No newline at end of file diff --git a/src/virtualhosts/www/javascript/src/select_loaders.js b/src/virtualhosts/www/javascript/src/select_loaders.js index b54204df3..cb8dbed48 100644 --- a/src/virtualhosts/www/javascript/src/select_loaders.js +++ b/src/virtualhosts/www/javascript/src/select_loaders.js @@ -297,7 +297,6 @@ export function loadVocabSelectOptions(selectItem, type, placeholder) { * Replace all the selects that exist on the page when the page has finished loading */ $(document).ready(function() { - // Use select2 to display the select dropdowns // rather than the HTML default $("select").each(function() { diff --git a/webpack.config.js b/webpack.config.js index ddc715bc6..725e8fe6f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,27 +1,29 @@ const path = require('path'); const js_path = path.join(__dirname, "src/virtualhosts/www/javascript") -module.exports = { - entry: { - bundle: path.join(js_path, "src", "main.js"), - resource_admin: path.join(js_path, "src", "resource_admin.js"), - edit_scripts: path.join(js_path, "src", "edit_scripts.js"), - select_loaders: path.join(js_path, "src", "select_loaders.js"), - }, - output: { - path: js_path, - filename: "[name].js", - libraryTarget: "window" - }, - devtool: "cheap-module-eval-source-map", - module: { - rules: [{ - loader: "babel-loader", - test: /\.js$/, - exclude: /node_modules/ - }] - }, - optimization: { - minimize: false - }, +module.exports = (env) => { + const isProduction = env === 'production'; + return { + mode: isProduction ? 'production' : 'development', + entry: { + bundle: path.join(js_path, "src", "main.js"), + resource_admin: path.join(js_path, "src", "resource_admin.js"), + edit_scripts: path.join(js_path, "src", "edit_scripts.js"), + select_loaders: path.join(js_path, "src", "select_loaders.js"), + }, + output: { + path: js_path, + filename: "[name].js", + libraryTarget: "window" + }, + devtool: isProduction ? 'source-map' : "cheap-module-eval-source-map", + watch: !isProduction, + module: { + rules: [{ + loader: "babel-loader", + test: /\.js$/, + exclude: /node_modules/ + }] + }, + }; };