mirror of
https://github.com/overte-org/community-apps.git
synced 2025-04-14 13:26:31 +02:00
Add files via upload
This commit is contained in:
parent
c5737d9978
commit
667eef02ce
2 changed files with 87 additions and 26 deletions
|
@ -17,7 +17,7 @@
|
|||
var APP_ICON_INACTIVE = ROOT + "appicon_i.png";
|
||||
var APP_ICON_ACTIVE = ROOT + "appicon_a.png";
|
||||
var Appstatus = false;
|
||||
var currentlyRunningScripts;
|
||||
|
||||
|
||||
var tablet = Tablet.getTablet("com.highfidelity.interface.tablet.system");
|
||||
var button = tablet.addButton({
|
||||
|
@ -35,8 +35,7 @@
|
|||
tablet.screenChanged.disconnect(onMoreAppScreenChanged);
|
||||
}else{
|
||||
//print("turn on");
|
||||
currentlyRunningScripts = ScriptDiscoveryService.getRunning();
|
||||
//print(JSON.stringify(currentlyRunningScripts));
|
||||
|
||||
|
||||
tablet.gotoWebScreen(APP_URL + "?version=" + Math.floor(Math.random()*50000));
|
||||
|
||||
|
@ -44,7 +43,7 @@
|
|||
tablet.screenChanged.connect(onMoreAppScreenChanged);
|
||||
|
||||
Script.setTimeout(function() {
|
||||
tablet.emitScriptEvent(currentlyRunningScripts);
|
||||
sendRunningScriptList();
|
||||
}, 2000);
|
||||
|
||||
|
||||
|
@ -61,27 +60,33 @@
|
|||
}
|
||||
|
||||
button.clicked.connect(clicked);
|
||||
|
||||
function sendRunningScriptList(){
|
||||
var currentlyRunningScripts = ScriptDiscoveryService.getRunning();
|
||||
tablet.emitScriptEvent(currentlyRunningScripts);
|
||||
}
|
||||
|
||||
|
||||
function onMoreAppWebEventReceived(eventz){
|
||||
|
||||
|
||||
if(typeof eventz === "string"){
|
||||
eventzget = JSON.parse(eventz);
|
||||
|
||||
|
||||
if(eventzget.type === "MORE_INSTALL"){
|
||||
/*
|
||||
var myVec = {
|
||||
x: parseFloat(eventzget.x),
|
||||
y: parseFloat(eventzget.y),
|
||||
z: parseFloat(eventzget.z)
|
||||
};
|
||||
*/
|
||||
if(eventzget.action === "installScript"){
|
||||
ScriptDiscoveryService.loadOneScript(eventzget.script);
|
||||
sendRunningScriptList();
|
||||
}
|
||||
|
||||
if(eventzget.type === "MORE_UNINSTALL"){
|
||||
|
||||
if(eventzget.action === "uninstallScript"){
|
||||
ScriptDiscoveryService.stopScript(eventzget.script, false);
|
||||
sendRunningScriptList();
|
||||
}
|
||||
|
||||
if(eventzget.action === "requestRunningScriptData"){
|
||||
sendRunningScriptList();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,15 +46,72 @@
|
|||
var rootPath = currentPath.replace("more/more.html", "applications/");
|
||||
|
||||
//Running scripts
|
||||
var currentlyRunningScripts;
|
||||
|
||||
var buttonList = [];
|
||||
|
||||
function requestRunningScriptData() {
|
||||
var readyEvent = {
|
||||
"action": "requestRunningScriptData"
|
||||
};
|
||||
EventBridge.emitWebEvent(JSON.stringify(readyEvent));
|
||||
}
|
||||
|
||||
var currentlyRunningScripts = {};
|
||||
|
||||
EventBridge.scriptEventReceived.connect(function(message){
|
||||
currentlyRunningScripts = message;
|
||||
//update the buttons
|
||||
buttonList.forEach(function(item){
|
||||
var btn = "";
|
||||
if(CheckRunning(item.url) != false){
|
||||
//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 CheckRunning(scriptName){
|
||||
function install(script, btnId){
|
||||
//Action
|
||||
var readyEvent = {
|
||||
"action": "installScript",
|
||||
"script": script
|
||||
};
|
||||
|
||||
return false;
|
||||
EventBridge.emitWebEvent(JSON.stringify(readyEvent));
|
||||
|
||||
//then change btn appearence
|
||||
//var btn = "<button class='uninstall' onclick='uninstall(" + script + ", " + btnId + ");'>Uninstall</button>";
|
||||
//document.getElementById(btnId).innerHTML = btn;
|
||||
|
||||
}
|
||||
|
||||
function uninstall(script, btnId){
|
||||
//Action
|
||||
var readyEvent = {
|
||||
"action": "uninstallScript",
|
||||
"script": script
|
||||
};
|
||||
|
||||
EventBridge.emitWebEvent(JSON.stringify(readyEvent));
|
||||
//then change btn appearence
|
||||
//var btn = "<button class='install' onclick='install(" + script + ", " + btnId + ");'>Install</button>";
|
||||
//document.getElementById(btnId).innerHTML = btn;
|
||||
|
||||
}
|
||||
|
||||
function CheckRunning(scriptUrl){
|
||||
if(currentlyRunningScripts.some(currentlyRunningScripts => currentlyRunningScripts.path === scriptUrl)){
|
||||
return true;
|
||||
} else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -231,19 +288,18 @@
|
|||
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;
|
||||
if(CheckRunning(absoluteJsFile) != false){
|
||||
//Means already running
|
||||
btn = "<button class='uninstall'>Uninstall</button>";
|
||||
}else{
|
||||
//Means not already installed
|
||||
btn = "<button class='install'>Install</button>";
|
||||
}
|
||||
|
||||
var btn = "<button class='install' onclick = 'uninstall(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>";
|
||||
|
@ -305,7 +361,7 @@
|
|||
document.getElementById("pager_top").innerHTML = pagerHtml;
|
||||
document.getElementById("data").innerHTML = pageContent;
|
||||
document.getElementById("pager_footer").innerHTML = pagerHtml;
|
||||
|
||||
requestRunningScriptData();
|
||||
</script>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue