This commit is contained in:
a-ill
2023-06-14 21:41:54 +03:00
parent 4d034eba7d
commit 9e8ee05bb6
128 changed files with 12242 additions and 0 deletions

View File

@@ -0,0 +1,532 @@
:root {
--light-blue:hsl(195, 67%, 95%);
--darker-pink:hsl(344, 60%, 47%);
--pink:hsl(344, 73%, 57%);
--dark-green:hsl(176, 63%, 25%);
--green:hsl(147, 33%, 60%);
--orange:hsl(30, 97%, 72%);
--light-orange: hsl(19, 76%, 72%);
--dark-brown:hsl(23, 47%, 20%);
--brown:hsl(23, 47%, 30%);
--light-brown: hsl(23, 47%, 50%);
--dark-pink:hsl(343, 39%, 16%);
--red:hsl(359, 72%, 61%);
--dark-blue:hsl(217, 25%, 16%);
--grey-blue:hsl(223, 13%, 22%);
--cream:hsl(34, 43%, 90%);
--dark-cream:hsl(33, 26%, 84%);
--sans-serif: "Space Grotesk";
--serif: "DejaVu";
}
svg {
width: auto;
height: auto;
}
:not(svg *) {
margin: 0;
padding: 0;
box-sizing: border-box;
border: none;
font-size: 0;
}
html {
overflow-x: hidden;
font-size: 16px;
}
body {
position: relative;
min-height: 100vh;
max-width: 100vw;
overflow: hidden;
background: white;
}
#content {
position: relative;
display: flex;
flex-direction: column;
justify-content: space-between;
height: 100%;
min-height: 100vh;
flex-grow: 1;
}
/*---Fonts---------------------------------------------------------*/
@font-face {
font-family: 'Space Grotesk';
font-weight: 400;
font-style: normal;
font-display: swap;
src: /*local('Space Grotesk Light'),
local('SpaceGroteskLight-Regular'),
local('Space Grotesk Light Regular'), */
url('/fonts/SpaceGrotesk/SpaceGrotesk.woff2') format('woff2'),
url('/fonts/SpaceGrotesk/SpaceGrotesk.woff') format('woff');
}
@font-face {
font-family: 'DejaVu';
font-weight: 400;
font-style: normal;
font-display: swap;
src: /*local('DejaVuLGCSerif'),
local('DejaVu LGC Serif'), */
url('/fonts/DejaVu/DejaVuLGCSerif.woff2') format('woff2'),
url('/fonts/DejaVu/DejaVuLGCSerif.woff') format('woff');
}
.serif {
font-family: var(--serif)
}
.sans-serif {
font-family: var(--sans-serif)
}
/*---Text related------------------------------------------------------------------------------*/
b {
font-family: inherit;
font-size: inherit;
}
h1 {
font-family: var(--sans-serif, sans-serif);
}
h2 {
font-size: 2rem;
font-family: var(--sans-serif, sans-serif);
font-weight: bold;
}
h3 {
font-family: var(--sans-serif, sans-serif);
font-size: 1.6rem
}
h4 {
font-family: var(--sans-serif, sans-serif);
font-size: 1.4rem
}
span {
font-family: var(--serif, serif);
font-size: 1.3rem;
height: auto;
width: auto;
}
p {
font-family: var(--serif, serif);
font-size: 1.2rem;
line-height: 170%;
}
b,i,s {
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
label {
font-family: var(--serif, serif);
font-size: 1.2rem;
}
sup {
vertical-align: top;
position: relative;
top: -0.682rem;
}
sub {
vertical-align: top;
position: relative;
top: 0.34rem;
}
a {
font-family: var(--serif, serif);
font-size: 1.638rem;
color: black;
}
a:link { text-decoration: none; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none; }
a:active { text-decoration: none; }
a:focus { text-decoration: none; }
.justify {
text-align: justify;
}
.center {
width: 100%;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.left {
text-align: left;
}
.bold {
font-weight: bold;
}
.margin-end {
margin-bottom: 1rem;
}
.margin-end2 {
margin-bottom: 2rem;
}
.text p, .text li {
font-size: 1.2rem;
font-family: var(--serif);
line-height: 170%;
}
.text li {
margin-left: 1.5rem;
margin-bottom: 0.5rem;
line-height: 140%;
}
.text ul p {
margin-bottom: 0.25rem;
}
.text h2 {
width: max-content;
position: relative;
text-align: center;
margin: auto;
margin-bottom: 1rem;
}
.title-highlight {
position: relative;
}
.title-highlight::before {
position: absolute;
margin-left: -0.68rem;
margin-top: -0.14rem;
width: 2.5rem;
height: 0rem;
content: "";
border-left: 0.19rem solid var(--pink);
border-top: 0.19rem solid var(--pink);
border-radius: 1rem;
}
.title-highlight::after {
position: absolute;
left:0;
top: 0;
margin-left: -0.68rem;
margin-top: -0.14rem;
width: 0rem;
height: 1.7rem;
content: "";
border-left: 0.19rem solid var(--pink);
border-top: 0.19rem solid var(--pink);
border-radius: 1rem;
}
.text h3 {
margin-top: 1rem;
margin-bottom: 0.5rem;
}
.text h4 {
margin-bottom: 0.5rem;
}
.text p {
margin-bottom: 1rem;
}
.text ul>ul>li {
margin-left: 2.5rem;
margin-bottom: 0.5rem;
line-height: 140%;
}
/*---Button/input related--------------------------------------------------------------*/
button {
cursor: pointer;
}
button {
background: transparent;
}
button:focus {
outline:0;
}
input[type="text"],input[type="email"],input[type="password"],input[type="number"] {
font-family: var(--serif, serif);
background-color: white;
border-radius: 0.4rem;
border-color: black;
border: black solid 0.063rem;
padding-left: 0.5rem;
font: 1.3rem var(--serif, serif);
}
input[type="text"] {
-webkit-appearance: textfield;
-moz-appearance: textfield;
appearance: textfield;
color: #353535;
}
input[type="email"] {
-webkit-appearance: textfield;
-moz-appearance: textfield;
appearance: textfield;
font-weight: normal;
color: #353535;
height: 2.7rem;
padding-left: 0.34rem;
}
input[type="password"] {
padding-left: 0.34rem;
-webkit-appearance: textfield;
-moz-appearance: textfield;
appearance: textfield;
font-weight: normal;
color: #353535;
}
input[type="number"] {
-webkit-appearance: textfield;
-moz-appearance: textfield;
appearance: textfield;
color: #353535;
}
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button {
-webkit-appearance: none;
}
/*---Scroll button---------------------------------------------------------------------*/
.scroll-button {
cursor: pointer;
background-color: #EBF7FB;
border-color: #EBF7FB;
height: 3.822rem;
width: 3.822rem;
border-radius: 3.822rem;
border: 0;
margin: 0;
padding-top: 0.505rem;
}
.scroll-button img {
width: 1.9rem;
padding-bottom: 0.4rem;
height: auto;
}
.next {
padding-left: 0.382rem;
}
.prev {
padding-right: 0.382rem;
}
/*---Grid related----------------------------------------------------------------------*/
.column {
display: grid;
grid-auto-flow: column
}
.center-items {
display: flex;
justify-content: center;
}
/*---Fillers-------------------------------------------------------------------------*/
.filler1 {
width: 100%;
height: 0.655rem;
display: inline-block;
}
.filler2 {
width: 100%;
height: 1.263rem;
display: inline-block;
}
.filler3 {
width: 100%;
height: 2.525rem;
display: inline-block;
}
.filler4 {
width: 100%;
height: 3.822rem;
display: inline-block;
}
.filler5 {
width: 100%;
height: 5.05rem;
display: inline-block;
}
.filler6 {
width: 100%;
height: 6.347rem;
display: inline-block;
}
/*---Margins------------------------------------------------------------------------*/
.bmargin1 {
margin-bottom: 0.5rem
}
.bmargin2 {
margin-bottom: 1rem
}
.bmargin3 {
margin-bottom: 1.5rem
}
.tmargin1 {
margin-top: 0.5rem
}
.tmargin2 {
margin-top: 1rem
}
.tmargin3 {
margin-top: 1.5rem
}
/*---Other-------------------------------------------------------------------------*/
.flex-column {
display: flex;
flex-direction: column;
flex-wrap: wrap;
}
.flex-row {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.pane {
background: white;
border: 0;
border-radius: 0.635rem;
box-shadow: 0 0 0.314rem rgb(187, 187, 187);
}
.pane-container {
margin-top: min(3vw, 1rem);
margin-bottom: 3.1rem;
display: grid;
grid-auto-flow: column;
column-gap: 5rem;
}
.pane-centering {
display: flex;
justify-content: center;
}
.main-pane {
position: relative;
margin: auto;
height: min-content;
max-width: 66rem;
width: 66rem;
z-index: 1;
}
.clicked {
background-color: hsla(344, 73%, 57%, 0.25);
}
@media only screen and (max-width: 1117px) {
.main-pane {
width: 100%;
}
}
/*---Scaling-----------------------------------------------------------------------*/
html {
font-size: 16px;
}
@media only screen and (max-width: 660px) {
html {
font-size: 14px;
}
}
@media only screen and (max-width: 570px) {
html {
font-size: 12px;
}
}
@media only screen and (max-width: 470px) {
html {
font-size: 11px;
}
}
@media only screen and (max-width: 400px) {
html {
font-size: 10px;
}
}
@media only screen and (max-width: 360px) {
html {
font-size: 9px;
}
}

View File

@@ -0,0 +1,177 @@
/*---Footer----------------------------------------------------*/
footer {
position: relative;
bottom: 0;
width: 100%;
height: auto;
background: var(--dark-green);
}
footer p, footer a {
font-family: var(--sans-serif);
}
#footer-content-container {
position: relative;
margin: auto;
padding-top: 2rem;
max-width: 116rem;
width: 97vw;
}
#footer-grid-content-container {
display: grid;
margin-left: 2rem;
margin-right: 2rem;
margin-bottom: 1.4rem;
}
.not-logged {
grid-template-columns: auto auto auto 2rem;
}
.logged {
grid-template-columns: auto auto 2rem;
}
footer h2 {
color: #ffffff;
font-size: 1.4rem;
margin-bottom: 0.5rem;
}
#footer-copyright {
position: relative;
color: #ffffff;
margin-left: 2rem;
bottom: 0rem;
font-weight: 400;
font-size: 1.2rem;
height: 3rem;
top: 0rem;
margin-bottom: 0;
}
footer a {
font-size: 1.2rem;
color: #d8d8d8;
}
footer p, footer label {
display: block;
font-size: 1.2rem;
color: #d8d8d8;
font-family: var(--sans-serif,sans-serif);
margin-bottom: 0.5rem;
}
#newsletter-container h3 {
margin-bottom: 0.99rem;
}
#newsletter-container p {
width: 28.665rem;
margin-bottom: 0.48rem;
}
#newsletterEmailInput {
height: 2.5rem;
width: 20.5rem;
border: 0;
border-radius: 0.4rem 0 0 0.4rem;
filter: drop-shadow( 0.07rem 0.14rem 0.07rem rgb(0 0 0 / 0.4));
}
#newsletterEmailInput::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */
color: var(--c,gray);
opacity: 1; /* Firefox */
}
#newsletterEmailButton {
position: absolute;
width: 6.8rem;
height: 2.5rem;
background: var(--pink);
color: #ffffff;
font-family: var(--sans-serif,sans-serif);
font-size: 1.4rem;
border-radius: 0 0.2rem 0.2rem 0;
filter: drop-shadow( 0.07rem 0.14rem 0.07rem rgb(0 0 0 / 0.4));
}
#newsletterEmailButton:active {
background: var(--darker-pink);
}
#contact-us-container {
width: 14rem;
}
#contact-us-container h3 {
margin-bottom: 0.99rem;
}
#legal-info-container {
width: 9.6rem;
}
#legal-info-container h3 {
margin-bottom: 0.99rem;
}
#legal-info-container p {
margin-bottom: 0.48rem;
}
#legal-info-container a {
display: block;
margin-bottom: 0.48rem;
}
#footer-up {
position: absolute;
width: 4.8rem;
height: 4.8rem;
border-radius: 3.4rem;
top: 4rem;
right: 2rem;
background: #ffffff;
}
#footer-up svg {
width: 40%;
height: auto;
}
.grass{
position: absolute;
top: -3.8rem;
--height: 3.82rem;
filter: drop-shadow( 0.07rem 0.14rem 0.07rem rgb(0 0 0 / 0.4));
z-index: -1;
}
@media only screen and (max-width: 1170px) {
.not-logged {
grid-template-rows: auto auto auto auto;
grid-template-columns: auto;
row-gap: 2rem;
}
.logged {
grid-template-rows: auto auto auto;
grid-template-columns: auto;
row-gap: 2rem;
}
#footer-copyright {
height: 1rem;
top: -2rem;
}
#newsletterEmailInput {
width: 18rem;
}
}

View File

View File

@@ -0,0 +1,200 @@
/* Header */
#navbar{
position: relative;
top: 0;
width: min(100%,116rem);
z-index: 1000;
height: 5.26rem;
}
#navbar * {
font-family: var(--sans-serif, sans-serif);
}
/* Logo */
#logo-container {
display: flex;
position: absolute;
margin-left: 1rem;
height: 100%;
max-height: 5.26rem;
color: black;
z-index: 1;
flex-direction: row;
flex-wrap: nowrap;
align-items: center;
}
#navbar-logo {
width: 3.16rem;
object-fit: contain;
}
#navbar-logo-text {
position: relative;
width: auto;
height: 100%;
line-height: 400%;
white-space: nowrap;
text-align: center;
font-size: 1.4rem;
color: #292222;
font-family: var(--sans-serif, sans-serif);
font-weight: 400;
padding-left: 1.2rem;
}
/* Nav menu */
#nav {
position: fixed;
width: 100%;
height: 100%;
background-color: white;
overflow: hidden;
z-index: 0;
}
#menu a{
display: block;
padding: 1.9rem;
color: black;
font-size: 1.4rem;
}
#menu a:hover {
background-color: rgb(220, 220, 220);
}
#menu a:active{
background-color: #f7aec0;
}
#nav{
max-height: 0;
/*transition: max-height .5s ease-out;*/
}
/* Menu Icon */
#hamb{
position: absolute;
cursor: pointer;
right: 0rem;
padding: 2.8rem 2rem;
z-index: 9999;
}/* Style label tag */
#hamb-line {
background: black;
display: block;
height: 2px;
position: relative;
width: 24px;
} /* Style span tag */
#hamb-line::before,
#hamb-line::after{
background: black;
content: '';
display: block;
height: 100%;
position: absolute;
transition: all .2s ease-out;
width: 100%;
}
#hamb-line::before{
top: 5px;
}
#hamb-line::after{
top: -5px;
}
#side-menu {
display: none;
} /* Hide checkbox */
/* Toggle menu icon */
#side-menu:checked ~ nav {
display: block;
max-height: 100%;
padding-top: 5.625rem;
}
#side-menu:checked ~ #logo-container {
position: fixed;
}
#side-menu:checked ~ #hamb {
position: fixed;
}
#side-menu:checked ~ #hamb #hamb-line {
background: transparent;
}
#side-menu:checked ~ #hamb #hamb-line::before {
transform: rotate(-45deg);
top:0;
}
#side-menu:checked ~ #hamb #hamb-line::after {
transform: rotate(45deg);
top:0;
}
#cart-icon {
height: 1.8rem;
pointer-events: none;
}
#menu a:hover div {
filter: saturate(50%) brightness(140%);
}
#menu a:hover svg {
stroke: rgb(127, 127, 127);;
}
#cart-counter {
position: relative;
top: -2.8rem;
left: 1.6rem;
width: 1.3rem;
height: 1.3rem;
border-radius: 3.4rem;
font-family: var(--sans-serif, sans-serif);
font-size: 1rem;
text-align: center;
color: white;
background: var(--pink);
}
/* Responsiveness */
@media only screen and (min-width: 1500px) {
#navbar{
left: 50%;
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}
#nav{
max-height: none;
top: 0;
position: relative;
float: right;
width: fit-content;
background-color: transparent;
}
#menu li{
float: left;
}
#menu a:hover{
background-color: transparent;
color: rgb(127, 127, 127);
}
#hamb{
display: none;
}
}

View File

@@ -0,0 +1,35 @@
export default class CssTools {
static applyCSS(element,id,outerclass,classlisthint) {
// Return if no CSS to apply
if (classlisthint==null || (outerclass==null && id==null)) {
return
}
let outerClassNames = outerclass.split(" ").map(x => "."+x)
let outerCssSelectors = [...outerClassNames,"#"+id]
let styleSheets = document.styleSheets
let l = styleSheets.length
for (let i=0; i<l; i++) {
let sheet = styleSheets[i]
let name = sheet.href.split("/").at(-1).split(".")[0]
if (name===classlisthint) {
for (let outerCss of outerCssSelectors) {
for (let rule of sheet.cssRules) {
if (rule.selectorText==outerCss) {
let styleRule = rule.style
let vals = Object.values(styleRule)
for (let val of vals) {
element.style[val] = styleRule[val]
}
}
}
}
break
}
}
}
}

View File

@@ -0,0 +1,146 @@
// Broadcast array on array
export function bAr(fun,ar1,ar2) {
var result = new Array(ar1.length)
for (var i = 0;i<ar1.length;i++) {
result[i] = fun(ar1[i],ar2[i])
}
return(result)
}
// Broadcast array on a number
export function b(fun,ar1,val) {
var result = new Array(ar1.length)
for (var i = 0;i<ar1.length;i++) {
result[i] = fun(ar1[i],val)
}
return(result)
}
// Broadcast array on a function
export function bFun(fun,ar1) {
var result = new Array(ar1.length)
for (var i = 0;i<ar1.length;i++) {
result[i] = fun(ar1[i])
}
return(result)
}
export function multiply(num1, num2) {
let result = num1 * num2;
return result;
}
export function sum(ar) {
return ar.reduce((a, b) => a + b, 0)
}
export function prod(ar) {
return ar.reduce((a, b) => a * b, 1)
}
export function mean(ar) {
return ar.reduce((a, b) => a + b, 0)/ar.length
}
export function median(values){
if(values.length ===0) throw new Error("No inputs");
values.sort(function(a,b){
return a-b;
});
var half = Math.floor(values.length / 2);
if (values.length % 2)
return values[half];
return (values[half - 1] + values[half]) / 2.0;
}
export function range(start,end, step = start<end ? 1 : -1) {
var arr = []
if (step>0) {
for (var i = start; i <= end; i += step) {
arr.push(i)
}
}
else {
for (var i = start; i >= end; i += step) {
arr.push(i)
}
}
return arr
}
export function numericallyIntegrate(f, a, b, dx) {
// calculate the number of trapezoids
let n = (b - a) / dx
// define the variable for area
let Area = 0
//loop to calculate the area of each trapezoid and sum.
for (let i = 1; i <= n; i++) {
//the x locations of the left and right side of each trapezpoid
let x0 = a + (i-1)*dx
let x1 = a + i*dx
// the area of each trapezoid
let Ai = dx * (f(x0) + f(x1))/ 2.
// cumulatively sum the areas
Area = Area + Ai
}
return Area
}
const randomNormals = () => {
let u1 = 0, u2 = 0;
//Convert [0,1) to (0,1)
while (u1 === 0) u1 = Math.random();
while (u2 === 0) u2 = Math.random();
const R = Math.sqrt(-2.0 * Math.log(u1));
const Θ = 2.0 * Math.PI * u2;
return [R * Math.cos(Θ), R * Math.sin(Θ)];
};
export function randomSkewNormal(ξ, ω, α = 0) {
const [u0, v] = randomNormals();
if (α === 0) {
return ξ + ω * u0;
}
const 𝛿 = α / Math.sqrt(1 + α * α);
const u1 = 𝛿 * u0 + Math.sqrt(1 - 𝛿 * 𝛿) * v;
const z = u0 >= 0 ? u1 : -u1;
return ξ + ω * z;
};
export function percentile(arr, p) {
arr.sort(function(a,b){
return a-b;
});
if (arr.length === 0) return 0;
if (typeof p !== 'number') throw new TypeError('p must be a number');
if (p <= 0) return arr[0];
if (p >= 1) return arr[arr.length - 1];
var index = (arr.length - 1) * p,
lower = Math.floor(index),
upper = lower + 1,
weight = index % 1;
if (upper >= arr.length) return arr[lower];
return arr[lower] * (1 - weight) + arr[upper] * weight;
}
export function smooth(ar,window) {
let windowHalf = window/2
let windowHalf1 = Math.floor(windowHalf)
let windowHalf2 = Math.ceil(windowHalf)
for (let i=windowHalf1;i<ar.length-windowHalf2;i++) {
ar[i] = mean(ar.slice(i-windowHalf1,i+windowHalf2))
}
}

View File

@@ -0,0 +1,112 @@
export function isObject(v) {
return typeof v === 'object' && !Array.isArray(v) && v !== null
}
// Prevents excessive function calling
export function debounce(func, timeout){
let timer;
return (...args) => {
clearTimeout(timer);
timer = setTimeout(() => { func.apply(this, args); }, timeout)
}
}
export function svgFromObject(object) {
var objectDoc = object.contentDocument;
var svgItem = objectDoc.querySelector("path");
return svgItem
}
export function rem2px(rem) {
let fontSizeString = window.getComputedStyle(document.getElementsByTagName("html")[0]).getPropertyValue('font-size')
let fontSize = parseFloat(fontSizeString.substring(0,fontSizeString.length-2))
return fontSize * rem
}
export function px2rem(px) {
let fontSizeString = window.getComputedStyle(document.getElementsByTagName("html")[0]).getPropertyValue('font-size')
let fontSize = parseFloat(fontSizeString.substring(0,fontSizeString.length-2))
return px / fontSize
}
/**
* Uses canvas.measureText to compute and return the width of the given text of given font in pixels.
*
* @param {String} text The text to be rendered.
* @param {String} font The css font descriptor that text is to be rendered with (e.g. "bold 14px verdana").
*
* @see https://stackoverflow.com/questions/118241/calculate-text-width-with-javascript/21015393#21015393
*/
export function getTextWidth(text, font) {
// re-use canvas object for better performance
const canvas = getTextWidth.canvas || (getTextWidth.canvas = document.createElement("canvas"));
const context = canvas.getContext("2d");
context.font = font;
const metrics = context.measureText(text);
return metrics.width;
}
function getCssStyle(element, prop) {
return window.getComputedStyle(element, null).getPropertyValue(prop);
}
export function getCanvasFont(el = document.body) {
const fontWeight = getCssStyle(el, 'font-weight') || 'normal';
const fontSize = getCssStyle(el, 'font-size') || '16px';
const fontFamily = getCssStyle(el, 'font-family') || 'Times New Roman';
return `${fontWeight} ${fontSize} ${fontFamily}`;
}
export function validateAge(event,input,callback) {
event.returnValue = false
var key
if (event.type === 'paste') {
key = event.clipboardData.getData('text/plain');
}
else {
// Handle key press
key = event.keyCode || event.which;
key = String.fromCharCode(key);
}
let keys = ["0","1","2","3","4","5","6","7","8","9"]
if (key in keys) {
var val = parseFloat(input.value)
if (val>120) {
input.value = 120
}
else {
input.value = val
}
if (callback!=undefined) {
callback(input.value)
}
}
}
export function validatePosNumber(event,input,callback,max) {
event.returnValue = false
var key
if (event.type === 'paste') {
key = event.clipboardData.getData('text/plain');
}
else {
// Handle key press
key = event.data;
}
let keys = ["0","1","2","3","4","5","6","7","8","9"]
if (key in keys) {
var val = parseFloat(input.value)
if (val>max) {
input.value = max
}
if (callback!=undefined) {
callback(input.value)
}
}
else {
callback(input.value)
}
}

View File

@@ -0,0 +1,64 @@
// Get data from server
export function getData(path,callback) {
var xhr = new XMLHttpRequest();
xhr.overrideMimeType("application/json");
xhr.open('GET', path, true);
xhr.onreadystatechange = function () {
if (xhr.readyState == 4 && xhr.status == "200") {
if (callback !== undefined) {
callback(xhr.responseText);
}
}
};
xhr.send(null);
}
// Parse JSON from given path into a given variable under a given key
export function getJSON(variable,key,path) {
getData(path,function(response) {
// Parse JSON string into object
variable[key] = JSON.parse(response);
});
}
export function sendData(route,data,callback) {
var xhr = new XMLHttpRequest();
xhr.open("POST", route, true)
xhr.setRequestHeader('Content-Type', 'application/json')
xhr.onreadystatechange = function() {
if(xhr.readyState === XMLHttpRequest.DONE) {
var status = xhr.status;
if (status === 0 || (status >= 200 && status < 400)) {
// The request has been completed successfully
if (callback !== undefined) {
callback(xhr.responseText)
}
} else {
// Oh no! There has been an error with the request!
}
}
};
xhr.send(JSON.stringify(data))
}
export function sendText(route,data,callback) {
var xhr = new XMLHttpRequest();
xhr.open("POST", route, true)
xhr.setRequestHeader('Content-Type', 'text/plain')
xhr.onreadystatechange = function() {
if(xhr.readyState === XMLHttpRequest.DONE) {
var status = xhr.status;
if (status === 0 || (status >= 200 && status < 400)) {
// The request has been completed successfully
if (callback !== undefined) {
callback(xhr.responseText)
}
} else {
// Oh no! There has been an error with the request!
}
}
};
xhr.send(data)
}