Update More App to latest revision.

More app now links to cdn.vircadia.com and also has a developer mode.
This commit is contained in:
Kasen IO 2020-05-19 18:22:20 -04:00
parent 22e9aec0dd
commit 8d9ad0aed4
3 changed files with 34 additions and 32 deletions

View file

@ -11,12 +11,12 @@
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
//
(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;
@ -31,7 +31,7 @@
text: APP_NAME,
icon: APP_ICON_INACTIVE,
activeIcon: APP_ICON_ACTIVE
});
});
function clicked() {
if (appStatus) {
@ -56,7 +56,7 @@
var runningScriptJson;
for (var j = 0; j < currentlyRunningScripts.length; j++) {
runningScriptJson = currentlyRunningScripts[j].url;
if (runningScriptJson.indexOf("https://kasenvr.github.io/community-apps/applications") !== -1) {
if (runningScriptJson.indexOf("https://cdn.vircadia.com/community-apps/applications") !== -1) {
newMessage += "_" + runningScriptJson;
}
}
@ -69,7 +69,8 @@
if (instruction.action === "installScript") {
if (lastProcessing.action !== instruction.action || lastProcessing.script !== instruction.script) {
ScriptDiscoveryService.loadScript(instruction.script, true, false, false, true, false); // Force reload the script, do not use cache. lastProcessing.action = instruction.action;
ScriptDiscoveryService.loadScript(instruction.script, true, false, false, true, false); // Force reload the script, do not use cache.
lastProcessing.action = instruction.action;
lastProcessing.script = instruction.script;
Script.setTimeout(function() {
sendRunningScriptList();

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://kasenvr.github.io/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("kasenvr.github.io") || !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://kasenvr.github.io/community-apps/applications/";
if (metadataScript.src !== "https://kasenvr.github.io/community-apps/applications/metadata.js") {
metadataScript.src = "https://kasenvr.github.io/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;
@ -172,7 +168,7 @@
</div>
<hr>
<p class="mainDesc">Want to contribute and add your own app?<br>
Read the <a href="https://kasenvr.github.io/community-apps/web/index.html">guide</a>!</p>
Read the <a href="https://cdn.vircadia.com/community-apps/web/index.html">guide</a>!</p>
<script>
function monitorEnter(e) {
var code = (e.keyCode ? e.keyCode : e.which);
@ -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>