File: edit_searchtimer.ecpp

package info (click to toggle)
vdr-plugin-live 3.5.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 6,128 kB
  • sloc: cpp: 12,995; javascript: 3,234; makefile: 241; sh: 40
file content (1158 lines) | stat: -rw-r--r-- 56,300 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
<%pre>

#include <tools.h>
#include <epgsearch.h>
#include <setup.h>
#include <users.h>

#include <iomanip>

using namespace vdrlive;
</%pre>
<%args>
  // input parameters
  std::string searchtimerid;
  std::string test;

  // form parameters
  std::string search = "";
  int mode = 0;
  bool matchcase = false;
  int tolerance = 1;
  bool usetitle = false;
  bool usesubtitle = false;
  bool usedescr = false;
  bool usecontentids = false;
  int usechannel = SearchTimer::NoChannel;
  std::string channelfrom_string = "";
  std::string channelto_string = "";
  std::string changrpsel = "";
  bool usetime = false;
  std::string start_s = "00:00";
  std::string stop_s = "00:00";
  bool useduration = false;
  int durationmin_h = 0;
  int durationmin_m = 0;
  int durationmax_h = 1;
  int durationmax_m = 30;
  bool useweekday = false;
  bool wday_mon = false;
  bool wday_tue = false;
  bool wday_wed = false;
  bool wday_thu = false;
  bool wday_fri = false;
  bool wday_sat = false;
  bool wday_sun = false;
  bool useinfavorites = false;
  int useassearchtimer = 0;
  int searchtimeraction = 0;
  bool seriesrecording = false;
  std::string directory = "";
  int delrecafterdays = 0;
  int keeprecs = 0;
  int pauseonrecs = 0;
  int blacklistmode = 3;
  int switchminbefore = 0;
  bool useextepginfo = false;
  std::string extepgvalues[];
  bool avoidrepeats = false;
  int allowedrepeats = 0;
  int repeatswithindays = 0;
  bool comparetitle = false;
  int comparesubtitle = 0;
  bool comparesummary = false;
  unsigned avoidrepeatscatselected[];
  int priority = 0;
  int lifetime = 0;
  int marginstart = 0;
  int marginstop = 0;
  bool usevps = false;
  int delmode = 0;
  int delaftercountrecs = 0;
  int delafterdaysoffirstrec = 0;
  std::string blacklistids;
  std::string useassearchtimerfrom;
  std::string useassearchtimerto;
  bool ignoreMissingEPGCats = false;
  bool unmutesoundonswitch = false;
  int comparesummarymatchinpercent = 0;
  int comparedate = 0;
  int nav_back = 1;
</%args>
<%session scope="global">
bool logged_in(false);
</%session>
<%request scope="page">
ExtEPGInfos extEPGInfos;
ChannelGroups channelGroups;
Blacklists blacklists;
RecordingDirs recordingdirs;
SearchTimer* editsearchtimer;
SearchTimer newSearchTimer;
std::string contentsFilter;
</%request>
<%include>page_init.eh</%include>
<{
if (!logged_in && LiveSetup().UseAuth()) {
  cToSvConcat<0> targetUrl = "/login.html?redirect=";
  targetUrl.appendUrlEscaped(request.getQuery());
  return reply.redirect(targetUrl.data());
}
}>
<%cpp>

  if (!cUser::CurrentUserHasRightTo(UR_EDITSTIMERS))
    throw HtmlError( tr("Sorry, no permission. Please contact your administrator!") );

#define SELECTIF(x) reply.out() << ( (x) ? "selected=\"selected\"" : "" );
#define CHECKIF(x) reply.out() << ( (x) ? "checked=\"checked\"" : "" );
#if TNTVERSION >= 30000
const char *TNT_ARRAY = "[]";
#else
const char *TNT_ARRAY = "";
#endif

  // ensure match with VDR settings
  constexpr uint contentGroups = 16;
  constexpr uint contentIdentifiersPerGroup = 16;
  constexpr uint contentIdentifiers = contentGroups * contentIdentifiersPerGroup;

  SearchTimers searchtimers;
  bool testmode = !test.empty();

  tChannelID channelfrom = tChannelID::FromString(channelfrom_string.c_str());
  tChannelID channelto   = tChannelID::FromString(channelto_string.c_str());

  if ( request.getMethod() == "POST") {
    SearchTimer searchtimer;
    if ( !searchtimerid.empty() && !testmode) {
      editsearchtimer = searchtimers.GetByTimerId( searchtimerid );
      if (!editsearchtimer)
        throw HtmlError( tr("Couldn't find search timer. Maybe you mistyped your request?") );
      // duplicate the search timer to preserve yet unknown fields
      searchtimer = *editsearchtimer;
    }

    searchtimer.SetSearch(search);
    searchtimer.SetSearchMode(mode);
    searchtimer.SetTolerance(tolerance);
    searchtimer.SetMatchCase(matchcase);
    searchtimer.SetUseTitle(usetitle);
    searchtimer.SetUseSubtitle(usesubtitle);
    searchtimer.SetUseDescription(usedescr);
    cToSvConcat contentsFilterString;
    if (usecontentids) {
      for (uint groupID = 0; groupID < contentGroups; groupID++) {
        cToSvFormatted<16> useGroupHexID("usegid%x0", groupID);
        if (qparam.has(useGroupHexID.data())) {
          for (uint contentID = 0; contentID < contentIdentifiersPerGroup; contentID++) {
            cToSvFormatted<8> contentHexID("cid%x%x", groupID, contentID);
            if (qparam.has(contentHexID.data())) {
              contentsFilterString.appendFormatted("%x%x", groupID, contentID);
            }
          }
        }
      }
    }
    searchtimer.SetContentsFilter(contentsFilterString.data());
    searchtimer.SetUseExtEPGInfo(useextepginfo);
    if (useextepginfo)
    {
      std::vector<std::string> infos;
      unsigned int i = 0;
      for (ExtEPGInfos::iterator extinfo = extEPGInfos.begin(); extinfo != extEPGInfos.end(); ++extinfo, i++)
      {
      std::stringstream os;
      os << extinfo->Id() << "#" << (i < extepgvalues.size() ? extepgvalues[i] : "");
      infos.push_back(os.str());
      }
      searchtimer.SetExtEPGInfo(infos);
      searchtimer.SetIgnoreMissingEPGCats(ignoreMissingEPGCats);
    }
    searchtimer.SetUseChannel((SearchTimer::eUseChannel)usechannel);
    if (usechannel == SearchTimer::Interval)
    {
      searchtimer.SetChannelMin(channelfrom);
      searchtimer.SetChannelMax(channelto);
    }
    if (usechannel == SearchTimer::Group)
      searchtimer.SetChannelText(changrpsel);

    searchtimer.SetUseTime(usetime);
    if (usetime)
    {
      searchtimer.SetStartTime(timeStringToInt(start_s));
      searchtimer.SetStopTime(timeStringToInt(stop_s));
    }
    searchtimer.SetUseDuration(useduration);
    if (useduration)
    {
      searchtimer.SetMinDuration(durationmin_h * 100 + durationmin_m);
      searchtimer.SetMaxDuration(durationmax_h * 100 + durationmax_m);
    }
    searchtimer.SetUseDayOfWeek(useweekday);
    if (useweekday)
    {
      int dayofweek = 0;
      if (wday_sun) dayofweek |= 0x01;
      if (wday_mon) dayofweek |= 0x02;
      if (wday_tue) dayofweek |= 0x04;
      if (wday_wed) dayofweek |= 0x08;
      if (wday_thu) dayofweek |= 0x10;
      if (wday_fri) dayofweek |= 0x20;
      if (wday_sat) dayofweek |= 0x40;
      searchtimer.SetDayOfWeek(-dayofweek);
    }
    searchtimer.SetUseInFavorites(useinfavorites);
    searchtimer.SetUseAsSearchTimer(useassearchtimer);
    if (useassearchtimer == 2)
    {
      searchtimer.SetUseAsSearchTimerFrom(useassearchtimerfrom, "yyyy-mm-dd");
      searchtimer.SetUseAsSearchTimerTil(useassearchtimerto, "yyyy-mm-dd");
    }
    searchtimer.SetSearchTimerAction(searchtimeraction);
    searchtimer.SetUseSeriesRecording(seriesrecording);
    searchtimer.SetDirectory(directory);
    searchtimer.SetDelRecsAfterDays(delrecafterdays);
    searchtimer.SetKeepRecs(keeprecs);
    searchtimer.SetPauseOnRecs(pauseonrecs);
    searchtimer.SetBlacklistMode(blacklistmode);
    if (blacklistmode == 1)
      searchtimer.ParseBlacklist(blacklistids);
    searchtimer.SetSwitchMinBefore(switchminbefore);
    searchtimer.SetUnmuteSoundOnSwitch(unmutesoundonswitch);
    searchtimer.SetAvoidRepeats(avoidrepeats);
    if (avoidrepeats)
    {
      searchtimer.SetAllowedRepeats(allowedrepeats);
      searchtimer.SetRepeatsWithinDays(repeatswithindays);
      searchtimer.SetCompareTitle(comparetitle);
      searchtimer.SetCompareSubtitle(comparesubtitle);
      searchtimer.SetCompareSummary(comparesummary);
      searchtimer.SetCompareSummaryMatchInPercent(comparesummarymatchinpercent);
      searchtimer.SetCompareDate(comparedate);
    }
    unsigned long catsselected = 0;
    for (unsigned int i = 0; i < avoidrepeatscatselected.size(); i++)
      catsselected |= (1 << (avoidrepeatscatselected[i] - 1));
    searchtimer.SetCompareCategories(catsselected);
    searchtimer.SetPriority(priority);
    searchtimer.SetLifetime(lifetime);
    searchtimer.SetMarginStart(marginstart);
    searchtimer.SetMarginStop(marginstop);
    searchtimer.SetUseVPS(usevps);
    searchtimer.SetDelMode(delmode);
    if (delmode)
    {
      searchtimer.SetDelAfterCountRecs(delaftercountrecs);
      searchtimer.SetDelAfterDaysOfFirstRec(delafterdaysoffirstrec);
    }
    if (!testmode)
    {
      searchtimers.Save(&searchtimer);
</%cpp>
<!DOCTYPE html>
<html>
  <script>
    history.go(<$-nav_back-1$>);
<#  window.location = "searchtimers.html";  #>
  </script>
</html>
<%cpp>
    }
    else
    {
      searchtimer.SetId(0);
      std::string md5 = SearchResults::AddQuery(searchtimer.ToText());
</%cpp>
<!DOCTYPE html>
<html>
  <script>
    window.location = "searchresults.html?searchtimerquery=<$md5$>";
  </script>
</html>
<%cpp>
    }
  }
  SearchTimer* searchtimer;
  if (!searchtimerid.empty()) {
    searchtimer = editsearchtimer = searchtimers.GetByTimerId(searchtimerid);
    if (!searchtimer)
      throw HtmlError( tr("Couldn't find search timer. Maybe you mistyped your request?") );
  } else {
    searchtimer = &newSearchTimer;
  }
  search = searchtimer->Search();
  mode = searchtimer->SearchMode();
  tolerance = searchtimer->Tolerance();
  matchcase = searchtimer->MatchCase();
  usetitle = searchtimer->UseTitle();
  usesubtitle = searchtimer->UseSubtitle();
  usedescr = searchtimer->UseDescription();
  usechannel = searchtimer->UseChannel();
  channelfrom = searchtimer->ChannelMin();
  channelto = searchtimer->ChannelMax();
  if (!channelto.Valid() && channelfrom.Valid())
    channelto = channelfrom;
  if (usechannel == SearchTimer::Group)
    changrpsel = searchtimer->ChannelText();
  usetime = searchtimer->UseTime();
  start_s = intToTimeString(searchtimer->StartTime() );
  stop_s  = intToTimeString(searchtimer->StopTime() );
  useduration = searchtimer->UseDuration();
  if (useduration)
  {
    durationmin_m = searchtimer->MinDuration() % 100;
    durationmin_h = searchtimer->MinDuration() / 100;
    durationmax_m = searchtimer->MaxDuration() % 100;
    durationmax_h = searchtimer->MaxDuration() / 100;
  }
  useweekday = searchtimer->UseDayOfWeek();
  if (useweekday)
  {
    int dayofweek = searchtimer->DayOfWeek();
    if (dayofweek >= 0)
    {
      wday_sun = (dayofweek == 0);
      wday_mon = (dayofweek == 1);
    wday_tue = (dayofweek == 2);
      wday_wed = (dayofweek == 3);
    wday_thu = (dayofweek == 4);
      wday_fri = (dayofweek == 5);
      wday_sat = (dayofweek == 6);
    }
    else
    {
    wday_sun = -dayofweek & 0x01;
    wday_mon = -dayofweek & 0x02;
    wday_tue = -dayofweek & 0x04;
    wday_wed = -dayofweek & 0x08;
    wday_thu = -dayofweek & 0x10;
    wday_fri = -dayofweek & 0x20;
    wday_sat = -dayofweek & 0x40;
    }
  }
  useinfavorites = searchtimer->UseInFavorites();
  useassearchtimer = searchtimer->UseAsSearchTimer();
  if (useassearchtimer == 2)
  {
    useassearchtimerfrom = searchtimer->UseAsSearchTimerFrom("yyyy-mm-dd");
    useassearchtimerto = searchtimer->UseAsSearchTimerTil("yyyy-mm-dd");
  }
  searchtimeraction = searchtimer->SearchTimerAction();
  seriesrecording = searchtimer->UseSeriesRecording();
  directory = searchtimer->Directory();
  delrecafterdays = searchtimer->DelRecsAfterDays();
  keeprecs = searchtimer->KeepRecs();
  pauseonrecs = searchtimer->PauseOnRecs();
  blacklistmode = searchtimer->BlacklistMode();
  switchminbefore = searchtimer->SwitchMinBefore();
  unmutesoundonswitch = searchtimer->UnmuteSoundOnSwitch();
  useextepginfo = searchtimer->UseExtEPGInfo();
  std::vector<std::string> infos = searchtimer->ExtEPGInfo();
  for (unsigned int i = 0; i < extEPGInfos.size(); i++) {
    if (i < infos.size()) {
      cSplit<std::string> parts(infos[i], '#');
      extepgvalues.push_back(parts.size() > 1? *(++parts.begin()):"");
    } else
      extepgvalues.push_back("");
  }
  ignoreMissingEPGCats = searchtimer->IgnoreMissingEPGCats();
  avoidrepeats = searchtimer->AvoidRepeats();
  allowedrepeats =  searchtimer->AllowedRepeats();
  repeatswithindays = searchtimer->RepeatsWithinDays();
  comparetitle = searchtimer->CompareTitle();
  comparesubtitle = searchtimer->CompareSubtitle();
  comparesummary = searchtimer->CompareSummary();
  comparesummarymatchinpercent = searchtimer->CompareSummaryMatchInPercent();
  comparedate = searchtimer->CompareDate();
  contentsFilter = searchtimer->ContentsFilter();     // no part of form, thus camelCase
  for (unsigned int i = 0; i < extEPGInfos.size(); i++)
  {
    bool selected = searchtimer->CompareCategories() & (1<<i);
    avoidrepeatscatselected.push_back(selected);
  }
  priority = searchtimer->Priority();
  lifetime = searchtimer->Lifetime();
  marginstart = searchtimer->MarginStart();
  marginstop = searchtimer->MarginStop();
  usevps = searchtimer->UseVPS();
  delmode = searchtimer->DelMode();
  delaftercountrecs = searchtimer->DelAfterCountRecs();
  delafterdaysoffirstrec = searchtimer->DelAfterDaysOfFirstRec();
</%cpp>
<& pageelems.doc_type &>
<html>
  <head>
    <meta name="viewport" content="width=device-width, initial-scale=1" />
    <title>VDR Live - <$ editsearchtimer ? tr("Edit search timer") : tr("New search timer") $></title>

    <& pageelems.stylesheets &>
    <& pageelems.ajax_js &>

    <script type="text/javascript">
    function initform()
    {
      changedsearchmode(document.getElementById("search_mode"));
      changedchannelmode(document.getElementById("channel_mode"));
      changedusetime(document.getElementById("usetime"));
      changeduseduration(document.getElementById("useduration"));
      changeduseweekday(document.getElementById("useweekday"));
      for (let gid = 0; gid < <$ contentGroups $>; gid++ ) {
        const hexID = gid.toString(16) + "0";
        changedusecontentgroup(document.getElementById("usecontentgroup" + hexID));
      }
      changedusecontentids(document.getElementById("usecontentids"));
%     if (extEPGInfos.size() > 0) {
        changeduseextepginfo(document.getElementById("useextepginfo"));
%     }
      changedblacklistmode(document.getElementById("blacklistmode"));
      changeduseassearchtimer(document.getElementById("useassearchtimer"));
      changedavoidrepeats(document.getElementById("avoidrepeats"));
      changedcomparesummary(document.getElementById("comparesummary"));
      changeddelmode(document.getElementById("delmode"));
    }

    function checksearchterm()
    {
      if (document.getElementById("searchterm").value.length <= 3)
        return confirm('<$ tr("Search text too short - use anyway?") $>');
      return true;
    }

    function changedsearchmode(selection)
    {
      const tolerance = document.getElementById("tolerance");
      if (selection.options[selection.selectedIndex].value == 5) {
        tolerance.style.display = "revert-layer";
        tolerance.disabled = false;
      } else {
        tolerance.style.display = "none";
        tolerance.disabled = true;
      }
    }

    function changedchannelmode(selection)
    {
      const value = selection.options[selection.selectedIndex].value;
      document.getElementById("channelinterval").style.display = (value == 1 ? "revert-layer" : "none");
      document.getElementById("channelgroup").style.display = (value == 2 ? "revert-layer" : "none");
    }

    function changedusetime(selection)
    {
      document.getElementById("timesettings").style.display = (selection.checked ? "revert-layer" : "none");
    }

    function changeduseduration(selection)
    {
      const durationSettings = document.getElementById("durationsettings");
      if (selection.checked) {
        durationSettings.style.display = "revert-layer";
        for (const input of durationSettings.getElementsByTagName("input")) {
          input.disabled = false;
        }
      } else {
        durationSettings.style.display = "none";
        for (const input of durationSettings.getElementsByTagName("input")) {
          input.disabled = true;
        }
      }
    }

    function changeduseweekday(selection)
    {
      document.getElementById("weekdaysettings").style.display = (selection.checked ? "revert-layer" : "none");
    }

    function changedusecontentids(selection)
    {
      document.getElementById("use_content_ids").style.display = (selection.checked ? "revert-layer" : "none");
    }

    function changedusecontentgroup(selection)
    {
      if (selection !== null) {
        const gid = selection.id.slice(-2);
        const group = document.getElementById("content_group_" + gid);
        if (group !== null) {
          group.style.display = (selection.checked ? "revert-layer" : "none");
        }
      }
    }

    function changeduseextepginfo(selection)
    {
      const useExtEpgSettings = document.getElementById("use_extepg_settings");
      if (useExtEpgSettings) useExtEpgSettings.style.display = (selection.checked ? "revert-layer" : "none");
    }

    function changedextepginfo(selection)
    {
      const extEpg = selection.id.replace(/_option_.*$/, "_");
      const input = document.getElementById(extEpg + "value");
      input.value = "";
      for (let i = 0; true; i++)
      {
        const option = document.getElementById(extEpg + "option_" + i);
        const label =  document.getElementById(extEpg + "label_" + i);
        if (!option || !label) break;
        if (option.checked)
        {
          if (input.value) input.value += ",";
          input.value += label.innerText;
        }
      }
    }

    function changedblacklistmode(selection)
    {
      document.getElementById("blacklistmodesettings").style.display =
        (selection.options[selection.selectedIndex].value == 1 ? "revert-layer" : "none");
    }

    function changedblacklists(selection)
    {
      const base = selection.id.replace(/_.*$/, "_");
      const input = document.getElementById("blacklistids");
      input.value = "";
      for (let i = 0; true; i++)
      {
        const blacklist = document.getElementById(base + i);
        if (!blacklist) break;
        if (blacklist.checked)
        {
          if (input.value) input.value += "|";
          input.value += blacklist.name.replace(/^.*_(\\d+)$/, "$1");
        }
      }
    }

    function changeduseassearchtimer(selection)
    {
      document.getElementById("searchtimeractionsettings").style.display =
        (selection.options[selection.selectedIndex].value > 0) ? "revert-layer" : "none";
      document.getElementById("useassearchtimeruserdef").style.display =
        (selection.options[selection.selectedIndex].value == 2) ? "revert-layer" : "none";
      changedsearchtimeraction(document.getElementById("searchtimeraction"));
    }

    function changedsearchtimeraction(selection)
    {
      const actionTimerSettings = document.getElementById("searchtimeraction05settings");
      const useAsSearchTimer = document.getElementById("useassearchtimer");
      const searchTimerMode = useAsSearchTimer.options[useAsSearchTimer.selectedIndex].value;
      // settings if action is (in)active timer
      let hidden = false;
      if (searchTimerMode > 0 && ["0", "5"].includes(selection.options[selection.selectedIndex].value)) {
          actionTimerSettings.style.display = "revert-layer";
      } else {
          actionTimerSettings.style.display = "none";
          hidden = true;
      }
      for (const input of actionTimerSettings.getElementsByTagName("input")) {
        if (input.type == "number") input.disabled = hidden;
      }
      changedavoidrepeats(document.getElementById("avoidrepeats"), hidden);
      changeddelmode(document.getElementById("delmode"), hidden);
      // settings if action is channel switching
      const actionAnncouncementSettings = document.getElementById("searchtimeraction23settings");
      const switchMinBefore = document.getElementById("switchminbefore");
      if (searchTimerMode > 0 && ["2", "3"].includes(selection.options[selection.selectedIndex].value)) {
        actionAnncouncementSettings.style.display = "revert-layer";
        switchMinBefore.disabled = false;
      } else {
        actionAnncouncementSettings.style.display = "none";
        switchMinBefore.disabled = true;
      }
    }

    function changeddirselection(selection)
    {
      document.getElementById("directory").value = selection.value;
    }

    function changedavoidrepeats(selection, hidden)
    {
      hidden ||= !selection.checked;
      const avoidRepeatsSettings = document.getElementById("avoidrepeatssettings");
      avoidRepeatsSettings.style.display = (selection.checked ? "revert-layer" : "none");
      for (const input of avoidRepeatsSettings.getElementsByTagName("input")) {
        if (input.type == "number") input.disabled = hidden;
      }
      changedcomparesummary(document.getElementById("comparesummary"), hidden);
    }

    function changedcomparesummary(selection, hidden)
    {
      const summaryMatchInPercent = document.getElementById("summarymatchinpercent");
      const compareSummaryMatchInPercent = document.getElementById("comparesummarymatchinpercent");
      if ((selection.checked && !hidden)) {
        summaryMatchInPercent.style.display =  "revert-layer";
        compareSummaryMatchInPercent.disabled = false;
      } else {
        summaryMatchInPercent.style.display =  "none";
        compareSummaryMatchInPercent.disabled = true;
      }
    }

    function changeddelmode(selection, hidden)
    {
      const delModeRecordings = document.getElementById("delmoderecordings");
      const delAfterCountRecordings = document.getElementById("delaftercountrecs");
      if (selection.value == 1 && !hidden) {
        delModeRecordings.style.display = "revert-layer";
        delAfterCountRecordings.disabled = false;
      } else {
        delModeRecordings.style.display = "none";
        delAfterCountRecordings.disabled = true;
      }
      const delModeDays = document.getElementById("delmodedays");
      const delAfterCountDays = document.getElementById("delafterdaysoffirstrec");
      if (selection.value == 2 && !hidden) {
        delModeDays.style.display = "revert-layer";
        delAfterCountDays.disabled = false;
      } else {
        delModeDays.style.display = "none";
        delAfterCountDays.disabled = true;
      }
    }
    </script>

  </head>
  <body onload="initform()" onpagehide="saveScrollPosition('content')" onpageshow="restoreScrollPosition()">
    <& pageelems.logo &>
    <& menu active=("searchtimers") &>
      <div id="content">
        <div class="spacebar"><# spacer with fade-out effect #></div>
        <form method="post" name="edit_searchtimer" action="edit_searchtimer.ecpp">
          <input type="hidden" name="searchtimerid" value="<$ searchtimerid $>"/>
          <input type="hidden" name="blacklistids" value="<$ blacklistids $>" id="blacklistids"/>
          <input type="hidden" name="nav_back" value="<$ nav_back $>"/>
          <table class="form" cellpadding="0" cellspacing="0">
            <tr class="head">
              <td  class="toprow leftcol rightcol" colspan="2"><div class="boxheader"><div class="caption"><$ editsearchtimer ? tr("Edit search timer") : tr("New search timer") $></div></div></td>
            </tr>

            <!-- Search term -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Search term") $>:</div></td>
              <td class="rightcol"><input type="text" name="search" value="<$ search $>" class="width99" size="55" id="searchterm" /></td>
            </tr>

            <!-- Search mode -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Search mode" ) $>:</div></td>
              <td class="rightcol">
                <div class="options">
                  <select onchange="changedsearchmode(this)" name="mode" size="1" id="search_mode">
                    <option value="0" <{ SELECTIF(mode == 0) }> ><$ tr("phrase") $></option>
                    <option value="1" <{ SELECTIF(mode == 1) }> ><$ tr("all words") $></option>
                    <option value="2" <{ SELECTIF(mode == 2) }> ><$ tr("at least one word") $></option>
                    <option value="3" <{ SELECTIF(mode == 3) }> ><$ tr("match exactly") $></option>
                    <option value="4" <{ SELECTIF(mode == 4) }> ><$ tr("regular expression") $></option>
                    <option value="5" <{ SELECTIF(mode == 5) }> ><$ tr("fuzzy") $></option>
                  </select>
                  <div id="tolerance" style="display: none">
                      <$ tr("Tolerance" ) $>:
                    <input type="number" name="tolerance" size="2" min="1" max="9" value="<$ tolerance $>" />
                  </div>
                </div>
              </td>
            </tr>

            <!-- Match case -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Match case") $>:</div></td>
              <td class="rightcol"><input type="checkbox" name="matchcase" value="1" <{ CHECKIF(matchcase) }> id="matchcase"/></td>
            </tr>

            <!-- Search in -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Search in") $>:</div></td>
              <td class="rightcol"><div class="options">
                <div class="dotted">
                  <input type="checkbox" name="usetitle" value="1" <{ CHECKIF(usetitle) }> />
                  <label for="usetitle"><$ tr("Title") $> </label>
                </div>
                <div class="dotted">
                  <input type="checkbox" name="usesubtitle" value="1" <{ CHECKIF(usesubtitle) }> />
                  <label for="usesubtitle"><$ tr("Episode") $> </label>
                </div>
                <div class="dotted">
                  <input type="checkbox" name="usedescr" value="1" <{ CHECKIF(usedescr) }> />
                  <label for="usedescr"><$ tr("Description") $> </label>
                </div>
              </div></td>
            </tr>

            <!-- Use content IDs -->
<%cpp>
            // collect the defined content IDs
            std::set<std::string> contentStrings;             // for identifying duplicates
            std::vector<uint> contentStringIDs;               // all defined content IDs
            for (uint contentID = 0; contentID < contentIdentifiers; contentID++) {
              const std::string contentDescription = cEvent::ContentToString(contentID);
              if (!contentDescription.empty() && contentStrings.find(contentDescription) == contentStrings.end()) {
                contentStrings.insert(contentDescription);
                contentStringIDs.push_back(contentID);
              }
            }
            // create the indicators of the filtered content IDs (for initializing the check marks)
            bool filteredContentIDs[contentIdentifiers] = { false };
            bool filteredContentGroupIDs[contentGroups] = { false };
            cSv contentFilterIDs = cToSvToLower(contentsFilter);
            for (size_t i = 0; i < contentFilterIDs.length(); i += 2) {
              uint contentID = parse_hex<uint>(contentFilterIDs.substr(i, 2));
              if (contentID < contentIdentifiers) filteredContentIDs[contentID] = true;
              uint groupID = contentID / contentIdentifiersPerGroup;
              if (groupID < contentGroups) filteredContentGroupIDs[groupID] = true;
            }
            if (contentStringIDs.size() > 0) {
</%cpp>
              <tr>
                <td class="label leftcol"><div class="withmargin"><$ tr("Use content categories") $>:</div></td>
                <td class="rightcol">
                  <input type="checkbox" name="usecontentids" value="1" <{ CHECKIF(contentFilterIDs.length() > 0) }> onclick="changedusecontentids(this)" id="usecontentids"/>
                  <div id="use_content_ids" style="display: none">
                    <table class="dependent" border="0" cellspacing="0" cellpadding="0">
                    <# we rely on the uniqueness of the content IDs and that group identifiers are always present #>
%                   for (uint contentID : contentStringIDs) {
%                     uint groupID = contentID / contentIdentifiersPerGroup;
%                     cToSvFormatted<8> hexID("%02x", contentID);
%                     cToSvConcat contentString;
%                     AppendHtmlEscapedAndCorrectNonUTF8(contentString, cEvent::ContentToString(contentID));
%                     contentString.replaceAll("/", "/<wbr>");
                      <# we subsequently deviate from our indentation scheme for better visual tag alignment #>
%                     if (contentID % contentIdentifiersPerGroup == 0) {
%                       if (contentID != contentStringIDs.front()) {
                            </div>
                          </td>
                        </tr>
%                       }
                        <tr>
%                         cToSvConcat contentLabel;
%                         if (groupID == 0xB) {
%                           // this is kind of a "miscellaneous" group, i.e. the first group entry
%                           // does not represent a meaningful group heading (cf. EN 300 468, Table 18)
%                           AppendHtmlEscapedAndCorrectNonUTF8(contentLabel, tr("Special Characteristics"));
%                         } else
%                           contentLabel.append(contentString);
                          <td class="label"><div class="withmargin"><$$ contentLabel $>:</div></td>
                          <td><input type="checkbox" name="usegid<$ hexID $>" value="1" <{ CHECKIF(groupID < contentIdentifiersPerGroup && filteredContentGroupIDs[groupID]) }> onclick="changedusecontentgroup(this)" id="usecontentgroup<$ hexID $>"/>
                            <div class="descriptors options" id="content_group_<$ hexID $>">
%                     }
                              <div class="dotted"><# like in EPGsearch, the groupID is the first item for selection #>
                                <input type="checkbox" name="cid<$ hexID $>" value="1" <{ CHECKIF(contentID < contentIdentifiers && filteredContentIDs[contentID]) }> onclick="" id="cid<$ hexID $>"/>
                                <label for="cid<$ hexID $>"><$$ contentString $></label>
                              </div>
%                   }
%                   if (contentStringIDs.size() > 0) {
                            </div>
                          </td>
                        </tr>
%                   }
                    </table>
                  </div>
                </td>
              </tr>
%           }

%           if (extEPGInfos.size() > 0) {
            <!-- Use ext. EPG categories -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Use extended EPG info" ) $>:</div></td>
              <td class="rightcol">
                <input type="checkbox" name="useextepginfo" value="1" <{ CHECKIF(useextepginfo) }> onclick="changeduseextepginfo(this)" id="useextepginfo"/>
                <div id="use_extepg_settings" style="display: none">
                  <table class="dependent" border="0" cellspacing="0" cellpadding="0">
                    <!-- Extended EPG categories -->
%                   int i = 0; for (ExtEPGInfos::iterator extinfo = extEPGInfos.begin(); extinfo != extEPGInfos.end(); ++extinfo, i++) {
                    <tr>
                      <td class="label"><div class="withmargin"><$ extinfo->Name() $>:</div></td>
                      <# EPGsearch returns a one-element list with an empty string for text-type categories #>
%                     bool isTextCategory = extinfo->Values().size() == 0 || (extinfo->Values().size() == 1 && extinfo->Values()[0].empty());
%                     cToSvConcat<16> id("extepg_");
%                     id.appendInt<1>(extinfo->Id());
                      <td>
                        <input type="text" name="extepgvalues<$TNT_ARRAY$>" value="<$extepgvalues[i]$>" size="20" id="<$ id $>_value" <?? !isTextCategory ? " hidden=\"1\" readonly=\"1\"" ?> />
%                       if (!isTextCategory) {
                          <div class="categories options">
%                         for (unsigned int j = 0; j < extinfo->Values().size(); j++) {
                            <div class="dotted">
                              <input type="checkbox" id="<$ id $>_option_<$ j $>" name="<$ id $>_option" value="1" <{ CHECKIF(extinfo->Selected(j, extepgvalues[i])) }> onchange="changedextepginfo(this)" />
                              <label id="<$ id $>_label_<$ j $>" for="<$ id $>_<$ j $>"><$ extinfo->Values()[j] $></label>
                            </div>
%                         }
                          </div>
%                       }
                      </td>
                    </tr>
%                   }

                    <!-- Ignore missing EPG categories -->
                    <tr>
                      <td colspan="2"><div class="options">
                        <div class="dotted">
                          <input type="checkbox" name="ignoreMissingEPGCats" value="1" <{ CHECKIF(ignoreMissingEPGCats) }> />
                          <label for="ignoreMissingEPGCats"><$ tr("Ignore missing EPG info") $> </label>
                          <& tooltip.help text=(tr("When active this can cause very many timers. So please always first test this search before using it as search timer!")) &>
                        </div>
                      </div></td>
                    </tr>
                  </table>
                </div>
              </td>
            </tr>
%           }

            <!-- Use channel -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Use channel" ) $>:</div></td>
              <td class="rightcol">
                <select onchange="changedchannelmode(this)" name="usechannel" size="1" id="channel_mode">
                  <option value="0" <{ SELECTIF(usechannel == 0) }> ><$ trVDR("no") $></option>
                  <option value="1" <{ SELECTIF(usechannel == 1) }> ><$ tr("interval") $></option>
                  <option value="2" <{ SELECTIF(usechannel == 2) }> ><$ tr("channel group") $></option>
                  <option value="3" <{ SELECTIF(usechannel == 3) }> ><$ tr("only FTA") $></option>
                </select>

                <div id="channelinterval" style="display: none;">
                  <table class="dependent" cellpadding="0" cellspacing="0">
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("from channel" ) $>:</div></td>
                      <td><& channels_widget name=("channelfrom_string") channelid=(true) selected=(channelfrom) &></td>
                    </tr>
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("to channel" ) $>:</div></td>
                      <td><& channels_widget name=("channelto_string") channelid=(true) selected=(channelto) &></td>
                    </tr>
                  </table>
                </div>

                <div id="channelgroup" style="display: none">
%               if (channelGroups.size() > 0) {
                  <select name="changrpsel" size="1" id="changrpsel">
%                 int i = 0; for (ChannelGroups::iterator changrp = channelGroups.begin(); changrp != channelGroups.end(); ++changrp, i++) {
                    <option value="<$ changrp->Name() $>" <{ SELECTIF(changrpsel == changrp->Name()) }> ><$ changrp->Name() $></option>
%                 }
                  </select>
%               }
                </div>
              </td>
            </tr>

            <!-- Use time -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Use time") $>:</div></td>
              <td class="rightcol">
                <input type="checkbox" name="usetime" value="1" <{ CHECKIF(usetime) }> onclick="changedusetime(this)" id="usetime" />
                <div id="timesettings" style="display: none">
                  <table class="dependent" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Start after") $>:</div></td>
                      <td>
                        <input type="time" name="start_s" value="<$ start_s $>" />
                        <& tooltip.help text=(tr("The time the show may start at the earliest")) &>
                      </td>
                    </tr>
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Start before") $>:</div></td>
                      <td>
                        <input type="time" name="stop_s" value="<$ stop_s $>" />
                        <& tooltip.help text=(tr("The time the show may start at the latest")) &>
                      </td>
                    </tr>
                  </table>
                </div>
              </td>
            </tr>

            <!-- Use duration -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Use duration") $>:</div></td>
              <td class="rightcol">
                <input type="checkbox" name="useduration" value="1" <{ CHECKIF(useduration) }> onclick="changeduseduration(this)" id="useduration" />
                <div id="durationsettings" style="display: none">
                  <table class="dependent" border="0" cellpadding="0" cellspacing="0">
                    <# cannot use time input, as time would be rendered acc. to locale (potentially as 12-hour am/pm) #>
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Min. duration") $>:</div></td>
                      <td><input type="number" min="0" max= "23" step="1" size="2" name="durationmin_h" value="<$ durationmin_h $>" /> : <input type="number" min="0" max= "59" step="1" size="2" name="durationmin_m" value="<$ durationmin_m $>" /> </td>
                    </tr>
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Max. duration") $>:</div></td>
                      <td><input type="number" min="0" max= "23" step="1" size="2" name="durationmax_h" value="<$ durationmax_h $>" /> : <input type="number" min="0" max= "59" step="1" size="2" name="durationmax_m" value="<$ durationmax_m $>" /> </td>
                    </tr>
                  </table>
                </div>
              </td>
            </tr>

            <!-- Use weekday -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Use day of week") $>:</div></td>
              <td class="rightcol">
                <input type="checkbox" name="useweekday" value="1" <{ CHECKIF(useweekday) }> onclick="changeduseweekday(this)" id="useweekday" />
                <div id="weekdaysettings" class="dependent options" style="display: none">
                  <div class="dotted"><input type="checkbox" name="wday_mon" value="1" <{ CHECKIF(wday_mon) }> /> <$ tr("Monday") $></div>
                  <div class="dotted"><input type="checkbox" name="wday_tue" value="1" <{ CHECKIF(wday_tue) }> /> <$ tr("Tuesday") $></div>
                  <div class="dotted"><input type="checkbox" name="wday_wed" value="1" <{ CHECKIF(wday_wed) }> /> <$ tr("Wednesday") $></div>
                  <div class="dotted"><input type="checkbox" name="wday_thu" value="1" <{ CHECKIF(wday_thu) }> /> <$ tr("Thursday") $></div>
                  <div class="dotted"><input type="checkbox" name="wday_fri" value="1" <{ CHECKIF(wday_fri) }> /> <$ tr("Friday") $></div>
                  <div class="dotted"><input type="checkbox" name="wday_sat" value="1" <{ CHECKIF(wday_sat) }> /> <$ tr("Saturday") $></div>
                  <# add class "first" if weekdays shall start with sunday #>
                  <div class="dotted"><input type="checkbox" name="wday_sun" value="1" <{ CHECKIF(wday_sun) }> /> <$ tr("Sunday") $></div>
                </div>
              </td>
            </tr>

            <!-- Use blacklists -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Use blacklists" ) $>:</div></td>
              <td class="rightcol">
                <select onchange="changedblacklistmode(this)" name="blacklistmode" size="1" id="blacklistmode">
                  <option value="3" <{ SELECTIF(blacklistmode == 3) }> ><$ trVDR("no") $></option>
                  <option value="0" <{ SELECTIF(blacklistmode == 0) }> ><$ tr("only global") $></option>
                  <option value="1" <{ SELECTIF(blacklistmode == 1) }> ><$ tr("Selection") $></option>
                  <option value="2" <{ SELECTIF(blacklistmode == 2) }> ><$ tr("all") $></option>
                </select>
                <div class="dependent" id="blacklistmodesettings" style="display: none">
%               if (blacklists.size() > 0) {
                  <div class="blacklists options">
%                 int i = 0; for (Blacklists::iterator blacklist = blacklists.begin(); blacklist != blacklists.end(); ++blacklist, i++) {
%                   cToSvConcat<16> id("blacklist_");
%                   id.appendInt<1>(i);
                    <div class="dotted">
                      <input type="checkbox" id="<$ id $>" name="<$ id $>_<$ blacklist->Id() $>" value="1" <{ CHECKIF(searchtimer && searchtimer->BlacklistSelected(blacklist->Id())) }> onchange="changedblacklists(this)" />
                      <label for="<$ id $>"><$ blacklist->Search() $></label>
                    </div>
%                 }
                  </div>
%               }
                </div>
              </td>
            </tr>

            <!-- Use in favorites menu -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Use in favorites menu") $>:</div></td>
              <td class="rightcol"><input type="checkbox" name="useinfavorites" value="1" <{ CHECKIF(useinfavorites) }>/></td>
            </tr>

            <!-- Use as search timer -->
            <tr>
              <td class="label leftcol"><div class="withmargin"><$ tr("Use as search timer" ) $>:</div></td>
              <td class="rightcol">
                <div>
                  <select onchange="changeduseassearchtimer(this)" name="useassearchtimer" size="1" id="useassearchtimer">
                    <option value="0" <{ SELECTIF(useassearchtimer == 0) }> ><$ trVDR("no") $></option>
                    <option value="1" <{ SELECTIF(useassearchtimer == 1) }> ><$ trVDR("yes") $></option>
                    <option value="2" <{ SELECTIF(useassearchtimer == 2) }> ><$ tr("user defined") $></option>
                  </select>
                </div>
                <div id="useassearchtimeruserdef" style="display: none">
                  <table class="dependent" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("from date") $>:</div></td>
                      <td><input id="datefrom" name="useassearchtimerfrom" type="date" value="<$ useassearchtimerfrom $>" /></td>
                    </tr>
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("to date") $>:</div></td>
                      <td><input id="dateto" name="useassearchtimerto" type="date" value="<$ useassearchtimerto $>" /></td>
                    </tr>
                  </table>
                </div>
                <div id="searchtimeractionsettings" style="display: none">
                  <select onchange="changedsearchtimeraction(this)" name="searchtimeraction" size="1" id="searchtimeraction">
                    <option value="0" <{ SELECTIF(searchtimeraction == 0) }> ><$ tr("Record") $></option>
                    <option value="1" <{ SELECTIF(searchtimeraction == 1) }> ><$ tr("Announce only") $></option>
                    <option value="2" <{ SELECTIF(searchtimeraction == 2) }> ><$ tr("Switch only") $></option>
                    <option value="3" <{ SELECTIF(searchtimeraction == 3) }> ><$ tr("Announce and Switch") $></option>
                    <option value="4" <{ SELECTIF(searchtimeraction == 4) }> ><$ tr("Announce via email") $></option>
                    <option value="5" <{ SELECTIF(searchtimeraction == 5) }> ><$ tr("Inactive Record") $></option>
                  </select>
                </div>
                <div id="searchtimeraction05settings" style="display: none">
                  <table class="dependent" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Series recording") $>:</div></td>
                      <td><input type="checkbox" name="seriesrecording" value="1" <{ CHECKIF(seriesrecording) }>/></td>
                    </tr>

                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Directory") $>:</div></td>
                      <td>
                        <div><input type="text" name="directory" id="directory" value="<$ directory $>" class="width99" size="70" /></div>
                        <div><select onchange="changeddirselection(this)" name="recordingdirsselection" size="1" id="recordingdirsselection">
                      <option/>
%                     for (RecordingDirs::iterator rdir = recordingdirs.begin(); rdir != recordingdirs.end(); ++rdir) {
                        <option value="<$ *rdir $>"><$ *rdir $></option>
%                     }
                      </select></div>
                      </td>
                    </tr>

                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Delete recordings after ... days") $>:</div></td>
                      <td>
                        <input type="number" min="0" max="99" name="delrecafterdays" id="delrecafterdays" size="6" value="<$ delrecafterdays $>"/>&nbsp;&nbsp;
                        <$ tr("Keep ... recordings") $>:
                        <input type="number" min="0" max="10" name="keeprecs" size="6" value="<$ keeprecs $>"/>
                      </td>
                    </tr>

                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Pause when ... recordings exist") $>:</div></td>
                      <td><input type="number" min="0" max="99" name="pauseonrecs" id="pauseonrecs" size="6" value="<$ pauseonrecs $>"/></td>
                    </tr>

                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Avoid repeats" ) $>:</div></td>
                      <td><input type="checkbox" name="avoidrepeats" value="1" <{ CHECKIF(avoidrepeats) }> onclick="changedavoidrepeats(this)" id="avoidrepeats"/>
                        <div id="avoidrepeatssettings" style="display: none">
                          <table class="dependent" border="0" cellpadding="0" cellspacing="0">
                            <tr>
                              <td class="label"><div class="withmargin"><$ tr("Allowed repeats") $>:</div></td>
                              <td>
                                <input type="number" min="0" max="10" size="6" name="allowedrepeats" value="<$ allowedrepeats $>" /><span class="withmargin"><$ tr("Only repeats within ... days") $>:</span><input type="number" min="0" max="999" size="6" name="repeatswithindays" value="<$ repeatswithindays $>" />
                              </td>
                            </tr>

                            <tr>
                              <td class="label"><div class="withmargin"><$ tr("Compare title" ) $>:</div></td>
                              <td><input type="checkbox" name="comparetitle" value="1" <{ CHECKIF(comparetitle) }>/>
                            </tr>

                            <tr>
                              <td class="label"><div class="withmargin"><$ tr("Compare subtitle" ) $>:</div></td>
                              <td><select name="comparesubtitle" size="1" id="comparesubtitle">
                                <option value="0" <{ SELECTIF(comparesubtitle == 0) }> ><$ trVDR("no") $></option>
                                <option value="1" <{ SELECTIF(comparesubtitle == 1) }> ><$ trVDR("yes") $></option>
                                <option value="2" <{ SELECTIF(comparesubtitle == 2) }> ><$ tr("if present") $></option></select></td>
                            </tr>

                            <tr>
                              <td class="label"><div class="withmargin"><$ tr("Compare summary" ) $>:</div></td>
                              <td>
                                <input type="checkbox" name="comparesummary" value="1" <{ CHECKIF(comparesummary) }> id="comparesummary" onclick="changedcomparesummary(this)">
                                <# value is restricted in EPGsearch #>
                                <span id="summarymatchinpercent" style="display: none">
                                  <$ tr("Match in percent" ) $>:
                                  <input type="number" min="1" max="100" name="comparesummarymatchinpercent" id="comparesummarymatchinpercent" size="6" value="<$ comparesummarymatchinpercent $>">
                                </span>
                              </td>
                            </tr>
                            <tr>
                              <td class="label"><div class="withmargin"><$ tr("Compare date" ) $>:</div></td>
                              <td><select name="comparedate" size="1" id="comparedate">
                                <option value="0" <{ SELECTIF(comparedate == 0) }> ><$ trVDR("no") $></option>
                                <option value="1" <{ SELECTIF(comparedate == 1) }> ><$ tr("same day") $></option>
                                <option value="2" <{ SELECTIF(comparedate == 2) }> ><$ tr("same week") $></option><
                                <option value="3" <{ SELECTIF(comparedate == 3) }> ><$ tr("same month") $></option></select>
                              </td>
                            </tr>

%                           if (extEPGInfos.size() > 0) {
%                             int i = 0; for (ExtEPGInfos::iterator extinfo = extEPGInfos.begin(); extinfo != extEPGInfos.end(); ++extinfo, i++) {
                                <tr>
                                  <td class="label"><div class="withmargin"><$ tr("Compare" ) $> <$ extinfo->Name() $>:</div></td>
                                  <td><input type="checkbox" name="avoidrepeatscatselected<$TNT_ARRAY$>" value="<$ i+1 $>" <{ CHECKIF(avoidrepeatscatselected[i]) }>/></td>
                                </tr>
%                             }
%                           }
                          </table>
                        </div>
                      </td>
                    </tr>

                    <tr>
                      <td class="label"><div class="withmargin"><$ trVDR("Priority") $>:</div></td>
                      <td><input type="number" min="0" max="99" name="priority" size="6" value="<$ priority $>"/></td>
                    </tr>

                    <tr>
                      <td class="label"><div class="withmargin"><$ trVDR("Lifetime") $>:</div></td>
                      <td><input type="number" min="0" max="99" name="lifetime" size="6" value="<$ lifetime $>"/></td>
                    </tr>

                    <tr>
                      <# validation may fail upon editing, since EPGsearch does not restrict the value #>
                      <td class="label"><div class="withmargin"><$ trVDR("Setup.Recording$Margin at start (min)") $>:</div></td>
                      <td><input type="number" min="0" max="30" name="marginstart" size="6" value="<$ marginstart $>"/></td>
                    </tr>

                    <tr>
                      <# validation may fail upon editing, since EPGsearch does not restrict the value #>
                      <td class="label"><div class="withmargin"><$ trVDR("Setup.Recording$Margin at stop (min)") $>:</div></td>
                      <td><input type="number" min="0" max="30" name="marginstop" size="6" value="<$ marginstop $>"/></td>
                    </tr>

                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Use VPS") $>:</div></td>
                      <td><input type="checkbox" name="usevps" value="1" <{ CHECKIF(usevps) }>/></td>
                    </tr>
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Auto-delete search timer") $>:</div></td>
                      <td>
                        <select onchange="changeddelmode(this)" name="delmode" size="1" id="delmode">
                          <option value="0" <{ SELECTIF(delmode == 0) }> ><$ trVDR("no") $></option>
                          <option value="1" <{ SELECTIF(delmode == 1) }> ><$ tr("based on recordings") $></option>
                          <option value="2" <{ SELECTIF(delmode == 2) }> ><$ tr("based on days") $></option>
                        </select>
                        <div id="delmoderecordings" style="display: none">
                          <span class="label"><$ tr("after ... recordings") $>:</span>
                          <input type="number" min="0" max="999" size="6" name="delaftercountrecs" id="delaftercountrecs" value="<$ delaftercountrecs $>" />
                        </div>
                        <div id="delmodedays" style="display: none">
                          <span class="label"><$ tr("after ... days after first rec.") $>:</span>
                          <input type="number" min="0" max="999" size="6" name="delafterdaysoffirstrec" id="delafterdaysoffirstrec" value="<$ delafterdaysoffirstrec $>" />
                        </div>
                      </td>
                    </tr>
                  </table>
                </div>

                <div id="searchtimeraction23settings" style="display: none">
                  <table class="dependent" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Switch ... minutes before start") $>:</div></td>
                      <td><input type="number" min="0" max="20"  name="switchminbefore" id="switchminbefore" size="6" value="<$ switchminbefore $>"/></td>
                    </tr>
                    <tr>
                      <td class="label"><div class="withmargin"><$ tr("Unmute sound on switch" ) $>:</div></td>
                      <td><input type="checkbox" name="unmutesoundonswitch" value="1" <{ CHECKIF(unmutesoundonswitch) }>/></td>
                     <tr>
                  </table>
                </div>
              </td>
            </tr>

            <!-- Messages and buttons -->
            <tr>
              <td class="buttonpanel leftcol rightcol bottomrow" colspan="2">
                <div class="submission">
                  <div class="warning"><span id="compatibility">
%                 if (searchtimers.begin() != searchtimers.end()) {
%                   if (searchtimers.begin()->HasInsufficientFields()) {
                      <$ tr("The searchtimer lacks some form fields, so that their values cannot be saved. Please upgrade to the most recent version of EPGsearch.") $>
%                   } else if (searchtimers.begin()->HasUnknownFields()) {
                      <$ tr("The searchtimer includes extra fields. These will be saved with their original values.") $>
%                   }
%                 }
                  </span></div>
                  <div class="buttons">
                    <button class="green" type="submit" name="test" value="test" onclick="return checksearchterm();"><$ tr("Test") $></button>
                    <button class="green" type="submit" name="save" onclick="return checksearchterm();"><$ tr("Save") $></button>
                    <button type="button" class="red" onclick="history.go(<$-nav_back$>)"><$ tr("Cancel") $></button>
                  </div>
                </div>
              </td>
            </tr>
          </table>
        </form>
        <div class="spacebar"><# spacer with fade-out effect #></div>
      </div>
  </body>
</html>
<%include>page_exit.eh</%include>