youtube iframe support beginnings
This commit is contained in:
+30
-1
@@ -537,7 +537,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
todo:
|
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>
|
</body>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@@ -681,8 +682,13 @@
|
|||||||
this.containerSettings.zIndex = numberOfImageContainers + numberOfTextContainers;
|
this.containerSettings.zIndex = numberOfImageContainers + numberOfTextContainers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (imageUrl.includes("youtube.com")) {
|
||||||
|
this.initializeYoutubeContainer();
|
||||||
|
}
|
||||||
|
else {
|
||||||
this.initializeImageContainer();
|
this.initializeImageContainer();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
numberOfTextContainers++;
|
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
|
* creates text container element, loadBookmarks() and applySettings() do the rest
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user