([^<]+)<\/expression>/),
tr = $(''
+ epgd.channels.getHtml(t.channelid) + ' | '
+ (t.action != 'A'
? ' ' + timerActions[t.action] + ' '
: stateIcons[t.state]
) + (t.info || '') + ' | '
+ ''
+ (t.day ? epgd.utils.formatDate(t.day) : '-')
+ ' | '
+ new String(100 + parseInt(t.starttime / 100, 10)).slice(1) + ':' + new String(100 + parseInt(t.starttime % 100, 10)).slice(1)
+ ' | '
+ new String(100 + parseInt(t.endtime / 100, 10)).slice(1) + ':' + new String(100 + parseInt(t.endtime % 100, 10)).slice(1)
+ ' | ' + (t.title || '') + ' ' + (t.shorttext || '') : '>') + ' | '
+ vdr.name + ' ' + (t.directory ? t.directory + '~' : '') + (t.file || '') + ' | '
+ (t.autotimerid ? searchTimerIcon.replace('$id$', t.autotimerid).replace('$title$', t.autotimername || t.expression || epgd.tr.pages.timer.searchTimerList) : '')
+ (noEditStates.indexOf(t.state) == -1 ? editIcons : '') + ' |
')[0];
tr.tData = t;
trs.push(tr);
});
timerList.trs = trs;
timerList.showHead();
/*timerList.$con.find('>table>tbody>tr').find('>td:eq(1)').tooltip({
items: "div", content: function () {
return this.innerHTML;
}
})*/
}
epgd.utils.loader.close();
$(window).trigger('timerlist_updated', timerList);
});
},true);
}
epgd.timerListBase.prototype.action = function ($el, iconName,data) {
//this.dialog && this.dialog.close && this.dialog.close();
var id;
switch (iconName) {
case 'edit':
case 'doc-new':
this.dialog.render($el.closest('tr')[0].tData);
break;
case 'trash':
this.del(this.getSelectedIds($el));
break;
case 'flashlight':
id = $el.attr('data-id'),
list = this;
$(window).one('searchTimerList_updated', function () {
list.$con.find('tbody>tr').each(function () {
if (this.tData.id == id) {
epgd.pages.searchTimerList.dialog.render(this.tData);
return false;
}
});
});
epgd.$menu.menu("select", { target: "#menu_searchTimerList" });
break;
default:
epgd.sortTable.prototype.action.call(this,$el, iconName, data);
}
};
epgd.timerListBase.prototype.editIcons = '';
epgd.timerListBase.prototype.getSelectedIds = function ($el) {
var ids = [];
if ($el[0].parentNode.nodeName == 'TH') {
$(this.trs).filter(".selected:visible").each(function () {
ids.push(this.tData.id);
});
} else
ids.push($el.closest('tr')[0].tData.id);
return ids;
}
epgd.timerListBase.prototype.del = function (ids, succFunc, arrayName) {
var self = this,
allIDs= $.isArray(ids) ? ids : [parseInt(ids,10)];
ids && allIDs.length && epgd.utils.confirm(epgd.tr.confirmDelete + (allIDs.length > 1 ? '
' + allIDs.length + epgd.tr.entries : ''), function (ok) {
ok && self.saveArray(allIDs, arrayName || "delete", succFunc);
});
}
epgd.timerListBase.prototype.saveArray = function (ids, arrayName, succFunc) {
var self = this,
allIDs= $.isArray(ids) ? ids : [parseInt(ids,10)],
data= {};
data[arrayName] = allIDs;
ids && allIDs.length && this.save(data, null, function (jqxhr) {
try {
var ids = ',';
$(jqxhr.responseJSON.result.failed).each(function () {
ids += allIDs[this] + ',';
});
if (ids.length > 1) {
$(self.trs).each(function () {
if (ids.indexOf(',' + this.tData.id + ',') >= 0)
this.style.backgroundColor = 'red';
});
}
} catch (e) { }
return false;
}, succFunc);
};
epgd.timerListBase.prototype.save = function (data, url, failFunc, succFunc) {
if (!data) return false;
var timerList = this;
epgd.utils.loader.process(function () {
epgd.ajax({
url: epgd.login.url + (url || timerList.o.saveUrl),
type: 'post',
data: JSON.stringify(data)
}, function (data) {
data = data.result;
if (data.state == 200)
epgd.utils.topInfo(epgd.tr.dataSaved);
else
epgd.utils.topInfo(data.message, { isError: 1 });
epgd.utils.loader.close();
timerList.$con && timerList.$con.parent().length && timerList.update();
succFunc && succFunc.call(timerList);
}, failFunc);
},true);
return true;
}
// searchResult List - Klasse
epgd.searchResultList = epgd.utils.inherits(function (options, dialog) {
epgd.timerListBase.call(this, $.extend({
saveUrl: 'data/save-searchtimer'
}, options),dialog);
}, epgd.timerListBase);
epgd.searchResultList.prototype.getTable = function () {
var tr = epgd.tr.pages.timerList;
return '' + epgd.tr.channel + this.sortIcons + ' | ' + tr.startTime + this.sortIcons + ' | '
+ tr.endTime + ' | ' + epgd.tr.pages.eventDetail.title + this.sortIcons + ' | |
---|
';
}
epgd.searchResultList.prototype.update = function (d) {
if (!d)
return false;
var timerList = this;
d.id && delete d.id;
d.name && delete d.name;
d.max = epgd.profile.maxListEntries;
epgd.utils.loader.process(function () {
timerList.$con.find('tbody').empty();
epgd.ajax({
url: epgd.login.url + "data/search",
type: 'post',
data: JSON.stringify(d)
}, function (data) {
var trs = [], i;
if (!data.events || !data.events.length) {
timerList.hideHead();
} else {
data.count > d.max && epgd.utils.popup('Achtung! Es wurden ' + data.count + ' Ergebnisse gefunden. Angezeigt werden aber nur ' + d.max + '.
Das Nachladen ist noch nicht implementiert! Der Wert kann in den Einstellungen angepasst werden');
$.each(data.events, function (id, e) {
var trClass = '',
icons = '',
d;
if (e.dones) {
for (i in e.dones) {
d = e.dones[i];
icons += '' + d.state + '';
if (d.state == 'R')
trClass = ' class="ui-state-disabled"';
}
}
trs.push($(''
+ epgd.channels.getHtml(e.channelid) + ' | '
+ epgd.utils.formatDate(e.starttime) + ' | '
+ epgd.utils.formatTime(e.starttime) + ' | '
+ epgd.utils.formatTime(e.starttime + e.duration)
+ ' | ' + e.title + ' ' + (e.shorttext || '')
+ ' | ' + icons + ' |
').tooltip()[0]);
});
timerList.trs = trs;
timerList.showHead();
}
epgd.utils.loader.close();
timerList.dialog && timerList.dialog.resize && window.setTimeout(function(){timerList.dialog.resize();},100);
});
},true);
};
// Timerliste eines Suchtimers - Klasse
epgd.searchTimerTimerList = epgd.utils.inherits(function (options, dialog) {
epgd.timerListBase.call(this, $.extend({
saveUrl: 'data/save-timer',
updateUrl: 'data/timers?state=P,R'
}, options), dialog);
}, epgd.timerListBase);
epgd.searchTimerTimerList.prototype.getTable = function () {
var tr = epgd.tr.pages.timerList;
return '' + epgd.tr.channel + this.sortIcons + ' | ' + tr.startTime + this.sortIcons + ' | '
+ tr.endTime + ' | ' + epgd.tr.pages.eventDetail.title + this.sortIcons + ' | VDR' + this.sortIcons + ' | '
+ ' |
---|
';
}
epgd.searchTimerTimerList.prototype.update = function (d) {
if (!d)
return false;
var timerList = this;
epgd.utils.loader.process(function () {
timerList.$con.find('tbody').empty();
epgd.ajax({ url: epgd.login.url + timerList.o.updateUrl + '&autotimerid=' + d.id, async: true, cache: false }, function (data) {
var trs = [],
editIcons = '';
if (!data.timers.length) {
timerList.hideHead();
} else {
$.each(data.timers, function (id, t) {
var vdr = epgd.vdrs.list[t.vdruuid] || { name: '--' },
tr = $(''
+ epgd.channels.getHtml(t.channelid) + ' | '
+ (t.day ? $.datepicker.formatDate(epgd.tr.dateTimePicker.dateFormat, epgd.utils.date(t.day)) : '-')
+ ' | '
+ new String(100 + parseInt(t.starttime / 100, 10)).slice(1) + ':' + new String(100 + parseInt(t.starttime % 100, 10)).slice(1)
+ ' | '
+ new String(100 + parseInt(t.endtime / 100, 10)).slice(1) + ':' + new String(100 + parseInt(t.endtime % 100, 10)).slice(1)
+ ' | ' + t.title + ' ' + (t.shorttext || '') : '>') + ' | '
+ vdr.name + ' ' + t.file + ' | '
+ editIcons + ' |
')[0];
tr.tData = t;
trs.push(tr);
});
timerList.trs = trs;
timerList.showHead();
}
timerList.dialog && timerList.dialog.resize && window.setTimeout(function () { timerList.dialog.resize(); }, 100);
epgd.utils.loader.close();
});
});
}
// anstehende Timer
epgd.pages.timerList = new epgd.timerListBase({
updateUrl: 'data/timers?state=P,R',
saveUrl: 'data/save-timer',
selectable: true,
addNew: true,
right: epgd.rights.umTimer
}, new epgd.timerDialog());
// Küzlich erledigte Timer
epgd.pages.timersDone = new epgd.timerListBase({
updateUrl: 'data/timers?state=D,F,E&action=A',
right: epgd.rights.umTimer
});
epgd.pages.timersDone.getTable = function () {
return epgd.timerListBase.prototype.getTable.call(this).replace('data-defaultSort="1"', 'data-defaultSort="-1"')
}
// Timerhistorie
epgd.pages.timerListDone = new epgd.timerListBase({
updateUrl: 'data/donetimers', saveUrl: 'data/store-donetimers',
selectable: true,
right: epgd.rights.umTimer
});
epgd.pages.timerListDone.getTable = function () {
return '';
}
epgd.pages.timerListDone.action = function ($el, iconName,data) {
if (iconName == 'detail' && !$el[0].eventDetail)
$el[0].eventDetail = new epgd.doneTimerDetail($el.parent()[0]);
epgd.timerListBase.prototype.action.call(this, $el, iconName, data);
}
epgd.pages.timerListDone.stateIcons = {
'D': '' + epgd.tr.pages.timerList.doneStates.D + '
', // gelöscht
'F': '' + epgd.tr.pages.timerList.doneStates.F + '
', // Aufnahme fehlgeschlagen
'f': '' + epgd.tr.pages.timerList.doneStates.f + '
', // Timer konnte nicht erstellt werden
'R': '' + epgd.tr.pages.timerList.doneStates.R + '
', // Aufnahme fertig
'C': '' + epgd.tr.pages.timerList.doneStates.C + '
', // Timer bereits erstellt
'Q': '' + epgd.tr.pages.timerList.doneStates.Q + '
' // Timer in Vorbereitung
}
epgd.pages.timerListDone.update = function () {
var timerList = this;
epgd.utils.loader.process(function () {
epgd.ajax({ url: epgd.login.url + timerList.o.updateUrl, async: false, cache: false }, function (data) {
timerList.$con.find('tbody').empty();
if (!data.donetimers.length) {
timerList.hideHead();
} else {
var trs = [],
tr, i, t,
searchTimerIcon = '$title$';
for (i in data.donetimers) {
t = data.donetimers[i];
tr = $(''
+ (t.state && timerList.stateIcons[t.state] || '') + ' | '
+ ''
+ epgd.utils.formatDateTime(t.starttime) + ' ' + parseInt(t.duration / 60, 10) + ' ' + epgd.tr.minutes
+ ' | ' + (t.title || '') + ' ' + (t.shorttext || '') + ' | '
+ epgd.channels.getHtml(t.channelid) + ' | '
+ ''
+ (t.autotimerid ? searchTimerIcon.replace('$id$', t.autotimerid).replace('$title$', t.autotimername || t.expression || epgd.tr.pages.timer.searchTimerList) : '')
+ ' |
')[0];
tr.tData = t;
trs.push(tr);
};
timerList.trs = trs;
timerList.showHead();
}
epgd.utils.loader.close();
$(window).trigger('timerlist_updated', timerList);
});
},true);
}
// ungesyncte Aufträge
epgd.pages.timerJobList = new epgd.timerListBase({
updateUrl: "data/timers?notaction=A",
saveUrl: 'data/delete-timerjobs',
selectable: true,
right: epgd.rights.umTimer
}, new epgd.timerDialog());
// Suchtimer
epgd.pages.searchTimerList = new epgd.timerListBase({
saveUrl: 'data/save-searchtimer',
right: epgd.rights.umSearchTimer
}, new epgd.searchTimerDialog());
epgd.pages.searchTimerList.getTable = function () {
var tr = epgd.tr.pages.timerList;
return '';
}
epgd.pages.searchTimerList.action = function ($el, iconName, data) {
epgd.timerListBase.prototype.action.call(this,$el, iconName, data);
switch (iconName) {
case 'link-ext':
this.triggerUpdate();
break;
case 'down-dir':
if (!$el[0].tList) {
var dialog={
$td: $el.parent().css("position", "relative"),
tdHeight: $el.parent().outerHeight() + 10,
data: $el.parent().parent()[0].tData,
resize: function () {
var $table = this.list.$con.find('>table').addClass("sub");
$table.width(this.$td.parent().outerWidth());
this.$td.height(this.tdHeight + $table.outerHeight(true) + 10);
//this.$td.append(this.list.$con);
},
toggle : function (doShow) {
this.list.$con.toggle(doShow);
if (doShow) {
this.$td.css("height", "100px");
this.list.update(this.data);
} else
this.$td.css("height", "auto");
}
},
options= {
conSel: $('').appendTo(document.body)
};
$el[0].tList = dialog.data.type == 'S' ? new epgd.searchResultList(options, dialog) : new epgd.searchTimerTimerList(options, dialog);
$el[0].tList.render();
dialog.$td.append(dialog.list.$con);
}
$el[0].tList.dialog.toggle(true);
$el.removeClass('i-down-dir').addClass('i-right-dir');
break;
case 'right-dir':
$el.removeClass('i-right-dir').addClass('i-down-dir');
if ($el[0].tList)
$el[0].tList.dialog.toggle(false);
break;
}
}
epgd.pages.searchTimerList.update = function () {
var timerList = this;
this.$con.find('tbody').empty();
epgd.utils.loader.process(function () {
epgd.ajax({ url: epgd.login.url + "data/searchtimers", async: false, cache: false }, function (data) {
var trs = [],
editIcons = timerList.editIcons,
typeIcons = { 'V': 'i-tv', 'R': 'i-record', 'S': 'i-search' };
if (!data.searchtimers.length) {
timerList.hideHead();
} else {
$.each(data.searchtimers, function (id, t) {
var vdr = epgd.vdrs.list[t.vdruuid] || { name: '--' },
tr = $(''
+ ''
+ ' ' + (t.name || t.expression) + ' | --' : ' data-sort="' + new String('00000' + t.hits).slice(-5) + '">' + t.hits) + ' | '
+ vdr.name + ' | ' + editIcons + ' |
')[0];
tr.tData = t;
trs.push(tr);
});
timerList.trs = trs;
timerList.showHead();
}
epgd.utils.loader.close();
$(window).trigger('searchTimerList_updated', timerList);
});
});
}
epgd.pages.searchTimerList.triggerUpdate = function () {
var timerList = this;
epgd.ajax({url: epgd.login.url + 'data/updatesearchtimer'},function (data) {
if (data.result.state == 200)
epgd.utils.topInfo(epgd.tr.dataSaved);
else
epgd.utils.topInfo(data.message, { isError: 1 });
timerList.update();
});
}
epgd.pages.search = new epgd.searchDialog();
//message List
epgd.pages.messageList = new epgd.timerListBase({
saveUrl: 'data/markmessages',
selectable: true
})
epgd.pages.messageList.getTable = function () {
return '';
}
epgd.pages.messageList.update = function (d) {
var messList = this;
epgd.utils.loader.process(function () {
epgd.ajax({ url: epgd.login.url + "data/messages", async: false, cache: false }, function (data) {
messList.$con.find('tbody').empty();
if (!data.messages.length) {
messList.hideHead();
} else {
var trs = [],
tr, i, t,
icons = {
'N': '' + epgd.tr.pages.timerList.messageStates.N + '',
'R': '' + epgd.tr.pages.timerList.messageStates.R + ''
},
types = {
'E': '' + epgd.tr.pages.timerList.timerStates.E + '
',
'F': '' + epgd.tr.pages.timerList.timerStates.F + '
',
'I': '' + epgd.tr.pages.timerList.messageTypes.I + '
',
'W': '' + epgd.tr.pages.timerList.messageTypes.W + '
'
};
for (i in data.messages) {
t = data.messages[i];
tr = $('' + t.id + ' | '
+ '' + (types[t.type] ||'') +' | '
+ ''
+ epgd.utils.formatDateTime(t.updsp) + ' | '
+ '' + t.title + ' | '
+ '' + t.text + ' | '
+ '' + (icons[t.state] || '') + ' | '
+ '
')[0];
tr.tData = t;
trs.push(tr);
};
messList.trs = trs;
messList.$con.find('>table>tbody').append(trs.sort(function (a,b) {
return a.tData.state == b.tData.state
? a.tData.state.updsp > b.tData.state.updsp ? -1 : 1
: a.tData.state > b.tData.state
}).slice());
messList.showHead();
}
epgd.utils.loader.close();
$(window).trigger('messagelist_updated', messList);
});
}, true);
};
epgd.pages.messageList.action = function ($el, iconName, data) {
var ids = this.getSelectedIds($el),
state= null,
i;
if (ids) {
switch (iconName) {
case 'check':
state = $el[0].parentNode.nodeName == 'TH' ? 'R' : 'N';
break;
case 'check-empty':
state = $el[0].parentNode.nodeName == 'TH' ? 'N' : 'R';
break;
case 'trash':
state = 'D'
break;
}
if (state) {
for (i in ids)
ids[i]= {"id":ids[i], "state":state}
state == 'D' ? this.del(ids, null,"messages") : this.saveArray(ids, "messages");
return true;
}
}
return epgd.timerListBase.prototype.action.call(this, $el, iconName, data);
}