-
Notifications
You must be signed in to change notification settings - Fork 0
/
singletemplate.html
57 lines (52 loc) · 2.01 KB
/
singletemplate.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<div>
<div class="karte2" style="margin: 0px auto;background-color: [[Color]]">
<div class="dropdown dropleft" style="float:right">
##actionsmenu##
</div>
##userpicture##
<span class="" style="font-size: small"><strong>##user## </strong></span>
<div>
<br><span style="font-family: 'Trebuchet MS', Helvetica, sans-serif"></span>[[Note]]<br>
<div class="dataurlview" id="dataurlview">
<img id="whiteboardcontent" src="[[Whiteboard]]" />
</div>
<hr id="null">##comments##
</div>
</div>
<script>
window.onload = function () {
// Wähle alle div-Elemente mit der Klasse "dataurlview" aus
let dataurlviews = document.querySelectorAll(".dataurlview");
// Das imgtemplate-Element verwenden
let imgBackground = new Image();
imgBackground.onload = function () {
// Größe jedes dataurlview-Elements anpassen
dataurlviews.forEach(function (dataurlview) {
dataurlview.style.width = dataurlview.offsetWidth + "px";
dataurlview.style.height = dataurlview.offsetHeight + "px";
// Größenverhältnis des Bildes berechnen
let ratio = Math.min(
dataurlview.offsetWidth / imgBackground.width,
dataurlview.offsetHeight / imgBackground.height
);
// Neue Größe des Bildes berechnen
let newWidth = imgBackground.width * ratio;
let newHeight = imgBackground.height * ratio;
// Bild als Hintergrundbild setzen
dataurlview.style.backgroundImage = "url(" + imgBackground.src + ")";
dataurlview.style.backgroundSize = newWidth + "px " + newHeight + "px";
dataurlview.style.backgroundRepeat = "no-repeat";
dataurlview.style.backgroundPosition = "center";
});
};
imgBackground.src = imgTemplate;
};
</script>
<script>
let whiteboardcontent = document.getElementById("whiteboardcontent");
if (whiteboardcontent.src === "") {
whiteboardcontent.style.display = "none";
} else {
whiteboardcontent.style.display = "block";
}
</script>