aboutsummaryrefslogtreecommitdiff
path: root/list.php
diff options
context:
space:
mode:
authorCamil Staps2020-02-03 10:22:56 +0100
committerCamil Staps2020-02-03 10:22:56 +0100
commit7dd04a84ab530ef572df3b0df4fa444271f78c7e (patch)
tree7b9be02b61277aeb910a3a0bb69eb32e2141b1a8 /list.php
parentInitial commit (diff)
Add ability to see description on list.php
Diffstat (limited to 'list.php')
-rw-r--r--list.php29
1 files changed, 28 insertions, 1 deletions
diff --git a/list.php b/list.php
index b942fa6..90e6084 100644
--- a/list.php
+++ b/list.php
@@ -55,7 +55,7 @@ foreach ($events as $event){
echo ' to '.date ('j M',strtotime ($event['end_date']));
echo '</td>';
echo '<td>'.htmlspecialchars ($event['location']).'</td>';
- echo '<td>'.htmlspecialchars ($event['title']).'</td>';
+ echo '<td><span class="title-link" title="Click for details" onclick="expand_or_collapse(this,'.$event['id'].');">'.htmlspecialchars ($event['title']).'</span></td>';
foreach ($event['keywords'] as $i => $kw){
if (!is_null ($selected_keywords) && !in_array ($kw,$selected_keywords))
$event['keywords'][$i]='<span class="filtered-keyword">'.htmlspecialchars ($kw).'</span>';
@@ -84,6 +84,33 @@ function check_all_keywords (check)
return false;
}
+function expand_or_collapse (elem,id)
+{
+ if (elem.parentNode.childNodes.length > 1){
+ let p=elem.parentNode.childNodes[1];
+ p.style.display=p.style.display=='none' ? 'block' : 'none';
+ return;
+ }
+
+ var xhttp=new XMLHttpRequest();
+ xhttp.onreadystatechange=function(){
+ if (this.readyState!=4)
+ return;
+ if (this.status!=200){
+ window.alert ('Failed to fetch event information ('+this.status+')');
+ return;
+ }
+
+ let ev=JSON.parse (xhttp.responseText);
+ let p=document.createElement ('p');
+ p.classList.add ('description');
+ p.innerHTML=ev.description;
+ elem.parentNode.appendChild (p);
+ };
+ xhttp.open ('GET','event.php?id='+id,true);
+ xhttp.send();
+}
+
update_keywords_field();
checkboxes.map (cb => cb.onchange=update_keywords_field);
</script>