/usr/share/vdr/plugins/live/js/live/pageenhance.js is in vdr-plugin-live 0.2.0+git20130305-6.1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 | /*
* This is part of the live vdr plugin. See COPYING for license information.
*
* PageEnhance class.
*
* This class applies several functions to the page based on
* selectors. This class is project dependent and not a general
* purpose class.
*/
var PageEnhance = new Class({
options: {
epgLinkSelector: 'a[href^="epginfo.html?epgid"]',
actionLinkSelector: 'a[href^="vdr_request/"]',
vlcLinkSelector: 'a[href^="vlc.html?"]',
vlcWinOptions: {
size: { width: 720, height: 640 }
},
editTimerSelector: 'a[href^="edit_timer.html?timerid"]',
hintTipSelector: '*[title]',
hintClassName: 'hint',
infoWinOptions: {
bodyselect: 'div.epg_content',
loadingMsg: 'loading',
errorMsg: 'an error occured!'
},
notifyIdPrefix: 'notify',
notifyStrings: {
successMsg: '<img src="active.png" alt=""> Success!',
errorMsg: '<img src="del.png" alt=""> failed!'
},
datePickerSelector: 'input.DatePicker',
datePickerOptions: ''
},
initialize: function(options){
this.setOptions(options);
this.$notifyCount = 0;
window.addEvent('domready', this.domReadySetup.bind(this));
window.addEvent('mousedown', this.mouseDownSetup.bind(this));
},
// actions applied on domready to the page.
domReadySetup: function(){
$$(this.options.epgLinkSelector).each(this.epgPopup.bind(this));
this.addHintTips($$(this.options.hintTipSelector));
$$(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.
mouseDownSetup: function(){
$$('.' + this.options.hintClassName + '-tip').setStyle('visibility', 'hidden');
},
// registered as 'onDomExtend' event for InfoWin. Takes care to
// enhance the new dom elements too.
domExtend: function(id, elems){
var sel = '#' + id + ' ' + this.options.hintTipSelector;
elems = $$(sel);
this.addHintTips(elems);
$$('#' + id + ' ' + this.options.actionLinkSelector).each(this.vdrRequest.bind(this));
$$('#' + id + ' ' + this.options.vlcLinkSelector).each(this.vlcRequest.bind(this));
},
// Epg Popup function. Apply to all elements that should
// pop up an Epg InfoWin window.
epgPopup: function(el){
var href = el.href;
var epgid = $pick(href, "");
if (epgid != "") {
var extractId = /epgid=(\w+)/;
var found = extractId.exec(epgid);
if ($defined(found) && found.length > 1) {
epgid = found[1];
el.addEvent('click', function(event){
var event = new Event(event);
new InfoWin.Ajax(epgid, href, $merge(this.options.infoWinOptions, {
onDomExtend: this.domExtend.bind(this)
})).show(event);
event.stop();
return false;
}.bind(this));
}
}
},
// 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){
var href = $pick(element.href, "");
if (href != "") {
this.$notifyCount++;
var req = new Ajax(href, {
method: 'post',
onComplete: function(text, xmldoc) {
try {
var success = xmldoc.getElementsByTagName('response').item(0).firstChild.nodeValue;
new InfoWin.Notifier(this.options.notifyIdPrefix + this.$notifyCount, {
className: success == '1' ? 'ok' : 'err',
message: success == '1' ? this.options.notifyStrings.successMsg : this.options.notifyStrings.errorMsg
}).show(event);
} catch(e) {
}
}.bind(this)
});
req.request('async=1');
event.stop();
return false;
}
return true;
}.bindWithEvent(this, el));
},
// function that opens a window for streaming of tv data.
vlcRequest: function(el){
el.addEvent('click', function(event, element){
var href = $pick(element.href, "");
if (href != "") {
href += "&async=1";
var bw = new BrowserWin("vlcstream", href, this.options.vlcWinOptions);
event.stop();
return false;
}
return true;
}.bindWithEvent(this, el));
},
// change normal 'title'-Attributes into enhanced hinttips
// usesd by domExtend and domReadySetup functions.
addHintTips: function(elems){
if (!$defined(this.tips)) {
this.tips = new HintTips(elems, {
maxTitleChars: 100,
className: this.options.hintClassName
});
}
else {
$$(elems).each(this.tips.build, this.tips);
}
},
// add datepicker to input element
datePicker: function(el){
el.alt = this.options.datePickerOptions;
new DatePicker(el);
}
});
PageEnhance.implement(new Events, new Options);
|