Merge pull request #187 from kasenvr/feature/default-moreapp
Add app-more.js to default scripts.
|
@ -41,6 +41,7 @@ var DEFAULT_SCRIPTS_SEPARATE = [
|
||||||
"system/controllers/controllerScripts.js",
|
"system/controllers/controllerScripts.js",
|
||||||
"communityModules/notificationCore/notificationCore.js",
|
"communityModules/notificationCore/notificationCore.js",
|
||||||
"simplifiedUI/ui/simplifiedNametag/simplifiedNametag.js",
|
"simplifiedUI/ui/simplifiedNametag/simplifiedNametag.js",
|
||||||
|
{"stable": "system/more/app-more.js", "beta": "https://kasenvr.github.io/community-apps/more/app-more.js"},
|
||||||
{"stable": "communityScripts/decentralizedGoTo/decentralizedGoTo.js", "beta": "https://metaverse.projectathena.io/interim/d-goto/app/decentralizedGoTo.js"},
|
{"stable": "communityScripts/decentralizedGoTo/decentralizedGoTo.js", "beta": "https://metaverse.projectathena.io/interim/d-goto/app/decentralizedGoTo.js"},
|
||||||
{"stable": "communityModules/chat/FloofChat.js", "beta": "https://content.fluffy.ws/scripts/chat/FloofChat.js"}
|
{"stable": "communityModules/chat/FloofChat.js", "beta": "https://content.fluffy.ws/scripts/chat/FloofChat.js"}
|
||||||
//"system/chat.js"
|
//"system/chat.js"
|
||||||
|
|
118
scripts/system/more/app-more.js
Normal file
|
@ -0,0 +1,118 @@
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
// app-more.js
|
||||||
|
// VERSION 1.0
|
||||||
|
//
|
||||||
|
// Created by Keb Helion, February 2020.
|
||||||
|
// Copyright 2020 Project Athena and contributors.
|
||||||
|
//
|
||||||
|
// 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...";
|
||||||
|
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 lastProcessing = {
|
||||||
|
"action": "",
|
||||||
|
"script": ""
|
||||||
|
};
|
||||||
|
|
||||||
|
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) {
|
||||||
|
tablet.webEventReceived.disconnect(onMoreAppWebEventReceived);
|
||||||
|
tablet.gotoHomeScreen();
|
||||||
|
appStatus = false;
|
||||||
|
} else {
|
||||||
|
tablet.gotoWebScreen(APP_URL);
|
||||||
|
tablet.webEventReceived.connect(onMoreAppWebEventReceived);
|
||||||
|
appStatus = true;
|
||||||
|
}
|
||||||
|
button.editProperties({
|
||||||
|
isActive: appStatus
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
button.clicked.connect(clicked);
|
||||||
|
|
||||||
|
function sendRunningScriptList() {
|
||||||
|
var currentlyRunningScripts = ScriptDiscoveryService.getRunning();
|
||||||
|
var newMessage = "RSL4MOREAPP:";
|
||||||
|
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) {
|
||||||
|
newMessage += "_" + runningScriptJson;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
tablet.emitScriptEvent(newMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
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 (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 (instruction.action === "requestRunningScriptData") {
|
||||||
|
sendRunningScriptList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onScreenChanged(type, url) {
|
||||||
|
if (type === "Web" && url.indexOf(APP_URL) !== -1) {
|
||||||
|
appStatus = true;
|
||||||
|
} else {
|
||||||
|
appStatus = false;
|
||||||
|
}
|
||||||
|
button.editProperties({
|
||||||
|
isActive: appStatus
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup() {
|
||||||
|
if (appStatus) {
|
||||||
|
tablet.gotoHomeScreen();
|
||||||
|
tablet.webEventReceived.disconnect(onMoreAppWebEventReceived);
|
||||||
|
}
|
||||||
|
tablet.screenChanged.disconnect(onScreenChanged);
|
||||||
|
tablet.removeButton(button);
|
||||||
|
}
|
||||||
|
|
||||||
|
Script.scriptEnding.connect(cleanup);
|
||||||
|
}());
|
BIN
scripts/system/more/appicon_a.png
Normal file
After Width: | Height: | Size: 521 B |
BIN
scripts/system/more/appicon_i.png
Normal file
After Width: | Height: | Size: 511 B |
BIN
scripts/system/more/blank_minus-16.png
Normal file
After Width: | Height: | Size: 250 B |
BIN
scripts/system/more/blank_plus-16.png
Normal file
After Width: | Height: | Size: 251 B |
186
scripts/system/more/css/styles.css
Normal file
|
@ -0,0 +1,186 @@
|
||||||
|
/*
|
||||||
|
styles.css
|
||||||
|
|
||||||
|
Created by Kalila L. on 23 Feb 2020.
|
||||||
|
Copyright 2020 Project Athena and contributors.
|
||||||
|
|
||||||
|
Distributed under the Apache License, Version 2.0.
|
||||||
|
See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
|
*/
|
||||||
|
|
||||||
|
body {
|
||||||
|
background: #27343B;
|
||||||
|
font-family: 'Merriweather', sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #FFFFFF;
|
||||||
|
font-weight: 600;
|
||||||
|
text-decoration: none;
|
||||||
|
font-style: normal;
|
||||||
|
font-variant: normal;
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
font.mainTitle {
|
||||||
|
font-family: 'Quicksand', sans-serif;
|
||||||
|
font-size: 28px;
|
||||||
|
color: #ffffff;
|
||||||
|
font-weight: 800;
|
||||||
|
text-decoration: none;
|
||||||
|
font-style: normal;
|
||||||
|
font-variant: normal;
|
||||||
|
text-transform: none;
|
||||||
|
text-shadow: 3px 3px 3px rgba(63,64,76,1);
|
||||||
|
}
|
||||||
|
|
||||||
|
p.mainDesc {
|
||||||
|
font-family: 'Merriweather', sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
p a {
|
||||||
|
color: SteelBlue;
|
||||||
|
}
|
||||||
|
|
||||||
|
font.appname {
|
||||||
|
font-family: 'Merriweather', sans-serif;
|
||||||
|
font-size: 18px;
|
||||||
|
color: #CFB538;
|
||||||
|
font-weight: 800;
|
||||||
|
text-decoration: none;
|
||||||
|
font-style: normal;
|
||||||
|
font-variant: normal;
|
||||||
|
text-transform: none;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
float: left;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
font.appdesc {
|
||||||
|
font-family: 'Merriweather', sans-serif;
|
||||||
|
font-size: 15px;
|
||||||
|
color: #ffffff;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
font-style: normal;
|
||||||
|
font-variant: normal;
|
||||||
|
text-transform: none;
|
||||||
|
margin-bottom: 5px;
|
||||||
|
float: left;
|
||||||
|
clear: both;
|
||||||
|
}
|
||||||
|
|
||||||
|
font.noresult {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
font-size: 18px;
|
||||||
|
color: #aaaaaa;
|
||||||
|
font-weight: 500;
|
||||||
|
text-decoration: none;
|
||||||
|
font-style: normal;
|
||||||
|
font-variant: normal;
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
font.caption {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
font-size: 12px;
|
||||||
|
color: #ffffff;
|
||||||
|
font-weight: 600;
|
||||||
|
text-decoration: none;
|
||||||
|
font-style: normal;
|
||||||
|
font-variant: normal;
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
font.pager {
|
||||||
|
font-family: 'Quicksand', sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #B2B5D9;
|
||||||
|
font-weight: 600;
|
||||||
|
text-decoration: none;
|
||||||
|
font-style: normal;
|
||||||
|
font-variant: normal;
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.iconContainer{
|
||||||
|
border-radius: 15px;
|
||||||
|
background: #000000;
|
||||||
|
padding: 5px;
|
||||||
|
width: 70px;
|
||||||
|
height: 70px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
table.item {
|
||||||
|
background: #3E415E;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
vertical-align: top;
|
||||||
|
padding: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.install {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
background-color: #008CBA;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #ffffff;
|
||||||
|
font-weight: 600;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 2px solid #008CBA;
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.install:hover {
|
||||||
|
background-color: #10afe3;
|
||||||
|
border: 2px solid #10afe3;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.uninstall {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
background-color: #b34700;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #ffffff;
|
||||||
|
font-weight: 600;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 2px solid #b34700;
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.uninstall:hover {
|
||||||
|
background-color: #e34c22;
|
||||||
|
border: 2px solid #e34c22;
|
||||||
|
}
|
||||||
|
|
||||||
|
button.processing {
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
background-color: #b59207;
|
||||||
|
font-size: 16px;
|
||||||
|
color: #ffffff;
|
||||||
|
font-weight: 600;
|
||||||
|
border-radius: 6px;
|
||||||
|
border: 2px solid #b59207;
|
||||||
|
transition-duration: 0.3s;
|
||||||
|
float: right;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.searchbox {
|
||||||
|
border-radius: 6px;
|
||||||
|
background: #ffffff;
|
||||||
|
padding: 4px;
|
||||||
|
border: 0px;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
input.searchtextbox{
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
font-size: 14px;
|
||||||
|
color: #000000;
|
||||||
|
font-weight: 400;
|
||||||
|
text-decoration: none;
|
||||||
|
border: 0px;
|
||||||
|
outline-color: #ffffff;
|
||||||
|
}
|
BIN
scripts/system/more/del-x-16.png
Normal file
After Width: | Height: | Size: 536 B |
BIN
scripts/system/more/minus-16.png
Normal file
After Width: | Height: | Size: 385 B |
276
scripts/system/more/more.html
Normal file
|
@ -0,0 +1,276 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<!--
|
||||||
|
// more.html
|
||||||
|
//
|
||||||
|
// 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
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// Distributed under the Apache License, Version 2.0.
|
||||||
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.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
|
||||||
|
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,
|
||||||
|
tmp = [];
|
||||||
|
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]);
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
var offset = findGetParameter("offset");
|
||||||
|
if (offset === null) {
|
||||||
|
offset = DEFAULT_OFFSET;
|
||||||
|
}
|
||||||
|
offset = parseInt(offset);
|
||||||
|
|
||||||
|
var perpage = findGetParameter("perpage");
|
||||||
|
if (perpage === null) {
|
||||||
|
perpage = DEFAULT_PER_PAGE;
|
||||||
|
}
|
||||||
|
perpage = parseInt(perpage);
|
||||||
|
|
||||||
|
var search = findGetParameter("search");
|
||||||
|
if (search === null) {
|
||||||
|
search = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
//Search
|
||||||
|
function doSearch(keyword) {
|
||||||
|
offset = 0;
|
||||||
|
search = keyword;
|
||||||
|
listBuilder(keyword, offset, perpage);
|
||||||
|
}
|
||||||
|
|
||||||
|
function clearSearch() {
|
||||||
|
offset = 0;
|
||||||
|
document.searchbar.searchtextbox.value = "";
|
||||||
|
search = "";
|
||||||
|
listBuilder("", offset, perpage);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Running scripts
|
||||||
|
var buttonList = [];
|
||||||
|
|
||||||
|
function requestRunningScriptData() {
|
||||||
|
var readyEvent = {
|
||||||
|
"action": "requestRunningScriptData"
|
||||||
|
};
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify(readyEvent));
|
||||||
|
}
|
||||||
|
|
||||||
|
EventBridge.scriptEventReceived.connect(function(message){
|
||||||
|
//update the buttons
|
||||||
|
if (message.indexOf("RSL4MOREAPP:") !== -1){
|
||||||
|
buttonList.forEach(function(item){
|
||||||
|
var btn = "";
|
||||||
|
if (message.indexOf(item.url) !== -1) {
|
||||||
|
//Means already running
|
||||||
|
btn = "<button class='uninstall' onclick='uninstall(" + '"' + item.url + '"' + ", " + '"' + item.id + '"' + ");'>Uninstall</button>";
|
||||||
|
} else {
|
||||||
|
//Means not already installed
|
||||||
|
btn = "<button class='install' onclick='install(" + '"' + item.url + '"' + ", " + '"' + item.id + '"' + ");'>Install</button>";
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById(item.id).innerHTML = btn;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function install(script, btnId){
|
||||||
|
var btn = "<button class='processing' >Processing...</button>";
|
||||||
|
document.getElementById(btnId).innerHTML = btn;
|
||||||
|
|
||||||
|
var readyEvent = {
|
||||||
|
"action": "installScript",
|
||||||
|
"script": script
|
||||||
|
};
|
||||||
|
|
||||||
|
EventBridge.emitWebEvent(JSON.stringify(readyEvent));
|
||||||
|
}
|
||||||
|
|
||||||
|
function uninstall(script, btnId){
|
||||||
|
var btn = "<button class='processing' >Processing...</button>";
|
||||||
|
document.getElementById(btnId).innerHTML = btn;
|
||||||
|
|
||||||
|
var readyEvent = {
|
||||||
|
"action": "uninstallScript",
|
||||||
|
"script": script
|
||||||
|
};
|
||||||
|
|
||||||
|
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" onsubmit="submitForm(event);">
|
||||||
|
<font class="mainTitle">Add more functionalities...</font><br>
|
||||||
|
<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" 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;">
|
||||||
|
<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>
|
||||||
|
<div id = "data"></div>
|
||||||
|
<div style="width:98%; text-align:right;">
|
||||||
|
<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>";
|
||||||
|
pageContent = pageContent + "<td><div class='iconContainer'><img src='" + rootPath + item.icon + "' style='width:50px;'><br><font class = 'caption'>" + item.caption + "</font></div></td>";
|
||||||
|
var btn = "";
|
||||||
|
var absoluteJsFile = rootPath + item.jsfile;
|
||||||
|
|
||||||
|
var btn = "<button class='install' onclick = 'install(" + '"' + absoluteJsFile + " ," + window.btoa(item.directory) + '"' + ");'>Install</button>";
|
||||||
|
var btndata = {
|
||||||
|
"url": absoluteJsFile,
|
||||||
|
"id": window.btoa(item.directory)
|
||||||
|
};
|
||||||
|
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>";
|
||||||
|
}
|
||||||
|
|
||||||
|
function listBuilder(searchKeyword, listOffset, listPerPage) {
|
||||||
|
buttonList = [];
|
||||||
|
var counterDir = -1;
|
||||||
|
var counterDisp = 0;
|
||||||
|
var index = 0;
|
||||||
|
var lowItem = "";
|
||||||
|
var needNext = false;
|
||||||
|
pageContent = "";
|
||||||
|
|
||||||
|
for (index = 0; index < metadata.applications.length; index++) {
|
||||||
|
lowItem = metadata.applications[index].name.toLowerCase();
|
||||||
|
if (lowItem.indexOf(searchKeyword.toLowerCase()) !== -1 && metadata.applications[index].isActive == true) {
|
||||||
|
counterDir = counterDir + 1;
|
||||||
|
if ((counterDir >= listOffset) && (counterDir < (listOffset + listPerPage))) {
|
||||||
|
displayApp(metadata.applications[index]);
|
||||||
|
counterDisp = counterDisp + 1;
|
||||||
|
}
|
||||||
|
if (counterDir >= (listOffset + listPerPage)) {
|
||||||
|
needNext = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var pagerPrevious = "<a href='#' onclick='pagetoPrevious();'><img src='minus-16.png'></a>";
|
||||||
|
if (listOffset <= 0) {
|
||||||
|
pagerPrevious = "<img src='blank_minus-16.png'>";
|
||||||
|
}
|
||||||
|
|
||||||
|
var pagerNext = "<a href='#' onclick='pagetoNext();'><img src='plus-16.png'></a>";
|
||||||
|
if (needNext == false) {
|
||||||
|
pagerNext = "<img src='blank_plus-16.png'>";
|
||||||
|
}
|
||||||
|
|
||||||
|
var countA = listOffset + 1;
|
||||||
|
|
||||||
|
var countB = listOffset + counterDisp;
|
||||||
|
|
||||||
|
var pagerHtml = pagerPrevious + "<font class='pager'> " + countA + " - " + countB + " </font>" + pagerNext;
|
||||||
|
|
||||||
|
if (counterDisp > 0 ) {
|
||||||
|
document.getElementById("pager_top").innerHTML = pagerHtml;
|
||||||
|
document.getElementById("data").innerHTML = pageContent;
|
||||||
|
document.getElementById("pager_footer").innerHTML = pagerHtml;
|
||||||
|
} 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>
|
BIN
scripts/system/more/plus-16.png
Normal file
After Width: | Height: | Size: 393 B |
BIN
scripts/system/more/search-32.png
Normal file
After Width: | Height: | Size: 1.5 KiB |