Merge pull request #16 from kasenvr/fix/dev-mode

Create ?dev mode for testing the app locally.
This commit is contained in:
kasenvr 2020-05-15 01:29:17 -04:00 committed by GitHub
commit 91b83ab5ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 29 additions and 27 deletions

View file

@ -14,8 +14,9 @@
//
(function() {
var ROOT = Script.resolvePath('').split("app-more.js")[0];
var DEV_PARAMETER = Script.resolvePath('').split("?")[1];
var APP_NAME = "MORE...";
var APP_URL = ROOT + "more.html";
var APP_URL = (ROOT + "more.html" + (DEV_PARAMETER === "dev" ? "?dev" : "")).replace(/%5C/g, "/");
var APP_ICON_INACTIVE = ROOT + "appicon_i.png";
var APP_ICON_ACTIVE = ROOT + "appicon_a.png";
var appStatus = false;
@ -30,7 +31,7 @@
text: APP_NAME,
icon: APP_ICON_INACTIVE,
activeIcon: APP_ICON_ACTIVE
});
});
function clicked() {
if (appStatus) {

2
more/jquery-3.5.1.min.js vendored Normal file

File diff suppressed because one or more lines are too long

View file

@ -15,33 +15,12 @@
<html>
<head>
<meta charset="UTF-8">
<script id="metadataScriptTag" type="text/javascript" src="https://cdn.vircadia.com/community-apps/applications/metadata.js"></script>
<script src="jquery-3.5.1.min.js"></script>
<script>
//Defaults
var DEFAULT_PER_PAGE = 3;
var DEFAULT_OFFSET = 0;
//Paths
var currentPath = window.location.protocol + "//" + window.location.host + window.location.pathname;
var rootPath;
var metadataScript = document.getElementById("metadataScriptTag");
if (currentPath.includes("cdn.vircadia.com") || !currentPath.includes("file:/")) { // Loading app from repo or filesystem.
rootPath = currentPath.replace("more/more.html", "applications/");
if (metadataScript.src !== "../applications/metadata.js") {
metadataScript.src = "../applications/metadata.js";
console.info("Loading apps and metadata locally.");
}
} else {
rootPath = "https://cdn.vircadia.com/community-apps/applications/";
if (metadataScript.src !== "https://cdn.vircadia.com/community-apps/applications/metadata.js") {
metadataScript.src = "https://cdn.vircadia.com/community-apps/applications/metadata.js";
console.info("Loading apps and metadata remotely.");
}
}
document.getElementsByTagName("head")[0].appendChild(metadataScript);
//Parameters
function findGetParameter(parameterName) {
var result = null,
@ -70,7 +49,24 @@
if (search === null) {
search = "";
}
//Paths
var currentPath = window.location.protocol + "//" + window.location.host + window.location.pathname;
var developmentMode = window.location.toString().split("?")[1];
var rootPath;
var metadataScriptSrc = "https://cdn.vircadia.com/community-apps/applications/metadata.js";
if (developmentMode === "dev") { // Development mode loads locally, if not, load from repo.
console.info("Setting applications to local.")
rootPath = currentPath.replace("more/more.html", "applications/");
console.info("Loading metadata locally.");
metadataScriptSrc = "../applications/metadata.js";
} else {
console.info("Setting applications to remote URL.")
console.info("Loading metadata remotely.");
rootPath = "https://cdn.vircadia.com/community-apps/applications/";
}
//Search
function doSearch(keyword) {
offset = 0;
@ -268,8 +264,11 @@
offset = offset + perpage;
listBuilder(search, offset, perpage);
}
$.getScript(metadataScriptSrc, function(data, textStatus, jqxhr) {
listBuilder(search, offset, perpage);
listBuilder(search, offset, perpage);
});
</script>
</body>