Create ?dev mode for testing the app locally.

This commit is contained in:
Kasen IO 2020-05-13 22:32:25 -04:00
parent 4da7f5d190
commit 7b9a9e9cf8
3 changed files with 32 additions and 27 deletions

View file

@ -14,6 +14,7 @@
//
(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_ICON_INACTIVE = ROOT + "appicon_i.png";
@ -24,13 +25,17 @@
"script": ""
};
if (DEV_PARAMETER && DEV_PARAMETER === "dev") {
APP_URL = ROOT + "more.html?" + DEV_PARAMETER;
}
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
tablet.screenChanged.connect(onScreenChanged);
var button = tablet.addButton({
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,10 @@
offset = offset + perpage;
listBuilder(search, offset, perpage);
}
listBuilder(search, offset, perpage);
$.getScript( metadataScriptSrc, function( data, textStatus, jqxhr ) {
listBuilder(search, offset, perpage);
});
</script>
</body>