1 var Controller = Class.create({
2 initialize: function(handler){
3 this.handler = handler;
4 this.handler.onFinished.push(this.registerEvents.bind(this));
5 this.handler.onFinished.push(this.onFinished.bind(this));
6 this.eventsregistered = false;
9 registerEvents: function(){
10 this.eventsregistered = true;
13 onFinished: function(){}
16 var Bouquets = Class.create(Controller, {
17 initialize: function($super, targetBouquets, targetMain){
18 $super(new BouquetListHandler(targetBouquets, targetMain));
19 this.loadFirstOnFinished = false;
22 load: function(sRef, loadFirstOnFinished){
23 if(loadFirstOnFinished)
24 this.loadFirstOnFinished = true;
25 this.handler.load( {'sRef' : sRef} );
26 var services = $('contentServices');
28 services.update('Please select a bouquet');
32 loadBouquetsTv: function(){
33 setContentHd('Bouquets (TV)');
34 this.load(bouquetsTv);
37 loadProviderTv: function(){
38 setContentHd('Providers (TV)');
39 this.load(providerTv);
42 loadSatellitesTv: function(){
43 setContentHd('Satellites (TV)');
44 this.load(satellitesTv);
47 loadBouquetsRadio: function(){
48 setContentHd('Bouquets (Radio)');
49 this.load(bouquetsRadio);
52 loadProviderRadio: function(){
53 setContentHd('Providers (Radio)');
54 this.load(providerRadio);
57 loadSatellitesRadio: function(){
58 setContentHd('Satellites (Radio)');
59 this.load(satellitesRadio);
62 onFinished: function(){
63 var bouquets = this.handler.data.services;
65 if(this.loadFirstOnFinished || bouquets.length == 1){
66 var bouquet = bouquets[0];
67 setContentHd(bouquet.servicename);
68 this.loadFirstOnFinished = false;
69 hash = core.getBaseHash() + '/' + bouquet.servicereference;
70 hashListener.setHash(hash);
72 var currentBouquet = hashListener.getHash().split('/')[3];
74 bouquets.each(function(bouquet){
75 if(bouquet.servicereference == currentBouquet){
76 setContentHd(bouquet.servicename);
85 var Current = Class.create(Controller, {
86 initialize: function($super, curTarget, volTarget){
87 $super(new CurrentHandler(curTarget, volTarget));
88 this.handler.onFinished[this.handler.onFinished.length] = this.onFinished.bind(this);
89 this.display = 'none';
93 this.handler.load({});
96 toggleVisibility: function(element){
97 var ext = $('trExtCurrent');
99 var bullet = element.down('.currentBulletToggle');
101 bullet.src = '/web-data/img/toggle_expand.png';
105 bullet.src = '/web-data/img/toggle_collapse.png';
109 this.display = ext.style.display;
110 setMaxHeight('contentMain');
114 onFinished: function(){
115 setMaxHeight('contentMain');
116 var ext = $('trExtCurrent');
118 ext.style.display = this.display;
119 var bullet = $('currentName').down('.currentBulletToggle');
121 bullet.src = '/web-data/img/toggle_collapse.png';
124 bullet.src = '/web-data/img/toggle_expand.png';
128 core.currentData = this.handler.data;
132 var Externals = Class.create(Controller, {
133 initialize: function($super, target){
134 $super(new ExternalsHandler(target));
140 this.handler.load({});
142 this.handler.show(this.handler.data);
145 onFinished: function(){
150 var EPG = Class.create(Controller, {
151 initialize: function($super){
152 $super(new EpgListHandler(this.show.bind(this)));
157 var win = core.popup("EPG" + new Date().getTime(), html, 900, 500);
158 this.doRegisterEvents(win);
161 load: function(sRef){
162 this.handler.load({'sRef' : sRef});
165 search: function(needle){
166 this.handler.search({'search' : needle});
169 doRegisterEvents: function(win){
170 var elem = win.document;
171 var onload = function(event){
175 function(event, element){
176 core.timers.addByEventId(element, 0);
183 function(event, element){
184 core.timers.addByEventId(element, 1);
191 function(event, element){
192 var hash = ["#!/timer", "edit"].join("/");
193 hashListener.setHash(hash);
194 core.timers.editFromEvent(element);
207 var MultiEpg = Class.create(Controller, {
208 initialize: function($super){
209 $super(new MultiEpgHandler(this.show.bind(this)));
210 this.tplDetails = "";
213 load: function(bRef){
214 templateEngine.fetch(
217 this.tplDetails = tpl;
222 doLoad: function(bRef){
223 this.handler.load({'bRef' : bRef});
227 var win = core.popup("MultiEpg" + new Date().getTime(), html, 900, 570);
228 this.doRegisterEvents(win);
231 doRegisterEvents: function(win){
232 var elem = win.document;
234 var onload = function(event){
237 // function(event, element){
238 // var tbody = $('mEpgTBody');
239 // var top = tbody.cumulativeOffset().top;
240 // var height = elem.viewport.height - top;
241 // tbody.style.height = height;
242 // console.log(offset);
248 function(event, element){
249 var detail = elem.getElementById('mEpgDetail');
252 e.servicereference = element.readAttribute('data-servicereference');
253 e.servicename = element.readAttribute('data-servicename');
254 e.eventid = element.readAttribute('data-eventid');
255 e.date = element.readAttribute('data-date');
256 e.start = element.readAttribute('data-start');
257 e.starttime = element.readAttribute('data-starttime');
258 e.end = element.readAttribute('data-end');
259 e.endtime = element.readAttribute('data-endtime');
260 e.duration = element.readAttribute('data-duration');
261 e.title = element.readAttribute('data-title');
262 e.description = element.readAttribute('data-description');
263 e.extdescription = element.readAttribute('data-extdescription');
264 var data = {'e' : e};
265 detail.update(_this.tplDetails.process(data));
266 detail.fadeIn({'delay' : 300, 'to' : 95});
274 function(event, element){
275 var detail = elem.getElementById('mEpgDetail');
277 detail.fadeOut({'delay' : 300});
285 function(event, element){
286 core.timers.addByEventId(element, 0);
293 function(event, element){
294 core.timers.addByEventId(element, 1);
301 function(event, element){
302 var hash = ["#!/timer", "edit"].join("/");
303 hashListener.setHash(hash);
304 core.timers.editFromEvent(element);
317 var Power = Class.create({
318 STATES: {'toggle' : 0, 'deep' : 1, 'reboot' : 2, 'gui' : 3},
320 initialize: function(){
321 //As we do not have an real templates here, there is no handler for powerstate.
322 //The Handling is up to the caller of this class
323 this.provider = new PowerstateProvider(this.onLoadFinished.bind(this));
325 this.isLoading = false;
326 this.isStandby = false;
329 load: function(params){
330 this.isLoading = true;
331 this.provider.load(params);
334 onLoadFinished:function (isStandby){
335 this.isStandby = isStandby;
336 this.isLoading = false;
337 var len = this.callbacks.length;
338 for(var i = 0; i < len; i++){
339 callback = this.callbacks.pop();
340 callback(this.isStandby);
344 inStandby: function(callback){
345 this.callbacks.push(callback);
351 set: function(newstate, callback){
352 this.callbacks.push(callback);
353 this.load({'newstate' : this.STATES[newstate]});
357 var LocationsAndTags = Class.create({
358 initialize: function(){
359 this.currentLocation = '';
362 this.isCurrentLocationsLoading = false;
363 this.isCurrentLocationReady = false;
364 this.isLocationsLoading = false;
365 this.isLocationsReady = false;
366 this.isTagsLoading = false;
367 this.isTagsReady = false;
368 this.curLocCallbacks = [];
369 this.locCallbacks = [];
370 this.tagCallbacks = [];
371 this.locTagCallbacks = [];
373 this.curlocprovider = new CurrentLocationProvider(this.onCurrentLocationAvailable.bind(this));
374 this.locprovider = new LocationProvider(this.onLocationsAvailable.bind(this));
375 this.tagprovider = new TagProvider(this.onTagsAvailable.bind(this));
378 getCurrentLocation: function(callback){
379 if(this.isCurrentLocationReady){
380 callback(this.currentLocation);
382 this.curLocCallbacks[this.curLocCallbacks.length] = callback;
383 if(!this.isCurrentLocationLoading){
384 this.curlocprovider.load({});
385 this.isCurrentLocationLoading = true;
390 onCurrentLocationAvailable: function(currentLocation){
391 debug("[LocationsAndTags].onCurrentLocationAvailable");
392 this.isCurrentLocationReady = true;
393 this.isCurrentLocationLoading = false;
394 this.currentLocation = currentLocation;
395 var len = this.curLocCallbacks.length;
396 for(var i = 0; i < len; i++){
397 callback = this.curLocCallbacks.pop();
398 callback(this.currentLocation);
400 this.onLocationsOrTagsAvailable();
403 getLocations: function(callback){
404 if(this.isLocationsReady){
405 callback(this.locations);
407 this.locCallbacks[this.locCallbacks.length] = callback;
408 if(!this.isLocationsLoading){
409 this.locprovider.load({});
410 this.isLocationsLoading = true;
415 onLocationsAvailable: function(locations){
416 debug("[LocationsAndTags].onLocationsAvailable");
417 this.isLocationsReady = true;
418 this.isLocationsLoading = false;
419 this.locations = locations.getList();
420 var len = this.locCallbacks.length;
421 for(var i = 0; i < len; i++){
422 callback = this.locCallbacks.pop();
423 callback(this.locations);
425 this.onLocationsOrTagsAvailable();
428 getTags: function(callback){
429 if(this.isTagsReady){
432 this.tagCallbacks[this.tagCallbacks.length] = callback;
433 if(!this.isTagsLoading){
434 this.tagprovider.load({});
435 this.isTagsLoading = true;
440 onTagsAvailable: function(tags){
441 debug("[LocationsAndTags].onTagsAvailable");
442 this.isTagsReady = true;
443 this.isTagsLoading = false;
444 this.tags = tags.getList();
445 var len = this.tagCallbacks.length;
446 for(var i = 0; i < len; i++){
447 callback = this.tagCallbacks.pop();
450 this.onLocationsOrTagsAvailable();
453 getLocationsAndTags: function(callback){
454 if(this.isCurrentLocationReady && this.isLocationsReady && this.isTagsReady){
455 callback(this.currentLocation, this.locations, this.tags);
457 this.locTagCallbacks[this.locTagCallbacks.length] = callback;
458 if(!this.isCurrentLocationLoading)
459 this.curlocprovider.load({});
460 if(!this.isLocationsLoading)
461 this.locprovider.load({});
462 if(!this.isTagsLoading)
463 this.tagprovider.load({});
467 onLocationsOrTagsAvailable: function(){
468 if(this.isCurrentLocationReady && this.isLocationsReady && this.isTagsReady){
469 var len = this.locTagCallbacks.length;
470 for(var i = 0; i < len; i++){
471 callback = this.locTagCallbacks.pop();
472 callback(this.currentLocation, this.locations, this.tags);
478 var MediaPlayer = Class.create(Controller, {
479 initialize: function($super, target){
480 $super(new MediaPlayerHandler(target));
483 load: function(path){
485 path = 'Filesystems';
487 var parms = {'path' : path};
488 this.handler.load(parms);
491 playFile: function(file){
492 this.handler.playFile(file);
495 addFile: function(file){
496 this.handler.addFile(file);
499 removeFile: function(file){
500 this.handler.removeFile(file);
503 savePlaylist: function(filename){
504 this.handler.savePlaylist(filename);
507 command: function(cmd){
508 this.handler.command(cmd);
512 var Messages = Class.create({
513 initialize: function(){
514 this.handler = new SimpleRequestHandler();
517 send: function(text, type, timeout){
518 this.handler.load(URL.message, {'text' : text, 'type' : type, 'timeout' : timeout});
522 var Movies = Class.create(Controller, {
523 initialize: function($super, listTarget, navTarget){
524 $super(new MovieListHandler(listTarget));
525 this.navHandler = new MovieNavHandler(navTarget);
528 load: function(location, tags){
530 var sethash = function(location){
531 var hash = [core.getBaseHash(), "filter", encodeURIComponent(location), encodeURIComponent(tags)].join("/");
532 hashListener.setHash(hash);
534 if(core.currentLocation == ""){ //wait for currentLocation to be set;
535 core.lt.getCurrentLocation(sethash);
537 sethash(core.currentLocation);
542 this.handler.load({'dirname' : location, 'tag' : tags});
546 core.lt.getLocationsAndTags(this.showNav.bind(this));
549 showNav: function(currentLocation, locations, tags){
550 this.navHandler.load(toOptionList(locations, currentLocation), toOptionList(tags, core.currentTag));
553 del: function(element){
554 this.handler.del(element);
558 var RemoteControl = Class.create({
559 initialize: function(){
560 this.handler = new RemoteControlHandler();
567 if (this.window.closed || !this.window.location){
569 switch(core.deviceInfo.info.devicename){
572 tpl = 'tplWebRemote';
575 tpl = 'tplWebRemoteOld';
578 templateEngine.fetch(tpl, function(template){
579 this.eventsregistered = false;
580 this.window = core.popup('WebRemote', template, 250, 600);
581 this.registerEvents();
586 sendKey: function(cmd, type, shotType){
587 debug("[RemoteControl].sendKey: " + cmd);
588 this.handler.sendKey({'command' : cmd, 'type': type});
590 var hash = '!/control'; //FIXME
596 hash = [hash, 'osdshot'].join("/");
599 hash = [hash, 'screenshot'].join("/");
602 //the box needs at least a little bit of time to actually draw the window
603 //wait 250ms before fetching a new screenshot
606 hashListener.setHash(hash);
607 if(hash == hashListener.getHash()){
608 core.onHashChanged(true);
614 registerEvents:function(){
616 var win = this.window;
617 var elem = win.document;
619 var onload = function(event){
623 function(event, element){
624 var id = element.readAttribute('data-keyid');
625 var long = _this.window.document.getElementById('long').checked;
626 var screenshot = _this.window.document.getElementById('screenshot').checked;
627 var video = _this.window.document.getElementById('video').checked;
632 var shotType = 'none';
633 if(screenshot && video){
635 } else if (screenshot && !video) {
638 _this.sendKey(id, type, shotType);
650 var Screenshots = Class.create(Controller, {
655 initialize: function($super, target){
656 $super(new ScreenshotHandler(target));
659 load: function(type){
660 var filename = '/tmp/' + new Date().getTime();
661 var params = {'format' : 'jpg', 'r': '720', 'filename' : filename};
667 params['format'] = 'png';
669 case this.TYPE_VIDEO:
675 this.handler.load(params);
678 shootOsd: function(){
679 setContentHd('Screenshot (OSD)');
680 this.load(this.TYPE_OSD);
683 shootVideo: function(){
684 setContentHd('Screenshot (Video)');
685 this.load(this.TYPE_VIDEO);
688 shootAll: function(){
689 setContentHd('Screenshot (All)');
690 this.load(this.TYPE_ALL);
694 var Services = Class.create(Controller, {
695 initialize: function($super, target, epg){
696 $super(new ServiceListHandler(target));
698 this.cachedServiceElements = null;
701 zap: function(sRef, callback){
702 this.handler.zap({'sRef' : sRef}, callback);
705 load: function(sRef){
706 this.handler.load({'bRef' : sRef});
709 getNowNext: function(){
710 this.handler.getNowNext();
713 getSubservices: function(){
714 this.handler.getSubservices();
717 loadAll: function(ref){
718 var tpl = 'tplBouquetsAndServices';
719 var fnc = function(){
720 $('contentBouquets').update('All Services');
724 if($('contentBouquets')){
727 templateEngine.process(
736 loadAllTv: function(){
738 setContentHd("All (Tv)");
741 loadAllRadio: function(){
742 this.loadAll(allRadio);
743 setContentHd("All (Radio)");
746 onFilterFocus: function(event){
747 event.element().value = '';
748 this.cachedServiceElements = null;
752 filter: function(event){
753 var needle = event.element().value.toLowerCase();
755 if(this.cachedServiceElements == null){
756 this.cachedServiceElements = $$('.sListRow');
759 for(var i = 0; i < this.cachedServiceElements.length; i++){
760 var row = this.cachedServiceElements[i];
761 var serviceName = row.readAttribute('data-servicename').toLowerCase();
763 if(serviceName.match(needle) != needle && serviceName != ""){
771 addFilterInput: function(){
772 var input = new Element('input');
773 input.id = 'serviceFilter';
774 input.value = 'Filter Services';
775 $('contentHdExt').update(input);
776 input.on('focus', this.onFilterFocus.bind(this));
777 input.on('keyup', this.filter.bind(this));
780 onFinished: function(){
781 this.addFilterInput();
782 core.startUpdateBouquetItemsPoller();
786 var SignalWindow = Class.create(Controller, {
787 initialize: function($super, seconds){
788 $super(new SignalHandler(this.show.bind(this)));
790 if(!isNaN(Number(seconds))){
791 this.seconds = seconds * 1000;
799 this.handler.load({});
803 debug('[SignalWindow].reload');
804 if (!this.window.closed && this.window.location){
807 clearInterval(this.interval);
811 show: function(html){
812 debug('[SignalWindow].show');
813 if (this.window.closed || !this.window.location){
814 this.window = core.popup("SignalPanel", html, 220, 120);
815 this.window.onbeforeunload = function(){
816 clearInterval(this.interval);
820 clearInterval(_this.interval);
821 this.interval = setInterval(_this.reload.bind(this), _this.seconds);
822 } else if(!this.window.closed && this.window.location) {
823 this.window.document.write(html);
824 this.window.document.close();
829 var SimplePages = Class.create({
830 PAGE_ABOUT : 'tplAbout',
831 PAGE_MESSAGE : 'tplSendMessage',
832 PAGE_POWER : 'tplPower',
833 PAGE_SETTINGS: 'tplSettings',
834 PAGE_TOOLS: 'tplTools',
836 initialize: function(target){
837 this.simpleHandler = new SimplePageHandler(target);
838 this.deviceInfoHandler = new DeviceInfoHandler(target);
841 show: function(tpl, data){
844 this.simpleHandler.show(tpl, data);
847 loadAbout: function(){
848 setContentHd('About');
849 this.show(this.PAGE_ABOUT);
852 loadMessage: function(){
853 setContentHd('Message');
854 this.show(this.PAGE_MESSAGE);
857 loadPower: function(){
858 setContentHd('PowerControl');
859 this.show(this.PAGE_POWER);
862 loadSettings: function(){
863 setContentHd('Settings');
864 var debug = userprefs.data.debug;
865 var debugChecked = "";
867 debugChecked = 'checked';
870 var updateCurrentInterval = userprefs.data.updateCurrentInterval / 1000;
871 var updateBouquetInterval = userprefs.data.updateBouquetInterval / 1000;
873 data = {'debug' : debugChecked,
874 'updateCurrentInterval' : updateCurrentInterval,
875 'updateBouquetInterval' : updateBouquetInterval
877 this.show(this.PAGE_SETTINGS, data);
880 loadTools: function(){
881 setContentHd('Tools');
882 this.show(this.PAGE_TOOLS);
885 loadDeviceInfo: function(){
886 setContentHd('Device Info');
887 this.deviceInfoHandler.load({});
890 getDeviceInfo: function(callback){
891 this.deviceInfoHandler.get({}, callback);
895 var Timers = Class.create({
896 initialize: function(target){
897 this.listHandler = new TimerListHandler(target);
898 this.timerHandler = new TimerHandler(target, this.loadList.bind(this), [this.onTimerEditLoadFinished.bind(this)]);
901 loadList: function(){
902 this.listHandler.load({});
905 cleanupList: function(){
906 this.listHandler.cleanup();
910 this.timerHandler.load({}, false, true);
913 edit: function(element){
914 this.timerHandler.load(element, true);
917 editFromEvent: function(element){
918 this.timerHandler.load(element, false, false, true);
921 save: function(element){
922 this.timerHandler.commitForm(element);
925 onBouquetChanged: function(bRef){
926 this.timerHandler.onBouquetChanged(bRef, this.onUpdatedServiceListReady.bind(this));
929 onUpdatedServiceListReady: function(data, timer){
930 var serviceSel = $('service');
931 var options = serviceSel.options;
935 data.services.each(function(s){
936 var selected = false;
937 if(timer.servicereference == unescape(s.servicereference)){
940 options.add ( new Option(s.servicename, s.servicereference, false, selected) );
945 recordNow: function(type, callback){
946 this.timerHandler.recordNow(type, callback);
949 addByEventId: function(element, justplay){
950 var parent = element.up('.epgListItem');
951 var sRef = unescape(parent.readAttribute('data-servicereference'));
952 var eventId = unescape(parent.readAttribute('data-eventid'));
953 this.timerHandler.addByEventId(sRef, eventId, justplay);
956 toggleDisabled: function(element){
957 this.timerHandler.toggleDisabled(element);
960 del: function(element){
961 this.timerHandler.del(element);
964 onTimerEditLoadFinished: function(){
965 debug("[Timers].onTimerEditLoadFinished");
966 datePickerController.destroyDatePicker('sdate');
967 datePickerController.destroyDatePicker('edate');
968 var today = new Date();
969 var pad = function(value, length) {
970 length = length || 2;
971 return "0000".substr(0,length - Math.min(String(value).length, length)) + value;
976 rangeLow: today.getFullYear() + "" + pad(today.getMonth()+1) + pad(today.getDate())
980 opts['formElements'] = { 'sdate' : 'Y-ds-m-ds-d'};
981 datePickerController.createDatePicker(opts);
983 opts['formElements'] = { 'edate' : 'Y-ds-m-ds-d'};
984 datePickerController.createDatePicker(opts);
989 var Volume = Class.create(Controller, {
990 initialize: function($super, target){
991 $super(new VolumeHandler(target));
995 this.handler.load({});
998 set: function(value){
999 this.handler.load({'set' : value});
1003 var E2WebCore = Class.create({
1004 initialize: function(){
1005 this.mediaPlayerStarted = false;
1006 this.popUpBlockerHinted = false;
1007 this.settings = null;
1008 this.parentControlList = null;
1011 this.signalWin = '';
1012 this.webRemoteWin = '';
1013 this.EPGListWin = '';
1015 this.currentBouquet = bouquetsTv;
1017 this.updateBouquetItemsPoller = '';
1018 this.updateCurrentPoller = '';
1019 this.signalPanelUpdatePoller = '';
1021 this.hideNotifierTimeout = '';
1024 this.isActive.getCurrent = false;
1029 //create required Instances
1030 this.bouquets = new Bouquets('contentBouquets', 'contentMain');
1031 this.current = new Current('currentContent', 'volContent');
1032 this.externals = new Externals('navExternalsContainer');
1033 this.epg = new EPG(new EpgListHandler());
1034 this.lt = new LocationsAndTags();
1035 this.mediaplayer = new MediaPlayer('contentMain');
1036 this.messages = new Messages();
1037 this.movies = new Movies('contentMain', 'navContent');
1038 this.multiepg = new MultiEpg();
1039 this.power = new Power();
1040 this.remote = new RemoteControl();
1041 this.screenshots = new Screenshots('contentMain');
1042 this.services = new Services('contentServices', this.epg);
1043 this.signal = new SignalWindow(3);
1044 this.simplepages = new SimplePages('contentMain');
1045 this.timers = new Timers('contentMain');
1046 this.volume = new Volume('volContent');
1048 this.currentData = {};
1049 this.currentLocation = this.lt.getCurrentLocation(function(location){this.currentLocation = location;}.bind(this));
1050 this.currentTag = "";
1051 this.deviceInfo = this.simplepages.getDeviceInfo(function(info){this.deviceInfo = info;}.bind(this));
1055 'bouquets' : this.bouquets.loadBouquetsTv.bind(this.bouquets),
1056 'providers' : this.bouquets.loadProviderTv.bind(this.bouquets),
1057 'all' : this.services.loadAllTv.bind(this.services)
1060 'bouquets' : this.bouquets.loadBouquetsRadio.bind(this.bouquets),
1061 'providers' : this.bouquets.loadProviderRadio.bind(this.bouquets),
1062 'all' : this.services.loadAllRadio.bind(this.services)
1065 'list' : function(){}
1068 'create' : this.timers.create.bind(this.timers),
1070 'list' : function() { this.loadContentDynamic(this.timers.loadList.bind(this.timers), 'Timer'); }.bind(this)
1073 'message' : this.simplepages.loadMessage.bind(this.simplepages),
1074 'power' : this.simplepages.loadPower.bind(this.simplepages),
1075 'osdshot' : this.screenshots.shootOsd.bind(this.screenshots),
1076 'screenshot' : this.screenshots.shootAll.bind(this.screenshots),
1077 'videoshot' : this.screenshots.shootVideo.bind(this.screenshots)
1080 'about' : this.simplepages.loadAbout.bind(this.simplepages),
1081 'deviceinfo' : this.simplepages.loadDeviceInfo.bind(this.simplepages),
1082 'mediaplayer' : function() { this.loadContentDynamic(this.mediaplayer.load.bind(this.mediaplayer), 'MediaPlayer'); }.bind(this),
1083 'settings' : this.simplepages.loadSettings.bind(this.simplepages),
1084 'tools' : this.simplepages.loadTools.bind(this.simplepages)
1089 hideNotifier: function(){
1090 debug("[E2WebCore].hideNotifier");
1091 $('notification').fadeOut(500);
1094 notify: function(text, state){
1095 debug("[E2WebCore].notify");
1096 notif = $('notification');
1098 //clear possibly existing hideNotifier timeout of a previous notfication
1099 clearTimeout(this.hideNotifierTimeout);
1100 if(state === false){
1101 notif.style.background = "#C00";
1103 notif.style.background = "#85C247";
1105 this.set('notification', "<div>"+text+"</div>");
1106 notif.fadeIn({'delay' : 500, 'to' : 90});
1108 this.hideNotifierTimeout = setTimeout(_this.hideNotifier.bind(this), 5000);
1112 set: function(element, value){
1113 element = parent.$(element);
1115 element.update(value);
1119 setAjaxLoad: function(targetElement){
1120 target = $(targetElement);
1122 target.update( getAjaxLoad() );
1126 messageBox: function(message){
1130 popUpBlockerHint: function(){
1131 if(!this.popUpBlockerHinted){
1132 this.popUpBlockerHinted = true;
1133 this.messageBox("Please disable your Popup-Blocker for enigma2 WebControl to work flawlessly!");
1138 setWindowContent: function(window, html){
1139 window.document.write(html);
1140 window.document.close();
1143 popup: function(title, html, width, height, x, y){
1145 var popup = window.open('about:blank',title,'scrollbars=yes, width='+width+',height='+height);
1146 this.setWindowContent(popup, html);
1149 this.popUpBlockerHint();
1154 updateItems: function(){
1155 debug("[E2WebCore].updateItems");
1156 this.current.load();
1157 this.power.inStandby(this.onPowerStateAvailable.bind(this));
1160 onPowerStateAvailable: function(isStandby){
1162 $('openSignalPanelImg').src="/web-data/img/transmit_grey.png";
1164 $('openSignalPanelImg').src="/web-data/img/transmit_blue.png";
1168 updateItemsLazy: function(){
1169 debug("[E2WebCore].updateItemsLazy");
1170 this.services.getNowNext();
1171 this.services.getSubservices();
1174 startUpdateCurrentPoller: function(){
1175 debug("[E2WebCore].startUpdateCurrentPoller");
1176 clearInterval(this.updateCurrentPoller);
1178 this.updateCurrentPoller = setInterval(_this.updateItems.bind(this), userprefs.data.updateCurrentInterval);
1181 stopUpdateCurrentPoller: function(){
1182 clearInterval(this.updateCurrentPoller);
1185 startUpdateBouquetItemsPoller: function(){
1186 debug("[E2WebCore].startUpdateBouquetItemsPoller");
1187 clearInterval(this.updateBouquetItemsPoller);
1189 this.updateBouquetItemsPoller = setInterval(_this.updateItemsLazy.bind(this), userprefs.data.updateBouquetInterval);
1192 stopUpdateBouquetItemsPoller: function(){
1193 debug("[E2WebCore].stopUpdateBouquetItemsPoller");
1194 clearInterval(this.updateBouquetItemsPoller);
1197 onHashChanged: function(isReload){
1198 var hash = hashListener.getHash();
1199 var parts = hash.split("/");
1201 var len = parts.length;
1203 var mode = parts[1];
1204 if(mode != this.mode || isReload || ( len <= 2 && this.subMode != '') ){
1205 this.switchMode(mode, len == 2);
1210 var subMode = parts[2];
1211 if(subMode != this.subMode || isReload){
1212 this.subMode = subMode;
1213 if(!this.navlut[this.mode][this.subMode]){
1216 if(this.mode != "movies")
1217 this.navlut[this.mode][this.subMode]();
1224 this.services.load(unescape(parts[3]));
1227 var location = decodeURIComponent(parts[4]);
1228 var tag = decodeURIComponent(parts[5]);
1230 this.currentLocation = location;
1231 this.currentTag = tag;
1232 this.loadContentDynamic(
1234 this.movies.load(location, tag);
1241 if(subMode == 'mediaplayer'){
1242 this.mediaplayer.load(decodeURIComponent(parts[3]));
1253 getBaseHash: function(){
1254 var hash = ['#!', this.mode].join("/");
1255 if(this.subMode != ''){
1256 hash = [hash, this.subMode].join("/");
1261 loadDefault: function(){
1262 debug("[E2WebCore].loadDefault");
1263 this.switchMode('tv');
1265 this.subMode = 'bouquets';
1266 this.bouquets.load(bouquetsTv, true);
1270 debug("[E2WebCore].run");
1271 if( parseNr(userprefs.data.updateCurrentInterval) < 10000){
1272 userprefs.data.updateCurrentInterval = 120000;
1276 if( parseNr(userprefs.data.updateBouquetInterval) < 60000 ){
1277 userprefs.data.updateBouquetInterval = 300000;
1281 if (typeof document.body.style.maxHeight == undefined) {
1282 alert("Due to the tremendous amount of work needed to get everthing to " +
1283 "work properly, there is (for now) no support for Internet Explorer Versions below 7");
1285 hashListener.onHashChanged = this.onHashChanged.bind(this);
1286 hashListener.init();
1288 this.registerEvents();
1290 this.setAjaxLoad('navContent');
1291 this.setAjaxLoad('contentMain');
1293 templateEngine.fetch('tplServiceListEPGItem');
1294 templateEngine.fetch('tplBouquetsAndServices');
1295 templateEngine.fetch('tplCurrent');
1296 if(!hashListener.getHash().length >= 1){
1300 this.startUpdateCurrentPoller();
1303 registerEvents: function(){
1304 debug("[E2WebCore].registerEvents");
1306 //HACK :: THIS IS EVIL VOODOO, DON'T TRY THIS AT HOME!
1310 function(event, element){
1311 var parts = element.href.split('#');
1312 var curHost = window.location.href.split('#')[0];
1313 //Don't do this crazy stuff when the target is another host!
1314 if(curHost == parts[0]){
1315 if (parts.length > 1){
1317 if(window.location == element.href){
1318 this.onHashChanged(true);
1321 window.location == element.href;
1325 element.href = window.location;
1333 $('openSignalPanel').on(
1335 function(event, element){
1340 $('instantRecord').on(
1342 function(event, element){
1343 var menu = $('instantRecordMenu');
1355 function(event, element){
1356 var menu = $('instantRecordMenu');
1357 this.timers.recordNow(
1358 element.readAttribute('data-type'),
1368 '.currentExtShowHide',
1369 function(event, element){
1370 this.current.toggleVisibility(element);
1377 function(event, element){
1378 var ref = unescape( element.readAttribute('data-servicereference') );
1384 $('epgSearchForm').on(
1386 function(event, element){
1387 this.epg.search($F('epgSearch'));
1393 function(event, element){
1397 $('epgSearchClear').on(
1399 function(event, element){
1400 $('epgSearch').value = '';
1405 var changeevt = Prototype.Browser.IE ? "click" : "change";
1406 var nav = $('navContent');
1410 function(event, element){
1411 var l = $('locations');
1413 var location = l.options[l.selectedIndex].value;
1414 var tag = t.options[t.selectedIndex].value;
1415 var hash = [this.getBaseHash(), "filter", encodeURIComponent(location), encodeURIComponent(tag)].join("/");
1416 if(hash != '#'+hashListener.getHash() || !Prototype.Browser.IE)
1417 hashListener.setHash(hash);
1424 this.remote.open.bind(this.remote)
1430 function(event, element){
1431 this.volume.set(element.readAttribute('data-volume'));
1437 var content = $('contentMain');
1442 function(event, element){
1443 this.mediaplayer.command(element.readAttribute('data-command'));
1449 function(event, element){
1450 var parent = element.up('.mpListItem');
1451 var ref = decodeURIComponent( parent.readAttribute('data-servicereference') );
1452 this.mediaplayer.playFile(ref);
1459 function(event, element){
1460 var parent = element.up('.mpListItem');
1461 var ref = decodeURIComponent( parent.readAttribute('data-servicereference') );
1462 this.mediaplayer.addFile(ref);
1469 function(event, element){
1470 var parent = element.up('.mpListItem');
1471 var ref = decodeURIComponent( parent.readAttribute('data-servicereference') );
1472 this.mediaplayer.removeFile(ref);
1479 function(event, element){
1480 var filename = prompt('Please enter a filename for the playlist', 'playlist');
1481 if(filename != null && filename != ""){
1482 this.mediaplayer.savePlaylist(filename);
1490 function(event, element){
1491 var t = $('messageType');
1492 text = $('messageText').value;
1493 timeout = $('messageTimeout').value;
1494 type = t.options[t.selectedIndex].value;
1495 this.messages.send(text, type, timeout);
1502 function(event, element){
1503 this.movies.del(element);
1511 function(event, element){
1512 var cb = function(isStandby){
1513 var text = "Device is now Running";
1515 text = "Device is now in Standby";
1516 this.notify(text, true);
1517 this.onPowerStateAvailable(isStandby);
1519 this.power.set(element.readAttribute("data-state"), cb);
1526 function(event, element){
1527 this.saveSettings();
1534 function(event, element){
1535 setContentHd(element.readAttribute("data-servicename"));
1541 function(event, element){
1542 var sref = decodeURIComponent( element.readAttribute("data-servicereference") );
1543 this.multiepg.load(sref);
1552 function(event, element){
1553 var ref = decodeURIComponent( element.id );
1554 this.services.zap(ref, this.updateItems.bind(this));
1560 'a.sListServiceEpg',
1561 function(event, element){
1562 var ref = unescape( element.readAttribute('data-servicereference') );
1570 function(event, element){
1571 var target = element.up('.sListEPGItem').down('.sListExtEpgLong');
1574 var bullet = element.down('.sListBulletToggle');
1575 if(target.visible()){
1577 bullet.src = "/web-data/img/toggle_expand_small.png";
1581 bullet.src = "/web-data/img/toggle_collapse_small.png";
1591 function(event, element){
1592 core.timers.addByEventId(element, 0);
1599 function(event, element){
1600 core.timers.addByEventId(element, 1);
1607 function(event, element){
1608 var hash = ["#!/timer", "edit"].join("/");
1609 hashListener.setHash(hash);
1610 core.timers.editFromEvent(element);
1619 function(event, element){
1620 this.timers.del(element);
1626 '.tListToggleDisabled',
1627 function(event, element){
1628 this.timers.toggleDisabled(element);
1635 function(event, element){
1636 var hash = ["#!/timer", "edit"].join("/");
1637 hashListener.setHash(hash);
1638 this.timers.edit(element);
1645 function(event, element){
1646 this.timers.cleanupList();
1654 function(event, element){
1655 var days = ['mo', 'tu', 'we', 'th', 'fr', 'sa', 'su'];
1656 var weekdays = days.slice(0,5);
1660 var checked = element.checked;
1661 weekdays.each(function(day){
1662 $(day).checked = checked;
1665 var others = ['sa', 'su', 'ms'];
1666 others.each(function(item){
1667 $(item).checked = false;
1672 var checked = element.checked;
1673 days.each(function(day){
1674 $(day).checked = checked;
1677 $('mf').checked = false;
1681 var weekdays = true;
1683 days.each(function(day){
1685 if(day.value <= 64){
1688 if(day.value <= 16){
1700 $('mf').checked = false;
1701 $('ms').checked = true;
1702 } else if (weekdays) {
1703 $('mf').checked = true;
1704 $('ms').checked = false;
1706 $('mf').checked = false;
1707 $('ms').checked = false;
1715 function(event, element){
1716 var value = unescape( element.options[element.selectedIndex].value );
1717 core.timers.onBouquetChanged(value);
1723 function(event, element){
1724 var selected = 'selected';
1725 var attr = 'data-selected';
1726 if(element.hasClassName(selected)){
1727 element.removeClassName(selected);
1728 element.writeAttribute(attr, '');
1730 element.addClassName(selected);
1731 element.writeAttribute(attr, selected);
1739 function(event, element){
1740 this.timers.save($('timerEditForm'));
1746 function(event, element){
1747 window.open('/web-data/tpl/default/streaminterface/index.html', 'WebTV', 'scrollbars=no, width=800, height=740');
1754 * Loads another navigation template and sets the navigation header
1755 * @param template - The name of the template
1756 * @param title - The title to set for the navigation
1758 reloadNav: function(template, title, callback){
1759 this.setAjaxLoad('navContent');
1760 templateEngine.process(template, null, 'navContent', callback);
1764 reloadNavDynamic: function(fnc, title){
1765 this.setAjaxLoad('navContent');
1771 * Loads dynamic content to $(contentMain) by calling a execution function
1772 * @param fnc - The function used to load the content
1773 * @param title - The Title to set on the contentpanel
1775 loadContentDynamic: function(fnc, title){
1776 setContentHd(title);
1777 this.stopUpdateBouquetItemsPoller();
1782 * Loads a static template to $(contentMain)
1783 * @param template - Name of the Template
1784 * @param title - The Title to set on the Content-Panel
1786 loadContentStatic: function(template, title){
1787 this.setAjaxLoad('contentMain');
1788 setContentHd(title);
1789 this.stopUpdateBouquetItemsPoller();
1790 templateEngine.process(template, null, 'contentMain');
1793 setEmptyContent: function(id, text){
1794 $(id).update('<div class="block center fullwidth oneliner">' + text + '</div>');
1797 switchMode: function(mode, initContent){
1799 this.setEmptyContent('contentMain', 'please select a submenu on the left...');
1800 setContentHd('...');
1805 if(this.mode != 'tv' && this.mode != 'radio'){
1806 this.services.registerEvents();
1808 this.reloadNav('tplNavTv', 'TeleVision');
1812 if(this.mode != 'TV' && this.mode != 'Radio'){
1813 this.services.registerEvents();
1815 this.reloadNav('tplNavRadio', 'Radio');
1819 this.reloadNavDynamic(this.movies.loadNav.bind(this.movies), 'Movies');
1823 this.reloadNav('tplNavTimer', 'Timer');
1827 this.reloadNav('tplNavBoxControl', 'BoxControl');
1831 this.reloadNav('tplNavExtras', 'Extras', this.externals.load.bind(this.externals));
1839 saveSettings: function(){
1842 var debug = $('enableDebug').checked;
1843 var changed = false;
1844 if(debug != undefined){
1845 if( userprefs.data.debug != debug ){
1846 userprefs.data.debug = debug;
1851 var updateCurrentInterval = parseNr( $F('updateCurrentInterval') ) * 1000;
1852 if( updateCurrentInterval < 10000){
1853 updateCurrentInterval = 120000;
1856 if( userprefs.data.updateCurrentInterval != updateCurrentInterval){
1857 userprefs.data.updateCurrentInterval = updateCurrentInterval;
1860 this.startUpdateCurrentPoller();
1863 var updateBouquetInterval = parseNr( $F('updateBouquetInterval') ) * 1000;
1864 if( updateBouquetInterval < 60000){
1865 updateBouquetInterval = 300000;
1868 if( userprefs.data.updateBouquetInterval != updateBouquetInterval){
1869 userprefs.data.updateBouquetInterval = updateBouquetInterval;
1872 this.startUpdateBouquetItemsPoller();
1877 this.notify("Settings saved");
1879 this.notify("Nothing changed! No need to save!");
1883 core = new E2WebCore();