summaryrefslogtreecommitdiff
path: root/startpage.html
diff options
context:
space:
mode:
authorSimon <vesspa0330@gmail.com>2025-07-30 22:27:28 -0400
committerSimon <vesspa0330@gmail.com>2025-07-30 22:27:28 -0400
commit88153e06a3699f7fa3fb2084993be820cf9b3a8d (patch)
tree58a546078dc83316b1fa70e0b0f200c01274aee7 /startpage.html
parent1d688b5034e6ff7a16c2e97badfb3a1b736097e3 (diff)
youtube iframe support beginnings
Diffstat (limited to 'startpage.html')
-rw-r--r--startpage.html33
1 files changed, 31 insertions, 2 deletions
diff --git a/startpage.html b/startpage.html
index d549d11..b12a6f6 100644
--- a/startpage.html
+++ b/startpage.html
@@ -537,7 +537,8 @@
</div>
</div>
todo:
- <br />also change add image to "add media" and add youtube iframe support
+ <br />add youtube iframe support
+ <br />rename stuff. containerSettings -> container | better function names | imageUrl -> mediaUrl | etc.
</body>
<script>
@@ -681,7 +682,12 @@
this.containerSettings.zIndex = numberOfImageContainers + numberOfTextContainers;
}
- this.initializeImageContainer();
+ if (imageUrl.includes("youtube.com")) {
+ this.initializeYoutubeContainer();
+ }
+ else {
+ this.initializeImageContainer();
+ }
}
else {
numberOfTextContainers++;
@@ -741,6 +747,29 @@
);
}
+ initializeYoutubeContainer() {
+ let link = this.imageUrl;
+
+ let videoId = link.slice(link.indexOf("v=")+2, link.length);
+ if (videoId.includes("&")) {
+ videoId = videoId.slice(0, videoId.indexOf("&"));
+ }
+
+ let embedLink = "https://www.youtube.com/embed/" + videoId;
+
+ document.body.insertAdjacentHTML(
+ "beforeend",
+ `
+ <iframe
+ class="movable userImage"
+ id="${this.id}"
+ style="z-index: ${numberOfImageContainers + numberOfTextContainers}; padding-top: 2rem;"
+ src="${embedLink}"
+ />
+ `
+ );
+ }
+
/**
* creates text container element, loadBookmarks() and applySettings() do the rest
*/