Skip to content

Commit

Permalink
Initial Commit
Browse files Browse the repository at this point in the history
  • Loading branch information
mrepol742 committed Sep 19, 2023
1 parent 9dfa72f commit 2b9604c
Show file tree
Hide file tree
Showing 12 changed files with 781 additions and 809 deletions.
108 changes: 55 additions & 53 deletions js/chat.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,56 @@
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/sw.js').then((reg) => {
if (reg.installing) {
console.log("Service worker installing");
} else if (reg.waiting) {
console.log("Service worker installed");
} else if (reg.active) {
console.log("Service worker active");
}
}).catch((err) => {
console.error('Service worker failed: ', err)
});
}
if ("serviceWorker" in navigator) {
navigator.serviceWorker
.register("/sw.js")
.then((reg) => {
if (reg.installing) {
console.log("Service worker installing");
} else if (reg.waiting) {
console.log("Service worker installed");
} else if (reg.active) {
console.log("Service worker active");
}
})
.catch((err) => {
console.error("Service worker failed: ", err);
});
}

function setCookie(cname, cvalue, exdays) {
function setCookie(cname, cvalue, exdays) {
const d = new Date();
d.setTime(d.getTime() + (exdays*24*60*60*1000));
var expires = "expires="+ d.toUTCString();
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1000);
var expires = "expires=" + d.toUTCString();
document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
}
function getCookie(cname) {
}

function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i <ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
var ca = decodedCookie.split(";");
for (var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == " ") {
c = c.substring(1);
}
if (c.indexOf(name) == 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
var pp = getCookie("pp");
try {
var bsAlert = new bootstrap.Toast(document.getElementById("privacypolicy"));
if (pp == "") {
bsAlert.show();
document.getElementById("accpt").onclick = function() {
bsAlert.hide();
setCookie("pp", "pp", 365);
}
}
} catch (err) {}
}

var pp = getCookie("pp");
try {
var bsAlert = new bootstrap.Toast(document.getElementById("privacypolicy"));

if (pp == "") {
bsAlert.show();
document.getElementById("accpt").onclick = function () {
bsAlert.hide();
setCookie("pp", "pp", 365);
};
}
} catch (err) {}

let isLoaded = true;
let chats = document.getElementById("chats");
let messages = [];
Expand Down Expand Up @@ -82,9 +85,9 @@ recognition.onerror = function (event) {
status = true;
console.log(event.error);
if (event.error == "no-speech") {
notif("Please speak....")
notif("Please speak....");
} else {
notif("An error occured. Please try again later.")
notif("An error occured. Please try again later.");
}
};

Expand Down Expand Up @@ -206,7 +209,7 @@ async function sendMsg() {
},
error: function (result) {
console.log(result);
notif("An error occured while parsing data from the server. Please try again later.")
notif("An error occured while parsing data from the server. Please try again later.");
},
});
if (hasChat) {
Expand Down Expand Up @@ -257,7 +260,7 @@ send.addEventListener("click", () => {

voice.addEventListener("click", () => {
if (status) {
notif("Speak now...")
notif("Speak now...");
status = false;
recognition.start();
var audio = new Audio("/audios/transition-base.mp3");
Expand All @@ -278,7 +281,6 @@ txt.addEventListener("keypress", function (evt) {
}
});


txt.addEventListener("input", () => {
if (isPending) {
isPending = false;
Expand Down Expand Up @@ -314,10 +316,10 @@ function notif(msg) {
let p = document.createElement("p");
p.innerText = msg;
body.appendChild(p);
div.appendChild(body)
var bsN = new bootstrap.Toast(div);
div.appendChild(body);
var bsN = new bootstrap.Toast(div);
bsN.show();
$('#notif').on('hidden.bs.toast', function () {
$("#notif").on("hidden.bs.toast", function () {
$("#notif").empty();
})
}
});
}
102 changes: 50 additions & 52 deletions js/flowers.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,50 @@
N = 15
w3 = "http://www.w3.org/"
svgNS = w3 + "2000/svg"
xlinkNS = w3 + "1999/xlink"
with (Math) R = random, S = sin, C = cos

w = svg.width = innerWidth
h = svg.height = innerHeight
this.onresize = function () {
if (w == innerWidth) return
w = svg.width = innerWidth
h = svg.height = innerHeight
svg.setAttribute("viewBox", [0, 0, w, h])
}

Flower = function (x, y, r, dx, dy) {
this.x = x
this.y = y
this.r = 0
this.dx = dx
this.dy = dy
var el = this.element = document.createElementNS(svgNS, 'use')
this.setTransforms()
el.setAttributeNS(xlinkNS, "href", "#flower")
svg.appendChild(el)
}

Flower.prototype.setTransforms = function () {
with (this) element.setAttribute("transform", "translate(" + x + "," + y + ") rotate(" + r + ")")
};


flowers = []
for (i = N; i--;)
flowers.push(new Flower((w * R()) | 0, (h * R()) | 0, 360 * R(), ((R() * 5) | 0) - 2, 1))

~function L(t) {
t /= 1e3
for (i = N; i--;) {
f = flowers[i]
f.r += 1
f.x += f.dx
f.y += f.dy
if (f.x > w + 200) f.x -= w + 400
if (f.x < -200) f.x += w + 400
if (f.y > h + 200) f.y -= h + 400
if (f.y < -200) f.y += h + 400
f.setTransforms()
}

requestAnimationFrame(L)
}(0)
N = 15;
w3 = "http://www.w3.org/";
svgNS = w3 + "2000/svg";
xlinkNS = w3 + "1999/xlink";
with (Math) (R = random), (S = sin), (C = cos);

w = svg.width = innerWidth;
h = svg.height = innerHeight;
this.onresize = function () {
if (w == innerWidth) return;
w = svg.width = innerWidth;
h = svg.height = innerHeight;
svg.setAttribute("viewBox", [0, 0, w, h]);
};

Flower = function (x, y, r, dx, dy) {
this.x = x;
this.y = y;
this.r = 0;
this.dx = dx;
this.dy = dy;
var el = (this.element = document.createElementNS(svgNS, "use"));
this.setTransforms();
el.setAttributeNS(xlinkNS, "href", "#flower");
svg.appendChild(el);
};

Flower.prototype.setTransforms = function () {
with (this) element.setAttribute("transform", "translate(" + x + "," + y + ") rotate(" + r + ")");
};

flowers = [];
for (i = N; i--; ) flowers.push(new Flower((w * R()) | 0, (h * R()) | 0, 360 * R(), ((R() * 5) | 0) - 2, 1));

~(function L(t) {
t /= 1e3;
for (i = N; i--; ) {
f = flowers[i];
f.r += 1;
f.x += f.dx;
f.y += f.dy;
if (f.x > w + 200) f.x -= w + 400;
if (f.x < -200) f.x += w + 400;
if (f.y > h + 200) f.y -= h + 400;
if (f.y < -200) f.y += h + 400;
f.setTransforms();
}

requestAnimationFrame(L);
})(0);
Loading

0 comments on commit 2b9604c

Please sign in to comment.