summaryrefslogtreecommitdiff
path: root/http/src/js/1_main.js
diff options
context:
space:
mode:
Diffstat (limited to 'http/src/js/1_main.js')
-rw-r--r--http/src/js/1_main.js305
1 files changed, 157 insertions, 148 deletions
diff --git a/http/src/js/1_main.js b/http/src/js/1_main.js
index 3a8251a..09e93c4 100644
--- a/http/src/js/1_main.js
+++ b/http/src/js/1_main.js
@@ -55,10 +55,10 @@ epgd.profile_load = function (doNotCache) {
epgd.channels.isDirty = true;
}
}
- if (epgd.utils.timeOffset == null) {
- epgd.utils.timeOffset = (data.timezone - new Date().getTimezoneOffset() * 60) * 1000;
- now = epgd.utils.now();
- epgd.$dtPicker.datetimepicker('setDate', new Date(now.setMinutes(parseInt(now.getMinutes() / 15, 10) * 15)));
+ if (epgd.utils.timeOffset == null) {
+ epgd.utils.timeOffset = (data.timezone - new Date().getTimezoneOffset() * 60) * 1000;
+ now = epgd.utils.now();
+ epgd.$dtPicker.datetimepicker('setDate', new Date(now.setMinutes(parseInt(now.getMinutes() / 15, 10) * 15)));
}
if (!profile.minEventTime) {
now = epgd.utils.now();
@@ -131,7 +131,7 @@ epgd.utils = {
width: 400,
height:200,
maxWidth: $w.width() * 0.8,
- maxHeight: $w.height() * 0.7,
+ maxHeight: $w.height() * 0.7,
}, options);
$dlg = $('<div class="epgPopUp"><p>' + txt + '</p></div>').dialog(options);
options.autoClose && window.setTimeout(function () { $dlg.dialog('close').dialog('destroy'); }, options.autoClose);
@@ -214,63 +214,63 @@ epgd.utils = {
fontSize, kc;
inst.selectedItems = {};
- if (o.multiselect) {
+ if (o.multiselect) {
inst.multiselect = $("<div></div>")
.addClass("ui-autocomplete-multiselect ui-state-default ui-widget " + cn)
.css("width", w)
.insertBefore(inst.element)
.append(inst.element)
- .bind("click.autocomplete", function () {
- inst.element.focus();
+ .bind("click.autocomplete", function () {
+ inst.element.focus();
});
inst.menu.element.css({ "height": "300px", "overflow-y": "auto" });
fontSize = parseInt(inst.element.css("fontSize") || 10, 10);
function autoSize(e) {
// Hackish autosizing
var $this = $(this);
- $this.width(1).width(this.scrollWidth + fontSize - 1);
+ $this.width(1).width(this.scrollWidth + fontSize - 1);
};
kc = $.ui.keyCode;
- inst.element.bind({
- "keydown.autocomplete": function (e) {
- if ((this.value === "") && (e.keyCode == kc.BACKSPACE)) {
+ inst.element.bind({
+ "keydown.autocomplete": function (e) {
+ if ((this.value === "") && (e.keyCode == kc.BACKSPACE)) {
var prev = inst.element.prev();
delete inst.selectedItems[prev.text()];
- prev.remove();
- }
+ prev.remove();
+ }
},
// TODO: Implement outline of container
- "focus.autocomplete blur.autocomplete": function () {
- inst.multiselect.toggleClass("ui-state-active");
+ "focus.autocomplete blur.autocomplete": function () {
+ inst.multiselect.toggleClass("ui-state-active");
},
- "keypress.autocomplete change.autocomplete focus.autocomplete blur.autocomplete": autoSize
+ "keypress.autocomplete change.autocomplete focus.autocomplete blur.autocomplete": autoSize
}).trigger("change");
- o.select = o.select || function (e, ui) {
- if (!inst.selectedItems[ui.item.label]) {
+ o.select = o.select || function (e, ui) {
+ if (!inst.selectedItems[ui.item.label]) {
$("<div></div>")
.addClass("ui-autocomplete-multiselect-item")
.text(ui.item.label)
.append(
$("<span></span>")
.addClass("ui-icon ui-icon-close")
- .click(function () {
+ .click(function () {
var item = $(this).parent();
delete inst.selectedItems[item.text()];
- item.remove();
+ item.remove();
})
)
.insertBefore(inst.element);
- inst.selectedItems[ui.item.label] = ui.item;
+ inst.selectedItems[ui.item.label] = ui.item;
}
inst._value("");
- return false;
- }
- } else {
- o.select = o.select || function (e, ui) {
- inst.selectedItems[0] = ui.item;
- inst._value(ui.item.label);
- return false;
- }
+ return false;
+ }
+ } else {
+ o.select = o.select || function (e, ui) {
+ inst.selectedItems[0] = ui.item;
+ inst._value(ui.item.label);
+ return false;
+ }
};
}
}, options)).focus(function () {
@@ -313,43 +313,43 @@ epgd.utils = {
}
}
},
- addPlaceholders: function (inputSelector, key, placeholders) {
- var input = $(inputSelector)[0],
- html = '<ul class="placeholders ui-menu ui-widget ui-widget-content">',
- p;
+ addPlaceholders: function (inputSelector, key, placeholders) {
+ var input = $(inputSelector)[0],
+ html = '<ul class="placeholders ui-menu ui-widget ui-widget-content">',
+ p;
for (p in placeholders)
html += '<li class="ui-menu-item"><b>' + p + '</b>' + placeholders[p] + '</li>';
- input.$placeholders = $(html + '</ul>').hide().insertAfter(input).click(function (ev) {
- var placeholder = ev.target.nodeName == 'B' ? $(ev.target).text() : ev.target.nodeName == 'LI' ? $(ev.target.firstChild).text() : null,
- cursorPos = $(input).prop('selectionStart'),
- v = $(input).val();
- if (placeholder) {
- $(input).val(v.substring(0, cursorPos) + placeholder + v.substring(cursorPos, v.length)).focus();
- cursorPos += placeholder.length;
- if (input.setSelectionRange) {
- input.setSelectionRange(cursorPos, cursorPos);
- }
- else if (input.createTextRange) {
- v = input.createTextRange();
- v.collapse(true);
- v.moveEnd('character', cursorPos);
- v.moveStart('character', cursorPos);
- v.select();
- }
- }
- $(this).hide();
- });
- $(input).keydown(function (ev) {
- if (ev.key == key) {
- $(document).one("click", function () { input.$placeholders.hide(); })
- input.blur();
- return !input.$placeholders.show().position({
- my: "left top",
- at: "left bottom",
- of: input
- });
- }
- });
+ input.$placeholders = $(html + '</ul>').hide().insertAfter(input).click(function (ev) {
+ var placeholder = ev.target.nodeName == 'B' ? $(ev.target).text() : ev.target.nodeName == 'LI' ? $(ev.target.firstChild).text() : null,
+ cursorPos = $(input).prop('selectionStart'),
+ v = $(input).val();
+ if (placeholder) {
+ $(input).val(v.substring(0, cursorPos) + placeholder + v.substring(cursorPos, v.length)).focus();
+ cursorPos += placeholder.length;
+ if (input.setSelectionRange) {
+ input.setSelectionRange(cursorPos, cursorPos);
+ }
+ else if (input.createTextRange) {
+ v = input.createTextRange();
+ v.collapse(true);
+ v.moveEnd('character', cursorPos);
+ v.moveStart('character', cursorPos);
+ v.select();
+ }
+ }
+ $(this).hide();
+ });
+ $(input).keydown(function (ev) {
+ if (ev.key == key) {
+ $(document).one("click", function () { input.$placeholders.hide(); })
+ input.blur();
+ return !input.$placeholders.show().position({
+ my: "left top",
+ at: "left bottom",
+ of: input
+ });
+ }
+ });
},
inherits : function (childClass, parentClass) {
var tempClass = function () { };
@@ -392,12 +392,12 @@ epgd.init = function () {
} else if (unit == 'second' && epgd.profile.quickTimes) {
obj.closest('dl').find('.ui_tpicker_time').removeClass()
.bind("click", { tp_inst: tp_inst, obj:obj, unit: 'time' }, $.timepicker.quicklink).html('<i><u title="' + epgd.profile.quickTimes.replace(/[^=~]+=@[a-z]+/gi, '').replace(/~{2,}/g, '~').replace(/=!?/g, '">').replace(/~/g, '</u></i><i><u title="') + '</u></i>');
- if (tp_inst.inst.settings.alwaysSetTime)
+ if (tp_inst.inst.settings.alwaysSetTime)
epgd.pages.help.initButtons(tp_inst.inst.dpDiv.find('.ui-datepicker-buttonpane').append(epgd.pages.help.getButton('datepicker')));
- else
- $('<button class="iAsButton i-cancel" role="button">' + epgd.tr.clear + '</button>').appendTo(tp_inst.inst.dpDiv.find('.ui-datepicker-buttonpane')).click(function () {
+ else
+ $('<button class="iAsButton i-cancel" role="button">' + epgd.tr.clear + '</button>').appendTo(tp_inst.inst.dpDiv.find('.ui-datepicker-buttonpane')).click(function () {
tp_inst.$input.val('');
- $.datepicker._hideDatepicker();
+ $.datepicker._hideDatepicker();
});
return obj;
} else
@@ -446,47 +446,47 @@ epgd.init = function () {
epgd.$menu.parent().toggleClass('open');
});
epgd.$menu.checkMenuSize = function (ev, callback) {
- if (window.wrm_i) { // interval aktiv?
- if (window.wrm_w == $(window).width()) { //Breite vom vorherigen Aufruf und aktuelle Breite gleich?
- window.clearInterval(window.wrm_i);
- delete window.wrm_i;
- epgd.$menu.parent().removeClass('mini').width(window.wrm_w).offset({ 'left': $(window).scrollLeft() });
- epgd.$menu.checkMenuSize(null, callback);
- } else
- window.wrm_w = $(window).width();
- return;
- }
- if (ev) {
- window.wrm_w = $(window).width();
- if (!window.wrm_i) // Interval setzen, um sicher zu sein, dass die Breite jetzt stimmt
- window.wrm_i = window.setInterval(epgd.$menu.checkMenuSize, 200,null,callback);
- } else {
- if (epgd.$menu.height() > 40)
- epgd.$menu.parent().addClass('mini');
- window.setTimeout(function () {
- document.body.style.paddingTop = (epgd.$menu.parent().height() + 10) + "px";
- callback && window.setTimeout(callback,200);
- }, 200);
+ if (window.wrm_i) { // interval aktiv?
+ if (window.wrm_w == $(window).width()) { //Breite vom vorherigen Aufruf und aktuelle Breite gleich?
+ window.clearInterval(window.wrm_i);
+ delete window.wrm_i;
+ epgd.$menu.parent().removeClass('mini').width(window.wrm_w).offset({ 'left': $(window).scrollLeft() });
+ epgd.$menu.checkMenuSize(null, callback);
+ } else
+ window.wrm_w = $(window).width();
+ return;
+ }
+ if (ev) {
+ window.wrm_w = $(window).width();
+ if (!window.wrm_i) // Interval setzen, um sicher zu sein, dass die Breite jetzt stimmt
+ window.wrm_i = window.setInterval(epgd.$menu.checkMenuSize, 200,null,callback);
+ } else {
+ if (epgd.$menu.height() > 40)
+ epgd.$menu.parent().addClass('mini');
+ window.setTimeout(function () {
+ document.body.style.paddingTop = (epgd.$menu.parent().height() + 10) + "px";
+ callback && window.setTimeout(callback,200);
+ }, 200);
}
};
//epgd.$menu.show().checkMenuSize();
$(window).bind("resize", epgd.$menu.checkMenuSize);
epgd.$dtPicker = $('<input type="text" id="selDate" readonly style="z-index:199;position:relative" />').appendTo(document.body).hide().bind("click",function () { $(this).datepicker("show"); return false; });
- epgd.$dtPicker.datetimepicker({
- beforeShow: function () {
- this.$overlay = $("<div />").addClass("ui-widget-overlay ui-front").appendTo(document.body);
+ epgd.$dtPicker.datetimepicker({
+ beforeShow: function () {
+ this.$overlay = $("<div />").addClass("ui-widget-overlay ui-front").appendTo(document.body);
},
- onClose: function () {
+ onClose: function () {
this.$overlay.remove();
- $(window).trigger('datepicker');
- },
+ $(window).trigger('datepicker');
+ },
calendarStart: function() {
var d= new Date(epgd.profile.minEventTime * 1000)
leadDays = (d.getDay() - parseInt(epgd.profile.pickerFirstDay, 10) + 7) % 7;
d.setHours(12, 0);
d.setDate(d.getDate() - leadDays);
return d;
- }
+ }
});
epgd.$menu.menu({
@@ -499,14 +499,14 @@ epgd.init = function () {
epgd.$menu.parent().removeClass('open');
$(".menu-active", this).removeClass("menu-active");
$(document.body).append(epgd.$dtPicker.hide());
- epgd.$menu.checkMenuSize(null,function () {
- try {
+ epgd.$menu.checkMenuSize(null,function () {
+ try {
ui.item.addClass("menu-active").parent().parent('.ui-menu-item').addClass("menu-active");
- epgd.pages[id.slice(5)].render();
- } catch (e) {
- epgd.utils.popup(epgd.tr.error.common, { title: epgd.tr.error.error });
- epgd.utils.log((e.message || 'common error') + '\n' + (e.stack || ''), 2);
- }
+ epgd.pages[id.slice(5)].render();
+ } catch (e) {
+ epgd.utils.popup(epgd.tr.error.common, { title: epgd.tr.error.error });
+ epgd.utils.log((e.message || 'common error') + '\n' + (e.stack || ''), 2);
+ }
});
}
});
@@ -522,8 +522,8 @@ epgd.init = function () {
if (changes["defaultVDRuuid"] != undefined) {
$('#menu_vdrs > select').val(epgd.profile.defaultVDRuuid);
}
- if (changes["quickTimes"] != undefined) {
- epgd.pages.magazine.initQT();
+ if (changes["quickTimes"] != undefined) {
+ epgd.pages.magazine.initQT();
}
if (changes["needLogin"] != undefined) {
epgd.pages.login.doLogin();
@@ -550,7 +550,7 @@ epgd.init = function () {
+ ((epgd.login.rights & epgd.rights.umConfigUsers) == epgd.rights.umConfigUsers ? '<li id="menu_editUser"><a href="#menu_editUser">' + epgd.tr.pages.options.editUser + '</a></li>' : '')
+ '</ul></li>');
epgd.$menu.append('<li id="menu_help"><a href="#menu_help">' + epgd.tr.menu.help + '</a></li>');
- epgd.$menu.append('<li id="menu_vdrs"><a href="#menu_vdrs">VDR</a><select></select></li>');
+ epgd.$menu.append('<li id="menu_vdrs"><a href="#menu_vdrs">VDR</a><select></select><span><a id="osd2web">-&gt;OSD</a></span></li>');
}
epgd.profile.needLogin == "1" && epgd.$menu.append('<li id="menu_login"><a href="#menu_login">'
+ (epgd.login.session ? epgd.login.user + ' ' + epgd.tr.pages.login.logout : epgd.tr.pages.login.label )
@@ -571,13 +571,22 @@ epgd.init = function () {
html += '<option value="' + uuid + '"' + (uuid == epgd.vdrs.current.uuid ? 'selected' : '') + '>' + epgd.vdrs.list[uuid].name + '</option>';
}
$('<select>' + html + '</select>').replaceAll('#menu_vdrs > select').show().change(function () {
- epgd.vdrs.current = epgd.vdrs.get(this[this.selectedIndex].value);
+ var vdr= epgd.vdrs.current = epgd.vdrs.get(this[this.selectedIndex].value);
+ if (vdr && vdr.osd2webp)
+ $('#osd2web').prop("target", "osd2web_" + vdr.name)
+ .prop("href", "http://" + vdr.ip + ":" + vdr.osd2webp)
+ .click(function(ev){
+ ev.stopPropagation();
+ return true;
+ }).show();
+ else
+ $('#osd2web').hide();
}).mousedown(function (ev) {
ev.stopPropagation();
return true;
}).click(function (ev) {
return false;
- });
+ }).change();
}).bind("unload", function () {
if (epgd.login.session)
epgd.pages.login.doLogin('logout');
@@ -593,15 +602,15 @@ epgd.init = function () {
window.setInterval(epgd.profile_load, 3600000); // ca. jede Stunde neu abfragen
// window.setTimeout(function () { $(window).trigger('resize'); });
}
-window.onerror = function (msg, url, line, col, error) {
- // Note that col & error are new to the HTML 5 spec and may not be
- // supported in every browser. It worked for me in Chrome.
- var extra = !col ? '' : '\ncolumn: ' + col;
- extra += !error ? '' : '\nerror: ' + error.stack;
- try{
- epgd.utils.log(msg + "\nline: " + line + extra, 2);
- } catch(e){}
- return true;
+window.onerror = function (msg, url, line, col, error) {
+ // Note that col & error are new to the HTML 5 spec and may not be
+ // supported in every browser. It worked for me in Chrome.
+ var extra = !col ? '' : '\ncolumn: ' + col;
+ extra += !error ? '' : '\nerror: ' + error.stack;
+ try{
+ epgd.utils.log(msg + "\nline: " + line + extra, 2);
+ } catch(e){}
+ return true;
};
$.widget("custom.catcomplete", $.ui.autocomplete, {
@@ -625,54 +634,54 @@ $.widget("custom.catcomplete", $.ui.autocomplete, {
});
}
});
-$.datepicker._gotoToday = function (id) {
+$.datepicker._gotoToday = function (id) {
var inst = this._getInst($(id)[0]),
now = epgd.utils.now();
this._base_gotoToday(id);
this._setTime(inst, now);
- this._setDate(inst, now);
- this._hideDatepicker();
+ this._setDate(inst, now);
+ this._hideDatepicker();
};
-$.timepicker.quicklink = function (ev) {
+$.timepicker.quicklink = function (ev) {
var target = ev.target.nodeName == 'I' ? ev.target.firstChild : ev.target,
tp_inst,
val = null,
d = false;
- try {
- tp_inst = ev.data.tp_inst || $.datepicker._getInst(epgd.$dtPicker[0]).settings.timepicker;
- } catch (e) {
- epgd.utils.log((e.message || 'common error') + '\n' + (e.stack || ''), 2);
- return false;
+ try {
+ tp_inst = ev.data.tp_inst || $.datepicker._getInst(epgd.$dtPicker[0]).settings.timepicker;
+ } catch (e) {
+ epgd.utils.log((e.message || 'common error') + '\n' + (e.stack || ''), 2);
+ return false;
}
- if (target.nodeName == 'U') {
- if (ev.data.unit == "time")
- val = $.datepicker.parseTime(tp_inst._defaults.timeFormat, target.innerHTML, tp_inst._defaults);
- else if (ev.data.unit == "hour")
- val = { hour: parseInt(target.innerHTML, 10), minute: tp_inst.minute };
-
- if (val) {
+ if (target.nodeName == 'U') {
+ if (ev.data.unit == "time")
+ val = $.datepicker.parseTime(tp_inst._defaults.timeFormat, target.innerHTML, tp_inst._defaults);
+ else if (ev.data.unit == "hour")
+ val = { hour: parseInt(target.innerHTML, 10), minute: tp_inst.minute };
+
+ if (val) {
if (val.hour < tp_inst.hour - 1)
- d = true;
- else {
+ d = true;
+ else {
tp_inst.control.value(tp_inst, tp_inst.hour_slider, "hour", val.hour);
tp_inst._onTimeChange();
if (tp_inst.hour != val.hour)
- d = true;
+ d = true;
}
- if (d) {
+ if (d) {
d = new Date(tp_inst.inst.selectedYear, tp_inst.inst.selectedMonth, tp_inst.inst.selectedDay + 1, val.hour, val.minute);
$.datepicker._setDate(tp_inst.inst, d);
$.datepicker._setTime(tp_inst.inst, d);
- $.datepicker._updateDatepicker(tp_inst.inst);
+ $.datepicker._updateDatepicker(tp_inst.inst);
} else
- tp_inst.control.value(tp_inst, tp_inst.minute_slider, "minute", val.minute);
+ tp_inst.control.value(tp_inst, tp_inst.minute_slider, "minute", val.minute);
} else
tp_inst.control.value(tp_inst, ev.data.obj, ev.data.unit, parseInt(target.innerHTML, 10));
tp_inst._onTimeChange();
tp_inst._onSelectHandler();
if (ev.target.nodeName == 'I')
- $.datepicker._hideDatepicker();
- }
+ $.datepicker._hideDatepicker();
+ }
}
epgd.ajax = function (options, success, error) {
@@ -692,19 +701,19 @@ epgd.ajax = function (options, success, error) {
}
else if (jqxhr.status == 403) {
epgd.utils.popup(epgd.tr.error.forbidden, { title: epgd.tr.error.error });
- } else if (jqxhr.status == 501){
- epgd.utils.popup(epgd.tr.error.notImplemented, { title: epgd.tr.error.error });
+ } else if (jqxhr.status == 501){
+ epgd.utils.popup(epgd.tr.error.notImplemented, { title: epgd.tr.error.error });
} else {
if (error && error.call(this, jqxhr, e))
return;
//if (jqxhr.status == 409) {
var mess = '';
- try {
+ try {
if (jqxhr.responseJSON)
- mess = jqxhr.responseJSON.result.message;
- } catch (e) {
+ mess = jqxhr.responseJSON.result.message;
+ } catch (e) {
mess = '';
- epgd.utils.log((e.message || 'common error') + '\n' + (e.stack || '') + '\n options:' + JSON.stringify(options) + '\n jqhr:' + JSON.stringify(jqxhr), 3);
+ epgd.utils.log((e.message || 'common error') + '\n' + (e.stack || '') + '\n options:' + JSON.stringify(options) + '\n jqhr:' + JSON.stringify(jqxhr), 3);
}
epgd.utils.popup(mess || jqxhr.responseText || epgd.tr.error.serverNotResponse, { title: epgd.tr.error.error });
// } else