3 var loadedChannellist = {};
6 var signalPanelData = {};
8 var mediaPlayerStarted = false;
9 var popUpBlockerHinted = false;
12 var parentControlList = null;
14 var requestcounter = 0;
18 var webRemoteWin = '';
21 var currentBouquet = bouquetsTv;
23 var updateBouquetItemsPoller = '';
24 var updateCurrentPoller = '';
25 var signalPanelUpdatePoller = '';
27 var hideNotifierTimeout = '';
30 isActive.getCurrent = false;
32 var currentLocation = "/hdd/movie";
33 var locationsList = [];
38 function startUpdateCurrentPoller(){
39 updateCurrentPoller = setInterval(updateItems, 60000);
42 function stopUpdateCurrentPoller(){
43 clearInterval(updateCurrentPoller);
46 function getXML(request){
49 if(window.ActiveXObject){ // we're on IE
50 xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
52 xmlDoc.loadXML(request.responseText);
53 } else { //we're not on IE
54 if (!window.google || !google.gears){
55 xmlDoc = request.responseXML;
56 } else { //no responseXML on gears
57 xmlDoc = (new DOMParser()).parseFromString(request.responseText, "text/xml");
64 * Set boxtype Variable for being able of determining model specific stuff correctly (like WebRemote)
66 function incomingDeviceInfoBoxtype(request){
67 debug("[incomingAboutBoxtype] returned");
68 boxtype = getXML(request).getElementsByTagName("e2devicename").item(0).firstChild.data;
70 debug("[incomingAboutBoxtype] Boxtype: " + boxtype);
74 function getBoxtype(){
75 doRequest(URL.deviceinfo, incomingDeviceInfoBoxtype, false);
78 function toggleStandby(){
82 function incomingPowerState(request){
83 var standby = getXML(request).getElementsByTagName("e2instandby").item(0).firstChild.data;
85 var signal = $('openSignalPanel');
86 var signalImg = $('openSignalPanelImg');
88 if(standby.strip() == "false"){
89 signal.stopObserving('click', openSignalPanel);
90 signal.observe('click', openSignalPanel);
92 signalImg.src = "/web-data/img/signal.png";
93 signalImg.title = "Show Signal Panel";
96 signal.stopObserving('click', openSignalPanel);
98 signalImg.src = "/web-data/img/signal_off.png";
99 signalImg.title = "Please disable standby first";
103 function getPowerState(){
104 doRequest(URL.powerstate, incomingPowerState);
107 function set(element, value){
108 element = parent.$(element);
110 element.innerHTML = value;
114 function hideNotifier(){
115 $('notification').fade({duration : 0.5 });
118 function notify(text, state){
119 notif = $('notification');
122 //clear possibly existing hideNotifier timeout of a previous notfication
123 clearTimeout(hideNotifierTimeout);
125 notif.style.background = "#C00";
127 notif.style.background = "#85C247";
130 set('notification', "<div>"+text+"</div>");
131 notif.appear({duration : 0.5, to: 0.9 });
132 hideNotifierTimeout = setTimeout(hideNotifier, 7500);
137 function simpleResultHandler(simpleResult){
138 notify(simpleResult.statetext, simpleResult.state);
142 function startUpdateBouquetItemsPoller(){
143 debug("[startUpdateBouquetItemsPoller] called");
144 updateBouquetItemsPoller = setInterval(updateItemsLazy, 300000);
148 function stopUpdateBouquetItemsPoller(){
149 debug("[stopUpdateBouquetItemsPoller] called");
150 clearInterval(updateBouquetItemsPoller);
155 function parseNr(num) {
164 function dec2hex(nr, len){
166 var hex = parseInt(nr, 10).toString(16).toUpperCase();
169 while(hex.length < len){
174 //something went wrong, return -1
182 function quotes2html(txt) {
183 if(typeof(txt) != "undefined"){
184 return txt.escapeHTML().replace('\n', '<br>');
190 function addLeadingZero(nr){
197 function dateToString(date){
201 dateString += date.getFullYear();
202 dateString += "-" + addLeadingZero(date.getMonth()+1);
203 dateString += "-" + addLeadingZero(date.getDate());
204 dateString += " " + addLeadingZero(date.getHours());
205 dateString += ":" + addLeadingZero(date.getMinutes());
211 function showhide(id){
213 s.display = (s.display!="none")? "none":"";
219 $(id).style.display = "";
221 debug("[show] Could not show element with id: " + id);
228 $(id).style.display = "none";
230 debug("[hide] Could not hide element with id: " + id);
236 * Sets the Loading Notification to the given HTML Element
237 * @param targetElement - The element the Ajax-Loader should be set in
239 function setAjaxLoad(targetElement){
240 $(targetElement).innerHTML = getAjaxLoad();
244 //Ajax Request Helpers
247 function requestIndicatorUpdate(){
248 /*debug(requestcounter+" open requests");
249 if(requestcounter>=1){
250 $('RequestIndicator').style.display = "inline";
252 $('RequestIndicator').style.display = "none";
256 function requestStarted(){
258 requestIndicatorUpdate();
261 function requestFinished(){
263 requestIndicatorUpdate();
266 //Popup And Messagebox Helpers
267 function messageBox(m){
272 function popUpBlockerHint(){
273 if(!popUpBlockerHinted){
274 popUpBlockerHinted = true;
275 messageBox("Please disable your Popup-Blocker for enigma2 WebControl to work flawlessly!");
280 function setWindowContent(window, html){
281 window.document.write(html);
282 window.document.close();
285 function openPopup(title, html, width, height, x, y){
287 var popup = window.open('about:blank',title,'scrollbars=yes, width='+width+',height='+height);
288 setWindowContent(popup, html);
296 function openPopupPage(title, uri, width, height, x, y){
298 var popup = window.open(uri,title,'scrollbars=yes, width='+width+',height='+height);
306 function debug(text){
307 var DBG = userprefs.data.debug || false;
311 if(!debugWin.closed && debugWin.location){
312 var inner = debugWin.document.getElementById('debugContent').innerHTML;
313 debugWin.document.getElementById('debugContent').innerHTML = new Date().toLocaleString() + ": "+text+"<br>" + inner;
317 setTimeout( function(){
318 var inner = debugWin.document.getElementById('debugContent').innerHTML;
319 debugWin.document.getElementById('debugContent').innerHTML = new Date().toLocaleString() + ": "+text+"<br>" + inner;
324 } catch (Exception) {}
328 function saveSettings(){
331 var debug = $('enableDebug').checked;
332 if(typeof(debug) != "undefined"){
333 if( userprefs.data.debug != debug ){
334 userprefs.data.debug = debug;
348 function saveTpl(request, tplName){
349 debug("[saveTpl] saving template: " + tplName);
350 templates[tplName] = request.responseText;
354 function renderTpl(tpl, data, domElement) {
355 var result = tpl.process(data);
358 $(domElement).innerHTML = result;
360 // debug("[renderTpl] exception: " + ex);
365 function fetchTpl(tplName, callback){
366 if(typeof(templates[tplName]) == "undefined") {
367 var url = URL.tpl+tplName+".htm";
372 saveTpl(transport, tplName);
373 if(typeof(callback) == 'function'){
379 if(typeof(callback) == 'function'){
385 function incomingProcessTpl(request, data, domElement, callback){
386 if(request.readyState == 4){
387 renderTpl(request.responseText, data, domElement);
388 if(typeof(callback) == 'function') {
394 function processTpl(tplName, data, domElement, callback){
395 var url = URL.tpl+tplName+".htm";
399 incomingProcessTpl(transport, data, domElement, callback);
407 function openDebug(){
408 var uri = URL.tpl+'tplDebug.htm';
409 debugWin = openPopupPage("Debug", uri, 500, 300);
412 function doRequest(url, readyFunction){
415 // gears or not that's the question here
416 if (!window.google || !google.gears){ //no gears, how sad
417 // debug("NO GEARS!!");
419 request = new Ajax.Request(url,
423 requestHeaders: ['Pragma', 'no-cache', 'Cache-Control', 'no-cache', 'Cache-Control', 'no-store', 'Expires', '0'],
424 onException: function(o,e){ throw(e); },
425 onSuccess: function (transport, json) {
426 if(typeof(readyFunction) != "undefined"){
427 readyFunction(transport);
430 onComplete: requestFinished
433 } else { //we're on gears!
435 request = google.gears.factory.create('beta.httprequest');
436 request.open('GET', url);
438 if( typeof(readyFunction) != "undefined" ){
439 request.onreadystatechange = function(){
440 if(request.readyState == 4){
441 if(request.status == 200){
442 readyFunction(request);
444 //we COULD do some error handling here
455 function incomingParentControl(request) {
456 if(request.readyState == 4){
457 parentControlList = new ServiceList(getXML(request)).getArray();
458 debug("[incomingParentControl] Got "+parentControlList.length + " services");
462 function getParentControl() {
463 doRequest(URL.parentcontrol, incomingParentControl, false);
467 function getParentControlByRef(txt) {
468 debug("[getParentControlByRef] ("+txt+")");
469 for(var i = 0; i < parentControlList.length; i++) {
470 debug( "[getParentControlByRef] "+parentControlList[i].getClearServiceReference() );
471 if(String(parentControlList[i].getClearServiceReference()) == String(txt)) {
472 return parentControlList[i].getClearServiceReference();
480 function getSettingByName(txt) {
481 debug("[getSettingByName] (" + txt + ")");
482 for(var i = 0; i < settings.length; i++) {
483 debug("("+settings[i].getSettingName()+") (" +settings[i].getSettingValue()+")");
484 if(String(settings[i].getSettingName()) == String(txt)) {
485 return settings[i].getSettingValue().toLowerCase();
491 function parentPin(servicereference) {
492 debug("[parentPin] parentControlList");
493 servicereference = decodeURIComponent(servicereference);
494 if(parentControlList === null || String(getSettingByName("config.ParentalControl.configured")) != "true") {
497 //debug("parentPin " + parentControlList.length);
498 if(getParentControlByRef(servicereference) == servicereference) {
499 if(String(getSettingByName("config.ParentalControl.type.value")) == "whitelist") {
500 debug("[parentPin] Channel in whitelist");
504 debug("[parentPin] sRef differs ");
507 debug("[parentPin] Asking for PIN");
509 var userInput = prompt('Parental Control is enabled!<br> Please enter the Parental Control PIN','PIN');
510 if (userInput !== '' && userInput !== null) {
511 if(String(userInput) == String(getSettingByName("config.ParentalControl.servicepin.0")) ) {
514 return parentPin(servicereference);
522 function incomingGetDreamboxSettings(request){
523 if(request.readyState == 4){
524 settings = new Settings(getXML(request)).getArray();
526 debug("[incomingGetDreamboxSettings] config.ParentalControl.configured="+ getSettingByName("config.ParentalControl.configured"));
528 if(String(getSettingByName("config.ParentalControl.configured")) == "true") {
535 function getDreamboxSettings(){
536 doRequest(URL.settings, incomingGetDreamboxSettings, false);
541 function incomingSubServiceRequest(request){
542 if(request.readyState == 4){
543 var services = new ServiceList(getXML(request)).getArray();
544 debug("[incomingSubServiceRequest] Got " + services.length + " SubServices");
546 if(services.length > 1) {
548 var first = services[0];
550 // we already have the main service in our servicelist so we'll
551 // start with the second element
554 var data = { subservices : services };
557 var id = 'SUB'+first.servicereference;
559 processTpl('tplSubServices', data, id);
565 function getSubServices(bouquet) {
566 doRequest(URL.subservices, incomingSubServiceRequest, false);
570 function delayedGetSubservices(){
571 setTimeout(getSubServices, 5000);
575 function zap(servicereference){
576 doRequest("/web/zap?sRef=" + servicereference);
577 setTimeout(updateItemsLazy, 7000); //reload epg and subservices
578 setTimeout(updateItems, 3000);
583 function updateSignalPanel(){
584 var html = templates.tplSignalPanel.process(signalPanelData);
586 if (!signalWin.closed && signalWin.location) {
587 setWindowContent(signalWin, html);
589 clearInterval(signalPanelUpdatePoller);
590 signalPanelUpdatePoller = '';
594 function incomingSignalPanel(request){
597 if (request.readyState == 4){
598 var xml = getXML(request).getElementsByTagName("e2frontendstatus").item(0);
600 snrdb : xml.getElementsByTagName('e2snrdb').item(0).firstChild.data,
601 snr : xml.getElementsByTagName('e2snr').item(0).firstChild.data,
602 ber : xml.getElementsByTagName('e2ber').item(0).firstChild.data,
603 acg : xml.getElementsByTagName('e2acg').item(0).firstChild.data
607 signalPanelData = { signal : namespace };
608 fetchTpl('tplSignalPanel', updateSignalPanel);
611 function reloadSignalPanel(){
612 doRequest(URL.signal, incomingSignalPanel, false);
615 function openSignalPanel(){
616 if (!(!signalWin.closed && signalWin.location)){
617 signalWin = openPopup('SignalPanel', '', 220, 120);
618 if(signalPanelUpdatePoller === ''){
619 signalPanelUpdatePoller = setInterval(reloadSignalPanel, 5000);
628 function showEpgList(){
629 var html = templates.tplEpgList.process(epgListData);
631 if (!EPGListWin.closed && EPGListWin.location) {
632 setWindowContent(EPGListWin, html);
634 EPGListWin = openPopup("EPG", html, 900, 500);
638 function incomingEPGrequest(request){
639 debug("[incomingEPGrequest] readyState" +request.readyState);
640 if (request.readyState == 4){
641 var EPGItems = new EPGList(getXML(request)).getArray(true);
642 debug("[incomingEPGrequest] got "+EPGItems.length+" e2events");
644 if( EPGItems.length > 0){
645 epgListData = {epg : EPGItems};
646 fetchTpl('tplEpgList', showEpgList);
648 messageBox('No Items found!', 'Sorry but I could not find any EPG Content containing your search value');
653 function loadEPGBySearchString(string){
654 doRequest(URL.epgsearch+escape(string),incomingEPGrequest, false);
657 function loadEPGByServiceReference(servicereference){
658 doRequest(URL.epgservice+servicereference,incomingEPGrequest, false);
661 function buildServiceListEPGItem(epgevent, type){
662 var data = { epg : epgevent,
665 // e.innerHTML = RND(tplServiceListEPGItem, namespace);
667 var id = type + epgevent.servicereference;
671 if(typeof(templates.tplServiceListEPGItem) != "undefined"){
672 renderTpl(templates.tplServiceListEPGItem, data, id, true);
674 debug("[buildServiceListEPGItem] tplServiceListEPGItem N/A");
678 function incomingServiceEPGNowNext(request, type){
679 if(request.readyState == 4){
680 var epgevents = getXML(request).getElementsByTagName("e2eventlist").item(0).getElementsByTagName("e2event");
681 for (var c = 0; c < epgevents.length; c++){
683 var epgEvt = new EPGEvent(epgevents.item(c), c).toJSON();
685 debug("[incomingServiceEPGNowNext]" + e);
688 if (epgEvt.eventid != ''){
689 buildServiceListEPGItem(epgEvt, type);
695 function incomingServiceEPGNow(request){
696 incomingServiceEPGNowNext(request, 'NOW');
699 function incomingServiceEPGNext(request){
700 incomingServiceEPGNowNext(request, 'NEXT');
703 function loadServiceEPGNowNext(servicereference, next){
704 var url = URL.epgnow+servicereference;
706 if(typeof(next) == 'undefined'){
707 doRequest(url, incomingServiceEPGNow, false);
709 url = URL.epgnext+servicereference;
710 doRequest(url, incomingServiceEPGNext, false);
715 function getBouquetEpg(){
716 loadServiceEPGNowNext(currentBouquet);
717 loadServiceEPGNowNext(currentBouquet, true);
721 function recordNowPopup(){
722 var result = confirm(
723 "OK: Record current event\n" +
724 "Cancel: Start infinite recording"
727 if( result === true || result === false){
728 recordNowDecision(result);
733 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
734 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
735 //++++ volume functions ++++
736 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
737 //+++++++++++++++++++++++++++++++++++++++++++++++++++++
738 function handleVolumeRequest(request){
739 if (request.readyState == 4) {
740 var b = getXML(request).getElementsByTagName("e2volume");
741 var newvalue = b.item(0).getElementsByTagName('e2current').item(0).firstChild.data;
742 var mute = b.item(0).getElementsByTagName('e2ismuted').item(0).firstChild.data;
743 debug("[handleVolumeRequest] Volume " + newvalue + " | Mute: " + mute);
745 for (var i = 1; i <= 10; i++) {
746 if ( (newvalue/10)>=i){
747 $("volume"+i).src = "/web-data/img/led_on.png";
749 $("volume"+i).src = "/web-data/img/led_off.png";
752 if (mute == "False"){
753 $("speaker").src = "/web-data/img/speak_on.png";
755 $("speaker").src = "/web-data/img/speak_off.png";
761 function getVolume(){
762 doRequest(URL.getvolume, handleVolumeRequest, false);
765 function volumeSet(val){
766 doRequest(URL.setvolume+val, handleVolumeRequest, false);
770 doRequest(URL.volumeup, handleVolumeRequest, false);
773 function volumeDown(){
774 doRequest(URL.volumedown, handleVolumeRequest, false);
777 function volumeMute(){
778 doRequest(URL.volumemute, handleVolumeRequest, false);
781 function initVolumePanel(){
787 //Channels and Bouquets
789 function incomingChannellist(request){
790 var serviceList = null;
791 if(typeof(loadedChannellist[currentBouquet]) != "undefined"){
792 serviceList = loadedChannellist[currentBouquet];
793 } else if(request.readyState == 4) {
794 serviceList = new ServiceList(getXML(request)).getArray();
795 debug("[incomingChannellist] got "+serviceList.length+" Services");
797 if(serviceList !== null) {
798 var data = { services : serviceList };
800 processTpl('tplServiceList', data, 'contentServices', getBouquetEpg);
801 delayedGetSubservices();
803 debug("[incomingChannellist] services is null");
808 function loadBouquet(servicereference, name){
809 debug("[loadBouquet] called");
811 currentBouquet = servicereference;
814 setAjaxLoad('contentServices');
816 startUpdateBouquetItemsPoller();
817 doRequest(URL.getservices+servicereference, incomingChannellist, true);
822 function incomingBouquetListInitial(request){
823 if (request.readyState == 4) {
824 var bouquetList = new ServiceList(getXML(request)).getArray();
825 debug("[incomingBouquetListInitial] Got " + bouquetList.length + " TV Bouquets!");
827 // loading first entry of TV Favorites as default for ServiceList
831 loadBouquet(bouquetList[0].servicereference, bouquetList[0].servicename);;
838 function incomingBouquetList(request, callback){
839 if (request.readyState == 4) {
840 var bouquetList = new ServiceList(getXML(request)).getArray();
841 debug("[incomingBouquetList] got " + bouquetList.length + " TV Bouquets!");
842 var data = { bouquets : bouquetList };
844 if( $('contentBouquets') != "undefined" && $('contentBouquets') != null ){
845 processTpl('tplBouquetList', data, 'contentBouquets');
846 if(typeof(callback) == 'function')
850 'tplBouquetsAndServices',
854 processTpl('tplBouquetList', data, 'contentBouquets');
855 if(typeof(callback) == 'function')
864 function initChannelList(){
865 var url = URL.getservices+encodeURIComponent(bouquetsTv);
866 currentBouquet = bouquetsTv;
868 doRequest(url, incomingBouquetListInitial, true);
874 function initMovieList(){
875 // get videodirs, last_videodir, and all tags
876 doRequest(URL.getcurrlocation, incomingMovieListCurrentLocation, false);
879 function incomingMovieListCurrentLocation(request){
880 if(request.readyState == 4){
881 result = new SimpleXMLList(getXML(request), "e2location");
882 currentLocation = result.getList()[0];
883 debug("[incomingMovieListCurrentLocation].currentLocation" + currentLocation);
884 doRequest(URL.getlocations, incomingMovieListLocations, false);
888 function incomingMovieListLocations(request){
889 if(request.readyState == 4){
890 result = new SimpleXMLList(getXML(request), "e2location");
891 locationsList = result.getList();
893 if (locationsList.length === 0) {
894 locationsList = ["/hdd/movie"];
896 doRequest(URL.gettags, incomingMovieListTags, false);
900 function incomingMovieListTags(request){
901 if(request.readyState == 4){
902 result = new SimpleXMLList(getXML(request), "e2tag");
903 tagsList = result.getList();
907 function createOptionListSimple(lst, selected) {
908 var namespace = Array();
912 for (i = 0; i < lst.length; i++) {
913 if (lst[i] == selected) {
919 lst = [ selected ].concat(lst);
922 for (i = 0; i < lst.length; i++) {
926 'selected': (lst[i] == selected ? "selected" : " ")};
932 function loadMovieNav(){
935 dirname: createOptionListSimple(locationsList, currentLocation),
936 tags: createOptionListSimple(tagsList, "")
939 processTpl('tplNavMovies', data, 'navContent');
942 function incomingMovieList(request){
943 if(request.readyState == 4){
945 var movieList = new MovieList(getXML(request)).getArray();
946 debug("[incomingMovieList] Got "+movieList.length+" movies");
948 var data = { movies : movieList };
949 processTpl('tplMovieList', data, 'contentMain');
953 function loadMovieList(loc, tag){
954 if(typeof(loc) == 'undefined'){
955 loc = currentLocation;
957 if(typeof(tag) == 'undefined'){
960 debug("[loadMovieList] Loading movies in location '"+loc+"' with tag '"+tag+"'");
961 doRequest(URL.movielist+"?dirname="+loc+"&tag="+tag, incomingMovieList, false);
965 function incomingDelMovieResult(request) {
966 debug("[incomingDelMovieResult] called");
967 if(request.readyState == 4){
968 var result = new SimpleXMLResult(getXML(request));
969 if(result.getState()){
972 simpleResultHandler(result);
977 function delMovie(sref ,servicename, title, description) {
978 debug("[delMovie] File(" + unescape(sref) + "), servicename(" + servicename + ")," +
979 "title(" + unescape(title) + "), description(" + description + ")");
981 result = confirm( "Are you sure want to delete the Movie?\n" +
982 "Servicename: " + servicename + "\n" +
983 "Title: " + unescape(title) + "\n" +
984 "Description: " + description + "\n");
987 debug("[delMovie] ok confirm panel");
988 doRequest(URL.moviedelete+"?sRef="+unescape(sref), incomingDelMovieResult, false);
992 debug("[delMovie] cancel confirm panel");
997 //Send Messages and Receive the Answer
1000 function incomingMessageResult(request){
1001 if(request.readyState== 4){
1002 var result = new SimpleXMLResult(getXML(request));
1003 simpleResultHandler(result);
1007 function getMessageAnswer() {
1008 doRequest(URL.messageanswer, incomingMessageResult, false);
1011 function sendMessage(messagetext, messagetype, messagetimeout){
1013 messagetext = $('MessageSendFormText').value;
1015 if(!messagetimeout){
1016 messagetimeout = $('MessageSendFormTimeout').value;
1019 var index = $('MessageSendFormType').selectedIndex;
1020 messagetype = $('MessageSendFormType').options[index].value;
1022 if(parseNr(messagetype) === 0){
1023 doRequest(URL.message+'?text='+messagetext+'&type='+messagetype+'&timeout='+messagetimeout);
1024 setTimeout(getMessageAnswer, parseNr(messagetimeout)*1000);
1026 doRequest(URL.message+'?text='+messagetext+'&type='+messagetype+'&timeout='+messagetimeout, incomingMessageResult, false);
1032 function getScreenShot(what) {
1033 debug("[getScreenShot] called");
1035 var buffer = new Image();
1039 buffer.onload = function () {
1040 debug("[getScreenShot] image assigned");
1042 data = { img : { src : buffer.src } };
1043 processTpl('tplGrab', data, 'contentMain');
1048 buffer.onerror = function (meldung) {
1049 debug("[getScreenShot] Loading image failed");
1065 downloadStart = new Date().getTime();
1066 buffer.src = '/grab?format=jpg&r=720&' + what + '&filename=/tmp/' + downloadStart;
1069 function getVideoShot() {
1073 function getOsdShot(){
1077 //RemoteControl Code
1079 function incomingRemoteControlResult(request){
1080 // if(request.readyState == 4){
1081 // var b = getXML(request).getElementsByTagName("e2remotecontrol");
1082 // var result = b.item(0).getElementsByTagName('e2result').item(0).firstChild.data;
1083 // var resulttext = b.item(0).getElementsByTagName('e2resulttext').item(0).firstChild.data;
1087 function openWebRemote(){
1088 var template = templates.tplWebRemoteOld;
1090 if(boxtype == "dm8000"){
1091 template = templates.tplWebRemote;
1095 if (!webRemoteWin.closed && webRemoteWin.location) {
1096 setWindowContent(webRemoteWin, template);
1098 webRemoteWin = openPopup('WebRemote', template, 250, 600);
1104 function loadAndOpenWebRemote(){
1105 if(boxtype == "dm8000"){
1106 fetchTpl('tplWebRemote', openWebRemote);
1109 fetchTpl('tplWebRemoteOld', openWebRemote);
1114 function sendRemoteControlRequest(command){
1115 doRequest(URL.remotecontrol+'?command='+command, incomingRemoteControlResult, false);
1116 if(webRemoteWin.document.getElementById('getScreen').checked) {
1117 if(webRemoteWin.document.getElementById('getVideo').checked){
1126 // Array.insert( index, value ) - Insert value at index, without overwriting existing keys
1127 Array.prototype.insert = function( j, v ) {
1129 var a = this.slice(), b = a.splice( j );
1131 return a.concat( b );
1135 //Array.splice() - Remove or replace several elements and return any deleted
1137 if( typeof Array.prototype.splice==='undefined' ) {
1138 Array.prototype.splice = function( a, c ) {
1139 var e = arguments, d = this.copy(), f = a, l = this.length;
1145 for( var i = 0; i < e.length - 2; i++ ) {
1146 this[a + i] = e[i + 2];
1150 for( var j = a; j < l - c; j++ ) {
1151 this[j + e.length - 2] = d[j - c];
1153 this.length -= c - e.length + 2;
1155 return d.slice( f, f + c );
1159 function ifChecked(rObj) {
1169 * Handles an incoming request for /web/deviceinfo Parses the Data, and calls
1170 * everything needed to render the Template using the parsed data and set the
1171 * result into contentMain @param request - the XHR
1173 function incomingDeviceInfo(request) {
1174 if(request.readyState == 4){
1175 debug("[incomingDeviceInfo] called");
1176 var deviceInfo = new DeviceInfo(getXML(request));
1178 processTpl('tplDeviceInfo', deviceInfo, 'contentMain');
1184 * Show Device Info Information in contentMain
1186 function showDeviceInfo() {
1187 doRequest(URL.deviceinfo, incomingDeviceInfo, false);
1190 function showGears(){
1191 var enabled = false;
1193 if (window.google && google.gears){
1194 enabled = gearsEnabled();
1197 data = { 'useGears' : enabled };
1198 processTpl('tplGears', data, 'contentMain');
1201 function showSettings(){
1202 var debug = userprefs.data.debug;
1203 var debugChecked = "";
1205 debugChecked = 'checked';
1208 data = { 'debug' : debugChecked };
1209 processTpl('tplSettings', data, 'contentMain');
1213 // Spezial functions, mostly for testing purpose
1214 function openHiddenFunctions(){
1215 openPopup("Extra Hidden Functions",tplExtraHiddenFunctions,300,100,920,0);
1219 function startDebugWindow() {
1221 debugWin = openPopup("DEBUG", "", 300, 300,920,140, "debugWindow");
1225 function restartTwisted() {
1226 doRequest( "/web/restarttwisted" );
1231 function sendMediaPlayer(command) {
1232 debug("[sendMediaPlayer] called");
1233 doRequest( URL.mediaplayercmd+command );
1237 function incomingMediaPlayer(request){
1238 if(request.readyState == 4){
1239 var files = new FileList(getXML(request)).getArray();
1241 debug("[loadMediaPlayer] Got "+files.length+" entries in mediaplayer filelist");
1242 // listerHtml = tplMediaPlayerHeader;
1246 var root = files[0].getRoot();
1247 if (root != "playlist") {
1248 namespace = {'root': root};
1250 var re = new RegExp(/(.*)\/(.*)\/$/);
1252 var newroot = RegExp.$1+'/';
1253 if(newroot == '//') {
1258 'servicereference': newroot,
1259 'exec': 'loadMediaPlayer',
1260 'exec_description': 'Change to directory ../',
1268 var itemnamespace = Array();
1269 for ( var i = 0; i <files.length; i++){
1270 var file = files[i];
1271 if(file.getNameOnly() == '') {
1274 var exec = 'loadMediaPlayer';
1275 var exec_description = 'Change to directory' + file.getServiceReference();
1276 var color = '000000';
1279 if (file.getIsDirectory() == "False") {
1281 exec_description = 'play file';
1286 itemnamespace[i] = {
1288 'servicereference': file.getServiceReference(),
1290 'exec_description': exec_description,
1292 'root': file.getRoot(),
1293 'name': file.getNameOnly()
1298 if (root == "playlist") {
1299 listerHtml += tplMediaPlayerFooterPlaylist;
1303 var data = { mp : namespace,
1304 items: itemnamespace
1307 processTpl('tplMediaPlayer', data, 'contentMain');
1308 var sendMediaPlayerTMP = sendMediaPlayer;
1309 sendMediaPlayer = false;
1310 // setBodyMainContent('BodyContent');
1311 sendMediaPlayer = sendMediaPlayerTMP;
1316 function loadMediaPlayer(directory){
1317 debug("[loadMediaPlayer] called");
1318 if(typeof(directory) == 'undefined') directory = 'Filesystems';
1319 doRequest(URL.mediaplayerlist+directory, incomingMediaPlayer, false);
1323 function playFile(file,root) {
1324 debug("[playFile] called");
1325 mediaPlayerStarted = true;
1326 doRequest( URL.mediaplayerplay+file+"&root="+root );
1330 function deleteFile(sref) {
1331 debug("[deleteFile] called");
1332 mediaPlayerStarted = true;
1333 doRequest( URL.mediaplayerremove+sref );
1337 function openMediaPlayerPlaylist() {
1338 debug("[openMediaPlayerPlaylist] called");
1339 doRequest(URL.mediaplayerlist+"playlist", incomingMediaPlayer, false);
1343 function writePlaylist() {
1344 debug("[writePlaylist] called");
1346 filename = prompt("Please enter a name for the playlist", "");
1348 if(filename !== "") {
1349 doRequest( URL.mediaplayerwrite+filename );
1355 * Sets the Powerstate @param newState - the new Powerstate Possible Values
1356 * (also see WebComponents/Sources/PowerState.py) #-1: get current state # 0:
1357 * toggle standby # 1: poweroff/deepstandby # 2: rebootdreambox # 3:
1360 function sendPowerState(newState){
1361 doRequest( URL.powerstate+'?newstate='+newState, incomingPowerState);
1365 //Currently Running Service
1366 function incomingCurrent(request){
1367 // debug("[incomingCurrent called]");
1368 if(request.readyState == 4){
1370 var epg = new EPGList(getXML(request)).getArray();
1373 var data = { current : epg };
1375 if(typeof(templates.tplCurrent) != "undefined"){
1376 var display = 'none';
1378 var display = $('trExtCurrent').style.display;
1381 renderTpl(templates.tplCurrent, data, "currentContent");
1382 $('trExtCurrent').style.display = display;
1384 debug("[incomingCurrent] tplCurrent N/A");
1389 isActive.getCurrent = false;
1394 function getCurrent(){
1395 if(!isActive.getCurrent){
1396 isActive.getCurrent = true;
1397 doRequest(URL.getcurrent, incomingCurrent, false);
1402 //Navigation and Content Helper Functions
1405 * Loads all Bouquets for the given enigma2 servicereference and sets the
1406 * according contentHeader @param sRef - the Servicereference for the bouquet to
1409 function getBouquets(sRef){
1410 var url = URL.getservices+encodeURIComponent(sRef);
1412 doRequest(url, incomingBouquetList, true);
1416 * Loads another navigation template and sets the navigation header
1417 * @param template - The name of the template
1418 * @param title - The title to set for the navigation
1420 function reloadNav(template, title){
1421 setAjaxLoad('navContent');
1422 processTpl(template, null, 'navContent');
1426 function reloadNavDynamic(fnc, title){
1427 setAjaxLoad('navContent');
1432 function getBouquetsTv(){
1433 getBouquets(bouquetsTv);
1436 function getProviderTv(){
1437 getBouquets(providerTv);
1440 function getSatellitesTv(){
1441 getBouquets(satellitesTv);
1444 function getAllTv(){
1445 loadBouquet(allTv, "All (TV)");
1449 function getBouquetsRadio(){
1450 getBouquets(bouquetsRadio);
1453 function getProviderRadio(){
1454 getBouquets(providerRadio);
1457 function getSatellitesRadio(){
1458 getBouquets(satellitesRadio);
1461 function getAllRadio(){
1462 loadBouquet(allRadio, "All (Radio)");
1466 * Loads dynamic content to $(contentMain) by calling a execution function
1467 * @param fnc - The function used to load the content
1468 * @param title - The Title to set on the contentpanel
1470 function loadContentDynamic(fnc, title, domid){
1471 if(typeof(domid) != "undefined" && $(domid) != null){
1474 setAjaxLoad('contentMain');
1476 setContentHd(title);
1477 stopUpdateBouquetItemsPoller();
1483 * like loadContentDynamic but without the AjaxLoaderAnimation being shown
1485 function reloadContentDynamic(fnc, title){
1486 setContentHd(title);
1491 * Loads a static template to $(contentMain)
1492 * @param template - Name of the Template
1493 * @param title - The Title to set on the Content-Panel
1495 function loadContentStatic(template, title){
1496 setAjaxLoad('contentMain');
1497 setContentHd(title);
1498 stopUpdateBouquetItemsPoller();
1499 processTpl(template, null, 'contentMain');
1504 * Opens the given Control
1505 * @param control - Control Page as String
1506 * Possible Values: power, extras, message, screenshot, videoshot, osdshot
1508 function loadControl(control){
1511 loadContentStatic('tplPower', 'PowerControl');
1515 loadContentStatic('tplSendMessage', 'Send a Message');
1519 loadAndOpenWebRemote();
1523 loadContentDynamic(getScreenShot, 'Screenshot');
1527 loadContentDynamic(getVideoShot, 'Videoshot');
1531 loadContentDynamic(getOsdShot, 'OSDshot');
1540 function loadDeviceInfo(){
1541 loadContentDynamic(showDeviceInfo, 'Device Information');
1544 function loadAbout(){
1545 loadContentStatic('tplAbout', 'About');
1548 function loadSettings(){
1549 loadContentDynamic(showSettings, 'Settings');
1552 function loadGearsInfo(){
1553 loadContentDynamic(showGears, 'Google Gears');
1556 function reloadGearsInfo(){
1557 loadContentDynamic(showGears, 'Google Gears');
1562 * Switches Navigation Modes
1563 * @param mode - The Navigation Mode you want to switch to
1564 * Possible Values: TV, Radio, Movies, Timer, Extras
1566 function switchMode(mode){
1569 reloadNav('tplNavTv', 'TeleVision');
1573 reloadNav('tplNavRadio', 'Radio');
1578 reloadNavDynamic(loadMovieNav, 'Movies');
1581 loadContentDynamic(loadMovieList, 'Movies');
1586 reloadNav('tplNavTimer', 'Timer');
1589 loadContentDynamic(loadTimerList, 'Timer');
1593 loadContentDynamic(loadMediaPlayer, 'MediaPlayer');
1597 reloadNav('tplNavBoxControl', 'BoxControl');
1601 reloadNav('tplNavExtras', 'Extras');
1609 function openWebTV(){
1610 window.open('/web-data/streaminterface.html', 'WebTV', 'scrollbars=no, width=800, height=730');
1615 function updateItems(){
1620 function updateItemsLazy(bouquet){
1626 * Does the everything required on initial pageload
1630 var DBG = userprefs.data.debug || false;
1635 if (typeof document.body.style.maxHeight == "undefined") {
1636 alert("Due to the tremendous amount of work needed to get everthing to " +
1637 "work properly, there is (for now) no support for Internet Explorer Versions below 7");
1642 setAjaxLoad('navContent');
1643 setAjaxLoad('contentMain');
1645 fetchTpl('tplServiceListEPGItem');
1646 fetchTpl('tplBouquetsAndServices');
1647 fetchTpl('tplCurrent');
1648 reloadNav('tplNavTv', 'TeleVision');
1655 startUpdateCurrentPoller();