mirror of
https://github.com/overte-org/overte.git
synced 2025-08-10 09:08:37 +02:00
Update code formatting and add search optimization features.
Co-Authored-By: Keb Helion <60008426+KebHelion@users.noreply.github.com>
This commit is contained in:
parent
f70a9ec4c0
commit
6420752db1
3 changed files with 138 additions and 146 deletions
|
@ -18,7 +18,7 @@
|
|||
var APP_URL = ROOT + "more.html";
|
||||
var APP_ICON_INACTIVE = ROOT + "appicon_i.png";
|
||||
var APP_ICON_ACTIVE = ROOT + "appicon_a.png";
|
||||
var Appstatus = false;
|
||||
var appStatus = false;
|
||||
var lastProcessing = {
|
||||
"action": "",
|
||||
"script": ""
|
||||
|
@ -32,22 +32,19 @@
|
|||
activeIcon: APP_ICON_ACTIVE
|
||||
});
|
||||
|
||||
|
||||
function clicked() {
|
||||
if (Appstatus) {
|
||||
if (appStatus) {
|
||||
tablet.webEventReceived.disconnect(onMoreAppWebEventReceived);
|
||||
tablet.gotoHomeScreen();
|
||||
Appstatus = false;
|
||||
appStatus = false;
|
||||
} else {
|
||||
tablet.gotoWebScreen(APP_URL);
|
||||
tablet.webEventReceived.connect(onMoreAppWebEventReceived);
|
||||
Appstatus = true;
|
||||
appStatus = true;
|
||||
}
|
||||
|
||||
button.editProperties({
|
||||
isActive: Appstatus
|
||||
isActive: appStatus
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
button.clicked.connect(clicked);
|
||||
|
@ -59,81 +56,57 @@
|
|||
for (var j = 0; j < currentlyRunningScripts.length; j++) {
|
||||
runningScriptJson = currentlyRunningScripts[j].url;
|
||||
if (runningScriptJson.indexOf("https://kasenvr.github.io/community-apps/applications") !== -1) {
|
||||
newMessage = newMessage + "_" + runningScriptJson;
|
||||
newMessage += "_" + runningScriptJson;
|
||||
}
|
||||
}
|
||||
|
||||
tablet.emitScriptEvent(newMessage);
|
||||
}
|
||||
|
||||
function onMoreAppWebEventReceived(eventz) {
|
||||
|
||||
if (typeof eventz === "string") {
|
||||
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) {
|
||||
return;
|
||||
} else {
|
||||
ScriptDiscoveryService.loadOneScript(eventzget.script);
|
||||
|
||||
lastProcessing.action = eventzget.action;
|
||||
lastProcessing.script = eventzget.script;
|
||||
function onMoreAppWebEventReceived(message) {
|
||||
if (typeof message === "string") {
|
||||
var instruction = JSON.parse(message);
|
||||
|
||||
if (instruction.action === "installScript") {
|
||||
if (lastProcessing.action !== instruction.action || lastProcessing.script !== instruction.script) {
|
||||
ScriptDiscoveryService.loadOneScript(instruction.script);
|
||||
lastProcessing.action = instruction.action;
|
||||
lastProcessing.script = instruction.script;
|
||||
Script.setTimeout(function() {
|
||||
sendRunningScriptList();
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
|
||||
if (eventzget.action === "uninstallScript") {
|
||||
|
||||
if (lastProcessing.action === eventzget.action && lastProcessing.script === eventzget.script) {
|
||||
return;
|
||||
} else {
|
||||
ScriptDiscoveryService.stopScript(eventzget.script, false);
|
||||
|
||||
lastProcessing.action = eventzget.action;
|
||||
lastProcessing.script = eventzget.script;
|
||||
|
||||
if (instruction.action === "uninstallScript") {
|
||||
if (lastProcessing.action !== instruction.action || lastProcessing.script !== instruction.script) {
|
||||
ScriptDiscoveryService.stopScript(instruction.script, false);
|
||||
lastProcessing.action = instruction.action;
|
||||
lastProcessing.script = instruction.script;
|
||||
Script.setTimeout(function() {
|
||||
sendRunningScriptList();
|
||||
}, 1500);
|
||||
}
|
||||
}
|
||||
|
||||
if (eventzget.action === "requestRunningScriptData") {
|
||||
if (instruction.action === "requestRunningScriptData") {
|
||||
sendRunningScriptList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function onScreenChanged(type, url) {
|
||||
if (type === "Web" && url.indexOf(APP_URL) !== -1) {
|
||||
//Active
|
||||
//print("MORE... ACTIVE");
|
||||
Appstatus = true;
|
||||
appStatus = true;
|
||||
} else {
|
||||
//Inactive
|
||||
//print("MORE... INACTIVE");
|
||||
Appstatus = false;
|
||||
appStatus = false;
|
||||
}
|
||||
|
||||
button.editProperties({
|
||||
isActive: Appstatus
|
||||
isActive: appStatus
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
function cleanup() {
|
||||
if (Appstatus) {
|
||||
if (appStatus) {
|
||||
tablet.gotoHomeScreen();
|
||||
tablet.webEventReceived.disconnect(onMoreAppWebEventReceived);
|
||||
}
|
||||
|
|
|
@ -20,7 +20,7 @@ body {
|
|||
text-transform: none;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font.mainTitle {
|
||||
font-family: 'Quicksand', sans-serif;
|
||||
font-size: 28px;
|
||||
color: #ffffff;
|
||||
|
@ -33,7 +33,9 @@ h1 {
|
|||
}
|
||||
|
||||
p.mainDesc {
|
||||
font-size: 16px;
|
||||
font-family: 'Merriweather', sans-serif;
|
||||
font-size: 14px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
p a {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
<!DOCTYPE html>
|
||||
<!--
|
||||
// more.html
|
||||
//
|
||||
|
@ -11,15 +12,14 @@
|
|||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
-->
|
||||
<!DOCTYPE html>
|
||||
<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;
|
||||
var DEFAULT_PER_PAGE = 3;
|
||||
var DEFAULT_OFFSET = 0;
|
||||
|
||||
//Paths
|
||||
var currentPath = window.location.protocol + "//" + window.location.host + window.location.pathname;
|
||||
|
@ -73,11 +73,16 @@
|
|||
|
||||
//Search
|
||||
function doSearch(keyword) {
|
||||
location.href = "more.html?offset=0&search=" + encodeURI(keyword);
|
||||
offset = 0;
|
||||
search = keyword;
|
||||
listBuilder(keyword, offset, perpage);
|
||||
}
|
||||
|
||||
function clearSearch() {
|
||||
location.href = "more.html?offset=0";
|
||||
offset = 0;
|
||||
document.searchbar.searchtextbox.value = "";
|
||||
search = "";
|
||||
listBuilder("", offset, perpage);
|
||||
}
|
||||
|
||||
//Running scripts
|
||||
|
@ -109,26 +114,21 @@
|
|||
});
|
||||
|
||||
function install(script, btnId){
|
||||
//then change btn appearence
|
||||
var btn = "<button class='processing' >Processing...</button>";
|
||||
document.getElementById(btnId).innerHTML = btn;
|
||||
|
||||
//Action
|
||||
var readyEvent = {
|
||||
"action": "installScript",
|
||||
"script": script
|
||||
};
|
||||
|
||||
EventBridge.emitWebEvent(JSON.stringify(readyEvent));
|
||||
|
||||
}
|
||||
|
||||
function uninstall(script, btnId){
|
||||
//then change btn appearence
|
||||
var btn = "<button class='processing' >Processing...</button>";
|
||||
document.getElementById(btnId).innerHTML = btn;
|
||||
|
||||
//Action
|
||||
var readyEvent = {
|
||||
"action": "uninstallScript",
|
||||
"script": script
|
||||
|
@ -136,16 +136,14 @@
|
|||
|
||||
EventBridge.emitWebEvent(JSON.stringify(readyEvent));
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<link href="https://fonts.googleapis.com/css?family=Merriweather|Quicksand:400,700&display=swap" rel="stylesheet">
|
||||
<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>
|
||||
<body><form name = "searchbar" onsubmit="submitForm(event);">
|
||||
<font class="mainTitle">Add more functionalities...</font><br>
|
||||
<table style = "width:100%;">
|
||||
<tr >
|
||||
<td style = "vertical-align:middle; text-align:left;">
|
||||
|
@ -153,7 +151,7 @@
|
|||
<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>
|
||||
<input class = "searchtextbox" name = "searchtextbox" size = "26" maxlength="32" onkeypress="monitorEnter(event, this);"> <a href="#" onclick='clearSearch();'><img src="del-x-16.png"></a>
|
||||
</div>
|
||||
</td>
|
||||
<td style = "vertical-align:middle; text-align:left;">
|
||||
|
@ -167,13 +165,28 @@
|
|||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form><br>
|
||||
</form><!--br-->
|
||||
<div id = "data"></div>
|
||||
<div style="width:98%; text-align:right;">
|
||||
<div style = "vertical-align: middle;" id = 'pager_footer'><!-- More info placeholder --></div>
|
||||
<div style = "vertical-align: middle;" id = 'pager_footer'></div>
|
||||
</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>
|
||||
<script>
|
||||
function monitorEnter(e) {
|
||||
var code = (e.keyCode ? e.keyCode : e.which);
|
||||
if (code == 13) {
|
||||
doSearch(document.searchbar.searchtextbox.value);
|
||||
}
|
||||
}
|
||||
|
||||
function submitForm(event){
|
||||
event.preventDefault();
|
||||
}
|
||||
|
||||
document.searchbar.searchtextbox.value = search;
|
||||
var pageContent = "";
|
||||
|
||||
function DisplayApp(item) {
|
||||
pageContent = pageContent + "<a name = '" + window.btoa(item.directory) + "'><table class='item'><tr>";
|
||||
|
@ -189,48 +202,35 @@
|
|||
buttonList.push(btndata);
|
||||
|
||||
pageContent = pageContent + "<td><font class='appname'>" + item.name + "<br></font><font class = 'appdesc'>" + item.description + "<br></font><div id = '"+ window.btoa(item.directory) +"' align='right'>" + btn + "</div></td>";
|
||||
pageContent = pageContent + "</tr></table><br><br>";
|
||||
pageContent = pageContent + "</tr></table><br>";
|
||||
}
|
||||
|
||||
function listBuilder(searchKeyword, listOffset, listPerPage) {
|
||||
buttonList = [];
|
||||
var counterDir = -1;
|
||||
var counterDisp = 0;
|
||||
var index = 0;
|
||||
var lowItem = "";
|
||||
var needNext = false;
|
||||
var pageContent = "";
|
||||
pageContent = "";
|
||||
|
||||
for (index = 0; index < metadata.applications.length; index++) {
|
||||
lowItem = metadata.applications[index].name.toLowerCase();
|
||||
if (lowItem.indexOf(search.toLowerCase()) !== -1 && metadata.applications[index].isActive == true) {
|
||||
if (lowItem.indexOf(searchKeyword.toLowerCase()) !== -1 && metadata.applications[index].isActive == true) {
|
||||
counterDir = counterDir + 1;
|
||||
if ((counterDir >= offset) && (counterDir < (offset + perpage))) {
|
||||
if ((counterDir >= listOffset) && (counterDir < (listOffset + listPerPage))) {
|
||||
DisplayApp(metadata.applications[index]);
|
||||
counterDisp = counterDisp + 1;
|
||||
}
|
||||
if (counterDir >= (offset + perpage)) {
|
||||
if (counterDir >= (listOffset + listPerPage)) {
|
||||
needNext = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//pager
|
||||
|
||||
function pagetoPrevious(){
|
||||
offset = offset - perpage;
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
}
|
||||
location.href = "more.html?offset=" + offset + "&perpage=" + perpage + "&search=" + encodeURI(search);
|
||||
}
|
||||
|
||||
function pagetoNext(){
|
||||
offset = offset + perpage;
|
||||
location.href = "more.html?offset=" + offset + "&perpage=" + perpage + "&search=" + encodeURI(search);
|
||||
}
|
||||
|
||||
var pagerPrevious = "<a href='#' onclick='pagetoPrevious();'><img src='minus-16.png'></a>";
|
||||
if (offset <= 0) {
|
||||
if (listOffset <= 0) {
|
||||
pagerPrevious = "<img src='blank_minus-16.png'>";
|
||||
}
|
||||
|
||||
|
@ -239,9 +239,9 @@
|
|||
pagerNext = "<img src='blank_plus-16.png'>";
|
||||
}
|
||||
|
||||
var countA = offset + 1;
|
||||
var countA = listOffset + 1;
|
||||
|
||||
var countB = offset + counterDisp;
|
||||
var countB = listOffset + counterDisp;
|
||||
|
||||
var pagerHtml = pagerPrevious + "<font class='pager'> " + countA + " - " + countB + " </font>" + pagerNext;
|
||||
|
||||
|
@ -252,8 +252,25 @@
|
|||
} else {
|
||||
document.getElementById("data").innerHTML = "<hr><div align='center'><font class='noresult'><br><br><br><br>Sorry, no result found.<br><br><br><br><br><br></font></div><hr>";
|
||||
}
|
||||
|
||||
requestRunningScriptData();
|
||||
}
|
||||
|
||||
//pager
|
||||
function pagetoPrevious(){
|
||||
offset = offset - perpage;
|
||||
if (offset < 0) {
|
||||
offset = 0;
|
||||
}
|
||||
listBuilder(search, offset, perpage);
|
||||
}
|
||||
|
||||
function pagetoNext(){
|
||||
offset = offset + perpage;
|
||||
listBuilder(search, offset, perpage);
|
||||
}
|
||||
|
||||
listBuilder(search, offset, perpage);
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
Loading…
Reference in a new issue