Son CV dans un terminal web en Javascript!
https://terminal-cv.gregandev.fr
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1605 lines
67 KiB
1605 lines
67 KiB
2 years ago
|
// modules are defined as an array
|
||
|
// [ module function, map of requires ]
|
||
|
//
|
||
|
// map of requires is short require name -> numeric require
|
||
|
//
|
||
|
// anything defined in a previous bundle is accessed via the
|
||
|
// orig method which is the require for previous bundles
|
||
|
|
||
1 year ago
|
(function(modules, entry, mainEntry, parcelRequireName, globalName) {
|
||
2 years ago
|
/* eslint-disable no-undef */
|
||
|
var globalObject =
|
||
|
typeof globalThis !== 'undefined'
|
||
|
? globalThis
|
||
|
: typeof self !== 'undefined'
|
||
|
? self
|
||
|
: typeof window !== 'undefined'
|
||
|
? window
|
||
|
: typeof global !== 'undefined'
|
||
|
? global
|
||
|
: {};
|
||
|
/* eslint-enable no-undef */
|
||
|
|
||
|
// Save the require from previous bundle to this closure if any
|
||
|
var previousRequire =
|
||
|
typeof globalObject[parcelRequireName] === 'function' &&
|
||
|
globalObject[parcelRequireName];
|
||
|
|
||
|
var cache = previousRequire.cache || {};
|
||
|
// Do not use `require` to prevent Webpack from trying to bundle this call
|
||
|
var nodeRequire =
|
||
|
typeof module !== 'undefined' &&
|
||
|
typeof module.require === 'function' &&
|
||
|
module.require.bind(module);
|
||
|
|
||
|
function newRequire(name, jumped) {
|
||
|
if (!cache[name]) {
|
||
|
if (!modules[name]) {
|
||
|
// if we cannot find the module within our internal map or
|
||
|
// cache jump to the current global require ie. the last bundle
|
||
|
// that was added to the page.
|
||
|
var currentRequire =
|
||
|
typeof globalObject[parcelRequireName] === 'function' &&
|
||
|
globalObject[parcelRequireName];
|
||
|
if (!jumped && currentRequire) {
|
||
|
return currentRequire(name, true);
|
||
|
}
|
||
|
|
||
|
// If there are other bundles on this page the require from the
|
||
|
// previous one is saved to 'previousRequire'. Repeat this as
|
||
|
// many times as there are bundles until the module is found or
|
||
|
// we exhaust the require chain.
|
||
|
if (previousRequire) {
|
||
|
return previousRequire(name, true);
|
||
|
}
|
||
|
|
||
|
// Try the node require function if it exists.
|
||
|
if (nodeRequire && typeof name === 'string') {
|
||
|
return nodeRequire(name);
|
||
|
}
|
||
|
|
||
|
var err = new Error("Cannot find module '" + name + "'");
|
||
|
err.code = 'MODULE_NOT_FOUND';
|
||
|
throw err;
|
||
|
}
|
||
|
|
||
|
localRequire.resolve = resolve;
|
||
|
localRequire.cache = {};
|
||
|
|
||
|
var module = (cache[name] = new newRequire.Module(name));
|
||
|
|
||
|
modules[name][0].call(
|
||
|
module.exports,
|
||
|
localRequire,
|
||
|
module,
|
||
|
module.exports,
|
||
|
this
|
||
|
);
|
||
|
}
|
||
|
|
||
|
return cache[name].exports;
|
||
|
|
||
|
function localRequire(x) {
|
||
1 year ago
|
return newRequire(localRequire.resolve(x));
|
||
2 years ago
|
}
|
||
|
|
||
|
function resolve(x) {
|
||
1 year ago
|
return modules[name][1][x] || x;
|
||
2 years ago
|
}
|
||
|
}
|
||
|
|
||
|
function Module(moduleName) {
|
||
|
this.id = moduleName;
|
||
|
this.bundle = newRequire;
|
||
|
this.exports = {};
|
||
|
}
|
||
|
|
||
|
newRequire.isParcelRequire = true;
|
||
|
newRequire.Module = Module;
|
||
|
newRequire.modules = modules;
|
||
|
newRequire.cache = cache;
|
||
|
newRequire.parent = previousRequire;
|
||
1 year ago
|
newRequire.register = function(id, exports) {
|
||
2 years ago
|
modules[id] = [
|
||
1 year ago
|
function(require, module) {
|
||
2 years ago
|
module.exports = exports;
|
||
|
},
|
||
|
{},
|
||
|
];
|
||
|
};
|
||
|
|
||
|
Object.defineProperty(newRequire, 'root', {
|
||
1 year ago
|
get: function() {
|
||
2 years ago
|
return globalObject[parcelRequireName];
|
||
|
},
|
||
|
});
|
||
|
|
||
|
globalObject[parcelRequireName] = newRequire;
|
||
|
|
||
|
for (var i = 0; i < entry.length; i++) {
|
||
|
newRequire(entry[i]);
|
||
|
}
|
||
|
|
||
|
if (mainEntry) {
|
||
|
// Expose entry point to Node, AMD or browser globals
|
||
|
// Based on https://github.com/ForbesLindesay/umd/blob/master/template.js
|
||
|
var mainExports = newRequire(mainEntry);
|
||
|
|
||
|
// CommonJS
|
||
|
if (typeof exports === 'object' && typeof module !== 'undefined') {
|
||
|
module.exports = mainExports;
|
||
|
|
||
|
// RequireJS
|
||
|
} else if (typeof define === 'function' && define.amd) {
|
||
1 year ago
|
define(function() {
|
||
2 years ago
|
return mainExports;
|
||
|
});
|
||
|
|
||
|
// <script>
|
||
|
} else if (globalName) {
|
||
|
this[globalName] = mainExports;
|
||
|
}
|
||
|
}
|
||
1 year ago
|
})({"1Mq12":[function(require,module,exports) {
|
||
2 years ago
|
var HMR_HOST = null;
|
||
|
var HMR_PORT = null;
|
||
|
var HMR_SECURE = false;
|
||
1 year ago
|
var HMR_ENV_HASH = "4a236f9275d0a351";
|
||
|
module.bundle.HMR_BUNDLE_ID = "b5b6c481d56a3cb1";
|
||
|
"use strict";
|
||
2 years ago
|
function _createForOfIteratorHelper(o, allowArrayLike) {
|
||
1 year ago
|
var it;
|
||
|
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
|
||
2 years ago
|
if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
|
||
|
if (it) o = it;
|
||
|
var i = 0;
|
||
|
var F = function F() {
|
||
|
};
|
||
|
return {
|
||
|
s: F,
|
||
|
n: function n() {
|
||
|
if (i >= o.length) return {
|
||
|
done: true
|
||
|
};
|
||
|
return {
|
||
|
done: false,
|
||
|
value: o[i++]
|
||
|
};
|
||
|
},
|
||
|
e: function e(_e) {
|
||
|
throw _e;
|
||
|
},
|
||
|
f: F
|
||
|
};
|
||
|
}
|
||
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
||
|
}
|
||
|
var normalCompletion = true, didErr = false, err;
|
||
|
return {
|
||
|
s: function s() {
|
||
1 year ago
|
it = o[Symbol.iterator]();
|
||
2 years ago
|
},
|
||
|
n: function n() {
|
||
|
var step = it.next();
|
||
|
normalCompletion = step.done;
|
||
|
return step;
|
||
|
},
|
||
|
e: function e(_e2) {
|
||
|
didErr = true;
|
||
|
err = _e2;
|
||
|
},
|
||
|
f: function f() {
|
||
|
try {
|
||
|
if (!normalCompletion && it.return != null) it.return();
|
||
|
} finally{
|
||
|
if (didErr) throw err;
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
function _unsupportedIterableToArray(o, minLen) {
|
||
|
if (!o) return;
|
||
|
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
||
|
var n = Object.prototype.toString.call(o).slice(8, -1);
|
||
|
if (n === "Object" && o.constructor) n = o.constructor.name;
|
||
|
if (n === "Map" || n === "Set") return Array.from(o);
|
||
|
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
||
|
}
|
||
|
function _arrayLikeToArray(arr, len) {
|
||
|
if (len == null || len > arr.length) len = arr.length;
|
||
|
for(var i = 0, arr2 = new Array(len); i < len; i++)arr2[i] = arr[i];
|
||
|
return arr2;
|
||
|
}
|
||
|
/* global HMR_HOST, HMR_PORT, HMR_ENV_HASH, HMR_SECURE */ /*::
|
||
|
import type {
|
||
|
HMRAsset,
|
||
|
HMRMessage,
|
||
|
} from '@parcel/reporter-dev-server/src/HMRServer.js';
|
||
|
interface ParcelRequire {
|
||
|
(string): mixed;
|
||
|
cache: {|[string]: ParcelModule|};
|
||
|
hotData: mixed;
|
||
|
Module: any;
|
||
|
parent: ?ParcelRequire;
|
||
|
isParcelRequire: true;
|
||
|
modules: {|[string]: [Function, {|[string]: string|}]|};
|
||
|
HMR_BUNDLE_ID: string;
|
||
|
root: ParcelRequire;
|
||
|
}
|
||
|
interface ParcelModule {
|
||
|
hot: {|
|
||
|
data: mixed,
|
||
|
accept(cb: (Function) => void): void,
|
||
|
dispose(cb: (mixed) => void): void,
|
||
|
// accept(deps: Array<string> | string, cb: (Function) => void): void,
|
||
|
// decline(): void,
|
||
|
_acceptCallbacks: Array<(Function) => void>,
|
||
|
_disposeCallbacks: Array<(mixed) => void>,
|
||
|
|};
|
||
|
}
|
||
|
declare var module: {bundle: ParcelRequire, ...};
|
||
|
declare var HMR_HOST: string;
|
||
|
declare var HMR_PORT: string;
|
||
|
declare var HMR_ENV_HASH: string;
|
||
|
declare var HMR_SECURE: boolean;
|
||
|
*/ var OVERLAY_ID = '__parcel__error__overlay__';
|
||
|
var OldModule = module.bundle.Module;
|
||
|
function Module(moduleName) {
|
||
|
OldModule.call(this, moduleName);
|
||
|
this.hot = {
|
||
|
data: module.bundle.hotData,
|
||
|
_acceptCallbacks: [],
|
||
|
_disposeCallbacks: [],
|
||
|
accept: function accept(fn) {
|
||
|
this._acceptCallbacks.push(fn || function() {
|
||
|
});
|
||
|
},
|
||
|
dispose: function dispose(fn) {
|
||
|
this._disposeCallbacks.push(fn);
|
||
|
}
|
||
|
};
|
||
|
module.bundle.hotData = undefined;
|
||
|
}
|
||
|
module.bundle.Module = Module;
|
||
|
var checkedAssets, acceptedAssets, assetsToAccept;
|
||
|
function getHostname() {
|
||
|
return HMR_HOST || (location.protocol.indexOf('http') === 0 ? location.hostname : 'localhost');
|
||
|
}
|
||
|
function getPort() {
|
||
|
return HMR_PORT || location.port;
|
||
|
} // eslint-disable-next-line no-redeclare
|
||
|
var parent = module.bundle.parent;
|
||
|
if ((!parent || !parent.isParcelRequire) && typeof WebSocket !== 'undefined') {
|
||
|
var hostname = getHostname();
|
||
|
var port = getPort();
|
||
|
var protocol = HMR_SECURE || location.protocol == 'https:' && !/localhost|127.0.0.1|0.0.0.0/.test(hostname) ? 'wss' : 'ws';
|
||
|
var ws = new WebSocket(protocol + '://' + hostname + (port ? ':' + port : '') + '/'); // $FlowFixMe
|
||
|
ws.onmessage = function(event) {
|
||
|
checkedAssets = {
|
||
|
};
|
||
|
acceptedAssets = {
|
||
|
};
|
||
|
assetsToAccept = [];
|
||
|
var data = JSON.parse(event.data);
|
||
|
if (data.type === 'update') {
|
||
|
// Remove error overlay if there is one
|
||
|
if (typeof document !== 'undefined') removeErrorOverlay();
|
||
|
var assets = data.assets.filter(function(asset) {
|
||
|
return asset.envHash === HMR_ENV_HASH;
|
||
|
}); // Handle HMR Update
|
||
|
var handled = assets.every(function(asset) {
|
||
|
return asset.type === 'css' || asset.type === 'js' && hmrAcceptCheck(module.bundle.root, asset.id, asset.depsByBundle);
|
||
|
});
|
||
|
if (handled) {
|
||
|
console.clear();
|
||
|
assets.forEach(function(asset) {
|
||
|
hmrApply(module.bundle.root, asset);
|
||
|
});
|
||
|
for(var i = 0; i < assetsToAccept.length; i++){
|
||
|
var id = assetsToAccept[i][1];
|
||
|
if (!acceptedAssets[id]) hmrAcceptRun(assetsToAccept[i][0], id);
|
||
|
}
|
||
|
} else window.location.reload();
|
||
|
}
|
||
|
if (data.type === 'error') {
|
||
|
// Log parcel errors to console
|
||
|
var _iterator = _createForOfIteratorHelper(data.diagnostics.ansi), _step;
|
||
|
try {
|
||
|
for(_iterator.s(); !(_step = _iterator.n()).done;){
|
||
|
var ansiDiagnostic = _step.value;
|
||
|
var stack = ansiDiagnostic.codeframe ? ansiDiagnostic.codeframe : ansiDiagnostic.stack;
|
||
|
console.error('🚨 [parcel]: ' + ansiDiagnostic.message + '\n' + stack + '\n\n' + ansiDiagnostic.hints.join('\n'));
|
||
|
}
|
||
|
} catch (err) {
|
||
|
_iterator.e(err);
|
||
|
} finally{
|
||
|
_iterator.f();
|
||
|
}
|
||
|
if (typeof document !== 'undefined') {
|
||
|
// Render the fancy html overlay
|
||
|
removeErrorOverlay();
|
||
|
var overlay = createErrorOverlay(data.diagnostics.html); // $FlowFixMe
|
||
|
document.body.appendChild(overlay);
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
ws.onerror = function(e) {
|
||
|
console.error(e.message);
|
||
|
};
|
||
|
ws.onclose = function() {
|
||
|
console.warn('[parcel] 🚨 Connection to the HMR server was lost');
|
||
|
};
|
||
|
}
|
||
|
function removeErrorOverlay() {
|
||
|
var overlay = document.getElementById(OVERLAY_ID);
|
||
|
if (overlay) {
|
||
|
overlay.remove();
|
||
|
console.log('[parcel] ✨ Error resolved');
|
||
|
}
|
||
|
}
|
||
|
function createErrorOverlay(diagnostics) {
|
||
|
var overlay = document.createElement('div');
|
||
|
overlay.id = OVERLAY_ID;
|
||
|
var errorHTML = '<div style="background: black; opacity: 0.85; font-size: 16px; color: white; position: fixed; height: 100%; width: 100%; top: 0px; left: 0px; padding: 30px; font-family: Menlo, Consolas, monospace; z-index: 9999;">';
|
||
|
var _iterator2 = _createForOfIteratorHelper(diagnostics), _step2;
|
||
|
try {
|
||
|
for(_iterator2.s(); !(_step2 = _iterator2.n()).done;){
|
||
|
var diagnostic = _step2.value;
|
||
|
var stack = diagnostic.codeframe ? diagnostic.codeframe : diagnostic.stack;
|
||
|
errorHTML += "\n <div>\n <div style=\"font-size: 18px; font-weight: bold; margin-top: 20px;\">\n \uD83D\uDEA8 ".concat(diagnostic.message, "\n </div>\n <pre>").concat(stack, "</pre>\n <div>\n ").concat(diagnostic.hints.map(function(hint) {
|
||
|
return '<div>💡 ' + hint + '</div>';
|
||
|
}).join(''), "\n </div>\n ").concat(diagnostic.documentation ? "<div>\uD83D\uDCDD <a style=\"color: violet\" href=\"".concat(diagnostic.documentation, "\" target=\"_blank\">Learn more</a></div>") : '', "\n </div>\n ");
|
||
|
}
|
||
|
} catch (err) {
|
||
|
_iterator2.e(err);
|
||
|
} finally{
|
||
|
_iterator2.f();
|
||
|
}
|
||
|
errorHTML += '</div>';
|
||
|
overlay.innerHTML = errorHTML;
|
||
|
return overlay;
|
||
|
}
|
||
|
function getParents(bundle, id) /*: Array<[ParcelRequire, string]> */ {
|
||
|
var modules = bundle.modules;
|
||
|
if (!modules) return [];
|
||
|
var parents = [];
|
||
|
var k, d, dep;
|
||
|
for(k in modules)for(d in modules[k][1]){
|
||
|
dep = modules[k][1][d];
|
||
|
if (dep === id || Array.isArray(dep) && dep[dep.length - 1] === id) parents.push([
|
||
|
bundle,
|
||
|
k
|
||
|
]);
|
||
|
}
|
||
|
if (bundle.parent) parents = parents.concat(getParents(bundle.parent, id));
|
||
|
return parents;
|
||
|
}
|
||
|
function updateLink(link) {
|
||
|
var newLink = link.cloneNode();
|
||
|
newLink.onload = function() {
|
||
|
if (link.parentNode !== null) // $FlowFixMe
|
||
|
link.parentNode.removeChild(link);
|
||
|
};
|
||
|
newLink.setAttribute('href', link.getAttribute('href').split('?')[0] + '?' + Date.now()); // $FlowFixMe
|
||
|
link.parentNode.insertBefore(newLink, link.nextSibling);
|
||
|
}
|
||
|
var cssTimeout = null;
|
||
|
function reloadCSS() {
|
||
|
if (cssTimeout) return;
|
||
|
cssTimeout = setTimeout(function() {
|
||
|
var links = document.querySelectorAll('link[rel="stylesheet"]');
|
||
|
for(var i = 0; i < links.length; i++){
|
||
|
// $FlowFixMe[incompatible-type]
|
||
|
var href = links[i].getAttribute('href');
|
||
|
var hostname = getHostname();
|
||
|
var servedFromHMRServer = hostname === 'localhost' ? new RegExp('^(https?:\\/\\/(0.0.0.0|127.0.0.1)|localhost):' + getPort()).test(href) : href.indexOf(hostname + ':' + getPort());
|
||
|
var absolute = /^https?:\/\//i.test(href) && href.indexOf(window.location.origin) !== 0 && !servedFromHMRServer;
|
||
|
if (!absolute) updateLink(links[i]);
|
||
|
}
|
||
|
cssTimeout = null;
|
||
|
}, 50);
|
||
|
}
|
||
|
function hmrApply(bundle, asset) {
|
||
|
var modules = bundle.modules;
|
||
|
if (!modules) return;
|
||
|
if (asset.type === 'css') reloadCSS();
|
||
|
else if (asset.type === 'js') {
|
||
|
var deps = asset.depsByBundle[bundle.HMR_BUNDLE_ID];
|
||
|
if (deps) {
|
||
|
var fn = new Function('require', 'module', 'exports', asset.output);
|
||
|
modules[asset.id] = [
|
||
|
fn,
|
||
|
deps
|
||
|
];
|
||
|
} else if (bundle.parent) hmrApply(bundle.parent, asset);
|
||
|
}
|
||
|
}
|
||
|
function hmrAcceptCheck(bundle, id, depsByBundle) {
|
||
|
var modules = bundle.modules;
|
||
|
if (!modules) return;
|
||
|
if (depsByBundle && !depsByBundle[bundle.HMR_BUNDLE_ID]) {
|
||
|
// If we reached the root bundle without finding where the asset should go,
|
||
|
// there's nothing to do. Mark as "accepted" so we don't reload the page.
|
||
|
if (!bundle.parent) return true;
|
||
|
return hmrAcceptCheck(bundle.parent, id, depsByBundle);
|
||
|
}
|
||
|
if (checkedAssets[id]) return true;
|
||
|
checkedAssets[id] = true;
|
||
|
var cached = bundle.cache[id];
|
||
|
assetsToAccept.push([
|
||
|
bundle,
|
||
|
id
|
||
|
]);
|
||
1 year ago
|
if (cached && cached.hot && cached.hot._acceptCallbacks.length) return true;
|
||
|
var parents = getParents(module.bundle.root, id); // If no parents, the asset is new. Prevent reloading the page.
|
||
|
if (!parents.length) return true;
|
||
|
return parents.some(function(v) {
|
||
|
return hmrAcceptCheck(v[0], v[1], null);
|
||
|
});
|
||
2 years ago
|
}
|
||
|
function hmrAcceptRun(bundle, id) {
|
||
|
var cached = bundle.cache[id];
|
||
|
bundle.hotData = {
|
||
|
};
|
||
|
if (cached && cached.hot) cached.hot.data = bundle.hotData;
|
||
|
if (cached && cached.hot && cached.hot._disposeCallbacks.length) cached.hot._disposeCallbacks.forEach(function(cb) {
|
||
|
cb(bundle.hotData);
|
||
|
});
|
||
|
delete bundle.cache[id];
|
||
|
bundle(id);
|
||
|
cached = bundle.cache[id];
|
||
|
if (cached && cached.hot && cached.hot._acceptCallbacks.length) cached.hot._acceptCallbacks.forEach(function(cb) {
|
||
|
var assetsToAlsoAccept = cb(function() {
|
||
|
return getParents(module.bundle.root, id);
|
||
|
});
|
||
|
if (assetsToAlsoAccept && assetsToAccept.length) // $FlowFixMe[method-unbinding]
|
||
|
assetsToAccept.push.apply(assetsToAccept, assetsToAlsoAccept);
|
||
|
});
|
||
|
acceptedAssets[id] = true;
|
||
|
}
|
||
|
|
||
1 year ago
|
},{}],"5HwUs":[function(require,module,exports) {
|
||
2 years ago
|
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
|
||
|
/**
|
||
|
* @typedef Command
|
||
|
* @property {string} command
|
||
|
* @property {string} responseType
|
||
|
* @property {string?} value
|
||
|
* @property {string[]?} headers
|
||
|
* @property {string[]?} rows
|
||
|
*/ /**
|
||
|
* @type {Command[]} commands
|
||
|
*/ var _commandsJson = require("./resources/commands.json");
|
||
|
var _commandsJsonDefault = parcelHelpers.interopDefault(_commandsJson);
|
||
|
var _customComands = require("./custom-comands");
|
||
|
var _draggable = require("./draggable");
|
||
1 year ago
|
// Table containing the orders (useful for the completion of the orders)
|
||
2 years ago
|
let commandsList = [];
|
||
|
_commandsJsonDefault.default.forEach((c)=>{
|
||
|
commandsList.push(c.command);
|
||
|
});
|
||
1 year ago
|
// Commands that require JS processing
|
||
2 years ago
|
const customCommands = [
|
||
|
"clear",
|
||
|
"dark",
|
||
|
"light",
|
||
|
"get cv"
|
||
|
];
|
||
|
commandsList = commandsList.concat(customCommands);
|
||
1 year ago
|
// Eyster eggs' commands not available for autocompletion
|
||
2 years ago
|
const hiddenCommands = [
|
||
|
"pif",
|
||
|
"rm -rf /"
|
||
|
];
|
||
1 year ago
|
// Added the ability to move the window for PCs
|
||
2 years ago
|
if (window.innerWidth > 1024) _draggable.dragElement(document.querySelector(".terminal"));
|
||
1 year ago
|
// Order history table
|
||
2 years ago
|
const commandsHistory = [];
|
||
|
let historyMode = false;
|
||
|
let historyIndex = -1;
|
||
|
const terminalBody = document.querySelector(".terminal__body");
|
||
1 year ago
|
// Adding the default line
|
||
2 years ago
|
addNewLine();
|
||
1 year ago
|
// December Easter egg, adding snowflakes
|
||
2 years ago
|
const now = new Date();
|
||
|
if (now.getMonth() === 11) {
|
||
|
let htmlFlakes = "";
|
||
|
for(let i = 0; i < 6; i++)htmlFlakes += `<div class="snowflake">❅</div><div class="snowflake">❆</div>`;
|
||
|
const html = `<div class="snowflakes" aria-hidden="true">${htmlFlakes}</div>`;
|
||
|
document.body.append(stringToDom(html));
|
||
|
}
|
||
1 year ago
|
// Set to dark mode if the browser theme is dark
|
||
|
if (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) _customComands.setDarkMode(true);
|
||
2 years ago
|
/**
|
||
1 year ago
|
* Returns the HTML of the response for a given command
|
||
2 years ago
|
* @param {string} command
|
||
|
*/ function getDomForCommand(command) {
|
||
|
const commandObj = _commandsJsonDefault.default.find((el)=>el.command === command
|
||
|
);
|
||
|
let html = "";
|
||
1 year ago
|
if (commandObj === undefined) html = `'${command.split(" ")[0]}' is not recognized as an internal command or external command, operable program or batch file. Type the <code>help</code> command to display a list of available commands.`;
|
||
2 years ago
|
else {
|
||
|
if (commandObj.responseType === "list" && Array.isArray(commandObj.value)) {
|
||
|
html = "<ul>";
|
||
|
html += commandObj.value.map((s)=>`<li>${s}</li>`
|
||
|
).join("");
|
||
|
html += "</ul>";
|
||
|
} else if (commandObj.responseType === "text") html = commandObj.value;
|
||
|
else if (commandObj.responseType === "table") {
|
||
|
const headers = commandObj.headers;
|
||
|
const rows = commandObj.rows;
|
||
|
const thsHtml = headers.map((h)=>`<th>${h}</th>`
|
||
|
).join("");
|
||
|
const tdsHtml = rows.map((r)=>`<tr>${r.map((rtd)=>`<td>${rtd}</td>`
|
||
|
).join("")}</tr>`
|
||
|
).join("");
|
||
|
html = `<table><thead><tr>${thsHtml}</tr></thead><tbody>${tdsHtml}</tbody></table>`;
|
||
|
} else if (commandObj.responseType === "code") html = `<pre>${commandObj.value.join("\n")}</pre>`;
|
||
|
}
|
||
|
return html;
|
||
|
}
|
||
|
/**
|
||
1 year ago
|
* Adds a new command input line and disables the previous one.
|
||
2 years ago
|
* @param {string|null} previousUid uid de la ligne précédente.
|
||
|
*/ function addNewLine(previousUid = null) {
|
||
|
const uid = Math.random().toString(36).replace("0.", "");
|
||
|
// terminal__line
|
||
|
const terminalLineEl = document.createElement("div");
|
||
|
terminalLineEl.classList.add("terminal__line");
|
||
|
// terminal__response
|
||
|
const terminalResponseEl = document.createElement("div");
|
||
|
terminalResponseEl.classList.add("terminal__response");
|
||
|
terminalResponseEl.id = `response-${uid}`;
|
||
|
// input text
|
||
|
const inputEl = document.createElement("input");
|
||
|
inputEl.type = "text";
|
||
|
inputEl.id = `input-${uid}`;
|
||
|
inputEl.autocapitalize = "off";
|
||
|
inputEl.dataset.uid = uid;
|
||
1 year ago
|
inputEl.dataset.active = "1"; // Needed for focus
|
||
2 years ago
|
inputEl.addEventListener("keydown", onCommandInput);
|
||
|
terminalLineEl.appendChild(inputEl);
|
||
|
if (previousUid) {
|
||
|
const previousInputEl = document.getElementById(previousUid);
|
||
|
if (previousInputEl) {
|
||
|
previousInputEl.setAttribute("disabled", "true");
|
||
|
previousInputEl.removeEventListener("keydown", onCommandInput);
|
||
|
delete previousInputEl.dataset.active;
|
||
|
}
|
||
|
}
|
||
|
document.getElementById("terminal").appendChild(terminalLineEl);
|
||
|
document.getElementById("terminal").appendChild(terminalResponseEl);
|
||
1 year ago
|
inputEl.focus(); // Adds the focus as soon as the field is created
|
||
2 years ago
|
}
|
||
|
/**
|
||
1 year ago
|
* Manages the keydown on the command input.
|
||
2 years ago
|
* @param e
|
||
|
*/ function onCommandInput(e) {
|
||
|
const commandValue = e.target.value.trim().toLowerCase();
|
||
|
if (e.keyCode === 13) // ENTER
|
||
|
{
|
||
|
if (commandValue !== "") {
|
||
|
historyMode = false;
|
||
|
const idResponse = `response-${e.target.dataset.uid}`;
|
||
|
const responseEl = document.getElementById(idResponse);
|
||
|
let html;
|
||
|
if (hiddenCommands.includes(commandValue) || customCommands.includes(commandValue)) html = handleCustomCommands(commandValue);
|
||
|
else html = getDomForCommand(commandValue);
|
||
|
if (responseEl) {
|
||
|
responseEl.innerHTML = html;
|
||
|
commandsHistory.push(commandValue);
|
||
|
addNewLine(e.target.id);
|
||
|
}
|
||
|
}
|
||
|
} else if (e.keyCode === 9) {
|
||
|
// TAB
|
||
|
e.preventDefault();
|
||
|
if (commandValue === "") this.value = "help";
|
||
|
else {
|
||
|
const matchingCommand = commandsList.find((c)=>c.startsWith(commandValue)
|
||
|
);
|
||
|
if (matchingCommand) this.value = matchingCommand;
|
||
|
}
|
||
|
historyMode = false;
|
||
|
} else if (e.keyCode === 38 || e.keyCode === 40) {
|
||
|
// UP / DOWN
|
||
1 year ago
|
// History management
|
||
2 years ago
|
if (commandsHistory.length > 0) {
|
||
|
if (historyMode === false) historyIndex = commandsHistory.length - 1;
|
||
|
else {
|
||
|
if (e.keyCode === 38 && historyIndex !== 0) // UP
|
||
|
historyIndex--;
|
||
|
else if (e.keyCode === 40 && historyIndex !== commandsHistory.length - 1) historyIndex++;
|
||
|
}
|
||
|
this.value = commandsHistory[historyIndex];
|
||
|
}
|
||
|
historyMode = true;
|
||
|
}
|
||
|
}
|
||
|
/**
|
||
1 year ago
|
* Allows to manage hidden commands (not proposed in the autocompletion)
|
||
2 years ago
|
* @param {string} command
|
||
1 year ago
|
* @returns {string|void} Html to be displayed in the response of the command
|
||
2 years ago
|
*/ function handleCustomCommands(command) {
|
||
|
switch(command){
|
||
|
case "pif":
|
||
|
_customComands.pif();
|
||
1 year ago
|
return "Let's go !";
|
||
2 years ago
|
case "light":
|
||
1 year ago
|
if (!document.body.classList.contains("dark-mode")) return "You are already in light mode.";
|
||
2 years ago
|
_customComands.setDarkMode(false);
|
||
1 year ago
|
return "Your are now in light mode.";
|
||
2 years ago
|
case "dark":
|
||
1 year ago
|
if (document.body.classList.contains("dark-mode")) return "You are already in dark mode.";
|
||
2 years ago
|
_customComands.setDarkMode(true);
|
||
1 year ago
|
return "You are now in dark mode.";
|
||
2 years ago
|
case "get cv":
|
||
|
_customComands.getCV();
|
||
1 year ago
|
return "The CV will be downloaded.";
|
||
2 years ago
|
case "rm -rf /":
|
||
|
_customComands.rmRf();
|
||
1 year ago
|
return "🎆";
|
||
2 years ago
|
case "clear":
|
||
|
terminalBody.innerHTML = `<div id="terminal"></div>`;
|
||
|
return;
|
||
|
}
|
||
|
}
|
||
|
/**
|
||
|
* Convert HTML to DOM object
|
||
|
* @param html
|
||
|
* @returns {DocumentFragment}
|
||
|
*/ function stringToDom(html) {
|
||
|
return document.createRange().createContextualFragment(html);
|
||
|
}
|
||
|
// ------------------------------------------------------------------------------------
|
||
|
// EVENT LISTENNER
|
||
|
// ------------------------------------------------------------------------------------
|
||
1 year ago
|
// Added focus on the input even if you click on the body (to keep the cursor)
|
||
2 years ago
|
document.body.addEventListener("click", function(e) {
|
||
|
if (e.target.tagName !== "INPUT") {
|
||
|
const activeInput = document.querySelector("input[data-active]");
|
||
|
activeInput.focus();
|
||
|
}
|
||
|
});
|
||
|
document.querySelector(".fake-close").addEventListener("click", function(e) {
|
||
|
const terminalEl = document.querySelector(".terminal");
|
||
|
terminalEl.parentElement.removeChild(terminalEl);
|
||
|
});
|
||
|
|
||
1 year ago
|
},{"./resources/commands.json":"2o5yf","./custom-comands":"lczTY","./draggable":"krRPl","@parcel/transformer-js/src/esmodule-helpers.js":"ciiiV"}],"2o5yf":[function(require,module,exports) {
|
||
2 years ago
|
module.exports = JSON.parse("[{\"command\":\"help\",\"responseType\":\"list\",\"value\":[\"<code>a-propos</code> : Affiche les informations me concernant\",\"<code>clear</code> : Nettoie le terminal\",\"<code>experiences</code> : Affiche la liste de mes expériences\",\"<code>get cv</code> : Télécharge le CV\",\"<code>help</code> : Affiche l'aide\",\"<code>hobby</code> : Affiche la liste de mes passes temps\",\"<code>projets-perso</code> : Affiche la liste de mes projets personnels\",\"<code>dark/light</code> : Change le thème de la page\",\"<em>Vous pouvez utiliser la touche TAB afin de compléter une commande</em>\",\"<em>Vous pouvez retrouver les anciennes commandes avec les flèches haut et bas.</em>\"]},{\"command\":\"a-propos\",\"responseType\":\"code\",\"value\":[\"{\",\" \\\"nom\\\" : \\\"Gregory Lebreton\\\",\",\" \\\"poste\\\" : \\\"Formateur Devops\\\",\",\" \\\"experience\\\" : \\\"6\\\",\",\" \\\"ville\\\" : \\\"Paris, France\\\"\",\"}\"]},{\"command\":\"experiences\",\"responseType\":\"table\",\"headers\":[\"Date\",\"Client\",\"Description\",\"Tech\"],\"rows\":[[\"maintenant<br/>03/2021\",\"<br/><em>Le garage numérique</em>\",\"Formateur Devops pour le CNAM,<br/>administrateur système et intégrateur pour le Garage\",\"Docker<br/>Python<br/>Bash\"],[\"09/2019<br/>06/2019\",\"<br/><em>Safran, S.A.E</em>\",\"Mise en place d'une plateforme mettant en relation les<br/>différents acteurs de la DSI sur une plateforme logicielle.\",\"Docker<br/>Kubernetes<br/>Jenkins\"],[\"03/2019<br/>12/2017\",\"PHP dev<br/><em>Leading Frog</em>\",\"Module PHP permettant l'envoie de cartes postales<br/>numériques avec implémentation API Stripe.\",\"PHP<br/>JavaScript<br/>SQL\"]]},{\"command\":\"hobby\",\"responseType\":\"list\",\"value\":[\"Musique: Skateboard, Unity, VR\",\"Programmation: Python, bash, PHP, C#\",\"Autre: Famille, Cinéma, Environnement\"]},{\"command\":\"projets-perso\",\"responseType\":\"table\",\"headers\":[\"Nom\",\"Description\",\"Tech\",\"Liens\"],\"rows\":[[\"Personal website<br/>(2021)\",\"Site web personnel me permettant de montrer mes projets et tester des applicatifs<br/>\",\"PHP/JS\",\"<a href=\\\"https://www.gregandev.fr\\\" target=\\\"blank\\\">Lien</a>\"],[\"GoldeneyeVR<br/>(2020)\",\"Implémentation VR au célèbre jeux de 1997.\",\"C# WPF\",\"<a href=\\\"https://www.gregandev.fr/page/goldeneyevr\\\" target=\\\"blank\\\">Lien</a>\"]]}]");
|
||
|
|
||
1 year ago
|
},{}],"lczTY":[function(require,module,exports) {
|
||
2 years ago
|
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
|
||
|
parcelHelpers.defineInteropFlag(exports);
|
||
|
/**
|
||
|
* Affiche des confettis sur la page
|
||
|
*/ parcelHelpers.export(exports, "pif", ()=>pif
|
||
|
);
|
||
|
parcelHelpers.export(exports, "setDarkMode", ()=>setDarkMode
|
||
|
);
|
||
|
parcelHelpers.export(exports, "getCV", ()=>getCV
|
||
|
);
|
||
|
parcelHelpers.export(exports, "rmRf", ()=>rmRf
|
||
|
);
|
||
|
var _canvasConfetti = require("canvas-confetti");
|
||
|
var _canvasConfettiDefault = parcelHelpers.interopDefault(_canvasConfetti);
|
||
|
var _fireworksJs = require("fireworks-js");
|
||
|
function pif() {
|
||
|
const count = 200;
|
||
|
const defaults = {
|
||
|
origin: {
|
||
|
y: 0.7
|
||
|
}
|
||
|
};
|
||
|
function fire(particleRatio, opts) {
|
||
|
_canvasConfettiDefault.default(Object.assign({
|
||
|
}, defaults, opts, {
|
||
|
particleCount: Math.floor(count * particleRatio)
|
||
|
}));
|
||
|
}
|
||
|
fire(0.25, {
|
||
|
spread: 26,
|
||
|
startVelocity: 55
|
||
|
});
|
||
|
fire(0.2, {
|
||
|
spread: 60
|
||
|
});
|
||
|
fire(0.35, {
|
||
|
spread: 100,
|
||
|
decay: 0.91,
|
||
|
scalar: 0.8
|
||
|
});
|
||
|
fire(0.1, {
|
||
|
spread: 120,
|
||
|
startVelocity: 25,
|
||
|
decay: 0.92,
|
||
|
scalar: 1.2
|
||
|
});
|
||
|
fire(0.1, {
|
||
|
spread: 120,
|
||
|
startVelocity: 45
|
||
|
});
|
||
|
}
|
||
|
function setDarkMode(value) {
|
||
|
if (value) document.body.classList.add("dark-mode");
|
||
|
else document.body.classList.remove("dark-mode");
|
||
|
}
|
||
|
function getCV() {
|
||
|
const a = document.createElement("a");
|
||
1 year ago
|
a.href = "resources/resume.pdf";
|
||
|
a.setAttribute("download", "CV - Antoine DAUTRY.pdf");
|
||
2 years ago
|
a.click();
|
||
|
}
|
||
|
function rmRf() {
|
||
|
setDarkMode(true);
|
||
|
document.body.classList.add("firework");
|
||
|
const fireworks = new _fireworksJs.Fireworks(document.body, {
|
||
|
mouse: {
|
||
|
click: true,
|
||
|
move: false,
|
||
|
max: 7
|
||
|
}
|
||
|
});
|
||
|
fireworks.start();
|
||
|
}
|
||
|
|
||
1 year ago
|
},{"canvas-confetti":"iA6Ya","fireworks-js":"2ZxwZ","@parcel/transformer-js/src/esmodule-helpers.js":"ciiiV"}],"iA6Ya":[function(require,module,exports) {
|
||
2 years ago
|
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
|
||
|
parcelHelpers.defineInteropFlag(exports);
|
||
|
parcelHelpers.export(exports, "create", ()=>create
|
||
|
);
|
||
|
// canvas-confetti v1.5.1 built on 2022-02-08T22:20:40.944Z
|
||
|
var module = {
|
||
|
};
|
||
1 year ago
|
(function main(global, module, isWorker, workerSize) {
|
||
2 years ago
|
var canUseWorker = !!(global.Worker && global.Blob && global.Promise && global.OffscreenCanvas && global.OffscreenCanvasRenderingContext2D && global.HTMLCanvasElement && global.HTMLCanvasElement.prototype.transferControlToOffscreen && global.URL && global.URL.createObjectURL);
|
||
|
function noop() {
|
||
|
}
|
||
|
// create a promise if it exists, otherwise, just
|
||
|
// call the function directly
|
||
|
function promise(func) {
|
||
1 year ago
|
var ModulePromise = module.exports.Promise;
|
||
2 years ago
|
var Prom = ModulePromise !== void 0 ? ModulePromise : global.Promise;
|
||
|
if (typeof Prom === 'function') return new Prom(func);
|
||
|
func(noop, noop);
|
||
|
return null;
|
||
|
}
|
||
|
var raf = function() {
|
||
|
var TIME = Math.floor(1000 / 60);
|
||
|
var frame, cancel;
|
||
|
var frames = {
|
||
|
};
|
||
|
var lastFrameTime = 0;
|
||
|
if (typeof requestAnimationFrame === 'function' && typeof cancelAnimationFrame === 'function') {
|
||
|
frame = function(cb) {
|
||
|
var id = Math.random();
|
||
|
frames[id] = requestAnimationFrame(function onFrame(time) {
|
||
|
if (lastFrameTime === time || lastFrameTime + TIME - 1 < time) {
|
||
|
lastFrameTime = time;
|
||
|
delete frames[id];
|
||
|
cb();
|
||
|
} else frames[id] = requestAnimationFrame(onFrame);
|
||
|
});
|
||
|
return id;
|
||
|
};
|
||
|
cancel = function(id) {
|
||
|
if (frames[id]) cancelAnimationFrame(frames[id]);
|
||
|
};
|
||
|
} else {
|
||
|
frame = function(cb) {
|
||
|
return setTimeout(cb, TIME);
|
||
|
};
|
||
|
cancel = function(timer) {
|
||
|
return clearTimeout(timer);
|
||
|
};
|
||
|
}
|
||
|
return {
|
||
|
frame: frame,
|
||
|
cancel: cancel
|
||
|
};
|
||
|
}();
|
||
|
var getWorker = function() {
|
||
1 year ago
|
var worker;
|
||
2 years ago
|
var prom;
|
||
|
var resolves = {
|
||
|
};
|
||
|
function decorate(worker) {
|
||
|
function execute(options, callback) {
|
||
|
worker.postMessage({
|
||
|
options: options || {
|
||
|
},
|
||
|
callback: callback
|
||
|
});
|
||
|
}
|
||
|
worker.init = function initWorker(canvas) {
|
||
|
var offscreen = canvas.transferControlToOffscreen();
|
||
|
worker.postMessage({
|
||
|
canvas: offscreen
|
||
|
}, [
|
||
|
offscreen
|
||
|
]);
|
||
|
};
|
||
|
worker.fire = function fireWorker(options, size, done) {
|
||
|
if (prom) {
|
||
|
execute(options, null);
|
||
|
return prom;
|
||
|
}
|
||
|
var id = Math.random().toString(36).slice(2);
|
||
|
prom = promise(function(resolve) {
|
||
|
function workerDone(msg) {
|
||
|
if (msg.data.callback !== id) return;
|
||
|
delete resolves[id];
|
||
|
worker.removeEventListener('message', workerDone);
|
||
|
prom = null;
|
||
|
done();
|
||
|
resolve();
|
||
|
}
|
||
|
worker.addEventListener('message', workerDone);
|
||
|
execute(options, id);
|
||
|
resolves[id] = workerDone.bind(null, {
|
||
|
data: {
|
||
|
callback: id
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
return prom;
|
||
|
};
|
||
|
worker.reset = function resetWorker() {
|
||
|
worker.postMessage({
|
||
|
reset: true
|
||
|
});
|
||
|
for(var id in resolves){
|
||
|
resolves[id]();
|
||
|
delete resolves[id];
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
return function() {
|
||
1 year ago
|
if (worker) return worker;
|
||
2 years ago
|
if (!isWorker && canUseWorker) {
|
||
|
var code = [
|
||
|
'var CONFETTI, SIZE = {}, module = {};',
|
||
|
'(' + main.toString() + ')(this, module, true, SIZE);',
|
||
|
'onmessage = function(msg) {',
|
||
|
' if (msg.data.options) {',
|
||
|
' CONFETTI(msg.data.options).then(function () {',
|
||
|
' if (msg.data.callback) {',
|
||
|
' postMessage({ callback: msg.data.callback });',
|
||
|
' }',
|
||
|
' });',
|
||
|
' } else if (msg.data.reset) {',
|
||
|
' CONFETTI.reset();',
|
||
|
' } else if (msg.data.resize) {',
|
||
|
' SIZE.width = msg.data.resize.width;',
|
||
|
' SIZE.height = msg.data.resize.height;',
|
||
|
' } else if (msg.data.canvas) {',
|
||
|
' SIZE.width = msg.data.canvas.width;',
|
||
|
' SIZE.height = msg.data.canvas.height;',
|
||
|
' CONFETTI = module.exports.create(msg.data.canvas);',
|
||
|
' }',
|
||
|
'}',
|
||
|
].join('\n');
|
||
|
try {
|
||
1 year ago
|
worker = new Worker(URL.createObjectURL(new Blob([
|
||
2 years ago
|
code
|
||
|
])));
|
||
|
} catch (e) {
|
||
|
// eslint-disable-next-line no-console
|
||
|
typeof console.warn === 'function' && console.warn('🎊 Could not load worker', e);
|
||
|
return null;
|
||
|
}
|
||
1 year ago
|
decorate(worker);
|
||
2 years ago
|
}
|
||
1 year ago
|
return worker;
|
||
2 years ago
|
};
|
||
|
}();
|
||
|
var defaults = {
|
||
|
particleCount: 50,
|
||
|
angle: 90,
|
||
|
spread: 45,
|
||
|
startVelocity: 45,
|
||
|
decay: 0.9,
|
||
|
gravity: 1,
|
||
|
drift: 0,
|
||
|
ticks: 200,
|
||
|
x: 0.5,
|
||
|
y: 0.5,
|
||
|
shapes: [
|
||
|
'square',
|
||
|
'circle'
|
||
|
],
|
||
|
zIndex: 100,
|
||
|
colors: [
|
||
|
'#26ccff',
|
||
|
'#a25afd',
|
||
|
'#ff5e7e',
|
||
|
'#88ff5a',
|
||
|
'#fcff42',
|
||
|
'#ffa62d',
|
||
|
'#ff36ff'
|
||
|
],
|
||
|
// probably should be true, but back-compat
|
||
|
disableForReducedMotion: false,
|
||
|
scalar: 1
|
||
|
};
|
||
|
function convert(val, transform) {
|
||
|
return transform ? transform(val) : val;
|
||
|
}
|
||
|
function isOk(val) {
|
||
|
return !(val === null || val === undefined);
|
||
|
}
|
||
|
function prop(options, name, transform) {
|
||
|
return convert(options && isOk(options[name]) ? options[name] : defaults[name], transform);
|
||
|
}
|
||
|
function onlyPositiveInt(number) {
|
||
|
return number < 0 ? 0 : Math.floor(number);
|
||
|
}
|
||
|
function randomInt(min, max) {
|
||
|
// [min, max)
|
||
|
return Math.floor(Math.random() * (max - min)) + min;
|
||
|
}
|
||
|
function toDecimal(str) {
|
||
|
return parseInt(str, 16);
|
||
|
}
|
||
|
function colorsToRgb(colors) {
|
||
|
return colors.map(hexToRgb);
|
||
|
}
|
||
|
function hexToRgb(str) {
|
||
|
var val = String(str).replace(/[^0-9a-f]/gi, '');
|
||
|
if (val.length < 6) val = val[0] + val[0] + val[1] + val[1] + val[2] + val[2];
|
||
|
return {
|
||
|
r: toDecimal(val.substring(0, 2)),
|
||
|
g: toDecimal(val.substring(2, 4)),
|
||
|
b: toDecimal(val.substring(4, 6))
|
||
|
};
|
||
|
}
|
||
|
function getOrigin(options) {
|
||
|
var origin = prop(options, 'origin', Object);
|
||
|
origin.x = prop(origin, 'x', Number);
|
||
|
origin.y = prop(origin, 'y', Number);
|
||
|
return origin;
|
||
|
}
|
||
|
function setCanvasWindowSize(canvas) {
|
||
|
canvas.width = document.documentElement.clientWidth;
|
||
|
canvas.height = document.documentElement.clientHeight;
|
||
|
}
|
||
|
function setCanvasRectSize(canvas) {
|
||
|
var rect = canvas.getBoundingClientRect();
|
||
|
canvas.width = rect.width;
|
||
|
canvas.height = rect.height;
|
||
|
}
|
||
|
function getCanvas(zIndex) {
|
||
|
var canvas = document.createElement('canvas');
|
||
|
canvas.style.position = 'fixed';
|
||
|
canvas.style.top = '0px';
|
||
|
canvas.style.left = '0px';
|
||
|
canvas.style.pointerEvents = 'none';
|
||
|
canvas.style.zIndex = zIndex;
|
||
|
return canvas;
|
||
|
}
|
||
|
function ellipse(context, x, y, radiusX, radiusY, rotation, startAngle, endAngle, antiClockwise) {
|
||
|
context.save();
|
||
|
context.translate(x, y);
|
||
|
context.rotate(rotation);
|
||
|
context.scale(radiusX, radiusY);
|
||
|
context.arc(0, 0, 1, startAngle, endAngle, antiClockwise);
|
||
|
context.restore();
|
||
|
}
|
||
|
function randomPhysics(opts) {
|
||
|
var radAngle = opts.angle * (Math.PI / 180);
|
||
|
var radSpread = opts.spread * (Math.PI / 180);
|
||
|
return {
|
||
|
x: opts.x,
|
||
|
y: opts.y,
|
||
|
wobble: Math.random() * 10,
|
||
|
wobbleSpeed: Math.min(0.11, Math.random() * 0.1 + 0.05),
|
||
|
velocity: opts.startVelocity * 0.5 + Math.random() * opts.startVelocity,
|
||
|
angle2D: -radAngle + (0.5 * radSpread - Math.random() * radSpread),
|
||
|
tiltAngle: (Math.random() * 0.5 + 0.25) * Math.PI,
|
||
|
color: opts.color,
|
||
|
shape: opts.shape,
|
||
|
tick: 0,
|
||
|
totalTicks: opts.ticks,
|
||
|
decay: opts.decay,
|
||
|
drift: opts.drift,
|
||
|
random: Math.random() + 2,
|
||
|
tiltSin: 0,
|
||
|
tiltCos: 0,
|
||
|
wobbleX: 0,
|
||
|
wobbleY: 0,
|
||
|
gravity: opts.gravity * 3,
|
||
|
ovalScalar: 0.6,
|
||
|
scalar: opts.scalar
|
||
|
};
|
||
|
}
|
||
|
function updateFetti(context, fetti) {
|
||
|
fetti.x += Math.cos(fetti.angle2D) * fetti.velocity + fetti.drift;
|
||
|
fetti.y += Math.sin(fetti.angle2D) * fetti.velocity + fetti.gravity;
|
||
|
fetti.wobble += fetti.wobbleSpeed;
|
||
|
fetti.velocity *= fetti.decay;
|
||
|
fetti.tiltAngle += 0.1;
|
||
|
fetti.tiltSin = Math.sin(fetti.tiltAngle);
|
||
|
fetti.tiltCos = Math.cos(fetti.tiltAngle);
|
||
|
fetti.random = Math.random() + 2;
|
||
|
fetti.wobbleX = fetti.x + 10 * fetti.scalar * Math.cos(fetti.wobble);
|
||
|
fetti.wobbleY = fetti.y + 10 * fetti.scalar * Math.sin(fetti.wobble);
|
||
|
var progress = (fetti.tick++) / fetti.totalTicks;
|
||
|
var x1 = fetti.x + fetti.random * fetti.tiltCos;
|
||
|
var y1 = fetti.y + fetti.random * fetti.tiltSin;
|
||
|
var x2 = fetti.wobbleX + fetti.random * fetti.tiltCos;
|
||
|
var y2 = fetti.wobbleY + fetti.random * fetti.tiltSin;
|
||
|
context.fillStyle = 'rgba(' + fetti.color.r + ', ' + fetti.color.g + ', ' + fetti.color.b + ', ' + (1 - progress) + ')';
|
||
|
context.beginPath();
|
||
|
if (fetti.shape === 'circle') context.ellipse ? context.ellipse(fetti.x, fetti.y, Math.abs(x2 - x1) * fetti.ovalScalar, Math.abs(y2 - y1) * fetti.ovalScalar, Math.PI / 10 * fetti.wobble, 0, 2 * Math.PI) : ellipse(context, fetti.x, fetti.y, Math.abs(x2 - x1) * fetti.ovalScalar, Math.abs(y2 - y1) * fetti.ovalScalar, Math.PI / 10 * fetti.wobble, 0, 2 * Math.PI);
|
||
|
else {
|
||
|
context.moveTo(Math.floor(fetti.x), Math.floor(fetti.y));
|
||
|
context.lineTo(Math.floor(fetti.wobbleX), Math.floor(y1));
|
||
|
context.lineTo(Math.floor(x2), Math.floor(y2));
|
||
|
context.lineTo(Math.floor(x1), Math.floor(fetti.wobbleY));
|
||
|
}
|
||
|
context.closePath();
|
||
|
context.fill();
|
||
|
return fetti.tick < fetti.totalTicks;
|
||
|
}
|
||
1 year ago
|
function animate(canvas, fettis, resizer, size, done) {
|
||
|
var animatingFettis = fettis.slice();
|
||
2 years ago
|
var context = canvas.getContext('2d');
|
||
|
var animationFrame;
|
||
|
var destroy;
|
||
|
var prom = promise(function(resolve) {
|
||
|
function onDone() {
|
||
|
animationFrame = destroy = null;
|
||
|
context.clearRect(0, 0, size.width, size.height);
|
||
|
done();
|
||
|
resolve();
|
||
|
}
|
||
|
function update() {
|
||
|
if (isWorker && !(size.width === workerSize.width && size.height === workerSize.height)) {
|
||
|
size.width = canvas.width = workerSize.width;
|
||
|
size.height = canvas.height = workerSize.height;
|
||
|
}
|
||
|
if (!size.width && !size.height) {
|
||
|
resizer(canvas);
|
||
|
size.width = canvas.width;
|
||
|
size.height = canvas.height;
|
||
|
}
|
||
|
context.clearRect(0, 0, size.width, size.height);
|
||
|
animatingFettis = animatingFettis.filter(function(fetti) {
|
||
|
return updateFetti(context, fetti);
|
||
|
});
|
||
|
if (animatingFettis.length) animationFrame = raf.frame(update);
|
||
|
else onDone();
|
||
|
}
|
||
|
animationFrame = raf.frame(update);
|
||
|
destroy = onDone;
|
||
|
});
|
||
|
return {
|
||
|
addFettis: function(fettis) {
|
||
|
animatingFettis = animatingFettis.concat(fettis);
|
||
|
return prom;
|
||
|
},
|
||
|
canvas: canvas,
|
||
|
promise: prom,
|
||
|
reset: function() {
|
||
|
if (animationFrame) raf.cancel(animationFrame);
|
||
|
if (destroy) destroy();
|
||
|
}
|
||
|
};
|
||
|
}
|
||
|
function confettiCannon(canvas, globalOpts) {
|
||
|
var isLibCanvas = !canvas;
|
||
|
var allowResize = !!prop(globalOpts || {
|
||
|
}, 'resize');
|
||
|
var globalDisableForReducedMotion = prop(globalOpts, 'disableForReducedMotion', Boolean);
|
||
|
var shouldUseWorker = canUseWorker && !!prop(globalOpts || {
|
||
|
}, 'useWorker');
|
||
|
var worker = shouldUseWorker ? getWorker() : null;
|
||
|
var resizer = isLibCanvas ? setCanvasWindowSize : setCanvasRectSize;
|
||
|
var initialized = canvas && worker ? !!canvas.__confetti_initialized : false;
|
||
|
var preferLessMotion = typeof matchMedia === 'function' && matchMedia('(prefers-reduced-motion)').matches;
|
||
|
var animationObj;
|
||
|
function fireLocal(options, size, done) {
|
||
|
var particleCount = prop(options, 'particleCount', onlyPositiveInt);
|
||
|
var angle = prop(options, 'angle', Number);
|
||
|
var spread = prop(options, 'spread', Number);
|
||
|
var startVelocity = prop(options, 'startVelocity', Number);
|
||
|
var decay = prop(options, 'decay', Number);
|
||
|
var gravity = prop(options, 'gravity', Number);
|
||
|
var drift = prop(options, 'drift', Number);
|
||
|
var colors = prop(options, 'colors', colorsToRgb);
|
||
|
var ticks = prop(options, 'ticks', Number);
|
||
|
var shapes = prop(options, 'shapes');
|
||
|
var scalar = prop(options, 'scalar');
|
||
|
var origin = getOrigin(options);
|
||
|
var temp = particleCount;
|
||
|
var fettis = [];
|
||
|
var startX = canvas.width * origin.x;
|
||
|
var startY = canvas.height * origin.y;
|
||
|
while(temp--)fettis.push(randomPhysics({
|
||
|
x: startX,
|
||
|
y: startY,
|
||
|
angle: angle,
|
||
|
spread: spread,
|
||
|
startVelocity: startVelocity,
|
||
|
color: colors[temp % colors.length],
|
||
|
shape: shapes[randomInt(0, shapes.length)],
|
||
|
ticks: ticks,
|
||
|
decay: decay,
|
||
|
gravity: gravity,
|
||
|
drift: drift,
|
||
|
scalar: scalar
|
||
|
}));
|
||
|
// if we have a previous canvas already animating,
|
||
|
// add to it
|
||
|
if (animationObj) return animationObj.addFettis(fettis);
|
||
|
animationObj = animate(canvas, fettis, resizer, size, done);
|
||
|
return animationObj.promise;
|
||
|
}
|
||
|
function fire(options) {
|
||
|
var disableForReducedMotion = globalDisableForReducedMotion || prop(options, 'disableForReducedMotion', Boolean);
|
||
|
var zIndex = prop(options, 'zIndex', Number);
|
||
|
if (disableForReducedMotion && preferLessMotion) return promise(function(resolve) {
|
||
|
resolve();
|
||
|
});
|
||
|
if (isLibCanvas && animationObj) // use existing canvas from in-progress animation
|
||
|
canvas = animationObj.canvas;
|
||
|
else if (isLibCanvas && !canvas) {
|
||
|
// create and initialize a new canvas
|
||
|
canvas = getCanvas(zIndex);
|
||
|
document.body.appendChild(canvas);
|
||
|
}
|
||
|
if (allowResize && !initialized) // initialize the size of a user-supplied canvas
|
||
|
resizer(canvas);
|
||
|
var size = {
|
||
|
width: canvas.width,
|
||
|
height: canvas.height
|
||
|
};
|
||
|
if (worker && !initialized) worker.init(canvas);
|
||
|
initialized = true;
|
||
|
if (worker) canvas.__confetti_initialized = true;
|
||
|
function onResize() {
|
||
|
if (worker) {
|
||
|
// TODO this really shouldn't be immediate, because it is expensive
|
||
|
var obj = {
|
||
|
getBoundingClientRect: function() {
|
||
|
if (!isLibCanvas) return canvas.getBoundingClientRect();
|
||
|
}
|
||
|
};
|
||
|
resizer(obj);
|
||
|
worker.postMessage({
|
||
|
resize: {
|
||
|
width: obj.width,
|
||
|
height: obj.height
|
||
|
}
|
||
|
});
|
||
|
return;
|
||
|
}
|
||
|
// don't actually query the size here, since this
|
||
|
// can execute frequently and rapidly
|
||
|
size.width = size.height = null;
|
||
|
}
|
||
|
function done() {
|
||
|
animationObj = null;
|
||
|
if (allowResize) global.removeEventListener('resize', onResize);
|
||
|
if (isLibCanvas && canvas) {
|
||
|
document.body.removeChild(canvas);
|
||
|
canvas = null;
|
||
|
initialized = false;
|
||
|
}
|
||
|
}
|
||
|
if (allowResize) global.addEventListener('resize', onResize, false);
|
||
|
if (worker) return worker.fire(options, size, done);
|
||
|
return fireLocal(options, size, done);
|
||
|
}
|
||
|
fire.reset = function() {
|
||
|
if (worker) worker.reset();
|
||
|
if (animationObj) animationObj.reset();
|
||
|
};
|
||
|
return fire;
|
||
|
}
|
||
|
// Make default export lazy to defer worker creation until called.
|
||
|
var defaultFire;
|
||
|
function getDefaultFire() {
|
||
|
if (!defaultFire) defaultFire = confettiCannon(null, {
|
||
|
useWorker: true,
|
||
|
resize: true
|
||
|
});
|
||
|
return defaultFire;
|
||
|
}
|
||
1 year ago
|
module.exports = function() {
|
||
2 years ago
|
return getDefaultFire().apply(this, arguments);
|
||
|
};
|
||
1 year ago
|
module.exports.reset = function() {
|
||
2 years ago
|
getDefaultFire().reset();
|
||
|
};
|
||
1 year ago
|
module.exports.create = confettiCannon;
|
||
2 years ago
|
})(function() {
|
||
|
if (typeof window !== 'undefined') return window;
|
||
|
if (typeof self !== 'undefined') return self;
|
||
|
return this || {
|
||
|
};
|
||
|
}(), module, false);
|
||
|
exports.default = module.exports;
|
||
|
var create = module.exports.create;
|
||
|
|
||
1 year ago
|
},{"@parcel/transformer-js/src/esmodule-helpers.js":"ciiiV"}],"ciiiV":[function(require,module,exports) {
|
||
2 years ago
|
exports.interopDefault = function(a) {
|
||
|
return a && a.__esModule ? a : {
|
||
|
default: a
|
||
|
};
|
||
|
};
|
||
|
exports.defineInteropFlag = function(a) {
|
||
|
Object.defineProperty(a, '__esModule', {
|
||
|
value: true
|
||
|
});
|
||
|
};
|
||
|
exports.exportAll = function(source, dest) {
|
||
|
Object.keys(source).forEach(function(key) {
|
||
|
if (key === 'default' || key === '__esModule' || dest.hasOwnProperty(key)) return;
|
||
|
Object.defineProperty(dest, key, {
|
||
|
enumerable: true,
|
||
|
get: function() {
|
||
|
return source[key];
|
||
|
}
|
||
|
});
|
||
|
});
|
||
|
return dest;
|
||
|
};
|
||
|
exports.export = function(dest, destName, get) {
|
||
|
Object.defineProperty(dest, destName, {
|
||
|
enumerable: true,
|
||
|
get: get
|
||
|
});
|
||
|
};
|
||
|
|
||
1 year ago
|
},{}],"2ZxwZ":[function(require,module,exports) {
|
||
2 years ago
|
/*!
|
||
|
* fireworks-js 1.3.5 by Vitalij Ryndin (https://crashmax.ru)
|
||
|
* https://fireworks.js.org
|
||
|
* License MIT
|
||
|
*/ !function(t, i) {
|
||
|
if ("object" == typeof exports && "object" == typeof module) module.exports = i();
|
||
|
else if ("function" == typeof define && define.amd) define([], i);
|
||
|
else {
|
||
|
var s = i();
|
||
|
for(var e in s)("object" == typeof exports ? exports : t)[e] = s[e];
|
||
|
}
|
||
|
}(this, function() {
|
||
|
return (()=>{
|
||
|
var t1 = {
|
||
1 year ago
|
511: (t, i, s)=>{
|
||
|
Object.defineProperty(i, "__esModule", {
|
||
2 years ago
|
value: !0
|
||
1 year ago
|
}), i.Explosion = void 0;
|
||
|
var e = s(909);
|
||
|
i.Explosion = class {
|
||
2 years ago
|
constructor(t){
|
||
|
var { x: i , y: s , ctx: h , hue: n , exp: o , gravity: a , friction: r , brightness: c , explosionLength: _ } = t;
|
||
|
for(this._coordinates = [], this._alpha = 1, this._x = i, this._y = s, this._exp = o, this._ctx = h, this._gravity = a, this._friction = r, this._explosionLength = _; this._explosionLength--;)this._coordinates.push([
|
||
|
i,
|
||
|
s
|
||
|
]);
|
||
1 year ago
|
this._angle = e.randomFloat(0, 2 * Math.PI), this._speed = e.randomInt(1, 10), this._hue = e.randomInt(n - 20, n + 20), this._brightness = e.randomInt(c.min, c.max), this._decay = e.randomFloat(c.decay.min, c.decay.max);
|
||
2 years ago
|
}
|
||
|
update(t) {
|
||
|
this._coordinates.pop(), this._coordinates.unshift([
|
||
|
this._x,
|
||
|
this._y
|
||
|
]), this._speed *= this._friction, this._x += Math.cos(this._angle) * this._speed, this._y += Math.sin(this._angle) * this._speed + this._gravity, this._alpha -= this._decay, this._alpha <= this._decay && t();
|
||
|
}
|
||
|
draw() {
|
||
|
var t = this._coordinates.length - 1;
|
||
1 year ago
|
this._ctx.beginPath(), this._exp && (this._ctx.arc(this._x, this._y, e.randomFloat(0.5, 1.5), 0, 2 * Math.PI), this._ctx.fill()), this._ctx.fillStyle = e.hsla(this._hue, this._brightness, this._alpha), this._ctx.moveTo(this._coordinates[t][0], this._coordinates[t][1]), this._ctx.lineTo(this._x, this._y), this._ctx.strokeStyle = e.hsla(this._hue, this._brightness, this._alpha), this._ctx.stroke();
|
||
2 years ago
|
}
|
||
|
};
|
||
|
},
|
||
1 year ago
|
909: (t, i)=>{
|
||
|
Object.defineProperty(i, "__esModule", {
|
||
2 years ago
|
value: !0
|
||
1 year ago
|
}), i.hsla = i.getDistance = i.randomInt = i.randomFloat = void 0, i.randomFloat = function(t, i) {
|
||
2 years ago
|
return Math.random() * (i - t) + t;
|
||
1 year ago
|
}, i.randomInt = function(t, i) {
|
||
2 years ago
|
return Math.floor(t + Math.random() * (i + 1 - t));
|
||
1 year ago
|
}, i.getDistance = function(t, i, s, e) {
|
||
2 years ago
|
var h = Math.pow;
|
||
|
return Math.sqrt(h(t - s, 2) + h(i - e, 2));
|
||
1 year ago
|
}, i.hsla = function(t, i) {
|
||
2 years ago
|
var s = arguments.length > 2 && void 0 !== arguments[2] ? arguments[2] : 1;
|
||
|
return "hsla(".concat(t, ", 100%, ").concat(i, "%, ").concat(s, ")");
|
||
|
};
|
||
|
},
|
||
1 year ago
|
449: function(t, i, s) {
|
||
|
var e = this && this.__awaiter || function(t, i, s, e) {
|
||
2 years ago
|
return new (s || (s = Promise))(function(h, n) {
|
||
|
function o(t) {
|
||
|
try {
|
||
|
r(e.next(t));
|
||
1 year ago
|
} catch (t1) {
|
||
|
n(t1);
|
||
2 years ago
|
}
|
||
|
}
|
||
|
function a(t) {
|
||
|
try {
|
||
|
r(e.throw(t));
|
||
1 year ago
|
} catch (t1) {
|
||
|
n(t1);
|
||
2 years ago
|
}
|
||
|
}
|
||
1 year ago
|
function r(t) {
|
||
2 years ago
|
var i;
|
||
1 year ago
|
t.done ? h(t.value) : (i = t.value, i instanceof s ? i : new s(function(t) {
|
||
2 years ago
|
t(i);
|
||
|
})).then(o, a);
|
||
|
}
|
||
1 year ago
|
r((e = e.apply(t, i || [])).next());
|
||
2 years ago
|
});
|
||
|
};
|
||
1 year ago
|
Object.defineProperty(i, "__esModule", {
|
||
2 years ago
|
value: !0
|
||
1 year ago
|
}), i.Sound = void 0;
|
||
|
var h = s(909);
|
||
|
i.Sound = class {
|
||
2 years ago
|
constructor(t){
|
||
|
this._buffer = [], this.onInit = !0, this._audioContext = new (window.AudioContext || window.webkitAudioContext), this.options = Object.assign({
|
||
|
enabled: !1,
|
||
|
files: [
|
||
|
"explosion0.mp3",
|
||
|
"explosion1.mp3",
|
||
|
"explosion2.mp3"
|
||
|
],
|
||
|
volume: {
|
||
|
min: 4,
|
||
|
max: 8
|
||
|
}
|
||
|
}, t), this.init();
|
||
|
}
|
||
|
init() {
|
||
|
this.onInit && this.options.enabled && (this.onInit = !1, this.load());
|
||
|
}
|
||
|
load() {
|
||
1 year ago
|
return e(this, void 0, void 0, function*() {
|
||
|
for (var t of this.options.files){
|
||
|
var i = yield (yield fetch(t)).arrayBuffer();
|
||
2 years ago
|
this._audioContext.decodeAudioData(i).then((t)=>{
|
||
|
this._buffer.push(t);
|
||
|
}).catch((t)=>{
|
||
|
throw t;
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
play() {
|
||
|
if (this.options.enabled && this._buffer.length) {
|
||
1 year ago
|
var t = this._audioContext.createBufferSource(), i = this._buffer[h.randomInt(0, this._buffer.length - 1)], s = this._audioContext.createGain();
|
||
|
t.buffer = i, s.gain.value = h.randomFloat(this.options.volume.min / 100, this.options.volume.max / 100), s.connect(this._audioContext.destination), t.connect(s), t.start(0);
|
||
2 years ago
|
} else this.init();
|
||
|
}
|
||
|
};
|
||
|
},
|
||
1 year ago
|
668: (t, i, s)=>{
|
||
|
Object.defineProperty(i, "__esModule", {
|
||
2 years ago
|
value: !0
|
||
1 year ago
|
}), i.Trace = void 0;
|
||
|
var e = s(909);
|
||
|
i.Trace = class {
|
||
2 years ago
|
constructor(t){
|
||
|
var { x: i , y: s , dx: h , dy: n , ctx: o , hue: a , speed: r , traceLength: c , acceleration: _ } = t;
|
||
1 year ago
|
for(this._coordinates = [], this._currentDistance = 0, this._x = i, this._y = s, this._sx = i, this._sy = s, this._dx = h, this._dy = n, this._ctx = o, this._hue = a, this._speed = r, this._traceLength = c, this._acceleration = _, this._totalDistance = e.getDistance(i, s, h, n); this._traceLength--;)this._coordinates.push([
|
||
2 years ago
|
i,
|
||
|
s
|
||
|
]);
|
||
1 year ago
|
this._angle = Math.atan2(n - s, h - i), this._brightness = e.randomInt(50, 70);
|
||
2 years ago
|
}
|
||
|
update(t) {
|
||
|
this._coordinates.pop(), this._coordinates.unshift([
|
||
|
this._x,
|
||
|
this._y
|
||
|
]), this._speed *= this._acceleration;
|
||
|
var i = Math.cos(this._angle) * this._speed, s = Math.sin(this._angle) * this._speed;
|
||
1 year ago
|
this._currentDistance = e.getDistance(this._sx, this._sy, this._x + i, this._y + s), this._currentDistance >= this._totalDistance ? t(this._dx, this._dy, this._hue) : (this._x += i, this._y += s);
|
||
2 years ago
|
}
|
||
|
draw() {
|
||
|
var t = this._coordinates.length - 1;
|
||
1 year ago
|
this._ctx.beginPath(), this._ctx.moveTo(this._coordinates[t][0], this._coordinates[t][1]), this._ctx.lineTo(this._x, this._y), this._ctx.strokeStyle = e.hsla(this._hue, this._brightness), this._ctx.stroke();
|
||
2 years ago
|
}
|
||
|
};
|
||
|
}
|
||
1 year ago
|
}, i = {
|
||
2 years ago
|
};
|
||
1 year ago
|
function s(e) {
|
||
|
var h = i[e];
|
||
2 years ago
|
if (void 0 !== h) return h.exports;
|
||
1 year ago
|
var n = i[e] = {
|
||
2 years ago
|
exports: {
|
||
|
}
|
||
|
};
|
||
1 year ago
|
return t1[e].call(n.exports, n, n.exports, s), n.exports;
|
||
2 years ago
|
}
|
||
1 year ago
|
var e = {
|
||
2 years ago
|
};
|
||
|
return (()=>{
|
||
1 year ago
|
var t2 = e;
|
||
|
Object.defineProperty(t2, "__esModule", {
|
||
2 years ago
|
value: !0
|
||
1 year ago
|
}), t2.Fireworks = void 0;
|
||
|
var i = s(668), h = s(449), n = s(511), o = s(909);
|
||
|
t2.Fireworks = class {
|
||
|
constructor(t){
|
||
2 years ago
|
var { autoresize: i = !0 , boundaries: s , brightness: e , delay: n , hue: o , mouse: a , sound: r , trace: c = 3 , speed: _ = 2 , explosion: d = 5 , gravity: u = 1.5 , opacity: l = 0.5 , particles: p = 50 , friction: x = 0.95 , rocketsPoint: m = 50 , acceleration: v = 1.05 } = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : {
|
||
|
};
|
||
1 year ago
|
this._tick = 0, this._version = "1.3.5", this._running = !1, this._randomRocketsPoint = !1, this._experimentals = !1, this._m = !1, this._container = t, this._canvas = document.createElement("canvas"), this._ctx = this._canvas.getContext("2d"), this._container.appendChild(this._canvas), this._sound = new h.Sound(r), this.setSize(), this.setBoundaries(Object.assign({
|
||
2 years ago
|
visible: !1,
|
||
|
x: 50,
|
||
|
y: 50
|
||
|
}, s)), this.autoresize = i, this.trace = c, this.speed = _, this.explosion = d, this.gravity = u, this.opacity = l, this.particles = p, this.friction = x, this.rocketsPoint = m, this.acceleration = v, this.hue = Object.assign({
|
||
|
min: 0,
|
||
|
max: 360
|
||
|
}, o), this.mouse = Object.assign({
|
||
|
click: !1,
|
||
|
move: !1,
|
||
|
max: 1
|
||
|
}, a), this.delay = Object.assign({
|
||
|
min: 15,
|
||
|
max: 30
|
||
|
}, n), this.brightness = Object.assign({
|
||
|
min: 50,
|
||
|
max: 80,
|
||
|
decay: {
|
||
|
min: 0.015,
|
||
|
max: 0.03
|
||
|
}
|
||
|
}, e), this.autoresize && window.addEventListener("resize", ()=>this.windowResize()
|
||
|
), this._canvas.addEventListener("mousedown", (t)=>this.mouseDown(t)
|
||
|
), this._canvas.addEventListener("mouseup", (t)=>this.mouseUp(t)
|
||
|
), this._canvas.addEventListener("mousemove", (t)=>this.mouseMove(t)
|
||
|
);
|
||
|
}
|
||
|
get isRunning() {
|
||
|
return this._running;
|
||
|
}
|
||
|
get version() {
|
||
|
return this._version;
|
||
|
}
|
||
|
start() {
|
||
|
this._running || (this._running = !0, this.clear(), this.render());
|
||
|
}
|
||
|
stop() {
|
||
|
this._running && (this._running = !1, this.clear());
|
||
|
}
|
||
|
unmount() {
|
||
|
window.removeEventListener("resize", this.windowResize), this._canvas.addEventListener("mousedown", this.mouseDown), this._canvas.addEventListener("mouseup", this.mouseUp), this._canvas.addEventListener("mousemove", this.mouseMove);
|
||
|
}
|
||
|
pause() {
|
||
|
this._running = !this._running;
|
||
|
}
|
||
|
clear() {
|
||
|
this._ctx && (this._traces = [], this._explosions = [], this._ctx.clearRect(0, 0, this._width, this._height));
|
||
|
}
|
||
|
setOptions(t) {
|
||
|
for (var [i, s] of Object.entries(t)){
|
||
|
var e = Object.prototype.hasOwnProperty.call(this, i);
|
||
|
if ("function" == typeof this[i]) throw new Error("You cannot change the methods of the class!");
|
||
|
e && ("object" == typeof this[i] ? Object.assign(this[i], s) : this[i] = s), "sound" === i && Object.assign(this._sound.options, s);
|
||
|
}
|
||
|
}
|
||
|
setSize() {
|
||
|
var { width: t = this._container.clientWidth , height: i = this._container.clientHeight } = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {
|
||
|
};
|
||
|
this._width = t, this._height = i, this._canvas.width = t, this._canvas.height = i, this.setBoundaries({
|
||
|
width: t,
|
||
|
height: i
|
||
|
});
|
||
|
}
|
||
|
setBoundaries(t) {
|
||
|
this.boundaries = Object.assign(Object.assign({
|
||
|
}, this.boundaries), t);
|
||
|
}
|
||
|
useMouse(t, i) {
|
||
|
(this.mouse.click || this.mouse.move) && (this._mx = t.pageX - this._canvas.offsetLeft, this._my = t.pageY - this._canvas.offsetTop, this._m = i);
|
||
|
}
|
||
|
windowResize() {
|
||
|
this.setSize();
|
||
|
}
|
||
|
mouseDown(t) {
|
||
|
this.useMouse(t, this.mouse.click);
|
||
|
}
|
||
|
mouseUp(t) {
|
||
|
this.useMouse(t, !1);
|
||
|
}
|
||
|
mouseMove(t) {
|
||
|
this.useMouse(t, this._m);
|
||
|
}
|
||
|
render() {
|
||
|
this._ctx && this._running && (requestAnimationFrame(()=>this.render()
|
||
|
), this._ctx.globalCompositeOperation = "destination-out", this._ctx.fillStyle = "rgba(0, 0, 0, ".concat(this.opacity, ")"), this._ctx.fillRect(0, 0, this._width, this._height), this._ctx.globalCompositeOperation = "lighter", this.drawBoundaries(), this.initTrace(), this.drawTrace(), this.drawExplosion(), this._tick++);
|
||
|
}
|
||
|
drawBoundaries() {
|
||
|
this.boundaries.visible && (this._ctx.beginPath(), this._ctx.strokeStyle = "red", this._ctx.rect(this.boundaries.x, this.boundaries.y, this.boundaries.width - 2 * this.boundaries.x, 0.5 * this.boundaries.height), this._ctx.stroke());
|
||
|
}
|
||
|
initTrace() {
|
||
1 year ago
|
this._ds = o.randomInt(this.delay.min, this.delay.max), (2 * this._ds < this._tick || this._m && this.mouse.max > this._traces.length) && (this._traces.push(new i.Trace({
|
||
|
x: this._width * (this._randomRocketsPoint ? o.randomInt(0, 100) : this.rocketsPoint) / 100,
|
||
2 years ago
|
y: this._height,
|
||
1 year ago
|
dx: this._mx && this.mouse.move || this._m ? this._mx : o.randomInt(this.boundaries.x, this.boundaries.width - 2 * this.boundaries.x),
|
||
|
dy: this._my && this.mouse.move || this._m ? this._my : o.randomInt(this.boundaries.y, 0.5 * this.boundaries.height),
|
||
2 years ago
|
ctx: this._ctx,
|
||
1 year ago
|
hue: o.randomInt(this.hue.min, this.hue.max),
|
||
2 years ago
|
speed: this.speed,
|
||
|
acceleration: this.acceleration,
|
||
|
traceLength: this.trace
|
||
|
})), this._tick = 0);
|
||
|
}
|
||
|
drawTrace() {
|
||
|
for(var t = this._traces.length; t--;)this._traces[t].draw(), this._traces[t].update((i, s, e)=>{
|
||
|
this.initExplosion(i, s, e), this._sound.play(), this._traces.splice(t, 1);
|
||
|
});
|
||
|
}
|
||
|
initExplosion(t, i, s) {
|
||
1 year ago
|
for(var e = this.particles; e--;)this._explosions.push(new n.Explosion({
|
||
2 years ago
|
x: t,
|
||
|
y: i,
|
||
|
ctx: this._ctx,
|
||
|
hue: s,
|
||
|
friction: this.friction,
|
||
|
gravity: this.gravity,
|
||
|
explosionLength: this.explosion,
|
||
|
brightness: this.brightness,
|
||
|
exp: this._experimentals
|
||
|
}));
|
||
|
}
|
||
|
drawExplosion() {
|
||
|
for(var t = this._explosions.length; t--;)this._explosions[t].draw(), this._explosions[t].update(()=>{
|
||
|
this._explosions.splice(t, 1);
|
||
|
});
|
||
|
}
|
||
|
};
|
||
1 year ago
|
})(), e;
|
||
2 years ago
|
})();
|
||
|
});
|
||
|
|
||
1 year ago
|
},{}],"krRPl":[function(require,module,exports) {
|
||
2 years ago
|
var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js");
|
||
|
parcelHelpers.defineInteropFlag(exports);
|
||
|
parcelHelpers.export(exports, "dragElement", ()=>dragElement
|
||
|
);
|
||
|
function dragElement(elmnt) {
|
||
|
var pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
|
||
|
const element = document.querySelector(".terminal__header");
|
||
|
if (element) // if present, the header is where you move the DIV from:
|
||
|
element.onmousedown = dragMouseDown;
|
||
|
else // otherwise, move the DIV from anywhere inside the DIV:
|
||
|
elmnt.onmousedown = dragMouseDown;
|
||
|
function dragMouseDown(e) {
|
||
|
e = e || window.event;
|
||
|
e.preventDefault();
|
||
|
// get the mouse cursor position at startup:
|
||
|
pos3 = e.clientX;
|
||
|
pos4 = e.clientY;
|
||
|
document.onmouseup = closeDragElement;
|
||
|
// call a function whenever the cursor moves:
|
||
|
document.onmousemove = elementDrag;
|
||
|
}
|
||
|
function elementDrag(e) {
|
||
|
e = e || window.event;
|
||
|
e.preventDefault();
|
||
|
// calculate the new cursor position:
|
||
|
pos1 = pos3 - e.clientX;
|
||
|
pos2 = pos4 - e.clientY;
|
||
|
pos3 = e.clientX;
|
||
|
pos4 = e.clientY;
|
||
|
// set the element's new position:
|
||
|
elmnt.style.top = elmnt.offsetTop - pos2 + "px";
|
||
|
elmnt.style.left = elmnt.offsetLeft - pos1 + "px";
|
||
|
}
|
||
|
function closeDragElement() {
|
||
|
// stop moving when mouse button is released:
|
||
|
document.onmouseup = null;
|
||
|
document.onmousemove = null;
|
||
|
}
|
||
|
}
|
||
|
|
||
1 year ago
|
},{"@parcel/transformer-js/src/esmodule-helpers.js":"ciiiV"}]},["1Mq12","5HwUs"], "5HwUs", "parcelRequiredb1a")
|
||
2 years ago
|
|
||
1 year ago
|
//# sourceMappingURL=index.d56a3cb1.js.map
|