Files
CLARA/core/share.html
2025-11-02 14:27:29 +01:00

243 lines
8.3 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>{{TITLE}}</title>
<style type="text/css">
html {
box-sizing: border-box;
}
*, *:before, *:after {
-webkit-box-sizing: inherit;
-moz-box-sizing: inherit;
box-sizing: inherit;
}
html, body {
margin: 0;
padding: 0;
}
body {
font-family: Arial, Helvetica, sans-serif;
background: #f3f4f6;
color: #222;
line-height: 1.4;
font-size: 14px;
}
.container {
width: 95%;
max-width: 760px;
margin: 10px auto;
background: #ffffff;
border: 1px solid #cfcfcf;
padding: 16px;
}
.header {
padding-bottom: 12px;
border-bottom: 2px solid #e6e6e6;
overflow: hidden;
}
.brand {
float: left;
font-weight: bold;
font-size: 20px;
color: #2b65a3;
}
.subtitle {
float: right;
color: #666;
font-size: 12px;
margin-top: 4px;
text-align: right;
}
.main {
margin-top: 16px;
overflow: hidden;
}
.left-col {
float: left;
width: 60%;
min-width: 300px;
}
.right-col {
float: left;
width: 36%;
min-width: 160px;
margin-left: 12px;
}
.section { margin-bottom: 18px; }
h2 {
font-size: 16px;
margin: 6px 0 10px 0;
color: #333;
}
p { margin: 8px 0; color: #444; }
table.file-list {
width: 100%;
border-collapse: collapse;
border-spacing: 0;
}
table.file-list th, table.file-list td {
padding: 8px 6px;
border-bottom: 1px solid #eaeaea;
text-align: left;
vertical-align: middle;
}
table.file-list th {
background: #f7f7f7;
font-size: 13px;
color: #333;
}
a.button {
display: inline-block;
padding: 6px 10px;
text-decoration: none;
border: 1px solid #9fb3d6;
background: #e9f0fb;
color: #1a4f86;
cursor: pointer;
font-size: 13px;
}
a.button:hover { text-decoration: underline; }
textarea.share-text {
width: 100%;
height: 220px;
font-family: "Courier New", Courier, monospace;
font-size: 12px;
padding: 6px;
border: 1px solid #ccc;
background: #fafafa;
}
.clearfix { display: block; }
.footer {
margin-top: 16px;
padding-top: 12px;
border-top: 1px solid #eaeaea;
text-align: center;
font-size: 11px;
color: #888;
}
.footer a {
color: #555;
text-decoration: none;
}
.footer a:hover { text-decoration: underline; }
/* Responsive styles */
@media screen and (max-width: 600px) {
.left-col, .right-col {
width: 100%;
float: none;
margin-left: 0;
min-width: 0;
}
.subtitle {
float: none;
text-align: left;
margin-top: 8px;
}
}
</style>
</head>
<body>
<div class="container">
<div class="header">
<div class="brand">CLARA Share</div>
<div class="subtitle">Simple file &amp; text sharing — local network</div>
</div>
<div class="main clearfix">
<div class="left-col">
<div class="section" id="shared-text-container">
{{SHARED_TEXT_HTML}}
</div>
<div class="section" id="shared-files-container">
{{SHARED_FILES_HTML}}
</div>
</div>
<div class="right-col">
<div class="section">
<h2>Quick Info</h2>
<p><strong>Host:</strong><br/><span>{{HOSTNAME}}</span></p>
<p><strong>URL:</strong><br/><span>{{URL}}</span></p>
<p><strong>Total Size:</strong><br/><span>{{TOTAL_SIZE_INFO}}</span></p>
<p><strong>Status:</strong><br/><span>Server running</span></p>
</div>
</div>
<div id="no-content-message" style="display: {{NO_CONTENT_DISPLAY}};">
<p>No content is currently being shared.</p>
</div>
</div>
<div class="footer">
<p>Powered by <a href="https://github.com/n0va-bot/CLARA" target="_blank">CLARA</a>, your friendly desktop assistant.</p>
</div>
</div>
<script type="text/javascript">
(function() {
var lastData = '';
function updateContent(data) {
var textContainer = document.getElementById('shared-text-container');
var filesContainer = document.getElementById('shared-files-container');
var noContent = document.getElementById('no-content-message');
var hasText = data.text && data.text.length > 0;
var hasFiles = data.files && data.files.length > 0;
if (textContainer) {
var textHtml = '';
if (hasText) {
textHtml = '<h2>Shared Text</h2>' +
'<p>Select the text below and copy it to your clipboard.</p>' +
'<textarea class="share-text" readonly="readonly">' + data.text + '</textarea>';
}
textContainer.innerHTML = textHtml;
}
if (filesContainer) {
var filesHtml = '';
if (hasFiles) {
var rows = '';
for (var i = 0; i < data.files.length; i++) {
var file = data.files[i];
rows += '<tr>' +
'<td>' + file.name + '</td>' +
'<td>' + file.size + '</td>' +
'<td><a class="button" href="' + file.url + '">Download</a></td>' +
'</tr>';
}
filesHtml = '<h2>Shared Files</h2>' +
'<p>Click a button to download the corresponding file.</p>' +
'<table class="file-list" cellpadding="0" cellspacing="0">' +
'<tr><th>Filename</th><th>Size</th><th>Action</th></tr>' + rows + '</table>';
}
filesContainer.innerHTML = filesHtml;
}
if (noContent) {
noContent.style.display = (hasText || hasFiles) ? 'none' : 'block';
}
}
function fetchData() {
var xhr = new (window.XMLHttpRequest || ActiveXObject)('MSXML2.XMLHTTP.3.0');
xhr.open('GET', '/api/data', true);
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
if (xhr.responseText !== lastData) {
lastData = xhr.responseText;
try {
var data = JSON.parse(xhr.responseText);
updateContent(data);
} catch (e) {}
}
}
};
xhr.send(null);
}
// Refresh data every 5 seconds
setInterval(fetchData, 5000);
})();
</script>
</body>
</html>