Skip to content

Commit

Permalink
perf 2
Browse files Browse the repository at this point in the history
  • Loading branch information
Markus Ehrnsperger committed Sep 28, 2022
1 parent 01b6504 commit e189038
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 35 deletions.
19 changes: 10 additions & 9 deletions pages/recordings.ecpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ function IMDB(im_db, name) {
}
// [0] : Level
// [1] : ID (prefix "recording_" removed !!!)
// [2] : Archived
// [2] : ArchiveDescr()
// [3] : image.path (nach "/tvscraper/")
// [4] : "pt" if m_s_image.width <= m_s_image.height, otherwise= ""
// [5] : title (scraper)
Expand All @@ -161,8 +161,11 @@ function Recordings(data) {
'<li class="recording"><div class="recording_item"><div class="recording_imgs">')
if (obj[0] > 0) document.write(
'<img src="img/transparent.png" width="' + String(16 * obj[0]) + 'px" height="16px" />')
if (obj[2] != "") document.write(obj[2])
else {
if (obj[2] != "") {
document.write('<img src=\"<$LiveSetup().GetThemedLinkPrefixImg()$>on_dvd.png\" alt=\"on_dvd\" title=\"')
document.write(obj[2])
document.write('/>')
} else {
document.write('<input type="checkbox" name="deletions<$TNT_ARRAY$>" value="recording_');
document.write(obj[1])
document.write('" />')
Expand Down Expand Up @@ -193,9 +196,8 @@ function Recordings(data) {
document.write('<br/>')
document.write(obj[8])
}
document.write('\"')
}
document.write('/> </a>')
document.write('\"/> </a>')
}
// end if (!LiveSetup().GetTvscraperImageDir().empty() )
document.write('</div><div class=\"recording_spec\"><div class=\"recording_day\">')
Expand Down Expand Up @@ -233,8 +235,7 @@ function Recordings(data) {
document.write(obj[14])
if (obj[14] == "") document.write('&nbsp;')
document.write('</span></a></div></div><div class=\"recording_actions\">')
//function RecordingAction(id, A, Img, Title, argList)
if (obj[17] != "") {
if (obj[2] == "") {
RecordingAction(obj[1], "vdr_request/play_recording?param=", "play.png", "<$tr("play this recording")$>", obj[17])
RecordingAction(obj[1], "playlist.m3u?recid=", "playlist.png", "<$tr("Stream this recording into media player.")$>", obj[17])
IMDB(obj[18], obj[15])
Expand All @@ -245,9 +246,9 @@ function Recordings(data) {
IMDB(obj[18], obj[15])
}
document.write('</div>')
if (obj[19] != "") {
if (obj[2] != "") {
document.write('<div class=\"recording_arch\">')
document.write(obj[19])
document.write(obj[2])
document.write('</div>')
}
document.write('</div></li>')
Expand Down
40 changes: 17 additions & 23 deletions recman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,19 +672,26 @@ namespace vdrlive {
AppendHtmlEscaped(target, tr("Click to view details.") );
}

// Spielfilm Thailand / Deutschland / Großbritannien 2015 (Rak ti Khon Kaen)
#define MAX_LEN_ST 70
void RecordingsItemRec::AppendShortTextOrDesc(std::string &target) const
{
const char *text = ShortText();
if (!text || Name() == text ) text = RecInfo()->Description();
// Spielfilm Italien / Großbritannien / USA 1965 (Doctor Zhivago)
if (!text) return;
if ((int)strlen(text) < 70)
int len = strlen(text);
int lb = len;
for (const char *s = text; *s; s++) if (*s == 10 || *s == 13) { lb = s-text; break;}
if (len < MAX_LEN_ST && lb == len)
AppendHtmlEscapedAndCorrectNonUTF8(target, text);
else {
const char *end = text + 69;
for (; *end && *end != ' '; end++);
AppendHtmlEscapedAndCorrectNonUTF8(target, std::string(text, end-text).c_str() );
else if (lb < MAX_LEN_ST) {
AppendHtmlEscapedAndCorrectNonUTF8(target, text, text + lb);
target.append("...");
} else {
const char *end = text + MAX_LEN_ST;
for (; *end && *end != ' ' && *end != 10 && *end != 13; end++);
AppendHtmlEscapedAndCorrectNonUTF8(target, text, end);
if (*end) target.append("...");
}
}
const char *RecordingsItemRec::RecordingErrorsIcon() const
Expand Down Expand Up @@ -788,14 +795,8 @@ namespace vdrlive {
// [1] : ID
target.append(Id().c_str() + 10);
target.append("\",\"");
// [2] : Archived
if (IsArchived() ) {
target.append("<img src=\"");
target.append(LiveSetup().GetThemedLinkPrefixImg() );
target.append("on_dvd.png\" alt=\"on_dvd\" title=\"");
AppendHtmlEscaped(target, ArchiveDescr().c_str() );
target.append("/>");
}
// [2] : ArchiveDescr()
if (IsArchived()) AppendHtmlEscapedAndCorrectNonUTF8(target, ArchiveDescr().c_str() );
target.append("\", \"");
// scraper data
// [3] : image.path (nach "/tvscraper/")
Expand All @@ -822,15 +823,11 @@ namespace vdrlive {
AppendHtmlEscapedAndCorrectNonUTF8(target, m_s_episode_name.c_str() );
}
target.append("\", \"");
if (m_s_runtime) {
// [7] : runtime (scraper)
AppendDuration(target, tr("(%d:%02d)"), m_s_runtime / 60, m_s_runtime % 60);
}
if (m_s_runtime) AppendDuration(target, tr("(%d:%02d)"), m_s_runtime / 60, m_s_runtime % 60);
target.append("\", \"");
if (!m_s_release_date.empty() ) {
// [8] : relase date (scraper)
target.append(m_s_release_date);
}
if (!m_s_release_date.empty() ) target.append(m_s_release_date);
target.append("\", \"");
// recording_spec: Day, time & duration
// [9] : recording_spec: Day, time & duration
Expand Down Expand Up @@ -880,9 +877,6 @@ namespace vdrlive {
target.append("\", \"");
// [18] IMDB ID
target.append(m_s_IMDB_ID);
target.append("\", \"");
// [19] ArchiveDescr()
if (IsArchived()) AppendHtmlEscapedAndCorrectNonUTF8(target, ArchiveDescr().c_str() );
target.append("\"]");
// target.append("])</script>");
}
Expand Down
5 changes: 3 additions & 2 deletions tools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,15 @@ namespace vdrlive {
target.append(notAppended, i);
}

void AppendHtmlEscapedAndCorrectNonUTF8(std::string &target, const char* s){
void AppendHtmlEscapedAndCorrectNonUTF8(std::string &target, const char* s, const char *end){
// append c-string s to target, html escape some chsracters
// replace invalid UTF8 characters with ?
if(!s) return;
if (!end) end = s + strlen(s);
int l = 0; // length of current utf8 codepoint
size_t i = 0; // number of not yet appended chars
const char* notAppended = s; // position of the first character which is not yet appended
for (const char* current = s; *current; current+=l) {
for (const char* current = s; *current && current < end; current+=l) {
l = utf8CodepointIsValid(current);
switch(l) {
case 1:
Expand Down
2 changes: 1 addition & 1 deletion tools.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ namespace vdrlive {
extern const std::collate<char>& g_collate_char;

void AppendHtmlEscaped(std::string &target, const char* s);
void AppendHtmlEscapedAndCorrectNonUTF8(std::string &target, const char *str);
void AppendHtmlEscapedAndCorrectNonUTF8(std::string &target, const char* s, const char *end = NULL);
void AppendCorrectNonUTF8(std::string &target, const char* s);

wint_t getNextUtfCodepoint(const char *&p);
Expand Down

0 comments on commit e189038

Please sign in to comment.