summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--epg_events.cpp10
-rw-r--r--live/js/live/pageenhance.js28
-rw-r--r--pages/edit_timer.ecpp23
-rw-r--r--pages/timers.ecpp10
-rw-r--r--timers.cpp18
-rw-r--r--timers.h11
-rw-r--r--tools.cpp18
-rw-r--r--tools.h7
8 files changed, 107 insertions, 18 deletions
diff --git a/epg_events.cpp b/epg_events.cpp
index 7d22cdf..962fcfc 100644
--- a/epg_events.cpp
+++ b/epg_events.cpp
@@ -214,8 +214,9 @@ namespace vdrlive
string channelId(chanId.ToString());
string eventId("event_");
- replace(channelId.begin(), channelId.end(), '.', 'p');
- replace(channelId.begin(), channelId.end(), '-', 'm');
+ channelId = vdrlive::EncodeDomId(channelId, ".-", "pm");
+ // replace(channelId.begin(), channelId.end(), '.', 'p');
+ // replace(channelId.begin(), channelId.end(), '-', 'm');
eventId += channelId;
eventId += '_';
@@ -230,8 +231,9 @@ namespace vdrlive
size_t delimPos = epgid.find_last_of('_');
string cIdStr = epgid.substr(eventStr.length(), delimPos - eventStr.length());
- replace(cIdStr.begin(), cIdStr.end(), 'm', '-');
- replace(cIdStr.begin(), cIdStr.end(), 'p', '.');
+ cIdStr = vdrlive::DecodeDomId(cIdStr, "mp", "-.");
+ // replace(cIdStr.begin(), cIdStr.end(), 'm', '-');
+ // replace(cIdStr.begin(), cIdStr.end(), 'p', '.');
string const eIdStr = epgid.substr(delimPos+1);
diff --git a/live/js/live/pageenhance.js b/live/js/live/pageenhance.js
index d98b374..5ca90c0 100644
--- a/live/js/live/pageenhance.js
+++ b/live/js/live/pageenhance.js
@@ -16,6 +16,7 @@ var PageEnhance = new Class({
vlcWinOptions: {
size: { width: 720, height: 640 }
},
+ editTimerSelector: 'a[href^="edit_timer.html?timerid"]',
hintTipSelector: '*[title]',
hintClassName: 'hint',
infoWinOptions: {
@@ -46,6 +47,9 @@ var PageEnhance = new Class({
$$(this.options.actionLinkSelector).each(this.vdrRequest.bind(this));
$$(this.options.vlcLinkSelector).each(this.vlcRequest.bind(this));
$$(this.options.datePickerSelector).each(this.datePicker.bind(this));
+ // the following line activates timer editing in popup window.
+ // but it does not yet work like expected. So we leave it deactivated currently.
+ // $$(this.options.editTimerSelector).each(this.editTimer.bind(this));
},
// actions applied on mouse down.
@@ -85,6 +89,30 @@ var PageEnhance = new Class({
}
},
+ // Edit Timer Popup function. Apply to all elements that should
+ // pop up a timer edit windows based on InfoWin window.
+ editTimer: function(el){
+ var href = el.href;
+ var timerid = $pick(href, "");
+ if (timerid != "") {
+ var extractId = /timerid=(.+)/;
+ var found = extractId.exec(timerid);
+ if ($defined(found) && found.length > 1) {
+ timerid = found[1];
+ el.addEvent('click', function(event){
+ var event = new Event(event);
+ new InfoWin.Ajax(timerid, href, $merge(this.options.infoWinOptions, {
+ bodyselect: '',
+ modal: true,
+ onDomExtend: this.domExtend.bind(this)
+ })).show(event);
+ event.stop();
+ return false;
+ }.bind(this));
+ }
+ }
+ },
+
// function that requests an action from the server vdr.
vdrRequest: function(el){
el.addEvent('click', function(event, element){
diff --git a/pages/edit_timer.ecpp b/pages/edit_timer.ecpp
index 7b92551..f1c6ca2 100644
--- a/pages/edit_timer.ecpp
+++ b/pages/edit_timer.ecpp
@@ -20,6 +20,7 @@ using namespace vdrlive;
// input parameters
string timerid;
string epgid;
+ string async;
// form parameters
tChannelID channel;
bool active = true;
@@ -53,6 +54,8 @@ cTimer* timer;
<%cpp>
if (!logged_in && LiveSetup().UseAuth()) return reply.redirect("login.html");
+ bool ajaxReq = !async.empty() && (lexical_cast<int>(async) != 0);
+
tChannelID channelid = tChannelID();
tEventID eventid = tEventID();
@@ -62,7 +65,9 @@ cTimer* timer;
timer = 0;
if ( !timerid.empty() ) {
- timer = timers.GetByTimerId( timerid );
+ string tId = SortedTimers::DecodeDomId(timerid);
+ dsyslog("DEBUG: TIMER: tId = %s", tId.c_str());
+ timer = timers.GetByTimerId(tId);
if ( timer == 0 )
throw HtmlError( tr("Couldn't find timer. Maybe you mistyped your request?") );
}
@@ -134,19 +139,31 @@ cTimer* timer;
<html>
<head>
<title>VDR Live - <$ timer ? tr("Edit timer") : tr("New timer") $></title>
+<%cpp>
+ if (!ajaxReq) {
+</%cpp>
<& pageelems.stylesheets &>
<& pageelems.ajax_js &>
+<%cpp>
+ }
+</%cpp>
</head>
<body>
+<%cpp>
+ if (!ajaxReq) {
+</%cpp>
<& pageelems.logo &>
<& menu active=("timers") &>
+<%cpp>
+ }
+</%cpp>
<div class="inhalt">
- <form method="post" name="edit_timer" action="edit_timer.ecpp">
+ <form method="post" name="edit_timer" id="<$ timerid $>" action="edit_timer.ecpp">
<input type="hidden" name="timerid" value="<$ timerid $>"/>
<input type="hidden" name="aux" value="<$ aux $>"/>
<table class="formular" cellpadding="0" cellspacing="0">
<tr class="head">
- <td class="toprow leftcol rightcol" colspan="2"><div class="boxheader"><div><div><$ timer ? tr("Edit timer") : tr("New timer") $></div></div></div></td>
+ <td class="toprow leftcol rightcol" colspan="2"><div class="boxheader"><div><div class="caption"><$ timer ? tr("Edit timer") : tr("New timer") $></div></div></div></td>
</tr>
<tr>
diff --git a/pages/timers.ecpp b/pages/timers.ecpp
index 9af9425..654484f 100644
--- a/pages/timers.ecpp
+++ b/pages/timers.ecpp
@@ -38,7 +38,9 @@ static const size_t maximumDescriptionLength = 300;
timer = 0;
if ( !timerid.empty() ) {
- timer = timers.GetByTimerId( timerid );
+ string tId = SortedTimers::DecodeDomId(timerid);
+ dsyslog("DEBUG: TIMER: tId = %s", tId.c_str());
+ timer = timers.GetByTimerId(tId);
if ( timer == 0 )
throw HtmlError( tr("Couldn't find timer. Maybe you mistyped your request?") );
if (action == "delete") {
@@ -143,9 +145,9 @@ static const size_t maximumDescriptionLength = 300;
% }
><$ timer->File() $></a></div>
</td>
- <td class="action <? bottom ? "bottomrow" ?>"><a href="timers.html?timerid=<$ timers.GetTimerId(*timer) $>&action=toggle"><img src="<$ LiveSetup().GetThemedLink("img", (timer->Flags() & tfActive) ? "active.png" : "inactive.png") $>" alt="" <& tooltip.hint text=(tr("Toggle timer active/inactive")) &>></img></a></td>
- <td class="action <? bottom ? "bottomrow" ?>"><a href="edit_timer.html?timerid=<$ timers.GetTimerId(*timer) $>"><img src="<$ LiveSetup().GetThemedLink("img", "edit.png") $>" alt="" <& tooltip.hint text=(tr("Edit timer")) &>></img></a></td>
- <td class="action rightcol <? bottom ? "bottomrow" ?>"><a href="timers.html?timerid=<$ timers.GetTimerId(*timer) $>&action=delete"><img src="<$ LiveSetup().GetThemedLink("img", "del.png") $>" alt="" <& tooltip.hint text=(tr("Delete timer")) &>></img></a></td>
+ <td class="action <? bottom ? "bottomrow" ?>"><a href="timers.html?timerid=<$ SortedTimers::EncodeDomId(timers.GetTimerId(*timer)) $>&action=toggle"><img src="<$ LiveSetup().GetThemedLink("img", (timer->Flags() & tfActive) ? "active.png" : "inactive.png") $>" alt="" <& tooltip.hint text=(tr("Toggle timer active/inactive")) &>></img></a></td>
+ <td class="action <? bottom ? "bottomrow" ?>"><a href="edit_timer.html?timerid=<$ SortedTimers::EncodeDomId(timers.GetTimerId(*timer)) $>"><img src="<$ LiveSetup().GetThemedLink("img", "edit.png") $>" alt="" <& tooltip.hint text=(tr("Edit timer")) &>></img></a></td>
+ <td class="action rightcol <? bottom ? "bottomrow" ?>"><a href="timers.html?timerid=<$ SortedTimers::EncodeDomId(timers.GetTimerId(*timer)) $>&action=delete"><img src="<$ LiveSetup().GetThemedLink("img", "del.png") $>" alt="" <& tooltip.hint text=(tr("Delete timer")) &>></img></a></td>
</tr>
<%cpp>
}
diff --git a/timers.cpp b/timers.cpp
index b5a82ed..4ceb60d 100644
--- a/timers.cpp
+++ b/timers.cpp
@@ -65,6 +65,24 @@ namespace vdrlive {
return 0;
}
+
+ string SortedTimers::EncodeDomId(string const& timerid)
+ {
+ string tId("timer_");
+ tId += vdrlive::EncodeDomId(timerid, ".-:", "pmc");
+ return tId;
+ }
+
+ string SortedTimers::DecodeDomId(string const &timerDomId)
+ {
+ string const timerStr("timer_");
+
+ string tId = timerDomId.substr(timerStr.length());
+
+ return vdrlive::DecodeDomId(tId, "pmc", ".-:");
+ }
+
+
void SortedTimers::ReloadTimers( bool initial )
{
dsyslog("live reloading timers");
diff --git a/timers.h b/timers.h
index 9bd7e6e..4ad8a7f 100644
--- a/timers.h
+++ b/timers.h
@@ -16,10 +16,15 @@ namespace vdrlive {
friend class TimerManager;
public:
- std::string GetTimerId( cTimer const& timer );
- cTimer* GetByTimerId( std::string const& timerid );
+ static std::string GetTimerId(cTimer const& timer);
+ cTimer* GetByTimerId(std::string const& timerid);
+
+ // en- or decodes a timer into an id usable for DOM Ids.
+ static std::string EncodeDomId(std::string const& timerid);
+ static std::string DecodeDomId(std::string const &timerDomId);
+
+ bool Modified() { return Timers.Modified(m_state); }
- bool Modified() { return Timers.Modified( m_state ); }
static std::string GetTimerDays(cTimer const& timer);
static std::string GetTimerInfo(cTimer const& timer);
diff --git a/tools.cpp b/tools.cpp
index 5fee00b..8b6006e 100644
--- a/tools.cpp
+++ b/tools.cpp
@@ -293,5 +293,23 @@ namespace vdrlive {
return FormatDateTime(cformat.c_str(), date);
}
+ std::string EncodeDomId(std::string const & toEncode, char const * from, char const * to)
+ {
+ std::string encoded = toEncode;
+ for (; *from && *to; from++, to++) {
+ replace(encoded.begin(), encoded.end(), *from, *to);
+ }
+ return encoded;
+ }
+
+ std::string DecodeDomId(std::string const & toDecode, char const * from, char const * to)
+ {
+ std::string decoded = toDecode;
+ for (; *from && *to; from++, to++) {
+ replace(decoded.begin(), decoded.end(), *from, *to);
+ }
+ return decoded;
+ }
+
} // namespace vdrlive
diff --git a/tools.h b/tools.h
index 23142da..f4020ac 100644
--- a/tools.h
+++ b/tools.h
@@ -33,7 +33,6 @@ namespace vdrlive {
std::string StringRepeat(int times, const std::string& input);
std::string StringWordTruncate(const std::string& input, size_t maxLen, bool& truncated);
-
inline std::string StringWordTruncate(const std::string& input, size_t maxLen) { bool dummy; return StringWordTruncate(input, maxLen, dummy); }
std::string StringEscapeAndBreak( std::string const& input );
@@ -41,13 +40,11 @@ namespace vdrlive {
std::string StringFormatBreak(std::string const& input);
std::string StringTrim(const std::string& str);
-
std::string ZeroPad(int number);
std::string MD5Hash(std::string const& str);
time_t GetTimeT(std::string timestring);
-
std::string ExpandTimeString(std::string timestring);
std::string StringUrlEncode( std::string const& input );
@@ -55,9 +52,11 @@ namespace vdrlive {
std::string GetXMLValue( std::string const& xml, std::string const& element );
time_t GetDateFromDatePicker(std::string const& datestring, std::string const& format);
-
std::string DatePickerToC(time_t date, std::string const& format);
+ std::string EncodeDomId(std::string const & toEncode, char const * from = ".-:", char const * to = "pmc");
+ std::string DecodeDomId(std::string const & toDecode, char const * from = "pmc", char const * to = ".-:");
+
struct bad_lexical_cast: std::runtime_error
{
bad_lexical_cast(): std::runtime_error( "bad lexical cast" ) {}