mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Lint + fix default apps per page + fix script list loading bug.
This commit is contained in:
parent
8092220ea4
commit
4eea4980fd
2 changed files with 57 additions and 54 deletions
|
@ -6,16 +6,12 @@
|
|||
// Created by Keb Helion, February 2020.
|
||||
// Copyright 2020 Project Athena and contributors.
|
||||
//
|
||||
// App maintained in: https://github.com/kasenvr/community-apps
|
||||
// App copied to: https://github.com/kasenvr/project-athena
|
||||
//
|
||||
// This script adds a "More Apps" selector to "Project Athena" to allow the user to add optional functionalities to the tablet.
|
||||
// This application has been designed to work directly from the Github repository.
|
||||
//
|
||||
// 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 APP_NAME = "MORE...";
|
||||
|
@ -38,7 +34,7 @@
|
|||
|
||||
|
||||
function clicked() {
|
||||
if (Appstatus) {
|
||||
if (Appstatus == true) {
|
||||
tablet.webEventReceived.disconnect(onMoreAppWebEventReceived);
|
||||
tablet.gotoHomeScreen();
|
||||
Appstatus = false;
|
||||
|
@ -64,14 +60,14 @@
|
|||
function onMoreAppWebEventReceived(eventz) {
|
||||
|
||||
if (typeof eventz === "string") {
|
||||
eventzget = JSON.parse(eventz);
|
||||
var eventzget = JSON.parse(eventz);
|
||||
|
||||
//print("EVENT ACTION: " + eventzget.action);
|
||||
//print("EVENT SCRIPT: " + eventzget.script);
|
||||
|
||||
if (eventzget.action === "installScript") {
|
||||
|
||||
if (lastProcessing.action === eventzget.action && lastProcessing.script === eventzget.script) {
|
||||
if (lastProcessing.action == eventzget.action && lastProcessing.script == eventzget.script) {
|
||||
return;
|
||||
} else {
|
||||
ScriptDiscoveryService.loadOneScript(eventzget.script);
|
||||
|
@ -87,7 +83,7 @@
|
|||
|
||||
if (eventzget.action === "uninstallScript") {
|
||||
|
||||
if (lastProcessing.action === eventzget.action && lastProcessing.script === eventzget.script) {
|
||||
if (lastProcessing.action == eventzget.action && lastProcessing.script == eventzget.script) {
|
||||
return;
|
||||
} else {
|
||||
ScriptDiscoveryService.stopScript(eventzget.script, false);
|
||||
|
@ -111,7 +107,7 @@
|
|||
|
||||
|
||||
function onScreenChanged(type, url) {
|
||||
if (type === "Web" && url.indexOf(APP_URL) !== -1) {
|
||||
if (type == "Web" && url.indexOf(APP_URL) != -1) {
|
||||
//Active
|
||||
//print("MORE... ACTIVE");
|
||||
Appstatus = true;
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
// App maintained in: https://github.com/kasenvr/community-apps
|
||||
// App copied to: https://github.com/kasenvr/project-athena
|
||||
//
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
-->
|
||||
|
@ -14,20 +15,29 @@
|
|||
<html>
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<script id="metadataScriptTag" type="text/javascript" src="https://kasenvr.github.io/community-apps/applications/metadata.js"></script>
|
||||
<script>
|
||||
//Defaults
|
||||
DEFAULT_PER_PAGE = 3;
|
||||
DEFAULT_OFFSET = 0;
|
||||
|
||||
//Paths
|
||||
var currentPath = window.location.protocol + "//" + window.location.host + window.location.pathname;
|
||||
var rootPath;
|
||||
var metadataScript = document.createElement("script");
|
||||
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/");
|
||||
metadataScript.src = "../applications/metadata.js";
|
||||
console.info("Loading apps and metadata locally.");
|
||||
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/";
|
||||
metadataScript.src = "https://kasenvr.github.io/community-apps/applications/metadata.js";
|
||||
console.info("Loading apps and metadata remotely.");
|
||||
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);
|
||||
|
@ -39,22 +49,20 @@
|
|||
var items = location.search.substr(1).split("&");
|
||||
for (var index = 0; index < items.length; index++) {
|
||||
tmp = items[index].split("=");
|
||||
if (tmp[0] === parameterName) {
|
||||
result = decodeURIComponent(tmp[1])
|
||||
};
|
||||
if (tmp[0] === parameterName) result = decodeURIComponent(tmp[1]);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
var offset = findGetParameter("offset");
|
||||
if (offset === null) {
|
||||
offset = 0;
|
||||
offset = DEFAULT_OFFSET;
|
||||
}
|
||||
offset = parseInt(offset);
|
||||
|
||||
var perpage = findGetParameter("perpage");
|
||||
if (perpage === null) {
|
||||
perpage = 25;
|
||||
perpage = DEFAULT_PER_PAGE;
|
||||
}
|
||||
perpage = parseInt(perpage);
|
||||
|
||||
|
@ -64,11 +72,11 @@
|
|||
}
|
||||
|
||||
//Search
|
||||
function doSearch(keyword){
|
||||
function doSearch(keyword) {
|
||||
location.href = "more.html?offset=0&search=" + encodeURI(keyword);
|
||||
}
|
||||
|
||||
function clearSearch(){
|
||||
function clearSearch() {
|
||||
location.href = "more.html?offset=0";
|
||||
}
|
||||
|
||||
|
@ -86,7 +94,7 @@
|
|||
//update the buttons
|
||||
buttonList.forEach(function(item){
|
||||
var btn = "";
|
||||
if (message.indexOf(item.url) !== -1) {
|
||||
if (message.indexOf(item.url) != -1) {
|
||||
//Means already running
|
||||
btn = "<button class='uninstall' onclick='uninstall(" + '"' + item.url + '"' + ", " + '"' + item.id + '"' + ");'>Uninstall</button>";
|
||||
} else {
|
||||
|
@ -133,31 +141,30 @@
|
|||
<link href="css/styles.css" rel="stylesheet">
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<form name = "searchbar">
|
||||
<h1 class="mainTitle">Add more functionalities...</h1>
|
||||
<p class="mainDesc">Want to add your own app? Read the <a href="https://kasenvr.github.io/community-apps/web/index.html">guide</a>!</p>
|
||||
<table style = "width:100%;">
|
||||
<tr >
|
||||
<td style = "vertical-align:middle; text-align:left;">
|
||||
<table>
|
||||
<tr>
|
||||
<td style = "vertical-align:middle; text-align:left;">
|
||||
<div class = "searchbox">
|
||||
<input class = "searchtextbox" name = "searchtextbox" size = "26" maxlength="32"> <a href="#" onclick='clearSearch();'><img src="del-x-16.png"></a>
|
||||
</div>
|
||||
</td>
|
||||
<td style = "vertical-align:middle; text-align:left;">
|
||||
<a href = "#" onclick = 'doSearch(document.searchbar.searchtextbox.value);'><img src="search-32.png"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style = "vertical-align:middle; text-align:right;">
|
||||
<div id = 'pager_top' style = "vertical-align: middle;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<body><form name = "searchbar">
|
||||
<h1 class="mainTitle">Add more functionalities...</h1>
|
||||
<p class="mainDesc">Want to add your own app? Read the <a href="../web/index.html">guide</a>!</p>
|
||||
<table style = "width:100%;">
|
||||
<tr >
|
||||
<td style = "vertical-align:middle; text-align:left;">
|
||||
<table>
|
||||
<tr>
|
||||
<td style = "vertical-align:middle; text-align:left;">
|
||||
<div class = "searchbox">
|
||||
<input class = "searchtextbox" name = "searchtextbox" size = "26" maxlength="32"> <a href="#" onclick='clearSearch();'><img src="del-x-16.png"></a>
|
||||
</div>
|
||||
</td>
|
||||
<td style = "vertical-align:middle; text-align:left;">
|
||||
<a href = "#" onclick = 'doSearch(document.searchbar.searchtextbox.value);'><img src="search-32.png"></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td style = "vertical-align:middle; text-align:right;">
|
||||
<div id = 'pager_top' style = "vertical-align: middle;"></div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form><br>
|
||||
<div id = "data"></div>
|
||||
<div style="width:98%; text-align:right;"><div style = "vertical-align: middle;" id = 'pager_footer'></div>
|
||||
|
@ -189,9 +196,9 @@
|
|||
var needNext = false;
|
||||
var pageContent = "";
|
||||
|
||||
for (index = 0; index < metadata.applications.length; index++){
|
||||
for (index = 0; index < metadata.applications.length; index++) {
|
||||
lowItem = metadata.applications[index].name.toLowerCase();
|
||||
if (lowItem.indexOf(search.toLowerCase()) !== -1 && metadata.applications[index].isActive) {
|
||||
if (lowItem.indexOf(search.toLowerCase()) != -1 && metadata.applications[index].isActive == true) {
|
||||
counterDir = counterDir + 1;
|
||||
if ((counterDir >= offset) && (counterDir < (offset + perpage))) {
|
||||
DisplayApp(metadata.applications[index]);
|
||||
|
@ -206,15 +213,15 @@
|
|||
|
||||
//pager
|
||||
|
||||
function pagetoPrevious() {
|
||||
function pagetoPrevious(){
|
||||
offset = offset - perpage;
|
||||
if (offset < 0){
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
}
|
||||
location.href = "more.html?offset=" + offset + "&perpage=" + perpage + "&search=" + encodeURI(search);
|
||||
}
|
||||
|
||||
function pagetoNext() {
|
||||
function pagetoNext(){
|
||||
offset = offset + perpage;
|
||||
location.href = "more.html?offset=" + offset + "&perpage=" + perpage + "&search=" + encodeURI(search);
|
||||
}
|
||||
|
@ -225,7 +232,7 @@
|
|||
}
|
||||
|
||||
var pagerNext = "<a href='#' onclick='pagetoNext();'><img src='plus-16.png'></a>";
|
||||
if (!needNext) {
|
||||
if (needNext == false) {
|
||||
pagerNext = "<img src='blank_plus-16.png'>";
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue