more bug fixing
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { createViewPage } from './utils.js';
|
||||
import { createViewPage, isValidURL } from './utils.js';
|
||||
import PolarisError from './error.js';
|
||||
import effects from './effects.js';
|
||||
|
||||
@@ -21,7 +21,7 @@ const load = () => fetch('/assets/JSON/apps.json').then(res => res.json()).then(
|
||||
document.body.style.opacity = '0.7';
|
||||
|
||||
setTimeout(() => {
|
||||
if (URL.canParse(app.target)) createViewPage({
|
||||
if (isValidURL(app.target)) createViewPage({
|
||||
target: app.target,
|
||||
title: app.name,
|
||||
proxied: true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createViewPage } from './utils.js';
|
||||
import { createViewPage, isValidURL } from './utils.js';
|
||||
import PolarisError from './error.js';
|
||||
import effects from './effects.js';
|
||||
|
||||
@@ -22,7 +22,7 @@ const load = () => fetch('/assets/JSON/cheats.json')
|
||||
document.body.style.opacity = '0.7';
|
||||
|
||||
setTimeout(() => {
|
||||
if (URL.canParse(cheat.target)) createViewPage({
|
||||
if (isValidURL(cheat.target)) createViewPage({
|
||||
target: cheat.target,
|
||||
title: cheat.name,
|
||||
proxied: true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createViewPage } from './utils.js';
|
||||
import { createViewPage, isValidURL } from './utils.js';
|
||||
import PolarisError from './error.js';
|
||||
import effects from './effects.js';
|
||||
|
||||
@@ -55,7 +55,7 @@ const load = () => {
|
||||
document.body.style.opacity = '0.7';
|
||||
|
||||
setTimeout(() => {
|
||||
if (URL.canParse(game.target)) createViewPage({
|
||||
if (isValidURL(game.target)) createViewPage({
|
||||
target: game.target,
|
||||
title: game.name,
|
||||
proxied: true
|
||||
@@ -80,7 +80,7 @@ const load = () => {
|
||||
document.body.style.opacity = '0.7';
|
||||
|
||||
setTimeout(() => {
|
||||
if (URL.canParse(game.target)) createViewPage({
|
||||
if (isValidURL(game.target)) createViewPage({
|
||||
target: game.target,
|
||||
title: game.name,
|
||||
proxied: true
|
||||
|
||||
+31
-14
@@ -1,5 +1,5 @@
|
||||
import loadEasterEggs from './eastereggs.js';
|
||||
import { createViewPage } from './utils.js';
|
||||
import { createViewPage, isValidURL, getVH } from './utils.js';
|
||||
import PolarisError from './error.js';
|
||||
import Settings from './settings.js';
|
||||
import Search from './search.js';
|
||||
@@ -55,7 +55,7 @@ if (location.pathname === '/') {
|
||||
const game = games.filter(g => g.name === gameName)[0];
|
||||
|
||||
document.querySelector('.featured').addEventListener('click', () => {
|
||||
if (URL.canParse(game.target)) createViewPage({
|
||||
if (isValidURL(game.target)) createViewPage({
|
||||
target: game.target,
|
||||
title: game.name,
|
||||
proxied: true
|
||||
@@ -71,19 +71,36 @@ if (location.pathname === '/') {
|
||||
|
||||
fetch('/assets/JSON/changelog.json')
|
||||
.then(res => res.json())
|
||||
.then(changelog => changelog
|
||||
.filter((data, i) => !(i >= 3))
|
||||
.forEach(change => {
|
||||
const date = document.createElement('p');
|
||||
date.textContent = change.date;
|
||||
date.classList = 'small';
|
||||
document.querySelector('#changelog').appendChild(date);
|
||||
.then(changelog => {
|
||||
changelog
|
||||
.filter((data, i) => !(i >= 3))
|
||||
.forEach(change => {
|
||||
const log = document.createElement('div');
|
||||
document.querySelector('#changelog').appendChild(log);
|
||||
|
||||
const description = document.createElement('i');
|
||||
description.textContent = change.simpleDescription;
|
||||
description.classList = 'small';
|
||||
document.querySelector('#changelog').appendChild(description);
|
||||
}));
|
||||
const date = document.createElement('p');
|
||||
date.textContent = change.date;
|
||||
date.classList = 'small';
|
||||
log.appendChild(date);
|
||||
|
||||
const description = document.createElement('i');
|
||||
description.textContent = change.simpleDescription;
|
||||
description.classList = 'small';
|
||||
log.appendChild(description);
|
||||
});
|
||||
|
||||
const updateChangelog = (amount = 3) => {
|
||||
amount = amount - 1;
|
||||
|
||||
for (let i = 0; i < document.querySelector('#changelog').children.length; i++) {
|
||||
if (i > amount) document.querySelector('#changelog').children[i].classList.add('hidden');
|
||||
else document.querySelector('#changelog').children[i].classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
updateChangelog(!(getVH(100) - getVH(69) > document.querySelector('#changelog').clientHeight) ? 2 : 3);
|
||||
window.onresize = () => updateChangelog(!(getVH(100) - getVH(69) > document.querySelector('#changelog').clientHeight) ? 2 : 3);
|
||||
});
|
||||
}
|
||||
|
||||
if (window.self === window.top && location.pathname !== '/view') {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { createViewPage } from './utils.js';
|
||||
import { createViewPage, isValidURL } from './utils.js';
|
||||
|
||||
const load = () => {
|
||||
const form = document.querySelector('#wpf');
|
||||
@@ -7,7 +7,7 @@ const load = () => {
|
||||
form.addEventListener('submit', async (e) => {
|
||||
e.preventDefault();
|
||||
|
||||
const url = /^(http(s)?:\/\/)?([\w-]+\.)+[\w]{2,}(\/.*)?$/.test(query.value) ? ((!query.value.startsWith('http://') && !query.value.startsWith('https://')) ? 'https://' + query.value : query.value) : 'https://www.google.com/search?q=' + encodeURIComponent(query.value);
|
||||
const url = isValidURL(query.value) ? ((!query.value.startsWith('http://') && !query.value.startsWith('https://')) ? 'https://' + query.value : query.value) : 'https://www.google.com/search?q=' + encodeURIComponent(query.value);
|
||||
|
||||
document.body.style.opacity = '0.7';
|
||||
|
||||
|
||||
@@ -124,12 +124,25 @@ const createViewPage = (options) => location.href = `/view?load=${btoa(JSON.stri
|
||||
title: options.title
|
||||
}))}`;
|
||||
|
||||
/**
|
||||
* Check if a url is valid
|
||||
* @param {string} url
|
||||
* @returns {boolean}
|
||||
*/
|
||||
const isValidURL = (url) => /^(http(s)?:\/\/)?([\w-]+\.)+[\w]{2,}(\/.*)?$/.test(url);
|
||||
|
||||
const getVH = (value) => (value * Math.max(document.documentElement.clientHeight, window.innerHeight || 0)) / 100;
|
||||
const getVW = (value) => (value * Math.max(document.documentElement.clientWidth, window.innerWidth || 0)) / 100;
|
||||
|
||||
export default {
|
||||
storage,
|
||||
loadProxyWorker,
|
||||
encoder,
|
||||
redirect,
|
||||
createViewPage
|
||||
createViewPage,
|
||||
isValidURL,
|
||||
getVH,
|
||||
getVW
|
||||
};
|
||||
|
||||
export {
|
||||
@@ -137,5 +150,8 @@ export {
|
||||
loadProxyWorker,
|
||||
encoder,
|
||||
redirect,
|
||||
createViewPage
|
||||
createViewPage,
|
||||
isValidURL,
|
||||
getVH,
|
||||
getVW
|
||||
};
|
||||
Reference in New Issue
Block a user