Upload files to "kronic-chat/js"
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
window.Kronick = window.Kronick || {};
|
||||
Kronick.state = Kronick.state || {};
|
||||
|
||||
Kronick.createId = function createId() {
|
||||
if (
|
||||
window.crypto
|
||||
&& typeof window.crypto.randomUUID === 'function'
|
||||
) {
|
||||
return window.crypto.randomUUID();
|
||||
}
|
||||
|
||||
return [
|
||||
Date.now(),
|
||||
Math.random().toString(36).slice(2)
|
||||
].join('-');
|
||||
};
|
||||
|
||||
Kronick.escapeHtml = function escapeHtml(value) {
|
||||
return String(value)
|
||||
.replaceAll('&', '&')
|
||||
.replaceAll('<', '<')
|
||||
.replaceAll('>', '>')
|
||||
.replaceAll('"', '"')
|
||||
.replaceAll("'", ''');
|
||||
};
|
||||
|
||||
Kronick.escapeAttribute = function escapeAttribute(value) {
|
||||
return Kronick.escapeHtml(value);
|
||||
};
|
||||
|
||||
Kronick.setStatus = function setStatus(
|
||||
message,
|
||||
state = ''
|
||||
) {
|
||||
const statusBar =
|
||||
document.getElementById('statusBar');
|
||||
|
||||
const statusIndicator =
|
||||
document.getElementById('statusIndicator');
|
||||
|
||||
if (statusBar) {
|
||||
statusBar.innerText = message;
|
||||
}
|
||||
|
||||
if (!statusIndicator) {
|
||||
return;
|
||||
}
|
||||
|
||||
statusIndicator.className =
|
||||
'status-indicator';
|
||||
|
||||
if (state) {
|
||||
statusIndicator.classList.add(state);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user