chore(project) rename main directory
This commit is contained in:
126
lib/views/index.html
Normal file
126
lib/views/index.html
Normal file
@@ -0,0 +1,126 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>WetSock Client Test</title>
|
||||
<style>
|
||||
/* Add some basic styling */
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 20px;
|
||||
}
|
||||
input, button {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
#output {
|
||||
border: 1px solid #ccc;
|
||||
padding: 10px;
|
||||
height: 300px;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>WetSock Client Test</h1>
|
||||
|
||||
<div>
|
||||
<label for="pluginIdentifier">Plugin:</label>
|
||||
<select id="pluginIdentifier">
|
||||
<!-- Options will be populated dynamically -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="actionName">Action:</label>
|
||||
<select id="actionName">
|
||||
<!-- Options will be populated dynamically -->
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="entityId">Entity ID:</label>
|
||||
<input type="text" id="entityId">
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="args">Arguments (comma-separated):</label>
|
||||
<input type="text" id="args">
|
||||
</div>
|
||||
|
||||
<button id="sendButton">Send</button>
|
||||
|
||||
<h2>Output:</h2>
|
||||
<div id="output"></div>
|
||||
|
||||
<script type="module">
|
||||
import WetSockClient from './client.js';
|
||||
const client = new WetSockClient('wss://wetsock.ghosted.id:443/chat');
|
||||
const pluginIdentifierSelect = document.getElementById('pluginIdentifier');
|
||||
const actionNameSelect = document.getElementById('actionName');
|
||||
const entityIdInput = document.getElementById('entityId');
|
||||
const argsInput = document.getElementById('args');
|
||||
const sendButton = document.getElementById('sendButton');
|
||||
const outputDiv = document.getElementById('output');
|
||||
|
||||
client.on('connected', () => {
|
||||
log('Connected to WetSock server');
|
||||
});
|
||||
|
||||
client.on('pluginList', (data) => {
|
||||
updatePluginOptions(data.plugins);
|
||||
});
|
||||
|
||||
client.on('actionPerformed', (data) => {
|
||||
log(`Action performed: ${JSON.stringify(data)}`);
|
||||
});
|
||||
|
||||
client.on('entityCreated', (data) => {
|
||||
log(`Entity created: ${JSON.stringify(data)}`);
|
||||
});
|
||||
|
||||
sendButton.addEventListener('click', () => {
|
||||
const pluginIdentifier = pluginIdentifierSelect.value;
|
||||
const actionName = actionNameSelect.value;
|
||||
const entityId = entityIdInput.value;
|
||||
const args = argsInput.value.split(',').map(arg => arg.trim());
|
||||
|
||||
if (actionName === 'create') {
|
||||
client.createEntity(pluginIdentifier, { /* entity data */ });
|
||||
} else {
|
||||
client.performAction(pluginIdentifier, entityId, actionName, ...args);
|
||||
}
|
||||
});
|
||||
|
||||
function updatePluginOptions(plugins) {
|
||||
pluginIdentifierSelect.innerHTML = '';
|
||||
plugins.forEach((plugin) => {
|
||||
const option = document.createElement('option');
|
||||
option.value = plugin.identifier;
|
||||
option.textContent = plugin.identifier;
|
||||
pluginIdentifierSelect.appendChild(option);
|
||||
});
|
||||
updateActionOptions();
|
||||
}
|
||||
|
||||
function updateActionOptions() {
|
||||
const pluginIdentifier = pluginIdentifierSelect.value;
|
||||
const actions = client.plugins.get(pluginIdentifier);
|
||||
actionNameSelect.innerHTML = '';
|
||||
actions.forEach((action) => {
|
||||
const option = document.createElement('option');
|
||||
option.value = action;
|
||||
option.textContent = action;
|
||||
actionNameSelect.appendChild(option);
|
||||
});
|
||||
}
|
||||
|
||||
function log(message) {
|
||||
const entry = document.createElement('div');
|
||||
entry.textContent = message;
|
||||
outputDiv.appendChild(entry);
|
||||
outputDiv.scrollTop = outputDiv.scrollHeight;
|
||||
}
|
||||
|
||||
pluginIdentifierSelect.addEventListener('change', updateActionOptions);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user