|
10 | 10 | <link rel="stylesheet" href="style.css"> |
11 | 11 | <link href="/dist/output.css" rel="stylesheet"> |
12 | 12 | <title>Programmer Netlink</title> |
| 13 | + <style> |
| 14 | + .quick-options { |
| 15 | + display: flex; /* Use flexbox to place the images in a row */ |
| 16 | + align-items: center; /* Center the images vertically */ |
| 17 | + } |
| 18 | + |
| 19 | + .quick-options img { |
| 20 | + margin-right: 10px; /* Add some spacing between the images */ |
| 21 | + } |
| 22 | + </style> |
13 | 23 | </head> |
| 24 | + |
14 | 25 | <body> |
15 | 26 |
|
| 27 | + |
| 28 | + |
16 | 29 | <!-- <div id="logo"> |
17 | 30 | <img src="/assets/text-logo.jpg"> |
18 | 31 | </div> --> |
19 | 32 |
|
20 | 33 | <!-- Button to show the modal --> |
21 | 34 | <button onclick="showModal()" id="showModalBtn"> |
22 | 35 | <img src="/assets/svg/+.svg"> |
| 36 | + <script> |
| 37 | +// JavaScript |
| 38 | +// JavaScript |
| 39 | +function uploadImage() { |
| 40 | + const fileInput = document.createElement('input'); |
| 41 | + fileInput.type = 'file'; |
| 42 | + fileInput.accept = 'image/*'; // Only allow image files |
| 43 | + |
| 44 | + fileInput.addEventListener('change', (event) => { |
| 45 | + const file = event.target.files[0]; |
| 46 | + if (file) { |
| 47 | + const reader = new FileReader(); |
| 48 | + reader.onload = (e) => { |
| 49 | + const imageDataUrl = e.target.result; |
| 50 | + const textarea = document.getElementById('post-title'); |
| 51 | + |
| 52 | + const imageBlob = dataURItoBlob(imageDataUrl); |
| 53 | + const blobURL = URL.createObjectURL(imageBlob); |
| 54 | + |
| 55 | + // Add blob URL to the textarea |
| 56 | + textarea.value = blobURL; |
| 57 | + |
| 58 | + // Save the blob URL to local storage |
| 59 | + localStorage.setItem('imageBlobURL', blobURL); |
| 60 | + }; |
| 61 | + |
| 62 | + reader.readAsDataURL(file); |
| 63 | + } |
| 64 | + }); |
| 65 | + |
| 66 | + // Trigger the file input dialog when the image is clicked |
| 67 | + fileInput.click(); |
| 68 | +} |
| 69 | + |
| 70 | +function dataURItoBlob(dataURI) { |
| 71 | + const byteString = atob(dataURI.split(',')[1]); |
| 72 | + const mimeString = dataURI.split(',')[0].split(':')[1].split(';')[0]; |
| 73 | + const ab = new ArrayBuffer(byteString.length); |
| 74 | + const ia = new Uint8Array(ab); |
| 75 | + for (let i = 0; i < byteString.length; i++) { |
| 76 | + ia[i] = byteString.charCodeAt(i); |
| 77 | + } |
| 78 | + return new Blob([ab], { type: mimeString }); |
| 79 | +} |
| 80 | + |
| 81 | + |
| 82 | + </script> |
23 | 83 | </button> |
24 | 84 |
|
25 | 85 |
|
|
28 | 88 | <!-- Modal container --> |
29 | 89 | <div class="modal-container" id="modalContainer"> |
30 | 90 | <div class="container"> |
31 | | - <form onsubmit="return checkBannedWordsBeforeSubmit()"> |
| 91 | + |
| 92 | + <!-- <h2 id="draftSnippetText">Draft a Snippet</h2> --> |
| 93 | + |
| 94 | + <form onsubmit="checkBannedWordsBeforeSubmit()"> |
32 | 95 |
|
33 | 96 | <textarea id="post-title" name="post-title" placeholder="Write about something..." minlength="10" maxlength="520" required></textarea> |
34 | 97 | <br> |
35 | 98 | <!-- Use onkeyup attribute here for the post-body textarea --> |
36 | 99 | <textarea onkeyup="checkBanWords()" id="post-body" name="post-body" placeholder="Write about something..." rows="4" minlength="10" maxlength="74"></textarea> |
37 | 100 | <br> |
38 | 101 | <div class="add-tags" style="display: none;"> |
39 | | - <!-- Rest of your form content... --> |
40 | 102 | </div> |
| 103 | + <div class="quick-options"> |
| 104 | + <img src="/assets/svg/image.svg" onclick="redirectToSettings()" width="35px" height="35px" alt="profile settings"> |
| 105 | + <img src="/assets/svg/tag.svg" onclick="logout()" width="35px" height="35px"> |
| 106 | + <img src="/assets/svg/link.svg" onclick="createLink()" width="35px" height="35px"> |
| 107 | + </div> |
41 | 108 |
|
42 | 109 | <input type="image" src="/assets/svg/sendPostArrow.svg" alt="Image Description"> |
43 | 110 | </form> |
@@ -195,8 +262,19 @@ <h4>Programmer Netlink | Navigation Menu</h4> |
195 | 262 | <li><a class="active" href="http://127.0.0.1:5500/productivity/app/app-selector/selector.html">Productivity Suite</a></li> |
196 | 263 |
|
197 | 264 | <div class="quick-options"> |
198 | | - <img src="/assets/svg/gear.svg" onclick="redirectToSettings()" width="35px" height="35px" alt="profile settings"> |
199 | | - <img src="/assets/svg/logout.svg" onclick="logout()" width="35px" height="35px"> |
| 265 | + <img src="/assets/svg/gear.svg" onclick="redirectToSettings()" width="35px" height="35px" alt="profile settings"> <img src="/assets/svg/logout.svg" onclick="logout()" width="35px" height="35px"> |
| 266 | + |
| 267 | + <style> |
| 268 | + .quick-options { |
| 269 | + display: flex; /* Use flexbox to place the images in a row */ |
| 270 | + align-items: center; /* Center the images vertically */ |
| 271 | +} |
| 272 | + |
| 273 | +.quick-options img { |
| 274 | + margin-right: 10px; /* Add some spacing between the images */ |
| 275 | +} |
| 276 | + |
| 277 | + </style> |
200 | 278 | </div> |
201 | 279 |
|
202 | 280 | </ul> |
@@ -255,7 +333,6 @@ <h4>Programmer Netlink | Navigation Menu</h4> |
255 | 333 | <div class="post-list"> |
256 | 334 |
|
257 | 335 | <div id="posts"> |
258 | | - |
259 | 336 | </div> |
260 | 337 |
|
261 | 338 | </div> |
@@ -323,9 +400,59 @@ <h4>Programmer Netlink | Navigation Menu</h4> |
323 | 400 | } |
324 | 401 | </script> |
325 | 402 |
|
| 403 | +<script> |
| 404 | + // Function to show the modal |
| 405 | + function showModal() { |
| 406 | + var modal = document.getElementById("modalContainer"); |
| 407 | + modal.style.display = "flex"; |
| 408 | + } |
| 409 | + |
| 410 | + // Function to hide the modal |
| 411 | + function hideModal() { |
| 412 | + var modal = document.getElementById("modalContainer"); |
| 413 | + modal.style.display = "none"; |
| 414 | + } |
| 415 | + |
| 416 | + // Function to convert dataURI to blob |
| 417 | + function dataURItoBlob(dataURI) { |
| 418 | + // ... Your dataURItoBlob function ... |
| 419 | + } |
| 420 | + |
| 421 | + // Function to upload image and display it |
| 422 | + function uploadImage() { |
| 423 | + // ... Your previous uploadImage function ... |
| 424 | + |
| 425 | + // Display the image below the textarea |
| 426 | + const imageElement = document.createElement('img'); |
| 427 | + imageElement.src = blobURL; |
| 428 | + imageElement.style.maxWidth = '100%'; |
| 429 | + imageElement.style.maxHeight = '300px'; |
| 430 | + |
| 431 | + const imageContainer = document.getElementById('imageContainer'); |
| 432 | + imageContainer.innerHTML = ''; // Clear previous image (if any) |
| 433 | + imageContainer.appendChild(imageElement); |
| 434 | + } |
| 435 | + |
| 436 | + // Event listener for file input change |
| 437 | + document.addEventListener('DOMContentLoaded', () => { |
| 438 | + const savedBlobURL = localStorage.getItem('imageBlobURL'); |
| 439 | + if (savedBlobURL) { |
| 440 | + const imageElement = document.createElement('img'); |
| 441 | + imageElement.src = savedBlobURL; |
| 442 | + imageElement.style.maxWidth = '100%'; |
| 443 | + imageElement.style.maxHeight = '300px'; |
| 444 | + |
| 445 | + const imageContainer = document.getElementById('imageContainer'); |
| 446 | + imageContainer.innerHTML = ''; |
| 447 | + imageContainer.appendChild(imageElement); |
| 448 | + } |
| 449 | + }); |
| 450 | +</script> |
| 451 | + |
326 | 452 |
|
327 | 453 |
|
328 | 454 | </body> |
329 | 455 | <script src="script.js"></script> |
330 | 456 | <script src="addTagAdder.js"></script> |
| 457 | +<script src="loadBlobImages.js"></script> |
331 | 458 | </html> |
0 commit comments