Skip to content

Commit 329f196

Browse files
committed
Implement Mini Apps in chrome environment
1 parent bf351f6 commit 329f196

23 files changed

Lines changed: 3770 additions & 87 deletions

.idea/workspace.xml

Lines changed: 52 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
// eventEmitter.js
2+
3+
/**
4+
* Class representing an EventEmitter.
5+
* This class allows different parts of an application to communicate with each other
6+
* by emitting and listening to events.
7+
*/
8+
class EventEmitter {
9+
10+
/**
11+
* Create an EventEmitter.
12+
* Initializes an empty events object to store event listeners.
13+
*/
14+
constructor() {
15+
this.events = {};
16+
}
17+
18+
/**
19+
* Register an event listener for a specific event.
20+
* If the event does not exist, it is created.
21+
*
22+
* @param {string} event - The name of the event.
23+
* @param {function} listener - The callback function to execute when the event is emitted.
24+
*/
25+
on(event, listener) {
26+
if (!this.events[event]) {
27+
this.events[event] = [];
28+
}
29+
this.events[event].push(listener);
30+
}
31+
32+
/**
33+
* Emit a specific event, executing all registered listeners for that event.
34+
* Additional arguments are passed to the listener functions.
35+
*
36+
* @param {string} event - The name of the event to emit.
37+
* @param {...*} args - The arguments to pass to the listener functions.
38+
* @returns {Array} - The results of the listener functions.
39+
*/
40+
emit(event, ...args) {
41+
if (!this.events[event]) return [];
42+
43+
return this.events[event].map(listener => listener(...args));
44+
}
45+
}
46+
47+
// Create a global instance of EventEmitter and assign it to window object
48+
window.eventEmitter = new EventEmitter();
Lines changed: 39 additions & 0 deletions
Loading
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
function getContactsList() {
2+
// Get the contacts list from the native code
3+
backend("getContactsList");
4+
}
5+
6+
function writeLogEntry(entry) {
7+
// Write a log entry to the native code, use currentMiniAppID to identify the app
8+
// entry is a JSONString
9+
backend("customApp:writeEntry " + currentMiniAppID + " " + entry);
10+
}
11+
12+
function readLogEntries(numberOfEntries) {
13+
// Read the log entries from the native code associated with the currentMiniAppID
14+
backend("customApp:readEntries " + currentMiniAppID + " " + numberOfEntries);
15+
}
16+
17+
function quitApp() {
18+
// Quit the app
19+
setScenario('miniapps');
20+
}
21+
22+
function launchContactsMenu(heading, subheading) {
23+
closeOverlay()
24+
fill_members(true);
25+
prev_scenario = 'customApp';
26+
setScenario("members");
27+
28+
document.getElementById("div:textarea").style.display = 'none';
29+
document.getElementById("div:confirm-members").style.display = 'flex';
30+
document.getElementById("tremolaTitle").style.display = 'none';
31+
var c = document.getElementById("conversationTitle");
32+
c.style.display = null;
33+
c.innerHTML = "<font size=+1><strong>" + heading + "</strong></font><br>" + subheading;
34+
document.getElementById('plus').style.display = 'none';
35+
}
Lines changed: 3 additions & 0 deletions
Loading
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
{
2+
"name": "Kanban Boards",
3+
"description": "A visual project management tool to organize tasks.",
4+
"extension": "False",
5+
"extensionText": "",
6+
"extensionInit": "",
7+
"icon": "miniApps/kanban/assets/kanban.svg",
8+
"init": "setKanbanScenario('kanban')",
9+
"id": "kanban",
10+
"pluginClass": "nz.scuttlebutt.tremolavossbol.miniapps.KanbanPlugin",
11+
"cssFile": "/resources/kanban.css",
12+
"scripts": [
13+
"/src/board.js",
14+
"/src/board_ui.js"
15+
],
16+
"htmlFile": "/resources/kanban.html",
17+
"displayOrNot": [
18+
"lst:kanban",
19+
"div:board"
20+
],
21+
"scenarioDisplay": {
22+
"kanban": [
23+
"div:back",
24+
"core",
25+
"lst:kanban",
26+
"plus"
27+
],
28+
"board": [
29+
"div:back",
30+
"core",
31+
"div:board"
32+
] },
33+
"scenario": {
34+
"kanban": {
35+
"New Kanban board": "menu_new_board",
36+
"Invitations": "menu_board_invitations",
37+
"Connected Devices": "menu_connection",
38+
"Settings": "menu_settings",
39+
"About": "menu_about"
40+
},
41+
"board": {
42+
"Add list": "menu_new_column",
43+
"Rename Kanban Board": "menu_rename_board",
44+
"Invite Users": "menu_invite",
45+
"History": "menu_history",
46+
"Reload": "reload_curr_board",
47+
"Leave": "leave_curr_board",
48+
"(un)Forget": "board_toggle_forget",
49+
"Debug": "ui_debug"
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)