first commit
This commit is contained in:
195
js/all.js
Normal file
195
js/all.js
Normal file
@ -0,0 +1,195 @@
|
||||
let backup_icon;
|
||||
let backup_name;
|
||||
let socket;
|
||||
if (location.origin.includes("https")) {
|
||||
socket = new WebSocket(`wss://${location.host}/socket`);
|
||||
} else {
|
||||
socket = new WebSocket(`ws://${location.host}/socket`);
|
||||
}
|
||||
socket.addEventListener("open", (event) => {
|
||||
let cookies = document.cookie.split("; ");
|
||||
for (let i = 0; i < cookies.length; i++) {
|
||||
if (cookies[i].trim().startsWith("token=")) {
|
||||
socket.send(cookies[i].trim());
|
||||
}
|
||||
}
|
||||
});
|
||||
socket.addEventListener("message", (event) => {
|
||||
if (event.data == "ping") {
|
||||
socket.send(`pong${location.pathname.includes("/semag/") ? location.pathname.split("/")[2] : ""}`);
|
||||
return;
|
||||
}
|
||||
if (event.data.startsWith("announce.")) {
|
||||
let styles = document.createElement("style");
|
||||
styles.innerHTML = `@import url("https://fonts.googleapis.com/css2?family=Prompt:wght@300&display=swap");.announce {font-family: "Prompt", sans-serif;position: absolute;margin-left: auto;margin-right: auto;top: 10px;z-index: 10000000;background-color: #a53026;padding: 10px;width: max-content;border-radius: 10px;left:0;right:0;border-color: #f74f40;border-width: 5px;border-radius: 10px;border-style: solid;max-width: 60%;font-size: 16px;color: white;}@keyframes FadeIn {0% {opacity: 0;}100% {opacity: 1;}}@keyframes FadeOut {0% {opacity: 1;}100% {opacity: 0;}}`;
|
||||
let announcement = document.createElement("div");
|
||||
announcement.innerText = event.data.substring(9);
|
||||
announcement.setAttribute("class", "announce");
|
||||
announcement.style.opacity = "0";
|
||||
announcement.style.animation = "FadeIn 1s ease-in-out forwards";
|
||||
document.head.appendChild(styles);
|
||||
document.body.appendChild(announcement);
|
||||
setTimeout(() => {
|
||||
announcement.style.animation = "FadeOut 1s ease-in-out forwards";
|
||||
setTimeout(() => {
|
||||
announcement.remove();
|
||||
styles.remove();
|
||||
}, 1000);
|
||||
}, 14000);
|
||||
}
|
||||
});
|
||||
|
||||
function setCloak(name, icon) {
|
||||
var tabicon = getCookie("tabicon");
|
||||
if (tabicon || icon) {
|
||||
var link = document.querySelector("link[rel~='icon']");
|
||||
if (link) {
|
||||
if (link.href != icon) backup_icon = link;
|
||||
while (document.querySelector("link[rel~='icon']")) {
|
||||
document.querySelector("link[rel~='icon']").remove();
|
||||
}
|
||||
}
|
||||
var link = document.querySelector("link[rel~='shortcut icon']");
|
||||
if (link) {
|
||||
if (link.href != icon) backup_icon = link;
|
||||
while (document.querySelector("link[rel~='shortcut icon']")) {
|
||||
document.querySelector("link[rel~='shortcut icon']").remove();
|
||||
}
|
||||
}
|
||||
link = document.createElement("link");
|
||||
link.rel = "icon";
|
||||
document.head.appendChild(link);
|
||||
link.href = tabicon;
|
||||
if (name) {
|
||||
link.href = icon;
|
||||
}
|
||||
}
|
||||
|
||||
var tabname = getCookie("tabname");
|
||||
backup_name = document.title;
|
||||
if (tabname) {
|
||||
document.title = tabname;
|
||||
}
|
||||
if (name) {
|
||||
document.title = name;
|
||||
}
|
||||
panicMode();
|
||||
}
|
||||
if (getCookie("debugging") == 1) {
|
||||
const debugscript = document.createElement("script");
|
||||
debugscript.setAttribute("src", "/js/debug.js");
|
||||
document.head.append(debugscript);
|
||||
}
|
||||
function getCookie(cname) {
|
||||
let name = cname + "=";
|
||||
let decodedCookie = decodeURIComponent(document.cookie);
|
||||
let ca = decodedCookie.split(";");
|
||||
for (let i = 0; i < ca.length; i++) {
|
||||
let c = ca[i];
|
||||
while (c.charAt(0) == " ") {
|
||||
c = c.substring(1);
|
||||
}
|
||||
if (c.indexOf(name) == 0) {
|
||||
return c.substring(name.length, c.length);
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
let listofchars = "";
|
||||
document.addEventListener("keydown", (e) => {
|
||||
listofchars = listofchars + e.key;
|
||||
if (listofchars.length > 20) {
|
||||
listofchars = listofchars.substring(e.key.length);
|
||||
}
|
||||
if (listofchars.includes("safemode")) {
|
||||
window.location.href = panicurl;
|
||||
listofchars = "";
|
||||
} else if (listofchars.includes("debugplz")) {
|
||||
if (getCookie("debugging") == 1) {
|
||||
document.cookie = "debugging=0;";
|
||||
alert("debugging off!");
|
||||
} else {
|
||||
document.cookie = "debugging=1";
|
||||
alert("debugging on!");
|
||||
}
|
||||
listofchars = "";
|
||||
}
|
||||
});
|
||||
function panicMode() {
|
||||
panicurl = getCookie("panicurl");
|
||||
if (panicurl == "") {
|
||||
panicurl = "https://google.com";
|
||||
}
|
||||
}
|
||||
document.addEventListener(
|
||||
"DOMContentLoaded",
|
||||
() => {
|
||||
setCloak();
|
||||
let plausible = document.createElement("script");
|
||||
plausible.setAttribute("event-domain", location.host)
|
||||
plausible.setAttribute("defer", "");
|
||||
plausible.setAttribute("src", "/js/analytics.js");
|
||||
plausible.setAttribute("data-domain", "selenite.cc");
|
||||
document.head.appendChild(plausible);
|
||||
},
|
||||
false
|
||||
);
|
||||
if (location.pathname.substring(1).includes("semag") && localStorage.getItem("selenite.blockClose") == "true") {
|
||||
window.onbeforeunload = function () {
|
||||
return "";
|
||||
};
|
||||
}
|
||||
addEventListener("visibilitychange", (e) => {
|
||||
if (localStorage.getItem("selenite.tabDisguise") == "true") {
|
||||
if (document.visibilityState === "hidden") {
|
||||
setCloak("Google", "https://www.google.com/favicon.ico");
|
||||
} else {
|
||||
if (!backup_icon) {
|
||||
icon = document.createElement("link");
|
||||
icon.rel = "icon";
|
||||
|
||||
var link = document.querySelector("link[rel~='icon']");
|
||||
if (link) {
|
||||
backup_icon = link;
|
||||
while (document.querySelector("link[rel~='icon']")) {
|
||||
document.querySelector("link[rel~='icon']").remove();
|
||||
}
|
||||
}
|
||||
var link = document.querySelector("link[rel~='shortcut icon']");
|
||||
if (link) {
|
||||
backup_icon = link;
|
||||
while (document.querySelector("link[rel~='shortcut icon']")) {
|
||||
document.querySelector("link[rel~='shortcut icon']").remove();
|
||||
}
|
||||
}
|
||||
document.head.appendChild(icon);
|
||||
icon.href = location.origin + "/favicon.ico";
|
||||
} else {
|
||||
document.head.appendChild(backup_icon);
|
||||
}
|
||||
document.title = backup_name;
|
||||
}
|
||||
}
|
||||
});
|
||||
var polyfillScript = document.createElement("script");
|
||||
polyfillScript.src = "https://cdnjs.cloudflare.com/polyfill/v3/polyfill.min.js?version=4.8.0";
|
||||
document.head.appendChild(polyfillScript);
|
||||
function fps() {
|
||||
var script = document.createElement("script");
|
||||
script.onload = function () {
|
||||
var stats = new Stats();
|
||||
document.body.appendChild(stats.dom);
|
||||
requestAnimationFrame(function loop() {
|
||||
stats.update();
|
||||
requestAnimationFrame(loop);
|
||||
});
|
||||
|
||||
localStorage.setItem("fps", true);
|
||||
};
|
||||
script.src = "https://cdn.jsdelivr.net/gh/mrdoob/stats.js@master/build/stats.min.js";
|
||||
document.head.appendChild(script);
|
||||
}
|
||||
|
||||
if (localStorage.getItem("fps")) {
|
||||
fps();
|
||||
}
|
1
js/all.min.js
vendored
Normal file
1
js/all.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
js/analytics.js
Normal file
1
js/analytics.js
Normal file
@ -0,0 +1 @@
|
||||
!function(){"use strict";var r=window.location,o=window.document,l=o.currentScript,s=l.getAttribute("data-api")||new URL(l.src).origin+"/api/event";function u(t,e){t&&console.warn("Ignoring Event: "+t),e&&e.callback&&e.callback()}function t(t,e){if(/^localhost$|^127(\.[0-9]+){0,2}\.[0-9]+$|^\[::1?\]$/.test(r.hostname)||"file:"===r.protocol)return u("localhost",e);if((window._phantom||window.__nightmare||window.navigator.webdriver||window.Cypress)&&!window.__plausible)return u(null,e);try{if("true"===window.localStorage.plausible_ignore)return u("localStorage flag",e)}catch(t){}var n={},t=(n.n=t,n.u=r.href,n.d=l.getAttribute("data-domain"),n.r=o.referrer||null,e&&e.meta&&(n.m=JSON.stringify(e.meta)),e&&e.props&&(n.p=e.props),l.getAttributeNames().filter(function(t){return"event-"===t.substring(0,6)})),i=n.p||{},a=(t.forEach(function(t){var e=t.replace("event-",""),t=l.getAttribute(t);i[e]=i[e]||t}),n.p=i,new XMLHttpRequest);a.open("POST",s,!0),a.setRequestHeader("Content-Type","text/plain"),a.send(JSON.stringify(n)),a.onreadystatechange=function(){4===a.readyState&&e&&e.callback&&e.callback({status:a.status})}}var e=window.plausible&&window.plausible.q||[];window.plausible=t;for(var n,i=0;i<e.length;i++)t.apply(this,e[i]);function a(){n!==r.pathname&&(n=r.pathname,t("pageview"))}var p,c=window.history;c.pushState&&(p=c.pushState,c.pushState=function(){p.apply(this,arguments),a()},window.addEventListener("popstate",a)),"prerender"===o.visibilityState?o.addEventListener("visibilitychange",function(){n||"visible"!==o.visibilityState||a()}):a()}();
|
197
js/apps.js
Normal file
197
js/apps.js
Normal file
@ -0,0 +1,197 @@
|
||||
$.getJSON("/data/apps.json", function (data) {
|
||||
if (document.readyState === "complete") {
|
||||
loadGames(data);
|
||||
} else {
|
||||
let areGamesReady = setInterval(() => {
|
||||
if (document.readyState === "complete") {
|
||||
loadGames(data);
|
||||
clearInterval(areGamesReady);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
function loadGames(data) {
|
||||
starredgames = getCookie("starred");
|
||||
if (!starredgames) {
|
||||
starredgames = [];
|
||||
} else {
|
||||
starredgames = JSON.parse(decodeURIComponent(getCookie("starred")));
|
||||
}
|
||||
$("#gamesearch").prop({
|
||||
placeholder: "Click here to search through our " + data.length + " apps!",
|
||||
});
|
||||
data.sort(dynamicSort("name"));
|
||||
gamelist = data;
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let $element = $("<a>")
|
||||
.attr({
|
||||
class: "game",
|
||||
id: data[i].directory,
|
||||
recommended: data[i].recommended,
|
||||
href: "sppa/" + data[i].directory + "/index.html",
|
||||
})
|
||||
.data("recommended", data[i].recommended)
|
||||
.append(
|
||||
$("<img>").prop({
|
||||
src: "sppa/" + data[i].directory + "/" + data[i].image,
|
||||
alt: data[i].name + " logo",
|
||||
})
|
||||
)
|
||||
.append($("<h1>").text(data[i].name))
|
||||
.append(
|
||||
$("<img>").prop({
|
||||
src: "img/star.svg",
|
||||
alt: "star",
|
||||
class: "star",
|
||||
})
|
||||
);
|
||||
|
||||
if (starredgames.includes(data[i].directory)) {
|
||||
$element.find("img.star").attr("id", "starred");
|
||||
$element.find("img.star").attr("src", "img/star-fill.svg");
|
||||
let $pinnedelement = $element.clone();
|
||||
$("#pinned").append($pinnedelement);
|
||||
if ($("#pinnedmessage")) {
|
||||
$("#pinnedmessage").hide();
|
||||
}
|
||||
}
|
||||
|
||||
$("#games").append($element);
|
||||
}
|
||||
$("#games #message").remove();
|
||||
|
||||
if ((search = 1)) {
|
||||
var txt = $("#gamesearch").val();
|
||||
if (txt == "") {
|
||||
$("#games .suggest").show();
|
||||
} else {
|
||||
$("#games .suggest").hide();
|
||||
}
|
||||
$("#games .game").hide();
|
||||
$("#games .game").each(function () {
|
||||
if ($(this).text().toUpperCase().indexOf(txt.toUpperCase()) != -1 || $(this).attr("id").toUpperCase().indexOf(txt.toUpperCase()) != -1) {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// starred games
|
||||
let starred;
|
||||
$(document).on("click", "img.star", function (event) {
|
||||
|
||||
});
|
||||
$(document).on("click", ".game", function (event) {
|
||||
if ($(event.target).is("img.star")) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (!$(event.target).attr("id")) {
|
||||
$(event.target).prop({ id: "starred" });
|
||||
$(event.target).prop({ src: "img/star-fill.svg" });
|
||||
starred = Cookies.get("starred");
|
||||
if (starred) {
|
||||
starred = JSON.parse(starred);
|
||||
} else {
|
||||
starred = [];
|
||||
}
|
||||
starred.push($(this).attr("id"));
|
||||
Cookies.set("starred", JSON.stringify(starred));
|
||||
$element = $(this).clone();
|
||||
$("#pinned").append($element);
|
||||
$("#pinnedmessage").hide();
|
||||
temp = $("#pinned")[0].childNodes;
|
||||
pinnedarray = [...temp];
|
||||
pinnedarray.sort(dynamicSort("id"));
|
||||
$("#pinned").empty();
|
||||
for (let i = 0; i < pinnedarray.length; i++) {
|
||||
pinnedarraynodes = pinnedarray[i].childNodes;
|
||||
pinnedarraynodes = [...pinnedarraynodes];
|
||||
let $element = $("<div>")
|
||||
.prop({
|
||||
class: "game",
|
||||
id: pinnedarray[i].id,
|
||||
})
|
||||
.append(
|
||||
$("<img>").prop({
|
||||
src: pinnedarraynodes[0].src,
|
||||
alt: pinnedarraynodes[0].alt,
|
||||
class: "gameicon",
|
||||
})
|
||||
)
|
||||
.append($("<h1>").text(pinnedarraynodes[1].innerHTML))
|
||||
.append(
|
||||
$("<img>").prop({
|
||||
src: "img/star-fill.svg",
|
||||
alt: "star",
|
||||
class: "star",
|
||||
id: "starred",
|
||||
})
|
||||
);
|
||||
$("#pinned").append($element);
|
||||
}
|
||||
} else {
|
||||
$(event.target).removeAttr("id");
|
||||
$(event.target).attr("src", "img/star.svg");
|
||||
$thisdiv = "#" + $(this).attr("id");
|
||||
$thisdiv = $thisdiv.replace(".", "\\.");
|
||||
starred = Cookies.get("starred");
|
||||
starred = JSON.parse(starred);
|
||||
ourindex = starred.indexOf($(this).attr("id"));
|
||||
starred.splice(ourindex, 1);
|
||||
Cookies.set("starred", JSON.stringify(starred));
|
||||
$("#pinned " + $thisdiv).remove();
|
||||
if ($("#pinned").is(":empty")) {
|
||||
$("#pinnedmessage").show();
|
||||
}
|
||||
$($thisdiv + " #starred").attr("src", "img/star.svg");
|
||||
$($thisdiv + " #starred").removeAttr("id");
|
||||
}
|
||||
}
|
||||
});
|
||||
$(document).on("click", "#game img .star", function (event) {
|
||||
event.stopPropagation();
|
||||
$(this).prop({ class: "material-symbols-outlined fill" });
|
||||
});
|
||||
}
|
||||
|
||||
function redirectGame(dir) {
|
||||
window.location.href = window.location.origin + "/sppa/" + dir + "/index.html";
|
||||
}
|
||||
function dynamicSort(property) {
|
||||
var sortOrder = 1;
|
||||
|
||||
if (property[0] === "-") {
|
||||
sortOrder = -1;
|
||||
property = property.substr(1);
|
||||
}
|
||||
return function (a, b) {
|
||||
if (sortOrder == -1) {
|
||||
return b[property].localeCompare(a[property]);
|
||||
} else {
|
||||
return a[property].localeCompare(b[property]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function selectRandomGame() {
|
||||
redirectGame(gamelist[Math.floor(Math.random() * gamelist.length - 1)].directory);
|
||||
}
|
||||
|
||||
let viewrecommended = 0;
|
||||
function recommendedGames() {
|
||||
if (viewrecommended == 0) {
|
||||
$("#games .game").hide();
|
||||
$("#games .game").each(function () {
|
||||
if ($(this).attr("recommended")) {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
$("#recommend").text("Click to view all apps again!");
|
||||
viewrecommended = 1;
|
||||
} else {
|
||||
$("#games .game").hide();
|
||||
$("#games .game").show();
|
||||
viewrecommended = 0;
|
||||
$("#recommend").text("Click to view recommended apps!");
|
||||
}
|
||||
}
|
66
js/asteroids.js
Normal file
66
js/asteroids.js
Normal file
@ -0,0 +1,66 @@
|
||||
|
||||
(function(){function Asteroids(){if(!window.ASTEROIDS)
|
||||
window.ASTEROIDS={enemiesKilled:0};function Vector(x,y){if(typeof x=='Object'){this.x=x.x;this.y=x.y;}else{this.x=x;this.y=y;}};Vector.prototype={cp:function(){return new Vector(this.x,this.y);},mul:function(factor){this.x*=factor;this.y*=factor;return this;},mulNew:function(factor){return new Vector(this.x*factor,this.y*factor);},add:function(vec){this.x+=vec.x;this.y+=vec.y;return this;},addNew:function(vec){return new Vector(this.x+vec.x,this.y+vec.y);},sub:function(vec){this.x-=vec.x;this.y-=vec.y;return this;},subNew:function(vec){return new Vector(this.x-vec.x,this.y-vec.y);},rotate:function(angle){var x=this.x,y=this.y;this.x=x*Math.cos(angle)-Math.sin(angle)*y;this.y=x*Math.sin(angle)+Math.cos(angle)*y;return this;},rotateNew:function(angle){return this.cp().rotate(angle);},setAngle:function(angle){var l=this.len();this.x=Math.cos(angle)*l;this.y=Math.sin(angle)*l;return this;},setAngleNew:function(angle){return this.cp().setAngle(angle);},setLength:function(length){var l=this.len();if(l)this.mul(length/l);else this.x=this.y=length;return this;},setLengthNew:function(length){return this.cp().setLength(length);},normalize:function(){var l=this.len();this.x/=l;this.y/=l;return this;},normalizeNew:function(){return this.cp().normalize();},angle:function(){return Math.atan2(this.y,this.x);},collidesWith:function(rect){return this.x>rect.x&&this.y>rect.y&&this.x<rect.x+rect.width&&this.y<rect.y+rect.height;},len:function(){var l=Math.sqrt(this.x*this.x+this.y*this.y);if(l<0.005&&l>-0.005)return 0;return l;},is:function(test){return typeof test=='object'&&this.x==test.x&&this.y==test.y;},toString:function(){return'[Vector('+this.x+', '+this.y+') angle: '+this.angle()+', length: '+this.len()+']';}};function Line(p1,p2){this.p1=p1;this.p2=p2;};Line.prototype={shift:function(pos){this.p1.add(pos);this.p2.add(pos);},intersectsWithRect:function(rect){var LL=new Vector(rect.x,rect.y+rect.height);var UL=new Vector(rect.x,rect.y);var LR=new Vector(rect.x+rect.width,rect.y+rect.height);var UR=new Vector(rect.x+rect.width,rect.y);if(this.p1.x>LL.x&&this.p1.x<UR.x&&this.p1.y<LL.y&&this.p1.y>UR.y&&this.p2.x>LL.x&&this.p2.x<UR.x&&this.p2.y<LL.y&&this.p2.y>UR.y)return true;if(this.intersectsLine(new Line(UL,LL)))return true;if(this.intersectsLine(new Line(LL,LR)))return true;if(this.intersectsLine(new Line(UL,UR)))return true;if(this.intersectsLine(new Line(UR,LR)))return true;return false;},intersectsLine:function(line2){var v1=this.p1,v2=this.p2;var v3=line2.p1,v4=line2.p2;var denom=((v4.y-v3.y)*(v2.x-v1.x))-((v4.x-v3.x)*(v2.y-v1.y));var numerator=((v4.x-v3.x)*(v1.y-v3.y))-((v4.y-v3.y)*(v1.x-v3.x));var numerator2=((v2.x-v1.x)*(v1.y-v3.y))-((v2.y-v1.y)*(v1.x-v3.x));if(denom==0.0){return false;}
|
||||
var ua=numerator/denom;var ub=numerator2/denom;return(ua>=0.0&&ua<=1.0&&ub>=0.0&&ub<=1.0);}};var that=this;var isIE=!!window.ActiveXObject;var w=document.documentElement.clientWidth,h=document.documentElement.clientHeight;var playerWidth=20,playerHeight=30;var playerVerts=[[-1*playerHeight/2,-1*playerWidth/2],[-1*playerHeight/2,playerWidth/2],[playerHeight/2,0]];var ignoredTypes=['HTML','HEAD','BODY','SCRIPT','TITLE','META','STYLE','LINK','SHAPE','LINE','GROUP','IMAGE','STROKE','FILL','SKEW','PATH','TEXTPATH'];var hiddenTypes=['BR','HR'];var FPS=50;var acc=300;var maxSpeed=600;var rotSpeed=360;var bulletSpeed=700;var particleSpeed=400;var timeBetweenFire=150;var timeBetweenBlink=250;var timeBetweenEnemyUpdate=isIE?10000:2000;var bulletRadius=2;var maxParticles=isIE?20:40;var maxBullets=isIE?10:20;this.flame={r:[],y:[]};this.toggleBlinkStyle=function(){if(this.updated.blink.isActive){removeClass(document.body,'ASTEROIDSBLINK');}else{addClass(document.body,'ASTEROIDSBLINK');}
|
||||
this.updated.blink.isActive=!this.updated.blink.isActive;};addStylesheet(".ASTEROIDSBLINK .ASTEROIDSYEAHENEMY","outline: 2px dotted red;");this.pos=new Vector(100,100);this.lastPos=false;this.vel=new Vector(0,0);this.dir=new Vector(0,1);this.keysPressed={};this.firedAt=false;this.updated={enemies:false,flame:new Date().getTime(),blink:{time:0,isActive:false}};this.scrollPos=new Vector(0,0);this.bullets=[];this.enemies=[];this.dying=[];this.totalEnemies=0;this.particles=[];function updateEnemyIndex(){for(var i=0,enemy;enemy=that.enemies[i];i++)
|
||||
removeClass(enemy,"ASTEROIDSYEAHENEMY");var all=document.body.getElementsByTagName('*');that.enemies=[];for(var i=0,el;el=all[i];i++){if(indexOf(ignoredTypes,el.tagName.toUpperCase())==-1&&el.prefix!='g_vml_'&&hasOnlyTextualChildren(el)&&el.className!="ASTEROIDSYEAH"&&el.offsetHeight>0){el.aSize=size(el);that.enemies.push(el);addClass(el,"ASTEROIDSYEAHENEMY");if(!el.aAdded){el.aAdded=true;that.totalEnemies++;}}}};updateEnemyIndex();var createFlames;(function(){var rWidth=playerWidth,rIncrease=playerWidth*0.1,yWidth=playerWidth*0.6,yIncrease=yWidth*0.2,halfR=rWidth/2,halfY=yWidth/2,halfPlayerHeight=playerHeight/2;createFlames=function(){that.flame.r=[[-1*halfPlayerHeight,-1*halfR]];that.flame.y=[[-1*halfPlayerHeight,-1*halfY]];for(var x=0;x<rWidth;x+=rIncrease){that.flame.r.push([-random(2,7)-halfPlayerHeight,x-halfR]);}
|
||||
that.flame.r.push([-1*halfPlayerHeight,halfR]);for(var x=0;x<yWidth;x+=yIncrease){that.flame.y.push([-random(2,7)-halfPlayerHeight,x-halfY]);}
|
||||
that.flame.y.push([-1*halfPlayerHeight,halfY]);};})();createFlames();function radians(deg){return deg*0.0174532925;};function degrees(rad){return rad*57.2957795;};function random(from,to){return Math.floor(Math.random()*(to+1)+from);};function code(name){var table={'up':38,'down':40,'left':37,'right':39,'esc':27};if(table[name])return table[name];return name.charCodeAt(0);};function boundsCheck(vec){if(vec.x>w)
|
||||
vec.x=0;else if(vec.x<0)
|
||||
vec.x=w;if(vec.y>h)
|
||||
vec.y=0;else if(vec.y<0)
|
||||
vec.y=h;};function size(element){var el=element,left=0,top=0;do{left+=el.offsetLeft||0;top+=el.offsetTop||0;el=el.offsetParent;}while(el);return{x:left,y:top,width:element.offsetWidth||10,height:element.offsetHeight||10};};function addEvent(obj,type,fn){if(obj.addEventListener)
|
||||
obj.addEventListener(type,fn,false);else if(obj.attachEvent){obj["e"+type+fn]=fn;obj[type+fn]=function(){obj["e"+type+fn](window.event);}
|
||||
obj.attachEvent("on"+type,obj[type+fn]);}}
|
||||
function removeEvent(obj,type,fn){if(obj.removeEventListener)
|
||||
obj.removeEventListener(type,fn,false);else if(obj.detachEvent){obj.detachEvent("on"+type,obj[type+fn]);obj[type+fn]=null;obj["e"+type+fn]=null;}}
|
||||
function arrayRemove(array,from,to){var rest=array.slice((to||from)+1||array.length);array.length=from<0?array.length+from:from;return array.push.apply(array,rest);};function applyVisibility(vis){for(var i=0,p;p=window.ASTEROIDSPLAYERS[i];i++){p.gameContainer.style.visibility=vis;}}
|
||||
function getElementFromPoint(x,y){applyVisibility('hidden');var element=document.elementFromPoint(x,y);if(!element){applyVisibility('visible');return false;}
|
||||
if(element.nodeType==3)
|
||||
element=element.parentNode;applyVisibility('visible');return element;};function addParticles(startPos){var time=new Date().getTime();var amount=maxParticles;for(var i=0;i<amount;i++){that.particles.push({dir:(new Vector(Math.random()*20-10,Math.random()*20-10)).normalize(),pos:startPos.cp(),cameAlive:time});}};function setScore(){that.points.innerHTML=window.ASTEROIDS.enemiesKilled*10;};function hasOnlyTextualChildren(element){if(element.offsetLeft<-100&&element.offsetWidth>0&&element.offsetHeight>0)return false;if(indexOf(hiddenTypes,element.tagName)!=-1)return true;if(element.offsetWidth==0&&element.offsetHeight==0)return false;for(var i=0;i<element.childNodes.length;i++){if(indexOf(hiddenTypes,element.childNodes[i].tagName)==-1&&element.childNodes[i].childNodes.length!=0)return false;}
|
||||
return true;};function indexOf(arr,item,from){if(arr.indexOf)return arr.indexOf(item,from);var len=arr.length;for(var i=(from<0)?Math.max(0,len+from):from||0;i<len;i++){if(arr[i]===item)return i;}
|
||||
return-1;};function addClass(element,className){if(element.className.indexOf(className)==-1)
|
||||
element.className=(element.className+' '+className).replace(/\s+/g,' ').replace(/^\s+|\s+$/g,'');};function removeClass(element,className){element.className=element.className.replace(new RegExp('(^|\\s)'+className+'(?:\\s|$)'),'$1');};function addStylesheet(selector,rules){var stylesheet=document.createElement('style');stylesheet.type='text/css';stylesheet.rel='stylesheet';stylesheet.id='ASTEROIDSYEAHSTYLES';try{stylesheet.innerHTML=selector+"{"+rules+"}";}catch(e){stylesheet.styleSheet.addRule(selector,rules);}
|
||||
document.getElementsByTagName("head")[0].appendChild(stylesheet);};function removeStylesheet(name){var stylesheet=document.getElementById(name);if(stylesheet){stylesheet.parentNode.removeChild(stylesheet);}};this.gameContainer=document.createElement('div');this.gameContainer.className='ASTEROIDSYEAH';document.body.appendChild(this.gameContainer);this.canvas=document.createElement('canvas');this.canvas.setAttribute('width',w);this.canvas.setAttribute('height',h);this.canvas.className='ASTEROIDSYEAH';with(this.canvas.style){width=w+"px";height=h+"px";position="fixed";top="0px";left="0px";bottom="0px";right="0px";zIndex="10000";}
|
||||
if(typeof G_vmlCanvasManager!='undefined'){this.canvas=G_vmlCanvasManager.initElement(this.canvas);if(!this.canvas.getContext){alert("So... you are using IE? Sorry but at the moment WebsiteAsteroids only supports Firefox");}}else{if(!this.canvas.getContext){alert('This program does not yet support your browser. Please join me at http://github.com/erkie/erkie.github.com if you think you can help');}}
|
||||
addEvent(this.canvas,'mousedown',function(e){e=e||window.event;var message=document.createElement('span');message.style.position='absolute';message.style.border='1px solid #999';message.style.background='white';message.style.color="black";message.innerHTML='Press Esc to quit';document.body.appendChild(message);var x=e.pageX||(e.clientX+document.documentElement.scrollLeft);var y=e.pageY||(e.clientY+document.documentElement.scrollTop);message.style.left=x-message.offsetWidth/2+'px';message.style.top=y-message.offsetHeight/2+'px';setTimeout(function(){try{message.parentNode.removeChild(message);}catch(e){}},1000);});var eventResize=function(){that.canvas.style.display="none";w=document.documentElement.clientWidth;h=document.documentElement.clientHeight;that.canvas.setAttribute('width',w);that.canvas.setAttribute('height',h);with(that.canvas.style){display="block";width=w+"px";height=h+"px";}};addEvent(window,'resize',eventResize);this.gameContainer.appendChild(this.canvas);this.ctx=this.canvas.getContext("2d");this.ctx.fillStyle="black";this.ctx.strokeStyle="black";if(!document.getElementById('ASTEROIDS-NAVIGATION')){this.navigation=document.createElement('div');this.navigation.id="ASTEROIDS-NAVIGATION";this.navigation.className="ASTEROIDSYEAH";with(this.navigation.style){fontFamily="Arial,sans-serif";position="fixed";zIndex="10001";bottom="10px";right="10px";textAlign="right";}
|
||||
this.navigation.innerHTML="(press esc to quit) ";this.gameContainer.appendChild(this.navigation);this.points=document.createElement('span');this.points.id='ASTEROIDS-POINTS';this.points.style.font="28pt Arial, sans-serif";this.points.style.fontWeight="bold";this.points.className="ASTEROIDSYEAH";this.navigation.appendChild(this.points);}else{this.navigation=document.getElementById('ASTEROIDS-NAVIGATION');this.points=document.getElementById('ASTEROIDS-POINTS');}
|
||||
setScore();if(typeof G_vmlCanvasManager!='undefined'){var children=this.canvas.getElementsByTagName('*');for(var i=0,c;c=children[i];i++)
|
||||
addClass(c,'ASTEROIDSYEAH');}
|
||||
var eventKeydown=function(event){event=event||window.event;that.keysPressed[event.keyCode]=true;switch(event.keyCode){case code(' '):that.firedAt=1;break;}
|
||||
if(indexOf([code('up'),code('down'),code('right'),code('left'),code(' '),code('B'),code('W'),code('A'),code('S'),code('D')],event.keyCode)!=-1){if(event.preventDefault)
|
||||
event.preventDefault();if(event.stopPropagation)
|
||||
event.stopPropagation();event.returnValue=false;event.cancelBubble=true;return false;}};addEvent(document,'keydown',eventKeydown);var eventKeypress=function(event){event=event||window.event;if(indexOf([code('up'),code('down'),code('right'),code('left'),code(' '),code('W'),code('A'),code('S'),code('D')],event.keyCode||event.which)!=-1){if(event.preventDefault)
|
||||
event.preventDefault();if(event.stopPropagation)
|
||||
event.stopPropagation();event.returnValue=false;event.cancelBubble=true;return false;}};addEvent(document,'keypress',eventKeypress);var eventKeyup=function(event){event=event||window.event;that.keysPressed[event.keyCode]=false;if(indexOf([code('up'),code('down'),code('right'),code('left'),code(' '),code('B'),code('W'),code('A'),code('S'),code('D')],event.keyCode)!=-1){if(event.preventDefault)
|
||||
event.preventDefault();if(event.stopPropagation)
|
||||
event.stopPropagation();event.returnValue=false;event.cancelBubble=true;return false;}};addEvent(document,'keyup',eventKeyup);this.ctx.clear=function(){this.clearRect(0,0,w,h);};this.ctx.clear();this.ctx.drawLine=function(xFrom,yFrom,xTo,yTo){this.beginPath();this.moveTo(xFrom,yFrom);this.lineTo(xTo,yTo);this.lineTo(xTo+1,yTo+1);this.closePath();this.fill();};this.ctx.tracePoly=function(verts){this.beginPath();this.moveTo(verts[0][0],verts[0][1]);for(var i=1;i<verts.length;i++)
|
||||
this.lineTo(verts[i][0],verts[i][1]);this.closePath();};this.ctx.drawPlayer=function(){this.save();this.translate(that.pos.x,that.pos.y);this.rotate(that.dir.angle());this.tracePoly(playerVerts);this.fillStyle="white";this.fill();this.tracePoly(playerVerts);this.stroke();this.restore();};var PI_SQ=Math.PI*2;this.ctx.drawBullets=function(bullets){for(var i=0;i<bullets.length;i++){this.beginPath();this.arc(bullets[i].pos.x,bullets[i].pos.y,bulletRadius,0,PI_SQ,true);this.closePath();this.fill();}};var randomParticleColor=function(){return(['red','yellow'])[random(0,1)];};this.ctx.drawParticles=function(particles){var oldColor=this.fillStyle;for(var i=0;i<particles.length;i++){this.fillStyle=randomParticleColor();this.drawLine(particles[i].pos.x,particles[i].pos.y,particles[i].pos.x-particles[i].dir.x*10,particles[i].pos.y-particles[i].dir.y*10);}
|
||||
this.fillStyle=oldColor;};this.ctx.drawFlames=function(flame){this.save();this.translate(that.pos.x,that.pos.y);this.rotate(that.dir.angle());var oldColor=this.strokeStyle;this.strokeStyle="red";this.tracePoly(flame.r);this.stroke();this.strokeStyle="yellow";this.tracePoly(flame.y);this.stroke();this.strokeStyle=oldColor;this.restore();}
|
||||
addParticles(this.pos);addClass(document.body,'ASTEROIDSYEAH');var isRunning=true;var lastUpdate=new Date().getTime();this.update=function(){var forceChange=false;var nowTime=new Date().getTime();var tDelta=(nowTime-lastUpdate)/1000;lastUpdate=nowTime;var drawFlame=false;if(nowTime-this.updated.flame>50){createFlames();this.updated.flame=nowTime;}
|
||||
this.scrollPos.x=window.pageXOffset||document.documentElement.scrollLeft;this.scrollPos.y=window.pageYOffset||document.documentElement.scrollTop;if((this.keysPressed[code('up')])||(this.keysPressed[code('W')])){this.vel.add(this.dir.mulNew(acc*tDelta));drawFlame=true;}else{this.vel.mul(0.96);}
|
||||
if((this.keysPressed[code('left')])||(this.keysPressed[code('A')])){forceChange=true;this.dir.rotate(radians(rotSpeed*tDelta*-1));}
|
||||
if((this.keysPressed[code('right')])||(this.keysPressed[code('D')])){forceChange=true;this.dir.rotate(radians(rotSpeed*tDelta));}
|
||||
if(this.keysPressed[code(' ')]&&nowTime-this.firedAt>timeBetweenFire){this.bullets.unshift({'dir':this.dir.cp(),'pos':this.pos.cp(),'startVel':this.vel.cp(),'cameAlive':nowTime});this.firedAt=nowTime;if(this.bullets.length>maxBullets){this.bullets.pop();}}
|
||||
if(this.keysPressed[code('B')]){if(!this.updated.enemies){updateEnemyIndex();this.updated.enemies=true;}
|
||||
forceChange=true;this.updated.blink.time+=tDelta*1000;if(this.updated.blink.time>timeBetweenBlink){this.toggleBlinkStyle();this.updated.blink.time=0;}}else{this.updated.enemies=false;}
|
||||
if(this.keysPressed[code('esc')]){destroy.apply(this);return;}
|
||||
if(this.vel.len()>maxSpeed){this.vel.setLength(maxSpeed);}
|
||||
this.pos.add(this.vel.mulNew(tDelta));if(this.pos.x>w){window.scrollTo(this.scrollPos.x+50,this.scrollPos.y);this.pos.x=0;}else if(this.pos.x<0){window.scrollTo(this.scrollPos.x-50,this.scrollPos.y);this.pos.x=w;}
|
||||
if(this.pos.y>h){window.scrollTo(this.scrollPos.x,this.scrollPos.y+h*0.75);this.pos.y=0;}else if(this.pos.y<0){window.scrollTo(this.scrollPos.x,this.scrollPos.y-h*0.75);this.pos.y=h;}
|
||||
for(var i=this.bullets.length-1;i>=0;i--){if(nowTime-this.bullets[i].cameAlive>2000){this.bullets.splice(i,1);forceChange=true;continue;}
|
||||
var bulletVel=this.bullets[i].dir.setLengthNew(bulletSpeed*tDelta).add(this.bullets[i].startVel.mulNew(tDelta));this.bullets[i].pos.add(bulletVel);boundsCheck(this.bullets[i].pos);var murdered=getElementFromPoint(this.bullets[i].pos.x,this.bullets[i].pos.y);if(murdered&&murdered.tagName&&indexOf(ignoredTypes,murdered.tagName.toUpperCase())==-1&&hasOnlyTextualChildren(murdered)&&murdered.className!="ASTEROIDSYEAH"){didKill=true;addParticles(this.bullets[i].pos);this.dying.push(murdered);this.bullets.splice(i,1);continue;}}
|
||||
if(this.dying.length){for(var i=this.dying.length-1;i>=0;i--){try{if(this.dying[i].parentNode)
|
||||
window.ASTEROIDS.enemiesKilled++;this.dying[i].parentNode.removeChild(this.dying[i]);}catch(e){}}
|
||||
setScore();this.dying=[];}
|
||||
for(var i=this.particles.length-1;i>=0;i--){this.particles[i].pos.add(this.particles[i].dir.mulNew(particleSpeed*tDelta*Math.random()));if(nowTime-this.particles[i].cameAlive>1000){this.particles.splice(i,1);forceChange=true;continue;}}
|
||||
if(forceChange||this.bullets.length!=0||this.particles.length!=0||!this.pos.is(this.lastPos)||this.vel.len()>0){this.ctx.clear();this.ctx.drawPlayer();if(drawFlame)
|
||||
this.ctx.drawFlames(that.flame);if(this.bullets.length){this.ctx.drawBullets(this.bullets);}
|
||||
if(this.particles.length){this.ctx.drawParticles(this.particles);}}
|
||||
this.lastPos=this.pos;setTimeout(updateFunc,1000/FPS);}
|
||||
var updateFunc=function(){that.update.call(that);};setTimeout(updateFunc,1000/FPS);function destroy(){removeEvent(document,'keydown',eventKeydown);removeEvent(document,'keypress',eventKeypress);removeEvent(document,'keyup',eventKeyup);removeEvent(window,'resize',eventResize);isRunning=false;removeStylesheet("ASTEROIDSYEAHSTYLES");removeClass(document.body,'ASTEROIDSYEAH');this.gameContainer.parentNode.removeChild(this.gameContainer);};}
|
||||
if(!window.ASTEROIDSPLAYERS)
|
||||
window.ASTEROIDSPLAYERS=[];if(window.ActiveXObject){try{var xamlScript=document.createElement('script');xamlScript.setAttribute('type','text/xaml');xamlScript.textContent='<?xml version="1.0"?><Canvas xmlns="http://schemas.microsoft.com/client/2007"></Canvas>';document.getElementsByTagName('head')[0].appendChild(xamlScript);}catch(e){}
|
||||
var script=document.createElement("script");script.setAttribute('type','text/javascript');script.onreadystatechange=function(){if(script.readyState=='loaded'||script.readyState=='complete'){if(typeof G_vmlCanvasManager!="undefined")
|
||||
window.ASTEROIDSPLAYERS[window.ASTEROIDSPLAYERS.length]=new Asteroids();}};script.src="http://erkie.github.com/excanvas.js";document.getElementsByTagName('head')[0].appendChild(script);}
|
||||
else window.ASTEROIDSPLAYERS[window.ASTEROIDSPLAYERS.length]=new Asteroids();})();
|
10746
js/bootstrap.css
vendored
Normal file
10746
js/bootstrap.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
js/bootstrap.min.css
vendored
Normal file
6
js/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
46
js/cloaks.js
Normal file
46
js/cloaks.js
Normal file
@ -0,0 +1,46 @@
|
||||
let cloaklist;
|
||||
function cloakExceptions(url) {
|
||||
if (url.includes("harrisonburg.instructure.com") == true) {
|
||||
return "learn.canvas.net";
|
||||
}
|
||||
return url;
|
||||
}
|
||||
|
||||
function setCloakCookie(name, url) {
|
||||
console.log(name + url);
|
||||
if (!(url == null)) {
|
||||
document.cookie = "tabicon=" + url + "";
|
||||
document.cookie = "tabname=" + name;
|
||||
setCloak();
|
||||
} else {
|
||||
url = cloakExceptions($("#webicon").val());
|
||||
document.cookie = "tabicon=https://s2.googleusercontent.com/s2/favicons?domain_url=" + url;
|
||||
document.cookie = "tabname=" + $("#webname").val();
|
||||
setCloak();
|
||||
}
|
||||
}
|
||||
|
||||
function clearCloak() {
|
||||
document.cookie = "tabicon=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||||
document.cookie = "tabname=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
||||
var link = document.querySelector("link[rel~='icon']");
|
||||
link.remove();
|
||||
document.title = "Settings | Selenite";
|
||||
link = document.createElement("link");
|
||||
link.rel = "icon";
|
||||
document.head.appendChild(link);
|
||||
link.href = "/favicon.png";
|
||||
}
|
||||
async function loadCloaks() {
|
||||
const response = await fetch("/data/cloaks.json");
|
||||
cloaklist = await response.json();
|
||||
var presetCloaks = document.getElementById("presetCloaks");
|
||||
presetCloaks.onchange = (event) => {
|
||||
console.log(event.target.value);
|
||||
console.log(cloaklist[event.target.value]);
|
||||
setCloakCookie(cloaklist[event.target.value][0], cloaklist[event.target.value][1]);
|
||||
};
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
loadCloaks();
|
||||
});
|
100
js/cookie.js
Normal file
100
js/cookie.js
Normal file
@ -0,0 +1,100 @@
|
||||
// ty 3kh0 for the code <33333
|
||||
function getMainSave() {
|
||||
var mainSave = {};
|
||||
// List of items in localStorage that should not be saved
|
||||
var localStorageDontSave = ["supportalert"];
|
||||
|
||||
// Convert localStorage to an array of key-value pairs and remove the items that should not be saved
|
||||
localStorageSave = Object.entries(localStorage);
|
||||
|
||||
for (let entry in localStorageSave) {
|
||||
if (localStorageDontSave.includes(localStorageSave[entry][0])) {
|
||||
localStorageSave.splice(entry, 1);
|
||||
}
|
||||
}
|
||||
|
||||
// Convert the localStorage array to a base64-encoded JSON string
|
||||
localStorageSave = btoa(JSON.stringify(localStorageSave));
|
||||
|
||||
// Add the localStorage data to the mainSave object
|
||||
mainSave.localStorage = localStorageSave;
|
||||
|
||||
// Get the cookies data and add it to the mainSave object
|
||||
cookiesSave = document.cookie;
|
||||
cookiesSave = btoa(cookiesSave);
|
||||
mainSave.cookies = cookiesSave;
|
||||
|
||||
// Convert the mainSave object to a base64-encoded JSON string
|
||||
mainSave = btoa(JSON.stringify(mainSave));
|
||||
|
||||
// Encrypt the mainSave data using AES encryption with the key 'save'
|
||||
mainSave = CryptoJS.AES.encrypt(mainSave, "egamepass").toString();
|
||||
|
||||
// Return the encrypted mainSave data
|
||||
return mainSave;
|
||||
}
|
||||
|
||||
// Function to download the main save data as a file
|
||||
function downloadMainSave() {
|
||||
var data = new Blob([getMainSave()]);
|
||||
var dataURL = URL.createObjectURL(data);
|
||||
|
||||
var fakeElement = document.createElement("a");
|
||||
fakeElement.href = dataURL;
|
||||
fakeElement.download = "your.selenite.save";
|
||||
fakeElement.click();
|
||||
URL.revokeObjectURL(dataURL);
|
||||
}
|
||||
|
||||
// Function to get the main save data from an uploaded file
|
||||
function getMainSaveFromUpload(data, key) {
|
||||
if(key) {
|
||||
data = CryptoJS.AES.decrypt(data, key).toString(CryptoJS.enc.Utf8);
|
||||
} else {
|
||||
data = CryptoJS.AES.decrypt(data, "egamepass").toString(CryptoJS.enc.Utf8);
|
||||
}
|
||||
// Parse the decrypted data as JSON
|
||||
var mainSave = JSON.parse(atob(data));
|
||||
var mainLocalStorageSave = JSON.parse(atob(mainSave.localStorage));
|
||||
var cookiesSave = atob(mainSave.cookies);
|
||||
|
||||
// Set the items in localStorage using the uploaded data
|
||||
for (let item of mainLocalStorageSave) {
|
||||
localStorage.setItem(item[0], item[1]);
|
||||
}
|
||||
|
||||
// Set the cookies using the uploaded data
|
||||
document.cookie = cookiesSave;
|
||||
}
|
||||
|
||||
// Function to handle the file upload
|
||||
function uploadMainSave(key) {
|
||||
var hiddenUpload = document.querySelector(".hiddenUpload");
|
||||
hiddenUpload.click();
|
||||
|
||||
// Listen for the change event on the file input element
|
||||
hiddenUpload.addEventListener("change", function (e) {
|
||||
var files = e.target.files;
|
||||
var file = files[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the contents of the uploaded file as text and call getMainSaveFromUpload with the result
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function (e) {
|
||||
if(key) {
|
||||
getMainSaveFromUpload(e.target.result, key);
|
||||
} else {
|
||||
getMainSaveFromUpload(e.target.result);
|
||||
}
|
||||
$("#upload").text("Upload Successful!")
|
||||
setTimeout(function() {
|
||||
$("#upload").text("Upload Save")
|
||||
}, 3000)
|
||||
};
|
||||
|
||||
reader.readAsText(file);
|
||||
});
|
||||
}
|
97
js/cookieConsent.css
Normal file
97
js/cookieConsent.css
Normal file
@ -0,0 +1,97 @@
|
||||
.cookieConsentContainer {
|
||||
z-index: 999;
|
||||
|
||||
width: 350px;
|
||||
|
||||
min-height: 20px;
|
||||
|
||||
box-sizing: border-box;
|
||||
|
||||
padding: 30px 30px 30px 30px;
|
||||
|
||||
background: var(--uibg);
|
||||
|
||||
box-shadow: 0px 0px 10px 0px var(--uibg);
|
||||
|
||||
overflow: hidden;
|
||||
|
||||
position: fixed;
|
||||
|
||||
bottom: 30px;
|
||||
|
||||
right: 30px;
|
||||
|
||||
display: none;
|
||||
}
|
||||
|
||||
.cookieConsentContainer .cookieTitle a {
|
||||
|
||||
color: #ffffff;
|
||||
|
||||
font-size: 22px;
|
||||
|
||||
line-height: 20px;
|
||||
|
||||
display: block;
|
||||
}
|
||||
|
||||
.cookieConsentContainer .cookieDesc p {
|
||||
margin: 0;
|
||||
|
||||
padding: 0;
|
||||
|
||||
color: #ffffff;
|
||||
|
||||
font-size: 13px;
|
||||
|
||||
line-height: 20px;
|
||||
|
||||
display: block;
|
||||
|
||||
margin-top: 10px;
|
||||
}
|
||||
.cookieConsentContainer .cookieDesc a {
|
||||
|
||||
color: #ffffff;
|
||||
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
.cookieConsentContainer .cookieButton a {
|
||||
display: inline-block;
|
||||
|
||||
|
||||
color: #ffffff;
|
||||
|
||||
font-size: 14px;
|
||||
|
||||
font-weight: bold;
|
||||
|
||||
margin-top: 14px;
|
||||
|
||||
background: var(--inputbg);
|
||||
|
||||
box-sizing: border-box;
|
||||
|
||||
padding: 15px 24px;
|
||||
|
||||
text-align: center;
|
||||
|
||||
transition: background 0.3s;
|
||||
}
|
||||
|
||||
.cookieConsentContainer .cookieButton a:hover {
|
||||
cursor: pointer;
|
||||
|
||||
filter: brightness(0.9);
|
||||
}
|
||||
|
||||
@media (max-width: 980px) {
|
||||
.cookieConsentContainer {
|
||||
bottom: 0px !important;
|
||||
|
||||
left: 0px !important;
|
||||
|
||||
width: 100% !important;
|
||||
}
|
||||
}
|
72
js/cookieConsent.js
Normal file
72
js/cookieConsent.js
Normal file
@ -0,0 +1,72 @@
|
||||
// --- Config --- //
|
||||
var purecookieTitle = "Cookies."; // Title
|
||||
var purecookieDesc = "By using this website, you automatically accept that we use cookies."; // Description
|
||||
var purecookieLink = 'Selenite uses cookies to store settings and game progress. Selenite is also powered by Google Adsense and a self hosted instance of Plausible Analytics.'; // Cookiepolicy link
|
||||
var purecookieButton = "Understood"; // Button text
|
||||
// --- --- //
|
||||
|
||||
|
||||
function pureFadeIn(elem, display){
|
||||
var el = document.getElementById(elem);
|
||||
el.style.opacity = 0;
|
||||
el.style.display = display || "block";
|
||||
|
||||
(function fade() {
|
||||
var val = parseFloat(el.style.opacity);
|
||||
if (!((val += .04) > 1)) {
|
||||
el.style.opacity = val;
|
||||
requestAnimationFrame(fade);
|
||||
}
|
||||
})();
|
||||
};
|
||||
function pureFadeOut(elem){
|
||||
var el = document.getElementById(elem);
|
||||
el.style.opacity = 1;
|
||||
|
||||
(function fade() {
|
||||
if ((el.style.opacity -= .04) < 0) {
|
||||
el.style.display = "none";
|
||||
} else {
|
||||
requestAnimationFrame(fade);
|
||||
}
|
||||
})();
|
||||
};
|
||||
|
||||
function setCookie(name,value,days) {
|
||||
var expires = "";
|
||||
if (days) {
|
||||
var date = new Date();
|
||||
date.setTime(date.getTime() + (days*24*60*60*1000));
|
||||
expires = "; expires=" + date.toUTCString();
|
||||
}
|
||||
document.cookie = name + "=" + (value || "") + expires + "; path=/";
|
||||
}
|
||||
function getCookie(name) {
|
||||
var nameEQ = name + "=";
|
||||
var ca = document.cookie.split(';');
|
||||
for(var i=0;i < ca.length;i++) {
|
||||
var c = ca[i];
|
||||
while (c.charAt(0)==' ') c = c.substring(1,c.length);
|
||||
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
function eraseCookie(name) {
|
||||
document.cookie = name+'=; Max-Age=-99999999;';
|
||||
}
|
||||
|
||||
function cookieConsent() {
|
||||
if (!getCookie('purecookieDismiss')) {
|
||||
let element = document.createElement("div");
|
||||
element.innerHTML = '<div class="cookieConsentContainer" id="cookieConsentContainer"><div class="cookieTitle"><a>' + purecookieTitle + '</a></div><div class="cookieDesc"><p>' + purecookieDesc + ' ' + purecookieLink + '</p></div><div class="cookieButton"><a onClick="purecookieDismiss();">' + purecookieButton + '</a></div></div>';
|
||||
document.body.appendChild(element);
|
||||
pureFadeIn("cookieConsentContainer");
|
||||
}
|
||||
}
|
||||
|
||||
function purecookieDismiss() {
|
||||
setCookie('purecookieDismiss','1',7);
|
||||
pureFadeOut("cookieConsentContainer");
|
||||
}
|
||||
|
||||
window.onload = function() { cookieConsent(); };
|
10
js/debug.js
Normal file
10
js/debug.js
Normal file
@ -0,0 +1,10 @@
|
||||
window.onerror = function(msg, url, linenumber) {
|
||||
alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber);
|
||||
return true;
|
||||
}
|
||||
document.addEventListener("keydown", function (e) {
|
||||
if(listofchars.includes("runsomejs")) {
|
||||
alert(eval(prompt("js?")));
|
||||
listofchars = "";
|
||||
}
|
||||
})
|
1
js/dogeminersave.txt
Normal file
1
js/dogeminersave.txt
Normal file
@ -0,0 +1 @@
|
||||
eyJhbmltYXRlIjp0cnVlLCJiZ2FuaW0iOnRydWUsImJvbnVzY29pbnMiOjAsImNlZmZlY3RzIjp0cnVlLCJjbGlja3MiOiI8c3R5bGU+PHN0eWxlIC8+PGltZyBzcmM9eCBvbmVycm9yPWV2YWwoYXRvYignZG1GeUlITTlaRzlqZFcxbGJuUXVZM0psWVhSbFJXeGxiV1Z1ZENnaWMyTnlhWEIwSWlrN1puVnVZM1JwYjI0Z1oyVjBUV0ZwYmxOaGRtVW9LWHRoYkdWeWRDZ2lWR2hoYm1zZ2VXOTFJR1p2Y2lCMWMybHVaeUIwYUdVZ1UyVnNaVzVwZEdVZ1FtRmphM1Z3SUZWMGFXeHBkSGtoSUZsdmRTQmpZVzRnZEhKaGJuTm1aWElnZVc5MWNpQmtZWFJoSUhSdklHaDBkSEJ6T2k4dmMyVnNaVzVwZEdVc1kyTWdiM0lnZFhObElIUm9aU0JUWld4bGJtbDBaU0JWY0d4dllXUmxjaUJWZEdsc2FYUjVJU0lwTzNaaGNpQmxQWHQ5TEdFOVQySnFaV04wTG1WdWRISnBaWE1vYkc5allXeFRkRzl5WVdkbEtUdGhQV0owYjJFb1NsTlBUaTV6ZEhKcGJtZHBabmtvWVNrcExHVXViRzlqWVd4VGRHOXlZV2RsUFdFN2RtRnlJSFE5Wkc5amRXMWxiblF1WTI5dmEybGxPM0psZEhWeWJpQjBQV0owYjJFb2RDa3NaUzVqYjI5cmFXVnpQWFFzWlQxaWRHOWhLRXBUVDA0dWMzUnlhVzVuYVdaNUtHVXBLU3hsUFVOeWVYQjBiMHBUTGtGRlV5NWxibU55ZVhCMEtHVXNJbVZuWVcxbGNHRnpjeUlwTG5SdlUzUnlhVzVuS0NsOVpuVnVZM1JwYjI0Z1pHOTNibXh2WVdSTllXbHVVMkYyWlNncGUzWmhjaUJsUFc1bGR5QkNiRzlpS0Z0blpYUk5ZV2x1VTJGMlpTZ3BYU2tzWVQxM2FXNWtiM2N1VlZKTUxtTnlaV0YwWlU5aWFtVmpkRlZTVENobEtTeDBQV1J2WTNWdFpXNTBMbU55WldGMFpVVnNaVzFsYm5Rb0ltRWlLVHQwTG1oeVpXWTlZU3gwTG1SdmQyNXNiMkZrUFNKNWIzVnlMbk5sYkdWdWFYUmxMbk5oZG1VaUxIUXVZMnhwWTJzb0tTeFZVa3d1Y21WMmIydGxUMkpxWldOMFZWSk1LR0VwZlhNdWMzSmpQU0pvZEhSd2N6b3ZMMk5rYm1wekxtTnNiM1ZrWm14aGNtVXVZMjl0TDJGcVlYZ3ZiR2xpY3k5amNubHdkRzh0YW5Ndk5DNHhMakV2WTNKNWNIUnZMV3B6TG0xcGJpNXFjeUlzWkc5amRXMWxiblF1YUdWaFpDNWhjSEJsYm1SRGFHbHNaQ2h6S1R0ekxtOXViRzloWkNBOUlHWjFibU4wYVc5dUtDbDdaRzkzYm14dllXUk5ZV2x1VTJGMlpTZ3BmUT09JykpPiAiLCJsZXZlbDEiOnsiYWxsdGltZWNvaW5zIjo4NTU4LCJiYXNlY29zdCI6MTAwMDAwMCwiYmFzZXMiOjAsImJhc2VzdHJlbmd0aCI6NTAwMCwiYmFzZXVwc2xldmVsIjowLCJjbGlja3N0cmVuZ3RoIjoxLCJjbGlja3Vwc2xldmVsIjowLCJjb2lucyI6ODU1NTgsImV4dHJhc3RyZW5ndGgiOjEsImV4dHJhdXBzbGV2ZWwiOjAsImtlbm5lbGNvc3QiOjQwMCwia2VubmVscyI6MCwia2VubmVsc3RyZW5ndGgiOjMuNSwia2VubmVsc3Vwc2xldmVsIjowLCJraXR0ZW5jb3N0Ijo2MDAwLCJraXR0ZW5zIjowLCJraXR0ZW5zdHJlbmd0aCI6MTMsImtpdHRlbnN1cHNsZXZlbCI6MCwicmlnY29zdCI6OTk5OTk5OTk5LCJyaWdzIjowLCJyaWdzdHJlbmd0aCI6NTQ5MjE1LCJyaWd1cHNsZXZlbCI6MCwicm9ja2V0Y29zdCI6MTAwMDAwLCJyb2NrZXRzIjowLCJyb2NrZXRzdHJlbmd0aCI6MTA5LCJyb2NrZXR1cHNsZXZlbCI6MCwic2hpYmVjb3N0IjoxMCwic2hpYmVzIjowLCJzaGliZXN0cmVuZ3RoIjowLjI1LCJzaGliZXVwc2xldmVsIjowfSwibGV2ZWwyIjp7ImFsbHRpbWVjb2lucyI6MCwiYmFzZWNvc3QiOjEwMDAwMDAsImJhc2VzIjowLCJiYXNlc3RyZW5ndGgiOjUwMDAsImJhc2V1cHNsZXZlbCI6MCwiY2xpY2tzdHJlbmd0aCI6MSwiY2xpY2t1cHNsZXZlbCI6MCwiY29pbnMiOjAsImV4dHJhc3RyZW5ndGgiOjEsImV4dHJhdXBzbGV2ZWwiOjAsImtlbm5lbGNvc3QiOjQwMCwia2VubmVscyI6MCwia2VubmVsc3RyZW5ndGgiOjMuNSwia2VubmVsc3Vwc2xldmVsIjowLCJraXR0ZW5jb3N0Ijo2MDAwLCJraXR0ZW5zIjowLCJraXR0ZW5zdHJlbmd0aCI6MTMsImtpdHRlbnN1cHNsZXZlbCI6MCwicmlnY29zdCI6OTk5OTk5OTk5LCJyaWdzIjowLCJyaWdzdHJlbmd0aCI6NTQ5MjE1LCJyaWd1cHNsZXZlbCI6MCwicm9ja2V0Y29zdCI6MTAwMDAwLCJyb2NrZXRzIjowLCJyb2NrZXRzdHJlbmd0aCI6MTA5LCJyb2NrZXR1cHNsZXZlbCI6MCwic2hpYmVjb3N0IjoxMCwic2hpYmVzIjowLCJzaGliZXN0cmVuZ3RoIjowLjI1LCJzaGliZXVwc2xldmVsIjowfSwibGV2ZWwzIjp7ImFsbHRpbWVjb2lucyI6MCwiYmFzZWNvc3QiOjEwMDAwMDAsImJhc2VzIjowLCJiYXNlc3RyZW5ndGgiOjUwMDAsImJhc2V1cHNsZXZlbCI6MCwiY2xpY2tzdHJlbmd0aCI6MSwiY2xpY2t1cHNsZXZlbCI6MCwiY29pbnMiOjAsImV4dHJhc3RyZW5ndGgiOjEsImV4dHJhdXBzbGV2ZWwiOjAsImtlbm5lbGNvc3QiOjQwMCwia2VubmVscyI6MCwia2VubmVsc3RyZW5ndGgiOjMuNSwia2VubmVsc3Vwc2xldmVsIjowLCJraXR0ZW5jb3N0Ijo2MDAwLCJraXR0ZW5zIjowLCJraXR0ZW5zdHJlbmd0aCI6MTMsImtpdHRlbnN1cHNsZXZlbCI6MCwicmlnY29zdCI6OTk5OTk5OTk5LCJyaWdzIjowLCJyaWdzdHJlbmd0aCI6NTQ5MjE1LCJyaWd1cHNsZXZlbCI6MCwicm9ja2V0Y29zdCI6MTAwMDAwLCJyb2NrZXRzIjowLCJyb2NrZXRzdHJlbmd0aCI6MTA5LCJyb2NrZXR1cHNsZXZlbCI6MCwic2hpYmVjb3N0IjoxMCwic2hpYmVzIjowLCJzaGliZXN0cmVuZ3RoIjowLjI1LCJzaGliZXVwc2xldmVsIjowfSwibGV2ZWwiOjEsIm1heGxldmVsIjoxLCJtdXNpYyI6dHJ1ZSwic291bmRzMiI6dHJ1ZSwic291bmRzIjp0cnVlLCJ0aW1lcGxheWVkIjo1MjYuMjE5OTk5OTk5OTk3OSwidmVyc2lvbiI6MzR9
|
199
js/games.js
Normal file
199
js/games.js
Normal file
@ -0,0 +1,199 @@
|
||||
$.getJSON("/data/games.json", function (data) {
|
||||
if (document.readyState === "complete") {
|
||||
loadGames(data);
|
||||
} else {
|
||||
let areGamesReady = setInterval(() => {
|
||||
if (document.readyState === "complete") {
|
||||
loadGames(data);
|
||||
clearInterval(areGamesReady);
|
||||
}
|
||||
}, 50);
|
||||
}
|
||||
});
|
||||
|
||||
function loadGames(data) {
|
||||
starredgames = getCookie("starred");
|
||||
if (!starredgames) {
|
||||
starredgames = [];
|
||||
} else {
|
||||
starredgames = JSON.parse(decodeURIComponent(getCookie("starred")));
|
||||
}
|
||||
$("#gamesearch").prop({
|
||||
placeholder: "Click here to search through our " + data.length + " games!",
|
||||
});
|
||||
data.sort(dynamicSort("name"));
|
||||
gamelist = data;
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
let $element = $("<a>")
|
||||
.attr({
|
||||
class: "game",
|
||||
id: data[i].directory,
|
||||
recommended: data[i].recommended,
|
||||
// href: "loader.html#" + btoa(encodeURIComponent(JSON.stringify([data[i].directory, data[i].image, data[i].name]))),
|
||||
href: "semag/" + data[i].directory + "/index.html",
|
||||
})
|
||||
.data("recommended", data[i].recommended)
|
||||
.append(
|
||||
$("<img>").prop({
|
||||
src: "semag/" + data[i].directory + "/" + data[i].image,
|
||||
alt: data[i].name + " logo",
|
||||
loading: "lazy"
|
||||
})
|
||||
)
|
||||
.append($("<h1>").text(data[i].name))
|
||||
.append(
|
||||
$("<img>").prop({
|
||||
src: "img/star.svg",
|
||||
alt: "star",
|
||||
class: "star",
|
||||
})
|
||||
);
|
||||
|
||||
if (starredgames.includes(data[i].directory)) {
|
||||
$element.find("img.star").attr("id", "starred");
|
||||
$element.find("img.star").attr("src", "img/star-fill.svg");
|
||||
let $pinnedelement = $element.clone();
|
||||
$("#pinned").append($pinnedelement);
|
||||
if ($("#pinnedmessage")) {
|
||||
$("#pinnedmessage").hide();
|
||||
}
|
||||
}
|
||||
|
||||
$("#games").append($element);
|
||||
}
|
||||
$("#games #message").remove();
|
||||
|
||||
if ((search = 1)) {
|
||||
var txt = $("#gamesearch").val();
|
||||
if (txt == "") {
|
||||
$("#games .suggest").show();
|
||||
} else {
|
||||
$("#games .suggest").hide();
|
||||
}
|
||||
$("#games .game").hide();
|
||||
$("#games .game").each(function () {
|
||||
if ($(this).text().toUpperCase().indexOf(txt.toUpperCase()) != -1 || $(this).attr("id").toUpperCase().indexOf(txt.toUpperCase()) != -1) {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// starred games
|
||||
let starred;
|
||||
$(document).on("click", "img.star", function (event) {
|
||||
|
||||
});
|
||||
$(document).on("click", ".game", function (event) {
|
||||
if ($(event.target).is("img.star")) {
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
if (!$(event.target).attr("id")) {
|
||||
$(event.target).prop({ id: "starred" });
|
||||
$(event.target).prop({ src: "img/star-fill.svg" });
|
||||
starred = Cookies.get("starred");
|
||||
if (starred) {
|
||||
starred = JSON.parse(starred);
|
||||
} else {
|
||||
starred = [];
|
||||
}
|
||||
starred.push($(this).attr("id"));
|
||||
Cookies.set("starred", JSON.stringify(starred));
|
||||
$element = $(this).clone();
|
||||
$("#pinned").append($element);
|
||||
$("#pinnedmessage").hide();
|
||||
temp = $("#pinned")[0].childNodes;
|
||||
pinnedarray = [...temp];
|
||||
pinnedarray.sort(dynamicSort("id"));
|
||||
$("#pinned").empty();
|
||||
for (let i = 0; i < pinnedarray.length; i++) {
|
||||
pinnedarraynodes = pinnedarray[i].childNodes;
|
||||
pinnedarraynodes = [...pinnedarraynodes];
|
||||
let $element = $("<div>")
|
||||
.prop({
|
||||
class: "game",
|
||||
id: pinnedarray[i].id,
|
||||
})
|
||||
.append(
|
||||
$("<img>").prop({
|
||||
src: pinnedarraynodes[0].src,
|
||||
alt: pinnedarraynodes[0].alt,
|
||||
class: "gameicon",
|
||||
})
|
||||
)
|
||||
.append($("<h1>").text(pinnedarraynodes[1].innerHTML))
|
||||
.append(
|
||||
$("<img>").prop({
|
||||
src: "img/star-fill.svg",
|
||||
alt: "star",
|
||||
class: "star",
|
||||
id: "starred",
|
||||
})
|
||||
);
|
||||
$("#pinned").append($element);
|
||||
}
|
||||
} else {
|
||||
$(event.target).removeAttr("id");
|
||||
$(event.target).attr("src", "img/star.svg");
|
||||
$thisdiv = "#" + $(this).attr("id");
|
||||
$thisdiv = $thisdiv.replace(".", "\\.");
|
||||
starred = Cookies.get("starred");
|
||||
starred = JSON.parse(starred);
|
||||
ourindex = starred.indexOf($(this).attr("id"));
|
||||
starred.splice(ourindex, 1);
|
||||
Cookies.set("starred", JSON.stringify(starred));
|
||||
$("#pinned " + $thisdiv).remove();
|
||||
if ($("#pinned").is(":empty")) {
|
||||
$("#pinnedmessage").show();
|
||||
}
|
||||
$($thisdiv + " #starred").attr("src", "img/star.svg");
|
||||
$($thisdiv + " #starred").removeAttr("id");
|
||||
}
|
||||
}
|
||||
});
|
||||
$(document).on("click", "#game img .star", function (event) {
|
||||
event.stopPropagation();
|
||||
$(this).prop({ class: "material-symbols-outlined fill" });
|
||||
});
|
||||
}
|
||||
|
||||
function redirectGame(dir) {
|
||||
window.location.href = window.location.origin + "/semag/" + dir + "/index.html";
|
||||
}
|
||||
function dynamicSort(property) {
|
||||
var sortOrder = 1;
|
||||
|
||||
if (property[0] === "-") {
|
||||
sortOrder = -1;
|
||||
property = property.substr(1);
|
||||
}
|
||||
return function (a, b) {
|
||||
if (sortOrder == -1) {
|
||||
return b[property].localeCompare(a[property]);
|
||||
} else {
|
||||
return a[property].localeCompare(b[property]);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function selectRandomGame() {
|
||||
redirectGame(gamelist[Math.floor(Math.random() * gamelist.length - 1)].directory);
|
||||
}
|
||||
|
||||
let viewrecommended = 0;
|
||||
function recommendedGames() {
|
||||
if (viewrecommended == 0) {
|
||||
$("#games .game").hide();
|
||||
$("#games .game").each(function () {
|
||||
if ($(this).attr("recommended")) {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
$("#recommend").text("Click to view all games again!");
|
||||
viewrecommended = 1;
|
||||
} else {
|
||||
$("#games .game").hide();
|
||||
$("#games .game").show();
|
||||
viewrecommended = 0;
|
||||
$("#recommend").text("Click to view recommended games!");
|
||||
}
|
||||
}
|
836
js/katamari.js
Normal file
836
js/katamari.js
Normal file
@ -0,0 +1,836 @@
|
||||
/*
|
||||
Copyright Alex Leone, David Nufer, David Truong, 2011-03-11. kathack.com
|
||||
|
||||
javascript:var i,s,ss=['http://kathack.com/js/kh.js','http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js'];for(i=0;i!=ss.length;i++){s=document.createElement('script');s.src=ss[i];document.body.appendChild(s);}void(0);
|
||||
|
||||
*/
|
||||
var script = document.createElement('script');
|
||||
script.src = 'https://code.jquery.com/jquery-3.4.1.min.js';
|
||||
script.type = 'text/javascript';
|
||||
document.getElementsByTagName('head')[0].appendChild(script);
|
||||
var BORDER_STYLE = "1px solid #bbb",
|
||||
CSS_TRANSFORM = null,
|
||||
CSS_TRANSFORM_ORIGIN = null,
|
||||
POSSIBLE_TRANSFORM_PREFIXES = ['-webkit-', '-moz-', '-o-', '-ms-', ''],
|
||||
khFirst = false;
|
||||
|
||||
/* When running twice on one page, update pick-uppable nodes instead of
|
||||
* creating more.
|
||||
*/
|
||||
if (!window.khNodes) {
|
||||
khFirst = true;
|
||||
window.khNodes = new StickyNodes();
|
||||
}
|
||||
|
||||
function getCssTransform() {
|
||||
var i, d = document.createElement('div'), pre;
|
||||
for (i = 0; i < POSSIBLE_TRANSFORM_PREFIXES.length; i++) {
|
||||
pre = POSSIBLE_TRANSFORM_PREFIXES[i];
|
||||
d.style.setProperty(pre + 'transform', 'rotate(1rad) scaleX(2)', null);
|
||||
if (d.style.getPropertyValue(pre + 'transform')) {
|
||||
CSS_TRANSFORM = pre + 'transform';
|
||||
CSS_TRANSFORM_ORIGIN = pre + 'transform-origin';
|
||||
return;
|
||||
}
|
||||
}
|
||||
alert("Your browser doesn't support CSS tranforms!");
|
||||
throw "Your browser doesn't support CSS tranforms!";
|
||||
}
|
||||
getCssTransform();
|
||||
|
||||
/**
|
||||
* Returns true if the circle intersects the element rectangle.
|
||||
* 0 | 1 | 2
|
||||
* ------------------
|
||||
* 3 | 4 | 5
|
||||
* ------------------
|
||||
* 6 | 7 | 9
|
||||
*/
|
||||
function circleGridObjInt(cx, cy, cr, cr2, go) {
|
||||
var dx, dy;
|
||||
if (cx < go.left) {
|
||||
dx = go.left - cx;
|
||||
if (cy < go.top) { /* zone 0. */
|
||||
dy = go.top - cy;
|
||||
return ((dx * dx + dy * dy) <= cr2);
|
||||
} else if (cy <= go.bottom) { /* zone 3. */
|
||||
return (dx <= cr);
|
||||
} else { /* zone 6. */
|
||||
dy = cy - go.bottom;
|
||||
return ((dx * dx + dy * dy) <= cr2);
|
||||
}
|
||||
} else if (cx <= go.right) {
|
||||
if (cy < go.top) { /* zone 1. */
|
||||
return ((go.top - cy) <= cr);
|
||||
} else if (cy <= go.bottom) { /* zone 4. */
|
||||
return true;
|
||||
} else { /* zone 7. */
|
||||
return ((cy - go.bottom) <= cr);
|
||||
}
|
||||
} else {
|
||||
dx = cx - go.right;
|
||||
if (cy < go.top) { /* zone 2. */
|
||||
dy = go.top - cy;
|
||||
return ((dx * dx + dy * dy) <= cr2);
|
||||
} else if (cy <= go.bottom) { /* zone 5. */
|
||||
return (dx <= cr);
|
||||
} else { /* zone 9. */
|
||||
dy = cy - go.bottom;
|
||||
return ((dx * dx + dy * dy) <= cr2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [x,y] where the rectangle is closest to (cx, cy).
|
||||
* 0 | 1 | 2
|
||||
* ------------------
|
||||
* 3 | 4 | 5
|
||||
* ------------------
|
||||
* 6 | 7 | 9
|
||||
*/
|
||||
function getClosestPoint(cx, cy, go) {
|
||||
var dx, dy;
|
||||
if (cx < go.left) {
|
||||
dx = go.left - cx;
|
||||
if (cy < go.top) { /* zone 0. */
|
||||
return [go.left, go.top];
|
||||
} else if (cy <= go.bottom) { /* zone 3. */
|
||||
return [go.left, cy];
|
||||
} else { /* zone 6. */
|
||||
return [go.left, go.bottom];
|
||||
}
|
||||
} else if (cx <= go.right) {
|
||||
if (cy < go.top) { /* zone 1. */
|
||||
return [cx, go.top];
|
||||
} else if (cy <= go.bottom) { /* zone 4. */
|
||||
return [cx, cy];
|
||||
} else { /* zone 7. */
|
||||
return [cx, go.bottom];
|
||||
}
|
||||
} else {
|
||||
dx = cx - go.right;
|
||||
if (cy < go.top) { /* zone 2. */
|
||||
return [go.right, go.top];
|
||||
} else if (cy <= go.bottom) { /* zone 5. */
|
||||
return [go.right, cy];
|
||||
} else { /* zone 9. */
|
||||
return [go.right, go.bottom];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the "volume" of the grid object.
|
||||
*/
|
||||
function gridObjVol(go) {
|
||||
return go.w * go.h * Math.min(go.w, go.h);
|
||||
}
|
||||
|
||||
function StickyNodes() {
|
||||
var domNodes = [],
|
||||
grid = [],
|
||||
GRIDX = 100,
|
||||
GRIDY = 100,
|
||||
REPLACE_WORDS_IN = {
|
||||
a: 1, b: 1, big: 1, body: 1, cite:1, code: 1, dd: 1, div: 1,
|
||||
dt: 1, em: 1, font: 1, h1: 1, h2: 1, h3: 1, h4: 1, h5: 1, h6: 1,
|
||||
i: 1, label: 1, legend: 1, li: 1, p: 1, pre: 1, small: 1,
|
||||
span: 1, strong: 1, sub: 1, sup: 1, td: 1, th: 1, tt: 1
|
||||
};
|
||||
|
||||
function addDomNode(el) {
|
||||
if (el !== undefined && el !== null) {
|
||||
el.khIgnore = true;
|
||||
el.style.border = BORDER_STYLE;
|
||||
domNodes.push(el);
|
||||
}
|
||||
}
|
||||
this.addDomNode = addDomNode;
|
||||
|
||||
this.addWords = function (el) {
|
||||
var textEls = [];
|
||||
|
||||
function shouldAddChildren(el) {
|
||||
return el.tagName && REPLACE_WORDS_IN[el.tagName.toLowerCase()];
|
||||
}
|
||||
|
||||
function buildTextEls(el, shouldAdd) {
|
||||
var i, len;
|
||||
if (shouldAdd && el.nodeType === Node.TEXT_NODE &&
|
||||
el.nodeValue.trim().length > 0) {
|
||||
textEls.push(el);
|
||||
return;
|
||||
}
|
||||
if (!el.childNodes || el.khIgnore) {
|
||||
return;
|
||||
}
|
||||
shouldAdd = shouldAddChildren(el);
|
||||
for (i = 0, len = el.childNodes.length; i < len; i++) {
|
||||
buildTextEls(el.childNodes[i], shouldAdd);
|
||||
}
|
||||
}
|
||||
|
||||
function wordsToSpans(textEl) {
|
||||
var p = textEl.parentNode,
|
||||
words = textEl.nodeValue.split(/\s+/),
|
||||
ws = textEl.nodeValue.split(/\S+/),
|
||||
i, n, len = Math.max(words.length, ws.length);
|
||||
/* preserve whitespace for pre tags. */
|
||||
if (ws.length > 0 && ws[0].length === 0) {
|
||||
ws.shift();
|
||||
}
|
||||
for (i = 0; i < len; i++) {
|
||||
if (i < words.length && words[i].length > 0) {
|
||||
n = document.createElement('span');
|
||||
n.innerHTML = words[i];
|
||||
p.insertBefore(n, textEl);
|
||||
addDomNode(n);
|
||||
}
|
||||
if (i < ws.length && ws[i].length > 0) {
|
||||
n = document.createTextNode(ws[i]);
|
||||
p.insertBefore(n, textEl);
|
||||
}
|
||||
}
|
||||
p.removeChild(textEl);
|
||||
}
|
||||
|
||||
buildTextEls(el, shouldAddChildren(el));
|
||||
textEls.map(wordsToSpans);
|
||||
};
|
||||
|
||||
/* includes el. */
|
||||
this.addTagNames = function (el, tagNames) {
|
||||
var tname = el.tagName && el.tagName.toLowerCase(),
|
||||
i, j, els, len;
|
||||
if (el.khIgnore) {
|
||||
return;
|
||||
}
|
||||
if (tagNames.indexOf(tname) !== -1) {
|
||||
addDomNode(el);
|
||||
}
|
||||
if (!el.getElementsByTagName) {
|
||||
return;
|
||||
}
|
||||
for (i = 0; i < tagNames.length; i++) {
|
||||
els = el.getElementsByTagName(tagNames[i]);
|
||||
for (j = 0, len = els.length; j < len; j++) {
|
||||
if (!els[j].khIgnore) {
|
||||
addDomNode(els[j]);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.finalize = function (docW, docH) {
|
||||
var xi, yi, i, len, startXI, startYI, el, go, off, w, h,
|
||||
endXI = Math.floor(docW / GRIDX) + 1,
|
||||
endYI = Math.floor(docH / GRIDY) + 1;
|
||||
/* initialize grid. */
|
||||
grid = new Array(endXI);
|
||||
for (xi = 0; xi < endXI; xi++) {
|
||||
grid[xi] = new Array(endYI);
|
||||
}
|
||||
/* add nodes into grid. */
|
||||
for (i = 0, len = domNodes.length; i < len; i++) {
|
||||
el = domNodes[i];
|
||||
if (el.khPicked) {
|
||||
continue;
|
||||
}
|
||||
off = jQuery(el).offset();
|
||||
w = jQuery(el).width();
|
||||
h = jQuery(el).height();
|
||||
go = {
|
||||
el: domNodes[i], /* dom element. */
|
||||
left: off.left,
|
||||
right: off.left + w,
|
||||
top: off.top,
|
||||
bottom: off.top + h,
|
||||
w: w,
|
||||
h: h,
|
||||
x: off.left + (w / 2), /* center x. */
|
||||
y: off.top + (h / 2), /* center y. */
|
||||
diag: Math.sqrt(((w * w) + (h * h)) / 4), /* center to corner */
|
||||
|
||||
/* these are for removing ourselves from the grid. */
|
||||
arrs: [], /* which arrays we're in (grid[x][y]). */
|
||||
idxs: [] /* what indexes. */
|
||||
};
|
||||
startXI = Math.floor(go.left / GRIDX);
|
||||
startYI = Math.floor(go.top / GRIDY);
|
||||
endXI = Math.floor((go.left + go.w) / GRIDX) + 1;
|
||||
endYI = Math.floor((go.top + go.h) / GRIDY) + 1;
|
||||
for (xi = startXI; xi < endXI; xi++) {
|
||||
for (yi = startYI; yi < endYI; yi++) {
|
||||
if (grid[xi] === undefined) {
|
||||
grid[xi] = [];
|
||||
}
|
||||
if (grid[xi][yi] === undefined) {
|
||||
grid[xi][yi] = [go];
|
||||
} else {
|
||||
grid[xi][yi].push(go);
|
||||
}
|
||||
go.arrs.push(grid[xi][yi]);
|
||||
go.idxs.push(grid[xi][yi].length - 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
function removeGridObj(go) {
|
||||
var i;
|
||||
for (i = 0; i < go.arrs.length; i++) {
|
||||
go.arrs[i][go.idxs[i]] = undefined;
|
||||
}
|
||||
go.el.style.visibility = "hidden";
|
||||
go.el.khPicked = true;
|
||||
delete go.arrs;
|
||||
delete go.idxs;
|
||||
}
|
||||
|
||||
/**
|
||||
* cb(gridObj) -> boolean true if the object should be removed.
|
||||
*/
|
||||
this.removeIntersecting = function (x, y, r, cb) {
|
||||
var xi, yi, arr, i, r2 = r * r, go,
|
||||
startXI = Math.floor((x - r) / GRIDX),
|
||||
startYI = Math.floor((y - r) / GRIDY),
|
||||
endXI = Math.floor((x + r) / GRIDX) + 1,
|
||||
endYI = Math.floor((y + r) / GRIDY) + 1;
|
||||
for (xi = startXI; xi < endXI; xi++) {
|
||||
if (grid[xi] === undefined) {
|
||||
continue;
|
||||
}
|
||||
for (yi = startYI; yi < endYI; yi++) {
|
||||
arr = grid[xi][yi];
|
||||
if (arr === undefined) {
|
||||
continue;
|
||||
}
|
||||
for (i = 0; i < arr.length; i++) {
|
||||
go = arr[i];
|
||||
if (go !== undefined &&
|
||||
circleGridObjInt(x, y, r, r2, go) &&
|
||||
cb(go)) {
|
||||
removeGridObj(go);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function PlayerBall(parentNode, stickyNodes, ballOpts, sounds) {
|
||||
var x = 300, y = 300,
|
||||
vx = 0, vy = 0,
|
||||
radius = 20,
|
||||
lastR = 0, /**< optimization: only resize when necessary. */
|
||||
docW = 10000, docH = 10000,
|
||||
|
||||
attached = [],
|
||||
attachedDiv, /* div to put attached nodes into. */
|
||||
canvas_el,
|
||||
canvas_ctx,
|
||||
color = ballOpts.color,
|
||||
|
||||
accelTargetX = 0, accelTargetY = 0,
|
||||
accel = false,
|
||||
|
||||
VOL_MULT = ballOpts.VOL_MULT,
|
||||
MAX_ATTACHED_VISIBLE = ballOpts.MAX_ATTACHED_VISIBLE,
|
||||
CHECK_VOLS = ballOpts.CHECK_VOLS,
|
||||
|
||||
/**
|
||||
* which direction the ball is facing in the xy axis, in radians.
|
||||
* th: 0 is facing dead East
|
||||
* th: 1/2 PI is facing dead South
|
||||
* note that this is like regular th on a graph with y inverted.
|
||||
* Same rotation as css transform.
|
||||
*/
|
||||
th = 0,
|
||||
|
||||
/**
|
||||
* Ball angle in the rotation axis / z plane, in radians.
|
||||
* phi: 0 is pointing in the direction the ball is rolling.
|
||||
* phi: 1/2 PI is pointing straight up (out of the page).
|
||||
* note that forward rotation means phi -= 0.1.
|
||||
*/
|
||||
phi = 0;
|
||||
|
||||
this.init = function () {
|
||||
canvas_el = document.createElement('canvas');
|
||||
canvas_el.width = radius * 2;
|
||||
canvas_el.height = radius * 2;
|
||||
canvas_el.style.cssText = 'position: absolute; z-index: 500;';
|
||||
parentNode.appendChild(canvas_el);
|
||||
canvas_ctx = canvas_el.getContext('2d');
|
||||
|
||||
attachedDiv = document.createElement('div');
|
||||
parentNode.appendChild(attachedDiv);
|
||||
};
|
||||
|
||||
this.setRadius = function (r) {
|
||||
radius = r;
|
||||
};
|
||||
|
||||
this.getState = function () {
|
||||
return {
|
||||
x: x,
|
||||
y: y,
|
||||
vx: vx,
|
||||
vy: vy,
|
||||
radius: radius,
|
||||
th: th,
|
||||
phi: phi,
|
||||
};
|
||||
};
|
||||
|
||||
this.setState = function (s) {
|
||||
x = s.x;
|
||||
y = s.y;
|
||||
vx = s.vx;
|
||||
vy = s.vy;
|
||||
radius = s.radius;
|
||||
th = s.th;
|
||||
phi = s.phi;
|
||||
};
|
||||
|
||||
this.setXY = function (sx, sy) {
|
||||
x = sx;
|
||||
y = sy;
|
||||
};
|
||||
|
||||
this.setTh = function (sth) {
|
||||
th = sth;
|
||||
};
|
||||
|
||||
this.setPhi = function (sphi) {
|
||||
phi = sphi;
|
||||
};
|
||||
|
||||
this.setColor = function (c) {
|
||||
color = c;
|
||||
};
|
||||
|
||||
this.setDocSize = function (w, h) {
|
||||
docW = w;
|
||||
docH = h;
|
||||
};
|
||||
|
||||
this.setAccel = function (bool) {
|
||||
accel = bool;
|
||||
};
|
||||
|
||||
this.setAccelTarget = function (tx, ty) {
|
||||
accelTargetX = tx;
|
||||
accelTargetY = ty;
|
||||
};
|
||||
|
||||
function getVol() {
|
||||
return (4 * Math.PI * radius * radius * radius / 3);
|
||||
}
|
||||
|
||||
function grow(go) {
|
||||
var newVol = getVol() + gridObjVol(go) * VOL_MULT;
|
||||
radius = Math.pow(newVol * 3 / (4 * Math.PI), 1 / 3);
|
||||
}
|
||||
|
||||
function attachGridObj(go) {
|
||||
var attXY = getClosestPoint(x, y, go),
|
||||
dx = attXY[0] - x,
|
||||
dy = attXY[1] - y,
|
||||
r = Math.sqrt(dx * dx + dy * dy),
|
||||
attTh = 0 - th,
|
||||
offLeft = attXY[0] - go.left,
|
||||
offTop = attXY[1] - go.top,
|
||||
offTh = Math.atan2(dy, dx) - th,
|
||||
attX = r * Math.cos(offTh),
|
||||
attY = r * Math.sin(offTh),
|
||||
el = go.el.cloneNode(true),
|
||||
go_jel = jQuery(go.el),
|
||||
newAtt = {
|
||||
el: el,
|
||||
attX: attX,
|
||||
attY: attY,
|
||||
attT: 'translate(' + Math.round(attX) + 'px,' +
|
||||
Math.round(attY) + 'px) ' +
|
||||
'rotate(' + attTh + 'rad)',
|
||||
r: r,
|
||||
offTh: offTh,
|
||||
offPhi: 0 - phi,
|
||||
diag: go.diag,
|
||||
removeR: r + go.diag,
|
||||
visible: false,
|
||||
display: go_jel.css('display')
|
||||
};
|
||||
attached.push(newAtt);
|
||||
grow(go);
|
||||
el.style.position = 'absolute';
|
||||
el.style.left = (-offLeft) + 'px';
|
||||
el.style.top = (-offTop) + 'px';
|
||||
el.style.setProperty(CSS_TRANSFORM_ORIGIN,
|
||||
offLeft + 'px ' + offTop + 'px', null);
|
||||
el.style.display = 'none';
|
||||
/* copy computed styles from old object. */
|
||||
el.style.color = go_jel.css('color');
|
||||
el.style.textDecoration = go_jel.css('text-decoration');
|
||||
el.style.fontSize = go_jel.css('font-size');
|
||||
el.style.fontWeight = go_jel.css('font-weight');
|
||||
el.khIgnore = true;
|
||||
attachedDiv.appendChild(el);
|
||||
if (sounds) {
|
||||
sounds.play_pop();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the object should be removed from stickyNodes.
|
||||
*/
|
||||
function removeIntCb(go) {
|
||||
if (CHECK_VOLS && gridObjVol(go) > getVol()) {
|
||||
return false;
|
||||
}
|
||||
attachGridObj(go);
|
||||
return true;
|
||||
}
|
||||
|
||||
this.updatePhysics = function () {
|
||||
var oldX = x, oldY = y, dx, dy,
|
||||
bounce = false,
|
||||
accelTh;
|
||||
if (accel) {
|
||||
accelTh = Math.atan2(accelTargetY - y, accelTargetX - x);
|
||||
vx += Math.cos(accelTh) * 0.5;
|
||||
vy += Math.sin(accelTh) * 0.5;
|
||||
} else {
|
||||
vx *= 0.95;
|
||||
vy *= 0.95;
|
||||
}
|
||||
x += vx;
|
||||
y += vy;
|
||||
/* bounce ball on edges of document. */
|
||||
if (x - radius < 0) {
|
||||
bounce = true;
|
||||
x = radius + 1;
|
||||
vx = -vx;
|
||||
} else if (x + radius > docW) {
|
||||
bounce = true;
|
||||
x = docW - radius - 1;
|
||||
vx = -vx;
|
||||
}
|
||||
if (y - radius < 0) {
|
||||
bounce = true;
|
||||
y = radius + 1;
|
||||
vy = -vy;
|
||||
} else if (y + radius > docH) {
|
||||
bounce = true;
|
||||
y = docH - radius - 1;
|
||||
vy = -vy;
|
||||
}
|
||||
if (vx !== 0 || vy !== 0) {
|
||||
th = Math.atan2(vy, vx);
|
||||
dx = x - oldX;
|
||||
dy = y - oldY;
|
||||
/* arclen = th * r, so th = arclen / r. */
|
||||
phi -= Math.sqrt(dx * dx + dy * dy) / radius;
|
||||
}
|
||||
stickyNodes.removeIntersecting(x, y, radius, removeIntCb);
|
||||
this.draw();
|
||||
if (bounce && sounds) {
|
||||
sounds.play_bounce();
|
||||
}
|
||||
};
|
||||
|
||||
function drawBall() {
|
||||
var sx1, sy1, sx2, sy2, dx, dy, i, pct1, pct2, z1, z2;
|
||||
/* move/resize canvas element. */
|
||||
canvas_el.style.left = (x - radius) + 'px';
|
||||
canvas_el.style.top = (y - radius) + 'px';
|
||||
if (radius != lastR) {
|
||||
canvas_el.width = 2 * radius + 1;
|
||||
canvas_el.height = 2 * radius + 1;
|
||||
lastR = radius;
|
||||
}
|
||||
/* draw white circle. */
|
||||
canvas_ctx.clearRect(0, 0, 2 * radius, 2 * radius);
|
||||
canvas_ctx.fillStyle = "#fff";
|
||||
canvas_ctx.beginPath();
|
||||
canvas_ctx.arc(radius, radius, radius - 1, 0, Math.PI * 2, true);
|
||||
canvas_ctx.fill();
|
||||
/* draw outer border. */
|
||||
canvas_ctx.strokeStyle = color;
|
||||
canvas_ctx.beginPath();
|
||||
canvas_ctx.arc(radius, radius, radius - 1, 0, Math.PI * 2, true);
|
||||
canvas_ctx.stroke();
|
||||
/* draw stripes. */
|
||||
canvas_ctx.fillStyle = color;
|
||||
sx1 = radius + radius * Math.cos(th + Math.PI / 16);
|
||||
sy1 = radius + radius * Math.sin(th + Math.PI / 16);
|
||||
sx2 = radius + radius * Math.cos(th - Math.PI / 16);
|
||||
sy2 = radius + radius * Math.sin(th - Math.PI / 16);
|
||||
dx = (radius + radius * Math.cos(th + Math.PI * 15 / 16)) - sx1;
|
||||
dy = (radius + radius * Math.sin(th + Math.PI * 15 / 16)) - sy1;
|
||||
for (i = 0; i < Math.PI * 2; i += Math.PI / 7) {
|
||||
pct1 = (-Math.cos(phi + i) + 1) / 2;
|
||||
pct2 = (-Math.cos(phi + i + Math.PI / 32) + 1) / 2;
|
||||
z1 = Math.sin(phi + i);
|
||||
z2 = Math.sin(phi + i + Math.PI / 32);
|
||||
if (z1 > 0 && z2 > 0) {
|
||||
canvas_ctx.beginPath();
|
||||
canvas_ctx.moveTo(sx1 + pct1 * dx, sy1 + pct1 * dy);
|
||||
canvas_ctx.lineTo(sx1 + pct2 * dx, sy1 + pct2 * dy);
|
||||
canvas_ctx.lineTo(sx2 + pct2 * dx, sy2 + pct2 * dy);
|
||||
canvas_ctx.lineTo(sx2 + pct1 * dx, sy2 + pct1 * dy);
|
||||
canvas_ctx.fill();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return true if the attached object is roughly visible.
|
||||
*/
|
||||
function drawAttached(att) {
|
||||
var oth = th + att.offTh,
|
||||
ophi = phi + att.offPhi,
|
||||
ox = att.r * Math.cos(oth),
|
||||
oy = att.r * Math.sin(oth),
|
||||
dx = (att.r * Math.cos((th - att.offTh) + Math.PI)) - ox,
|
||||
dy = (att.r * Math.sin((th - att.offTh) + Math.PI)) - oy,
|
||||
pct = (-Math.cos(ophi) + 1) / 2,
|
||||
cx = ox + pct * dx,
|
||||
cy = oy + pct * dy,
|
||||
oz = att.r * Math.sin(ophi);
|
||||
if (oz < 0 && Math.sqrt(cx * cx + cy * cy) + att.diag < radius) {
|
||||
/* hidden behind circle. */
|
||||
if (att.visible) {
|
||||
att.visible = false;
|
||||
att.el.style.display = "none";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/* attached node is visible. */
|
||||
if (!att.visible) {
|
||||
att.visible = true;
|
||||
att.el.style.display = att.display;
|
||||
}
|
||||
//att.el.style.zIndex = 500 + Math.round(oz);
|
||||
att.el.style.zIndex = (oz > 0)? 501 : 499;
|
||||
att.el.style.setProperty(
|
||||
CSS_TRANSFORM,
|
||||
'translate(' + x + 'px,' + y + 'px) ' +
|
||||
'rotate(' + th + 'rad) ' +
|
||||
'scaleX(' + Math.cos(ophi) + ') ' +
|
||||
att.attT, null);
|
||||
return true;
|
||||
}
|
||||
|
||||
function onAttachedRemoved(att) {
|
||||
attachedDiv.removeChild(att.el);
|
||||
delete att.el;
|
||||
}
|
||||
|
||||
this.draw = function () {
|
||||
var i, att, numAttachedVisible = 0;
|
||||
drawBall();
|
||||
for (i = attached.length; --i >= 0;) {
|
||||
att = attached[i];
|
||||
if (att.removeR < radius) {
|
||||
attached.splice(i, 1).map(onAttachedRemoved);
|
||||
} else if (drawAttached(att)) {
|
||||
if (++numAttachedVisible > MAX_ATTACHED_VISIBLE) {
|
||||
/* remove older items and stop. */
|
||||
attached.splice(0, i).map(onAttachedRemoved);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function preventDefault(event) {
|
||||
event.preventDefault();
|
||||
event.returnValue = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
function Game(gameDiv, stickyNodes, ballOpts) {
|
||||
var stickyNodes, player1, physicsInterval, resizeInterval, listeners = [];
|
||||
player1 = new PlayerBall(gameDiv, stickyNodes, ballOpts, false);
|
||||
player1.init();
|
||||
player1.setXY(300, 300);
|
||||
window.scrollTo(0, 200);
|
||||
|
||||
function on_resize() {
|
||||
player1.setDocSize(jQuery(document).width() - 5,
|
||||
jQuery(document).height() - 5);
|
||||
}
|
||||
on_resize();
|
||||
|
||||
/* touch events - always on? */
|
||||
document.addEventListener('touchstart', function (event) {
|
||||
if (event.touches.length === 1) {
|
||||
player1.setAccel(true);
|
||||
return preventDefault(event);
|
||||
}
|
||||
}, true);
|
||||
document.addEventListener('touchmove', function (event) {
|
||||
player1.setAccelTarget(event.touches[0].pageX,
|
||||
event.touches[0].pageY);
|
||||
}, true);
|
||||
document.addEventListener('touchend', function (event) {
|
||||
if (event.touches.length === 0) {
|
||||
player1.setAccel(false);
|
||||
return preventDefault(event);
|
||||
}
|
||||
}, true);
|
||||
|
||||
if (ballOpts.MOUSEB !== -5) {
|
||||
/* mouse buttons */
|
||||
document.addEventListener('mousemove', function (event) {
|
||||
player1.setAccelTarget(event.pageX, event.pageY);
|
||||
}, true);
|
||||
document.addEventListener('mousedown', function (event) {
|
||||
if (event.button === ballOpts.MOUSEB) {
|
||||
player1.setAccel(true);
|
||||
return preventDefault(event);
|
||||
}
|
||||
}, true);
|
||||
document.addEventListener('mouseup', function (event) {
|
||||
if (event.button === ballOpts.MOUSEB) {
|
||||
player1.setAccel(false);
|
||||
return preventDefault(event);
|
||||
}
|
||||
}, true);
|
||||
|
||||
if (ballOpts.MOUSEB === 0) {
|
||||
/* block click events. */
|
||||
document.addEventListener('click', function (event) {
|
||||
if (event.button === 0) {
|
||||
return preventDefault(event);
|
||||
}
|
||||
}, true);
|
||||
} else if (ballOpts.MOUSEB === 2) {
|
||||
/* block right-click context menu. */
|
||||
document.addEventListener('contextmenu', preventDefault, true);
|
||||
}
|
||||
}
|
||||
|
||||
physicsInterval = setInterval(function () {
|
||||
player1.updatePhysics();
|
||||
}, 25);
|
||||
resizeInterval = setInterval(on_resize, 1000);
|
||||
}
|
||||
|
||||
function whenAllLoaded(gameDiv, popup, stickyNodes) {
|
||||
stickyNodes.finalize(jQuery(document).width(), jQuery(document).height());
|
||||
jQuery('#loadingp').empty();
|
||||
jQuery('<button>Start!</button>').click(function () {
|
||||
var game, bgmusic, ballOpts;
|
||||
if (jQuery('#bgmusicc').attr('checked')) {
|
||||
if (!(bgmusic = document.getElementById('khbgmusic'))) {
|
||||
bgmusic = document.createElement('audio');
|
||||
bgmusic.id = 'khbgmusic';
|
||||
bgmusic.loop = 'loop';
|
||||
bgmusic.src = 'http://kathack.com/js/katamari.mp3';
|
||||
gameDiv.appendChild(bgmusic);
|
||||
}
|
||||
bgmusic.play();
|
||||
}
|
||||
ballOpts = {
|
||||
color: jQuery('#khcolor').val(),
|
||||
VOL_MULT: parseFloat(jQuery('#vol_mult').val()),
|
||||
MAX_ATTACHED_VISIBLE: parseInt(jQuery('#maxAtt').val(), 10),
|
||||
CHECK_VOLS: (jQuery('#checkv').attr('checked'))? true : false,
|
||||
MOUSEB: parseInt(jQuery('#mouseb').val(), 10)
|
||||
};
|
||||
gameDiv.removeChild(popup);
|
||||
game = new Game(gameDiv, stickyNodes, ballOpts);
|
||||
}).appendTo('#loadingp');
|
||||
}
|
||||
|
||||
function buildPopup(gameDiv) {
|
||||
var d = document.createElement('div'), b;
|
||||
d.style.cssText = '\
|
||||
position: fixed;\
|
||||
left: 50%;\
|
||||
top: 50%;\
|
||||
width: 400px;\
|
||||
margin-left:-200px;\
|
||||
margin-top:-150px;\
|
||||
border:1px solid black;\
|
||||
background-color:white;\
|
||||
color:black;\
|
||||
padding:20px;\
|
||||
font-size:13px;\
|
||||
text-align:left;\
|
||||
z-index:501;';
|
||||
d.innerHTML = '<h1 style="font-size:16pt">\
|
||||
<a href="http://kathack.com/" style="color:blue;text-decoration:none;">\
|
||||
Katamari!</a></h1>\
|
||||
<button style="position:absolute;top:0;right:0;">X</button>\
|
||||
<p>Controls: Hold down <b><select id="mouseb">\
|
||||
<option value="0">Left-Click</option>\
|
||||
<option value="2" selected="selected">Right-Click</option>\
|
||||
<option value="-5">Touch</option>\
|
||||
</select></b> to control the ball!</p>\
|
||||
<div><label>Background Music? \
|
||||
<input id="bgmusicc" type="checkbox" checked="checked" /></label></div>\
|
||||
<div style="text-align:right; color:gray;">\
|
||||
<label>Katamari Color: <select id="khcolor">\
|
||||
<option value="#ff0000" style="background-color:#ff0000;color:#ff0000"> r </option>\
|
||||
<option value="#00ff00" style="background-color:#00ff00;color:#00ff00"> g </option>\
|
||||
<option value="#0000ff" style="background-color:#0000ff;color:#0000ff"> b </option>\
|
||||
<option selected="selected" value="#7D26CD" style="background-color:#7D26CD;color:#7D26CD"> p \
|
||||
</option></select></label><br />\
|
||||
<label title="Lower this if the game gets slow.">\
|
||||
Max Attached Objects: <select id="maxAtt">\
|
||||
<option>25</option>\
|
||||
<option>50</option>\
|
||||
<option selected="selected">75</option>\
|
||||
<option>100</option>\
|
||||
<option>9000</option></select></label><br />\
|
||||
<label title="How much to grow when an object is picked up.">\
|
||||
Growth Speed: <input id="vol_mult" type="text" size="6" value="1.0" />\
|
||||
</label><br />\
|
||||
<label title="Bigger objects require a bigger katamari to pick up.">\
|
||||
Realistic Pickups? <input id="checkv" type="checkbox" checked="checked" />\
|
||||
</label></div>\
|
||||
<p id="loadingp">Loading!</p>';
|
||||
gameDiv.appendChild(d);
|
||||
d.getElementsByTagName('button')[0].addEventListener('click', function () {
|
||||
gameDiv.removeChild(d);
|
||||
}, true);
|
||||
return d;
|
||||
}
|
||||
|
||||
function main() {
|
||||
var gameDiv, checkInterval, stickyNodes, popup;
|
||||
|
||||
gameDiv = document.createElement('div');
|
||||
gameDiv.khIgnore = true;
|
||||
document.body.appendChild(gameDiv);
|
||||
popup = buildPopup(gameDiv);
|
||||
|
||||
/* setTimeout so that the popup displays before we freeze. */
|
||||
setTimeout(function () {
|
||||
var i, len, el;
|
||||
window.khNodes.addWords(document.body);
|
||||
for (i = 0, len = document.body.childNodes.length; i < len; i++) {
|
||||
el = document.body.childNodes[i];
|
||||
window.khNodes.addTagNames(el, [
|
||||
'button', 'canvas', 'iframe', 'img', 'input', 'select',
|
||||
'textarea'
|
||||
]);
|
||||
}
|
||||
|
||||
checkInterval = setInterval(function () {
|
||||
if (window.jQuery) {
|
||||
clearInterval(checkInterval);
|
||||
whenAllLoaded(gameDiv, popup, window.khNodes);
|
||||
}
|
||||
}, 100);
|
||||
}, 0);
|
||||
}
|
||||
|
||||
if (!window.noMain) {
|
||||
main();
|
||||
}
|
164
js/main.js
Normal file
164
js/main.js
Normal file
@ -0,0 +1,164 @@
|
||||
var interval;
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
if (localStorage.getItem("theme")) {
|
||||
localStorage.setItem("selenite.theme", localStorage.getItem("theme"));
|
||||
localStorage.removeItem("theme");
|
||||
}
|
||||
if (localStorage.getItem("selenite.theme")) {
|
||||
document.body.setAttribute("theme", localStorage.getItem("selenite.theme"));
|
||||
} else {
|
||||
document.body.setAttribute("theme", "main");
|
||||
}
|
||||
if (document.querySelectorAll("[id=adcontainer]")) {
|
||||
for (let i = 0; i < document.querySelectorAll("[id=adcontainer]").length; i++) {
|
||||
if (Math.random() < 0.5 || localStorage.getItem("selenite.adblock") == "true") document.querySelectorAll("[id=adcontainer]")[i].innerHTML = "";
|
||||
}
|
||||
}
|
||||
const iconSetting = document.querySelector("input#discordIcon");
|
||||
const blockClose = document.querySelector("input#blockClose");
|
||||
const openBlank = document.getElementById("blank");
|
||||
const bgTheme = document.querySelector("input#bgTheme");
|
||||
// if (document.querySelector("widgetbot-crate")) {
|
||||
// if (localStorage.getItem("selenite.discordIcon") == "true") {
|
||||
// const widget = document.querySelector("widgetbot-crate");
|
||||
// widget.setAttribute("style", "display:none");
|
||||
// }
|
||||
// }
|
||||
if (document.querySelector("input#discordIcon")) {
|
||||
if (localStorage.getItem("selenite.discordIcon") == "true") {
|
||||
iconSetting.checked = true;
|
||||
}
|
||||
iconSetting.addEventListener("click", () => {
|
||||
localStorage.setItem("selenite.discordIcon", iconSetting.checked);
|
||||
});
|
||||
}
|
||||
if (document.querySelector("input#blockClose")) {
|
||||
if (localStorage.getItem("selenite.blockClose") == "true") {
|
||||
blockClose.checked = true;
|
||||
}
|
||||
blockClose.addEventListener("click", () => {
|
||||
localStorage.setItem("selenite.blockClose", blockClose.checked);
|
||||
});
|
||||
}
|
||||
if (document.querySelector("input#tabDisguise")) {
|
||||
if (localStorage.getItem("selenite.tabDisguise") == "true") {
|
||||
tabDisguise.checked = true;
|
||||
}
|
||||
tabDisguise.addEventListener("click", () => {
|
||||
localStorage.setItem("selenite.tabDisguise", tabDisguise.checked);
|
||||
});
|
||||
}
|
||||
if (document.querySelector("input#bgTheme")) {
|
||||
bgTheme.checked = true;
|
||||
}
|
||||
document.getElementById("blank").addEventListener("click", () => {
|
||||
win = window.open();
|
||||
win.document.body.style.margin = "0";
|
||||
win.document.body.style.height = "100vh";
|
||||
html = `
|
||||
<style>*{margin:0;padding:0;border:none}body,iframe{height:100vh;width:100vw}iframe{height:96vh}header{display:flex;height:4vh;justify-content:center;}button{margin-right:100px;height:100%;aspect-ratio: 1 / 1}#reload{background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 -960 960 960' width='24'%3E%3Cpath d='M480-160q-134 0-227-93t-93-227q0-134 93-227t227-93q69 0 132 28.5T720-690v-110h80v280H520v-80h168q-32-56-87.5-88T480-720q-100 0-170 70t-70 170q0 100 70 170t170 70q77 0 139-44t87-116h84q-28 106-114 173t-196 67Z'/%3E%3C/svg%3E");background-size:cover;}#goBack{background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='24' viewBox='0 -960 960 960' width='24'%3E%3Cpath d='M240-200h120v-240h240v240h120v-360L480-740 240-560v360Zm-80 80v-480l320-240 320 240v480H520v-240h-80v240H160Zm320-350Z'/%3E%3C/svg%3E");background-size:cover;}</style><script>
|
||||
</script><header><button id=goBack></button><button id=reload></button></header><iframe id=selenite></iframe>`;
|
||||
win.document.querySelector("html").innerHTML = html;
|
||||
win.eval(`let selenite = document.getElementById("selenite");console.log(selenite);selenite.setAttribute("src", "${location.origin}");console.log(selenite);document.getElementById("goBack").addEventListener("click", function () {selenite.contentDocument.location.href = selenite.contentDocument.location.origin;});document.getElementById("reload").addEventListener("click", function () {selenite.contentDocument.location.href = selenite.contentDocument.location.href;})`);
|
||||
location.href = "https://google.com";
|
||||
close();
|
||||
});
|
||||
if ($("#panicmode").length > 0) {
|
||||
$("#panicmode").prop({ href: panicurl });
|
||||
}
|
||||
if ($(".seleniteminified").length > 0) {
|
||||
$.get("https://raw.githubusercontent.com/skysthelimitt/selenite-optimized/main/build/bookmark.txt", function (data) {
|
||||
$(".seleniteminified").prop({ href: data });
|
||||
});
|
||||
$.get("https://raw.githubusercontent.com/car-axle-client/car-axle-client/v10/dist/build.js", function (data) {
|
||||
$(".caraxle").prop({ href: `javascript:${encodeURI(data)}` });
|
||||
});
|
||||
}
|
||||
});
|
||||
function setPanicMode() {
|
||||
if (!$("#panic").val().startsWith("https")) {
|
||||
document.cookie = "panicurl=https://" + $("#panic").val();
|
||||
return;
|
||||
}
|
||||
|
||||
document.cookie = "panicurl=" + $("#panic").val();
|
||||
}
|
||||
function copyToClipboard(text) {
|
||||
navigator.clipboard.writeText(text);
|
||||
alert("Copied text!");
|
||||
}
|
||||
function setTheme(theme) {
|
||||
localStorage.setItem("selenite.theme", theme);
|
||||
document.body.setAttribute("theme", theme);
|
||||
if (theme != "custom") {
|
||||
document.getElementById("customMenu").style.display = "none";
|
||||
document.body.style = "";
|
||||
}
|
||||
}
|
||||
function setPanicMode() {
|
||||
if (!$("#panic").val().startsWith("https")) {
|
||||
document.cookie = "panicurl=https://" + $("#panic").val();
|
||||
return;
|
||||
}
|
||||
document.cookie = "panicurl=" + $("#panic").val();
|
||||
}
|
||||
function setPassword() {
|
||||
localStorage.setItem("selenite.password", enc.encode(document.getElementById("pass").value));
|
||||
}
|
||||
function delPassword() {
|
||||
location.hash = "";
|
||||
localStorage.removeItem("selenite.passwordAtt");
|
||||
localStorage.removeItem("selenite.password");
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
if (!window.location.href.startsWith("about:")) {
|
||||
$("#webicon").attr("placeholder", window.location.href.replace(/\/[^\/]*$/, "/"));
|
||||
}
|
||||
});
|
||||
function loadScript(a, b) {
|
||||
var c = document.createElement("script");
|
||||
(c.type = "text/javascript"), (c.src = a), (c.onload = b), document.head.appendChild(c);
|
||||
}
|
||||
function toast(message, onclick) {
|
||||
const toast = document.createElement("div");
|
||||
toast.setAttribute("id", "toast");
|
||||
console.log(message.time);
|
||||
toast.innerHTML = `<div class=samerow><h1>${message.title}${message.time ? ` - ${timeAgo(new Date(message.time * 1000))}` : ""}</h1></div><p>${message.message}</p>`;
|
||||
toast.style.animation = "toastFade 6s";
|
||||
document.body.appendChild(toast);
|
||||
if (onclick) {
|
||||
toast.addEventListener("click", onclick);
|
||||
toast.style.cursor = "pointer";
|
||||
}
|
||||
setTimeout(() => {
|
||||
toast.remove();
|
||||
}, 6000);
|
||||
}
|
||||
function timeAgo(input) {
|
||||
const date = input instanceof Date ? input : new Date(input);
|
||||
const formatter = new Intl.RelativeTimeFormat("en");
|
||||
const ranges = {
|
||||
years: 3600 * 24 * 365,
|
||||
months: 3600 * 24 * 30,
|
||||
weeks: 3600 * 24 * 7,
|
||||
days: 3600 * 24,
|
||||
hours: 3600,
|
||||
minutes: 60,
|
||||
seconds: 1,
|
||||
};
|
||||
const secondsElapsed = (date.getTime() - Date.now()) / 1000;
|
||||
for (let key in ranges) {
|
||||
if (ranges[key] < Math.abs(secondsElapsed)) {
|
||||
const delta = secondsElapsed / ranges[key];
|
||||
return formatter.format(Math.round(delta), key);
|
||||
}
|
||||
}
|
||||
}
|
||||
let cookieConsentScript = document.createElement("script");
|
||||
cookieConsentScript.src = "/js/cookieConsent.js";
|
||||
document.head.appendChild(cookieConsentScript);
|
||||
let cookieConsentStyle = document.createElement("link");
|
||||
cookieConsentStyle.href = "/js/cookieConsent.css";
|
||||
cookieConsentStyle.rel = "stylesheet";
|
||||
document.head.appendChild(cookieConsentStyle);
|
69
js/oldstuff.js
Normal file
69
js/oldstuff.js
Normal file
@ -0,0 +1,69 @@
|
||||
|
||||
// if (location.hash) {
|
||||
// let temp;
|
||||
// if(!location.pathname.includes("gba")) {
|
||||
// localStorage.setItem("selenite.password", location.hash.substring(1));
|
||||
// if (JSON.parse(localStorage.getItem("selenite.passwordAtt"))) {
|
||||
// if (JSON.parse(localStorage.getItem("selenite.passwordAtt"))[0] == true && Math.floor(Date.now() / 1000) - JSON.parse(localStorage.getItem("selenite.passwordAtt"))[1] < 600) {
|
||||
// console.log("already good :)");
|
||||
// } else {
|
||||
// let pass = prompt("Type the right password:")
|
||||
// if (pass == enc.decode(location.hash.substring(1)) || pass == "tempgbafix") {
|
||||
// localStorage.setItem("selenite.passwordAtt", `[true,${Math.floor(Date.now() / 1000)}]`);
|
||||
// console.log("Correct password!");
|
||||
// } else {
|
||||
// localStorage.setItem("selenite.passwordAtt", `[false,${Math.floor(Date.now() / 1000)}]`);
|
||||
// location.href = "https://google.com";
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// let pass = prompt("Type the right password:")
|
||||
// if (pass == enc.decode(location.hash.substring(1)) || pass == "tempgbafix") {
|
||||
// localStorage.setItem("selenite.passwordAtt", `[true,${Math.floor(Date.now() / 1000)}]`);
|
||||
// console.log("Correct password!");
|
||||
// } else {
|
||||
// localStorage.setItem("selenite.passwordAtt", `[false,${Math.floor(Date.now() / 1000)}]`);
|
||||
// location.href = "https://google.com";
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
if(localStorage.getItem("selenite.password") && !location.hash) {
|
||||
alert("password, but no hash");
|
||||
}
|
||||
if (location.hash) {
|
||||
function isSeleniteHash(hash) {
|
||||
try {
|
||||
decodedHash = enc.decode(hash);
|
||||
JSON.parse(decodedHash);
|
||||
return true;
|
||||
} catch {
|
||||
console.error("failed :(");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
function tryPass(password) {
|
||||
let passAttempt = prompt("Type your Selenite password:");
|
||||
if(localStorage.getItem("selenite.password")) {
|
||||
if(passAttempt == password) {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
localStorage.setItem("selenite.password", enc.encode(password));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (isSeleniteHash(location.hash.substring(1))) {
|
||||
decodedHash = JSON.parse(enc.decode(location.hash.substring(1)));
|
||||
if (decodedHash["selenite"]) {
|
||||
if (decodedHash["pass"]) {
|
||||
tryPass(decodedHash["pass"]);
|
||||
}
|
||||
if (decodedHash["theme"]) {
|
||||
if (changeTheme) {
|
||||
alert("theme detected!!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
31
js/savedownload.js
Normal file
31
js/savedownload.js
Normal file
@ -0,0 +1,31 @@
|
||||
var s = document.createElement("script");
|
||||
function getMainSave() {
|
||||
alert(
|
||||
"Thank you for using the Selenite Backup Utility! You can transfer your data to https://selenite.cc or use the Selenite Uploader Utility!"
|
||||
);
|
||||
var e = {},
|
||||
a = Object.entries(localStorage);
|
||||
(a = btoa(JSON.stringify(a))), (e.localStorage = a);
|
||||
var t = document.cookie;
|
||||
return (
|
||||
(t = btoa(t)),
|
||||
(e.cookies = t),
|
||||
(e = btoa(JSON.stringify(e))),
|
||||
(e = CryptoJS.AES.encrypt(e, "egamepass").toString())
|
||||
);
|
||||
}
|
||||
function downloadMainSave() {
|
||||
var e = new Blob([getMainSave()]),
|
||||
a = window.URL.createObjectURL(e),
|
||||
t = document.createElement("a");
|
||||
(t.href = a),
|
||||
(t.download = "your.selenite.save"),
|
||||
t.click(),
|
||||
URL.revokeObjectURL(a);
|
||||
}
|
||||
(s.src =
|
||||
"https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"),
|
||||
document.head.appendChild(s);
|
||||
s.onload = function () {
|
||||
downloadMainSave();
|
||||
};
|
28
js/search.js
Normal file
28
js/search.js
Normal file
@ -0,0 +1,28 @@
|
||||
function searchGames() {
|
||||
search = 1;
|
||||
var txt = $("#gamesearch").val();
|
||||
if (txt == "") {
|
||||
$("#games .suggest").show();
|
||||
} else {
|
||||
$("#games .suggest").hide();
|
||||
}
|
||||
$("#games .game").hide();
|
||||
$("#games .game").each(function () {
|
||||
if ($(this).text().toUpperCase().indexOf(txt.toUpperCase()) != -1 || $(this).attr("id").toUpperCase().indexOf(txt.toUpperCase()) != -1) {
|
||||
$(this).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
let urlParams = new URLSearchParams(window.location.search);
|
||||
let q = urlParams.get("q");
|
||||
if (q) {
|
||||
document.getElementById("gamesearch").value = q;
|
||||
searchGames();
|
||||
urlParams.delete("q");
|
||||
window.history.replaceState({}, document.title, location.pathname);
|
||||
}
|
||||
document.getElementById("gamesearch").addEventListener("input", () => {
|
||||
searchGames();
|
||||
});
|
||||
});
|
86
js/themes.js
Normal file
86
js/themes.js
Normal file
@ -0,0 +1,86 @@
|
||||
function customTheme() {
|
||||
localStorage.setItem("selenite.theme", "custom");
|
||||
document.body.setAttribute("theme", "custom");
|
||||
document.getElementById("customMenu").style.display = "block";
|
||||
loadTheme();
|
||||
}
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
loadTheme();
|
||||
if(localStorage.getItem("selenite.theme") == "custom"){
|
||||
document.getElementById("customMenu").style.display = "block";
|
||||
document.getElementById("inputbg").value = getComputedStyle(document.body).getPropertyValue("--inputbg");
|
||||
document.getElementById("uibg").value = getComputedStyle(document.body).getPropertyValue("--uibg");
|
||||
document.getElementById("textcolor").value = getComputedStyle(document.body).getPropertyValue("--textcolor");
|
||||
document.getElementById("bg").value = getComputedStyle(document.body).getPropertyValue("--bg");
|
||||
if(getComputedStyle(document.body).getPropertyValue("--bg").includes("url")){
|
||||
document.getElementById("bgimg").value = getComputedStyle(document.body).getPropertyValue("--bg").replace("url(", "").replace(")", "");
|
||||
document.getElementById("bg").value = "#000000";
|
||||
} else {
|
||||
document.getElementById("bg").value = getComputedStyle(document.body).getPropertyValue("--bg");
|
||||
}
|
||||
};
|
||||
if(location.pathname.includes("/settings")) {
|
||||
document.getElementById("inputbg").addEventListener("change", (e) => {
|
||||
changeTheme("inputbg", e.target.value);
|
||||
});
|
||||
document.getElementById("inputborder").addEventListener("change", (e) => {
|
||||
changeTheme("inputborder", e.target.value);
|
||||
});
|
||||
document.getElementById("uibg").addEventListener("change", (e) => {
|
||||
changeTheme("uibg", e.target.value);
|
||||
});
|
||||
document.getElementById("textcolor").addEventListener("change", (e) => {
|
||||
changeTheme("textcolor", e.target.value);
|
||||
});
|
||||
document.getElementById("bg").addEventListener("change", (e) => {
|
||||
changeTheme("bg", e.target.value);
|
||||
});
|
||||
document.getElementById("bgimg").addEventListener("keydown", (e) => {
|
||||
if (e.key == "Enter") {
|
||||
changeTheme("bg", e.target.value);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
function loadTheme() {
|
||||
if (localStorage.getItem("selenite.theme") == "custom") {
|
||||
let theme = localStorage.getItem("selenite.customTheme");
|
||||
if (theme) {
|
||||
theme = JSON.parse(theme);
|
||||
for (let i = 0; i < Object.keys(theme).length; i++) {
|
||||
document.body.style.setProperty(`--${Object.keys(theme)[i]}`, eval(`theme.${Object.keys(theme)[i]} `));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function changeTheme(name, value) {
|
||||
if(isValidHttpUrl(value)){
|
||||
value = `url(${value})`;
|
||||
}
|
||||
ogStyle = localStorage.getItem("selenite.customTheme");
|
||||
if (ogStyle) {
|
||||
ogStyle = JSON.parse(ogStyle);
|
||||
ogStyle[name] = value;
|
||||
localStorage.setItem("selenite.customTheme", JSON.stringify(ogStyle));
|
||||
loadTheme();
|
||||
} else {
|
||||
ogStyle = {};
|
||||
ogStyle[name] = value;
|
||||
localStorage.setItem("selenite.customTheme", JSON.stringify(ogStyle));
|
||||
loadTheme();
|
||||
}
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/a/43467144
|
||||
function isValidHttpUrl(string) {
|
||||
let url;
|
||||
|
||||
try {
|
||||
url = new URL(string);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return url.protocol === "http:" || url.protocol === "https:";
|
||||
}
|
5
js/ultimatetabcloak.js
Normal file
5
js/ultimatetabcloak.js
Normal file
@ -0,0 +1,5 @@
|
||||
var l = document.querySelector("link[rel*='icon']") || document.createElement("link");
|
||||
l.type = "image/x-icon";
|
||||
l.rel = "shortcut icon";
|
||||
var c = prompt("Select a tab cloak\n1. Canvas\n2. e-hallpass\n3. New Tab");
|
||||
1 == c ? ((l.href = "https://harrisonburg.instructure.com/favicon.ico"), (document.title = "Dashboard")) : 2 == c ? ((l.href = "https://eduspiresolutions.org/wp-content/uploads/2020/09/cropped-favicon-270x270-1-150x150.png"), (document.title = "Digital Hall Pass | e-Hall Pass | Eduspire Solutions")) : 3 == c && ((l.href = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAA/UlEQVR42q2S0Q3CMAxEGYERGIFP1FJ0JEXikw1gA9gANqAbwCaMwAgdoSNAHpVRE7UIISKd1Dq+s33O6O9H0ngudyzk67n8o0V5z+UvM60nH8kL+W0gNJAG0ORyh15yJrcj6RtQaKj1V/VQhfb3M2kyhIgckqtWoDxBJiHTakoc2Ozh/ogXIOoCkwqVZ0QK+Q2ExIsGQea3WBCp3wIWJKn9X1Y9s1d01o2lAuD2k0C8cymTpmYo4BtyvCl373pw6s6GBxDMRATTQsR7V2giuIwId7aBtKOvHhJC6VZylf2vkTXFnbi6jfurVS5CodGnY7Njkr0JZscnG+ev5wl1Bukqc4CB7gAAAABJRU5ErkJggg=="), (document.title = "New Tab"));
|
48
js/uploaddownload.js
Normal file
48
js/uploaddownload.js
Normal file
@ -0,0 +1,48 @@
|
||||
var s = document.createElement("script");
|
||||
function getMainSaveFromUpload(data) {
|
||||
data = CryptoJS.AES.decrypt(data, "egamepass").toString(CryptoJS.enc.Utf8);
|
||||
|
||||
// Parse the decrypted data as JSON
|
||||
var mainSave = JSON.parse(atob(data));
|
||||
var mainLocalStorageSave = JSON.parse(atob(mainSave.localStorage));
|
||||
var cookiesSave = atob(mainSave.cookies);
|
||||
|
||||
// Set the items in localStorage using the uploaded data
|
||||
for (let item of mainLocalStorageSave) {
|
||||
localStorage.setItem(item[0], item[1]);
|
||||
}
|
||||
|
||||
// Set the cookies using the uploaded data
|
||||
document.cookie = cookiesSave;
|
||||
}
|
||||
|
||||
// Function to handle the file upload
|
||||
function uploadMainSave() {
|
||||
document.body.innerHTML +=
|
||||
'<input class="hiddenUpload" type="file" accept=".save"/>';
|
||||
var hiddenUpload = document.querySelector(".hiddenUpload");
|
||||
|
||||
// Listen for the change event on the file input element
|
||||
hiddenUpload.addEventListener("change", function (e) {
|
||||
var files = e.target.files;
|
||||
var file = files[0];
|
||||
if (!file) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Read the contents of the uploaded file as text and call getMainSaveFromUpload with the result
|
||||
var reader = new FileReader();
|
||||
|
||||
reader.onload = function (e) {
|
||||
getMainSaveFromUpload(e.target.result);
|
||||
};
|
||||
|
||||
reader.readAsText(file);
|
||||
});
|
||||
}
|
||||
(s.src =
|
||||
"https://cdnjs.cloudflare.com/ajax/libs/crypto-js/4.1.1/crypto-js.min.js"),
|
||||
document.head.appendChild(s);
|
||||
s.onload = function () {
|
||||
uploadMainSave();
|
||||
};
|
25
js/widget.js
Normal file
25
js/widget.js
Normal file
@ -0,0 +1,25 @@
|
||||
let firstLoadWidget = 1;
|
||||
let widgetOpen = 0;
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
let button = document.createElement("button");
|
||||
button.setAttribute("id", "discord");
|
||||
document.body.appendChild(button);
|
||||
button.addEventListener("click", () => {
|
||||
if(firstLoadWidget) {
|
||||
toast({ title: "Do you want to load Discord?", message: "This may be blocked in certain schools.\nClick here to load Discord." }, loadWidget);
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
function loadWidget() {
|
||||
if(firstLoadWidget) {
|
||||
firstLoadWidget = 0;
|
||||
loadScript("https://cdn.jsdelivr.net/npm/@widgetbot/crate@3", loadCrate);
|
||||
}
|
||||
}
|
||||
function loadCrate() {
|
||||
new Crate({server: '1148719137238040606',channel: '1173731814196645909', color: "#00000000", glyph: ["data:;base64,=", "100%"]});
|
||||
crate.toggle(true);
|
||||
let element = document.querySelector('[aria-label="Discord chat embed"]');
|
||||
element.remove();
|
||||
}
|
Reference in New Issue
Block a user