mirror of
https://github.com/overte-org/community-apps.git
synced 2025-04-07 12:42:58 +02:00
383 lines
No EOL
10 KiB
HTML
383 lines
No EOL
10 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<script type="text/javascript" src="../applications/metadata.js"></script>
|
|
<script>
|
|
//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 = 0;}
|
|
offset = parseInt(offset);
|
|
|
|
var perpage = findGetParameter("perpage");
|
|
if(perpage === null){perpage = 25;}
|
|
perpage = parseInt(perpage);
|
|
|
|
var search = findGetParameter("search");
|
|
if(search === null){search = "";}
|
|
|
|
|
|
|
|
//Search
|
|
function doSearch(keyword){
|
|
location.href = "more.html?offset=0&search=" + encodeURI(keyword);
|
|
}
|
|
|
|
function clearSearch(){
|
|
location.href = "more.html?offset=0";
|
|
}
|
|
|
|
|
|
|
|
//Paths
|
|
var currentPath = window.location.protocol + "//" + window.location.host + window.location.pathname;
|
|
var rootPath = currentPath.replace("more/more.html", "applications/");
|
|
|
|
//Running scripts
|
|
|
|
var buttonList = [];
|
|
|
|
function requestRunningScriptData() {
|
|
var readyEvent = {
|
|
"action": "requestRunningScriptData"
|
|
};
|
|
EventBridge.emitWebEvent(JSON.stringify(readyEvent));
|
|
}
|
|
|
|
|
|
|
|
EventBridge.scriptEventReceived.connect(function(message){
|
|
|
|
//update the buttons
|
|
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){
|
|
//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
|
|
};
|
|
|
|
EventBridge.emitWebEvent(JSON.stringify(readyEvent));
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</script>
|
|
<style>
|
|
|
|
body {
|
|
background: #73758c;
|
|
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;
|
|
}
|
|
|
|
h1 {
|
|
font-family: Arial, Helvetica, 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);
|
|
}
|
|
|
|
font.appname {
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
font-size: 18px;
|
|
color: #CFB538;
|
|
font-weight: 800;
|
|
text-decoration: none;
|
|
font-style: normal;
|
|
font-variant: normal;
|
|
text-transform: none;
|
|
}
|
|
|
|
font.appdesc {
|
|
font-family: Arial, Helvetica, sans-serif;
|
|
font-size: 14px;
|
|
color: #ffffff;
|
|
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: Arial, Helvetica, 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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
<body><form name = "searchbar">
|
|
<h1>Add more functionalities...</h1>
|
|
|
|
<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:100%; text-align:right;"><div style = "vertical-align: middle;" id = 'pager_footer'></div>
|
|
|
|
<script>
|
|
|
|
document.searchbar.searchtextbox.value = search;
|
|
|
|
|
|
|
|
|
|
|
|
function DisplayApp(item) {
|
|
pageContent = pageContent + "<a name = '" + window.btoa(item.name) + "'><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.name) + '"' + ");'>Install</button>";
|
|
var btndata = {
|
|
"url": absoluteJsFile,
|
|
"id": window.btoa(item.name)
|
|
};
|
|
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.name) +"' align='right'>" + btn + "</div></td>";
|
|
pageContent = pageContent + "</tr></table><br><br>";
|
|
}
|
|
|
|
|
|
var counterDir = -1;
|
|
var counterDisp = 0;
|
|
var index = 0;
|
|
var lowItem = "";
|
|
var needNext = false;
|
|
var pageContent = "";
|
|
|
|
for (index = 0; index < metadata.applications.length; index++){
|
|
lowItem = metadata.applications[index].name.toLowerCase();
|
|
if (lowItem.indexOf(search.toLowerCase()) != -1){
|
|
counterDir = counterDir + 1;
|
|
if ((counterDir >= offset) && (counterDir < (offset + perpage))){
|
|
DisplayApp(metadata.applications[index]);
|
|
counterDisp = counterDisp + 1;
|
|
}
|
|
if (counterDir >= (offset + perpage)){
|
|
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){
|
|
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 = offset + 1;
|
|
|
|
var countB = offset + counterDisp;
|
|
|
|
var pagerHtml = pagerPrevious + "<font class='pager'> " + countA + " - " + countB + " </font>" + pagerNext;
|
|
document.getElementById("pager_top").innerHTML = pagerHtml;
|
|
document.getElementById("data").innerHTML = pageContent;
|
|
document.getElementById("pager_footer").innerHTML = pagerHtml;
|
|
|
|
requestRunningScriptData();
|
|
</script>
|
|
|
|
|
|
</body>
|
|
</html> |