dicc
This commit is contained in:
Malloc of Kuzkycyziklistan 2017-05-15 13:19:32 -05:00
parent 132e272580
commit eeacb55344
6 changed files with 143 additions and 21 deletions

7
client/deploy.bat Normal file
View file

@ -0,0 +1,7 @@
mkdir \\aroltd.com\aroltd\scape
mkdir \\aroltd.com\aroltd\scape\bin
copy /y /b index.html \\aroltd.com\aroltd\scape
copy /y /b error.html \\aroltd.com\aroltd\scape
copy /y /b style.css \\aroltd.com\aroltd\scape
copy /y /b bin\scape.js \\aroltd.com\aroltd\scape\bin
copy /y /b bin\lib.js \\aroltd.com\aroltd\scape\bin

View file

@ -24,7 +24,7 @@
font-style: italic;
}
#content {
.content {
width: 25%;
min-width: 300px;
max-width: 600px;
@ -32,6 +32,16 @@
padding: 30px 0;
}
@media screen and (max-width: 480px) {
.content {
width: 75%;
}
}
.hidden {
display: none;
}
ul {
list-style: none;
padding: 0;
@ -66,15 +76,22 @@
window.onload = function() {
var url = window.location.href;
url = url.substr(url.lastIndexOf("?") + 1);
var features = url.split("&")[0].split("=")[1];
var params = url.split("&");
var features = params[0].split("=")[1];
for(var i = 1; i <= features.length; ++i)
document.getElementById("supchk"+ i).className = features[i-1] == "1" ? "mark check" : "mark cross";
if(params.length >= 2) {
document.getElementById("noSupport").className = "content hidden";
document.getElementById("error").className = "content";
document.getElementById("errorText").innerText = decodeURIComponent(params[0].split("=")[1]);
} else {
for(var i = 1; i <= features.length; ++i)
document.getElementById("supchk"+ i).className = features[i-1] == "1" ? "mark check" : "mark cross";
}
}
</script>
</head>
<body>
<div id="content">
<div class="content" id="noSupport">
<h2>
Your browser does not support the required features to run this application.
</h2>
@ -94,5 +111,13 @@
such as <a href="https://www.mozilla.org">Mozilla Firefox</a> or <a href="https://www.google.com/chrome/">Google Chrome</a>.
</p>
</div>
<div class="content hidden" id="error">
<h2>An error occurred.</h2>
<p><i>Details: <span id="errorText"></span></i></p>
<p>Please report this error to <a href="mailto:aleco@aroltd.com">aleco@aroltd.com</a>.
</div>
</body>
</html>

View file

@ -23,13 +23,18 @@ window.onload = function() {
if(!window.indexedDB)
support.idb = false;
if(!support.anim || !support.canvas || !support.webgl || !support.idb) {
window.location.href = "error.html?err="+ (+support.anim)
+""+ (+support.canvas)
+""+ (+support.webgl)
+""+ (+support.idb);
var supported = true;
for(var i in support)
supported = supported && support[i];
if(!supported) {
var supportStr = "";
for(var i in support)
supportStr += ""+ (+support[i]);
window.location.href = "error.html?err="+ supportStr;
return;
}
Entrypoint.Main();
Entrypoint.Start();
}

View file

@ -1,7 +1,36 @@
/// <reference path="FileCache.ts" />
/// <reference path="Utilities.ts" />
class Entrypoint {
static Main(): void {
FileCache.Initialize();
private static InitStatus = {
FileCache: false
}
private static InitCheck(): void {
var done = true;
for(var i in Entrypoint.InitStatus)
done = done && Entrypoint.InitStatus[i];
if(done)
Entrypoint.Initialized();
}
public static Start(): void {
FileCache.Initialize(
// SUCCESS
() => {
Entrypoint.InitStatus.FileCache = true;
this.InitCheck();
},
// FAILURE
(error: string) => {
CriticalStop.Redirect(error);
}
);
}
private static Initialized(): void {
}
}

View file

@ -1,17 +1,68 @@
class FileCache {
static dbHandle: IDBDatabase = null;
private static DB: IDBDatabase = null;
static Initialize(): void {
var request = window.indexedDB.open("fileCache", 1);
public static Initialize(success: ()=>void, error: (error: string)=>void): void {
var request = window.indexedDB.open("fileCache", 2);
request.onupgradeneeded = function(event: any) {
request.onupgradeneeded = (event: any) => {
var db: IDBDatabase = event.target.result;
db.createObjectStore("files", {keyPath: "name"});
if(db.objectStoreNames.contains("hashes"))
db.deleteObjectStore("hashes");
if(!db.objectStoreNames.contains("files"))
db.createObjectStore("files", {keyPath: "Name", autoIncrement: false});
if(!db.objectStoreNames.contains("metadata"))
db.createObjectStore("metadata", {keyPath: "Name", autoIncrement: false});
};
request.onsuccess = function(event: any) {
}
request.onerror = (event: any) => {
error("Could not upgrade the client database to the most recent version.");
};
request.onsuccess = (event: any) => {
FileCache.DB = request.result;
success();
};
}
public static GetHash(fileName: string, success: (hash: string)=>void, error: (error: string)=>void): void {
var query = FileCache.DB.transaction("metadata");
var store = query.objectStore("metadata");
var request = store.get(fileName);
request.onsuccess = () => {
success(request.result);
};
request.onerror = (event: any) => {
error(event);
};
}
public static SetHash(fileName: string, hash: string) {
var query = FileCache.DB.transaction("metadata", "readwrite");
var store = query.objectStore("metadata");
store.put({Name: fileName, Hash: hash});
}
public static GetFile(fileName: string, success: (data: Uint8Array)=>void, error: (error: string)=>void): void {
var query = FileCache.DB.transaction("files");
var store = query.objectStore("files");
var request = store.get(fileName);
request.onsuccess = () => {
success(request.result);
};
request.onerror = (event: any) => {
error(event);
};
}
public static SetFile(fileName: string, data: Uint8Array) {
var query = FileCache.DB.transaction("files", "readwrite");
var store = query.objectStore("files");
store.put(data, fileName);
}
}

5
client/src/Utilities.ts Normal file
View file

@ -0,0 +1,5 @@
class CriticalStop {
public static Redirect(message: string): void {
window.location.href = "error.html?txt="+ encodeURIComponent(message) +"&rterr";
}
}