From 6bd91ddffe86ebeb10420f05a232f8e779eaf86d Mon Sep 17 00:00:00 2001 From: Dieter Hametner Date: Sun, 29 Jul 2007 17:41:38 +0000 Subject: - Made vdr ajax requests work also via a static page. This is for browsers that don't support javascript (e.g. PDA browsers) - Implemented for AJAX request a visual notification how requested action performed. - Adapted styles for this. - Moded images for rounded boxes (formerly tip-hint-??.png) to central image directory and renamed them according to their color. This makes them reusable in different themes. - Adapted themes to this move. --- pages/page_init.eh | 6 ++++-- pages/pageelems.ecpp | 6 +++++- pages/switch_channel.ecpp | 29 ++++++++++++++++++++++++++++- pages/whats_on.ecpp | 2 -- pages/xmlresponse.ecpp | 8 ++++++-- 5 files changed, 43 insertions(+), 8 deletions(-) (limited to 'pages') diff --git a/pages/page_init.eh b/pages/page_init.eh index d09a392..5a367df 100644 --- a/pages/page_init.eh +++ b/pages/page_init.eh @@ -1,5 +1,7 @@ -<# do not add to Makefile #> <%pre> +// do not add to Makefile +// and do not write a ecpp comment into this file. It must produce no +// html output not even a empty line. #include #include "exception.h" @@ -10,4 +12,4 @@ std::string pageTitle; try { reply.setHeader("Expires", "Mon, 26 Jul 1997 05:00:00 GMT"); tnt::Savepoint spoint( reply ); - + \ No newline at end of file diff --git a/pages/pageelems.ecpp b/pages/pageelems.ecpp index 277d84c..0507b56 100644 --- a/pages/pageelems.ecpp +++ b/pages/pageelems.ecpp @@ -153,6 +153,10 @@ int update_status(1); infoWinStrings: { loadingMsg: '<$ tr("loading data") $>', errorMsg: '<$ tr("an error occured!") $>' + }, + notifyStrings: { + successMsg: '" alt=""> <$ tr("Request succeeded!") $>', + errorMsg: '" alt=""> <$ tr("Request failed!") $>' } }); --> @@ -188,7 +192,7 @@ int update_status(1); string alt; string id; -<%cpp> { if (!id.empty()) { id="<$ id $>" <%cpp> } <& hide_element hide=(!id.empty()) &> href="javascript:LiveSimpleAjaxRequest('<$ action $>.xml', 'param', '<$ param $>');" <%cpp>if (!tip.empty()) { <& tooltip.hint text=(tip) &> <%cpp> } >" alt="<$ alt $>"> <%cpp> } +<%cpp> { if (!id.empty()) { id="<$ id $>" <%cpp> } <& hide_element hide=(!id.empty()) &> href="vdr_request/<$ action $>?param=<$ param $>" <%cpp>if (!tip.empty()) { <& tooltip.hint text=(tip) &> <%cpp> } >" alt="<$ alt $>"> <%cpp> } <# ---------------------------------------------------------------------- #> diff --git a/pages/switch_channel.ecpp b/pages/switch_channel.ecpp index 0031f4e..9b8b48b 100644 --- a/pages/switch_channel.ecpp +++ b/pages/switch_channel.ecpp @@ -4,16 +4,43 @@ #include "tasks.h" #include "tools.h" +using namespace std; using namespace vdrlive; <%args> tChannelID param; + string async; <%cpp> - reply.setContentType( "application/xml" ); + bool ajaxReq = !async.empty() && (lexical_cast(async) != 0); + string referrer; + + if (ajaxReq) { + reply.setContentType( "application/xml" ); + } + else { + referrer = request.getHeader("Referer:"); + } SwitchChannelTask task( param ); LiveTaskManager().Execute( task ); + + if (!ajaxReq) { + if (!referrer.empty()) { + return reply.redirect(referrer); + } + +Normale Seite:
+channel: <$ param $>
+result: <$ (task.Result()) $>
+error: <$ (task.Error()) $>
+Seitenende! +<%cpp> + } + else { <& xmlresponse.ajax name=("switch_channel") pname=("channel") value=(param) result=(task.Result()) error=(task.Error()) &> +<%cpp> + } + diff --git a/pages/whats_on.ecpp b/pages/whats_on.ecpp index dfba641..d724c23 100644 --- a/pages/whats_on.ecpp +++ b/pages/whats_on.ecpp @@ -21,7 +21,6 @@ type = "now"; string mode; string attime; string fixtime; - <%session scope="global"> bool logged_in(false); @@ -33,7 +32,6 @@ string current_attime; string current_fixtime; string current_displaytime; - <%include>page_init.eh <%cpp> if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html"); diff --git a/pages/xmlresponse.ecpp b/pages/xmlresponse.ecpp index 54fe088..4bca87f 100644 --- a/pages/xmlresponse.ecpp +++ b/pages/xmlresponse.ecpp @@ -3,6 +3,10 @@ #include "i18n.h" using namespace std; +using namespace vdrlive; + +string const XMLHEADER = ""; + <# ------------------------------------------------------------------------- #> @@ -15,7 +19,7 @@ using namespace std; bool result; string error; -"?> +<$$ XMLHEADER $> <$ value $> @@ -39,7 +43,7 @@ using namespace std; string prev_chan; string next_chan; - +<$$ XMLHEADER $> <$ update $> -- cgit v1.2.3