-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathesther.html
163 lines (145 loc) · 5.12 KB
/
esther.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Collaborative Poetry Worksheet</title>
const app = firebase.initializeApp(firebaseConfig);
const database = firebase.database();
<script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.10.1/firebase-database.js"></script>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: center;
flex-direction: column;
background-color: #f9f9f9;
}
.container {
display: flex;
flex-direction: row;
width: 80%;
margin-top: 20px;
}
.comments {
flex: 1;
padding: 10px;
border: 1px solid #ccc;
background-color: #fff;
overflow-y: auto;
height: 600px;
}
.poem {
flex: 2;
padding: 20px;
text-align: center;
border: 2px solid #000;
background-color: #fff;
height: 600px;
overflow-y: auto;
position: relative;
direction: rtl;
}
.poem span {
background-color: yellow;
cursor: pointer;
}
.input-section {
margin: 20px;
width: 80%;
}
.input-section textarea, .input-section input {
width: 100%;
margin: 5px 0;
padding: 10px;
font-size: 1rem;
}
.input-section button {
padding: 10px;
background-color: #007BFF;
color: white;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Collaborative Poetry Worksheet</h1>
<div class="container">
<div class="comments" id="left-comments">
<!-- Left comments appear here -->
</div>
<div class="poem" id="poem">
<p>
שושנים הן <span data-word="red">אדומות</span>,<br>
סיגליות הן <span data-word="blue">כחולות</span>,<br>
סוכר הוא <span data-word="sweet">מתוק</span>,<br>
וכך גם <span data-word="you">אתה</span>.
</p>
</div>
<div class="comments" id="right-comments">
<!-- Right comments appear here -->
</div>
</div>
<div class="input-section">
<textarea id="comment" rows="4" placeholder="הוסף את ההערה שלך כאן..."></textarea>
<input type="text" id="highlight" placeholder="המילה או הביטוי עליו אתה מעיר">
<button onclick="addComment()">הוסף הערה</button>
</div>
<script>
// Firebase configuration
const firebaseConfig = {
apiKey: "AIzaSyC7-uVT7c1nFdw9jfS_e2jsMO8y1RsnPGU",
authDomain: "esther-poetry-talmud.firebaseapp.com",
databaseURL: "https://esther-poetry-talmud-default-rtdb.firebaseio.com",
projectId: "esther-poetry-talmud",
storageBucket: "esther-poetry-talmud.firebasestorage.app",
messagingSenderId: "400649726147",
appId: "1:400649726147:web:74979f39624f5d99175a76"
};
// Initialize Firebase
const app = firebase.initializeApp(firebaseConfig);
const database = firebase.database();
const commentsRef = database.ref("comments");
// Fetch existing comments and listen for new ones
commentsRef.on("value", (snapshot) => {
const data = snapshot.val();
renderComments(data);
});
function addComment() {
const commentText = document.getElementById("comment").value;
const highlight = document.getElementById("highlight").value;
if (!commentText || !highlight) {
alert("אנא מלא את כל השדות.");
return;
}
const comment = {
text: commentText,
highlight: highlight
};
commentsRef.push(comment);
document.getElementById("comment").value = "";
document.getElementById("highlight").value = "";
}
function renderComments(data) {
const leftContainer = document.getElementById("left-comments");
const rightContainer = document.getElementById("right-comments");
leftContainer.innerHTML = "";
rightContainer.innerHTML = "";
if (data) {
const comments = Object.values(data);
comments.forEach((comment, index) => {
const container = index % 2 === 0 ? leftContainer : rightContainer;
const div = document.createElement("div");
div.innerHTML = `<strong>${comment.highlight}:</strong> ${comment.text}`;
container.appendChild(div);
});
}
}
</script>
</body>
</html>