aboutme.astro 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <script is:inline>
  2. function closeWindow() {
  3. document.getElementById("aboutme").style.display = "none";
  4. }
  5. function raiseUp() {
  6. let els = document.getElementsByClassName("window");
  7. let elArray = Array.from(els);
  8. // find the highest z-index
  9. let highestIndex = 0;
  10. for (let element in elArray) {
  11. let zindex = parseInt(elArray[element].style.zIndex);
  12. if (zindex > highestIndex) {
  13. highestIndex = zindex;
  14. }
  15. }
  16. // set the highest z-index plus one
  17. document.getElementById("aboutme").style.zIndex = (
  18. highestIndex + 1
  19. ).toString();
  20. }
  21. </script>
  22. <div
  23. id="aboutme"
  24. class="window"
  25. style="width: 70%; height: 45%; position: absolute; left: 15%; top: 22%; display: none;"
  26. onclick="raiseUp()"
  27. >
  28. <div id="aboutmeheader" class="title-bar">
  29. <div class="title-bar-text">About Me</div>
  30. <div class="title-bar-controls">
  31. <button onclick="closeWindow()" aria-label="Minimize"></button>
  32. <button onclick="closeWindow()" aria-label="Close"></button>
  33. </div>
  34. </div>
  35. <div class="window-body">
  36. <div class="field-row-stacked">
  37. <!-- prettier-ignore -->
  38. <textarea
  39. readonly
  40. id="text20"
  41. style="font-size: 25px; resize: none; padding: 10px; height: 37vh;"
  42. >I'm Simon, a self taught programmer
  43. My programming skills include proficiency in Javascript, Typescript, Html, Css My
  44. Web Framework knowlage includes Sveltekit, React, Astro
  45. Although not entirely proficient, I also write in Python and Golang from time to time
  46. </textarea>
  47. </div>
  48. </div>
  49. </div>
  50. <script is:inline>
  51. dragElement(document.getElementById("aboutme"));
  52. function dragElement(elmnt) {
  53. var pos1 = 0,
  54. pos2 = 0,
  55. pos3 = 0,
  56. pos4 = 0;
  57. if (document.getElementById(elmnt.id + "header")) {
  58. // If present, the header is where you move the DIV from:
  59. document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
  60. document.getElementById(elmnt.id + "header").ontouchstart = dragMouseDown;
  61. } else {
  62. // Otherwise, move the DIV from anywhere inside the DIV:
  63. elmnt.onmousedown = dragMouseDown;
  64. elmnt.ontouchstart = dragMouseDown;
  65. }
  66. function dragMouseDown(e) {
  67. // e.preventDefault();
  68. raiseUp();
  69. // Get the initial touch point for touch events
  70. if (e.type == "touchstart") {
  71. pos3 = e.touches[0].clientX;
  72. pos4 = e.touches[0].clientY;
  73. } else {
  74. pos3 = e.clientX;
  75. pos4 = e.clientY;
  76. }
  77. document.onmouseup = closeDragElement;
  78. document.ontouchend = closeDragElement;
  79. document.onmousemove = elementDrag;
  80. document.ontouchmove = elementDrag;
  81. }
  82. function elementDrag(e) {
  83. // e.preventDefault();
  84. if (e.type == "touchmove") {
  85. // Calculate the new cursor position for touch
  86. pos1 = pos3 - e.touches[0].clientX;
  87. pos2 = pos4 - e.touches[0].clientY;
  88. pos3 = e.touches[0].clientX;
  89. pos4 = e.touches[0].clientY;
  90. } else {
  91. // Calculate the new cursor position for mouse
  92. pos1 = pos3 - e.clientX;
  93. pos2 = pos4 - e.clientY;
  94. pos3 = e.clientX;
  95. pos4 = e.clientY;
  96. }
  97. // Set the element's new position
  98. elmnt.style.top = elmnt.offsetTop - pos2 + "px";
  99. elmnt.style.left = elmnt.offsetLeft - pos1 + "px";
  100. }
  101. function closeDragElement() {
  102. // Stop moving when mouse button or touch is released
  103. document.onmouseup = null;
  104. document.ontouchend = null;
  105. document.onmousemove = null;
  106. document.ontouchmove = null;
  107. }
  108. }
  109. </script>