From ed161e7fb20a697ecba070ef7db4c231d700f245 Mon Sep 17 00:00:00 2001 From: Mitja Felicijan Date: Wed, 25 Mar 2020 05:12:40 +0100 Subject: Move to my own static generator --- src/static/comments.js | 65 -------------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 src/static/comments.js (limited to 'src/static/comments.js') diff --git a/src/static/comments.js b/src/static/comments.js deleted file mode 100644 index 3f373e5..0000000 --- a/src/static/comments.js +++ /dev/null @@ -1,65 +0,0 @@ -var firebaseConfig = { - apiKey: "AIzaSyD3E0XtiUJI4-JIxcIPZziNLGVaTdojz20", - authDomain: "mitja-felicijan-blog.firebaseapp.com", - databaseURL: "https://mitja-felicijan-blog.firebaseio.com", - projectId: "mitja-felicijan-blog", - storageBucket: "mitja-felicijan-blog.appspot.com", - messagingSenderId: "41650892882", - appId: "1:41650892882:web:b308f0a9c47198bdf7ef8b" -}; -firebase.initializeApp(firebaseConfig); - -var database = firebase.database(); -var docPath = window.location.hostname.replace('.', '-') + '/comments' + window.location.pathname.replace('.html', ''); -var submit = document.querySelector('#submit'); -var comments = document.querySelector('.comments ul'); -var textName = document.querySelector('#name'); -var textComment = document.querySelector('#comment'); -var ref = firebase.database().ref(docPath); - -function encodeHTML(s) { - return s.replace(/&/g, '&').replace(/ -
${encodeHTML(item.name)} - ${encodeHTML(item.published)}
-
${encodeHTML(item.comment)}
- `; - comments.innerHTML += liItem; - }); - - }, function (errorObject) { - console.log("The read failed: " + errorObject.code); - }); - - submit.addEventListener('click', function (evt) { - if (textName.value && textComment.value) { - submit.disabled = true; - firebase.database().ref(docPath + '/' + Date.now()).set({ - name: textName.value, - comment: textComment.value, - published: new Date().toISOString().slice(0, 16).replace('T', ' '), - }, function (error) { - if (error) { - alert('Data could not be saved.' + error); - } else { - textName.value = ''; - textComment.value = ''; - submit.disabled = false; - } - }); - } - }); -} -- cgit v1.2.3