succ
dicc
This commit is contained in:
parent
132e272580
commit
eeacb55344
6 changed files with 143 additions and 21 deletions
7
client/deploy.bat
Normal file
7
client/deploy.bat
Normal 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
|
|
@ -24,7 +24,7 @@
|
||||||
font-style: italic;
|
font-style: italic;
|
||||||
}
|
}
|
||||||
|
|
||||||
#content {
|
.content {
|
||||||
width: 25%;
|
width: 25%;
|
||||||
min-width: 300px;
|
min-width: 300px;
|
||||||
max-width: 600px;
|
max-width: 600px;
|
||||||
|
@ -32,6 +32,16 @@
|
||||||
padding: 30px 0;
|
padding: 30px 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@media screen and (max-width: 480px) {
|
||||||
|
.content {
|
||||||
|
width: 75%;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.hidden {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
ul {
|
ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
|
@ -66,15 +76,22 @@
|
||||||
window.onload = function() {
|
window.onload = function() {
|
||||||
var url = window.location.href;
|
var url = window.location.href;
|
||||||
url = url.substr(url.lastIndexOf("?") + 1);
|
url = url.substr(url.lastIndexOf("?") + 1);
|
||||||
var features = url.split("&")[0].split("=")[1];
|
var params = url.split("&");
|
||||||
|
var features = params[0].split("=")[1];
|
||||||
|
|
||||||
|
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)
|
for(var i = 1; i <= features.length; ++i)
|
||||||
document.getElementById("supchk"+ i).className = features[i-1] == "1" ? "mark check" : "mark cross";
|
document.getElementById("supchk"+ i).className = features[i-1] == "1" ? "mark check" : "mark cross";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="content">
|
<div class="content" id="noSupport">
|
||||||
<h2>
|
<h2>
|
||||||
Your browser does not support the required features to run this application.
|
Your browser does not support the required features to run this application.
|
||||||
</h2>
|
</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>.
|
such as <a href="https://www.mozilla.org">Mozilla Firefox</a> or <a href="https://www.google.com/chrome/">Google Chrome</a>.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</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>
|
</body>
|
||||||
</html>
|
</html>
|
|
@ -23,13 +23,18 @@ window.onload = function() {
|
||||||
if(!window.indexedDB)
|
if(!window.indexedDB)
|
||||||
support.idb = false;
|
support.idb = false;
|
||||||
|
|
||||||
if(!support.anim || !support.canvas || !support.webgl || !support.idb) {
|
var supported = true;
|
||||||
window.location.href = "error.html?err="+ (+support.anim)
|
for(var i in support)
|
||||||
+""+ (+support.canvas)
|
supported = supported && support[i];
|
||||||
+""+ (+support.webgl)
|
|
||||||
+""+ (+support.idb);
|
if(!supported) {
|
||||||
|
var supportStr = "";
|
||||||
|
for(var i in support)
|
||||||
|
supportStr += ""+ (+support[i]);
|
||||||
|
|
||||||
|
window.location.href = "error.html?err="+ supportStr;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entrypoint.Main();
|
Entrypoint.Start();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,36 @@
|
||||||
/// <reference path="FileCache.ts" />
|
/// <reference path="FileCache.ts" />
|
||||||
|
/// <reference path="Utilities.ts" />
|
||||||
|
|
||||||
class Entrypoint {
|
class Entrypoint {
|
||||||
static Main(): void {
|
private static InitStatus = {
|
||||||
FileCache.Initialize();
|
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 {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,17 +1,68 @@
|
||||||
class FileCache {
|
class FileCache {
|
||||||
static dbHandle: IDBDatabase = null;
|
private static DB: IDBDatabase = null;
|
||||||
|
|
||||||
static Initialize(): void {
|
public static Initialize(success: ()=>void, error: (error: string)=>void): void {
|
||||||
var request = window.indexedDB.open("fileCache", 1);
|
var request = window.indexedDB.open("fileCache", 2);
|
||||||
|
|
||||||
request.onupgradeneeded = function(event: any) {
|
request.onupgradeneeded = (event: any) => {
|
||||||
var db: IDBDatabase = event.target.result;
|
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
5
client/src/Utilities.ts
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class CriticalStop {
|
||||||
|
public static Redirect(message: string): void {
|
||||||
|
window.location.href = "error.html?txt="+ encodeURIComponent(message) +"&rterr";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue