web/polemicaltimeline.php
changeset 1436 b3d23c1b791e
parent 1366 2cebaaf18c54
child 1443 66ca0c90c47c
--- a/web/polemicaltimeline.php	Fri Sep 14 15:44:27 2018 +0200
+++ b/web/polemicaltimeline.php	Wed Sep 19 18:09:27 2018 +0200
@@ -149,23 +149,30 @@
             {
                 type: "Polemic",
                 max_elements: 60,
-<?php if ($protocol_level < 3): ?>
+<?php if ($protocol_level < 4): ?>
                 polemics: []
 <?php elseif (isset($annotations)): ?>
                 polemics : [
 <?php foreach ($annotations as $annot_key => $annot_def): ?>
-    <?php if($annot_key == 'default') { continue; } ?>
+    <?php 
+    $hVal = (isset($annot_def['colors'])&&isset($annot_def['colors']['h']))?floatval($annot_def['colors']['h']):0.17;
+    $hVal = ($hVal<1)?floor($hVal*360.0):$hVal;
+    $sVal = (isset($annot_def['colors'])&&isset($annot_def['colors']['s']))?floatval($annot_def['colors']['s']):1.0;
+
+    $polemicColor = isset($annot_def['polemic_color'])?$annot_def['polemic_color']:rgb2hex(hsl2Rgb($hVal, $sVal, 0.5));
+
+    if($annot_key == 'default') { continue; } ?>
                     {
                         "name" : "<?php echo $annot_def['polemic_cat']; ?>",
                         "keywords" : <?php echo json_encode($annot_def['polemic_keywords']); ?>,
-                        "color" : "<?php echo $annot_def['polemic_color'];?>"
+                        "color" : "<?php echo $polemicColor; ?>"
                     },
 <?php endforeach; ?>
                 ]
 <?php endif; ?>
             },
 <?php endif; ?>
-<?php if ($protocol_level > 1): ?>
+<?php if ($protocol_level > 1 || isset($annotations)): ?>
             {
                 type: "MultiSegments",
                 //annotation_type: "chap"