2020-03-16 01:12:45 +00:00
|
|
|
function interact(e) {
|
|
|
|
e.preventDefault();
|
|
|
|
ajaxPost(e.target);
|
2020-03-21 21:29:39 +00:00
|
|
|
var identifier = e.target.getAttribute('data-id');
|
|
|
|
var elements = document.getElementsByClassName(identifier);
|
|
|
|
for (var i = 0; i < elements.length; i++) {
|
|
|
|
if (elements[i].className.includes('hidden')) {
|
|
|
|
elements[i].className = elements[i].className.replace('hidden', '');
|
|
|
|
} else {
|
|
|
|
elements[i].className += ' hidden';
|
|
|
|
}
|
2020-03-16 01:12:45 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-03-21 23:50:49 +00:00
|
|
|
function reply(e) {
|
2020-03-16 01:12:45 +00:00
|
|
|
e.preventDefault();
|
|
|
|
ajaxPost(e.target);
|
|
|
|
// TODO: display comment
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-04-04 17:08:34 +00:00
|
|
|
function rate_stars(e) {
|
2020-04-03 23:47:47 +00:00
|
|
|
e.preventDefault();
|
|
|
|
ajaxPost(e.target);
|
2020-04-04 17:08:34 +00:00
|
|
|
rating = e.target.rating.value;
|
2020-04-03 23:47:47 +00:00
|
|
|
var stars = e.target.parentElement.getElementsByClassName('icon');
|
|
|
|
for (var i = 0; i < stars.length ; i++) {
|
2020-04-04 17:08:34 +00:00
|
|
|
stars[i].className = rating > i ? 'icon icon-star-full' : 'icon icon-star-empty';
|
2020-04-03 23:47:47 +00:00
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-03-21 23:50:49 +00:00
|
|
|
function tabChange(e) {
|
2020-09-29 18:48:03 +00:00
|
|
|
var target = e.target.parentElement.parentElement;
|
2020-03-21 23:50:49 +00:00
|
|
|
var identifier = target.getAttribute('data-id');
|
|
|
|
|
|
|
|
var tabs = target.parentElement.children;
|
|
|
|
for (i = 0; i < tabs.length; i++) {
|
|
|
|
if (tabs[i].getAttribute('data-id') == identifier) {
|
2020-09-29 18:00:54 +00:00
|
|
|
tabs[i].className += ' is-active';
|
2020-03-21 23:50:49 +00:00
|
|
|
} else {
|
2020-09-29 18:00:54 +00:00
|
|
|
tabs[i].className = tabs[i].className.replace('is-active', '');
|
2020-03-21 23:50:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
var el = document.getElementById(identifier);
|
|
|
|
}
|
|
|
|
|
2020-03-21 21:29:39 +00:00
|
|
|
function ajaxPost(form) {
|
|
|
|
fetch(form.action, {
|
|
|
|
method : "POST",
|
|
|
|
body: new FormData(form)
|
|
|
|
});
|
2020-03-15 21:15:36 +00:00
|
|
|
}
|