implemented spaces, fixed login and signup, thought creation and space creation.

This commit is contained in:
2025-05-26 13:00:12 -06:00
parent 54a01f0f1f
commit d3fa1733f4
32 changed files with 1499 additions and 1132 deletions
+15
View File
@@ -0,0 +1,15 @@
document.addEventListener('DOMContentLoaded', function() {
const rows = document.querySelectorAll('tbody tr');
rows.forEach(row => {
row.addEventListener('click', function(event) {
// Check if the clicked element is within the non-clickable cell
if (event.target.closest('.excluded_cell')) {
return; // Do nothing if clicked inside the non-clickable cell
}
// Perform the desired action (e.g., redirect)
window.location.href = this.dataset.href; // Example redirect
});
});
});
+16
View File
@@ -0,0 +1,16 @@
const textarea = document.querySelector('textarea');
const preview = document.getElementById('md_preview');
textarea.addEventListener('input', function() {
fetch('functions/preview.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: 'markdown=' + encodeURIComponent(this.value),
})
.then(response => response.text())
.then(data => {
preview.innerHTML = decodeURIComponent(data);
});
});
+169
View File
@@ -0,0 +1,169 @@
document.addEventListener('DOMContentLoaded', function() {
var user_actions_modal = document.getElementById("modal");
var modal_content = document.getElementById("display_modal");
var profile_picture_input = document.getElementById("profile_picture_input");
// Event listener on the file input
profile_picture_input.addEventListener('change', function() {
if (profile_picture_input.files && profile_picture_input.files[0]) {
var file = profile_picture_input.files[0];
var form_data = new FormData();
form_data.append('upload', file);
form_data.append('test_key', 'test_value');
var xhr = new XMLHttpRequest();
xhr.open('POST', 'http://localhost:2025/functions/functions.php', true);
xhr.setRequestHeader('enctype', 'multipart/form-data');
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300) {
filepath = '/data/tmp/' + profile_picture_input.files[0].name;
openModal('profile_cropper', filepath);
} else {
console.error('Error uploading file:', xhr.status, xhr.statusText);
}
xhr.onerror = function() {
console.error('Network error occurred.');
};
};
xhr.send(form_data);
}
});
// Open modal function
function openModal(formId, filePath = null) {
let content = document.getElementById(formId).innerHTML;
if (filePath) {
content = content.replace('IMG_UPLOAD_PATH', filePath);
}
modal_content.innerHTML = content;
user_actions_modal.style.display = "block";
cropper();
}
function cropper() {
let img_to_crop = document.getElementById('img_to_crop');
let selection_box = document.getElementById('img_crop_selection');
let crop_button = document.getElementById('crop_button');
let corners = document.querySelectorAll('.corner');
const img_bounds = img_to_crop.getBoundingClientRect();
console.log('img_bounds: ' + img_bounds.top + ', ' + img_bounds.left);
let selection = {
x: 0,
y: 0,
width: 100,
height: 100,
is_resizing: false,
is_dragging: false,
resize_corner: null,
};
function updateSelection() {
selection_box.style.left = `${selection.x}px`;
selection_box.style.top = `${selection.y}px`;
selection_box.style.width = `${selection.width}px`;
selection_box.style.height = `${selection.height}px`;
}
img_to_crop.addEventListener('mousemove', (e) => {
const { clientX, clientY } = e;
if (!selection_box.classList.contains('stop')) {
// const box_bounds = selection_box.getBoundingClientRect();
//
// console.log('box_bounds: ' + box_bounds.top);
// if (box_bounds.left > img_bounds.left || box_bounds.right < img_bounds.right)
selection.x = clientX;
// if (box_bounds.top > img_bounds.top || box_bounds.bottom > img_bounds.bottom)
selection.y = clientY;
updateSelection();
} else if (selection.is_resizing) {
resizing(e);
}
});
img_to_crop.addEventListener('click', function(event) {
if (selection_box.classList.contains('stop')) {
selection.is_resizing = false;
selection_box.classList.remove('stop');
}
else {
selection_box.classList.add('stop');
}
})
corners.forEach((corner) => {
corner.addEventListener('mousedown', (e) => {
selection.resize_corner = corner.id;
selection.is_resizing = true;
e.stopPropagation(); // Prevent image click event
});
corner.addEventListener('dragstart', (e) => {
e.preventDefault();
})
});
crop_button.addEventListener('click', () => {
var ratio = img_to_crop.naturalWidth / img_bounds.width;
document.getElementById('crop_x').value = (selection.x - img_bounds.left - (selection.width / 2)) * ratio;
document.getElementById('crop_y').value = (selection.y - img_bounds.top - (selection.width / 2)) * ratio;
document.getElementById('crop_width').value = selection.width;
closeModal();
});
function resizing(e) {
if (!selection.is_resizing) return;
const aspect_ratio = 1;
let newWidth = selection.width;
switch (selection.resize_corner) {
case 'corner_nw':
newWidth = selection.x - e.clientX;
break;
case 'corner_sw':
newWidth = selection.x - e.clientX;
break;
case 'corner_ne':
newWidth = e.clientX - selection.x;
break;
case 'corner_se':
newWidth = e.clientX - selection.x;
break;
}
selection.width = newWidth;
selection.height = newWidth / aspect_ratio;
// }
updateSelection();
}
}
modal_content.addEventListener('click', function(event) {
if (event.target.classList.contains('modal_close')) {
closeModal();
}
});
window.onclick = function(event) {
if (event.target.classList.contains('modal')) {
closeModal();
}
};
// Close modal function
function closeModal() {
modal_content.innerHTML = ""; // Clear content when closing
user_actions_modal.style.display = "none";
}
});
+49
View File
@@ -0,0 +1,49 @@
/*
.then(response => {
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json(); // Or handle other response formats
})
.then(responseData => {
console.log('Response received:', responseData);
// Handle the server's response
});
*/
document.addEventListener('DOMContentLoaded', function() {
var todos = document.getElementsByClassName('todo_item');
//var todos = document.querySelectorAll('todo_item');
for (let i = 0; i < todos.length; i++) {
var item = todos[i];
var checkbox = item.querySelector('input[type="checkbox"]');
checkbox.todo_id = item.querySelector('input[name="todo_id"]').value;
checkbox.is_checked = checkbox.checked;
checkbox.addEventListener('click', function() {
if (!this.is_checked) {
this.is_checked = true;
fetch('director.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: 'ajax_id=todo&action_id=status&todo_id=' + this.todo_id + '&status=completed',
});
} else {
this.is_checked = false;
fetch('director.php', {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
body: 'ajax_id=todo&action_id=status&todo_id=' + this.todo_id + '&status=open',
});
}
});
}
});
+12
View File
@@ -0,0 +1,12 @@
const file_inputs = document.getElementsByClassName('file_input');
const filename_displays = document.getElementsByClassName('file_input_feedback');
for (let i = 0; i < file_inputs.length; i++) {
file_inputs[i].addEventListener('change', function() {
const selected_file = event.target.files[0];
if (selected_file)
filename_displays[i].textContent = 'File uploaded: ' + selected_file.name;
else
filename_displays[i].textContent = 'No file selected.';
})
}
+57
View File
@@ -0,0 +1,57 @@
document.addEventListener('DOMContentLoaded', function() {
var user_actions_modal = document.getElementById("user_actions_modal");
var modal_content = document.getElementById("modal_content");
var buttons = document.getElementsByClassName("modal_button");
for (let i = 0; i < buttons.length; i++) {
buttons[i].onclick = function() {
switch (buttons[i].id) {
case 'reset_pw_form_button':
openModal('reset_pw_form');
break;
case 'update_email_form_button':
openModal('update_email_form');
break;
case 'update_username_form_button':
openModal('update_username_form');
break;
case 'update_profile_picture_form_button':
openModal('update_profile_picture_form');
break;
case 'request_role_form_button':
openModal("request_role_change_form");
break;
case 'delete_account_form_button':
openModal('delete_account_form');
break;
default:
break;
}
}
}
// Open modal function
function openModal(formId) {
modal_content.innerHTML = document.getElementById(formId).innerHTML;
user_actions_modal.style.display = "block";
}
modal_content.addEventListener('click', function(event) {
if (event.target.classList.contains('modal_close')) {
closeModal();
}
});
window.onclick = function(event) {
if (event.target.classList.contains('modal')) {
closeModal();
}
};
// Close modal function
function closeModal() {
modal_content.innerHTML = ""; // Clear content when closing
user_actions_modal.style.display = "none";
}
});