]> git.ipfire.org Git - thirdparty/tvheadend.git/commitdiff
Add channel / 3even view
authorAndreas Öman <andreas@lonelycoder.com>
Thu, 24 Apr 2008 05:38:33 +0000 (05:38 +0000)
committerAndreas Öman <andreas@lonelycoder.com>
Thu, 24 Apr 2008 05:38:33 +0000 (05:38 +0000)
ajaxui/ajaxui.css
ajaxui/ajaxui_channels.c

index 7490bdeef69e9ef63122bf28c7431e5d560bd27c..ee6d494f6267b38f389b8cdc6ba63ec2f2f163be 100644 (file)
@@ -54,6 +54,22 @@ img { border: 0; }
  * Misc classes
  */
 
+.event3 {
+ height: 42px
+
+}
+
+.compact {
+ float: left;
+ height: 100%;
+ overflow: hidden;
+}
+
+.fullrow {
+ overflow: auto;
+ width: 100%;
+ height: 14px;
+}
 
 .cell_100_center {
  margin-top: 2px;
index b37434f3ed904c693906e35a0e9a7b8ae0fe0680..bec126ea57429860bc9054867fd28a972868c606 100644 (file)
@@ -27,7 +27,7 @@
 #include "http.h"
 #include "ajaxui.h"
 #include "channels.h"
-
+#include "epg.h"
 
 static void
 ajax_channelgroupmenu_content(tcp_queue_t *tq, int current)
@@ -72,7 +72,49 @@ ajax_channelgroup_menu(http_connection_t *hc, http_reply_t *hr,
 }
 
 
+static void
+ajax_output_event(tcp_queue_t *tq, event_t *e, int flags, int color)
+{
+  struct tm a, b;
+  time_t stop;
+
+  tcp_qprintf(tq, "<div class=\"fullrow\"%s>",
+             color ? "style=\"background: #fff\" " : "");
+
+  localtime_r(&e->e_start, &a);
+  stop = e->e_start + e->e_duration;
+  localtime_r(&stop, &b);
+  
+  tcp_qprintf(tq, 
+             "<div class=\"compact\" style=\"width: 35%%\">"
+             "%02d:%02d-%02d:%02d"
+             "</div>",
+             a.tm_hour, a.tm_min, b.tm_hour, b.tm_min);
+  tcp_qprintf(tq, 
+             "<div class=\"compact\" style=\"width: 65%%\">"
+             "%s"
+             "</div>",
+             e->e_title);
+    
+  tcp_qprintf(tq, "</div>");
+}
+
 
+static void
+ajax_list_events(tcp_queue_t *tq, th_channel_t *ch, int lines)
+{
+  event_t *e;
+  int i;
+
+
+  e = epg_event_find_current_or_upcoming(ch);
+
+  for(i = 0; i < 3 && e != NULL; i++) {
+    ajax_output_event(tq, e, 0, !(i & 1));
+    e = TAILQ_NEXT(e, e_link);
+  }
+}
 
 
 /*
@@ -84,26 +126,51 @@ int
 ajax_channel_tab(http_connection_t *hc, http_reply_t *hr,
                 const char *remain, void *opaque)
 {
-  //  tcp_queue_t *tq = &hr->hr_tq;
+  
+  tcp_queue_t *tq = &hr->hr_tq;
   th_channel_t *ch;
   th_channel_group_t *tcg;
+  char dispname[20];
 
-  if(remain == NULL)
-    return HTTP_STATUS_NOT_FOUND;
-  
-  if((tcg = channel_group_by_tag(atoi(remain))) == NULL)
+  if(remain == NULL || (tcg = channel_group_by_tag(atoi(remain))) == NULL)
     return HTTP_STATUS_NOT_FOUND;
 
   TAILQ_FOREACH(ch, &tcg->tcg_channels, ch_group_link) {
     if(LIST_FIRST(&ch->ch_transports) == NULL)
       continue;
 
-#if 0
-    ajax_box_begin(&tq, "x", ch->ch_name);
+    epg_lock();
+
+    tcp_qprintf(tq, "<div style=\"float:left; width: 25%%\">");
+
+    snprintf(dispname, sizeof(dispname), "%s", ch->ch_name);
+    strcpy(dispname + sizeof(dispname) - 4, "...");
+
+    ajax_box_begin(tq, AJAX_BOX_SIDEBOX, NULL, NULL, dispname);
 
-    tcp_qprintf(&tq, "<div style=\"height: 100px\"></div>");
-    ajax_sidebox_end(&tq);
-#endif
+    tcp_qprintf(tq, 
+               "<div style=\"width: 100%%; overflow: hidden; height:36px\">");
+
+    tcp_qprintf(tq, 
+               "<div style=\"float: left; height:32px; width:32px; "
+               "margin: 2px\">");
+
+    if(ch->ch_icon != NULL) {
+      tcp_qprintf(tq, "<img src=\"%s\" style=\"width:32px\">",
+                 ch->ch_icon);
+    }
+
+    tcp_qprintf(tq, "</div>");
+    tcp_qprintf(tq, "</div>");
+
+
+    tcp_qprintf(tq, "<div id=\"events%d\" style=\"height:42px\">", ch->ch_tag);
+    ajax_list_events(tq, ch, 3);
+    tcp_qprintf(tq, "</div>");
+
+    ajax_box_end(tq, AJAX_BOX_SIDEBOX);
+    tcp_qprintf(tq, "</div>");
+    epg_unlock();
   }
 
   http_output_html(hc, hr);
@@ -113,6 +180,7 @@ ajax_channel_tab(http_connection_t *hc, http_reply_t *hr,
 
 
 
+
 /*
  * Channel (group)s AJAX page
  *