good luck SSD
This commit is contained in:
parent
e6ea7b32f8
commit
8061f621f2
8 changed files with 157 additions and 4 deletions
File diff suppressed because one or more lines are too long
19
static/resources/appModules/database-manager.js
Normal file
19
static/resources/appModules/database-manager.js
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
const dbPromise = Ultraviolet.openDB('keyval-store', 1, {
|
||||||
|
upgrade(db) {
|
||||||
|
db.createObjectStore('keyval');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
self.storage = {
|
||||||
|
async get(key) {
|
||||||
|
return (await dbPromise).get('keyval', key);
|
||||||
|
},
|
||||||
|
|
||||||
|
async set(key, val) {
|
||||||
|
return (await dbPromise).put('keyval', val, key);
|
||||||
|
},
|
||||||
|
|
||||||
|
async del(key) {
|
||||||
|
return (await dbPromise).delete('keyval', key);
|
||||||
|
},
|
||||||
|
}
|
||||||
74
static/resources/appModules/selectBare.js
Normal file
74
static/resources/appModules/selectBare.js
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
|
||||||
|
const dbPromise = Ultraviolet.openDB('keyval-store', 1, {
|
||||||
|
upgrade(db) {
|
||||||
|
db.createObjectStore('keyval');
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
self.storage = {
|
||||||
|
async get(key) {
|
||||||
|
return (await dbPromise).get('keyval', key);
|
||||||
|
},
|
||||||
|
|
||||||
|
async set(key, val) {
|
||||||
|
return (await dbPromise).put('keyval', val, key);
|
||||||
|
},
|
||||||
|
|
||||||
|
async del(key) {
|
||||||
|
return (await dbPromise).delete('keyval', key);
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
function getBareLocation() {
|
||||||
|
const location = storage.get("bareLocation");
|
||||||
|
return location;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setBareLocation(location) {
|
||||||
|
if (/^http(s?):\/\//.test(location) || (location.includes('.') && val.substr(0, 1) !== ' ') || location.includes('/bare/')) {
|
||||||
|
storage.set("bareLocation", location);
|
||||||
|
return 'Bare is located at: ' + location;
|
||||||
|
} else {
|
||||||
|
console.log('Invalid Location provided, please provide a server in the format of http(s)://server.domain.com/');
|
||||||
|
return 'Invalid Location provided';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function bareValidator(bareLocation) {
|
||||||
|
fetch(bareLocation)
|
||||||
|
.then((res) => res.json())
|
||||||
|
.then((data) => {
|
||||||
|
if (data.project.name === "bare-server-node") {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
window.addEventListener("load", () => {
|
||||||
|
const _loc = document.getElementById('bareLocationInput')
|
||||||
|
const indicator = document.getElementById('validIndicator')
|
||||||
|
if (bareValidator(_loc.value) === true) {
|
||||||
|
indicator.innerText = 'Connected to server: ' + _loc.value
|
||||||
|
indicator.style.color = '#42f851'
|
||||||
|
} else if (bareValidator(_loc.value) === false) {
|
||||||
|
indicator.innerText = 'Could not connect to server: ' + _loc.value
|
||||||
|
indicator.style.color = '#f45145bd'
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('bareLocationInput').addEventListener('keydown', function (event) {
|
||||||
|
if (event.key === 'Enter') {
|
||||||
|
if (bareValidator(_loc.value) === true) {
|
||||||
|
indicator.innerText = 'Connected to server: ' + _loc.value
|
||||||
|
indicator.style.color = '#42f851'
|
||||||
|
setBareLocation(_loc.value)
|
||||||
|
} else if (bareValidator(_loc.value) === false) {
|
||||||
|
indicator.innerText = 'Could not connect to server: ' + _loc.value
|
||||||
|
indicator.style.color = '#f45145bd'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
@ -19,6 +19,12 @@ function closeNav() {
|
||||||
window.addEventListener("load", () => {
|
window.addEventListener("load", () => {
|
||||||
// Register the service workers for Osana and Ultraviolet proxy protocols
|
// Register the service workers for Osana and Ultraviolet proxy protocols
|
||||||
// This is a better method than registering onsubmit because this allows the ability to use proxied links on the main page.
|
// This is a better method than registering onsubmit because this allows the ability to use proxied links on the main page.
|
||||||
|
|
||||||
|
if (localStorage.getItem("_BareLocation") == undefined || localStorage.getItem("_BareLocation") == null) {
|
||||||
|
localStorage.setItem("_BareLocation", "/bare/")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
navigator.serviceWorker.register("./sw.js", {
|
navigator.serviceWorker.register("./sw.js", {
|
||||||
scope: "/service/",
|
scope: "/service/",
|
||||||
})
|
})
|
||||||
|
|
@ -65,7 +71,10 @@ window.addEventListener("load", () => {
|
||||||
return time
|
return time
|
||||||
}
|
}
|
||||||
// initialize the time function
|
// initialize the time function
|
||||||
|
|
||||||
|
if (window.location.pathname == "/"){
|
||||||
displayTime()
|
displayTime()
|
||||||
|
}
|
||||||
|
|
||||||
// Link evaluation
|
// Link evaluation
|
||||||
// This functions' purpose is to check a string of text (the argument)
|
// This functions' purpose is to check a string of text (the argument)
|
||||||
|
|
@ -83,6 +92,7 @@ window.addEventListener("load", () => {
|
||||||
const proxy = localStorage.getItem("proxy") || "uv"
|
const proxy = localStorage.getItem("proxy") || "uv"
|
||||||
const inpbox = document.querySelector("form")
|
const inpbox = document.querySelector("form")
|
||||||
// Display the "loading" indicators on the main page, looks much better than a static/still screen.
|
// Display the "loading" indicators on the main page, looks much better than a static/still screen.
|
||||||
|
|
||||||
inpbox.addEventListener("submit", (event) => {
|
inpbox.addEventListener("submit", (event) => {
|
||||||
// Prevents the default event tasks
|
// Prevents the default event tasks
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
|
|
|
||||||
|
|
@ -492,4 +492,38 @@ input:checked+label:after {
|
||||||
|
|
||||||
label:active:after {
|
label:active:after {
|
||||||
width: 38px;
|
width: 38px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.bareLocationInput {
|
||||||
|
border-style: solid !important;
|
||||||
|
border: var(--input-border-size) solid #5e18eb;
|
||||||
|
border-width: 0px;
|
||||||
|
border-radius: 6px;
|
||||||
|
background-color: #191724;
|
||||||
|
color: var(--input-text-color);
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
box-shadow: none !important;
|
||||||
|
outline: none;
|
||||||
|
text-align: center;
|
||||||
|
width: 220px;
|
||||||
|
font-size: 16px;
|
||||||
|
font-family: 'Roboto';
|
||||||
|
height: 29px;
|
||||||
|
transition: 0.06s;
|
||||||
|
}
|
||||||
|
.bareLocationInput:hover {
|
||||||
|
border: var(--input-border-size) solid #5e18eb;
|
||||||
|
border-width: 1px;
|
||||||
|
border-radius: 6px;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.bareValidSignal{
|
||||||
|
margin-top: -13px;
|
||||||
|
color: #f45145bd;
|
||||||
|
font-family: 'Ubuntu', sans-serif;
|
||||||
|
font-weight: lighter;
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
@ -1,3 +1,6 @@
|
||||||
|
importScripts('./uv/uv.bundle.js');
|
||||||
|
importScripts('./resources/appModules/database-manager.js');
|
||||||
|
importScripts('./uv/uv.config.js');
|
||||||
importScripts('./uv/uv.sw.js');
|
importScripts('./uv/uv.sw.js');
|
||||||
importScripts('./osana/osana.worker.js');
|
importScripts('./osana/osana.worker.js');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
|
|
||||||
|
|
||||||
self.__uv$config = {
|
self.__uv$config = {
|
||||||
prefix: '/service/go/',
|
prefix: '/service/go/',
|
||||||
bare: '/bare/',
|
bare: self.storage.get("bareLocation"),
|
||||||
encodeUrl: Ultraviolet.codec.xor.encode,
|
encodeUrl: Ultraviolet.codec.xor.encode,
|
||||||
decodeUrl: Ultraviolet.codec.xor.decode,
|
decodeUrl: Ultraviolet.codec.xor.decode,
|
||||||
handler: '/uv/uv.handler.js',
|
handler: '/uv/uv.handler.js',
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
importScripts('/uv/uv.bundle.js');
|
|
||||||
importScripts('/uv/uv.config.js');
|
|
||||||
|
|
||||||
class UVServiceWorker extends EventEmitter {
|
class UVServiceWorker extends EventEmitter {
|
||||||
constructor(config = __uv$config) {
|
constructor(config = __uv$config) {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue